Révision 3569
TXM/trunk/org.txm.annotation.kr.rcp/plugin.xml (revision 3569) | ||
---|---|---|
262 | 262 |
icon="icons/functions/pencil_save.png" |
263 | 263 |
label="%command.label.111" |
264 | 264 |
style="push"> |
265 |
<visibleWhen |
|
266 |
checkEnabled="false"> |
|
267 |
<reference |
|
268 |
definitionId="CorpusNeedtoSaveAnnotation"> |
|
269 |
</reference> |
|
270 |
</visibleWhen> |
|
271 | 265 |
</command> |
272 | 266 |
</menuContribution> |
273 | 267 |
<menuContribution |
TXM/trunk/org.txm.annotation.kr.rcp/src/org/txm/annotation/kr/rcp/commands/SaveAnnotations.java (revision 3569) | ||
---|---|---|
1 | 1 |
package org.txm.annotation.kr.rcp.commands; |
2 | 2 |
|
3 |
import java.util.ArrayList; |
|
4 |
import java.util.HashMap; |
|
5 |
import java.util.LinkedHashMap; |
|
6 |
|
|
3 | 7 |
import org.eclipse.core.commands.AbstractHandler; |
4 | 8 |
import org.eclipse.core.commands.ExecutionEvent; |
5 | 9 |
import org.eclipse.core.commands.ExecutionException; |
... | ... | |
11 | 15 |
import org.eclipse.jface.viewers.IStructuredSelection; |
12 | 16 |
import org.eclipse.osgi.util.NLS; |
13 | 17 |
import org.eclipse.swt.widgets.Display; |
18 |
import org.eclipse.ui.dialogs.ListDialog; |
|
19 |
import org.eclipse.ui.dialogs.ListSelectionDialog; |
|
14 | 20 |
import org.eclipse.ui.handlers.HandlerUtil; |
15 | 21 |
import org.txm.annotation.kr.core.AnnotationManager; |
16 | 22 |
import org.txm.annotation.kr.core.KRAnnotationEngine; |
23 |
import org.txm.objects.Workspace; |
|
17 | 24 |
import org.txm.rcp.messages.TXMUIMessages; |
25 |
import org.txm.rcp.swt.dialog.ListMultiSelectionDialog; |
|
26 |
import org.txm.rcp.swt.dialog.MultipleChoiceDialog; |
|
27 |
import org.txm.rcp.swt.dialog.MultipleValueDialog; |
|
18 | 28 |
import org.txm.rcp.utils.JobHandler; |
19 | 29 |
import org.txm.rcp.utils.SWTEditorsUtils; |
20 | 30 |
import org.txm.rcp.views.corpora.CorporaView; |
... | ... | |
28 | 38 |
@Override |
29 | 39 |
public Object execute(ExecutionEvent event) throws ExecutionException { |
30 | 40 |
|
31 |
ISelection sel = HandlerUtil.getCurrentSelection(event); |
|
32 |
if (!(sel instanceof IStructuredSelection)) return null; |
|
33 |
IStructuredSelection selection = (IStructuredSelection) sel; |
|
41 |
LinkedHashMap<String, MainCorpus> corporaWithAnnotationsToSave = new LinkedHashMap<>(); |
|
42 |
for (MainCorpus corpus : Workspace.getInstance().getDeepChildren(MainCorpus.class)) { |
|
43 |
if (!corpus.getProject().isOpen()) continue; |
|
44 |
AnnotationManager am; |
|
45 |
try { |
|
46 |
am = KRAnnotationEngine.getAnnotationManager(corpus); |
|
47 |
} |
|
48 |
catch (Exception e) { |
|
49 |
// TODO Auto-generated catch block |
|
50 |
e.printStackTrace(); |
|
51 |
continue; |
|
52 |
} |
|
53 |
if (am == null) { |
|
54 |
continue; // nothing to do |
|
55 |
} |
|
56 |
|
|
57 |
if (!KRAnnotationEngine.needToSaveAnnotations(corpus)) { |
|
58 |
continue; |
|
59 |
} |
|
60 |
|
|
61 |
corporaWithAnnotationsToSave.put(corpus.getName(), corpus); |
|
62 |
} |
|
34 | 63 |
|
35 |
Object s = selection.getFirstElement();
|
|
36 |
if (!(s instanceof MainCorpus))
|
|
64 |
if (corporaWithAnnotationsToSave.size() == 0) {
|
|
65 |
Log.info("No annotation to do in corpora.");
|
|
37 | 66 |
return null; |
38 |
MainCorpus corpus = (MainCorpus) s; |
|
39 |
try { |
|
40 |
JobHandler job = save(corpus); |
|
41 |
if (job == null) { |
|
42 |
return null; |
|
43 |
} |
|
44 | 67 |
} |
45 |
catch (Exception e) { |
|
46 |
// TODO Auto-generated catch block
|
|
47 |
e.printStackTrace();
|
|
68 |
|
|
69 |
ListMultiSelectionDialog<MainCorpus> dialog = new ListMultiSelectionDialog<MainCorpus>(HandlerUtil.getActiveShell(event), "Select corpus to save", "Select in the list the corpus you wich to save annotations", corporaWithAnnotationsToSave);
|
|
70 |
if (dialog.open() != MultipleChoiceDialog.OK) {
|
|
48 | 71 |
return null; |
49 | 72 |
} |
50 | 73 |
|
74 |
// Object s = selection.getFirstElement(); |
|
75 |
// if (!(s instanceof MainCorpus)) |
|
76 |
// return null; |
|
77 |
|
|
78 |
for (MainCorpus corpus : dialog.getSelectedValues().values()) { |
|
79 |
try { |
|
80 |
JobHandler job = save(corpus); |
|
81 |
if (job == null) { |
|
82 |
return null; |
|
83 |
} else { |
|
84 |
job.join(); |
|
85 |
} |
|
86 |
} |
|
87 |
catch (Exception e) { |
|
88 |
// TODO Auto-generated catch block |
|
89 |
e.printStackTrace(); |
|
90 |
return null; |
|
91 |
} |
|
92 |
} |
|
93 |
|
|
51 | 94 |
CorporaView.refresh(); |
52 | 95 |
|
53 |
return corpus;
|
|
96 |
return dialog.getSelectedValues();
|
|
54 | 97 |
} |
55 | 98 |
|
56 | 99 |
public static JobHandler save(final MainCorpus corpus) throws Exception { |
TXM/trunk/org.txm.annotation.kr.rcp/src/org/txm/annotation/kr/rcp/commands/SaveAnnotationsAndUpdateCorpus.java (revision 3569) | ||
---|---|---|
1 | 1 |
package org.txm.annotation.kr.rcp.commands; |
2 | 2 |
|
3 |
import java.util.LinkedHashMap; |
|
4 |
|
|
3 | 5 |
import org.eclipse.core.commands.AbstractHandler; |
4 | 6 |
import org.eclipse.core.commands.ExecutionEvent; |
5 | 7 |
import org.eclipse.core.commands.ExecutionException; |
... | ... | |
12 | 14 |
import org.eclipse.osgi.util.NLS; |
13 | 15 |
import org.eclipse.swt.widgets.Display; |
14 | 16 |
import org.eclipse.ui.handlers.HandlerUtil; |
17 |
import org.txm.annotation.kr.core.AnnotationManager; |
|
15 | 18 |
import org.txm.annotation.kr.core.KRAnnotationEngine; |
16 | 19 |
import org.txm.annotation.kr.core.preferences.KRAnnotationPreferences; |
17 | 20 |
import org.txm.concordance.rcp.editors.ConcordanceEditor; |
18 | 21 |
import org.txm.core.results.TXMResult; |
22 |
import org.txm.objects.CorpusBuild; |
|
23 |
import org.txm.objects.Workspace; |
|
19 | 24 |
import org.txm.rcp.commands.workspace.UpdateCorpus; |
20 | 25 |
import org.txm.rcp.messages.TXMUIMessages; |
21 | 26 |
import org.txm.rcp.swt.dialog.UpdateCorpusDialog; |
... | ... | |
31 | 36 |
@Override |
32 | 37 |
public Object execute(ExecutionEvent event) throws ExecutionException { |
33 | 38 |
|
34 |
ISelection sel = HandlerUtil.getCurrentSelection(event); |
|
35 |
if (!(sel instanceof IStructuredSelection)) { |
|
36 |
Log.info("No available selection to target the corpus annotations to save"); |
|
37 |
return null; |
|
38 |
} |
|
39 |
IStructuredSelection selection = (IStructuredSelection) sel; |
|
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 |
// MainCorpus corpus = null; |
|
47 |
// |
|
48 |
// if (HandlerUtil.getActiveEditor(event) instanceof ConcordanceEditor) { |
|
49 |
// corpus = ((ConcordanceEditor) HandlerUtil.getActiveEditor(event)).getCorpus().getMainCorpus(); |
|
50 |
// } else { |
|
51 |
// Object s = selection.getFirstElement(); |
|
52 |
// if (s == null) { |
|
53 |
// Log.info("No available selection to target the corpus annotations to save"); |
|
54 |
// return null; |
|
55 |
// } else if ((s instanceof MainCorpus)) { |
|
56 |
// corpus = (MainCorpus) s; |
|
57 |
// } else if (s instanceof TXMResult) { |
|
58 |
// corpus = ((TXMResult) s).getFirstParent(MainCorpus.class); |
|
59 |
// } else { |
|
60 |
// Log.info("No available selection to target the corpus annotations to save"); |
|
61 |
// return null; |
|
62 |
// } |
|
63 |
// } |
|
64 |
// |
|
40 | 65 |
|
41 |
MainCorpus corpus = null; |
|
42 |
|
|
43 |
if (HandlerUtil.getActiveEditor(event) instanceof ConcordanceEditor) { |
|
44 |
corpus = ((ConcordanceEditor) HandlerUtil.getActiveEditor(event)).getCorpus().getMainCorpus(); |
|
45 |
} else { |
|
46 |
Object s = selection.getFirstElement(); |
|
47 |
if (s == null) { |
|
48 |
Log.info("No available selection to target the corpus annotations to save"); |
|
49 |
return null; |
|
50 |
} else if ((s instanceof MainCorpus)) { |
|
51 |
corpus = (MainCorpus) s; |
|
52 |
} else if (s instanceof TXMResult) { |
|
53 |
corpus = ((TXMResult) s).getFirstParent(MainCorpus.class); |
|
54 |
} else { |
|
55 |
Log.info("No available selection to target the corpus annotations to save"); |
|
56 |
return null; |
|
66 |
|
|
67 |
LinkedHashMap<String, MainCorpus> corporaWithAnnotationsToSave = new LinkedHashMap<>(); |
|
68 |
for (MainCorpus corpus : Workspace.getInstance().getDeepChildren(MainCorpus.class)) { |
|
69 |
if (!corpus.getProject().isOpen()) continue; |
|
70 |
AnnotationManager am; |
|
71 |
try { |
|
72 |
am = KRAnnotationEngine.getAnnotationManager(corpus); |
|
57 | 73 |
} |
74 |
catch (Exception e) { |
|
75 |
// TODO Auto-generated catch block |
|
76 |
e.printStackTrace(); |
|
77 |
continue; |
|
78 |
} |
|
79 |
if (am == null) { |
|
80 |
continue; // nothing to do |
|
81 |
} |
|
82 |
|
|
83 |
if (!KRAnnotationEngine.needToSaveAnnotations(corpus)) { |
|
84 |
continue; |
|
85 |
} |
|
86 |
|
|
87 |
corporaWithAnnotationsToSave.put(corpus.getName(), corpus); |
|
58 | 88 |
} |
59 | 89 |
|
90 |
if (corporaWithAnnotationsToSave.size() == 0) { |
|
91 |
Log.info("No CQP annotation found to save in the corpora."); |
|
92 |
return null; |
|
93 |
} |
|
94 |
|
|
60 | 95 |
try { |
61 |
if (!KRAnnotationEngine.needToSaveAnnotations(corpus)) { |
|
62 |
Log.info(NLS.bind("No CQP annotation found to save in the {0} corpus.", corpus)); |
|
63 |
return null; |
|
64 |
} |
|
96 |
// if (!KRAnnotationEngine.needToSaveAnnotations(corpus)) {
|
|
97 |
// Log.info(NLS.bind("No CQP annotation found to save in the {0} corpus.", corpus));
|
|
98 |
// return null;
|
|
99 |
// }
|
|
65 | 100 |
|
66 | 101 |
// System.out.println("DISPLAY="+Display.getDefault()); |
67 | 102 |
final Boolean[] doit = new Boolean[1]; |
... | ... | |
70 | 105 |
final Boolean[] doupdateedition = new Boolean[1]; |
71 | 106 |
doupdateedition[0] = KRAnnotationPreferences.getInstance().getBoolean(KRAnnotationPreferences.UPDATE_EDITION); |
72 | 107 |
|
108 |
UpdateCorpusDialog dialog = new UpdateCorpusDialog(Display.getDefault().getActiveShell(), corporaWithAnnotationsToSave); |
|
109 |
dialog.setTitle("Select corpus to save and update options"); |
|
110 |
dialog.setMessages(null, dialog.getBottomMessage()); |
|
111 |
dialog.setDoForceUpdate(false); |
|
112 |
dialog.setDoUpdateEdition(KRAnnotationPreferences.getInstance().getBoolean(KRAnnotationPreferences.UPDATE_EDITION)); |
|
113 |
|
|
73 | 114 |
Display.getDefault().syncExec(new Runnable() { |
74 | 115 |
|
75 | 116 |
@Override |
76 | 117 |
public void run() { |
77 |
UpdateCorpusDialog dialog = new UpdateCorpusDialog(Display.getDefault().getActiveShell()); |
|
78 |
dialog.setTitle("Before saving annotations..."); |
|
79 |
dialog.setMessages("Save Annotations and update the corpus.", dialog.getBottomMessage()); |
|
80 |
dialog.setDoForceUpdate(false); |
|
81 |
dialog.setDoUpdateEdition(KRAnnotationPreferences.getInstance().getBoolean(KRAnnotationPreferences.UPDATE_EDITION)); |
|
82 | 118 |
|
119 |
|
|
83 | 120 |
doit[0] = dialog.open() == Window.OK; |
84 | 121 |
doupdateedition[0] = dialog.getDoUpdateEdition(); |
85 | 122 |
} |
... | ... | |
88 | 125 |
return null; |
89 | 126 |
} |
90 | 127 |
|
91 |
|
|
92 |
Log.info(NLS.bind("Saving {0} annotations...", corpus.getName())); |
|
93 |
JobHandler job = SaveAnnotations.save(corpus); |
|
94 |
if (job == null) { |
|
128 |
if (dialog.getSelectedCorpus().size() == 0) { |
|
129 |
Log.info("No corpus selected. Aborting."); |
|
95 | 130 |
return null; |
96 | 131 |
} |
97 |
final MainCorpus fcorpus = corpus; |
|
132 |
|
|
133 |
|
|
134 |
JobHandler job = null; |
|
135 |
|
|
136 |
Log.info(NLS.bind("Saving {0} annotations...", dialog.getSelectedCorpus().keySet())); |
|
137 |
for (MainCorpus corpus : dialog.getSelectedCorpus().values()) { |
|
138 |
try { |
|
139 |
job = SaveAnnotations.save(corpus); |
|
140 |
if (job == null) { |
|
141 |
return null; |
|
142 |
} else { |
|
143 |
job.join(); |
|
144 |
} |
|
145 |
} |
|
146 |
catch (Exception e) { |
|
147 |
// TODO Auto-generated catch block |
|
148 |
e.printStackTrace(); |
|
149 |
return null; |
|
150 |
} |
|
151 |
} |
|
98 | 152 |
|
99 |
if (job.getState() == Status.OK_STATUS.getCode()) { |
|
153 |
if (job != null && job.getState() == Status.OK_STATUS.getCode()) {
|
|
100 | 154 |
if (KRAnnotationPreferences.getInstance().getBoolean(KRAnnotationPreferences.UPDATE)) { |
101 | 155 |
|
102 | 156 |
JobHandler job2 = new JobHandler("Updating corpus editions and indexes", true) { |
... | ... | |
106 | 160 |
this.runInit(monitor); |
107 | 161 |
|
108 | 162 |
try { |
109 |
monitor.setTaskName("Updating corpus"); |
|
110 |
if (fcorpus != null && UpdateCorpus.update(fcorpus, false, doupdateedition[0]) != null) { |
|
111 |
monitor.worked(50); |
|
112 |
this.syncExec(new Runnable() { |
|
113 |
|
|
114 |
@Override |
|
115 |
public void run() { |
|
116 |
CorporaView.refreshObject(fcorpus); |
|
163 |
monitor.setTaskName("Updating corpora: "+dialog.getSelectedCorpus().values()); |
|
164 |
for (MainCorpus fcorpus : dialog.getSelectedCorpus().values()) { |
|
165 |
JobHandler job2 = UpdateCorpus.update(fcorpus, false, doupdateedition[0]); |
|
166 |
if (fcorpus != null && job2 != null) { |
|
167 |
try { |
|
168 |
job2.join(); |
|
117 | 169 |
} |
118 |
}); |
|
119 |
return Status.OK_STATUS; |
|
170 |
catch (InterruptedException e) { |
|
171 |
// TODO Auto-generated catch block |
|
172 |
e.printStackTrace(); |
|
173 |
} |
|
174 |
monitor.worked(50); |
|
175 |
} |
|
176 |
else { |
|
177 |
monitor.worked(50); |
|
178 |
Log.warning("Fail to update corpus. Aborting"); |
|
179 |
Log.warning("Fix XML-TXM files and call command 'UpdateCorpus'"); |
|
180 |
return Status.CANCEL_STATUS; |
|
181 |
} |
|
120 | 182 |
} |
121 |
else { |
|
122 |
monitor.worked(50); |
|
123 |
Log.warning("Fail to update corpus. Aborting"); |
|
124 |
Log.warning("Fix XML-TXM files and call command 'UpdateCorpus'"); |
|
125 |
return Status.CANCEL_STATUS; |
|
126 |
} |
|
183 |
|
|
184 |
this.syncExec(new Runnable() { |
|
185 |
|
|
186 |
@Override |
|
187 |
public void run() { |
|
188 |
CorporaView.refresh(); |
|
189 |
} |
|
190 |
}); |
|
191 |
return Status.OK_STATUS; |
|
192 |
|
|
127 | 193 |
} catch(ThreadDeath ex) { |
128 | 194 |
Log.info(TXMUIMessages.executionCanceled); |
129 | 195 |
return Status.CANCEL_STATUS; |
... | ... | |
144 | 210 |
|
145 | 211 |
CorporaView.refresh(); |
146 | 212 |
|
147 |
return corpus;
|
|
213 |
return corporaWithAnnotationsToSave;
|
|
148 | 214 |
} |
149 | 215 |
} |
TXM/trunk/org.txm.rcp/src/main/java/org/txm/rcp/commands/workspace/UpdateCorpus.java (revision 3569) | ||
---|---|---|
43 | 43 |
} |
44 | 44 |
MainCorpus corpus = (MainCorpus) s; |
45 | 45 |
|
46 |
UpdateCorpusDialog dialog = new UpdateCorpusDialog(HandlerUtil.getActiveShell(event)); |
|
46 |
UpdateCorpusDialog dialog = new UpdateCorpusDialog(HandlerUtil.getActiveShell(event), null);
|
|
47 | 47 |
dialog.setDoUpdateEdition(TBXPreferences.getInstance().getBoolean(TBXPreferences.UPDATEEDITIONS)); |
48 | 48 |
dialog.setDoForceUpdate("true".equals(event.getParameter("org.txm.rcp.commands.workspace.UpdateCorpus.force"))); //$NON-NLS-1$ //$NON-NLS-2$ |
49 | 49 |
|
TXM/trunk/org.txm.rcp/src/main/java/org/txm/rcp/swt/dialog/ListMultiSelectionDialog.java (revision 3569) | ||
---|---|---|
1 |
package org.txm.rcp.swt.dialog; |
|
2 |
|
|
3 |
import java.util.LinkedHashMap; |
|
4 |
|
|
5 |
import org.eclipse.jface.dialogs.Dialog; |
|
6 |
import org.eclipse.swt.SWT; |
|
7 |
import org.eclipse.swt.widgets.Composite; |
|
8 |
import org.eclipse.swt.widgets.Control; |
|
9 |
import org.eclipse.swt.widgets.List; |
|
10 |
import org.eclipse.swt.widgets.Shell; |
|
11 |
|
|
12 |
public class ListMultiSelectionDialog<T> extends Dialog { |
|
13 |
|
|
14 |
LinkedHashMap<String, T> values; |
|
15 |
LinkedHashMap<String, T> selectedValues; |
|
16 |
List valuesList; |
|
17 |
|
|
18 |
public ListMultiSelectionDialog(Shell parentShell, String title, String message, LinkedHashMap<String, T> values) { |
|
19 |
|
|
20 |
super(parentShell); |
|
21 |
this.values = values; |
|
22 |
this.selectedValues = new LinkedHashMap<>(); |
|
23 |
} |
|
24 |
|
|
25 |
public LinkedHashMap<String, T> getInitialValues() { |
|
26 |
return values; |
|
27 |
} |
|
28 |
|
|
29 |
public LinkedHashMap<String, T> getSelectedValues() { |
|
30 |
return selectedValues; |
|
31 |
} |
|
32 |
|
|
33 |
/* (non-Javadoc) |
|
34 |
* @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite) |
|
35 |
*/ |
|
36 |
@Override |
|
37 |
protected Control createDialogArea(Composite p) { |
|
38 |
//System.out.println(p.getLayout()); |
|
39 |
|
|
40 |
valuesList = new List(p, SWT.MULTI); |
|
41 |
|
|
42 |
valuesList.setItems(values.keySet().toArray(new String[values.size()])); |
|
43 |
|
|
44 |
return p; |
|
45 |
} |
|
46 |
|
|
47 |
/* (non-Javadoc) |
|
48 |
* @see org.eclipse.jface.dialogs.Dialog#okPressed() |
|
49 |
*/ |
|
50 |
@Override |
|
51 |
protected void okPressed() { |
|
52 |
for (String item : valuesList.getSelection()) { |
|
53 |
selectedValues.put(item, values.get(item)); |
|
54 |
} |
|
55 |
super.okPressed(); |
|
56 |
} |
|
57 |
|
|
58 |
} |
|
0 | 59 |
TXM/trunk/org.txm.rcp/src/main/java/org/txm/rcp/swt/dialog/MultipleChoiceDialog.java (revision 3569) | ||
---|---|---|
27 | 27 |
// |
28 | 28 |
package org.txm.rcp.swt.dialog; |
29 | 29 |
|
30 |
import java.util.HashMap; |
|
31 |
import java.util.LinkedHashMap; |
|
32 |
|
|
33 | 30 |
import org.eclipse.jface.dialogs.Dialog; |
34 | 31 |
import org.eclipse.swt.SWT; |
35 | 32 |
import org.eclipse.swt.events.SelectionEvent; |
... | ... | |
41 | 38 |
import org.eclipse.swt.widgets.Control; |
42 | 39 |
import org.eclipse.swt.widgets.Label; |
43 | 40 |
import org.eclipse.swt.widgets.Shell; |
44 |
import org.eclipse.swt.widgets.Text; |
|
45 | 41 |
|
46 | 42 |
/** |
47 | 43 |
* Open a dialog with a button per choice |
TXM/trunk/org.txm.rcp/src/main/java/org/txm/rcp/swt/dialog/ObjectSelectionDialog.java (revision 3569) | ||
---|---|---|
48 | 48 |
import org.txm.rcp.IImageKeys; |
49 | 49 |
import org.txm.rcp.messages.TXMUIMessages; |
50 | 50 |
|
51 |
// TODO: Auto-generated Javadoc |
|
52 | 51 |
/** |
53 |
* allow to choose between a set of values and choose the order of the selection @
|
|
54 |
* author mdecorde. |
|
52 |
* allow to choose between a set of values and choose the order of the selection |
|
53 |
* @author mdecorde.
|
|
55 | 54 |
*/ |
56 | 55 |
public class ObjectSelectionDialog extends Dialog { |
57 | 56 |
|
... | ... | |
123 | 122 |
mainArea.setLayout(layout); |
124 | 123 |
|
125 | 124 |
regexAvailable = new Text(mainArea, SWT.BORDER); |
126 |
regexAvailable.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, |
|
127 |
false)); |
|
125 |
regexAvailable.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false)); |
|
128 | 126 |
|
129 | 127 |
Button searchAvailableBtn = new Button(mainArea, SWT.PUSH); |
130 |
searchAvailableBtn.setLayoutData(new GridData(SWT.FILL, SWT.FILL, |
|
131 |
false, false)); |
|
132 |
searchAvailableBtn.setImage(IImageKeys |
|
133 |
.getImage(IImageKeys.ACTION_SEARCH)); |
|
128 |
searchAvailableBtn.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false)); |
|
129 |
searchAvailableBtn.setImage(IImageKeys.getImage(IImageKeys.ACTION_SEARCH)); |
|
134 | 130 |
searchAvailableBtn.addSelectionListener(new SelectionListener() { |
135 | 131 |
@Override |
136 | 132 |
public void widgetSelected(SelectionEvent e) { |
... | ... | |
144 | 140 |
}); |
145 | 141 |
|
146 | 142 |
regexSelected = new Text(mainArea, SWT.BORDER); |
147 |
regexSelected.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, |
|
148 |
false)); |
|
143 |
regexSelected.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false)); |
|
149 | 144 |
Button searchSelectedBtn = new Button(mainArea, SWT.PUSH); |
150 |
searchSelectedBtn.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, |
|
151 |
false)); |
|
152 |
searchSelectedBtn.setImage(IImageKeys |
|
153 |
.getImage(IImageKeys.ACTION_SEARCH)); |
|
145 |
searchSelectedBtn.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false)); |
|
146 |
searchSelectedBtn.setImage(IImageKeys.getImage(IImageKeys.ACTION_SEARCH)); |
|
154 | 147 |
searchSelectedBtn.addSelectionListener(new SelectionListener() { |
155 | 148 |
@Override |
156 | 149 |
public void widgetSelected(SelectionEvent e) { |
... | ... | |
163 | 156 |
} |
164 | 157 |
}); |
165 | 158 |
|
166 |
availablesView = new org.eclipse.swt.widgets.List(mainArea, SWT.BORDER |
|
167 |
| SWT.MULTI | SWT.V_SCROLL); |
|
159 |
availablesView = new org.eclipse.swt.widgets.List(mainArea, SWT.BORDER | SWT.MULTI | SWT.V_SCROLL); |
|
168 | 160 |
GridData gridData = new GridData(SWT.FILL, SWT.FILL, true, true); |
169 | 161 |
availablesView.setLayoutData(gridData); |
170 | 162 |
|
... | ... | |
173 | 165 |
Button select = new Button(selectionButtons, SWT.ARROW | SWT.RIGHT); |
174 | 166 |
Button unselect = new Button(selectionButtons, SWT.ARROW | SWT.LEFT); |
175 | 167 |
|
176 |
selectedsView = new org.eclipse.swt.widgets.List(mainArea, SWT.BORDER |
|
177 |
| SWT.MULTI | SWT.V_SCROLL); |
|
168 |
selectedsView = new org.eclipse.swt.widgets.List(mainArea, SWT.BORDER | SWT.MULTI | SWT.V_SCROLL); |
|
178 | 169 |
gridData = new GridData(SWT.FILL, SWT.FILL, true, true); |
179 | 170 |
selectedsView.setLayoutData(gridData); |
180 | 171 |
|
TXM/trunk/org.txm.rcp/src/main/java/org/txm/rcp/swt/dialog/UpdateCorpusDialog.java (revision 3569) | ||
---|---|---|
1 | 1 |
package org.txm.rcp.swt.dialog; |
2 | 2 |
|
3 |
import java.util.LinkedHashMap; |
|
4 |
|
|
3 | 5 |
import org.eclipse.jface.dialogs.Dialog; |
6 |
import org.eclipse.jface.viewers.IStructuredSelection; |
|
4 | 7 |
import org.eclipse.swt.SWT; |
5 | 8 |
import org.eclipse.swt.layout.GridData; |
6 | 9 |
import org.eclipse.swt.layout.GridLayout; |
... | ... | |
8 | 11 |
import org.eclipse.swt.widgets.Composite; |
9 | 12 |
import org.eclipse.swt.widgets.Control; |
10 | 13 |
import org.eclipse.swt.widgets.Label; |
14 |
import org.eclipse.swt.widgets.List; |
|
11 | 15 |
import org.eclipse.swt.widgets.Shell; |
16 |
import org.txm.objects.CorpusBuild; |
|
12 | 17 |
import org.txm.rcp.messages.TXMUIMessages; |
18 |
import org.txm.searchengine.cqp.corpus.MainCorpus; |
|
13 | 19 |
|
14 | 20 |
public class UpdateCorpusDialog extends Dialog { |
15 | 21 |
|
... | ... | |
24 | 30 |
public boolean doOpenCorpusParameters = false; |
25 | 31 |
public boolean doUpdateEditions = false; |
26 | 32 |
public boolean doForceUpdate = false; |
33 |
private LinkedHashMap<String, MainCorpus> corpora; |
|
34 |
private LinkedHashMap<String, MainCorpus> selectedCorpora; |
|
35 |
private List valuesList; |
|
27 | 36 |
|
28 |
public UpdateCorpusDialog(Shell parentShell) { |
|
37 |
public UpdateCorpusDialog(Shell parentShell, LinkedHashMap<String, MainCorpus> corpora) {
|
|
29 | 38 |
|
30 | 39 |
super(parentShell); |
40 |
this.corpora = corpora; |
|
41 |
this.selectedCorpora = new LinkedHashMap<>(); |
|
31 | 42 |
} |
32 | 43 |
|
33 | 44 |
@Override |
... | ... | |
45 | 56 |
layout.verticalSpacing = 20; |
46 | 57 |
layout.marginWidth = 15; |
47 | 58 |
|
48 |
createTopMessageArea(comp); |
|
59 |
if (topMessage !=null && topMessage.length() > 0) { |
|
60 |
createTopMessageArea(comp); |
|
61 |
} |
|
49 | 62 |
|
63 |
if (corpora != null && corpora.size() > 1) { |
|
64 |
createCorporaSelectionArea(comp); |
|
65 |
} else { |
|
66 |
selectedCorpora = corpora; |
|
67 |
} |
|
68 |
|
|
50 | 69 |
createButtonsArea(comp); |
51 | 70 |
|
52 | 71 |
createBottomMessageArea(comp); |
... | ... | |
54 | 73 |
return comp; |
55 | 74 |
} |
56 | 75 |
|
76 |
private void createCorporaSelectionArea(Composite p) { |
|
77 |
|
|
78 |
Label valuesListLabel = new Label(p, SWT.NONE); |
|
79 |
valuesListLabel.setText("Select the corpus annotations to save :"); |
|
80 |
valuesList = new List(p, SWT.MULTI | SWT.BORDER); |
|
81 |
GridData data = new GridData(GridData.FILL_HORIZONTAL); |
|
82 |
valuesList.setLayoutData(data); |
|
83 |
valuesList.setItems(corpora.keySet().toArray(new String[corpora.size()])); |
|
84 |
valuesList.selectAll(); |
|
85 |
} |
|
86 |
|
|
57 | 87 |
protected void createButtonsArea(Composite comp) { |
58 | 88 |
|
89 |
Label titleLabel = new Label(comp, SWT.NONE); |
|
90 |
titleLabel.setText("Options :"); |
|
91 |
|
|
59 | 92 |
GridData data = new GridData(GridData.FILL_HORIZONTAL); |
60 | 93 |
|
61 | 94 |
openCorpusParameters = new Button(comp, SWT.CHECK); |
... | ... | |
102 | 135 |
doUpdateEditions = updateEditionsCheck.getSelection(); |
103 | 136 |
doForceUpdate = forceUpdateCheck.getSelection(); |
104 | 137 |
doOpenCorpusParameters = openCorpusParameters.getSelection(); |
138 |
if (corpora != null) { |
|
139 |
selectedCorpora = new LinkedHashMap<>(); |
|
140 |
for (String item : valuesList.getSelection()) { |
|
141 |
selectedCorpora.put(item, corpora.get(item)); |
|
142 |
} |
|
143 |
} |
|
105 | 144 |
} |
106 | 145 |
|
107 | 146 |
super.buttonPressed(buttonId); |
... | ... | |
171 | 210 |
|
172 | 211 |
this.title = title; |
173 | 212 |
} |
213 |
|
|
214 |
public LinkedHashMap<String, MainCorpus> getSelectedCorpus() { |
|
215 |
|
|
216 |
return selectedCorpora; |
|
217 |
} |
|
174 | 218 |
} |
TXM/trunk/org.txm.jodconverter.core/target/classes/document-formats.js (revision 3569) | ||
---|---|---|
1 |
[ |
|
2 |
{ |
|
3 |
"name": "Portable Document Format", |
|
4 |
"extension": "pdf", |
|
5 |
"mediaType": "application/pdf", |
|
6 |
"storePropertiesByFamily": { |
|
7 |
"DRAWING": {"FilterName": "draw_pdf_Export"}, |
|
8 |
"SPREADSHEET": {"FilterName": "calc_pdf_Export"}, |
|
9 |
"PRESENTATION": {"FilterName": "impress_pdf_Export"}, |
|
10 |
"TEXT": {"FilterName": "writer_pdf_Export"} |
|
11 |
} |
|
12 |
}, |
|
13 |
{ |
|
14 |
"name": "Macromedia Flash", |
|
15 |
"extension": "swf", |
|
16 |
"mediaType": "application/x-shockwave-flash", |
|
17 |
"storePropertiesByFamily": { |
|
18 |
"DRAWING": {"FilterName": "draw_flash_Export"}, |
|
19 |
"PRESENTATION": {"FilterName": "impress_flash_Export"} |
|
20 |
} |
|
21 |
}, |
|
22 |
{ |
|
23 |
"name": "HTML", |
|
24 |
"extension": "html", |
|
25 |
"mediaType": "text/html", |
|
26 |
"inputFamily": "TEXT", |
|
27 |
"storePropertiesByFamily": { |
|
28 |
"SPREADSHEET": {"FilterName": "HTML (StarCalc)"}, |
|
29 |
"PRESENTATION": {"FilterName": "impress_html_Export"}, |
|
30 |
"TEXT": {"FilterName": "HTML (StarWriter)"} |
|
31 |
} |
|
32 |
}, |
|
33 |
{ |
|
34 |
"name": "OpenDocument Text", |
|
35 |
"extension": "odt", |
|
36 |
"mediaType": "application/vnd.oasis.opendocument.text", |
|
37 |
"inputFamily": "TEXT", |
|
38 |
"storePropertiesByFamily": {"TEXT": {"FilterName": "writer8"}} |
|
39 |
}, |
|
40 |
{ |
|
41 |
"name": "OpenOffice.org 1.0 Text Document", |
|
42 |
"extension": "sxw", |
|
43 |
"mediaType": "application/vnd.sun.xml.writer", |
|
44 |
"inputFamily": "TEXT", |
|
45 |
"storePropertiesByFamily": {"TEXT": {"FilterName": "StarOffice XML (Writer)"}} |
|
46 |
}, |
|
47 |
{ |
|
48 |
"name": "Microsoft Word", |
|
49 |
"extension": "doc", |
|
50 |
"mediaType": "application/msword", |
|
51 |
"inputFamily": "TEXT", |
|
52 |
"storePropertiesByFamily": {"TEXT": {"FilterName": "MS Word 97"}} |
|
53 |
}, |
|
54 |
{ |
|
55 |
"name": "Microsoft Word 2007 XML", |
|
56 |
"extension": "docx", |
|
57 |
"mediaType": "application/vnd.openxmlformats-officedocument.wordprocessingml.document", |
|
58 |
"inputFamily": "TEXT" |
|
59 |
}, |
|
60 |
{ |
|
61 |
"name": "Rich Text Format", |
|
62 |
"extension": "rtf", |
|
63 |
"mediaType": "text/rtf", |
|
64 |
"inputFamily": "TEXT", |
|
65 |
"storePropertiesByFamily": {"TEXT": {"FilterName": "Rich Text Format"}} |
|
66 |
}, |
|
67 |
{ |
|
68 |
"name": "WordPerfect", |
|
69 |
"extension": "wpd", |
|
70 |
"mediaType": "application/wordperfect", |
|
71 |
"inputFamily": "TEXT" |
|
72 |
}, |
|
73 |
{ |
|
74 |
"name": "Plain Text", |
|
75 |
"extension": "txt", |
|
76 |
"mediaType": "text/plain", |
|
77 |
"inputFamily": "TEXT", |
|
78 |
"loadProperties": { |
|
79 |
"FilterName": "Text (encoded)", |
|
80 |
"FilterOptions": "utf8" |
|
81 |
}, |
|
82 |
"storePropertiesByFamily": {"TEXT": { |
|
83 |
"FilterName": "Text (encoded)", |
|
84 |
"FilterOptions": "utf8" |
|
85 |
}} |
|
86 |
}, |
|
87 |
{ |
|
88 |
"name": "MediaWiki wikitext", |
|
89 |
"extension": "wiki", |
|
90 |
"mediaType": "text/x-wiki", |
|
91 |
"storePropertiesByFamily": {"TEXT": {"FilterName": "MediaWiki"}} |
|
92 |
}, |
|
93 |
{ |
|
94 |
"name": "OpenDocument Spreadsheet", |
|
95 |
"extension": "ods", |
|
96 |
"mediaType": "application/vnd.oasis.opendocument.spreadsheet", |
|
97 |
"inputFamily": "SPREADSHEET", |
|
98 |
"storePropertiesByFamily": {"SPREADSHEET": {"FilterName": "calc8"}} |
|
99 |
}, |
|
100 |
{ |
|
101 |
"name": "OpenOffice.org 1.0 Spreadsheet", |
|
102 |
"extension": "sxc", |
|
103 |
"mediaType": "application/vnd.sun.xml.calc", |
|
104 |
"inputFamily": "SPREADSHEET", |
|
105 |
"storePropertiesByFamily": {"SPREADSHEET": {"FilterName": "StarOffice XML (Calc)"}} |
|
106 |
}, |
|
107 |
{ |
|
108 |
"name": "Microsoft Excel", |
|
109 |
"extension": "xls", |
|
110 |
"mediaType": "application/vnd.ms-excel", |
|
111 |
"inputFamily": "SPREADSHEET", |
|
112 |
"storePropertiesByFamily": {"SPREADSHEET": {"FilterName": "MS Excel 97"}} |
|
113 |
}, |
|
114 |
{ |
|
115 |
"name": "Microsoft Excel 2007 XML", |
|
116 |
"extension": "xlsx", |
|
117 |
"mediaType": "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", |
|
118 |
"inputFamily": "SPREADSHEET" |
|
119 |
}, |
|
120 |
{ |
|
121 |
"name": "Comma Separated Values", |
|
122 |
"extension": "csv", |
|
123 |
"mediaType": "text/csv", |
|
124 |
"inputFamily": "SPREADSHEET", |
|
125 |
"loadProperties": { |
|
126 |
"FilterName": "Text - txt - csv (StarCalc)", |
|
127 |
"FilterOptions": "44,34,0" |
|
128 |
}, |
|
129 |
"storePropertiesByFamily": {"SPREADSHEET": { |
|
130 |
"FilterName": "Text - txt - csv (StarCalc)", |
|
131 |
"FilterOptions": "44,34,0" |
|
132 |
}} |
|
133 |
}, |
|
134 |
{ |
|
135 |
"name": "Tab Separated Values", |
|
136 |
"extension": "tsv", |
|
137 |
"mediaType": "text/tab-separated-values", |
|
138 |
"inputFamily": "SPREADSHEET", |
|
139 |
"loadProperties": { |
|
140 |
"FilterName": "Text - txt - csv (StarCalc)", |
|
141 |
"FilterOptions": "9,34,0" |
|
142 |
}, |
|
143 |
"storePropertiesByFamily": {"SPREADSHEET": { |
|
144 |
"FilterName": "Text - txt - csv (StarCalc)", |
|
145 |
"FilterOptions": "9,34,0" |
|
146 |
}} |
|
147 |
}, |
|
148 |
{ |
|
149 |
"name": "OpenDocument Presentation", |
|
150 |
"extension": "odp", |
|
151 |
"mediaType": "application/vnd.oasis.opendocument.presentation", |
|
152 |
"inputFamily": "PRESENTATION", |
|
153 |
"storePropertiesByFamily": {"PRESENTATION": {"FilterName": "impress8"}} |
|
154 |
}, |
|
155 |
{ |
|
156 |
"name": "OpenOffice.org 1.0 Presentation", |
|
157 |
"extension": "sxi", |
|
158 |
"mediaType": "application/vnd.sun.xml.impress", |
|
159 |
"inputFamily": "PRESENTATION", |
|
160 |
"storePropertiesByFamily": {"PRESENTATION": {"FilterName": "StarOffice XML (Impress)"}} |
|
161 |
}, |
|
162 |
{ |
|
163 |
"name": "Microsoft PowerPoint", |
|
164 |
"extension": "ppt", |
|
165 |
"mediaType": "application/vnd.ms-powerpoint", |
|
166 |
"inputFamily": "PRESENTATION", |
|
167 |
"storePropertiesByFamily": {"PRESENTATION": {"FilterName": "MS PowerPoint 97"}} |
|
168 |
}, |
|
169 |
{ |
|
170 |
"name": "Microsoft PowerPoint 2007 XML", |
|
171 |
"extension": "pptx", |
|
172 |
"mediaType": "application/vnd.openxmlformats-officedocument.presentationml.presentation", |
|
173 |
"inputFamily": "PRESENTATION" |
|
174 |
}, |
|
175 |
{ |
|
176 |
"name": "OpenDocument Drawing", |
|
177 |
"extension": "odg", |
|
178 |
"mediaType": "application/vnd.oasis.opendocument.graphics", |
|
179 |
"inputFamily": "DRAWING", |
|
180 |
"storePropertiesByFamily": {"DRAWING": {"FilterName": "draw8"}} |
|
181 |
}, |
|
182 |
{ |
|
183 |
"name": "Scalable Vector Graphics", |
|
184 |
"extension": "svg", |
|
185 |
"mediaType": "image/svg+xml", |
|
186 |
"storePropertiesByFamily": {"DRAWING": {"FilterName": "draw_svg_Export"}} |
|
187 |
} |
|
188 |
] |
Formats disponibles : Unified diff