|
1 |
package org.txm.annotation.rcp.concordance;
|
|
2 |
|
|
3 |
import java.io.File;
|
|
4 |
import java.util.ArrayList;
|
|
5 |
import java.util.HashMap;
|
|
6 |
import java.util.List;
|
|
7 |
import java.util.Vector;
|
|
8 |
import java.util.logging.Level;
|
|
9 |
|
|
10 |
import org.eclipse.core.runtime.IProgressMonitor;
|
|
11 |
import org.eclipse.core.runtime.IStatus;
|
|
12 |
import org.eclipse.core.runtime.Status;
|
|
13 |
import org.eclipse.jface.dialogs.InputDialog;
|
|
14 |
import org.eclipse.jface.dialogs.MessageDialog;
|
|
15 |
import org.eclipse.jface.viewers.ArrayContentProvider;
|
|
16 |
import org.eclipse.jface.viewers.ColumnLabelProvider;
|
|
17 |
import org.eclipse.jface.viewers.ComboViewer;
|
|
18 |
import org.eclipse.jface.viewers.ISelection;
|
|
19 |
import org.eclipse.jface.viewers.ISelectionChangedListener;
|
|
20 |
import org.eclipse.jface.viewers.IStructuredSelection;
|
|
21 |
import org.eclipse.jface.viewers.SelectionChangedEvent;
|
|
22 |
import org.eclipse.jface.viewers.TableViewer;
|
|
23 |
import org.eclipse.jface.viewers.TableViewerColumn;
|
|
24 |
import org.eclipse.jface.viewers.ViewerCell;
|
|
25 |
import org.eclipse.swt.SWT;
|
|
26 |
import org.eclipse.swt.events.ControlEvent;
|
|
27 |
import org.eclipse.swt.events.ControlListener;
|
|
28 |
import org.eclipse.swt.events.KeyEvent;
|
|
29 |
import org.eclipse.swt.events.KeyListener;
|
|
30 |
import org.eclipse.swt.events.SelectionEvent;
|
|
31 |
import org.eclipse.swt.events.SelectionListener;
|
|
32 |
import org.eclipse.swt.graphics.Point;
|
|
33 |
import org.eclipse.swt.layout.GridData;
|
|
34 |
import org.eclipse.swt.layout.GridLayout;
|
|
35 |
import org.eclipse.swt.widgets.Button;
|
|
36 |
import org.eclipse.swt.widgets.Combo;
|
|
37 |
import org.eclipse.swt.widgets.Composite;
|
|
38 |
import org.eclipse.swt.widgets.Display;
|
|
39 |
import org.eclipse.swt.widgets.Label;
|
|
40 |
import org.eclipse.swt.widgets.TableColumn;
|
|
41 |
import org.eclipse.swt.widgets.Text;
|
|
42 |
import org.eclipse.ui.IWorkbenchWindow;
|
|
43 |
import org.eclipse.ui.PartInitException;
|
|
44 |
import org.eclipse.ui.dialogs.ListDialog;
|
|
45 |
import org.txm.concordance.core.functions.Concordance;
|
|
46 |
import org.txm.concordance.core.functions.Line;
|
|
47 |
import org.txm.concordance.rcp.editors.ConcordanceEditor;
|
|
48 |
import org.txm.concordance.rcp.editors.ConcordanceEditor.ConcordanceColumnSizeControlListener;
|
|
49 |
import org.txm.concordance.rcp.editors.ConcordanceEditorExtension;
|
|
50 |
import org.txm.concordance.rcp.messages.Messages;
|
|
51 |
import org.txm.core.preferences.TXMPreferences;
|
|
52 |
import org.txm.rcp.IImageKeys;
|
|
53 |
import org.txm.rcp.RCPMessages;
|
|
54 |
import org.txm.rcp.commands.OpenBrowser;
|
|
55 |
import org.txm.rcp.preferences.RCPPreferences;
|
|
56 |
import org.txm.rcp.swt.dialog.ConfirmDialog;
|
|
57 |
import org.txm.rcp.swt.provider.SimpleLabelProvider;
|
|
58 |
import org.txm.rcp.utils.JobHandler;
|
|
59 |
import org.txm.rcp.views.corpora.CorporaView;
|
|
60 |
import org.txm.searchengine.cqp.clientExceptions.CqiClientException;
|
|
61 |
import org.txm.searchengine.cqp.corpus.Corpus;
|
|
62 |
import org.txm.searchengine.cqp.corpus.query.Match;
|
|
63 |
import org.txm.utils.AsciiUtils;
|
|
64 |
import org.txm.utils.logger.Log;
|
|
65 |
import org.txm.annotation.core.Annotation;
|
|
66 |
import org.txm.annotation.core.AnnotationManager;
|
|
67 |
import org.txm.annotation.core.KRAnnotationEngine;
|
|
68 |
import org.txm.annotation.core.preferences.AnnotationPreferences;
|
|
69 |
import org.txm.annotation.core.repository.AnnotationType;
|
|
70 |
import org.txm.annotation.core.repository.KnowledgeRepository;
|
|
71 |
import org.txm.annotation.core.repository.KnowledgeRepositoryManager;
|
|
72 |
import org.txm.annotation.core.repository.LocalKnowledgeRepository;
|
|
73 |
import org.txm.annotation.core.repository.SQLKnowledgeRepository;
|
|
74 |
import org.txm.annotation.core.repository.TypedValue;
|
|
75 |
import org.txm.annotation.rcp.commands.InitializeKnowledgeRepository;
|
|
76 |
import org.txm.annotation.rcp.commands.SaveAnnotations;
|
|
77 |
import org.txm.annotation.rcp.commands.krview.OpenKRView;
|
|
78 |
import org.txm.annotation.rcp.views.knowledgerepositories.KRView;
|
|
79 |
|
|
80 |
public class ConcordanceAnnotationExtension extends ConcordanceEditorExtension {
|
|
81 |
|
|
82 |
/**
|
|
83 |
* the limit number of annotation when a confirm dialog box is shown
|
|
84 |
*/
|
|
85 |
protected static final int NALERTAFFECTANNOTATIONS = 100;
|
|
86 |
|
|
87 |
/** The annotation service */
|
|
88 |
protected AnnotationManager annotManager;
|
|
89 |
|
|
90 |
//boolean annotation_expert_mode = TxmPreferences.getBoolean(AnnotationPreferencePage.MODE, false);
|
|
91 |
|
|
92 |
/** The annotation area. */
|
|
93 |
protected Composite annotationArea;
|
|
94 |
|
|
95 |
protected Point annotationSize;
|
|
96 |
|
|
97 |
/** The annot btn. */
|
|
98 |
protected Button annotationButton;
|
|
99 |
private Button addAnnotationTypeLink;
|
|
100 |
|
|
101 |
protected Text annotationValuesText;
|
|
102 |
protected ComboViewer annotationTypesCombo;
|
|
103 |
|
|
104 |
protected List<TypedValue> typeValuesList;
|
|
105 |
|
|
106 |
protected Point annotSize;
|
|
107 |
|
|
108 |
protected TableColumn annotationColumn;
|
|
109 |
|
|
110 |
protected Combo addRemoveCombo;
|
|
111 |
protected Combo affectCombo;
|
|
112 |
protected Button affectAnnotationButton;
|
|
113 |
|
|
114 |
protected Button infosAnnotTypeSelectedLink;
|
|
115 |
|
|
116 |
protected HashMap<AnnotationType, ArrayList<TypedValue>> history = new HashMap<AnnotationType, ArrayList<TypedValue>>();
|
|
117 |
|
|
118 |
protected KnowledgeRepository currentKnowledgeRepository = null;
|
|
119 |
protected Vector<AnnotationType> typesList = new Vector<AnnotationType>();
|
|
120 |
|
|
121 |
protected Button addTypedValueLink;
|
|
122 |
|
|
123 |
protected Label withLabel;
|
|
124 |
|
|
125 |
protected AnnotationType tagAnnotationType; // the tag annotation type if annotation mode is simple
|
|
126 |
|
|
127 |
protected Label equalLabel;
|
|
128 |
protected Boolean advanced_annotation_mode = false;
|
|
129 |
|
|
130 |
protected TypedValue value_to_add;
|
|
131 |
|
|
132 |
protected Concordance concordance;
|
|
133 |
|
|
134 |
private Corpus corpus;
|
|
135 |
|
|
136 |
private ConcordanceAnnotations annotations;
|
|
137 |
|
|
138 |
public ConcordanceAnnotationExtension() {
|
|
139 |
|
|
140 |
}
|
|
141 |
|
|
142 |
@Override
|
|
143 |
public String getName() {
|
|
144 |
return "Annotation";
|
|
145 |
}
|
|
146 |
|
|
147 |
@Override
|
|
148 |
public boolean installWidgets() throws Exception {
|
|
149 |
|
|
150 |
final Composite controlArea = editor.getNavigationArea();
|
|
151 |
final Composite navigationArea = editor.getNavigationArea();
|
|
152 |
TableViewer viewer = editor.getLineTableViewer();
|
|
153 |
|
|
154 |
// CONTROLS
|
|
155 |
if (KRAnnotationEngine.getKnowledgeRepositoryNames(corpus).size() > 0) { // shown only if corpus has a registered KR
|
|
156 |
|
|
157 |
annotationButton = new Button(navigationArea, SWT.PUSH);
|
|
158 |
annotationButton.setToolTipText(Messages.ConcordancesEditor_75);
|
|
159 |
annotationButton.setImage(IImageKeys.getImage(IImageKeys.PENCIL));
|
|
160 |
annotationButton.addSelectionListener(new SelectionListener() {
|
|
161 |
@Override
|
|
162 |
public void widgetSelected(SelectionEvent e) {
|
|
163 |
if (annotationArea != null) {
|
|
164 |
AnnotationManager am = KRAnnotationEngine.getAnnotationManager(corpus);
|
|
165 |
if (am != null && am.hasChanges()) {
|
|
166 |
// && MessageDialog.openConfirm(e.display.getActiveShell(), "Confirm annotation save", "Saving annotation will close this editor. Are you sure you want to save annotations right now ?")
|
|
167 |
JobHandler saveJob = SaveAnnotations.save(corpus.getMainCorpus());
|
|
168 |
if (saveJob.getResult() == Status.CANCEL_STATUS) {
|
|
169 |
// update editor corpus
|
|
170 |
System.out.println("Fail to save annotations of the corpus."); //$NON-NLS-1$
|
|
171 |
}
|
|
172 |
}
|
|
173 |
|
|
174 |
} else {
|
|
175 |
if (annotationArea == null) composeAnnotationArea(controlArea);
|
|
176 |
if (annotationArea == null) return;
|
|
177 |
|
|
178 |
annotationColumn.pack();
|
|
179 |
annotationButton.setToolTipText(Messages.ConcordancesEditor_76);
|
|
180 |
annotationButton.setImage(IImageKeys.getImage(IImageKeys.PENCIL_SAVE));
|
|
181 |
|
|
182 |
annotSize = annotationArea.getSize();
|
|
183 |
Point size = controlArea.getSize();
|
|
184 |
controlArea.setSize(size.x, size.y + annotSize.y);
|
|
185 |
GridData data = (GridData) annotationArea.getLayoutData();
|
|
186 |
data.heightHint = annotSize.y;
|
|
187 |
data.minimumHeight = annotSize.y;
|
|
188 |
annotationArea.setSize(annotSize);
|
|
189 |
controlArea.layout(true);
|
|
190 |
controlArea.getParent().layout();
|
|
191 |
|
|
192 |
if (concordance != null) {
|
|
193 |
AnnotationType type = getSelectedAnnotationType();
|
|
194 |
if (type != null) {
|
|
195 |
annotations.setViewAnnotation(type);
|
|
196 |
annotations.setAnnotationOverlap(true);
|
|
197 |
editor.fillDisplayArea(editor.getTopLine(), editor.getBottomLine()+1);
|
|
198 |
}
|
|
199 |
}
|
|
200 |
|
|
201 |
CorporaView.refreshObject(corpus);
|
|
202 |
}
|
|
203 |
}
|
|
204 |
|
|
205 |
@Override
|
|
206 |
public void widgetDefaultSelected(SelectionEvent e) { }
|
|
207 |
});
|
|
208 |
}
|
|
209 |
|
|
210 |
// RESULT
|
|
211 |
|
|
212 |
int position = 3;
|
|
213 |
TableViewerColumn annotationColumnViewer = new TableViewerColumn(viewer, SWT.CENTER, position);
|
|
214 |
annotationColumn = annotationColumnViewer.getColumn();
|
|
215 |
annotationColumn.setText(Messages.ConcordancesEditor_15);
|
|
216 |
annotationColumn.setToolTipText(Messages.ConcordancesEditor_17);
|
|
217 |
annotationColumn.setAlignment(SWT.CENTER);
|
|
218 |
|
|
219 |
annotationColumn.addControlListener(new ConcordanceColumnSizeControlListener(annotationColumn));
|
|
220 |
annotationColumnViewer.setLabelProvider(new ColumnLabelProvider() {
|
|
221 |
@Override
|
|
222 |
public String getText(Object element) {
|
|
223 |
Line line = (Line)element;
|
|
224 |
AnnotationLine annotationLine = annotations.getAnnotationLine(line);
|
|
225 |
if (annotationLine.getAnnotation()!=null) {
|
|
226 |
String value = annotationLine.getAnnotationValue().getStandardName();
|
|
227 |
Annotation a = annotationLine.getAnnotation();
|
|
228 |
if (value == null) value = a.getValue();
|
|
229 |
|
|
230 |
if (a.getStart() < line.matchGetStart() - line.getLeftContextSize()) {
|
|
231 |
value = "… "+value;
|
|
232 |
}
|
|
233 |
|
|
234 |
if (a.getEnd() > line.matchGetEnd() + line.getRightContextSize()) {
|
|
235 |
value = value+" …";
|
|
236 |
}
|
|
237 |
return value;
|
|
238 |
} else {
|
|
239 |
return "";
|
|
240 |
}
|
|
241 |
}
|
|
242 |
});
|
|
243 |
|
|
244 |
|
|
245 |
return true;
|
|
246 |
}
|
|
247 |
|
|
248 |
public boolean initialiseInput(ConcordanceEditor editor) throws Exception {
|
|
249 |
this.editor = editor;
|
|
250 |
concordance = editor.getConcordance();
|
|
251 |
annotations = new ConcordanceAnnotations(concordance);
|
|
252 |
corpus = concordance.getCorpus();
|
|
253 |
|
|
254 |
Corpus corpus = editor.getCorpus();
|
|
255 |
|
|
256 |
this.annotManager = KRAnnotationEngine.getAnnotationManager(corpus);
|
|
257 |
|
|
258 |
return true;
|
|
259 |
|
|
260 |
}
|
|
261 |
|
|
262 |
private void composeAnnotationArea(final Composite parent){
|
|
263 |
advanced_annotation_mode = "advanced".equals(TXMPreferences.getString(AnnotationPreferences.ANNOTATION_MODE, RCPPreferences.PREFERENCES_NODE));
|
|
264 |
|
|
265 |
List<KnowledgeRepository> krs = InitializeKnowledgeRepository.get(corpus.getMainCorpus());
|
|
266 |
typesList.clear();
|
|
267 |
Log.warning("Corpus KRs: "+krs); //$NON-NLS-1$
|
|
268 |
|
|
269 |
for (KnowledgeRepository kr : krs) {
|
|
270 |
if (kr == null) continue;
|
|
271 |
|
|
272 |
currentKnowledgeRepository = kr;
|
|
273 |
Log.warning(" KR: "+kr); //$NON-NLS-1$
|
|
274 |
List<AnnotationType> krtypes = kr.getAllAnnotationTypes();
|
|
275 |
Log.warning("Advanced annotation mode ? "+advanced_annotation_mode);
|
|
276 |
if (!advanced_annotation_mode) { // creates the "span" annotation type
|
|
277 |
boolean createTagAnnotationType = true;
|
|
278 |
for (AnnotationType type : krtypes) {
|
|
279 |
if (type.getName().equals("span")) { //$NON-NLS-1$
|
|
280 |
createTagAnnotationType = false;
|
|
281 |
}
|
|
282 |
}
|
|
283 |
if (createTagAnnotationType) {
|
|
284 |
tagAnnotationType = kr.addType("span", "span");//corresponds to an "undef" type //$NON-NLS-1$ //$NON-NLS-2$
|
|
285 |
typesList.add(tagAnnotationType);
|
|
286 |
} else {
|
|
287 |
tagAnnotationType = kr.getType("span"); //$NON-NLS-1$
|
|
288 |
}
|
|
289 |
} else {
|
|
290 |
typesList.addAll(krtypes);
|
|
291 |
}
|
|
292 |
Log.warning("Available annotation types: "+typesList);
|
|
293 |
break;
|
|
294 |
}
|
|
295 |
|
|
296 |
if (currentKnowledgeRepository == null) {
|
|
297 |
System.out.println("Error: no suitable KnowledgeRepository found");
|
|
298 |
return;
|
|
299 |
}
|
|
300 |
|
|
301 |
annotationArea = new Composite(parent, SWT.NONE);
|
|
302 |
annotationArea.setLayoutData(new GridData(SWT.FILL, SWT.LEFT, false, false));
|
|
303 |
|
|
304 |
GridLayout annotLayout = new GridLayout(12, false);
|
|
305 |
annotLayout.verticalSpacing = 0;
|
|
306 |
annotLayout.marginWidth = 0;
|
|
307 |
annotLayout.marginHeight = 0;
|
|
308 |
annotationArea.setLayout(annotLayout);
|
|
309 |
|
|
310 |
//init values history
|
|
311 |
for (AnnotationType type : typesList) {
|
|
312 |
history.put(type, new ArrayList<TypedValue>());
|
|
313 |
}
|
|
314 |
|
|
315 |
addRemoveCombo = new Combo(annotationArea, SWT.READ_ONLY);
|
|
316 |
String affectLabel = currentKnowledgeRepository.getString(editor.getLocale(), "ConcordancesEditor_22");
|
|
317 |
if (affectLabel == null) affectLabel= Messages.ConcordancesEditor_22;
|
|
318 |
String removeLabel = currentKnowledgeRepository.getString(editor.getLocale(), "ConcordancesEditor_24");
|
|
319 |
if (removeLabel == null) removeLabel= Messages.ConcordancesEditor_24;
|
|
320 |
String items[] = {affectLabel, removeLabel};
|
|
321 |
addRemoveCombo.setItems(items);
|
|
322 |
addRemoveCombo.select(0);
|
|
323 |
addRemoveCombo.addSelectionListener(new SelectionListener() {
|
|
324 |
@Override
|
|
325 |
public void widgetSelected(SelectionEvent e) {
|
|
326 |
if (addRemoveCombo.getSelectionIndex() == 0) { // add
|
|
327 |
annotationValuesText.setEnabled(true);
|
|
328 |
String withLabelText = currentKnowledgeRepository.getString(editor.getLocale(), "ConcordancesEditor_83");
|
|
329 |
if (withLabelText == null) withLabelText= Messages.ConcordancesEditor_83;
|
|
330 |
withLabel.setText(withLabelText);
|
|
331 |
if (equalLabel != null) equalLabel.setText("=");
|
|
332 |
} else { // remove
|
|
333 |
annotationValuesText.setEnabled(false);
|
|
334 |
withLabel.setText(""); //$NON-NLS-1$
|
|
335 |
if (equalLabel != null) equalLabel.setText("");
|
|
336 |
}
|
|
337 |
withLabel.redraw();
|
|
338 |
annotationArea.layout();
|
|
339 |
updateAnnotationWidgetStates();
|
|
340 |
}
|
|
341 |
@Override
|
|
342 |
public void widgetDefaultSelected(SelectionEvent e) { }
|
|
343 |
});
|
|
344 |
GridData gdata = new GridData(SWT.CENTER, SWT.CENTER, false, true);
|
|
345 |
gdata.widthHint = 90;
|
|
346 |
addRemoveCombo.setLayoutData(gdata);
|
|
347 |
|
|
348 |
withLabel = new Label(annotationArea, SWT.NONE);
|
|
349 |
String withLabelText = currentKnowledgeRepository.getString(editor.getLocale(), "ConcordancesEditor_83");
|
|
350 |
if (withLabelText == null) withLabelText= Messages.ConcordancesEditor_83;
|
|
351 |
withLabel.setText(withLabelText);
|
|
352 |
withLabel.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false));
|
|
353 |
|
|
354 |
if (advanced_annotation_mode) {
|
|
355 |
equalLabel = new Label(annotationArea, SWT.NONE);
|
|
356 |
equalLabel.setText("="); //$NON-NLS-1$
|
|
357 |
equalLabel.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false));
|
|
358 |
}
|
|
359 |
|
|
360 |
//Display combo with list of Annotation Type
|
|
361 |
if (advanced_annotation_mode) {
|
|
362 |
annotationTypesCombo = new ComboViewer(annotationArea, SWT.READ_ONLY);
|
|
363 |
annotationTypesCombo.setContentProvider(new ArrayContentProvider());
|
|
364 |
annotationTypesCombo.setLabelProvider(new SimpleLabelProvider() {
|
|
365 |
@Override
|
|
366 |
public String getColumnText(Object element, int columnIndex) {
|
|
367 |
return ((AnnotationType)element).getName(); //$NON-NLS-1$
|
|
368 |
}
|
|
369 |
@Override
|
|
370 |
public String getText(Object element) {
|
|
371 |
return ((AnnotationType)element).getName(); //$NON-NLS-1$
|
|
372 |
}
|
|
373 |
});
|
|
374 |
gdata = new GridData(SWT.CENTER, SWT.CENTER, false, true);
|
|
375 |
gdata.widthHint = 200;
|
|
376 |
|
|
377 |
annotationTypesCombo.getCombo().setLayoutData(gdata);
|
|
378 |
annotationTypesCombo.setInput(typesList);
|
|
379 |
if (advanced_annotation_mode.equals(RCPMessages.AnnotationPreferences_2)) {
|
|
380 |
annotationTypesCombo.getCombo().select(0);
|
|
381 |
}
|
|
382 |
|
|
383 |
annotationTypesCombo.addSelectionChangedListener(new ISelectionChangedListener() {
|
|
384 |
@Override
|
|
385 |
public void selectionChanged(SelectionChangedEvent event) {
|
|
386 |
AnnotationType type = getSelectedAnnotationType();
|
|
387 |
if (type == null) return;
|
|
388 |
if (type.getSize() != AnnotationType.ValuesSize.LARGE) {
|
|
389 |
try {
|
|
390 |
KnowledgeRepository kr = KnowledgeRepositoryManager.getKnowledgeRepository(type.getKnowledgeRepository());
|
|
391 |
typeValuesList = kr.getValues(type);
|
|
392 |
} catch (Exception e) {
|
|
393 |
// TODO Auto-generated catch block
|
|
394 |
e.printStackTrace();
|
|
395 |
}
|
|
396 |
} else { // set history values
|
|
397 |
typeValuesList = history.get(type);
|
|
398 |
}
|
|
399 |
|
|
400 |
annotationColumn.setText(type.getName());
|
|
401 |
if (concordance != null) {
|
|
402 |
annotations.setViewAnnotation(type);
|
|
403 |
annotations.setAnnotationOverlap(true);
|
|
404 |
editor.fillDisplayArea(editor.getTopLine(), editor.getBottomLine()+1);
|
|
405 |
}
|
|
406 |
|
|
407 |
updateAnnotationWidgetStates();
|
|
408 |
}
|
|
409 |
});
|
|
410 |
}
|
|
411 |
|
|
412 |
if (advanced_annotation_mode) {
|
|
413 |
if (currentKnowledgeRepository instanceof SQLKnowledgeRepository) {
|
|
414 |
infosAnnotTypeSelectedLink = new Button(annotationArea, SWT.PUSH);
|
|
415 |
infosAnnotTypeSelectedLink.setImage(IImageKeys.getImage(IImageKeys.ACTION_INFO));
|
|
416 |
infosAnnotTypeSelectedLink.setEnabled(true);
|
|
417 |
infosAnnotTypeSelectedLink.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, true));
|
|
418 |
infosAnnotTypeSelectedLink.addSelectionListener(new SelectionListener() {
|
|
419 |
@Override
|
|
420 |
public void widgetSelected(SelectionEvent e) {
|
|
421 |
AnnotationType type = getSelectedAnnotationType();
|
|
422 |
if (type == null) return;
|
|
423 |
|
|
424 |
String typedValueURL = type.getURL(); // may be null/empty
|
|
425 |
if (typedValueURL != null && typedValueURL.length() > 0) {
|
|
426 |
KnowledgeRepository kr = KnowledgeRepositoryManager.getKnowledgeRepository(type.getKnowledgeRepository());
|
|
427 |
kr.getTypeURL(type);
|
|
428 |
}
|
|
429 |
if (typedValueURL != null && typedValueURL.length() > 0) {
|
|
430 |
OpenBrowser.openfile(typedValueURL, new File(typedValueURL).getName());
|
|
431 |
} else {
|
|
432 |
IWorkbenchWindow window = editor.getSite().getWorkbenchWindow();
|
|
433 |
try {
|
|
434 |
OpenKRView.openView(window, type);
|
|
435 |
} catch (PartInitException e1) {
|
|
436 |
e1.printStackTrace();
|
|
437 |
}
|
|
438 |
}
|
|
439 |
}
|
|
440 |
|
|
441 |
@Override
|
|
442 |
public void widgetDefaultSelected(SelectionEvent e) { }
|
|
443 |
});
|
|
444 |
}
|
|
445 |
|
|
446 |
if (currentKnowledgeRepository instanceof LocalKnowledgeRepository) {
|
|
447 |
addAnnotationTypeLink = new Button(annotationArea, SWT.PUSH);
|
|
448 |
addAnnotationTypeLink.setToolTipText(Messages.ConcordancesEditor_115);
|
|
449 |
addAnnotationTypeLink.setImage(IImageKeys.getImage(IImageKeys.ACTION_ADD));
|
|
450 |
addAnnotationTypeLink.setEnabled(true);
|
|
451 |
addAnnotationTypeLink.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, true));
|
|
452 |
addAnnotationTypeLink.addSelectionListener(new SelectionListener() {
|
|
453 |
@Override
|
|
454 |
public void widgetSelected(SelectionEvent e) {
|
|
455 |
if (currentKnowledgeRepository == null) return;
|
|
456 |
if (!(currentKnowledgeRepository instanceof LocalKnowledgeRepository)) return;
|
|
457 |
|
|
458 |
LocalKnowledgeRepository kr = (LocalKnowledgeRepository)currentKnowledgeRepository;
|
|
459 |
|
|
460 |
InputDialog dialog = new InputDialog(e.widget.getDisplay().getActiveShell(), Messages.ConcordancesEditor_82, Messages.ConcordancesEditor_81, "", null); //$NON-NLS-3$
|
|
461 |
if (dialog.open() == InputDialog.OK) {
|
|
462 |
String name = dialog.getValue();
|
|
463 |
if (name.trim().length() == 0) return;
|
|
464 |
String baseid = AsciiUtils.buildId(name);
|
|
465 |
String id = AsciiUtils.buildId(name);
|
|
466 |
int c = 1;
|
|
467 |
while (kr.getType(id) != null) {
|
|
468 |
id = baseid+"_"+(c++); //$NON-NLS-1$
|
|
469 |
}
|
|
470 |
AnnotationType type = kr.addType(name, id, ""); //$NON-NLS-1$
|
|
471 |
typesList.add(type);
|
|
472 |
history.put(type, new ArrayList<TypedValue>());
|
|
473 |
|
|
474 |
if (annotationTypesCombo != null) annotationTypesCombo.refresh();
|
|
475 |
if (typesList.size() == 1) {
|
|
476 |
if (annotationTypesCombo != null) annotationTypesCombo.getCombo().select(0);
|
|
477 |
if (concordance != null) {
|
|
478 |
annotations.setViewAnnotation(type);
|
|
479 |
annotations.setAnnotationOverlap(true);
|
|
480 |
editor.fillDisplayArea(editor.getTopLine(), editor.getBottomLine()+1);
|
|
481 |
}
|
|
482 |
annotationArea.layout(true);
|
|
483 |
}else {
|
|
484 |
if (typesList.size() > 1){
|
|
485 |
if (annotationTypesCombo != null) annotationTypesCombo.getCombo().select(typesList.size()-1);
|
|
486 |
|
|
487 |
}
|
|
488 |
|
|
489 |
}
|
|
490 |
KRView.refresh();
|
|
491 |
updateAnnotationWidgetStates();
|
|
492 |
} else {
|
|
493 |
System.out.println("Creation aborted."); //$NON-NLS-1$
|
|
494 |
}
|
|
495 |
}
|
|
496 |
|
|
497 |
@Override
|
|
498 |
public void widgetDefaultSelected(SelectionEvent e) { }
|
|
499 |
});
|
|
500 |
}
|
|
501 |
}
|
|
502 |
if (advanced_annotation_mode) {
|
|
503 |
Label valueLabel = new Label(annotationArea, SWT.NONE);
|
|
504 |
String valueLabelText = currentKnowledgeRepository.getString(editor.getLocale(), "ConcordancesEditor_80");
|
|
505 |
if (valueLabelText == null) valueLabelText= Messages.ConcordancesEditor_80;
|
|
506 |
valueLabel.setText(valueLabelText);
|
|
507 |
valueLabel.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false));
|
|
508 |
}
|
|
509 |
|
|
510 |
annotationValuesText = new Text(annotationArea, SWT.BORDER);
|
|
511 |
annotationValuesText.setToolTipText(Messages.ConcordancesEditor_32);
|
|
512 |
GridData gdata2 = new GridData(SWT.FILL, SWT.CENTER, false, true);
|
|
513 |
gdata2.widthHint = 200;
|
|
514 |
annotationValuesText.setLayoutData(gdata2);
|
|
515 |
annotationValuesText.addKeyListener(new KeyListener() {
|
|
516 |
@Override
|
|
517 |
public void keyReleased(KeyEvent e) {
|
|
518 |
if (e.keyCode == SWT.CR || e.keyCode == SWT.KEYPAD_CR) {
|
|
519 |
affectAnnotationToSelection(editor.getLineTableViewer().getSelection());
|
|
520 |
}
|
|
521 |
}
|
|
522 |
|
|
523 |
@Override
|
|
524 |
public void keyPressed(KeyEvent e) { }
|
|
525 |
});
|
|
526 |
|
|
527 |
if (currentKnowledgeRepository instanceof LocalKnowledgeRepository) {
|
|
528 |
addTypedValueLink = new Button(annotationArea, SWT.PUSH);
|
|
529 |
addTypedValueLink.setText("..."); //$NON-NLS-1$
|
|
530 |
if (advanced_annotation_mode.equals(RCPMessages.AnnotationPreferences_2)) {
|
|
531 |
addTypedValueLink.setToolTipText(Messages.ConcordancesEditor_79);
|
|
532 |
}else {
|
|
533 |
addTypedValueLink.setToolTipText(Messages.ConcordancesEditor_77);
|
|
534 |
}
|
|
535 |
addTypedValueLink.setEnabled(true);
|
|
536 |
addTypedValueLink.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, true));
|
|
537 |
addTypedValueLink.addSelectionListener(new SelectionListener() {
|
|
538 |
@Override
|
|
539 |
public void widgetSelected(SelectionEvent e) {
|
|
540 |
if (currentKnowledgeRepository == null) return;
|
|
541 |
if (!(currentKnowledgeRepository instanceof LocalKnowledgeRepository)) return;
|
|
542 |
|
|
543 |
AnnotationType type = getSelectedAnnotationType();
|
|
544 |
if (type == null) return;
|
|
545 |
|
|
546 |
LocalKnowledgeRepository kr = (LocalKnowledgeRepository)currentKnowledgeRepository;
|
|
547 |
|
|
548 |
ListDialog dialog = new ListDialog(e.widget.getDisplay().getActiveShell());
|
|
549 |
if (advanced_annotation_mode.equals(RCPMessages.AnnotationPreferences_2)) {
|
|
550 |
String title = currentKnowledgeRepository.getString(editor.getLocale(), "ConcordancesEditor_100");
|
|
551 |
if (title == null) title = Messages.ConcordancesEditor_100;
|
|
552 |
dialog.setTitle(Messages.bind(title, type.getName()));//+"valeurs de "+type.getName());
|
|
553 |
}else {
|
|
554 |
dialog.setTitle(Messages.ConcordancesEditor_99);//+"valeurs de "+type.getName());
|
|
555 |
}
|
|
556 |
dialog.setContentProvider(new ArrayContentProvider());
|
|
557 |
dialog.setLabelProvider(new SimpleLabelProvider() {
|
|
558 |
public String getColumnText(Object element, int columnIndex) {
|
|
559 |
if (element instanceof TypedValue)
|
|
560 |
return ((TypedValue)element).getId();
|
|
561 |
return element.toString();
|
|
562 |
}
|
|
563 |
});
|
|
564 |
List<TypedValue> values;
|
|
565 |
try {
|
|
566 |
values = kr.getValues(type);
|
|
567 |
} catch (Exception e1) {
|
|
568 |
e1.printStackTrace();
|
|
569 |
return;
|
|
570 |
}
|
|
571 |
dialog.setInput(values);
|
|
572 |
if (dialog.open() == InputDialog.OK) {
|
|
573 |
TypedValue value = (TypedValue) dialog.getResult()[0];
|
|
574 |
String name = value.getId();
|
|
575 |
if (name.trim().length() == 0) return;
|
|
576 |
|
|
577 |
annotationValuesText.setText(name);
|
|
578 |
} else {
|
|
579 |
|
|
580 |
}
|
|
581 |
}
|
|
582 |
|
|
583 |
@Override
|
|
584 |
public void widgetDefaultSelected(SelectionEvent e) { }
|
|
585 |
});
|
|
586 |
}
|
|
587 |
|
|
588 |
affectCombo = new Combo(annotationArea, SWT.READ_ONLY);
|
|
589 |
affectCombo.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, true));
|
|
590 |
String items2[] = {Messages.ConcordancesEditor_35, Messages.ConcordancesEditor_42, Messages.ConcordancesEditor_49};
|
|
591 |
affectCombo.setItems(items2);
|
|
592 |
affectCombo.select(0);
|
|
593 |
gdata = new GridData(SWT.CENTER, SWT.CENTER, false, true);
|
|
594 |
gdata.widthHint = 140;
|
|
595 |
affectCombo.setLayoutData(gdata);
|
|
596 |
|
|
597 |
affectAnnotationButton = new Button(annotationArea, SWT.PUSH);
|
|
598 |
affectAnnotationButton.setText(Messages.ConcordancesEditor_85);
|
|
599 |
affectAnnotationButton.setToolTipText(Messages.ConcordancesEditor_116);
|
|
600 |
affectAnnotationButton.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, true));
|
|
601 |
affectAnnotationButton.addSelectionListener(new SelectionListener() {
|
|
602 |
@Override
|
|
603 |
public void widgetSelected(SelectionEvent e) {
|
|
604 |
int isel = affectCombo.getSelectionIndex();
|
|
605 |
if (isel == 0) { // selected line
|
|
606 |
affectAnnotationToSelection(editor.getLineTableViewer().getSelection());
|
|
607 |
} else if (isel == 1) { // page
|
|
608 |
try {
|
|
609 |
List<Match> matches = concordance.getMatches().subList(editor.getTopLine(), editor.getBottomLine()+1);
|
|
610 |
affectMatchesToSelection(matches);
|
|
611 |
} catch (CqiClientException e1) {
|
|
612 |
Log.severe(Messages.ConcordancesEditor_53+e1);
|
|
613 |
Log.printStackTrace(e1);
|
|
614 |
return;
|
|
615 |
}
|
|
616 |
} else { // all
|
|
617 |
try {
|
|
618 |
List<Match> matches = concordance.getMatches();
|
|
619 |
affectMatchesToSelection(matches);
|
|
620 |
} catch (CqiClientException e1) {
|
|
621 |
Log.severe(Messages.ConcordancesEditor_53+e1);
|
|
622 |
Log.printStackTrace(e1);
|
|
623 |
return;
|
|
624 |
}
|
|
625 |
}
|
|
626 |
}
|
|
627 |
|
|
628 |
@Override
|
|
629 |
public void widgetDefaultSelected(SelectionEvent e) { }
|
|
630 |
});
|
|
631 |
Button cancelAnnotateButton = new Button(annotationArea, SWT.PUSH);
|
|
632 |
cancelAnnotateButton.setText(Messages.ConcordancesEditor_101);
|
|
633 |
cancelAnnotateButton.addSelectionListener(new SelectionListener() {
|
|
634 |
@Override
|
|
635 |
public void widgetSelected(SelectionEvent e) {
|
|
636 |
//@TODO Closing the annotation tool bar
|
|
637 |
//System.out.println("must hide");
|
|
638 |
annotationSize = annotationArea.getSize();
|
|
639 |
annotationArea.dispose();
|
|
640 |
annotationArea = null;
|
|
641 |
parent.layout(true);
|
|
642 |
parent.layout();
|
|
643 |
annotationButton.setToolTipText(Messages.ConcordancesEditor_75);
|
|
644 |
annotationButton.setImage(IImageKeys.getImage(IImageKeys.PENCIL));
|
|
645 |
annotationColumn.setWidth(0);
|
|
646 |
annotationColumn.setResizable(false);
|
|
647 |
}
|
|
648 |
|
|
649 |
@Override
|
|
650 |
public void widgetDefaultSelected(SelectionEvent e) { }
|
|
651 |
});
|
|
652 |
|
|
653 |
|
|
654 |
updateAnnotationWidgetStates();
|
|
655 |
|
|
656 |
|
|
657 |
|
|
658 |
parent.layout();
|
|
659 |
}
|
|
660 |
|
|
661 |
protected void affectAnnotationToSelection(ISelection selection) {
|
|
662 |
|
|
663 |
final IStructuredSelection lineSelection = (IStructuredSelection) selection;
|
|
664 |
List<Line> lines = lineSelection.toList();
|
|
665 |
ArrayList<Match> matches = new ArrayList<Match>();
|
|
666 |
for (Line l : lines) matches.add(l.getMatch());
|
|
667 |
|
|
668 |
affectMatchesToSelection(matches);
|
|
669 |
}
|
|
670 |
|
|
671 |
protected AnnotationType getSelectedAnnotationType() {
|
|
672 |
if (annotationTypesCombo != null) {
|
|
673 |
IStructuredSelection isel = (IStructuredSelection)annotationTypesCombo.getSelection();
|
|
674 |
if (isel.isEmpty()) return null;
|
|
675 |
return (AnnotationType) isel.getFirstElement();
|
|
676 |
} else { // simple mode
|
|
677 |
return tagAnnotationType;
|
|
678 |
}
|
|
679 |
}
|
|
680 |
|
|
681 |
protected void affectMatchesToSelection(final List<Match> matches) {
|
|
682 |
final AnnotationType type = getSelectedAnnotationType();
|
|
683 |
final String svalue = annotationValuesText.getText();
|
|
684 |
final boolean doAffect = addRemoveCombo.getSelectionIndex() == 0; // add is default
|
|
685 |
|
|
686 |
JobHandler job = new JobHandler(Messages.ConcordancesEditor_36, true) {
|
|
687 |
@Override
|
|
688 |
protected IStatus run(IProgressMonitor monitor) {
|
|
689 |
this.runInit(monitor);
|
|
690 |
try {
|
|
691 |
if (doAffect) {
|
|
692 |
affectAnnotationValues(matches, type, svalue, this);
|
|
693 |
} else {
|
|
694 |
deleteAnnotationValues(matches, type, this);
|
|
695 |
}
|
|
696 |
} catch(Exception e) {
|
|
697 |
Log.severe(Messages.ConcordancesEditor_40+e);
|
|
698 |
Log.printStackTrace(e);
|
|
699 |
return Status.CANCEL_STATUS;
|
|
700 |
} catch(ThreadDeath td) {
|
|
701 |
System.out.println("Annotation canceled by user.");
|
|
702 |
return Status.CANCEL_STATUS;
|
|
703 |
}
|
|
704 |
|
|
705 |
return Status.OK_STATUS;
|
|
706 |
}
|
|
707 |
};
|
|
708 |
job.startJob(true);
|
|
709 |
}
|
|
710 |
|
|
711 |
public void updateAnnotationWidgetStates() {
|
|
712 |
if (annotationArea == null) return; // :)
|
|
713 |
|
|
714 |
if (addRemoveCombo.getSelectionIndex() == 0) { // add is default
|
|
715 |
|
|
716 |
if (getSelectedAnnotationType() != null) {
|
|
717 |
annotationValuesText.setEnabled(true);
|
|
718 |
|
|
719 |
affectAnnotationButton.setEnabled(true);
|
|
720 |
affectCombo.setEnabled(true);
|
|
721 |
} else {
|
|
722 |
annotationValuesText.setEnabled(false);
|
|
723 |
|
|
724 |
affectAnnotationButton.setEnabled(false);
|
|
725 |
affectCombo.setEnabled(false);
|
|
726 |
}
|
|
727 |
} else {
|
|
728 |
annotationValuesText.setEnabled(false);
|
|
729 |
|
|
730 |
if (getSelectedAnnotationType() != null) {
|
|
731 |
affectAnnotationButton.setEnabled(true);
|
|
732 |
affectCombo.setEnabled(true);
|
|
733 |
} else {
|
|
734 |
affectAnnotationButton.setEnabled(false);
|
|
735 |
affectCombo.setEnabled(false);
|
|
736 |
}
|
|
737 |
}
|
|
738 |
|
|
739 |
if (advanced_annotation_mode.equals(RCPMessages.AnnotationPreferences_2)) {
|
|
740 |
if (infosAnnotTypeSelectedLink != null) infosAnnotTypeSelectedLink.setEnabled(getSelectedAnnotationType() != null);
|
|
741 |
}
|
|
742 |
if (addTypedValueLink != null) addTypedValueLink.setEnabled(getSelectedAnnotationType() != null);
|
|
743 |
|
|
744 |
if (concordance == null) {
|
|
745 |
affectAnnotationButton.setEnabled(false);
|
|
746 |
affectCombo.setEnabled(false);
|
|
747 |
}
|
|
748 |
}
|
|
749 |
|
|
750 |
protected void deleteAnnotationValues(List<Match> matches, AnnotationType type, JobHandler job) {
|
|
751 |
if (concordance == null) return;
|
|
752 |
if (matches.size() == 0) {
|
|
753 |
System.out.println("No lines selected. Aborting."); //$NON-NLS-1$
|
|
754 |
return;
|
|
755 |
}
|
|
756 |
if (type == null) return;
|
|
757 |
|
|
758 |
if (concordance != null) {
|
|
759 |
try {
|
|
760 |
if (annotManager != null && annotManager.deleteAnnotations(type, matches, job)) {
|
|
761 |
if (Log.getLevel().intValue() < Level.WARNING.intValue()) annotManager.checkData();
|
|
762 |
concordance.reloadLines(editor.getTopLine(), editor.getBottomLine()+1);
|
|
763 |
} else {
|
|
764 |
return;
|
|
765 |
}
|
|
766 |
} catch (Exception e1) {
|
|
767 |
System.out.println(Messages.ConcordancesEditor_54+e1);
|
|
768 |
Log.printStackTrace(e1);
|
|
769 |
return;
|
|
770 |
}
|
|
771 |
|
|
772 |
job.syncExec(new Runnable() {
|
|
773 |
@Override
|
|
774 |
public void run() {
|
|
775 |
editor.fillDisplayArea(editor.getTopLine(), editor.getBottomLine()+1);
|
|
776 |
CorporaView.refreshObject(corpus);
|
|
777 |
}
|
|
778 |
});
|
|
779 |
}
|
|
780 |
}
|
|
781 |
|
|
782 |
protected void affectAnnotationValues(final List<Match> matches, final AnnotationType type, final String svalue, JobHandler job) {
|
|
783 |
value_to_add = null; // reset
|
|
784 |
if (concordance == null) {
|
|
785 |
System.out.println("No concordance done. Aborting."); //$NON-NLS-1$
|
|
786 |
return;
|
|
787 |
}
|
|
788 |
if (matches.size() == 0) {
|
|
789 |
System.out.println("No line selected. Aborting."); //$NON-NLS-1$
|
|
790 |
return;
|
|
791 |
}
|
|
792 |
if (type == null) return; // no type, no annotation
|
|
793 |
|
|
794 |
job.syncExec(new Runnable() {
|
|
795 |
@Override
|
|
796 |
public void run() {
|
|
797 |
if (matches.size() > NALERTAFFECTANNOTATIONS) {
|
|
798 |
ConfirmDialog dialog = new ConfirmDialog(Display.getCurrent().getActiveShell(),
|
|
799 |
"confirm_annotate", //$NON-NLS-1$
|
|
800 |
Messages.ConcordancesEditor_86,
|
|
801 |
Messages.ConcordancesEditor_87+matches.size()+Messages.ConcordancesEditor_108);
|
|
802 |
|
|
803 |
if (dialog.open() == ConfirmDialog.CANCEL) {
|
|
804 |
System.out.println("Annotation aborted by user."); //$NON-NLS-1$
|
|
805 |
matches.clear();
|
|
806 |
}
|
|
807 |
}
|
|
808 |
}
|
|
809 |
});
|
|
810 |
|
|
811 |
// get value from combo text value
|
|
812 |
Log.warning(Messages.ConcordancesEditor_57+svalue);
|
|
813 |
final KnowledgeRepository kr = KnowledgeRepositoryManager.getKnowledgeRepository(type.getKnowledgeRepository());
|
|
814 |
value_to_add = kr.getValue(type, svalue);
|
|
815 |
|
|
816 |
|
|
817 |
if (value_to_add == null && kr instanceof LocalKnowledgeRepository) { // create or not the annotation is simple mode
|
|
818 |
job.syncExec(new Runnable() {
|
|
819 |
@Override
|
|
820 |
public void run() {
|
|
821 |
String title = kr.getString(editor.getLocale(), "ConcordancesEditor_110");
|
|
822 |
String content = kr.getString(editor.getLocale(), "ConcordancesEditor_112");
|
|
823 |
if (title == null ) title = Messages.ConcordancesEditor_110;
|
|
824 |
if (content == null ) content = Messages.ConcordancesEditor_112;
|
|
825 |
ConfirmDialog dialog = new ConfirmDialog(Display.getCurrent().getActiveShell(),
|
|
826 |
"create_value", //$NON-NLS-1$
|
|
827 |
Messages.bind(title, svalue, type.getName()),
|
|
828 |
Messages.bind(content, svalue, type.getName()));
|
|
829 |
if (dialog.open() == ConfirmDialog.CANCEL) {
|
|
830 |
System.out.println("Annotation aborted by user."); //$NON-NLS-1$
|
|
831 |
return;
|
|
832 |
} else {
|
|
833 |
value_to_add = kr.addValue(svalue, svalue, type.getId());
|
|
834 |
KRView.refresh();
|
|
835 |
}
|
|
836 |
}
|
|
837 |
});
|
|
838 |
}
|
|
839 |
|
|
840 |
if (value_to_add == null && kr instanceof LocalKnowledgeRepository) return; // canceled
|
|
841 |
|
|
842 |
if (value_to_add == null) {
|
|
843 |
job.syncExec(new Runnable() {
|
|
844 |
@Override
|
|
845 |
public void run() {
|
|
846 |
String mess = Messages.bind(Messages.ConcordancesEditor_58, svalue);
|
|
847 |
System.out.println(mess);
|
|
848 |
MessageDialog.openError(Display.getCurrent().getActiveShell(), "Annotation canceled", mess); //$NON-NLS-1$
|
|
849 |
}
|
|
850 |
});
|
|
851 |
return;
|
|
852 |
}
|
|
853 |
|
|
854 |
Log.info(Messages.ConcordancesEditor_59+value_to_add+Messages.ConcordancesEditor_60+matches);
|
|
855 |
|
|
856 |
// finally we can 'try' to create the annotations \o/
|
|
857 |
try {
|
|
858 |
HashMap<Match, List<Annotation>> existingAnnots = annotManager.createAnnotations(type, value_to_add, matches, job);
|
|
859 |
|
|
860 |
// did we had problems ?
|
|
861 |
if (existingAnnots!=null && existingAnnots.size() > 0) {
|
|
862 |
String message = Messages.ConcordancesEditor_61+value_to_add.getStandardName()+
|
|
863 |
Messages.ConcordancesEditor_62;
|
|
864 |
for (Match m : existingAnnots.keySet()) {
|
|
865 |
message += Messages.ConcordancesEditor_63+m+Messages.ConcordancesEditor_64;
|
|
866 |
|
|
867 |
for (Annotation existingAnnot : existingAnnots.get(m)) {
|
|
868 |
if (existingAnnot.getStart() < m.getStart()){
|
|
869 |
message += Messages.ConcordancesEditor_65+existingAnnot.getType()+Messages.ConcordancesEditor_66+existingAnnot.getStart()+Messages.ConcordancesEditor_67+existingAnnot.getEnd()+Messages.ConcordancesEditor_68;
|
|
870 |
} else {
|
|
871 |
message += Messages.ConcordancesEditor_69+existingAnnot.getType()+Messages.ConcordancesEditor_70+existingAnnot.getStart()+Messages.ConcordancesEditor_71+existingAnnot.getEnd()+Messages.ConcordancesEditor_72;
|
|
872 |
}
|
|
873 |
}
|
|
874 |
}
|
|
875 |
final String final_message = message;
|
|
876 |
job.syncExec(new Runnable() {
|
|
877 |
@Override
|
|
878 |
public void run() {
|
|
879 |
MessageDialog.openInformation(editor.getSite().getShell(), Messages.ConcordancesEditor_73, final_message);
|
|
880 |
}
|
|
881 |
});
|
|
882 |
}
|
|
883 |
// if (history != null && !history.get(type).contains(value_to_add))
|
|
884 |
// history.get(type).add(value_to_add);
|
|
885 |
|
|
886 |
if (Log.getLevel().intValue() < Level.WARNING.intValue() && annotManager != null) annotManager.checkData();
|
|
887 |
concordance.reloadLines(editor.getTopLine(), editor.getBottomLine()+1);
|
|
888 |
} catch (Exception e1) {
|
|
889 |
System.out.println(Messages.ConcordancesEditor_74+e1);
|
|
890 |
Log.printStackTrace(e1);
|
|
891 |
return;
|
|
892 |
}
|
|
893 |
|
|
894 |
job.syncExec(new Runnable() {
|
|
895 |
@Override
|
|
896 |
public void run() {
|
|
897 |
editor.fillDisplayArea(editor.getTopLine(), editor.getBottomLine()+1);
|
|
898 |
CorporaView.refreshObject(corpus);
|
|
899 |
}
|
|
900 |
});
|
|
901 |
|
|
902 |
}
|
|
903 |
|
|
904 |
@Override
|
|
905 |
public boolean notifyStartOfCompute() throws Exception {
|
|
906 |
if (annotationArea != null) {
|
|
907 |
AnnotationType type = getSelectedAnnotationType();
|
|
908 |
if (type != null) {
|
|
909 |
annotations.setViewAnnotation(type);
|
|
910 |
annotations.setAnnotationOverlap(true);
|
|
911 |
}
|
|
912 |
}
|
|
913 |
return true;
|
|
914 |
}
|
|
915 |
|
|
916 |
@Override
|
|
917 |
public boolean notifyEndOfCompute() throws Exception {
|
|
918 |
updateAnnotationWidgetStates();
|
|
919 |
|
|
920 |
// update annotation column width
|
|
921 |
if (annotationArea != null) {
|
|
922 |
annotationColumn.pack();
|
|
923 |
|
|
924 |
annotationColumn.setResizable(true);
|
|
925 |
} else {
|
|
926 |
annotationColumn.setWidth(0);
|
|
927 |
}
|
|
928 |
|
|
929 |
return true;
|
|
930 |
}
|
|
931 |
|
|
932 |
|
|
933 |
public boolean isAnnotationEnable() {
|
|
934 |
return annotationArea != null;
|
|
935 |
}
|
|
936 |
}
|
0 |
937 |
|