Révision 3653
TXM/trunk/bundles/org.txm.annotation.kr.rcp/plugin.xml (revision 3653) | ||
---|---|---|
1 |
<?xml version="1.0" encoding="UTF-8"?> |
|
2 |
<?eclipse version="3.4"?> |
|
3 |
<plugin> |
|
4 |
<extension |
|
5 |
point="org.eclipse.ui.commands"> |
|
6 |
<command |
|
7 |
categoryId="org.txm.rcp.category.txm" |
|
8 |
defaultHandler="org.txm.rcp.commands.workspace.RecodeCorpus" |
|
9 |
id="org.txm.rcp.commands.workspace.RecodeCorpus" |
|
10 |
name="%command.name"> |
|
11 |
</command> |
|
12 |
<command |
|
13 |
categoryId="org.txm.rcp.category.txm" |
|
14 |
defaultHandler="org.txm.annotation.kr.rcp.commands.SaveAnnotations" |
|
15 |
id="org.txm.rcp.commands.annotation.SaveAnnotations" |
|
16 |
name="%command.name.0"> |
|
17 |
</command> |
|
18 |
<command |
|
19 |
defaultHandler="org.txm.annotation.kr.rcp.commands.krview.OpenKRView" |
|
20 |
id="org.txm.rcp.commands.krview.OpenKRView" |
|
21 |
name="%command.name.1"> |
|
22 |
</command> |
|
23 |
<command |
|
24 |
defaultHandler="org.txm.annotation.kr.rcp.commands.krview.Copy" |
|
25 |
id="org.txm.rcp.commands.krview.Copy" |
|
26 |
name="%command.name.2"> |
|
27 |
</command> |
|
28 |
<command |
|
29 |
defaultHandler="org.txm.annotation.kr.rcp.commands.krview.Reload" |
|
30 |
id="org.txm.rcp.commands.krview.Reload" |
|
31 |
name="%command.name.3"> |
|
32 |
</command> |
|
33 |
<command |
|
34 |
defaultHandler="org.txm.annotation.kr.rcp.commands.krview.Informations" |
|
35 |
id="org.txm.rcp.commands.krview.Informations" |
|
36 |
name="%command.name.4"> |
|
37 |
</command> |
|
38 |
<command |
|
39 |
defaultHandler="org.txm.annotation.kr.rcp.commands.krview.Delete" |
|
40 |
id="org.txm.rcp.commands.krview.Delete" |
|
41 |
name="%command.name.5"> |
|
42 |
</command> |
|
43 |
<command |
|
44 |
defaultHandler="org.txm.annotation.kr.rcp.commands.krview.Add" |
|
45 |
id="org.txm.rcp.commands.krview.Add" |
|
46 |
name="%command.name.6"> |
|
47 |
</command> |
|
48 |
<command |
|
49 |
defaultHandler="org.txm.annotation.kr.rcp.commands.ExportStandoff" |
|
50 |
id="org.txm.rcp.commands.annotation.ExportStandoff" |
|
51 |
name="%command.name.7"> |
|
52 |
</command> |
|
53 |
<command |
|
54 |
categoryId="org.txm.rcp.category.txm" |
|
55 |
defaultHandler="org.txm.annotation.kr.rcp.commands.SaveAnnotationsAndUpdateCorpus" |
|
56 |
id="org.txm.annotation.kr.rcp.commands.SaveAnnotationsAndUpdateCorpus" |
|
57 |
name="%command.label.111"> |
|
58 |
</command> |
|
59 |
<command |
|
60 |
defaultHandler="org.txm.annotation.kr.rcp.commands.ExportTable" |
|
61 |
id="org.txm.annotation.kr.rcp.commands.ExportTable" |
|
62 |
name="%command.name.8"> |
|
63 |
</command> |
|
64 |
<command |
|
65 |
defaultHandler="org.txm.annotation.kr.rcp.commands.ImportTable" |
|
66 |
id="org.txm.annotation.kr.rcp.commands.ImportTable" |
|
67 |
name="%command.name.9"> |
|
68 |
</command> |
|
69 |
</extension> |
|
70 |
<extension |
|
71 |
point="org.eclipse.ui.preferencePages"> |
|
72 |
<page |
|
73 |
category="org.txm.annotation.rcp.preferences.AnnotationPreferencePage" |
|
74 |
class="org.txm.annotation.kr.rcp.preferences.KRAnnotationPreferencePage" |
|
75 |
id="org.txm.annotation.kr.rcp.preferences.KRAnnotationPreferencePage" |
|
76 |
name="%page.name.0"> |
|
77 |
</page> |
|
78 |
</extension> |
|
79 |
<extension |
|
80 |
point="org.eclipse.ui.views"> |
|
81 |
<view |
|
82 |
category="org.txm.rcp" |
|
83 |
class="org.txm.annotation.kr.rcp.views.knowledgerepositories.KRView" |
|
84 |
id="org.txm.annotation.kr.rcp.views.knowledgerepositories.KRView" |
|
85 |
name="%view.name" |
|
86 |
restorable="true"> |
|
87 |
</view> |
|
88 |
</extension> |
|
89 |
<extension |
|
90 |
point="org.eclipse.ui.bindings"> |
|
91 |
<key |
|
92 |
commandId="org.txm.rcp.commands.krview.Add" |
|
93 |
contextId="org.txm.rcp.annotation.krview" |
|
94 |
schemeId="org.txm.rcp.scheme" |
|
95 |
sequence="Ctrl+A"> |
|
96 |
</key> |
|
97 |
<key |
|
98 |
commandId="org.txm.rcp.commands.krview.Reload" |
|
99 |
contextId="org.txm.rcp.annotation.krview" |
|
100 |
schemeId="org.txm.rcp.scheme" |
|
101 |
sequence="Ctrl+R"> |
|
102 |
</key> |
|
103 |
<key |
|
104 |
commandId="org.txm.rcp.commands.krview.Informations" |
|
105 |
contextId="org.txm.rcp.annotation.krview" |
|
106 |
schemeId="org.txm.rcp.scheme" |
|
107 |
sequence="Ctrl+I"> |
|
108 |
</key> |
|
109 |
<key |
|
110 |
commandId="org.txm.rcp.commands.krview.Copy" |
|
111 |
contextId="org.txm.rcp.annotation.krview" |
|
112 |
schemeId="org.txm.rcp.scheme" |
|
113 |
sequence="Ctrl+C"> |
|
114 |
</key> |
|
115 |
<key |
|
116 |
commandId="org.txm.rcp.commands.krview.Delete" |
|
117 |
contextId="org.txm.rcp.annotation.krview" |
|
118 |
schemeId="org.txm.rcp.scheme" |
|
119 |
sequence="Ctrl+D"> |
|
120 |
</key> |
|
121 |
</extension> |
|
122 |
<extension |
|
123 |
point="org.eclipse.ui.menus"> |
|
124 |
<menuContribution |
|
125 |
allPopups="false" |
|
126 |
locationURI="menu:menu.display.views?before=menu.display.views.separator"> |
|
127 |
<command |
|
128 |
commandId="org.txm.rcp.commands.krview.OpenKRView" |
|
129 |
label="%command.label" |
|
130 |
style="push"> |
|
131 |
</command> |
|
132 |
</menuContribution> |
|
133 |
<menuContribution |
|
134 |
locationURI="popup:org.txm.annotation.kr.rcp.views.knowledgerepositories.KRView"> |
|
135 |
<command |
|
136 |
commandId="org.txm.rcp.commands.krview.Copy" |
|
137 |
style="push" |
|
138 |
tooltip="%command.tooltip.89"> |
|
139 |
</command> |
|
140 |
<command |
|
141 |
commandId="org.txm.rcp.commands.krview.Reload" |
|
142 |
style="push" |
|
143 |
tooltip="%command.tooltip.90"> |
|
144 |
<visibleWhen |
|
145 |
checkEnabled="false"> |
|
146 |
<reference |
|
147 |
definitionId="OneKRSelected"> |
|
148 |
</reference> |
|
149 |
</visibleWhen> |
|
150 |
</command> |
|
151 |
<command |
|
152 |
commandId="org.txm.rcp.commands.krview.Informations" |
|
153 |
style="push" |
|
154 |
tooltip="%command.tooltip.93"> |
|
155 |
</command> |
|
156 |
<command |
|
157 |
commandId="org.txm.rcp.commands.krview.Add" |
|
158 |
style="push" |
|
159 |
tooltip="%command.tooltip.94"> |
|
160 |
<visibleWhen |
|
161 |
checkEnabled="false"> |
|
162 |
<or> |
|
163 |
<reference |
|
164 |
definitionId="OneLocalKRSelected"> |
|
165 |
</reference> |
|
166 |
<reference |
|
167 |
definitionId="OneAnnotationTypeSelected"> |
|
168 |
</reference> |
|
169 |
</or> |
|
170 |
</visibleWhen> |
|
171 |
</command> |
|
172 |
<command |
|
173 |
commandId="org.txm.rcp.commands.krview.Delete" |
|
174 |
style="push" |
|
175 |
tooltip="%command.tooltip.95"> |
|
176 |
<visibleWhen |
|
177 |
checkEnabled="false"> |
|
178 |
<or> |
|
179 |
<reference |
|
180 |
definitionId="OneAnnotationTypeSelected"> |
|
181 |
</reference> |
|
182 |
<reference |
|
183 |
definitionId="OneTypedValueSelected"> |
|
184 |
</reference> |
|
185 |
</or> |
|
186 |
</visibleWhen> |
|
187 |
</command> |
|
188 |
</menuContribution> |
|
189 |
<menuContribution |
|
190 |
allPopups="false" |
|
191 |
locationURI="menu:menu.file.export.properties"> |
|
192 |
<command |
|
193 |
commandId="org.txm.rcp.commands.annotation.ExportStandoff" |
|
194 |
id="menu.file.export.exporttei" |
|
195 |
label="%command.label.0" |
|
196 |
style="push"> |
|
197 |
<visibleWhen |
|
198 |
checkEnabled="false"> |
|
199 |
<reference |
|
200 |
definitionId="OneMainCorpusSelected"> |
|
201 |
</reference> |
|
202 |
</visibleWhen> |
|
203 |
</command> |
|
204 |
</menuContribution> |
|
205 |
<menuContribution |
|
206 |
allPopups="false" |
|
207 |
locationURI="menu:menu.file.export.annotations"> |
|
208 |
<command |
|
209 |
commandId="org.txm.annotation.kr.rcp.commands.ExportTable" |
|
210 |
id="menu.file.export.exporttable" |
|
211 |
label="%command.label.1" |
|
212 |
style="push"> |
|
213 |
<visibleWhen |
|
214 |
checkEnabled="false"> |
|
215 |
<reference |
|
216 |
definitionId="OneMainCorpusSelected"> |
|
217 |
</reference> |
|
218 |
</visibleWhen> |
|
219 |
</command> |
|
220 |
</menuContribution> |
|
221 |
<menuContribution |
|
222 |
allPopups="false" |
|
223 |
locationURI="menu:corporaview.menu.file.export?after=org.txm.rcp.views.corpora.CorporaView.annotation"> |
|
224 |
<command |
|
225 |
commandId="org.txm.rcp.commands.annotation.ExportStandoff" |
|
226 |
label="%command.label.0" |
|
227 |
style="push"> |
|
228 |
<visibleWhen |
|
229 |
checkEnabled="false"> |
|
230 |
<reference |
|
231 |
definitionId="OneMainCorpusSelected"> |
|
232 |
</reference> |
|
233 |
</visibleWhen> |
|
234 |
</command> |
|
235 |
<command |
|
236 |
commandId="org.txm.annotation.kr.rcp.commands.ExportTable" |
|
237 |
label="%command.label.1" |
|
238 |
style="push"> |
|
239 |
<visibleWhen |
|
240 |
checkEnabled="false"> |
|
241 |
<reference |
|
242 |
definitionId="OneMainCorpusSelected"> |
|
243 |
</reference> |
|
244 |
</visibleWhen> |
|
245 |
</command> |
|
246 |
</menuContribution> |
|
247 |
<menuContribution |
|
248 |
allPopups="false" |
|
249 |
locationURI="menu:menu.corpus?after=menu.corpus.build"> |
|
250 |
<command |
|
251 |
commandId="org.txm.annotation.kr.rcp.commands.SaveAnnotationsAndUpdateCorpus" |
|
252 |
icon="icons/functions/pencil_save.png" |
|
253 |
label="%command.label.111" |
|
254 |
style="push"> |
|
255 |
</command> |
|
256 |
</menuContribution> |
|
257 |
<menuContribution |
|
258 |
allPopups="false" |
|
259 |
locationURI="popup:org.txm.rcp.views.corpora.CorporaView"> |
|
260 |
<command |
|
261 |
commandId="org.txm.annotation.kr.rcp.commands.SaveAnnotationsAndUpdateCorpus" |
|
262 |
icon="icons/functions/pencil_save.png" |
|
263 |
label="%command.label.111" |
|
264 |
style="push"> |
|
265 |
<visibleWhen |
|
266 |
checkEnabled="false"> |
|
267 |
<reference |
|
268 |
definitionId="CorpusNeedtoSaveAnnotation"> |
|
269 |
</reference> |
|
270 |
</visibleWhen> |
|
271 |
</command> |
|
272 |
</menuContribution> |
|
273 |
<menuContribution |
|
274 |
allPopups="false" |
|
275 |
locationURI="toolbar:org.txm.rcp.toolbarcorpus?after=org.txm.rcp.toolbarcorpus.annotation"> |
|
276 |
<command |
|
277 |
commandId="org.txm.annotation.kr.rcp.commands.SaveAnnotationsAndUpdateCorpus" |
|
278 |
icon="icons/functions/pencil_save.png" |
|
279 |
label="CQP" |
|
280 |
mode="FORCE_TEXT" |
|
281 |
style="push" |
|
282 |
tooltip="CQP"> |
|
283 |
</command> |
|
284 |
</menuContribution> |
|
285 |
<menuContribution |
|
286 |
locationURI="menu:menu.file.import.annotations"> |
|
287 |
<command |
|
288 |
commandId="org.txm.annotation.kr.rcp.commands.ImportTable" |
|
289 |
label="%command.label.2" |
|
290 |
style="push"> |
|
291 |
<visibleWhen |
|
292 |
checkEnabled="false"> |
|
293 |
<reference |
|
294 |
definitionId="OneMainCorpusSelected"> |
|
295 |
</reference> |
|
296 |
</visibleWhen> |
|
297 |
</command> |
|
298 |
</menuContribution> |
|
299 |
</extension> |
|
300 |
<extension |
|
301 |
point="org.eclipse.ui.contexts"> |
|
302 |
<context |
|
303 |
description="%context.description" |
|
304 |
id="org.txm.rcp.annotation.krview" |
|
305 |
name="%context.name"> |
|
306 |
</context> |
|
307 |
</extension> |
|
308 |
<extension |
|
309 |
point="org.eclipse.core.expressions.definitions"> |
|
310 |
<definition |
|
311 |
id="OneKRSelected"> |
|
312 |
<with |
|
313 |
variable="selection"> |
|
314 |
<iterate |
|
315 |
ifEmpty="false" |
|
316 |
operator="and"> |
|
317 |
<instanceof |
|
318 |
value="org.txm.annotation.KnowledgeRepository"> |
|
319 |
</instanceof> |
|
320 |
</iterate> |
|
321 |
</with> |
|
322 |
</definition> |
|
323 |
<definition |
|
324 |
id="OneLocalKRSelected"> |
|
325 |
<with |
|
326 |
variable="selection"> |
|
327 |
<iterate |
|
328 |
ifEmpty="false" |
|
329 |
operator="and"> |
|
330 |
<instanceof |
|
331 |
value="org.txm.annotation.repository.LocalKnowledgeRepository"> |
|
332 |
</instanceof> |
|
333 |
</iterate> |
|
334 |
</with> |
|
335 |
</definition> |
|
336 |
<definition |
|
337 |
id="OneAnnotationTypeSelected"> |
|
338 |
<with |
|
339 |
variable="selection"> |
|
340 |
<iterate |
|
341 |
ifEmpty="false" |
|
342 |
operator="and"> |
|
343 |
<instanceof |
|
344 |
value="org.txm.annotation.repository.AnnotationType"> |
|
345 |
</instanceof> |
|
346 |
</iterate> |
|
347 |
</with> |
|
348 |
</definition> |
|
349 |
<definition |
|
350 |
id="OneTypedValueSelected"> |
|
351 |
<with |
|
352 |
variable="selection"> |
|
353 |
<iterate |
|
354 |
ifEmpty="false" |
|
355 |
operator="and"> |
|
356 |
<instanceof |
|
357 |
value="org.txm.annotation.repository.TypedValue"> |
|
358 |
</instanceof> |
|
359 |
</iterate> |
|
360 |
</with> |
|
361 |
</definition> |
|
362 |
<definition |
|
363 |
id="CorpusNeedtoSaveAnnotation"> |
|
364 |
<and> |
|
365 |
<test |
|
366 |
forcePluginActivation="true" |
|
367 |
property="org.txm.rcp.testers.IsCorpusDirty"> |
|
368 |
</test> |
|
369 |
</and> |
|
370 |
</definition> |
|
371 |
</extension> |
|
372 |
|
|
373 |
<extension |
|
374 |
point="org.eclipse.core.expressions.propertyTesters"> |
|
375 |
<propertyTester |
|
376 |
class="org.txm.rcp.testers.IsCorpusDirty" |
|
377 |
id="org.txm.rcp.testers.IsCorpusDirty" |
|
378 |
namespace="org.txm.rcp.testers" |
|
379 |
properties="IsCorpusDirty" |
|
380 |
type="java.lang.Object"> |
|
381 |
</propertyTester> |
|
382 |
</extension> |
|
383 |
|
|
384 |
<extension |
|
385 |
point="org.txm.annotation.rcp.editor.AnnotationArea"> |
|
386 |
<annotationtoolbar |
|
387 |
class="org.txm.annotation.kr.rcp.concordance.KRAnnotation" |
|
388 |
position="3"> |
|
389 |
</annotationtoolbar> |
|
390 |
<annotationtoolbar |
|
391 |
class="org.txm.annotation.kr.rcp.concordance.WordAnnotationToolbar" |
|
392 |
position="1"> |
|
393 |
</annotationtoolbar> |
|
394 |
<annotationtoolbar |
|
395 |
class="org.txm.annotation.kr.rcp.concordance.SimpleKRAnnotation" |
|
396 |
position="2"> |
|
397 |
</annotationtoolbar> |
|
398 |
</extension> |
|
399 |
</plugin> |
|
0 | 400 |
TXM/trunk/bundles/org.txm.annotation.kr.rcp/.settings/org.eclipse.core.resources.prefs (revision 3653) | ||
---|---|---|
1 |
eclipse.preferences.version=1 |
|
2 |
encoding//src/org/txm/annotation/kr/rcp/messages/messages.properties=UTF-8 |
|
3 |
encoding//src/org/txm/annotation/kr/rcp/messages/messages_fr.properties=UTF-8 |
|
0 | 4 |
TXM/trunk/bundles/org.txm.annotation.kr.rcp/.classpath (revision 3653) | ||
---|---|---|
1 |
<?xml version="1.0" encoding="UTF-8"?> |
|
2 |
<classpath> |
|
3 |
<classpathentry kind="con" |
|
4 |
path="org.eclipse.jdt.launching.JRE_CONTAINER" /> |
|
5 |
<classpathentry kind="con" |
|
6 |
path="org.eclipse.pde.core.requiredPlugins"> |
|
7 |
<accessrules> |
|
8 |
<accessrule kind="accessible" pattern="**" /> |
|
9 |
</accessrules> |
|
10 |
</classpathentry> |
|
11 |
<classpathentry kind="src" path="src" /> |
|
12 |
<classpathentry kind="output" path="bin" /> |
|
13 |
</classpath> |
|
0 | 14 |
TXM/trunk/bundles/org.txm.annotation.kr.rcp/META-INF/MANIFEST.MF (revision 3653) | ||
---|---|---|
1 |
Manifest-Version: 1.0 |
|
2 |
Export-Package: org.txm.annotation.kr.rcp.commands,org.txm.annotation. |
|
3 |
kr.rcp.commands.krview,org.txm.annotation.kr.rcp.concordance,org.txm. |
|
4 |
annotation.kr.rcp.editors.imports.sections,org.txm.annotation.kr.rcp. |
|
5 |
messages,org.txm.annotation.kr.rcp.preferences,org.txm.annotation.kr. |
|
6 |
rcp.views.knowledgerepositories |
|
7 |
Bundle-SymbolicName: org.txm.annotation.kr.rcp;singleton:=true |
|
8 |
Bundle-Version: 1.0.0.qualifier |
|
9 |
Bundle-Name: %Bundle-Name |
|
10 |
Require-Bundle: org.txm.annotation.kr.core;bundle-version="1.0.0";visi |
|
11 |
bility:=reexport,org.txm.annotation.rcp;bundle-version="1.0.0";visibi |
|
12 |
lity:=reexport |
|
13 |
Bundle-ManifestVersion: 2 |
|
14 |
Bundle-RequiredExecutionEnvironment: JavaSE-16 |
|
15 |
Bundle-Vendor: Textometrie.org |
|
16 |
Automatic-Module-Name: org.txm.annotation.kr.rcp |
|
17 |
|
|
0 | 18 |
TXM/trunk/bundles/org.txm.annotation.kr.rcp/.project (revision 3653) | ||
---|---|---|
1 |
<?xml version="1.0" encoding="UTF-8"?> |
|
2 |
<projectDescription> |
|
3 |
<name>org.txm.annotation.kr.rcp</name> |
|
4 |
<comment></comment> |
|
5 |
<projects> |
|
6 |
</projects> |
|
7 |
<buildSpec> |
|
8 |
<buildCommand> |
|
9 |
<name>org.eclipse.jdt.core.javabuilder</name> |
|
10 |
<arguments> |
|
11 |
</arguments> |
|
12 |
</buildCommand> |
|
13 |
<buildCommand> |
|
14 |
<name>org.eclipse.pde.ManifestBuilder</name> |
|
15 |
<arguments> |
|
16 |
</arguments> |
|
17 |
</buildCommand> |
|
18 |
<buildCommand> |
|
19 |
<name>org.eclipse.pde.SchemaBuilder</name> |
|
20 |
<arguments> |
|
21 |
</arguments> |
|
22 |
</buildCommand> |
|
23 |
</buildSpec> |
|
24 |
<natures> |
|
25 |
<nature>org.eclipse.pde.PluginNature</nature> |
|
26 |
<nature>org.eclipse.jdt.core.javanature</nature> |
|
27 |
</natures> |
|
28 |
</projectDescription> |
|
0 | 29 |
TXM/trunk/bundles/org.txm.annotation.kr.rcp/src/org/txm/rcp/testers/IsCorpusDirty.java (revision 3653) | ||
---|---|---|
1 |
package org.txm.rcp.testers; |
|
2 |
|
|
3 |
import java.util.List; |
|
4 |
|
|
5 |
import org.eclipse.core.expressions.PropertyTester; |
|
6 |
import org.eclipse.ui.IEditorPart; |
|
7 |
import org.eclipse.ui.PlatformUI; |
|
8 |
import org.txm.annotation.kr.core.KRAnnotationEngine; |
|
9 |
import org.txm.concordance.core.functions.Line; |
|
10 |
import org.txm.concordance.rcp.editors.ConcordanceEditor; |
|
11 |
import org.txm.core.results.TXMResult; |
|
12 |
import org.txm.searchengine.cqp.corpus.MainCorpus; |
|
13 |
|
|
14 |
|
|
15 |
public class IsCorpusDirty extends PropertyTester { |
|
16 |
|
|
17 |
@Override |
|
18 |
public boolean test(Object receiver, String property, Object[] args, Object expectedValue) { |
|
19 |
|
|
20 |
if (receiver instanceof List) { |
|
21 |
List list = (List) receiver; |
|
22 |
if (list.size() == 0) return true; |
|
23 |
receiver = list.get(0); |
|
24 |
} |
|
25 |
|
|
26 |
if (receiver instanceof TXMResult) { |
|
27 |
receiver = ((TXMResult) receiver).getFirstParent(MainCorpus.class); |
|
28 |
} |
|
29 |
|
|
30 |
if (receiver instanceof Line) { |
|
31 |
receiver = ((Line) receiver).getConcordance().getFirstParent(MainCorpus.class); |
|
32 |
} |
|
33 |
|
|
34 |
if (receiver instanceof MainCorpus) { |
|
35 |
return KRAnnotationEngine.needToSaveAnnotations(((MainCorpus) receiver)); |
|
36 |
} |
|
37 |
|
|
38 |
IEditorPart e = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor(); |
|
39 |
if (e instanceof ConcordanceEditor) { |
|
40 |
KRAnnotationEngine.needToSaveAnnotations(((ConcordanceEditor) e).getCorpus().getMainCorpus()); |
|
41 |
} |
|
42 |
|
|
43 |
return false; |
|
44 |
} |
|
45 |
} |
|
0 | 46 |
TXM/trunk/bundles/org.txm.annotation.kr.rcp/src/org/txm/annotation/kr/rcp/commands/SaveAnnotations.java (revision 3653) | ||
---|---|---|
1 |
package org.txm.annotation.kr.rcp.commands; |
|
2 |
|
|
3 |
import org.eclipse.core.commands.AbstractHandler; |
|
4 |
import org.eclipse.core.commands.ExecutionEvent; |
|
5 |
import org.eclipse.core.commands.ExecutionException; |
|
6 |
import org.eclipse.core.runtime.IProgressMonitor; |
|
7 |
import org.eclipse.core.runtime.IStatus; |
|
8 |
import org.eclipse.core.runtime.Status; |
|
9 |
import org.eclipse.jface.dialogs.MessageDialog; |
|
10 |
import org.eclipse.jface.viewers.ISelection; |
|
11 |
import org.eclipse.jface.viewers.IStructuredSelection; |
|
12 |
import org.eclipse.osgi.util.NLS; |
|
13 |
import org.eclipse.swt.widgets.Display; |
|
14 |
import org.eclipse.ui.handlers.HandlerUtil; |
|
15 |
import org.txm.annotation.kr.core.AnnotationManager; |
|
16 |
import org.txm.annotation.kr.core.KRAnnotationEngine; |
|
17 |
import org.txm.rcp.messages.TXMUIMessages; |
|
18 |
import org.txm.rcp.utils.JobHandler; |
|
19 |
import org.txm.rcp.utils.SWTEditorsUtils; |
|
20 |
import org.txm.rcp.views.corpora.CorporaView; |
|
21 |
import org.txm.searchengine.cqp.corpus.MainCorpus; |
|
22 |
import org.txm.utils.logger.Log; |
|
23 |
|
|
24 |
public class SaveAnnotations extends AbstractHandler { |
|
25 |
|
|
26 |
public static final String ID = SaveAnnotations.class.getCanonicalName(); |
|
27 |
|
|
28 |
@Override |
|
29 |
public Object execute(ExecutionEvent event) throws ExecutionException { |
|
30 |
|
|
31 |
ISelection sel = HandlerUtil.getCurrentSelection(event); |
|
32 |
if (!(sel instanceof IStructuredSelection)) return null; |
|
33 |
IStructuredSelection selection = (IStructuredSelection) sel; |
|
34 |
|
|
35 |
Object s = selection.getFirstElement(); |
|
36 |
if (!(s instanceof MainCorpus)) |
|
37 |
return null; |
|
38 |
MainCorpus corpus = (MainCorpus) s; |
|
39 |
try { |
|
40 |
JobHandler job = save(corpus); |
|
41 |
if (job == null) { |
|
42 |
return null; |
|
43 |
} |
|
44 |
} |
|
45 |
catch (Exception e) { |
|
46 |
// TODO Auto-generated catch block |
|
47 |
e.printStackTrace(); |
|
48 |
return null; |
|
49 |
} |
|
50 |
|
|
51 |
CorporaView.refresh(); |
|
52 |
|
|
53 |
return corpus; |
|
54 |
} |
|
55 |
|
|
56 |
public static JobHandler save(final MainCorpus corpus) throws Exception { |
|
57 |
final AnnotationManager am = KRAnnotationEngine.getAnnotationManager(corpus); |
|
58 |
if (am == null) return null; // nothing to do |
|
59 |
|
|
60 |
if (!KRAnnotationEngine.needToSaveAnnotations(corpus)) { |
|
61 |
return null; |
|
62 |
} |
|
63 |
|
|
64 |
JobHandler jobhandler = new JobHandler(NLS.bind("Saving annotations of {0}", corpus)) { |
|
65 |
|
|
66 |
@Override |
|
67 |
protected IStatus run(IProgressMonitor monitor) { |
|
68 |
this.runInit(monitor); |
|
69 |
try { |
|
70 |
|
|
71 |
boolean rez = am.saveAnnotations(monitor); |
|
72 |
monitor.worked(30); |
|
73 |
|
|
74 |
if (rez) { |
|
75 |
Log.fine("Annotations are saved in XML-TXM files. Updating corpus indexes and editions"); |
|
76 |
// close all opened editors of all children corpus |
|
77 |
SWTEditorsUtils.closeEditors(corpus.getProject(), true); |
|
78 |
} |
|
79 |
else { |
|
80 |
Log.warning("** Error while saving annotations (see logs above)."); |
|
81 |
} |
|
82 |
} |
|
83 |
catch (Exception e) { |
|
84 |
Log.warning(NLS.bind("Error while saving annotations: {0}", e)); |
|
85 |
Log.printStackTrace(e); |
|
86 |
return Status.CANCEL_STATUS; |
|
87 |
} catch(ThreadDeath ex) { |
|
88 |
Log.info(TXMUIMessages.executionCanceled); |
|
89 |
return Status.CANCEL_STATUS; |
|
90 |
} |
|
91 |
return Status.OK_STATUS; |
|
92 |
} |
|
93 |
}; |
|
94 |
|
|
95 |
jobhandler.startJob(true); |
|
96 |
jobhandler.join(); |
|
97 |
return jobhandler; |
|
98 |
} |
|
99 |
} |
|
0 | 100 |
TXM/trunk/bundles/org.txm.annotation.kr.rcp/src/org/txm/annotation/kr/rcp/commands/RecodeCorpus.java (revision 3653) | ||
---|---|---|
1 |
package org.txm.annotation.kr.rcp.commands; |
|
2 |
|
|
3 |
import java.io.File; |
|
4 |
import java.io.IOException; |
|
5 |
import java.util.HashMap; |
|
6 |
import java.util.LinkedHashMap; |
|
7 |
import java.util.logging.Level; |
|
8 |
import java.util.regex.Pattern; |
|
9 |
|
|
10 |
import javax.xml.stream.XMLStreamException; |
|
11 |
|
|
12 |
import org.eclipse.core.commands.AbstractHandler; |
|
13 |
import org.eclipse.core.commands.ExecutionEvent; |
|
14 |
import org.eclipse.core.commands.ExecutionException; |
|
15 |
import org.eclipse.core.runtime.IProgressMonitor; |
|
16 |
import org.eclipse.core.runtime.IStatus; |
|
17 |
import org.eclipse.core.runtime.Status; |
|
18 |
import org.eclipse.jface.viewers.ISelection; |
|
19 |
import org.eclipse.jface.viewers.IStructuredSelection; |
|
20 |
import org.eclipse.osgi.util.NLS; |
|
21 |
import org.eclipse.swt.widgets.Display; |
|
22 |
import org.eclipse.ui.handlers.HandlerUtil; |
|
23 |
import org.kohsuke.args4j.Option; |
|
24 |
import org.txm.Toolbox; |
|
25 |
import org.txm.annotation.kr.core.conversion.CorpusRuledConvertion; |
|
26 |
import org.txm.annotation.kr.rcp.messages.KRAnnotationUIMessages; |
|
27 |
import org.txm.core.preferences.TBXPreferences; |
|
28 |
import org.txm.objects.Project; |
|
29 |
import org.txm.rcp.commands.CloseEditorsUsing; |
|
30 |
import org.txm.rcp.handlers.scripts.ExecuteImportScript; |
|
31 |
import org.txm.rcp.messages.TXMUIMessages; |
|
32 |
import org.txm.rcp.swt.widget.parameters.ParametersDialog; |
|
33 |
import org.txm.rcp.utils.JobHandler; |
|
34 |
import org.txm.searchengine.cqp.clientExceptions.CqiClientException; |
|
35 |
import org.txm.searchengine.cqp.corpus.MainCorpus; |
|
36 |
import org.txm.searchengine.cqp.corpus.Property; |
|
37 |
import org.txm.utils.logger.Log; |
|
38 |
|
|
39 |
public class RecodeCorpus extends AbstractHandler { |
|
40 |
|
|
41 |
public static final String ID = RecodeCorpus.class.getCanonicalName(); |
|
42 |
|
|
43 |
@Option(name = "conversionFile", usage = "conversionFile", widget = "File", required = true, def = "conv.tsv") |
|
44 |
protected File conversionFile; |
|
45 |
|
|
46 |
@Option(name = "oldType", usage = "oldType", widget = "String", required = true, def = "pos") |
|
47 |
protected String oldType; |
|
48 |
|
|
49 |
@Option(name = "newType", usage = "newType", widget = "String", required = true, def = "pos2") |
|
50 |
protected String newType; |
|
51 |
|
|
52 |
@Option(name = "gestionInconnus", usage = "how to manage failed conversion", widget = "String", required = true, def = "abandon") |
|
53 |
protected String gestionInconnus; |
|
54 |
|
|
55 |
@Override |
|
56 |
public Object execute(ExecutionEvent event) throws ExecutionException { |
|
57 |
|
|
58 |
ISelection isel = HandlerUtil.getCurrentSelection(event); |
|
59 |
if (isel == null) return null; |
|
60 |
if (!(isel instanceof IStructuredSelection)) return null; |
|
61 |
IStructuredSelection selection = (IStructuredSelection) isel; |
|
62 |
Object s = selection.getFirstElement(); |
|
63 |
if (!(s instanceof MainCorpus)) return null; |
|
64 |
|
|
65 |
final MainCorpus corpus = (MainCorpus) s; |
|
66 |
|
|
67 |
try { |
|
68 |
if (ParametersDialog.open(this)) { |
|
69 |
|
|
70 |
JobHandler job = new JobHandler("Recode corpus " + corpus) { |
|
71 |
|
|
72 |
@Override |
|
73 |
protected IStatus run(IProgressMonitor monitor) { |
|
74 |
this.runInit(monitor); |
|
75 |
|
|
76 |
try { |
|
77 |
recode(corpus, conversionFile, oldType, newType, monitor); |
|
78 |
} catch (Exception e) { |
|
79 |
Log.warning(NLS.bind("Fail to convert properties of the {0} corpus.", corpus)); |
|
80 |
e.printStackTrace(); |
|
81 |
return Status.CANCEL_STATUS; |
|
82 |
} catch(ThreadDeath ex) { |
|
83 |
Log.info(TXMUIMessages.executionCanceled); |
|
84 |
return Status.CANCEL_STATUS; |
|
85 |
} |
|
86 |
return Status.OK_STATUS; |
|
87 |
} |
|
88 |
}; |
|
89 |
job.startJob(); |
|
90 |
return corpus; |
|
91 |
} |
|
92 |
} |
|
93 |
catch (Exception e) { |
|
94 |
e.printStackTrace(); |
|
95 |
} |
|
96 |
|
|
97 |
return corpus; |
|
98 |
} |
|
99 |
|
|
100 |
public static JobHandler recode(final MainCorpus corpus, CorpusRuledConvertion crc, String oldType, String newType, IProgressMonitor monitor) throws IOException, CqiClientException, |
|
101 |
XMLStreamException { |
|
102 |
|
|
103 |
Project project = corpus.getProject(); |
|
104 |
if (!"xtz".equals(project.getImportModuleName())) { |
|
105 |
Log.warning(NLS.bind("The {0} corpus was not imported with the XTZ import module", corpus)); |
|
106 |
return null; |
|
107 |
} |
|
108 |
|
|
109 |
Property p1 = corpus.getProperty(oldType); |
|
110 |
if (p1 == null) { |
|
111 |
Log.warning(NLS.bind("The {0} corpus has no {1} property.", corpus, oldType)); |
|
112 |
return null; |
|
113 |
} |
|
114 |
|
|
115 |
Log.info(NLS.bind("Recoding the {0} corpus properties: {1}.", corpus, oldType+" -> "+newType)); |
|
116 |
|
|
117 |
monitor.beginTask("Recoding corpus properties...", 2); |
|
118 |
monitor.setTaskName("Recoding XML-TXM files"); |
|
119 |
// apply conversion file |
|
120 |
if (!crc.process(corpus)) { |
|
121 |
Log.warning(NLS.bind("Failed to edit XML-TXM of the {0} corpus.", corpus)); |
|
122 |
return null; |
|
123 |
} |
|
124 |
monitor.worked(1); |
|
125 |
|
|
126 |
// update corpus indexes and edition |
|
127 |
// String txmhome = Toolbox.getTxmHomePath(); |
|
128 |
|
|
129 |
|
|
130 |
project.setDoMultiThread(false); // too soon |
|
131 |
project.setDoUpdate(true, false); |
|
132 |
|
|
133 |
// monitor.setTaskName("Updating corpus"); |
|
134 |
// File scriptDir = new File(txmhome, "scripts/groovy/user/org/txm/scripts/importer/xtz"); |
|
135 |
// File script = new File(scriptDir, "xtzLoader.groovy"); |
|
136 |
Log.info(NLS.bind(KRAnnotationUIMessages.updatingTheP0Corpus, corpus)); |
|
137 |
JobHandler ret = ExecuteImportScript.executeScript(project); |
|
138 |
Display.getDefault().syncExec(new Runnable() { |
|
139 |
|
|
140 |
@Override |
|
141 |
public void run() { |
|
142 |
CloseEditorsUsing.corpus(corpus); |
|
143 |
} |
|
144 |
}); |
|
145 |
monitor.worked(1); |
|
146 |
return ret; |
|
147 |
} |
|
148 |
|
|
149 |
public static JobHandler recode(final MainCorpus corpus, LinkedHashMap<Pattern, String> rules, String oldType, String newType, IProgressMonitor monitor) throws IOException, CqiClientException, |
|
150 |
XMLStreamException { |
|
151 |
|
|
152 |
// apply conversion file |
|
153 |
CorpusRuledConvertion crc = new CorpusRuledConvertion(rules, newType, oldType); |
|
154 |
return recode(corpus, crc, oldType, newType, monitor); |
|
155 |
} |
|
156 |
|
|
157 |
public static JobHandler recode(final MainCorpus corpus, File conversionFile, String oldType, String newType, IProgressMonitor monitor) throws IOException, CqiClientException, XMLStreamException { |
|
158 |
Log.info(NLS.bind("Create CorpusRuledConvertion with the {0} conversion file.", conversionFile)); |
|
159 |
// apply conversion file |
|
160 |
CorpusRuledConvertion crc = new CorpusRuledConvertion(conversionFile, oldType, newType); |
|
161 |
|
|
162 |
return recode(corpus, crc, oldType, newType, monitor); |
|
163 |
} |
|
164 |
} |
|
0 | 165 |
TXM/trunk/bundles/org.txm.annotation.kr.rcp/src/org/txm/annotation/kr/rcp/commands/SaveAnnotationsAndUpdateCorpus.java (revision 3653) | ||
---|---|---|
1 |
package org.txm.annotation.kr.rcp.commands; |
|
2 |
|
|
3 |
import java.util.ArrayList; |
|
4 |
import java.util.Collections; |
|
5 |
import java.util.List; |
|
6 |
|
|
7 |
import org.eclipse.core.commands.AbstractHandler; |
|
8 |
import org.eclipse.core.commands.ExecutionEvent; |
|
9 |
import org.eclipse.core.commands.ExecutionException; |
|
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.viewers.ISelection; |
|
14 |
import org.eclipse.jface.viewers.IStructuredSelection; |
|
15 |
import org.eclipse.jface.window.Window; |
|
16 |
import org.eclipse.osgi.util.NLS; |
|
17 |
import org.eclipse.swt.widgets.Display; |
|
18 |
import org.eclipse.ui.handlers.HandlerUtil; |
|
19 |
import org.txm.annotation.kr.core.KRAnnotationEngine; |
|
20 |
import org.txm.annotation.kr.core.preferences.KRAnnotationPreferences; |
|
21 |
import org.txm.concordance.rcp.editors.ConcordanceEditor; |
|
22 |
import org.txm.core.results.TXMResult; |
|
23 |
import org.txm.objects.Workspace; |
|
24 |
import org.txm.rcp.commands.workspace.UpdateCorpus; |
|
25 |
import org.txm.rcp.messages.TXMUIMessages; |
|
26 |
import org.txm.rcp.swt.dialog.UpdateCorpusDialog; |
|
27 |
import org.txm.rcp.utils.JobHandler; |
|
28 |
import org.txm.rcp.views.corpora.CorporaView; |
|
29 |
import org.txm.searchengine.cqp.corpus.MainCorpus; |
|
30 |
import org.txm.utils.logger.Log; |
|
31 |
|
|
32 |
public class SaveAnnotationsAndUpdateCorpus extends AbstractHandler { |
|
33 |
|
|
34 |
public static final String ID = SaveAnnotationsAndUpdateCorpus.class.getCanonicalName(); |
|
35 |
|
|
36 |
@Override |
|
37 |
public Object execute(ExecutionEvent event) throws ExecutionException { |
|
38 |
|
|
39 |
ISelection sel = HandlerUtil.getCurrentSelection(event); |
|
40 |
// if (!(sel instanceof IStructuredSelection)) { |
|
41 |
// Log.info("No available selection to target the corpus annotations to save"); |
|
42 |
// return null; |
|
43 |
// } |
|
44 |
IStructuredSelection selection = (IStructuredSelection) sel; |
|
45 |
|
|
46 |
List<MainCorpus> corpora = Workspace.getInstance().getDeepChildren(MainCorpus.class); |
|
47 |
Collections.sort(corpora); |
|
48 |
ArrayList<MainCorpus> corpusWithAnnotationsToSave = new ArrayList<>(); |
|
49 |
for (MainCorpus corpus : corpora) { |
|
50 |
if (KRAnnotationEngine.needToSaveAnnotations(corpus)) { |
|
51 |
corpusWithAnnotationsToSave.add(corpus); |
|
52 |
} |
|
53 |
} |
|
54 |
|
|
55 |
// if (HandlerUtil.getActiveEditor(event) instanceof ConcordanceEditor) { |
|
56 |
// corpus = ((ConcordanceEditor) HandlerUtil.getActiveEditor(event)).getCorpus().getMainCorpus(); |
|
57 |
// } else { |
|
58 |
// Object s = selection.getFirstElement(); |
|
59 |
// if (s == null) { |
|
60 |
// Log.info("No available selection to target the corpus annotations to save"); |
|
61 |
// return null; |
|
62 |
// } else if ((s instanceof MainCorpus)) { |
|
63 |
// corpus = (MainCorpus) s; |
|
64 |
// } else if (s instanceof TXMResult) { |
|
65 |
// corpus = ((TXMResult) s).getFirstParent(MainCorpus.class); |
|
66 |
// } else { |
|
67 |
// Log.info("No available selection to target the corpus annotations to save"); |
|
68 |
// return null; |
|
69 |
// } |
|
70 |
// } |
|
71 |
|
|
72 |
if (corpusWithAnnotationsToSave.size() == 0) { |
|
73 |
Log.info(NLS.bind("No CQP annotations found to save in the corpora: {0}", corpora)); |
|
74 |
return null; |
|
75 |
} |
|
76 |
|
|
77 |
try { |
|
78 |
|
|
79 |
// System.out.println("DISPLAY="+Display.getDefault()); |
|
80 |
final Boolean[] doit = new Boolean[1]; |
|
81 |
doit[0] = true; |
|
82 |
final MainCorpus[] corpus = new MainCorpus[1]; |
|
83 |
|
|
84 |
final Boolean[] doupdateedition = new Boolean[1]; |
|
85 |
doupdateedition[0] = KRAnnotationPreferences.getInstance().getBoolean(KRAnnotationPreferences.UPDATE_EDITION); |
|
86 |
|
|
87 |
Display.getDefault().syncExec(new Runnable() { |
|
88 |
|
|
89 |
@Override |
|
90 |
public void run() { |
|
91 |
UpdateCorpusDialog dialog = new UpdateCorpusDialog(Display.getDefault().getActiveShell()); |
|
92 |
dialog.setTitle("Before saving annotations..."); |
|
93 |
dialog.setMessages("Save Annotations and update the corpus.", dialog.getBottomMessage()); |
|
94 |
dialog.setDoForceUpdate(false); |
|
95 |
dialog.setDoUpdateEdition(KRAnnotationPreferences.getInstance().getBoolean(KRAnnotationPreferences.UPDATE_EDITION)); |
|
96 |
if (selection.getFirstElement() != null && selection.getFirstElement() instanceof MainCorpus) { |
|
97 |
dialog.setCorpusToUpdate((MainCorpus) selection.getFirstElement()); |
|
98 |
} |
|
99 |
dialog.setCorporaToUpdate(corpusWithAnnotationsToSave); |
|
100 |
|
|
101 |
doit[0] = dialog.open() == Window.OK; |
|
102 |
doupdateedition[0] = dialog.getDoUpdateEdition(); |
|
103 |
corpus[0] = dialog.getCorpustoUpdate(); |
|
104 |
} |
|
105 |
}); |
|
106 |
if (doit[0] == false) { |
|
107 |
return null; |
|
108 |
} |
|
109 |
|
|
110 |
final MainCorpus fcorpus = corpus[0]; |
|
111 |
|
|
112 |
Log.info(NLS.bind("Saving {0} annotations...", fcorpus.getName())); |
|
113 |
JobHandler job = SaveAnnotations.save(fcorpus); |
|
114 |
if (job == null) { |
|
115 |
return null; |
|
116 |
} |
|
117 |
|
|
118 |
if (job.getState() == Status.OK_STATUS.getCode()) { |
|
119 |
if (KRAnnotationPreferences.getInstance().getBoolean(KRAnnotationPreferences.UPDATE)) { |
|
120 |
|
|
121 |
JobHandler job2 = new JobHandler("Updating corpus editions and indexes", true) { |
|
122 |
|
|
123 |
@Override |
|
124 |
protected IStatus run(IProgressMonitor monitor) { |
|
125 |
this.runInit(monitor); |
|
126 |
|
|
127 |
try { |
|
128 |
monitor.setTaskName("Updating corpus"); |
|
129 |
if (fcorpus != null && UpdateCorpus.update(fcorpus, false, doupdateedition[0]) != null) { |
|
130 |
monitor.worked(50); |
|
131 |
this.syncExec(new Runnable() { |
|
132 |
|
|
133 |
@Override |
|
134 |
public void run() { |
|
135 |
CorporaView.refreshObject(fcorpus); |
|
136 |
} |
|
137 |
}); |
|
138 |
return Status.OK_STATUS; |
|
139 |
} |
|
140 |
else { |
|
141 |
monitor.worked(50); |
|
142 |
Log.warning("Fail to update corpus. Aborting"); |
|
143 |
Log.warning("Fix XML-TXM files and call command 'UpdateCorpus'"); |
|
144 |
return Status.CANCEL_STATUS; |
|
145 |
} |
|
146 |
} catch(ThreadDeath ex) { |
|
147 |
Log.info(TXMUIMessages.executionCanceled); |
|
148 |
return Status.CANCEL_STATUS; |
|
149 |
} |
|
150 |
} |
|
151 |
}; |
|
152 |
job2.schedule(); |
|
153 |
} else { |
|
154 |
Log.warning("CQP indexes not updated. Only the XML-TXM files have been updated. Call Update corpus later to access the annotations"); |
|
155 |
} |
|
156 |
} |
|
157 |
|
|
158 |
CorporaView.refresh(); |
|
159 |
|
|
160 |
return fcorpus; |
|
161 |
} |
|
162 |
catch (Exception e) { |
|
163 |
// TODO Auto-generated catch block |
|
164 |
e.printStackTrace(); |
|
165 |
return null; |
|
166 |
} |
|
167 |
|
|
168 |
} |
|
169 |
} |
|
0 | 170 |
TXM/trunk/bundles/org.txm.annotation.kr.rcp/src/org/txm/annotation/kr/rcp/commands/InitializeKnowledgeRepository.java (revision 3653) | ||
---|---|---|
1 |
package org.txm.annotation.kr.rcp.commands; |
|
2 |
|
|
3 |
import java.util.ArrayList; |
|
4 |
import java.util.List; |
|
5 |
|
|
6 |
import org.eclipse.core.commands.AbstractHandler; |
|
7 |
import org.eclipse.core.commands.ExecutionEvent; |
|
8 |
import org.eclipse.core.commands.ExecutionException; |
|
9 |
import org.eclipse.jface.viewers.ISelection; |
|
10 |
import org.eclipse.jface.viewers.IStructuredSelection; |
|
11 |
import org.eclipse.osgi.util.NLS; |
|
12 |
import org.eclipse.swt.widgets.Display; |
|
13 |
import org.eclipse.ui.handlers.HandlerUtil; |
|
14 |
import org.osgi.service.prefs.BackingStoreException; |
|
15 |
import org.txm.annotation.kr.core.KRAnnotationEngine; |
|
16 |
import org.txm.annotation.kr.core.repository.KnowledgeRepository; |
|
17 |
import org.txm.annotation.kr.core.repository.KnowledgeRepositoryManager; |
|
18 |
import org.txm.rcp.swt.dialog.UsernamePasswordDialog; |
|
19 |
import org.txm.searchengine.cqp.corpus.MainCorpus; |
|
20 |
import org.txm.utils.logger.Log; |
|
21 |
|
|
22 |
public class InitializeKnowledgeRepository extends AbstractHandler { |
|
23 |
|
|
24 |
public static final String ID = InitializeKnowledgeRepository.class.getCanonicalName(); |
|
25 |
|
|
26 |
@Override |
|
27 |
public Object execute(ExecutionEvent event) throws ExecutionException { |
|
28 |
|
|
29 |
ISelection sel = (IStructuredSelection) HandlerUtil.getCurrentSelection(event); |
|
30 |
if (!(sel instanceof IStructuredSelection)) return null; |
|
31 |
IStructuredSelection selection = (IStructuredSelection) sel; |
|
32 |
|
|
33 |
Object s = selection.getFirstElement(); |
|
34 |
if (!(s instanceof MainCorpus)) |
|
35 |
return null; |
|
36 |
|
|
37 |
MainCorpus corpus = (MainCorpus) s; |
|
38 |
return get(corpus); |
|
39 |
} |
|
40 |
|
|
41 |
/** |
|
42 |
* Use this method to set eventual login+password needed by SQL knowledge repositories |
|
43 |
* |
|
44 |
* @param corpus |
|
45 |
* @return |
|
46 |
*/ |
|
47 |
public static List<KnowledgeRepository> get(MainCorpus corpus) { |
|
48 |
List<KnowledgeRepository> ret = new ArrayList<KnowledgeRepository>(); |
|
49 |
|
|
50 |
for (String kr_name : KRAnnotationEngine.getKnowledgeRepositoryNames(corpus)) { |
|
51 |
KnowledgeRepository kr; |
|
52 |
try { |
|
53 |
kr = KRAnnotationEngine.getKnowledgeRepository(corpus, kr_name); |
|
54 |
|
|
55 |
if (kr == null) { |
|
56 |
Log.warning(NLS.bind("Warning ''{0}'' KR is null. Please check KR configuration.", kr_name)); |
|
57 |
continue; |
|
58 |
} |
|
59 |
//System.out.println("IS CREDENTIAL NEEDED: "+kr_name+" "+corpus); |
|
60 |
boolean[] must = KnowledgeRepositoryManager.mustLoginToKnowledgeRepository(kr_name, corpus); |
|
61 |
|
|
62 |
if (must[0] || must[1]) { |
|
63 |
Log.info(NLS.bind("Asking credentials for {0} KR login.", kr_name)); |
|
64 |
UsernamePasswordDialog dialog = new UsernamePasswordDialog(Display.getCurrent().getActiveShell(), must, kr_name); |
|
65 |
|
|
66 |
if (dialog.open() == UsernamePasswordDialog.OK) { |
|
67 |
Log.info("Temporary save login+password"); |
|
68 |
System.setProperty(KnowledgeRepository.LOGIN_KEY+kr_name, dialog.getUser()); |
|
69 |
System.setProperty(KnowledgeRepository.PASSWORD_KEY+kr_name, dialog.getPassword()); |
|
70 |
} else { |
|
71 |
Log.info(NLS.bind("Cancelling login for {0} KR.", kr_name)); |
|
72 |
continue; // ignoring |
|
73 |
} |
|
74 |
} |
|
75 |
|
|
76 |
if (!kr.checkConnection()) { |
|
77 |
Log.warning(NLS.bind("Error during connection to the ''{0}'' KR. Please check login, password and Internet connection.", kr_name)); |
|
78 |
} else { |
|
79 |
ret.add(kr); |
|
80 |
} |
|
81 |
} catch (BackingStoreException e) { |
|
82 |
// TODO Auto-generated catch block |
|
83 |
e.printStackTrace(); |
|
84 |
} |
|
85 |
|
|
86 |
} |
|
87 |
return ret; |
|
88 |
} |
|
89 |
} |
|
0 | 90 |
TXM/trunk/bundles/org.txm.annotation.kr.rcp/src/org/txm/annotation/kr/rcp/commands/ImportTable.java (revision 3653) | ||
---|---|---|
1 |
// Copyright © 2010-2020 ENS de Lyon., University of Franche-Comté |
|
2 |
// Copyright © 2007-2010 ENS de Lyon, CNRS, INRP, University of |
|
3 |
// Lyon 2, University of Franche-Comté, University of Nice |
|
4 |
// Sophia Antipolis, University of Paris 3. |
|
5 |
// |
|
6 |
// The TXM platform is free software: you can redistribute it |
|
7 |
// and/or modify it under the terms of the GNU General Public |
|
8 |
// License as published by the Free Software Foundation, |
|
9 |
// either version 2 of the License, or (at your option) any |
|
10 |
// later version. |
|
11 |
// |
|
12 |
// The TXM platform is distributed in the hope that it will be |
|
13 |
// useful, but WITHOUT ANY WARRANTY; without even the implied |
|
14 |
// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR |
|
15 |
// PURPOSE. See the GNU General Public License for more |
|
16 |
// details. |
|
17 |
// |
|
18 |
// You should have received a copy of the GNU General |
|
19 |
// Public License along with the TXM platform. If not, see |
|
20 |
// http://www.gnu.org/licenses. |
|
21 |
// |
|
22 |
// |
|
23 |
// |
|
24 |
// $LastChangedDate:$ |
|
25 |
// $LastChangedRevision:$ |
|
26 |
// $LastChangedBy:$ |
|
27 |
// |
|
28 |
package org.txm.annotation.kr.rcp.commands; |
|
29 |
|
|
30 |
import java.io.File; |
|
31 |
|
|
32 |
import org.eclipse.core.commands.AbstractHandler; |
|
33 |
import org.eclipse.core.commands.ExecutionEvent; |
|
34 |
import org.eclipse.core.commands.ExecutionException; |
|
35 |
import org.eclipse.core.runtime.IProgressMonitor; |
|
36 |
import org.eclipse.core.runtime.IStatus; |
|
37 |
import org.eclipse.core.runtime.Status; |
|
38 |
import org.eclipse.jface.viewers.ISelection; |
|
39 |
import org.eclipse.jface.viewers.IStructuredSelection; |
|
40 |
import org.eclipse.osgi.util.NLS; |
|
41 |
import org.eclipse.swt.SWT; |
|
42 |
import org.eclipse.swt.widgets.FileDialog; |
|
43 |
import org.eclipse.swt.widgets.Shell; |
|
44 |
import org.eclipse.ui.handlers.HandlerUtil; |
|
45 |
import org.txm.Toolbox; |
|
46 |
import org.txm.annotation.kr.core.AnnotationManager; |
|
47 |
import org.txm.annotation.kr.core.KRAnnotationEngine; |
|
48 |
import org.txm.rcp.StatusLine; |
|
49 |
import org.txm.rcp.messages.TXMUIMessages; |
|
50 |
import org.txm.rcp.swt.dialog.LastOpened; |
|
51 |
import org.txm.rcp.utils.JobHandler; |
|
52 |
import org.txm.searchengine.cqp.corpus.MainCorpus; |
|
53 |
import org.txm.utils.logger.Log; |
|
54 |
|
|
55 |
/** |
|
56 |
* Open a file in the TxtEditor |
|
57 |
* |
|
58 |
* @author mdecorde. |
|
59 |
*/ |
|
60 |
public class ImportTable extends AbstractHandler { |
|
61 |
|
|
62 |
public static final String ID = ImportTable.class.getCanonicalName(); |
|
63 |
|
|
64 |
|
|
65 |
/* (non-Javadoc) |
|
66 |
* @see org.eclipse.core.commands.AbstractHandler#execute(org.eclipse.core.commands.ExecutionEvent) |
|
67 |
*/ |
|
68 |
@Override |
|
69 |
public Object execute(ExecutionEvent event) throws ExecutionException { |
|
70 |
|
|
71 |
ISelection sel = (IStructuredSelection) HandlerUtil.getCurrentSelection(event); |
|
72 |
if (!(sel instanceof IStructuredSelection)) return null; |
|
73 |
IStructuredSelection selection = (IStructuredSelection) sel; |
|
74 |
|
|
75 |
Object s = selection.getFirstElement(); |
|
76 |
if (!(s instanceof MainCorpus)) { |
|
77 |
Log.warning(NLS.bind("Selection is not a Corpus: {0}. Aborting.", s)); |
|
78 |
return null; |
|
79 |
} |
|
80 |
|
|
81 |
Shell shell = HandlerUtil.getActiveWorkbenchWindowChecked(event).getShell(); |
|
82 |
//FileDialog dialog = new FileDialog(shell, SWT.SAVE); |
|
83 |
FileDialog dialog = new FileDialog(shell, SWT.OPEN); |
|
84 |
MainCorpus corpus = (MainCorpus) s; |
|
85 |
String path = Toolbox.getTxmHomePath(); |
|
86 |
dialog.setFilterPath(path); //To set a specific path |
|
87 |
dialog.setFileName(corpus.getID()+"_annotations.csv"); |
|
88 |
dialog.setFilterExtensions(new String[]{"*.csv", "*.tsv"}); |
|
89 |
if (dialog.open() != null) { |
|
90 |
StatusLine.setMessage(TXMUIMessages.exportingAnnotations); |
|
91 |
String filepath = dialog.getFilterPath(); |
|
92 |
String filename = dialog.getFileName(); |
|
93 |
|
|
94 |
final File resultFile = new File(filepath, filename); |
|
95 |
LastOpened.set(ID, resultFile.getParent(), resultFile.getName()); |
|
96 |
|
|
97 |
try { |
|
98 |
importAnnotations(corpus, resultFile); |
|
99 |
} catch (Exception e) { |
|
100 |
// TODO Auto-generated catch block |
|
101 |
e.printStackTrace(); |
|
102 |
return null; |
|
103 |
} |
|
104 |
} |
|
105 |
return corpus; |
|
106 |
} |
|
107 |
|
|
108 |
public static boolean importAnnotations(final MainCorpus corpus, final File annotationsFile) throws Exception { |
|
109 |
final AnnotationManager am = KRAnnotationEngine.getAnnotationManager(corpus); |
|
110 |
if (am == null) return true; // nothing to do |
|
111 |
|
|
112 |
JobHandler jobhandler = new JobHandler("Importing annotations in table for "+corpus) { //$NON-NLS-1$ |
|
113 |
@Override |
|
114 |
protected IStatus run(IProgressMonitor monitor) { |
|
115 |
this.runInit(monitor); |
|
116 |
try { |
|
117 |
monitor.beginTask("Importing annotations as standoff", 100); |
|
118 |
|
|
119 |
monitor.setTaskName("Reading annotations in the table file: "+annotationsFile); |
|
120 |
/*if (MessageDialog.openConfirm(Display.getCurrent().getActiveShell(), "Before saving annotations...", "All editors using this corpus are going to be closed. Continue ?")) { |
|
121 |
return false; |
|
122 |
}*/ |
|
123 |
|
|
124 |
///lecture de tous les fichiers un par un |
|
125 |
///chaque annotation est récupérée et selon l'annotateur, écrite dans un fichier spécifique à celui-ci |
|
126 |
|
|
127 |
if (!am.importAnnotationsFromTable(annotationsFile)) { |
|
128 |
Log.warning("Error while importing annotations (see logs above)."); |
|
129 |
return Status.CANCEL_STATUS; |
|
130 |
} |
|
131 |
monitor.worked(30); |
|
132 |
|
|
133 |
Log.info("Done."); |
|
134 |
|
|
135 |
} catch(Exception e) { |
|
136 |
Log.warning(NLS.bind("Error while importing annotations: {0}.", e)); |
|
137 |
Log.printStackTrace(e); |
|
138 |
return Status.CANCEL_STATUS; |
|
139 |
} |
|
140 |
return Status.OK_STATUS; |
|
141 |
} |
|
142 |
}; |
|
143 |
|
|
144 |
jobhandler.startJob(true); |
|
145 |
return true; |
|
146 |
} |
|
147 |
} |
|
0 | 148 |
TXM/trunk/bundles/org.txm.annotation.kr.rcp/src/org/txm/annotation/kr/rcp/commands/ExportStandoff.java (revision 3653) | ||
---|---|---|
1 |
// Copyright © 2010-2020 ENS de Lyon., University of Franche-Comté |
|
2 |
// Copyright © 2007-2010 ENS de Lyon, CNRS, INRP, University of |
|
3 |
// Lyon 2, University of Franche-Comté, University of Nice |
|
4 |
// Sophia Antipolis, University of Paris 3. |
|
5 |
// |
|
6 |
// The TXM platform is free software: you can redistribute it |
|
7 |
// and/or modify it under the terms of the GNU General Public |
|
8 |
// License as published by the Free Software Foundation, |
|
9 |
// either version 2 of the License, or (at your option) any |
|
10 |
// later version. |
|
11 |
// |
|
12 |
// The TXM platform is distributed in the hope that it will be |
|
13 |
// useful, but WITHOUT ANY WARRANTY; without even the implied |
|
14 |
// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR |
|
15 |
// PURPOSE. See the GNU General Public License for more |
|
16 |
// details. |
|
17 |
// |
|
18 |
// You should have received a copy of the GNU General |
|
19 |
// Public License along with the TXM platform. If not, see |
|
20 |
// http://www.gnu.org/licenses. |
|
21 |
// |
|
22 |
// |
|
23 |
// |
|
24 |
// $LastChangedDate:$ |
|
25 |
// $LastChangedRevision:$ |
|
26 |
// $LastChangedBy:$ |
|
27 |
// |
|
28 |
package org.txm.annotation.kr.rcp.commands; |
|
29 |
|
|
30 |
import java.io.File; |
|
31 |
|
|
32 |
import org.eclipse.core.commands.AbstractHandler; |
|
33 |
import org.eclipse.core.commands.ExecutionEvent; |
|
34 |
import org.eclipse.core.commands.ExecutionException; |
|
35 |
import org.eclipse.core.runtime.IProgressMonitor; |
|
36 |
import org.eclipse.core.runtime.IStatus; |
|
37 |
import org.eclipse.core.runtime.Status; |
|
38 |
import org.eclipse.jface.viewers.ISelection; |
|
39 |
import org.eclipse.jface.viewers.IStructuredSelection; |
|
40 |
import org.eclipse.osgi.util.NLS; |
|
41 |
import org.eclipse.swt.SWT; |
|
42 |
import org.eclipse.swt.widgets.FileDialog; |
|
43 |
import org.eclipse.swt.widgets.Shell; |
|
44 |
import org.eclipse.ui.handlers.HandlerUtil; |
|
45 |
import org.txm.Toolbox; |
|
46 |
import org.txm.annotation.kr.core.AnnotationManager; |
|
47 |
import org.txm.annotation.kr.core.KRAnnotationEngine; |
|
48 |
import org.txm.core.preferences.TBXPreferences; |
|
49 |
import org.txm.rcp.StatusLine; |
|
50 |
import org.txm.rcp.messages.TXMUIMessages; |
|
51 |
import org.txm.rcp.swt.dialog.LastOpened; |
|
52 |
import org.txm.rcp.utils.JobHandler; |
|
53 |
import org.txm.searchengine.cqp.corpus.MainCorpus; |
|
54 |
import org.txm.utils.logger.Log; |
|
55 |
|
|
56 |
// TODO: Auto-generated Javadoc |
|
57 |
/** |
|
58 |
* Open a file in the TxtEditor @ author mdecorde. |
|
59 |
*/ |
|
60 |
public class ExportStandoff extends AbstractHandler { |
|
61 |
|
|
62 |
public static final String ID = ExportStandoff.class.getCanonicalName(); |
|
63 |
|
|
64 |
|
|
65 |
/* (non-Javadoc) |
|
66 |
* @see org.eclipse.core.commands.AbstractHandler#execute(org.eclipse.core.commands.ExecutionEvent) |
|
67 |
*/ |
|
68 |
@Override |
|
69 |
public Object execute(ExecutionEvent event) throws ExecutionException { |
|
70 |
|
|
71 |
ISelection sel = (IStructuredSelection) HandlerUtil.getCurrentSelection(event); |
|
72 |
if (!(sel instanceof IStructuredSelection)) return null; |
|
73 |
IStructuredSelection selection = (IStructuredSelection) sel; |
|
74 |
|
|
75 |
Object s = selection.getFirstElement(); |
|
76 |
if (!(s instanceof MainCorpus)) { |
|
77 |
Log.warning(NLS.bind("Selection is not a Corpus: {0}. Aborting.", s)); |
|
78 |
return null; |
|
79 |
} |
|
80 |
|
|
81 |
Shell shell = HandlerUtil.getActiveWorkbenchWindowChecked(event).getShell(); |
|
82 |
//FileDialog dialog = new FileDialog(shell, SWT.SAVE); |
|
83 |
FileDialog dialog = new FileDialog(shell, SWT.SAVE); |
|
84 |
MainCorpus corpus = (MainCorpus) s; |
|
85 |
String path = Toolbox.getTxmHomePath(); |
|
86 |
dialog.setFilterPath(path); //To set a specific path |
|
87 |
dialog.setFileName(corpus.getID()+"_annotations.zip"); |
|
88 |
dialog.setFilterExtensions(new String[]{"*.zip"}); |
|
89 |
if (dialog.open() != null) { |
|
90 |
StatusLine.setMessage(TXMUIMessages.exportingAnnotations); |
|
91 |
String filepath = dialog.getFilterPath(); |
|
92 |
String filename = dialog.getFileName(); |
|
93 |
|
|
94 |
final File resultZipFile = new File(filepath, filename); |
|
95 |
LastOpened.set(ID, resultZipFile.getParent(), resultZipFile.getName()); |
|
96 |
|
|
97 |
try { |
|
98 |
exportAnnotations(corpus, resultZipFile); |
|
99 |
} catch (Exception e) { |
|
100 |
// TODO Auto-generated catch block |
|
101 |
e.printStackTrace(); |
|
102 |
return null; |
|
103 |
} |
|
104 |
} |
|
105 |
return corpus; |
|
106 |
} |
|
107 |
|
|
108 |
public static boolean exportAnnotations(final MainCorpus corpus, final File resultZipFile) throws Exception { |
|
109 |
final AnnotationManager am = KRAnnotationEngine.getAnnotationManager(corpus); |
|
110 |
if (am == null) return true; // nothing to do |
|
111 |
|
|
112 |
JobHandler saveJob = SaveAnnotations.save(corpus); |
|
113 |
if (saveJob != null) |
|
114 |
try { |
|
115 |
saveJob.join(); |
|
116 |
} catch (InterruptedException e1) { |
|
117 |
// TODO Auto-generated catch block |
|
118 |
e1.printStackTrace(); |
|
119 |
} |
|
120 |
|
|
121 |
JobHandler jobhandler = new JobHandler("Exporting annotations as standoff for "+corpus) { //$NON-NLS-1$ |
|
122 |
@Override |
|
123 |
protected IStatus run(IProgressMonitor monitor) { |
|
124 |
this.runInit(monitor); |
|
125 |
try { |
|
126 |
monitor.beginTask("Exporting annotations as standoff", 100); |
|
127 |
|
|
128 |
monitor.setTaskName("Writing annotations in XML-TXM stand-off files"); |
|
129 |
/*if (MessageDialog.openConfirm(Display.getCurrent().getActiveShell(), "Before saving annotations...", "All editors using this corpus are going to be closed. Continue ?")) { |
|
130 |
return false; |
|
131 |
}*/ |
|
132 |
|
|
133 |
///lecture de tous les fichiers un par un |
|
134 |
///chaque annotation est récupérée et selon l'annotateur, écrite dans un fichier spécifique à celui-ci |
|
135 |
|
|
136 |
if (!am.exportAnnotationsToSyMoGIH(resultZipFile)) { |
|
137 |
Log.warning("Error while saving stand-off annotations (see logs above)."); |
|
138 |
return Status.CANCEL_STATUS; |
|
139 |
} |
|
140 |
monitor.worked(30); |
|
141 |
|
|
142 |
Log.info("Done."); |
|
143 |
|
|
144 |
} catch(Exception e) { |
|
145 |
Log.warning(NLS.bind("Error while saving annotations: {0}.", e)); |
|
146 |
Log.printStackTrace(e); |
|
147 |
return Status.CANCEL_STATUS; |
|
148 |
} |
|
149 |
return Status.OK_STATUS; |
|
150 |
} |
|
151 |
}; |
|
152 |
|
|
153 |
jobhandler.startJob(true); |
|
154 |
return true; |
|
155 |
} |
|
156 |
} |
|
0 | 157 |
TXM/trunk/bundles/org.txm.annotation.kr.rcp/src/org/txm/annotation/kr/rcp/commands/krview/Reload.java (revision 3653) | ||
---|---|---|
1 |
// Copyright © 2010-2020 ENS de Lyon., University of Franche-Comté |
|
2 |
// Copyright © 2007-2010 ENS de Lyon, CNRS, INRP, University of |
|
3 |
// Lyon 2, University of Franche-Comté, University of Nice |
|
4 |
// Sophia Antipolis, University of Paris 3. |
|
5 |
// |
|
6 |
// The TXM platform is free software: you can redistribute it |
|
7 |
// and/or modify it under the terms of the GNU General Public |
|
8 |
// License as published by the Free Software Foundation, |
|
9 |
// either version 2 of the License, or (at your option) any |
|
10 |
// later version. |
|
11 |
// |
|
12 |
// The TXM platform is distributed in the hope that it will be |
|
13 |
// useful, but WITHOUT ANY WARRANTY; without even the implied |
|
14 |
// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR |
|
15 |
// PURPOSE. See the GNU General Public License for more |
|
16 |
// details. |
|
17 |
// |
|
18 |
// You should have received a copy of the GNU General |
|
19 |
// Public License along with the TXM platform. If not, see |
|
20 |
// http://www.gnu.org/licenses. |
|
21 |
// |
|
22 |
// |
|
23 |
// |
|
24 |
// $LastChangedDate:$ |
|
25 |
// $LastChangedRevision:$ |
|
26 |
// $LastChangedBy:$ |
|
27 |
// |
|
28 |
package org.txm.annotation.kr.rcp.commands.krview; |
|
29 |
|
|
30 |
import org.eclipse.core.commands.AbstractHandler; |
|
31 |
import org.eclipse.core.commands.ExecutionEvent; |
Formats disponibles : Unified diff