Révision 3495
TXM/trunk/org.txm.annotation.kr.rcp/plugin.xml (revision 3495) | ||
---|---|---|
374 | 374 |
<definition |
375 | 375 |
id="CorpusNeedtoSaveAnnotation"> |
376 | 376 |
<and> |
377 |
<reference |
|
378 |
definitionId="OneMainCorpusSelected"> |
|
379 |
</reference> |
|
380 | 377 |
<test |
381 | 378 |
forcePluginActivation="true" |
382 | 379 |
property="org.txm.rcp.testers.IsCorpusDirty"> |
TXM/trunk/org.txm.annotation.kr.rcp/src/org/txm/rcp/testers/IsCorpusDirty.java (revision 3495) | ||
---|---|---|
3 | 3 |
import java.util.List; |
4 | 4 |
|
5 | 5 |
import org.eclipse.core.expressions.PropertyTester; |
6 |
import org.eclipse.ui.IEditorPart; |
|
7 |
import org.eclipse.ui.PlatformUI; |
|
6 | 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; |
|
7 | 12 |
import org.txm.searchengine.cqp.corpus.MainCorpus; |
8 | 13 |
|
9 | 14 |
|
... | ... | |
11 | 16 |
|
12 | 17 |
@Override |
13 | 18 |
public boolean test(Object receiver, String property, Object[] args, Object expectedValue) { |
14 |
|
|
19 |
|
|
15 | 20 |
if (receiver instanceof List) { |
16 | 21 |
List list = (List) receiver; |
17 | 22 |
if (list.size() == 0) return true; |
18 | 23 |
receiver = list.get(0); |
19 | 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 |
|
|
20 | 34 |
if (receiver instanceof MainCorpus) { |
21 | 35 |
return KRAnnotationEngine.needToSaveAnnotations(((MainCorpus) receiver)); |
22 | 36 |
} |
23 | 37 |
|
38 |
IEditorPart e = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor(); |
|
39 |
if (e instanceof ConcordanceEditor) { |
|
40 |
KRAnnotationEngine.needToSaveAnnotations(((ConcordanceEditor) e).getCorpus().getMainCorpus()); |
|
41 |
} |
|
42 |
|
|
24 | 43 |
return false; |
25 | 44 |
} |
26 | 45 |
} |
TXM/trunk/org.txm.annotation.kr.rcp/src/org/txm/annotation/kr/rcp/commands/SaveAnnotationsAndUpdateCorpus.java (revision 3495) | ||
---|---|---|
15 | 15 |
import org.eclipse.ui.handlers.HandlerUtil; |
16 | 16 |
import org.txm.annotation.kr.core.KRAnnotationEngine; |
17 | 17 |
import org.txm.annotation.kr.core.preferences.KRAnnotationPreferences; |
18 |
import org.txm.concordance.rcp.editors.ConcordanceEditor; |
|
19 |
import org.txm.core.results.TXMResult; |
|
18 | 20 |
import org.txm.rcp.commands.workspace.UpdateCorpus; |
19 | 21 |
import org.txm.rcp.messages.TXMUIMessages; |
20 | 22 |
import org.txm.rcp.swt.dialog.UpdateCorpusDialog; |
... | ... | |
26 | 28 |
public class SaveAnnotationsAndUpdateCorpus extends AbstractHandler { |
27 | 29 |
|
28 | 30 |
public static final String ID = SaveAnnotationsAndUpdateCorpus.class.getCanonicalName(); |
31 |
MainCorpus corpus = null; |
|
29 | 32 |
|
30 | 33 |
@Override |
31 | 34 |
public Object execute(ExecutionEvent event) throws ExecutionException { |
... | ... | |
34 | 37 |
if (!(sel instanceof IStructuredSelection)) return null; |
35 | 38 |
IStructuredSelection selection = (IStructuredSelection) sel; |
36 | 39 |
|
37 |
Object s = selection.getFirstElement(); |
|
38 |
if (!(s instanceof MainCorpus)) { |
|
39 |
return null; |
|
40 |
|
|
41 |
if (HandlerUtil.getActiveEditor(event) instanceof ConcordanceEditor) { |
|
42 |
corpus = ((ConcordanceEditor) HandlerUtil.getActiveEditor(event)).getCorpus().getMainCorpus(); |
|
43 |
} else { |
|
44 |
Object s = selection.getFirstElement(); |
|
45 |
if ((s instanceof MainCorpus)) { |
|
46 |
corpus = (MainCorpus) s; |
|
47 |
return null; |
|
48 |
} else if (!(s instanceof TXMResult)) { |
|
49 |
corpus = ((TXMResult) s).getFirstParent(MainCorpus.class); |
|
50 |
} |
|
40 | 51 |
} |
41 | 52 |
|
42 |
|
|
43 |
|
|
44 |
|
|
45 |
MainCorpus corpus = (MainCorpus) s; |
|
46 | 53 |
try { |
47 | 54 |
|
48 | 55 |
if (!KRAnnotationEngine.needToSaveAnnotations(corpus)) { |
Formats disponibles : Unified diff