Révision 3124
tmp/org.txm.annotation.kr.rcp/src/org/txm/annotation/kr/rcp/commands/SaveAnnotations.java (revision 3124) | ||
---|---|---|
18 | 18 |
import org.txm.annotation.kr.core.KRAnnotationEngine; |
19 | 19 |
import org.txm.core.results.TXMResult; |
20 | 20 |
import org.txm.rcp.editors.ITXMResultEditor; |
21 |
import org.txm.rcp.messages.TXMUIMessages; |
|
21 | 22 |
import org.txm.rcp.utils.JobHandler; |
22 | 23 |
import org.txm.rcp.utils.SWTEditorsUtils; |
23 | 24 |
import org.txm.rcp.views.corpora.CorporaView; |
... | ... | |
105 | 106 |
System.out.println("Error while saving annotations: " + e); |
106 | 107 |
Log.printStackTrace(e); |
107 | 108 |
return Status.CANCEL_STATUS; |
109 |
} catch(ThreadDeath ex) { |
|
110 |
Log.info(TXMUIMessages.executionCanceled); |
|
111 |
return Status.CANCEL_STATUS; |
|
108 | 112 |
} |
109 | 113 |
return Status.OK_STATUS; |
110 | 114 |
} |
tmp/org.txm.annotation.kr.rcp/src/org/txm/annotation/kr/rcp/commands/RecodeCorpus.java (revision 3124) | ||
---|---|---|
28 | 28 |
import org.txm.objects.Project; |
29 | 29 |
import org.txm.rcp.commands.CloseEditorsUsing; |
30 | 30 |
import org.txm.rcp.handlers.scripts.ExecuteImportScript; |
31 |
import org.txm.rcp.messages.TXMUIMessages; |
|
31 | 32 |
import org.txm.rcp.swt.widget.parameters.ParametersDialog; |
32 | 33 |
import org.txm.rcp.utils.JobHandler; |
33 | 34 |
import org.txm.searchengine.cqp.clientExceptions.CqiClientException; |
... | ... | |
70 | 71 |
|
71 | 72 |
@Override |
72 | 73 |
protected IStatus run(IProgressMonitor monitor) { |
74 |
this.runInit(monitor); |
|
75 |
|
|
73 | 76 |
try { |
74 | 77 |
recode(corpus, conversionFile, oldType, newType, monitor); |
75 |
} |
|
76 |
catch (Exception e) { |
|
78 |
} catch (Exception e) { |
|
77 | 79 |
System.out.println("Fail to convert properties of corpus " + corpus); |
78 | 80 |
e.printStackTrace(); |
79 | 81 |
return Status.CANCEL_STATUS; |
82 |
} catch(ThreadDeath ex) { |
|
83 |
Log.info(TXMUIMessages.executionCanceled); |
|
84 |
return Status.CANCEL_STATUS; |
|
80 | 85 |
} |
81 | 86 |
return Status.OK_STATUS; |
82 | 87 |
} |
tmp/org.txm.annotation.kr.rcp/src/org/txm/annotation/kr/rcp/commands/SaveAnnotationsAndUpdateCorpus.java (revision 3124) | ||
---|---|---|
12 | 12 |
import org.eclipse.ui.handlers.HandlerUtil; |
13 | 13 |
import org.txm.annotation.kr.core.KRAnnotationEngine; |
14 | 14 |
import org.txm.rcp.commands.workspace.UpdateCorpus; |
15 |
import org.txm.rcp.messages.TXMUIMessages; |
|
15 | 16 |
import org.txm.rcp.utils.JobHandler; |
16 | 17 |
import org.txm.rcp.views.corpora.CorporaView; |
17 | 18 |
import org.txm.searchengine.cqp.corpus.MainCorpus; |
18 | 19 |
import org.txm.utils.logger.Log; |
19 | 20 |
|
20 | 21 |
public class SaveAnnotationsAndUpdateCorpus extends AbstractHandler { |
21 |
|
|
22 |
|
|
22 | 23 |
public static final String ID = SaveAnnotationsAndUpdateCorpus.class.getCanonicalName(); |
23 |
|
|
24 |
|
|
24 | 25 |
@Override |
25 | 26 |
public Object execute(ExecutionEvent event) throws ExecutionException { |
26 |
|
|
27 |
|
|
27 | 28 |
ISelection sel = HandlerUtil.getCurrentSelection(event); |
28 | 29 |
if (!(sel instanceof IStructuredSelection)) return null; |
29 | 30 |
IStructuredSelection selection = (IStructuredSelection) sel; |
30 |
|
|
31 |
|
|
31 | 32 |
Object s = selection.getFirstElement(); |
32 | 33 |
if (!(s instanceof MainCorpus)) { |
33 | 34 |
return null; |
34 | 35 |
} |
35 | 36 |
MainCorpus corpus = (MainCorpus) s; |
36 | 37 |
try { |
37 |
|
|
38 |
|
|
38 | 39 |
if (!KRAnnotationEngine.needToSaveAnnotations(corpus)) { |
39 | 40 |
Log.info("No annotation to save."); |
40 | 41 |
return null; |
41 | 42 |
} |
42 |
|
|
43 |
|
|
43 | 44 |
Log.info(NLS.bind("Saving {0} annotations...", corpus.getName())); |
44 | 45 |
JobHandler job = SaveAnnotations.save(corpus); |
45 | 46 |
if (job == null) { |
46 | 47 |
return null; |
47 | 48 |
} |
48 |
|
|
49 |
|
|
49 | 50 |
if (job.getState() == Status.OK_STATUS.getCode()) { |
50 | 51 |
JobHandler job2 = new JobHandler("Updating corpus editions and indexes", true) { |
51 |
|
|
52 |
|
|
52 | 53 |
@Override |
53 | 54 |
protected IStatus run(IProgressMonitor monitor) { |
54 |
monitor.setTaskName("updating corpus indexes and editions"); |
|
55 |
if (corpus != null && UpdateCorpus.update(corpus) != null) { |
|
56 |
monitor.worked(50); |
|
57 |
this.syncExec(new Runnable() { |
|
58 |
|
|
59 |
@Override |
|
60 |
public void run() { |
|
61 |
CorporaView.refreshObject(corpus); |
|
62 |
} |
|
63 |
}); |
|
64 |
return Status.OK_STATUS; |
|
65 |
} |
|
66 |
else { |
|
67 |
monitor.worked(50); |
|
68 |
System.out.println("Fail to update corpus. Aborting"); |
|
69 |
System.out.println("Fix XML-TXM files and call command 'UpdateCorpus'"); |
|
55 |
this.runInit(monitor); |
|
56 |
|
|
57 |
try { |
|
58 |
monitor.setTaskName("updating corpus indexes and editions"); |
|
59 |
if (corpus != null && UpdateCorpus.update(corpus) != null) { |
|
60 |
monitor.worked(50); |
|
61 |
this.syncExec(new Runnable() { |
|
62 |
|
|
63 |
@Override |
|
64 |
public void run() { |
|
65 |
CorporaView.refreshObject(corpus); |
|
66 |
} |
|
67 |
}); |
|
68 |
return Status.OK_STATUS; |
|
69 |
} |
|
70 |
else { |
|
71 |
monitor.worked(50); |
|
72 |
System.out.println("Fail to update corpus. Aborting"); |
|
73 |
System.out.println("Fix XML-TXM files and call command 'UpdateCorpus'"); |
|
74 |
return Status.CANCEL_STATUS; |
|
75 |
} |
|
76 |
} catch(ThreadDeath ex) { |
|
77 |
Log.info(TXMUIMessages.executionCanceled); |
|
70 | 78 |
return Status.CANCEL_STATUS; |
71 | 79 |
} |
72 | 80 |
} |
... | ... | |
79 | 87 |
e.printStackTrace(); |
80 | 88 |
return null; |
81 | 89 |
} |
82 |
|
|
90 |
|
|
83 | 91 |
CorporaView.refresh(); |
84 |
|
|
92 |
|
|
85 | 93 |
return corpus; |
86 | 94 |
} |
87 | 95 |
} |
tmp/org.txm.annotation.rcp/src/org/txm/annotation/rcp/editor/AnnotationExtension.java (revision 3124) | ||
---|---|---|
25 | 25 |
import org.txm.rcp.commands.workspace.UpdateCorpus; |
26 | 26 |
import org.txm.rcp.editors.TXMEditorExtension; |
27 | 27 |
import org.txm.rcp.editors.TXMEditorToolBar; |
28 |
import org.txm.rcp.messages.TXMUIMessages; |
|
28 | 29 |
import org.txm.rcp.utils.JobHandler; |
29 | 30 |
import org.txm.rcp.views.corpora.CorporaView; |
30 | 31 |
import org.txm.searchengine.cqp.corpus.MainCorpus; |
31 | 32 |
import org.txm.utils.logger.Log; |
32 | 33 |
|
33 | 34 |
public class AnnotationExtension extends TXMEditorExtension<TXMResult> { |
34 |
|
|
35 |
|
|
35 | 36 |
/** The annotation area. */ |
36 | 37 |
protected ArrayList<AnnotationArea> annotationAreas = new ArrayList<>(); |
37 |
|
|
38 |
|
|
38 | 39 |
private Group controlArea; |
39 |
|
|
40 |
|
|
40 | 41 |
private SelectionListener defaultListener; |
41 |
|
|
42 |
|
|
42 | 43 |
private ToolItem saveButton; |
43 |
|
|
44 |
|
|
44 | 45 |
public static final String GROUP_NAME = "Annotation"; |
45 |
|
|
46 |
|
|
46 | 47 |
@Override |
47 | 48 |
public String getName() { |
48 | 49 |
return GROUP_NAME; |
49 | 50 |
} |
50 |
|
|
51 |
|
|
51 | 52 |
/** |
52 | 53 |
* use this to enable/disable the button |
53 | 54 |
* |
... | ... | |
56 | 57 |
public ToolItem getSaveButton() { |
57 | 58 |
return saveButton; |
58 | 59 |
} |
59 |
|
|
60 |
|
|
60 | 61 |
/** |
61 | 62 |
* install the annotation start button and dropdown list |
62 | 63 |
*/ |
63 | 64 |
@Override |
64 | 65 |
public void notifyEndOfCreatePartControl() throws Exception { |
65 |
|
|
66 |
|
|
66 | 67 |
IConfigurationElement[] config = Platform.getExtensionRegistry().getConfigurationElementsFor(AnnotationArea.class.getName()); |
67 | 68 |
Arrays.sort(config, new Comparator<IConfigurationElement>() { |
68 |
|
|
69 |
|
|
69 | 70 |
@Override |
70 | 71 |
public int compare(IConfigurationElement o1, IConfigurationElement o2) { |
71 | 72 |
return o1.getAttribute("position").compareTo(o2.getAttribute("position")); |
72 | 73 |
} |
73 | 74 |
}); |
74 |
|
|
75 |
|
|
75 | 76 |
ArrayList<String> modes = new ArrayList<>(); |
76 | 77 |
ArrayList<SelectionListener> listeners = new ArrayList<>(); |
77 | 78 |
for (final IConfigurationElement celement : config) { |
78 | 79 |
try { |
79 | 80 |
Object o = celement.createExecutableExtension("class"); //$NON-NLS-1$ |
80 | 81 |
AnnotationArea aa = (AnnotationArea) o; |
81 |
|
|
82 |
|
|
82 | 83 |
if (!aa.getAnnotatedTXMResultClass().equals(editor.getResult().getClass())) { |
83 | 84 |
continue; |
84 | 85 |
} |
85 | 86 |
Log.finer("Installing AnnotationExtension: " + aa.getName()); |
86 | 87 |
modes.add(aa.getName()); // get the annotation name |
87 |
|
|
88 |
|
|
88 | 89 |
listeners.add(new SelectionListener() { // create alistener to instantiate a new AnnotationArea |
89 |
|
|
90 |
|
|
90 | 91 |
@Override |
91 | 92 |
public void widgetSelected(SelectionEvent e) { |
92 | 93 |
try { |
... | ... | |
98 | 99 |
e1.printStackTrace(); |
99 | 100 |
} |
100 | 101 |
} |
101 |
|
|
102 |
|
|
102 | 103 |
@Override |
103 | 104 |
public void widgetDefaultSelected(SelectionEvent e) {} |
104 | 105 |
}); |
... | ... | |
107 | 108 |
exx.printStackTrace(); |
108 | 109 |
} |
109 | 110 |
} |
110 |
|
|
111 |
|
|
111 | 112 |
if (modes.size() == 0) { |
112 | 113 |
return; // no need to show the buttons |
113 | 114 |
} |
114 |
|
|
115 |
|
|
115 | 116 |
SelectionListener openCloseSelectionListener = new SelectionListener() { |
116 |
|
|
117 |
|
|
117 | 118 |
@Override |
118 | 119 |
public void widgetSelected(SelectionEvent e) { |
119 | 120 |
// if (editor.getTopToolbar().isVisible(GROUP_NAME)) { |
... | ... | |
124 | 125 |
// else { |
125 | 126 |
// annotationAreas.clear(); |
126 | 127 |
// } |
127 |
|
|
128 |
|
|
128 | 129 |
if (annotationAreas.size() == 0) { // if no annotation mode is opened, opens the default mode |
129 | 130 |
openDefaultAnnotationMode(e); |
130 | 131 |
} |
131 | 132 |
} |
132 |
|
|
133 |
|
|
133 | 134 |
@Override |
134 | 135 |
public void widgetDefaultSelected(SelectionEvent e) {} |
135 | 136 |
}; |
136 |
|
|
137 |
|
|
137 | 138 |
defaultListener = listeners.get(0); |
138 | 139 |
String defaultMode = modes.get(0); |
139 | 140 |
controlArea = editor.getTopToolbar().installAlternativesGroup(GROUP_NAME, AnnotationUIMessages.annotateWordProperty, |
... | ... | |
141 | 142 |
"platform:/plugin/org.txm.rcp/icons/functions/pencil_close.png", false, |
142 | 143 |
openCloseSelectionListener, modes, listeners); |
143 | 144 |
controlArea.setLayout(new GridLayout(1, true)); |
144 |
|
|
145 |
|
|
145 | 146 |
saveButton = new ToolItem(editor.getTopToolbar(), SWT.PUSH); |
146 | 147 |
saveButton.setImage(IImageKeys.getImage(IImageKeys.PENCIL_SAVE)); |
147 | 148 |
saveButton.addSelectionListener(new SelectionListener() { |
148 |
|
|
149 |
|
|
149 | 150 |
@Override |
150 | 151 |
public void widgetSelected(SelectionEvent e) { |
151 | 152 |
try { |
... | ... | |
156 | 157 |
e1.printStackTrace(); |
157 | 158 |
} |
158 | 159 |
} |
159 |
|
|
160 |
|
|
160 | 161 |
@Override |
161 | 162 |
public void widgetDefaultSelected(SelectionEvent e) {} |
162 | 163 |
}); |
163 | 164 |
saveButton.setEnabled(false); |
164 | 165 |
} |
165 |
|
|
166 |
|
|
166 | 167 |
public void closeAreasPanel() { |
167 | 168 |
editor.getTopToolbar().setVisible(GROUP_NAME, false); |
168 | 169 |
editor.getTopToolbar().getOpenCloseButton().setSelection(false); |
169 | 170 |
saveButton.setEnabled(false); |
170 | 171 |
} |
171 |
|
|
172 |
|
|
172 | 173 |
public void openAnnotationMode(AnnotationArea aa, int position) throws Exception { |
173 | 174 |
// AnnotationArea aa = (AnnotationArea)o; |
174 | 175 |
if (!aa.allowMultipleAnnotations()) { |
... | ... | |
180 | 181 |
removed.addAll(closeAllAreas(aa.getClass())); |
181 | 182 |
annotationAreas.removeAll(removed); |
182 | 183 |
} |
183 |
|
|
184 |
|
|
184 | 185 |
// System.out.println("Starting "+aa.getName()); |
185 |
|
|
186 |
|
|
186 | 187 |
aa.install(editor, AnnotationExtension.this, controlArea, position); |
187 |
|
|
188 |
|
|
188 | 189 |
editor.getTopToolbar().setVisible(GROUP_NAME, true); |
189 | 190 |
annotationAreas.add(aa); |
190 | 191 |
editor.refresh(false); // refresh the concordance display |
191 | 192 |
} |
192 |
|
|
193 |
|
|
193 | 194 |
/** |
194 | 195 |
* |
195 | 196 |
* @param areaToAvoid |
... | ... | |
207 | 208 |
} |
208 | 209 |
return removed; |
209 | 210 |
} |
210 |
|
|
211 |
|
|
211 | 212 |
public void closeArea(AnnotationArea area, boolean closeExtensionIfEmpty) { |
212 | 213 |
if (area != null && !area.getAnnotationArea().isDisposed()) { |
213 | 214 |
area.getAnnotationArea().dispose(); |
214 | 215 |
} |
215 | 216 |
area._close(); |
216 |
|
|
217 |
|
|
217 | 218 |
this.annotationAreas.remove(area); |
218 | 219 |
if (this.annotationAreas.size() == 0 && closeExtensionIfEmpty) { |
219 | 220 |
this.closeAreasPanel(); |
220 | 221 |
} |
221 | 222 |
} |
222 |
|
|
223 |
|
|
223 | 224 |
protected void openDefaultAnnotationMode(SelectionEvent e) { |
224 | 225 |
defaultListener.widgetSelected(e); |
225 | 226 |
} |
226 |
|
|
227 |
|
|
227 | 228 |
@Override |
228 | 229 |
public void notifyStartOfCompute() throws Exception { |
229 | 230 |
for (AnnotationArea aa : annotationAreas) { |
230 | 231 |
aa.notifyStartOfCompute(); |
231 | 232 |
} |
232 | 233 |
} |
233 |
|
|
234 |
|
|
234 | 235 |
@Override |
235 | 236 |
public void notifyEndOfCompute() throws Exception { |
236 | 237 |
for (AnnotationArea aa : annotationAreas) { |
237 | 238 |
aa.notifyEndOfCompute(); |
238 | 239 |
} |
239 | 240 |
} |
240 |
|
|
241 |
|
|
241 |
|
|
242 |
|
|
242 | 243 |
public boolean isAnnotationEnable() { |
243 | 244 |
return annotationAreas != null; |
244 | 245 |
} |
245 |
|
|
246 |
|
|
246 | 247 |
@Override |
247 | 248 |
public void notifyEndOfRefresh() throws Exception { |
248 | 249 |
for (AnnotationArea aa : annotationAreas) { |
249 | 250 |
aa.notifyEndOfRefresh(); |
250 | 251 |
} |
251 | 252 |
} |
252 |
|
|
253 |
|
|
253 | 254 |
@Override |
254 | 255 |
public void notifyStartOfCreatePartControl() throws Exception { |
255 | 256 |
for (AnnotationArea aa : annotationAreas) { |
256 | 257 |
aa.notifyStartOfCreatePartControl(); |
257 | 258 |
} |
258 | 259 |
} |
259 |
|
|
260 |
|
|
260 | 261 |
@Override |
261 | 262 |
public void notifyStartOfRefresh() throws Exception { |
262 | 263 |
for (AnnotationArea aa : annotationAreas) { |
263 | 264 |
aa.notifyStartOfRefresh(); |
264 | 265 |
} |
265 | 266 |
} |
266 |
|
|
267 |
|
|
267 | 268 |
@Override |
268 | 269 |
public boolean isDirty() throws Exception { |
269 | 270 |
boolean dirty = false; |
... | ... | |
272 | 273 |
} |
273 | 274 |
return dirty; |
274 | 275 |
} |
275 |
|
|
276 |
|
|
276 | 277 |
@Override |
277 | 278 |
public boolean isSaveOnCloseNeeded() throws Exception { |
278 | 279 |
return true; |
279 | 280 |
} |
280 |
|
|
281 |
|
|
281 | 282 |
@Override |
282 | 283 |
public void notifyDoSave() throws Exception { |
283 |
boolean needToUpdateIndexes = false; |
|
284 |
// System.out.println("Saving annotations..."); |
|
285 |
if (annotationAreas != null && annotationAreas.size() > 0) { |
|
286 |
for (AnnotationArea aa : annotationAreas) { |
|
287 |
needToUpdateIndexes = needToUpdateIndexes || (aa.needToUpdateIndexes() && aa.isDirty() && aa.save()); |
|
288 |
} |
|
289 |
} |
|
290 |
|
|
291 |
if (needToUpdateIndexes) { |
|
292 |
JobHandler job = new JobHandler("Updating corpus editions and indexes", true) { |
|
293 |
|
|
294 |
@Override |
|
295 |
protected IStatus run(IProgressMonitor monitor) { |
|
296 |
final MainCorpus corpus = editor.getResult().getFirstParent(MainCorpus.class); |
|
297 |
monitor.setTaskName("updating corpus indexes and editions"); |
|
298 |
if (corpus != null && UpdateCorpus.update(corpus) != null) { |
|
299 |
monitor.worked(50); |
|
300 |
this.syncExec(new Runnable() { |
|
301 |
|
|
302 |
@Override |
|
303 |
public void run() { |
|
304 |
CorporaView.refreshObject(corpus); |
|
305 |
} |
|
306 |
}); |
|
307 |
return Status.OK_STATUS; |
|
284 |
|
|
285 |
|
|
286 |
// if (needToUpdateIndexes) { |
|
287 |
JobHandler job = new JobHandler("Updating corpus indexes and editions", true) { |
|
288 |
|
|
289 |
@Override |
|
290 |
protected IStatus run(IProgressMonitor monitor) { |
|
291 |
|
|
292 |
this.runInit(monitor); |
|
293 |
|
|
294 |
try { |
|
295 |
monitor.setTaskName("Updating corpus XML-TXM files"); |
|
296 |
|
|
297 |
boolean needToUpdateIndexes = false; |
|
298 |
// System.out.println("Saving annotations..."); |
|
299 |
if (annotationAreas != null && annotationAreas.size() > 0) { |
|
300 |
for (AnnotationArea aa : annotationAreas) { |
|
301 |
needToUpdateIndexes = needToUpdateIndexes || (aa.needToUpdateIndexes() && aa.isDirty() && aa.save()); |
|
302 |
} |
|
308 | 303 |
} |
309 |
else { |
|
310 |
monitor.worked(50); |
|
311 |
System.out.println("Fail to update corpus. Aborting"); |
|
312 |
System.out.println("Fix XML-TXM files and call command 'UpdateCorpus'"); |
|
313 |
return Status.CANCEL_STATUS; |
|
304 |
|
|
305 |
if (needToUpdateIndexes) { |
|
306 |
final MainCorpus corpus = editor.getResult().getFirstParent(MainCorpus.class); |
|
307 |
monitor.setTaskName("Updating corpus indexes and editions"); |
|
308 |
if (corpus != null && UpdateCorpus.update(corpus) != null) { |
|
309 |
monitor.worked(50); |
|
310 |
this.syncExec(new Runnable() { |
|
311 |
|
|
312 |
@Override |
|
313 |
public void run() { |
|
314 |
CorporaView.refreshObject(corpus); |
|
315 |
} |
|
316 |
}); |
|
317 |
return Status.OK_STATUS; |
|
318 |
} |
|
319 |
else { |
|
320 |
monitor.worked(50); |
|
321 |
System.out.println("Fail to update corpus. Aborting"); |
|
322 |
System.out.println("Fix XML-TXM files and call command 'UpdateCorpus'"); |
|
323 |
return Status.CANCEL_STATUS; |
|
324 |
} |
|
314 | 325 |
} |
326 |
} catch(ThreadDeath ex) { |
|
327 |
Log.info(TXMUIMessages.executionCanceled); |
|
328 |
return Status.CANCEL_STATUS; |
|
315 | 329 |
} |
316 |
}; |
|
317 |
job.schedule(); |
|
318 |
} |
|
330 |
return Status.OK_STATUS; |
|
331 |
} |
|
332 |
}; |
|
333 |
job.schedule(); |
|
334 |
// } |
|
319 | 335 |
} |
320 |
|
|
336 |
|
|
321 | 337 |
@Override |
322 | 338 |
public void notifyDispose() throws Exception { |
323 | 339 |
for (AnnotationArea aa : annotationAreas) { |
324 | 340 |
aa._close(); |
325 | 341 |
} |
326 | 342 |
} |
327 |
|
|
343 |
|
|
328 | 344 |
public void layout() { |
329 | 345 |
if (!controlArea.isDisposed()) { |
330 | 346 |
editor.layout(true); |
331 | 347 |
} |
332 | 348 |
} |
333 |
|
|
349 |
|
|
334 | 350 |
public int getNumberOfAnnotationArea() { |
335 | 351 |
return annotationAreas.size(); |
336 | 352 |
} |
337 |
|
|
353 |
|
|
338 | 354 |
@Override |
339 | 355 |
public Set<Class<? extends TXMResult>> getTXMResultValidClasses() { |
340 | 356 |
HashSet<Class<? extends TXMResult>> h = new HashSet<>(); |
... | ... | |
342 | 358 |
h.add(Text.class); |
343 | 359 |
return h; |
344 | 360 |
} |
345 |
|
|
346 |
|
|
361 |
|
|
362 |
|
|
347 | 363 |
} |
tmp/org.txm.concordance.rcp/src/org/txm/concordance/rcp/widgets/ComplexSortSelector.java (revision 3124) | ||
---|---|---|
45 | 45 |
import org.txm.concordance.core.functions.comparators.LineComparator; |
46 | 46 |
import org.txm.concordance.rcp.editors.ConcordanceEditor; |
47 | 47 |
import org.txm.rcp.messages.TXMUIMessages; |
48 |
import org.txm.rcp.swt.GLComposite; |
|
48 | 49 |
import org.txm.utils.logger.Log; |
49 | 50 |
// TODO: Auto-generated Javadoc |
50 | 51 |
/** |
51 | 52 |
* allow to build a Composite sorter of 1 to 4 keys @ author mdecorde. |
52 | 53 |
*/ |
53 |
public class ComplexSortSelector extends Composite { |
|
54 |
public class ComplexSortSelector extends GLComposite {
|
|
54 | 55 |
|
55 | 56 |
/** The standard comparators. */ |
56 | 57 |
HashMap<String, LineComparator> standardComparators = new HashMap<String, LineComparator>(); |
... | ... | |
83 | 84 |
* @param style the style |
84 | 85 |
*/ |
85 | 86 |
public ComplexSortSelector(Composite parent, int style) { |
86 |
super(parent, style); |
|
87 |
GridLayout gl = new GridLayout(10, false); |
|
88 |
gl.marginWidth = 0;
|
|
89 |
gl.marginLeft = 0;
|
|
90 |
gl.marginRight = 0;
|
|
91 |
this.setLayout(gl);
|
|
87 |
super(parent, style, "complex sorter");
|
|
88 |
|
|
89 |
GridLayout gl = this.getLayout();
|
|
90 |
gl.marginWidth = gl.marginLeft = gl.marginRight = 0;
|
|
91 |
gl.horizontalSpacing = 1;
|
|
92 |
this.getLayout().numColumns = 10;
|
|
92 | 93 |
|
93 | 94 |
SelectionListener listener = new SelectionListener() { |
94 | 95 |
@Override |
... | ... | |
100 | 101 |
public void widgetDefaultSelected(SelectionEvent e) { |
101 | 102 |
} |
102 | 103 |
}; |
103 |
new Label(this, SWT.NONE).setText(TXMUIMessages.sortKeys); |
|
104 |
new Label(this, SWT.NONE).setText("#1"); //$NON-NLS-1$ |
|
104 |
|
|
105 |
Label l = new Label(this, SWT.NONE); |
|
106 |
l.setLayoutData(new GridData()); |
|
107 |
l.setText(TXMUIMessages.sortKeys); |
|
108 |
|
|
109 |
l = new Label(this, SWT.NONE); |
|
110 |
l.setLayoutData(new GridData()); |
|
111 |
l.setText("#1"); //$NON-NLS-1$ |
|
112 |
|
|
105 | 113 |
firstKey = new Combo(this, SWT.NONE | SWT.READ_ONLY); |
106 |
//firstKey.addSelectionListener(listener); |
|
107 |
GridData griddata = new GridData(GridData.FILL, GridData.FILL, false, |
|
108 |
true); |
|
109 |
griddata.widthHint = 100; |
|
114 |
GridData griddata = new GridData(GridData.FILL, GridData.FILL, false, true); |
|
115 |
//griddata.widthHint = 100; |
|
110 | 116 |
firstKey.setLayoutData(griddata); |
111 | 117 |
|
112 |
new Label(this, SWT.NONE).setText("#2"); //$NON-NLS-1$ |
|
118 |
l = new Label(this, SWT.NONE); |
|
119 |
l.setLayoutData(new GridData()); |
|
120 |
l.setText("#2"); //$NON-NLS-1$ |
|
121 |
|
|
113 | 122 |
secondKey = new Combo(this, SWT.NONE | SWT.READ_ONLY); |
114 |
//secondKey.addSelectionListener(listener);
|
|
123 |
griddata = new GridData(GridData.FILL, GridData.FILL, false, true);
|
|
115 | 124 |
secondKey.setLayoutData(griddata); |
116 | 125 |
|
117 |
new Label(this, SWT.NONE).setText("#3"); //$NON-NLS-1$ |
|
126 |
l = new Label(this, SWT.NONE); |
|
127 |
l.setLayoutData(new GridData()); |
|
128 |
l.setText("#3"); //$NON-NLS-1$ |
|
129 |
|
|
118 | 130 |
thirdKey = new Combo(this, SWT.NONE | SWT.READ_ONLY); |
119 |
//thirdKey.addSelectionListener(listener);
|
|
131 |
griddata = new GridData(GridData.FILL, GridData.FILL, false, true);
|
|
120 | 132 |
thirdKey.setLayoutData(griddata); |
121 | 133 |
|
122 |
new Label(this, SWT.NONE).setText("#4"); //$NON-NLS-1$ |
|
134 |
l = new Label(this, SWT.NONE); |
|
135 |
l.setLayoutData(new GridData()); |
|
136 |
l.setText("#4"); //$NON-NLS-1$ |
|
137 |
|
|
123 | 138 |
fourthKey = new Combo(this, SWT.NONE | SWT.READ_ONLY); |
124 |
//fourthKey.addSelectionListener(listener);
|
|
139 |
griddata = new GridData(GridData.FILL, GridData.FILL, false, true);
|
|
125 | 140 |
fourthKey.setLayoutData(griddata); |
126 | 141 |
|
127 | 142 |
Button sortButton = new Button(this, SWT.PUSH); |
128 | 143 |
sortButton.setText(TXMUIMessages.sort); |
129 | 144 |
sortButton.addSelectionListener(listener); |
130 |
|
|
145 |
sortButton.setLayoutData(new GridData()); |
|
131 | 146 |
} |
132 | 147 |
|
133 | 148 |
/** |
tmp/org.txm.concordance.rcp/src/org/txm/concordance/rcp/editors/ConcordanceEditor.java (revision 3124) | ||
---|---|---|
25 | 25 |
// |
26 | 26 |
package org.txm.concordance.rcp.editors; |
27 | 27 |
|
28 |
import java.io.IOException; |
|
28 | 29 |
import java.util.ArrayList; |
29 | 30 |
import java.util.Arrays; |
30 | 31 |
import java.util.List; |
... | ... | |
60 | 61 |
import org.eclipse.swt.events.SelectionAdapter; |
61 | 62 |
import org.eclipse.swt.events.SelectionEvent; |
62 | 63 |
import org.eclipse.swt.events.SelectionListener; |
64 |
import org.eclipse.swt.graphics.Color; |
|
63 | 65 |
import org.eclipse.swt.graphics.GC; |
64 | 66 |
import org.eclipse.swt.graphics.Point; |
65 | 67 |
import org.eclipse.swt.graphics.Rectangle; |
... | ... | |
123 | 125 |
import org.txm.rcp.swt.widget.ReferencePatternSelector; |
124 | 126 |
import org.txm.rcp.utils.JobHandler; |
125 | 127 |
import org.txm.rcp.views.QueriesView; |
128 |
import org.txm.searchengine.core.SearchEngine; |
|
126 | 129 |
import org.txm.searchengine.cqp.CQPSearchEngine; |
127 | 130 |
import org.txm.searchengine.cqp.ReferencePattern; |
128 | 131 |
import org.txm.searchengine.cqp.clientExceptions.CqiClientException; |
132 |
import org.txm.searchengine.cqp.clientExceptions.UnexpectedAnswerException; |
|
129 | 133 |
import org.txm.searchengine.cqp.core.messages.CQPSearchEngineCoreMessages; |
130 | 134 |
import org.txm.searchengine.cqp.corpus.CQPCorpus; |
131 | 135 |
import org.txm.searchengine.cqp.corpus.Property; |
132 | 136 |
import org.txm.searchengine.cqp.corpus.WordProperty; |
137 |
import org.txm.searchengine.cqp.serverException.CqiServerError; |
|
133 | 138 |
import org.txm.utils.TXMProgressMonitor; |
134 | 139 |
import org.txm.utils.logger.Log; |
135 | 140 |
|
... | ... | |
314 | 319 |
private TableViewerColumn keywordColumnViewer; |
315 | 320 |
|
316 | 321 |
private TableViewerColumn rightContextColumnViewer; |
322 |
|
|
323 |
//tmp background |
|
324 |
private Color queryWidgetInitBackground = null; |
|
317 | 325 |
|
318 | 326 |
// private PropertiesSelector<Property> propsArea; |
319 | 327 |
|
... | ... | |
1289 | 1297 |
deleteLineButton = new Button(navigationArea, SWT.PUSH); |
1290 | 1298 |
deleteLineButton.setLayoutData(new GridData(GridData.FILL, GridData.FILL, false, false)); |
1291 | 1299 |
deleteLineButton.setToolTipText(ConcordanceUIMessages.deleteSelectedLines); |
1292 |
deleteLineButton.setImage(IImageKeys.getImage(IImageKeys.ACTION_DELETE));
|
|
1300 |
deleteLineButton.setImage(IImageKeys.getImage("org.txm.concordance.rcp", "icons/concordance_line_delete.png"));
|
|
1293 | 1301 |
deleteLineButton.addSelectionListener(new SelectionListener() { |
1294 | 1302 |
|
1295 | 1303 |
@Override |
... | ... | |
1456 | 1464 |
|
1457 | 1465 |
this.queryWidget.memorize(); |
1458 | 1466 |
|
1467 |
if (getResult().isDirty()) { // the result compute failed |
|
1468 |
SearchEngine se = getResult().getQuery().getSearchEngine(); |
|
1469 |
if (se instanceof CQPSearchEngine) { |
|
1470 |
try { |
|
1471 |
String error = CQPSearchEngine.getCqiClient().getLastCQPError(); |
|
1472 |
if ( error.contains("undefined") || |
|
1473 |
error.contains("Illegal regular expression") || |
|
1474 |
error.contains("syntax error") || |
|
1475 |
error.contains("does not exist")) { |
|
1476 |
if (queryWidgetInitBackground == null) queryWidgetInitBackground = queryWidget.getBackground(); |
|
1477 |
queryWidget.setBackground(new Color(queryWidget.getDisplay(), 255, 0, 0, 30)); |
|
1478 |
} |
|
1479 |
} catch (Exception e1) { |
|
1480 |
e1.printStackTrace(); |
|
1481 |
} |
|
1482 |
} |
|
1483 |
} else { |
|
1484 |
if (queryWidgetInitBackground != null) queryWidget.setBackground(queryWidgetInitBackground); |
|
1485 |
} |
|
1486 |
|
|
1459 | 1487 |
if (update) { |
1460 | 1488 |
resetColumnWidths(); |
1461 | 1489 |
} |
tmp/org.txm.analec.rcp/src/org/txm/annotation/urs/toolbar/URSAnnotationToolbar.java (revision 3124) | ||
---|---|---|
95 | 95 |
vue = URSCorpora.getVue(maincorpus); |
96 | 96 |
|
97 | 97 |
annotationArea = new GLComposite(parent, SWT.NONE, "Unit annotation"); |
98 |
annotationArea.getLayout().horizontalSpacing = 1; |
|
98 | 99 |
|
99 | 100 |
if (getEditorClickListener() != null) |
100 | 101 |
editor.getEditionPanel(0).getBrowser().addMouseListener(getEditorClickListener()); |
tmp/org.txm.analec.rcp/src/org/txm/annotation/urs/toolbar/UnitConcordanceToolbar.java (revision 3124) | ||
---|---|---|
53 | 53 |
import org.txm.objects.Match; |
54 | 54 |
import org.txm.rcp.IImageKeys; |
55 | 55 |
import org.txm.rcp.editors.TXMEditor; |
56 |
import org.txm.rcp.messages.TXMUIMessages; |
|
56 | 57 |
import org.txm.rcp.swt.GLComposite; |
57 | 58 |
import org.txm.rcp.swt.provider.SimpleLabelProvider; |
58 | 59 |
import org.txm.rcp.utils.JobHandler; |
... | ... | |
463 | 464 |
Log.printStackTrace(e); |
464 | 465 |
return Status.CANCEL_STATUS; |
465 | 466 |
} |
466 |
catch (ThreadDeath td) {
|
|
467 |
System.out.println("Canceled");
|
|
467 |
catch(ThreadDeath ex) {
|
|
468 |
Log.info(TXMUIMessages.executionCanceled);
|
|
468 | 469 |
return Status.CANCEL_STATUS; |
469 | 470 |
} |
470 | 471 |
|
Formats disponibles : Unified diff