Révision 2878
| tmp/org.txm.edition.rcp/src/org/txm/edition/rcp/editors/SynopticEditionEditor.java (revision 2878) | ||
|---|---|---|
| 52 | 52 |
import org.eclipse.jface.window.Window; |
| 53 | 53 |
import org.eclipse.osgi.util.NLS; |
| 54 | 54 |
import org.eclipse.swt.SWT; |
| 55 |
import org.eclipse.swt.SWTError; |
|
| 55 | 56 |
import org.eclipse.swt.events.KeyEvent; |
| 56 | 57 |
import org.eclipse.swt.events.KeyListener; |
| 57 | 58 |
import org.eclipse.swt.events.MouseEvent; |
| ... | ... | |
| 95 | 96 |
* |
| 96 | 97 |
*/ |
| 97 | 98 |
public class SynopticEditionEditor extends TXMEditor<Text> implements IEditionEditor {
|
| 98 |
|
|
| 99 |
|
|
| 99 | 100 |
/** The Constant ID. */ |
| 100 | 101 |
public final static String ID = SynopticEditionEditor.class.getName(); |
| 101 |
|
|
| 102 |
|
|
| 102 | 103 |
LinkedHashMap<String, EditionPanel> editionPanels = new LinkedHashMap<>(); |
| 103 |
|
|
| 104 |
|
|
| 104 | 105 |
/** The page_label: show current page name. */ |
| 105 | 106 |
org.eclipse.swt.widgets.Text page_text; |
| 106 |
|
|
| 107 |
|
|
| 107 | 108 |
Label page_label; |
| 108 |
|
|
| 109 |
|
|
| 109 | 110 |
GLComposite editionsArea; |
| 110 |
|
|
| 111 |
|
|
| 111 | 112 |
private List<String> editionNames; |
| 112 |
|
|
| 113 |
|
|
| 113 | 114 |
private CQPCorpus corpus; |
| 114 |
|
|
| 115 |
|
|
| 115 | 116 |
private MainCorpus mainCorpus; |
| 116 |
|
|
| 117 |
|
|
| 117 | 118 |
private Text text; |
| 118 |
|
|
| 119 |
|
|
| 119 | 120 |
private Button editionsChooser; |
| 120 |
|
|
| 121 |
|
|
| 121 | 122 |
// private Label editionsLabel; |
| 122 | 123 |
private GLComposite controlsArea; |
| 123 |
|
|
| 124 |
|
|
| 124 | 125 |
// private GLComposite annotationWidgetsArea; |
| 125 | 126 |
// private TXMEditorToolBar supplementaryButtonToolbar; |
| 126 | 127 |
private ISelectionProvider selProvider; |
| 127 |
|
|
| 128 |
|
|
| 128 | 129 |
private org.eclipse.swt.widgets.Text text_text; |
| 129 |
|
|
| 130 |
|
|
| 130 | 131 |
// private Label text_label; |
| 131 | 132 |
private TXMAutoCompleteField identifiantComboAutoCompleteField; |
| 132 |
|
|
| 133 |
|
|
| 133 | 134 |
// TODO finish editor conversion |
| 134 | 135 |
@Override |
| 135 | 136 |
public Text getResult() {
|
| ... | ... | |
| 138 | 139 |
} |
| 139 | 140 |
return text; |
| 140 | 141 |
} |
| 141 |
|
|
| 142 |
|
|
| 142 | 143 |
/** |
| 143 | 144 |
* Instantiates a new txm browser. |
| 144 | 145 |
*/ |
| 145 | 146 |
public SynopticEditionEditor() {
|
| 146 | 147 |
selProvider = new ISelectionProvider() {
|
| 147 |
|
|
| 148 |
|
|
| 148 | 149 |
@Override |
| 149 | 150 |
public void setSelection(ISelection selection) {}
|
| 150 |
|
|
| 151 |
|
|
| 151 | 152 |
@Override |
| 152 | 153 |
public void removeSelectionChangedListener(ISelectionChangedListener listener) {}
|
| 153 |
|
|
| 154 |
|
|
| 154 | 155 |
@Override |
| 155 | 156 |
public ISelection getSelection() {
|
| 156 | 157 |
ITextSelection sel = new ITextSelection() {
|
| 157 |
|
|
| 158 |
|
|
| 158 | 159 |
@Override |
| 159 | 160 |
public boolean isEmpty() {
|
| 160 | 161 |
for (EditionPanel panel : editionPanels.values()) {
|
| ... | ... | |
| 163 | 164 |
} |
| 164 | 165 |
return true; |
| 165 | 166 |
} |
| 166 |
|
|
| 167 |
|
|
| 167 | 168 |
@Override |
| 168 | 169 |
public String getText() {
|
| 169 | 170 |
for (EditionPanel panel : editionPanels.values()) {
|
| ... | ... | |
| 172 | 173 |
} |
| 173 | 174 |
return EditionUIMessages.CommandLink_empty; |
| 174 | 175 |
} |
| 175 |
|
|
| 176 |
|
|
| 176 | 177 |
@Override |
| 177 | 178 |
public int getStartLine() {
|
| 178 | 179 |
return 0; |
| 179 | 180 |
} |
| 180 |
|
|
| 181 |
|
|
| 181 | 182 |
@Override |
| 182 | 183 |
public int getOffset() {
|
| 183 | 184 |
return 0; |
| 184 | 185 |
} |
| 185 |
|
|
| 186 |
|
|
| 186 | 187 |
@Override |
| 187 | 188 |
public int getLength() {
|
| 188 | 189 |
return 0; |
| 189 | 190 |
} |
| 190 |
|
|
| 191 |
|
|
| 191 | 192 |
@Override |
| 192 | 193 |
public int getEndLine() {
|
| 193 | 194 |
return 0; |
| ... | ... | |
| 195 | 196 |
}; |
| 196 | 197 |
return sel; |
| 197 | 198 |
} |
| 198 |
|
|
| 199 |
|
|
| 199 | 200 |
@Override |
| 200 | 201 |
public void addSelectionChangedListener(ISelectionChangedListener listener) {}
|
| 201 | 202 |
}; |
| 202 |
|
|
| 203 |
|
|
| 203 | 204 |
} |
| 204 |
|
|
| 205 |
|
|
| 205 | 206 |
public void setHighlightWordsById(RGBA color, HashSet<String> wordids) {
|
| 206 | 207 |
for (EditionPanel panel : editionPanels.values()) {
|
| 207 | 208 |
panel.setHighlightWordsById(color, wordids); |
| 208 | 209 |
} |
| 209 | 210 |
} |
| 210 |
|
|
| 211 |
|
|
| 211 | 212 |
public void addHighlightWordsById(RGBA color, String wordid) {
|
| 212 | 213 |
for (EditionPanel panel : editionPanels.values()) {
|
| 213 | 214 |
panel.addHighlightWordsById(color, wordid); |
| 214 | 215 |
} |
| 215 | 216 |
} |
| 216 |
|
|
| 217 |
|
|
| 217 | 218 |
public void addHighlightWordsById(RGBA color, Collection<String> wordids) {
|
| 218 | 219 |
for (EditionPanel panel : editionPanels.values()) {
|
| 219 | 220 |
panel.addHighlightWordsById(color, wordids); |
| 220 | 221 |
} |
| 221 | 222 |
} |
| 222 |
|
|
| 223 |
|
|
| 223 | 224 |
public void removeHighlightWordsById(RGBA color, Collection<String> wordids) {
|
| 224 | 225 |
for (EditionPanel panel : editionPanels.values()) {
|
| 225 | 226 |
if (!panel.isDisposed()) {
|
| ... | ... | |
| 227 | 228 |
} |
| 228 | 229 |
} |
| 229 | 230 |
} |
| 230 |
|
|
| 231 |
|
|
| 231 | 232 |
public void removeHighlightWordsById(RGBA color, String wordid) {
|
| 232 | 233 |
for (EditionPanel panel : editionPanels.values()) {
|
| 233 | 234 |
if (!panel.isDisposed()) {
|
| ... | ... | |
| 235 | 236 |
} |
| 236 | 237 |
} |
| 237 | 238 |
} |
| 238 |
|
|
| 239 |
|
|
| 239 | 240 |
// /** |
| 240 | 241 |
// * |
| 241 | 242 |
// * @param wordids2 all the words to highlight |
| ... | ... | |
| 257 | 258 |
// |
| 258 | 259 |
// |
| 259 | 260 |
// } |
| 260 |
|
|
| 261 |
|
|
| 261 | 262 |
/** |
| 262 | 263 |
* First page. |
| 263 | 264 |
*/ |
| ... | ... | |
| 267 | 268 |
} |
| 268 | 269 |
updatePageLabel(); |
| 269 | 270 |
} |
| 270 |
|
|
| 271 |
|
|
| 271 | 272 |
/** |
| 272 | 273 |
* Last page. |
| 273 | 274 |
*/ |
| ... | ... | |
| 276 | 277 |
panel.lastPage(); |
| 277 | 278 |
updatePageLabel(); |
| 278 | 279 |
} |
| 279 |
|
|
| 280 |
|
|
| 280 | 281 |
/** |
| 281 | 282 |
* Previous page. |
| 282 | 283 |
*/ |
| ... | ... | |
| 285 | 286 |
panel.previousPage(); |
| 286 | 287 |
updatePageLabel(); |
| 287 | 288 |
} |
| 288 |
|
|
| 289 |
|
|
| 289 | 290 |
/** |
| 290 | 291 |
* Next page. |
| 291 | 292 |
*/ |
| ... | ... | |
| 294 | 295 |
panel.nextPage(); |
| 295 | 296 |
updatePageLabel(); |
| 296 | 297 |
} |
| 297 |
|
|
| 298 |
|
|
| 298 | 299 |
/** |
| 299 | 300 |
* Direct access to a page with a name. |
| 300 | 301 |
*/ |
| ... | ... | |
| 303 | 304 |
panel.goToPage(name); |
| 304 | 305 |
} |
| 305 | 306 |
updatePageLabel(); |
| 306 |
|
|
| 307 |
|
|
| 307 | 308 |
} |
| 308 |
|
|
| 309 |
|
|
| 309 | 310 |
/** |
| 310 | 311 |
* Direct access to a text with a name. |
| 311 | 312 |
*/ |
| ... | ... | |
| 325 | 326 |
catch (Exception e) {
|
| 326 | 327 |
e.printStackTrace(); |
| 327 | 328 |
} |
| 328 |
|
|
| 329 |
|
|
| 329 | 330 |
Log.info(NLS.bind("No {0} text found.", id));
|
| 330 | 331 |
} |
| 331 |
|
|
| 332 |
|
|
| 332 | 333 |
/** |
| 333 | 334 |
* Previous text. |
| 334 | 335 |
*/ |
| ... | ... | |
| 338 | 339 |
} |
| 339 | 340 |
updatePageLabel(); |
| 340 | 341 |
} |
| 341 |
|
|
| 342 |
|
|
| 342 | 343 |
/** |
| 343 | 344 |
* Next text. |
| 344 | 345 |
*/ |
| ... | ... | |
| 348 | 349 |
} |
| 349 | 350 |
updatePageLabel(); |
| 350 | 351 |
} |
| 351 |
|
|
| 352 |
|
|
| 352 | 353 |
/** |
| 353 | 354 |
* Previous text. |
| 354 | 355 |
*/ |
| ... | ... | |
| 358 | 359 |
} |
| 359 | 360 |
updatePageLabel(); |
| 360 | 361 |
} |
| 361 |
|
|
| 362 |
|
|
| 362 | 363 |
/** |
| 363 | 364 |
* Next text. |
| 364 | 365 |
*/ |
| ... | ... | |
| 368 | 369 |
} |
| 369 | 370 |
updatePageLabel(); |
| 370 | 371 |
} |
| 371 |
|
|
| 372 |
|
|
| 372 | 373 |
public Composite getEditionArea() {
|
| 373 | 374 |
return editionsArea; |
| 374 | 375 |
} |
| 375 |
|
|
| 376 |
|
|
| 376 | 377 |
// public Composite getUpperToolbarArea() {
|
| 377 | 378 |
// return annotationWidgetsArea; |
| 378 | 379 |
// } |
| 379 |
|
|
| 380 |
|
|
| 380 | 381 |
public Composite getLowerToolbarArea() {
|
| 381 | 382 |
return controlsArea; |
| 382 | 383 |
} |
| 383 |
|
|
| 384 |
|
|
| 384 | 385 |
@Override |
| 385 | 386 |
public void _createPartControl() {
|
| 386 |
|
|
| 387 |
|
|
| 387 | 388 |
// remove the compute button |
| 388 | 389 |
this.removeComputeButton(); |
| 389 |
|
|
| 390 |
|
|
| 390 | 391 |
editionsArea = getResultArea(); |
| 391 |
|
|
| 392 |
|
|
| 392 | 393 |
controlsArea = getBottomToolbar().installGLComposite(EditionUIMessages.controls, 15, false); |
| 393 | 394 |
controlsArea.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, false)); |
| 394 | 395 |
// spacer |
| 395 | 396 |
new Label(controlsArea, SWT.NONE).setText(" "); //$NON-NLS-1$
|
| 396 |
|
|
| 397 |
|
|
| 397 | 398 |
// annotationWidgetsArea = new GLComposite(getBetweenTopToolbarsAndResultComposite(), SWT.NONE, "Edition annotation area"); |
| 398 | 399 |
// this.annotationWidgetsArea.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true, false)); |
| 399 |
|
|
| 400 |
|
|
| 400 | 401 |
// supplementaryButtonToolbar = new TXMEditorToolBar(this, getTopToolbarContainer(), annotationWidgetsArea, SWT.NONE, "annotation urs"); |
| 401 |
|
|
| 402 |
|
|
| 402 | 403 |
// Edition names label |
| 403 | 404 |
editionsChooser = new Button(controlsArea, SWT.PUSH); |
| 404 | 405 |
editionsChooser.setText(StringUtils.join(editionNames, " | ")); //$NON-NLS-1$ |
| 405 |
|
|
| 406 |
|
|
| 406 | 407 |
if (mainCorpus.getProject().getBuiltEditionNames().size() > 1) {
|
| 407 |
|
|
| 408 |
|
|
| 408 | 409 |
editionsChooser.addSelectionListener(new SelectionListener() {
|
| 409 |
|
|
| 410 |
|
|
| 410 | 411 |
@Override |
| 411 | 412 |
public void widgetSelected(SelectionEvent e) {
|
| 412 | 413 |
try {
|
| 413 | 414 |
List<String> availableEditions = mainCorpus.getProject().getBuiltEditionNames(); |
| 414 | 415 |
if (availableEditions.size() == 0) return; |
| 415 | 416 |
if (availableEditions.size() == 1) return; |
| 416 |
|
|
| 417 |
|
|
| 417 |
|
|
| 418 |
|
|
| 418 | 419 |
Shell shell = e.display.getActiveShell(); |
| 419 | 420 |
EditionSelectorDialog d = new EditionSelectorDialog(shell, mainCorpus, editionNames); |
| 420 |
|
|
| 421 |
|
|
| 421 | 422 |
if (d.open() == Window.OK) {
|
| 422 | 423 |
Object[] rez = d.getResult(); |
| 423 | 424 |
editionNames = new ArrayList<>(); |
| 424 | 425 |
for (int i = 0; i < rez.length; i++) {
|
| 425 | 426 |
editionNames.add(rez[i].toString()); |
| 426 | 427 |
} |
| 427 |
|
|
| 428 |
|
|
| 428 | 429 |
editionsChooser.setText(StringUtils.join(editionNames, " | ")); //$NON-NLS-1$ |
| 429 | 430 |
openEditions(text, editionNames); |
| 430 | 431 |
firstPage(); |
| ... | ... | |
| 435 | 436 |
System.out.println(NLS.bind(EditionUIMessages.errorWhileGettingAvailableEditionsColonP0, e2)); |
| 436 | 437 |
} |
| 437 | 438 |
} |
| 438 |
|
|
| 439 |
|
|
| 439 | 440 |
@Override |
| 440 | 441 |
public void widgetDefaultSelected(SelectionEvent e) {}
|
| 441 | 442 |
}); |
| ... | ... | |
| 443 | 444 |
else {
|
| 444 | 445 |
editionsChooser.setEnabled(false); |
| 445 | 446 |
} |
| 446 |
|
|
| 447 |
|
|
| 447 | 448 |
// Navigation buttons |
| 448 | 449 |
GLComposite pageNavigationComposite = new GLComposite(controlsArea, SWT.NONE, EditionUIMessages.pageButtons); |
| 449 | 450 |
pageNavigationComposite.getLayout().numColumns = 6; |
| ... | ... | |
| 455 | 456 |
Button next = new Button(pageNavigationComposite, SWT.FLAT | SWT.PUSH); |
| 456 | 457 |
Button last = new Button(pageNavigationComposite, SWT.FLAT | SWT.PUSH); |
| 457 | 458 |
pageNavigationComposite.setLayoutData(new GridData(GridData.CENTER, GridData.FILL, true, false)); |
| 458 |
|
|
| 459 |
|
|
| 459 | 460 |
GLComposite textNavigationComposite = new GLComposite(controlsArea, SWT.NONE, EditionUIMessages.textButtons); |
| 460 | 461 |
textNavigationComposite.getLayout().numColumns = 7; |
| 461 | 462 |
textNavigationComposite.getLayout().horizontalSpacing = 1; |
| ... | ... | |
| 495 | 496 |
Button lastText = new Button(textNavigationComposite, SWT.FLAT | SWT.PUSH); |
| 496 | 497 |
textNavigationComposite.setLayoutData(new GridData(GridData.CENTER, GridData.FILL, false, false)); |
| 497 | 498 |
// Layouts data |
| 498 |
|
|
| 499 |
|
|
| 499 | 500 |
editionsChooser.setLayoutData(new GridData(GridData.BEGINNING, GridData.CENTER, false, false)); |
| 500 |
|
|
| 501 |
|
|
| 501 | 502 |
// GridData buttonGridData = new GridData(GridData.END,GridData.CENTER, true, false); |
| 502 | 503 |
// buttonGridData.widthHint = 30; |
| 503 | 504 |
// buttonGridData.heightHint = 30; |
| ... | ... | |
| 511 | 512 |
// centerButtonGridData.heightHint = 30; |
| 512 | 513 |
// first.setLayoutData(centerButtonGridData); |
| 513 | 514 |
// previous.setLayoutData(buttonGridData); |
| 514 |
|
|
| 515 |
|
|
| 515 | 516 |
// set sizes |
| 516 | 517 |
GridData gdata = new GridData(GridData.END, GridData.CENTER, false, false); |
| 517 | 518 |
gdata.minimumWidth = 25; |
| 518 | 519 |
gdata.widthHint = 25; |
| 519 |
|
|
| 520 |
|
|
| 520 | 521 |
page_text.setLayoutData(gdata); |
| 521 | 522 |
// page_label.setLayoutData(new GridData(GridData.BEGINNING,GridData.CENTER, false, false)); |
| 522 | 523 |
// |
| ... | ... | |
| 527 | 528 |
// last.setLayoutData(centerButtonGridData); |
| 528 | 529 |
// nextText.setLayoutData(buttonGridData); |
| 529 | 530 |
// lastText.setLayoutData(buttonGridData); |
| 530 |
|
|
| 531 |
|
|
| 531 | 532 |
// if (editionsChooser != null) |
| 532 | 533 |
// editionsChooser.setLayoutData(new GridData(GridData.BEGINNING,GridData.CENTER, false, true)); |
| 533 | 534 |
// else spacer.setLayoutData(new GridData(GridData.END,GridData.CENTER, true, true)); |
| 534 |
|
|
| 535 |
|
|
| 535 | 536 |
// set labels |
| 536 | 537 |
page_label.setText(""); //$NON-NLS-1$
|
| 537 | 538 |
// text_label.setText(""); //$NON-NLS-1$
|
| ... | ... | |
| 551 | 552 |
nextText.setToolTipText(EditionUIMessages.nextText); |
| 552 | 553 |
lastText.setImage(IImageKeys.getImage(IImageKeys.CTRLFASTFORWARDEND)); |
| 553 | 554 |
lastText.setToolTipText(EditionUIMessages.lastTextOfTheCorpus); |
| 554 |
|
|
| 555 |
|
|
| 555 | 556 |
page_text.addKeyListener(new KeyListener() {
|
| 556 |
|
|
| 557 |
|
|
| 557 | 558 |
@Override |
| 558 | 559 |
public void keyReleased(KeyEvent e) {
|
| 559 | 560 |
if (e.keyCode == SWT.CR || e.keyCode == SWT.KEYPAD_CR) {
|
| 560 | 561 |
goToPage(page_text.getText()); |
| 561 | 562 |
} |
| 562 | 563 |
} |
| 563 |
|
|
| 564 |
|
|
| 564 | 565 |
@Override |
| 565 | 566 |
public void keyPressed(KeyEvent e) {}
|
| 566 | 567 |
}); |
| 567 | 568 |
text_text.addKeyListener(new KeyListener() {
|
| 568 |
|
|
| 569 |
|
|
| 569 | 570 |
@Override |
| 570 | 571 |
public void keyReleased(KeyEvent e) {
|
| 571 | 572 |
if (identifiantComboAutoCompleteField.isOpen()) return; |
| 572 |
|
|
| 573 |
|
|
| 573 | 574 |
if (e.keyCode == SWT.CR || e.keyCode == SWT.KEYPAD_CR) {
|
| 574 | 575 |
if (identifiantComboAutoCompleteField.isOpen()) {
|
| 575 | 576 |
return; // ignore keys when content assist is opened |
| 576 | 577 |
} |
| 577 |
|
|
| 578 |
|
|
| 578 | 579 |
goToText(text_text.getText()); |
| 579 | 580 |
} |
| 580 | 581 |
else if (e.keyCode == SWT.ARROW_DOWN) {
|
| ... | ... | |
| 584 | 585 |
previousText(false); |
| 585 | 586 |
} |
| 586 | 587 |
} |
| 587 |
|
|
| 588 |
|
|
| 588 | 589 |
@Override |
| 589 | 590 |
public void keyPressed(KeyEvent e) {}
|
| 590 | 591 |
}); |
| 591 | 592 |
text_text.addMouseWheelListener(new MouseWheelListener() {
|
| 592 |
|
|
| 593 |
|
|
| 593 | 594 |
@Override |
| 594 | 595 |
public void mouseScrolled(MouseEvent e) {
|
| 595 | 596 |
if (identifiantComboAutoCompleteField.isOpen()) {
|
| 596 | 597 |
return; |
| 597 | 598 |
} |
| 598 |
|
|
| 599 |
|
|
| 599 | 600 |
if (e.count > 0) {
|
| 600 | 601 |
previousText(false); |
| 601 | 602 |
} |
| ... | ... | |
| 607 | 608 |
}); |
| 608 | 609 |
// set listeners |
| 609 | 610 |
first.addSelectionListener(new SelectionListener() {
|
| 610 |
|
|
| 611 |
|
|
| 611 | 612 |
@Override |
| 612 | 613 |
public void widgetDefaultSelected(SelectionEvent e) {
|
| 613 | 614 |
firstPage(); |
| 614 | 615 |
} |
| 615 |
|
|
| 616 |
|
|
| 616 | 617 |
@Override |
| 617 | 618 |
public void widgetSelected(SelectionEvent e) {
|
| 618 | 619 |
firstPage(); |
| 619 | 620 |
} |
| 620 | 621 |
}); |
| 621 | 622 |
previous.addSelectionListener(new SelectionListener() {
|
| 622 |
|
|
| 623 |
|
|
| 623 | 624 |
@Override |
| 624 | 625 |
public void widgetDefaultSelected(SelectionEvent e) {
|
| 625 | 626 |
previousPage(); |
| 626 | 627 |
} |
| 627 |
|
|
| 628 |
|
|
| 628 | 629 |
@Override |
| 629 | 630 |
public void widgetSelected(SelectionEvent e) {
|
| 630 | 631 |
previousPage(); |
| 631 | 632 |
} |
| 632 | 633 |
}); |
| 633 | 634 |
next.addSelectionListener(new SelectionListener() {
|
| 634 |
|
|
| 635 |
|
|
| 635 | 636 |
@Override |
| 636 | 637 |
public void widgetDefaultSelected(SelectionEvent e) {
|
| 637 | 638 |
nextPage(); |
| 638 | 639 |
} |
| 639 |
|
|
| 640 |
|
|
| 640 | 641 |
@Override |
| 641 | 642 |
public void widgetSelected(SelectionEvent e) {
|
| 642 | 643 |
nextPage(); |
| 643 | 644 |
} |
| 644 | 645 |
}); |
| 645 | 646 |
last.addSelectionListener(new SelectionListener() {
|
| 646 |
|
|
| 647 |
|
|
| 647 | 648 |
@Override |
| 648 | 649 |
public void widgetDefaultSelected(SelectionEvent e) {
|
| 649 | 650 |
lastPage(); |
| 650 | 651 |
} |
| 651 |
|
|
| 652 |
|
|
| 652 | 653 |
@Override |
| 653 | 654 |
public void widgetSelected(SelectionEvent e) {
|
| 654 | 655 |
lastPage(); |
| 655 | 656 |
} |
| 656 | 657 |
}); |
| 657 | 658 |
nextText.addSelectionListener(new SelectionListener() {
|
| 658 |
|
|
| 659 |
|
|
| 659 | 660 |
@Override |
| 660 | 661 |
public void widgetDefaultSelected(SelectionEvent e) {
|
| 661 | 662 |
nextText(); |
| 662 | 663 |
} |
| 663 |
|
|
| 664 |
|
|
| 664 | 665 |
@Override |
| 665 | 666 |
public void widgetSelected(SelectionEvent e) {
|
| 666 | 667 |
nextText(); |
| ... | ... | |
| 668 | 669 |
}); |
| 669 | 670 |
// set listeners |
| 670 | 671 |
previousText.addSelectionListener(new SelectionListener() {
|
| 671 |
|
|
| 672 |
|
|
| 672 | 673 |
@Override |
| 673 | 674 |
public void widgetDefaultSelected(SelectionEvent e) {
|
| 674 | 675 |
previousText(false); |
| 675 | 676 |
} |
| 676 |
|
|
| 677 |
|
|
| 677 | 678 |
@Override |
| 678 | 679 |
public void widgetSelected(SelectionEvent e) {
|
| 679 | 680 |
previousText(false); |
| 680 | 681 |
} |
| 681 | 682 |
}); |
| 682 | 683 |
lastText.addSelectionListener(new SelectionListener() {
|
| 683 |
|
|
| 684 |
|
|
| 684 | 685 |
@Override |
| 685 | 686 |
public void widgetDefaultSelected(SelectionEvent e) {
|
| 686 | 687 |
lastText(); |
| 687 | 688 |
} |
| 688 |
|
|
| 689 |
|
|
| 689 | 690 |
@Override |
| 690 | 691 |
public void widgetSelected(SelectionEvent e) {
|
| 691 | 692 |
lastText(); |
| ... | ... | |
| 693 | 694 |
}); |
| 694 | 695 |
// set listeners |
| 695 | 696 |
firstText.addSelectionListener(new SelectionListener() {
|
| 696 |
|
|
| 697 |
|
|
| 697 | 698 |
@Override |
| 698 | 699 |
public void widgetDefaultSelected(SelectionEvent e) {
|
| 699 | 700 |
firstText(); |
| 700 | 701 |
} |
| 701 |
|
|
| 702 |
|
|
| 702 | 703 |
@Override |
| 703 | 704 |
public void widgetSelected(SelectionEvent e) {
|
| 704 | 705 |
firstText(); |
| 705 | 706 |
} |
| 706 | 707 |
}); |
| 707 |
|
|
| 708 |
|
|
| 708 | 709 |
try {
|
| 709 | 710 |
// ensure all texts have build their page indexes |
| 710 | 711 |
for (Text t : mainCorpus.getProject().getTexts()) {
|
| ... | ... | |
| 718 | 719 |
e1.printStackTrace(); |
| 719 | 720 |
} |
| 720 | 721 |
} |
| 721 |
|
|
| 722 |
|
|
| 722 | 723 |
// /** |
| 723 | 724 |
// * Opens the default corpus edition with the first Text |
| 724 | 725 |
// * |
| ... | ... | |
| 728 | 729 |
// if (corpus == null) return false; |
| 729 | 730 |
// return openEditions(corpus, corpus.getProject().getFirstText(), corpus.getProject().getDefaultEdition()); |
| 730 | 731 |
// } |
| 731 |
|
|
| 732 |
|
|
| 732 | 733 |
/** |
| 733 | 734 |
* update editor title using the first panel only |
| 734 | 735 |
*/ |
| ... | ... | |
| 743 | 744 |
continue; |
| 744 | 745 |
} |
| 745 | 746 |
this.setPartName(e.getText().getName() + " - " + cpage.getName()); //$NON-NLS-1$ |
| 746 |
|
|
| 747 |
|
|
| 747 | 748 |
if (page_text.isDisposed()) {
|
| 748 | 749 |
continue; |
| 749 | 750 |
} |
| 750 | 751 |
page_text.setText(cpage.getName()); |
| 751 | 752 |
page_label.setText(" / " + e.getNumPages()); //$NON-NLS-1$
|
| 752 |
|
|
| 753 |
|
|
| 753 | 754 |
text_text.setText(p.getCurrentText().getName()); |
| 754 | 755 |
// try {
|
| 755 | 756 |
// text_label.setText(" / "+corpus.getCorpusTextIdsList().length);
|
| ... | ... | |
| 757 | 758 |
// // TODO Auto-generated catch block |
| 758 | 759 |
// e1.printStackTrace(); |
| 759 | 760 |
// } |
| 760 |
|
|
| 761 |
|
|
| 761 | 762 |
controlsArea.layout(); |
| 762 | 763 |
return; |
| 763 | 764 |
} |
| 764 | 765 |
} |
| 765 |
|
|
| 766 |
|
|
| 766 | 767 |
// public boolean openEditions(CQPCorpus corpus, String textID, String... editionNames) {
|
| 767 | 768 |
// Text text = corpus.getProject().getText(textID); |
| 768 | 769 |
// if (text == null) return false; |
| 769 | 770 |
// return openEditions(corpus, text, editionNames); |
| 770 | 771 |
// } |
| 771 |
|
|
| 772 |
|
|
| 772 | 773 |
// /** |
| 773 | 774 |
// * Opens a list of edition corpus |
| 774 | 775 |
// * @param corpus |
| ... | ... | |
| 777 | 778 |
// public boolean openEditions(CQPCorpus corpus, Text text, String... editionNames) {
|
| 778 | 779 |
// return openEditions(corpus, text, Arrays.asList(editionNames)); |
| 779 | 780 |
// } |
| 780 |
|
|
| 781 |
|
|
| 781 | 782 |
/** |
| 782 | 783 |
* Opens a list of edition corpus |
| 783 | 784 |
* |
| ... | ... | |
| 785 | 786 |
* @param editionNames |
| 786 | 787 |
*/ |
| 787 | 788 |
public boolean openEditions(Text text, List<String> editionNames) {
|
| 788 |
|
|
| 789 |
|
|
| 789 | 790 |
try {
|
| 790 | 791 |
text.compute(); |
| 791 | 792 |
} |
| ... | ... | |
| 798 | 799 |
panel.dispose(); |
| 799 | 800 |
} |
| 800 | 801 |
editionPanels = new LinkedHashMap<>(); |
| 801 |
|
|
| 802 |
|
|
| 802 | 803 |
editionsArea.getLayout().numColumns = editionNames.size(); |
| 803 |
|
|
| 804 |
|
|
| 804 | 805 |
for (int i = 0; i < editionNames.size(); i++) {
|
| 805 | 806 |
String editionName = editionNames.get(i); |
| 806 | 807 |
// System.out.println("EDITION NAME: "+editionName);
|
| 807 | 808 |
Composite container = editionsArea;// .getContainer(i); |
| 808 | 809 |
Edition edition = text.getEdition(editionName); |
| 809 | 810 |
if (edition != null) {
|
| 810 |
EditionPanel panel = new EditionPanel(this, container, SWT.BORDER, edition); |
|
| 811 |
panel.initSelectionProvider(); |
|
| 812 |
|
|
| 813 |
if (i == 0) { // TODO: how to manage multiple menumanager -> the text selection does not work only the first panel selection is used
|
|
| 814 |
panel.initMenu(); |
|
| 815 |
getSite().registerContextMenu(panel.getMenuManager(), panel.getSelectionProvider()); |
|
| 811 |
try {
|
|
| 812 |
EditionPanel panel = new EditionPanel(this, container, SWT.BORDER, edition); |
|
| 813 |
panel.initSelectionProvider(); |
|
| 814 |
|
|
| 815 |
if (i == 0) { // TODO: how to manage multiple menumanager -> the text selection does not work only the first panel selection is used
|
|
| 816 |
panel.initMenu(); |
|
| 817 |
getSite().registerContextMenu(panel.getMenuManager(), panel.getSelectionProvider()); |
|
| 818 |
} |
|
| 819 |
|
|
| 820 |
editionPanels.put(editionName, panel); |
|
| 821 |
} catch (SWTError e) {
|
|
| 822 |
Log.severe("TXM could not open the internal browser: "+e);
|
|
| 823 |
Log.printStackTrace(e); |
|
| 816 | 824 |
} |
| 817 |
|
|
| 818 |
editionPanels.put(editionName, panel); |
|
| 819 | 825 |
} |
| 820 | 826 |
else {
|
| 821 |
System.out.println(NLS.bind(EditionUIMessages.warningColonCouldNotFindEditionForNameEqualsP0, editionName));
|
|
| 827 |
Log.warning(NLS.bind(EditionUIMessages.warningColonCouldNotFindEditionForNameEqualsP0, editionName));
|
|
| 822 | 828 |
} |
| 823 | 829 |
} |
| 824 | 830 |
editionsArea.layout(); |
| 825 | 831 |
return true; |
| 826 | 832 |
} |
| 827 |
|
|
| 833 |
|
|
| 828 | 834 |
// /** |
| 829 | 835 |
// * |
| 830 | 836 |
// * //TODO: add getDefaultEditions to Corpus object |
| ... | ... | |
| 840 | 846 |
// return new String[]{defaultEdition};
|
| 841 | 847 |
// } |
| 842 | 848 |
// } |
| 843 |
|
|
| 849 |
|
|
| 844 | 850 |
@Override |
| 845 | 851 |
public void doSaveAs() {
|
| 846 | 852 |
return; |
| 847 | 853 |
} |
| 848 |
|
|
| 854 |
|
|
| 849 | 855 |
@Override |
| 850 | 856 |
public void init(IEditorSite site, IEditorInput input) throws PartInitException {
|
| 851 |
|
|
| 857 |
|
|
| 852 | 858 |
corpus = ((SynopticEditorInput) input).getCorpus(); // corpus focused when opening the editions |
| 853 | 859 |
try {
|
| 854 | 860 |
corpus.compute(false); |
| ... | ... | |
| 860 | 866 |
mainCorpus = corpus.getMainCorpus(); // get the main corpus of the corpus |
| 861 | 867 |
text = ((SynopticEditorInput) input).getText(); |
| 862 | 868 |
editionNames = ((SynopticEditorInput) input).getEditions(); |
| 863 |
|
|
| 869 |
|
|
| 864 | 870 |
super.init(site, input); |
| 865 | 871 |
} |
| 866 |
|
|
| 872 |
|
|
| 867 | 873 |
public boolean isDisposed() {
|
| 868 | 874 |
return editionsArea.isDisposed(); |
| 869 | 875 |
} |
| 870 |
|
|
| 876 |
|
|
| 871 | 877 |
@Override |
| 872 | 878 |
public boolean isSaveAsAllowed() {
|
| 873 | 879 |
return false; |
| 874 | 880 |
} |
| 875 |
|
|
| 881 |
|
|
| 876 | 882 |
@Override |
| 877 | 883 |
public void _setFocus() {
|
| 878 | 884 |
this.getEditionPanel(0).setFocus(); |
| 879 | 885 |
} |
| 880 |
|
|
| 886 |
|
|
| 881 | 887 |
public void backToText(Text text, String line_wordid) {
|
| 882 | 888 |
try {
|
| 883 | 889 |
text.compute(); |
| ... | ... | |
| 892 | 898 |
e.printStackTrace(); |
| 893 | 899 |
} |
| 894 | 900 |
} |
| 895 |
|
|
| 901 |
|
|
| 896 | 902 |
public void reloadPage() {
|
| 897 | 903 |
for (EditionPanel p : editionPanels.values()) {
|
| 898 | 904 |
p.reloadPage(); |
| 899 | 905 |
} |
| 900 | 906 |
} |
| 901 |
|
|
| 907 |
|
|
| 902 | 908 |
@Override |
| 903 | 909 |
public String getTextSelection() {
|
| 904 | 910 |
String sel = null; |
| ... | ... | |
| 910 | 916 |
} |
| 911 | 917 |
return EditionUIMessages.CommandLink_empty; |
| 912 | 918 |
} |
| 913 |
|
|
| 919 |
|
|
| 914 | 920 |
@Override |
| 915 | 921 |
public CQPCorpus getCorpus() {
|
| 916 | 922 |
return corpus; |
| 917 | 923 |
} |
| 918 |
|
|
| 924 |
|
|
| 919 | 925 |
public CQPCorpus getMainCorpus() {
|
| 920 | 926 |
return mainCorpus; |
| 921 | 927 |
} |
| 922 |
|
|
| 928 |
|
|
| 923 | 929 |
public EditionPanel getEditionPanel(int i) {
|
| 924 | 930 |
int n = 0; |
| 925 | 931 |
for (EditionPanel p : editionPanels.values()) {
|
| ... | ... | |
| 929 | 935 |
} |
| 930 | 936 |
return null; |
| 931 | 937 |
} |
| 932 |
|
|
| 938 |
|
|
| 933 | 939 |
/** |
| 934 | 940 |
* |
| 935 | 941 |
* @return the first and last word ID covered by the text selection of the first EditionPanel |
| ... | ... | |
| 940 | 946 |
} |
| 941 | 947 |
return null; |
| 942 | 948 |
} |
| 943 |
|
|
| 949 |
|
|
| 944 | 950 |
/** |
| 945 | 951 |
* |
| 946 | 952 |
* @param text2 the Text to set |
| ... | ... | |
| 952 | 958 |
} |
| 953 | 959 |
updatePageLabel(); |
| 954 | 960 |
} |
| 955 |
|
|
| 961 |
|
|
| 956 | 962 |
public void setFocusedWordID(String focusid) {
|
| 957 | 963 |
for (EditionPanel p : editionPanels.values()) {
|
| 958 | 964 |
p.setFocusedWordID(focusid); |
| 959 | 965 |
} |
| 960 | 966 |
updatePageLabel(); |
| 961 | 967 |
} |
| 962 |
|
|
| 968 |
|
|
| 963 | 969 |
/** |
| 964 | 970 |
* TODO finish implementation in EditionPanel |
| 965 | 971 |
* |
| ... | ... | |
| 970 | 976 |
p.setHighlightedArea(positions); |
| 971 | 977 |
} |
| 972 | 978 |
} |
| 973 |
|
|
| 979 |
|
|
| 974 | 980 |
public void updateWordStyles() {
|
| 975 | 981 |
for (EditionPanel p : editionPanels.values()) {
|
| 976 | 982 |
p.updateWordStyles(); |
| 977 | 983 |
} |
| 978 | 984 |
} |
| 979 |
|
|
| 985 |
|
|
| 980 | 986 |
public void addFontWeightWordsById(String weight, List<String> previousSelectedUnitIDS) {
|
| 981 | 987 |
for (EditionPanel p : editionPanels.values()) {
|
| 982 | 988 |
p.addFontWeightWordsById(weight, previousSelectedUnitIDS); |
| 983 | 989 |
} |
| 984 | 990 |
} |
| 985 |
|
|
| 991 |
|
|
| 986 | 992 |
public void removeFontWeightWordsById(List<String> previousSelectedUnitIDS) {
|
| 987 | 993 |
for (EditionPanel p : editionPanels.values()) {
|
| 988 | 994 |
p.removeFontWeightWordsById(previousSelectedUnitIDS); |
| 989 | 995 |
} |
| 990 | 996 |
} |
| 991 |
|
|
| 997 |
|
|
| 992 | 998 |
public void fireIsDirty() {
|
| 993 | 999 |
this.firePropertyChange(IEditorPart.PROP_DIRTY); |
| 994 | 1000 |
} |
| 995 |
|
|
| 1001 |
|
|
| 996 | 1002 |
/** |
| 997 | 1003 |
* Clears all highlighted words. |
| 998 | 1004 |
*/ |
| ... | ... | |
| 1001 | 1007 |
p.removeHighlightWords(); |
| 1002 | 1008 |
} |
| 1003 | 1009 |
} |
| 1004 |
|
|
| 1010 |
|
|
| 1005 | 1011 |
@Override |
| 1006 | 1012 |
public void updateResultFromEditor() {
|
| 1007 | 1013 |
// TODO Auto-generated method stub |
| 1008 | 1014 |
} |
| 1009 |
|
|
| 1015 |
|
|
| 1010 | 1016 |
@Override |
| 1011 | 1017 |
public void updateEditorFromResult(boolean update) throws Exception {
|
| 1012 | 1018 |
this.firstPage(); |
| 1013 | 1019 |
} |
| 1014 |
|
|
| 1020 |
|
|
| 1015 | 1021 |
/** |
| 1016 | 1022 |
* Browser command that opens an edition |
| 1017 | 1023 |
* |
| ... | ... | |
| 1022 | 1028 |
IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); |
| 1023 | 1029 |
ICommandService cmdService = window.getService(ICommandService.class); |
| 1024 | 1030 |
Command cmd = cmdService.getCommand(id); |
| 1025 |
|
|
| 1031 |
|
|
| 1026 | 1032 |
// get the parameter |
| 1027 | 1033 |
ArrayList<Parameterization> parameters = new ArrayList<>(); |
| 1028 | 1034 |
for (String k : params.keySet()) {
|
| ... | ... | |
| 1035 | 1041 |
System.out.println(NLS.bind(EditionUIMessages.warningColonUnknownedParameterIdEqualsP0, k)); |
| 1036 | 1042 |
} |
| 1037 | 1043 |
} |
| 1038 |
|
|
| 1044 |
|
|
| 1039 | 1045 |
// build the parameterized command |
| 1040 | 1046 |
ParameterizedCommand pc = new ParameterizedCommand(cmd, parameters.toArray(new Parameterization[parameters.size()])); |
| 1041 |
|
|
| 1047 |
|
|
| 1042 | 1048 |
// execute the command |
| 1043 | 1049 |
IHandlerService handlerService = window.getService(IHandlerService.class); |
| 1044 | 1050 |
try {
|
| ... | ... | |
| 1049 | 1055 |
} |
| 1050 | 1056 |
return null; |
| 1051 | 1057 |
} |
| 1052 |
|
|
| 1058 |
|
|
| 1053 | 1059 |
/** |
| 1054 | 1060 |
* |
| 1055 | 1061 |
* @param editor may be null, will be used by the command to display its result |
| ... | ... | |
| 1066 | 1072 |
for (int i = 0; i + 1 < arguments.length; i += 2) {
|
| 1067 | 1073 |
params.put(arguments[i].toString(), arguments[i + 1].toString()); |
| 1068 | 1074 |
} |
| 1069 |
|
|
| 1075 |
|
|
| 1070 | 1076 |
String id = params.get("id"); //$NON-NLS-1$
|
| 1071 | 1077 |
if (id != null) {
|
| 1072 | 1078 |
params.remove("id"); //$NON-NLS-1$
|
Formats disponibles : Unified diff