| 56 |
56 |
import visuAnalec.elements.Unite;
|
| 57 |
57 |
|
| 58 |
58 |
public class UnitConcordanceToolbar extends AnnotationArea {
|
| 59 |
|
|
|
59 |
|
| 60 |
60 |
/**
|
| 61 |
61 |
* the limit number of annotation when a confirm dialog box is shown
|
| 62 |
62 |
*/
|
| 63 |
63 |
protected static final int NALERTAFFECTANNOTATIONS = 100;
|
|
64 |
|
| 64 |
65 |
public static final String EMPTYTEXT = ""; //$NON-NLS-1$
|
| 65 |
|
|
|
66 |
|
| 66 |
67 |
protected ConcordanceEditor editor;
|
| 67 |
|
|
|
68 |
|
| 68 |
69 |
/**
|
| 69 |
70 |
* All available annotation types
|
| 70 |
71 |
*/
|
| 71 |
72 |
protected List<String> typeValuesList;
|
| 72 |
|
|
|
73 |
|
| 73 |
74 |
/**
|
| 74 |
75 |
* display the annotation values of the current shown concordance lines
|
| 75 |
76 |
*/
|
| 76 |
77 |
protected TableColumn annotationColumn;
|
| 77 |
|
|
|
78 |
|
| 78 |
79 |
protected ComboViewer annotationTypesCombo;
|
|
80 |
|
| 79 |
81 |
/** add a new type of annotation */
|
| 80 |
82 |
private Button addAnnotationTypeButton;
|
|
83 |
|
| 81 |
84 |
protected Label equalLabel;
|
|
85 |
|
| 82 |
86 |
protected Text annotationValuesText;
|
|
87 |
|
| 83 |
88 |
protected Button affectAnnotationButton;
|
|
89 |
|
| 84 |
90 |
protected Button deleteAnnotationButton;
|
|
91 |
|
| 85 |
92 |
private Button affectAllAnnotationButton;
|
| 86 |
|
|
| 87 |
|
protected Vector<String> typesList = new Vector<String>();
|
| 88 |
|
|
|
93 |
|
|
94 |
protected Vector<String> typesList = new Vector<>();
|
|
95 |
|
| 89 |
96 |
protected Concordance concordance;
|
|
97 |
|
| 90 |
98 |
private CQPCorpus corpus;
|
|
99 |
|
| 91 |
100 |
private TableViewerColumn annotationColumnViewer;
|
|
101 |
|
| 92 |
102 |
private Font annotationColummnFont;
|
|
103 |
|
| 93 |
104 |
private Font defaultColummnFont;
|
|
105 |
|
| 94 |
106 |
private Corpus annotManager;
|
|
107 |
|
| 95 |
108 |
private HashMap<Line, ArrayList<Unite>> annotations;
|
| 96 |
109 |
|
| 97 |
110 |
protected String unitType;
|
|
111 |
|
| 98 |
112 |
protected String unitProperty;
|
|
113 |
|
| 99 |
114 |
private ComboViewer annotationPropertiesCombo;
|
| 100 |
|
|
|
115 |
|
|
116 |
@Override
|
| 101 |
117 |
public String getName() {
|
| 102 |
118 |
return "Unit (URS)";
|
| 103 |
119 |
}
|
| ... | ... | |
| 106 |
122 |
public boolean allowMultipleAnnotations() {
|
| 107 |
123 |
return true;
|
| 108 |
124 |
}
|
| 109 |
|
|
| 110 |
|
public UnitConcordanceToolbar() {
|
| 111 |
|
}
|
| 112 |
|
|
|
125 |
|
|
126 |
public UnitConcordanceToolbar() {}
|
|
127 |
|
| 113 |
128 |
@Override
|
| 114 |
129 |
public boolean install(TXMEditor<? extends TXMResult> txmeditor, AnnotationExtension ext, Composite parent, int position) throws Exception {
|
| 115 |
|
|
|
130 |
|
| 116 |
131 |
this.extension = ext;
|
| 117 |
|
this.editor = (ConcordanceEditor)txmeditor;
|
|
132 |
this.editor = (ConcordanceEditor) txmeditor;
|
| 118 |
133 |
this.concordance = this.editor.getConcordance();
|
| 119 |
134 |
this.corpus = concordance.getCorpus();
|
| 120 |
|
this.annotations = new HashMap<Line, ArrayList<Unite>>();
|
|
135 |
this.annotations = new HashMap<>();
|
| 121 |
136 |
this.annotManager = URSCorpora.getCorpus(corpus);
|
| 122 |
|
|
|
137 |
|
| 123 |
138 |
TableViewer viewer = this.editor.getLineTableViewer();
|
| 124 |
|
|
|
139 |
|
| 125 |
140 |
// RESULT
|
| 126 |
141 |
if (position < 0) {
|
| 127 |
142 |
position = 3 + extension.getNumberOfAnnotationArea(); // after keyword column and previous annotation columns
|
| 128 |
143 |
}
|
| 129 |
144 |
|
| 130 |
145 |
typesList.clear();
|
| 131 |
|
|
|
146 |
|
| 132 |
147 |
for (String type : this.annotManager.getStructure().getUnites()) {
|
| 133 |
148 |
typesList.add(type);
|
| 134 |
149 |
}
|
| ... | ... | |
| 148 |
163 |
FontData fdata = defaultColummnFont.getFontData()[0];
|
| 149 |
164 |
annotationColummnFont = new Font(Display.getCurrent(), fdata.getName(), fdata.getHeight(), SWT.ITALIC);
|
| 150 |
165 |
annotationColumnViewer.setLabelProvider(new ColumnLabelProvider() {
|
| 151 |
|
|
|
166 |
|
| 152 |
167 |
@Override
|
| 153 |
168 |
public String getText(Object element) {
|
| 154 |
|
Line line = (Line)element;
|
|
169 |
Line line = (Line) element;
|
| 155 |
170 |
ArrayList<Unite> a = annotations.get(line);
|
| 156 |
171 |
if (a.size() == 0) return "<none>";
|
| 157 |
172 |
|
| ... | ... | |
| 161 |
176 |
|
| 162 |
177 |
if (value != null) {
|
| 163 |
178 |
if (unite.getDeb() < line.matchGetStart() - line.getLeftContextSize()) {
|
| 164 |
|
value = "… "+value; //$NON-NLS-1$
|
|
179 |
value = "… " + value; //$NON-NLS-1$
|
| 165 |
180 |
}
|
| 166 |
|
|
|
181 |
|
| 167 |
182 |
if (unite.getFin() > line.matchGetEnd() + line.getRightContextSize()) {
|
| 168 |
|
value = value+" …"; //$NON-NLS-1$
|
|
183 |
value = value + " …"; //$NON-NLS-1$
|
| 169 |
184 |
}
|
| 170 |
185 |
if (buffer.length() > 0) buffer.append(", ");
|
| 171 |
186 |
buffer.append(value);
|
| 172 |
|
} else {
|
|
187 |
}
|
|
188 |
else {
|
| 173 |
189 |
buffer.append("[]");
|
| 174 |
190 |
}
|
| 175 |
191 |
}
|
| 176 |
192 |
return buffer.toString();
|
| 177 |
193 |
}
|
| 178 |
194 |
});
|
| 179 |
|
|
|
195 |
|
| 180 |
196 |
if (unitType != null) {
|
| 181 |
197 |
annotationColumn.setText(unitType);
|
| 182 |
198 |
}
|
| 183 |
|
|
|
199 |
|
| 184 |
200 |
annotationArea = new GLComposite(parent, SWT.NONE, "Unit URS");
|
| 185 |
201 |
annotationArea.getLayout().numColumns = 12;
|
| 186 |
202 |
annotationArea.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
|
| 187 |
|
|
|
203 |
|
| 188 |
204 |
GridData gdata = new GridData(SWT.CENTER, SWT.CENTER, false, false);
|
| 189 |
205 |
gdata.widthHint = 90;
|
| 190 |
|
|
|
206 |
|
| 191 |
207 |
// UNIT TYPE
|
| 192 |
208 |
annotationTypesCombo = new ComboViewer(annotationArea, SWT.SINGLE);
|
| 193 |
209 |
annotationTypesCombo.setContentProvider(new ArrayContentProvider());
|
| ... | ... | |
| 201 |
217 |
if (typesList.contains(name)) {
|
| 202 |
218 |
StructuredSelection selection = new StructuredSelection(name);
|
| 203 |
219 |
annotationTypesCombo.setSelection(selection, true);
|
| 204 |
|
} else {
|
|
220 |
}
|
|
221 |
else {
|
| 205 |
222 |
createNewType(e, name);
|
| 206 |
223 |
}
|
| 207 |
224 |
}
|
| 208 |
225 |
}
|
| 209 |
226 |
|
| 210 |
227 |
@Override
|
| 211 |
|
public void keyPressed(KeyEvent e) { }
|
|
228 |
public void keyPressed(KeyEvent e) {}
|
| 212 |
229 |
});
|
| 213 |
|
|
|
230 |
|
| 214 |
231 |
gdata = new GridData(SWT.CENTER, SWT.CENTER, false, false);
|
| 215 |
232 |
gdata.widthHint = 200;
|
| 216 |
|
|
|
233 |
|
| 217 |
234 |
annotationTypesCombo.getCombo().setLayoutData(gdata);
|
| 218 |
235 |
annotationTypesCombo.setInput(typesList);
|
| 219 |
236 |
annotationTypesCombo.getCombo().select(0);
|
| 220 |
|
|
|
237 |
|
| 221 |
238 |
annotationTypesCombo.addSelectionChangedListener(new ISelectionChangedListener() {
|
|
239 |
|
| 222 |
240 |
@Override
|
| 223 |
241 |
public void selectionChanged(SelectionChangedEvent event) {
|
| 224 |
242 |
onAnnotationTypeSelected(event);
|
| ... | ... | |
| 244 |
262 |
if (typesList.contains(name)) {
|
| 245 |
263 |
StructuredSelection selection = new StructuredSelection(name);
|
| 246 |
264 |
annotationTypesCombo.setSelection(selection, true);
|
| 247 |
|
} else {
|
|
265 |
}
|
|
266 |
else {
|
| 248 |
267 |
createNewType(e, name);
|
| 249 |
268 |
}
|
| 250 |
269 |
}
|
| 251 |
270 |
}
|
| 252 |
271 |
|
| 253 |
272 |
@Override
|
| 254 |
|
public void keyPressed(KeyEvent e) { }
|
|
273 |
public void keyPressed(KeyEvent e) {}
|
| 255 |
274 |
});
|
| 256 |
|
|
|
275 |
|
| 257 |
276 |
gdata = new GridData(SWT.CENTER, SWT.CENTER, false, false);
|
| 258 |
277 |
gdata.widthHint = 200;
|
| 259 |
|
|
|
278 |
|
| 260 |
279 |
annotationPropertiesCombo.getCombo().setLayoutData(gdata);
|
| 261 |
|
ArrayList<String> properties = new ArrayList<String>();
|
|
280 |
ArrayList<String> properties = new ArrayList<>();
|
| 262 |
281 |
properties.add("");
|
| 263 |
282 |
properties.addAll(annotManager.getStructure().getNomsProps(Unite.class, unitType));
|
| 264 |
283 |
annotationPropertiesCombo.setInput(properties);
|
| 265 |
284 |
annotationPropertiesCombo.getCombo().select(0);
|
| 266 |
|
|
|
285 |
|
| 267 |
286 |
annotationPropertiesCombo.addSelectionChangedListener(new ISelectionChangedListener() {
|
|
287 |
|
| 268 |
288 |
@Override
|
| 269 |
289 |
public void selectionChanged(SelectionChangedEvent event) {
|
| 270 |
290 |
onAnnotationPropertySelected(event);
|
| 271 |
291 |
}
|
| 272 |
292 |
});
|
| 273 |
|
|
|
293 |
|
| 274 |
294 |
equalLabel = new Label(annotationArea, SWT.NONE);
|
| 275 |
295 |
equalLabel.setText("="); //$NON-NLS-1$
|
| 276 |
296 |
equalLabel.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false));
|
| 277 |
|
|
|
297 |
|
| 278 |
298 |
annotationValuesText = new Text(annotationArea, SWT.BORDER);
|
| 279 |
299 |
annotationValuesText.setToolTipText("value");
|
| 280 |
300 |
GridData gdata2 = new GridData(SWT.FILL, SWT.CENTER, false, false);
|
| 281 |
301 |
gdata2.widthHint = 200;
|
| 282 |
302 |
annotationValuesText.setLayoutData(gdata2);
|
| 283 |
303 |
annotationValuesText.addKeyListener(new KeyListener() {
|
|
304 |
|
| 284 |
305 |
@Override
|
| 285 |
306 |
public void keyReleased(KeyEvent e) {
|
| 286 |
307 |
if (e.keyCode == SWT.CR || e.keyCode == SWT.KEYPAD_CR) {
|
| 287 |
308 |
affectAnnotationToSelection(editor.getLineTableViewer().getSelection());
|
| 288 |
309 |
}
|
| 289 |
310 |
}
|
| 290 |
|
|
|
311 |
|
| 291 |
312 |
@Override
|
| 292 |
|
public void keyPressed(KeyEvent e) { }
|
|
313 |
public void keyPressed(KeyEvent e) {}
|
| 293 |
314 |
});
|
| 294 |
|
|
|
315 |
|
| 295 |
316 |
affectAnnotationButton = new Button(annotationArea, SWT.PUSH);
|
| 296 |
317 |
affectAnnotationButton.setText("Create");
|
| 297 |
318 |
affectAnnotationButton.setToolTipText("Create unit for each selected line.");
|
| 298 |
319 |
affectAnnotationButton.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false));
|
| 299 |
320 |
affectAnnotationButton.addSelectionListener(new SelectionListener() {
|
|
321 |
|
| 300 |
322 |
@Override
|
| 301 |
323 |
public void widgetSelected(SelectionEvent e) {
|
| 302 |
324 |
affectAnnotationToSelection(editor.getLineTableViewer().getSelection());
|
| 303 |
325 |
}
|
| 304 |
|
|
|
326 |
|
| 305 |
327 |
@Override
|
| 306 |
|
public void widgetDefaultSelected(SelectionEvent e) { }
|
|
328 |
public void widgetDefaultSelected(SelectionEvent e) {}
|
| 307 |
329 |
});
|
| 308 |
330 |
|
| 309 |
331 |
deleteAnnotationButton = new Button(annotationArea, SWT.PUSH);
|
| ... | ... | |
| 311 |
333 |
deleteAnnotationButton.setToolTipText("Delete unit for each selected line.");
|
| 312 |
334 |
deleteAnnotationButton.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false));
|
| 313 |
335 |
deleteAnnotationButton.addSelectionListener(new SelectionListener() {
|
|
336 |
|
| 314 |
337 |
@Override
|
| 315 |
338 |
public void widgetSelected(SelectionEvent e) {
|
| 316 |
339 |
deleteAnnotationValues(editor.getLineTableViewer().getSelection());
|
| 317 |
340 |
}
|
| 318 |
|
|
|
341 |
|
| 319 |
342 |
@Override
|
| 320 |
|
public void widgetDefaultSelected(SelectionEvent e) { }
|
|
343 |
public void widgetDefaultSelected(SelectionEvent e) {}
|
| 321 |
344 |
});
|
| 322 |
|
|
|
345 |
|
| 323 |
346 |
affectAllAnnotationButton = new Button(annotationArea, SWT.PUSH);
|
| 324 |
347 |
affectAllAnnotationButton.setText("All");
|
| 325 |
348 |
affectAllAnnotationButton.setToolTipText("Create unit for all lines");
|
| 326 |
349 |
affectAllAnnotationButton.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false));
|
| 327 |
350 |
affectAllAnnotationButton.addSelectionListener(new SelectionListener() {
|
|
351 |
|
| 328 |
352 |
@Override
|
| 329 |
353 |
public void widgetSelected(SelectionEvent e) {
|
| 330 |
|
|
|
354 |
|
| 331 |
355 |
try {
|
| 332 |
356 |
List<? extends Match> matches = concordance.getMatches();
|
| 333 |
357 |
affectMatchesToSelection(matches);
|
| 334 |
|
} catch (Exception e1) {
|
|
358 |
}
|
|
359 |
catch (Exception e1) {
|
| 335 |
360 |
Log.severe(NLS.bind("** Error: {0}", e1.getLocalizedMessage()));
|
| 336 |
361 |
Log.printStackTrace(e1);
|
| 337 |
362 |
return;
|
| 338 |
363 |
}
|
| 339 |
364 |
}
|
| 340 |
|
|
|
365 |
|
| 341 |
366 |
@Override
|
| 342 |
|
public void widgetDefaultSelected(SelectionEvent e) { }
|
|
367 |
public void widgetDefaultSelected(SelectionEvent e) {}
|
| 343 |
368 |
});
|
| 344 |
|
|
|
369 |
|
| 345 |
370 |
Button closeButton = new Button(annotationArea, SWT.PUSH);
|
| 346 |
371 |
closeButton.setToolTipText("End URS annotation");
|
| 347 |
372 |
closeButton.setImage(IImageKeys.getImage(IImageKeys.ACTION_REMOVE));
|
| ... | ... | |
| 350 |
375 |
|
| 351 |
376 |
@Override
|
| 352 |
377 |
public void widgetSelected(SelectionEvent e) {
|
| 353 |
|
extension.removeAnnotationArea(UnitConcordanceToolbar.this);
|
|
378 |
extension.closeArea(UnitConcordanceToolbar.this, true);
|
| 354 |
379 |
}
|
| 355 |
380 |
|
| 356 |
381 |
@Override
|
| 357 |
382 |
public void widgetDefaultSelected(SelectionEvent e) {}
|
| 358 |
383 |
});
|
| 359 |
|
|
|
384 |
|
| 360 |
385 |
updateAnnotationWidgetStates();
|
| 361 |
386 |
editor.layout(true);
|
| 362 |
387 |
ext.getSaveButton().setEnabled(true);
|
| 363 |
388 |
return true;
|
| 364 |
389 |
}
|
| 365 |
|
|
|
390 |
|
| 366 |
391 |
private void updateAnnotationWidgetStates() {
|
| 367 |
392 |
// TODO Auto-generated method stub
|
| 368 |
393 |
|
| 369 |
394 |
}
|
| 370 |
|
|
|
395 |
|
| 371 |
396 |
protected void affectMatchesToSelection(final List<? extends Match> matches) {
|
| 372 |
|
|
|
397 |
|
| 373 |
398 |
final String value = annotationValuesText.getText();
|
| 374 |
399 |
|
| 375 |
400 |
JobHandler job = new JobHandler("Creating units...", true) {
|
|
401 |
|
| 376 |
402 |
@Override
|
| 377 |
403 |
protected IStatus run(IProgressMonitor monitor) {
|
| 378 |
404 |
this.runInit(monitor);
|
| 379 |
405 |
try {
|
| 380 |
406 |
for (Match m : matches) {
|
| 381 |
|
HashMap<String, String> props = new HashMap<String, String>();
|
|
407 |
HashMap<String, String> props = new HashMap<>();
|
| 382 |
408 |
props.put(unitProperty, value);
|
| 383 |
409 |
Unite u = annotManager.addUniteSaisie(unitType, m.getStart(), m.getEnd(), props);
|
| 384 |
410 |
}
|
| 385 |
411 |
|
| 386 |
|
} catch(Exception e) {
|
|
412 |
}
|
|
413 |
catch (Exception e) {
|
| 387 |
414 |
Log.severe(NLS.bind("** Error: {0}", e));
|
| 388 |
415 |
Log.printStackTrace(e);
|
| 389 |
416 |
return Status.CANCEL_STATUS;
|
| 390 |
|
} catch(ThreadDeath td) {
|
|
417 |
}
|
|
418 |
catch (ThreadDeath td) {
|
| 391 |
419 |
System.out.println("Canceled");
|
| 392 |
420 |
return Status.CANCEL_STATUS;
|
| 393 |
421 |
}
|
| 394 |
|
|
|
422 |
|
| 395 |
423 |
return Status.OK_STATUS;
|
| 396 |
424 |
}
|
| 397 |
425 |
};
|
| 398 |
426 |
job.startJob(true);
|
| 399 |
427 |
}
|
| 400 |
|
|
|
428 |
|
| 401 |
429 |
protected void deleteAnnotationValues(ISelection selection) {
|
| 402 |
430 |
final IStructuredSelection lineSelection = (IStructuredSelection) selection;
|
| 403 |
431 |
List<Line> lines = lineSelection.toList();
|
| 404 |
|
ArrayList<Match> matches = new ArrayList<Match>();
|
|
432 |
ArrayList<Match> matches = new ArrayList<>();
|
| 405 |
433 |
for (Line l : lines) {
|
| 406 |
434 |
matches.add(l.getMatch());
|
| 407 |
435 |
}
|
| 408 |
436 |
}
|
| 409 |
|
|
|
437 |
|
| 410 |
438 |
protected void affectAnnotationToSelection(ISelection selection) {
|
| 411 |
439 |
|
| 412 |
440 |
final IStructuredSelection lineSelection = (IStructuredSelection) selection;
|
| 413 |
441 |
List<Line> lines = lineSelection.toList();
|
| 414 |
|
ArrayList<Match> matches = new ArrayList<Match>();
|
|
442 |
ArrayList<Match> matches = new ArrayList<>();
|
| 415 |
443 |
for (Line l : lines) {
|
| 416 |
444 |
matches.add(l.getMatch());
|
| 417 |
445 |
}
|
| 418 |
|
|
|
446 |
|
| 419 |
447 |
affectMatchesToSelection(matches);
|
| 420 |
448 |
}
|
| 421 |
|
|
|
449 |
|
| 422 |
450 |
protected void onAnnotationPropertySelected(SelectionChangedEvent event) {
|
| 423 |
451 |
|
| 424 |
452 |
IStructuredSelection sel = (IStructuredSelection) annotationPropertiesCombo.getSelection();
|
| ... | ... | |
| 429 |
457 |
|
| 430 |
458 |
try {
|
| 431 |
459 |
editor.refresh(false);
|
| 432 |
|
} catch (Exception e) {
|
|
460 |
}
|
|
461 |
catch (Exception e) {
|
| 433 |
462 |
// TODO Auto-generated catch block
|
| 434 |
463 |
e.printStackTrace();
|
| 435 |
464 |
}
|
| 436 |
465 |
|
| 437 |
466 |
updateAnnotationWidgetStates();
|
| 438 |
467 |
}
|
| 439 |
|
|
|
468 |
|
| 440 |
469 |
protected void onAnnotationTypeSelected(SelectionChangedEvent event) {
|
| 441 |
470 |
IStructuredSelection sel = (IStructuredSelection) annotationTypesCombo.getSelection();
|
| 442 |
471 |
String type = (String) sel.getFirstElement();
|
| ... | ... | |
| 445 |
474 |
unitType = type;
|
| 446 |
475 |
annotationColumn.setText(type);
|
| 447 |
476 |
|
| 448 |
|
ArrayList<String> properties = new ArrayList<String>();
|
|
477 |
ArrayList<String> properties = new ArrayList<>();
|
| 449 |
478 |
properties.add("");
|
| 450 |
479 |
properties.addAll(annotManager.getStructure().getNomsProps(Unite.class, unitType));
|
| 451 |
480 |
annotationPropertiesCombo.setInput(properties);
|
| ... | ... | |
| 453 |
482 |
|
| 454 |
483 |
try {
|
| 455 |
484 |
editor.refresh(false);
|
| 456 |
|
} catch (Exception e) {
|
|
485 |
}
|
|
486 |
catch (Exception e) {
|
| 457 |
487 |
// TODO Auto-generated catch block
|
| 458 |
488 |
e.printStackTrace();
|
| 459 |
489 |
}
|
| 460 |
|
|
|
490 |
|
| 461 |
491 |
updateAnnotationWidgetStates();
|
| 462 |
492 |
}
|
| 463 |
|
|
|
493 |
|
| 464 |
494 |
protected void createNewType(TypedEvent e, String typeName) {
|
| 465 |
495 |
|
| 466 |
496 |
if (typeName == null) typeName = ""; //$NON-NLS-1$
|
| 467 |
497 |
if (typesList.contains(typeName)) return;
|
| 468 |
498 |
|
| 469 |
|
InputDialog dialog = new InputDialog(e.widget.getDisplay().getActiveShell(), "Nouveau type d'unite", "avec le nom", typeName, null); //$NON-NLS-3$
|
|
499 |
InputDialog dialog = new InputDialog(e.widget.getDisplay().getActiveShell(), "Nouveau type d'unite", "avec le nom", typeName, null);
|
| 470 |
500 |
if (dialog.open() == InputDialog.OK) {
|
| 471 |
501 |
String name = dialog.getValue();
|
| 472 |
502 |
if (name.trim().length() == 0) return;
|
| ... | ... | |
| 476 |
506 |
annotationTypesCombo.refresh();
|
| 477 |
507 |
StructuredSelection selection = new StructuredSelection(name);
|
| 478 |
508 |
annotationTypesCombo.setSelection(selection, true);
|
| 479 |
|
|
| 480 |
|
} else {
|
|
509 |
|
|
510 |
}
|
|
511 |
else {
|
| 481 |
512 |
System.out.println("Creation aborted."); //$NON-NLS-1$
|
| 482 |
513 |
}
|
| 483 |
514 |
}
|
| 484 |
|
|
|
515 |
|
| 485 |
516 |
@Override
|
| 486 |
517 |
public boolean save() {
|
| 487 |
518 |
try {
|
| 488 |
519 |
return URSCorpora.saveCorpus(corpus);
|
| 489 |
|
} catch(Exception ex) {
|
|
520 |
}
|
|
521 |
catch (Exception ex) {
|
| 490 |
522 |
ex.printStackTrace();
|
| 491 |
523 |
return false;
|
| 492 |
524 |
}
|
| ... | ... | |
| 496 |
528 |
public boolean hasChanges() {
|
| 497 |
529 |
return annotManager.isModifie();
|
| 498 |
530 |
}
|
| 499 |
|
|
|
531 |
|
| 500 |
532 |
@Override
|
| 501 |
533 |
public boolean notifyEndOfCompute() throws Exception {
|
| 502 |
534 |
return true;
|
| 503 |
535 |
}
|
| 504 |
|
|
|
536 |
|
|
537 |
@Override
|
| 505 |
538 |
public boolean isAnnotationEnable() {
|
| 506 |
539 |
return annotationArea != null;
|
| 507 |
540 |
}
|
| 508 |
|
|
|
541 |
|
| 509 |
542 |
@Override
|
| 510 |
543 |
public void notifyStartOfRefresh() throws Exception {
|
| 511 |
|
List<Line> lines = concordance.getLines(concordance.getTopIndex(), concordance.getTopIndex()+concordance.getNLinePerPage());
|
|
544 |
List<Line> lines = concordance.getLines(concordance.getTopIndex(), concordance.getTopIndex() + concordance.getNLinePerPage());
|
| 512 |
545 |
annotations.clear();
|
| 513 |
546 |
|
| 514 |
547 |
ArrayList<Unite> units = annotManager.getUnites(unitType);
|
| 515 |
548 |
|
| 516 |
|
// int iUnit = 0;
|
| 517 |
|
// int iLine = 0;
|
| 518 |
|
// for (; iUnit < units.size() && iLine < lines.size();) {
|
| 519 |
|
// Line line = lines.get(iLine);
|
| 520 |
|
// Unite unite = units.get(iUnit);
|
| 521 |
|
// if (unite.getFin() < line.getMatch().getStart()) {
|
| 522 |
|
// iUnit++;
|
| 523 |
|
// } else if (line.getMatch().getEnd() < unite.getDeb()) {
|
| 524 |
|
// iLine++;
|
| 525 |
|
// } else {
|
| 526 |
|
// annotations.put(line, unite);
|
| 527 |
|
// iLine++;
|
| 528 |
|
// }
|
| 529 |
|
// }
|
|
549 |
// int iUnit = 0;
|
|
550 |
// int iLine = 0;
|
|
551 |
// for (; iUnit < units.size() && iLine < lines.size();) {
|
|
552 |
// Line line = lines.get(iLine);
|
|
553 |
// Unite unite = units.get(iUnit);
|
|
554 |
// if (unite.getFin() < line.getMatch().getStart()) {
|
|
555 |
// iUnit++;
|
|
556 |
// } else if (line.getMatch().getEnd() < unite.getDeb()) {
|
|
557 |
// iLine++;
|
|
558 |
// } else {
|
|
559 |
// annotations.put(line, unite);
|
|
560 |
// iLine++;
|
|
561 |
// }
|
|
562 |
// }
|
| 530 |
563 |
for (Line line : lines) {
|
| 531 |
|
ArrayList<Unite> lineUnites = new ArrayList<Unite>();
|
| 532 |
|
annotations.put(line, lineUnites); //ok test next one
|
|
564 |
ArrayList<Unite> lineUnites = new ArrayList<>();
|
|
565 |
annotations.put(line, lineUnites); // ok test next one
|
| 533 |
566 |
for (int iUnit = 0; iUnit < units.size(); iUnit++) {
|
| 534 |
567 |
|
| 535 |
568 |
Unite unite = units.get(iUnit);
|
| 536 |
569 |
if (unite.getFin() < line.getMatch().getStart()) {
|
| 537 |
570 |
continue;
|
| 538 |
|
} else if (line.getMatch().getEnd() < unite.getDeb()) {
|
| 539 |
|
break; //no need to go further
|
| 540 |
|
} else {
|
|
571 |
}
|
|
572 |
else if (line.getMatch().getEnd() < unite.getDeb()) {
|
|
573 |
break; // no need to go further
|
|
574 |
}
|
|
575 |
else {
|
| 541 |
576 |
lineUnites.add(unite);
|
| 542 |
577 |
}
|
| 543 |
578 |
}
|
| 544 |
579 |
}
|
| 545 |
580 |
|
| 546 |
581 |
updateAnnotationWidgetStates();
|
| 547 |
|
|
|
582 |
|
| 548 |
583 |
// update annotation column width
|
| 549 |
584 |
if (annotationArea != null) {
|
| 550 |
585 |
annotationColumn.pack();
|
| 551 |
|
|
|
586 |
|
| 552 |
587 |
annotationColumn.setResizable(true);
|
| 553 |
|
} else {
|
|
588 |
}
|
|
589 |
else {
|
| 554 |
590 |
annotationColumn.setWidth(0);
|
| 555 |
591 |
}
|
| 556 |
592 |
}
|
| 557 |
|
|
|
593 |
|
| 558 |
594 |
@Override
|
| 559 |
595 |
protected void _close() {
|
| 560 |
596 |
if (!annotationColumn.isDisposed()) annotationColumn.dispose();
|
| 561 |
597 |
if (!annotationArea.isDisposed()) annotationArea.dispose();
|
| 562 |
598 |
extension.layout();
|
| 563 |
599 |
}
|
| 564 |
|
|
|
600 |
|
| 565 |
601 |
@Override
|
| 566 |
602 |
public void notifyEndOfRefresh() throws Exception {
|
| 567 |
603 |
// TODO Auto-generated method stub
|
| 568 |
604 |
}
|
| 569 |
|
|
|
605 |
|
| 570 |
606 |
@Override
|
| 571 |
607 |
public void notifyStartOfCreatePartControl() throws Exception {
|
| 572 |
608 |
// TODO Auto-generated method stub
|
| ... | ... | |
| 575 |
611 |
public void notifyEndOfCreatePartControl() throws Exception {
|
| 576 |
612 |
// TODO Auto-generated method stub
|
| 577 |
613 |
}
|
| 578 |
|
|
|
614 |
|
| 579 |
615 |
@Override
|
| 580 |
616 |
public Class<? extends TXMResult> getAnnotatedTXMResultClass() {
|
| 581 |
617 |
return Concordance.class;
|
| 582 |
618 |
}
|
| 583 |
|
|
|
619 |
|
| 584 |
620 |
@Override
|
| 585 |
621 |
public boolean isDirty() {
|
| 586 |
622 |
return annotManager.isModifie();
|
| 587 |
623 |
}
|
| 588 |
|
|
|
624 |
|
| 589 |
625 |
@Override
|
| 590 |
626 |
public boolean discardChanges() {
|
| 591 |
627 |
return false;
|
| 592 |
628 |
}
|
| 593 |
|
|
|
629 |
|
| 594 |
630 |
@Override
|
| 595 |
631 |
public boolean needToUpdateIndexes() {
|
| 596 |
632 |
return true;
|
| 597 |
633 |
}
|
| 598 |
|
|
|
634 |
|
| 599 |
635 |
@Override
|
| 600 |
636 |
public boolean notifyStartOfCompute() throws Exception {
|
| 601 |
637 |
return true;
|
| 602 |
638 |
}
|
| 603 |
|
}
|
|
639 |
}
|