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