Révision 2404
tmp/org.txm.lexicaltable.rcp/src/org/txm/lexicaltable/rcp/preferences/LexicalTablePreferencePage.java (revision 2404) | ||
---|---|---|
45 | 45 |
* |
46 | 46 |
*/ |
47 | 47 |
public class LexicalTablePreferencePage extends TXMPreferencePage { |
48 |
|
|
49 |
|
|
48 |
|
|
49 |
|
|
50 | 50 |
@Override |
51 | 51 |
public void createFieldEditors() { |
52 | 52 |
|
53 |
IntegerFieldEditor fmin = new IntegerFieldEditor(TXMPreferences.F_MIN, TXMCoreMessages.common_lowestFrequency, this.getFieldEditorParent());
|
|
53 |
IntegerFieldEditor fmin = new IntegerFieldEditor(TXMPreferences.F_MIN, TXMCoreMessages.common_lowestFrequency, this.getFieldEditorParent()); |
|
54 | 54 |
fmin.setValidRange(1, 999999999); |
55 | 55 |
|
56 |
IntegerFieldEditor vmax = new IntegerFieldEditor(TXMPreferences.V_MAX, TXMCoreMessages.common_numberOfLines, this.getFieldEditorParent());
|
|
56 |
IntegerFieldEditor vmax = new IntegerFieldEditor(TXMPreferences.V_MAX, TXMCoreMessages.common_numberOfLines, this.getFieldEditorParent()); |
|
57 | 57 |
vmax.setValidRange(1, 999999999); |
58 | 58 |
|
59 | 59 |
this.addField(fmin); |
60 | 60 |
this.addField(vmax); |
61 | 61 |
|
62 | 62 |
} |
63 |
|
|
63 |
|
|
64 | 64 |
@Override |
65 | 65 |
public void init(IWorkbench workbench) { |
66 | 66 |
this.setPreferenceStore(new TXMPreferenceStore(LexicalTablePreferences.getInstance().getPreferencesNodeQualifier())); |
67 | 67 |
this.setTitle(LexicalTableCoreMessages.RESULT_TYPE); |
68 | 68 |
this.setImageDescriptor(LexicalTableAdapterFactory.ICON); |
69 | 69 |
} |
70 |
|
|
70 |
|
|
71 | 71 |
} |
tmp/org.txm.lexicaltable.rcp/src/org/txm/lexicaltable/rcp/adapters/InterTextDistanceAdapterFactory.java (revision 2404) | ||
---|---|---|
12 | 12 |
|
13 | 13 |
/** |
14 | 14 |
* A factory for creating Adapter objects. |
15 |
*
|
|
15 |
* |
|
16 | 16 |
* @author mdecorde |
17 | 17 |
* @author sjacquot |
18 | 18 |
*/ |
19 | 19 |
public class InterTextDistanceAdapterFactory extends TXMResultAdapterFactory { |
20 |
|
|
21 | 20 |
|
22 |
public static final ImageDescriptor ICON = |
|
23 |
AbstractUIPlugin.imageDescriptorFromPlugin(FrameworkUtil.getBundle(InterTextDistanceAdapterFactory.class).getSymbolicName(), |
|
24 |
"platform:/plugin/"+ FrameworkUtil.getBundle(InterTextDistanceAdapterFactory.class).getSymbolicName() + "/icons/dist.png"); //$NON-NLS-1$ //$NON-NLS-2$ |
|
25 | 21 |
|
26 |
|
|
22 |
public static final ImageDescriptor ICON = AbstractUIPlugin.imageDescriptorFromPlugin(FrameworkUtil.getBundle(InterTextDistanceAdapterFactory.class).getSymbolicName(), |
|
23 |
"platform:/plugin/" + FrameworkUtil.getBundle(InterTextDistanceAdapterFactory.class).getSymbolicName() + "/icons/dist.png"); //$NON-NLS-1$ //$NON-NLS-2$ |
|
24 |
|
|
25 |
|
|
27 | 26 |
@Override |
28 | 27 |
public Object getAdapter(Object adaptableObject, Class adapterType) { |
29 |
if(this.canAdapt(adapterType) && adaptableObject instanceof InterTextDistance) {
|
|
28 |
if (this.canAdapt(adapterType) && adaptableObject instanceof InterTextDistance) {
|
|
30 | 29 |
return new TXMResultAdapter() { |
30 |
|
|
31 | 31 |
@Override |
32 | 32 |
public ImageDescriptor getImageDescriptor(Object object) { |
33 | 33 |
return ICON; |
tmp/org.txm.lexicaltable.rcp/src/org/txm/lexicaltable/rcp/adapters/LexicalTableAdapterFactory.java (revision 2404) | ||
---|---|---|
11 | 11 |
|
12 | 12 |
/** |
13 | 13 |
* A factory for creating Adapter objects. |
14 |
*
|
|
14 |
* |
|
15 | 15 |
* @author mdecorde |
16 | 16 |
* @author sjacquot |
17 | 17 |
*/ |
18 | 18 |
public class LexicalTableAdapterFactory extends TXMResultAdapterFactory { |
19 |
|
|
20 | 19 |
|
21 |
public static final ImageDescriptor ICON = |
|
22 |
AbstractUIPlugin.imageDescriptorFromPlugin(FrameworkUtil.getBundle(LexicalTableAdapterFactory.class).getSymbolicName(), |
|
23 |
"platform:/plugin/"+ FrameworkUtil.getBundle(LexicalTableAdapterFactory.class).getSymbolicName() + "/icons/lexicaltable.png"); //$NON-NLS-1$ //$NON-NLS-2$ |
|
24 | 20 |
|
25 |
|
|
21 |
public static final ImageDescriptor ICON = AbstractUIPlugin.imageDescriptorFromPlugin(FrameworkUtil.getBundle(LexicalTableAdapterFactory.class).getSymbolicName(), |
|
22 |
"platform:/plugin/" + FrameworkUtil.getBundle(LexicalTableAdapterFactory.class).getSymbolicName() + "/icons/lexicaltable.png"); //$NON-NLS-1$ //$NON-NLS-2$ |
|
23 |
|
|
24 |
|
|
26 | 25 |
@Override |
27 | 26 |
public Object getAdapter(Object adaptableObject, Class adapterType) { |
28 |
if(this.canAdapt(adapterType) && adaptableObject instanceof LexicalTable) {
|
|
27 |
if (this.canAdapt(adapterType) && adaptableObject instanceof LexicalTable) {
|
|
29 | 28 |
return new TXMResultAdapter() { |
29 |
|
|
30 | 30 |
@Override |
31 | 31 |
public ImageDescriptor getImageDescriptor(Object object) { |
32 | 32 |
return ICON; |
... | ... | |
35 | 35 |
} |
36 | 36 |
return null; |
37 | 37 |
} |
38 |
|
|
39 |
|
|
38 |
|
|
39 |
|
|
40 | 40 |
} |
tmp/org.txm.lexicaltable.rcp/src/org/txm/lexicaltable/rcp/messages/LexicalTableUIMessages.java (revision 2404) | ||
---|---|---|
10 | 10 |
* |
11 | 11 |
*/ |
12 | 12 |
public class LexicalTableUIMessages extends NLS { |
13 |
|
|
13 |
|
|
14 | 14 |
private static final String BUNDLE_NAME = "org.txm.lexicaltable.rcp.messages.messages"; //$NON-NLS-1$ |
15 | 15 |
|
16 |
public static String errorColonDifferentColumnsNumberColonBeforeP0AfterP1; |
|
17 |
public static String mergeOrDeleteColumns; |
|
18 |
public static String mergeColsColonP0; |
|
19 |
public static String deleteColsColonP0; |
|
20 |
public static String mergeOrDeleteRows; |
|
21 |
public static String failedToImportLexicalTable; |
|
22 |
public static String errorWhileImportingDataColonP0; |
|
23 |
public static String mergingLines; |
|
24 |
public static String userIndexOccurrences; |
|
25 |
public static String selectWhichMarginsYouWantToUse; |
|
26 |
public static String useAllOccurrences; |
|
27 |
public static String openingMargeConfigurationDialog; |
|
28 |
public static String canNotCreateALexicalTableWithAnIndexCreatedOnACorpus; |
|
29 |
public static String vocabulariesMustShareTheSamePropertiesColonP0; |
|
16 |
public static String errorColonDifferentColumnsNumberColonBeforeP0AfterP1; |
|
17 |
|
|
18 |
public static String mergeOrDeleteColumns; |
|
19 |
|
|
20 |
public static String mergeColsColonP0; |
|
21 |
|
|
22 |
public static String deleteColsColonP0; |
|
23 |
|
|
24 |
public static String mergeOrDeleteRows; |
|
25 |
|
|
26 |
public static String failedToImportLexicalTable; |
|
27 |
|
|
28 |
public static String errorWhileImportingDataColonP0; |
|
29 |
|
|
30 |
public static String mergingLines; |
|
31 |
|
|
32 |
public static String userIndexOccurrences; |
|
33 |
|
|
34 |
public static String selectWhichMarginsYouWantToUse; |
|
35 |
|
|
36 |
public static String useAllOccurrences; |
|
37 |
|
|
38 |
public static String openingMargeConfigurationDialog; |
|
39 |
|
|
40 |
public static String canNotCreateALexicalTableWithAnIndexCreatedOnACorpus; |
|
41 |
|
|
42 |
public static String vocabulariesMustShareTheSamePropertiesColonP0; |
|
43 |
|
|
30 | 44 |
public static String vocabulariesMustShareTheSamePartitionColonP0; |
31 |
|
|
32 |
public static String tP0vP1fminP2fmaxP3; |
|
33 | 45 |
|
34 |
|
|
35 |
|
|
46 |
public static String tP0vP1fminP2fmaxP3; |
|
47 |
|
|
48 |
|
|
49 |
|
|
36 | 50 |
static { |
37 | 51 |
// initialize resource bundle |
38 | 52 |
Utf8NLS.initializeMessages(BUNDLE_NAME, LexicalTableUIMessages.class); |
tmp/org.txm.lexicaltable.rcp/src/org/txm/lexicaltable/rcp/handlers/ComputeLexicalTable.java (revision 2404) | ||
---|---|---|
62 | 62 |
* |
63 | 63 |
*/ |
64 | 64 |
public class ComputeLexicalTable extends BaseAbstractHandler { |
65 |
|
|
66 |
/* (non-Javadoc) |
|
65 |
|
|
66 |
/* |
|
67 |
* (non-Javadoc) |
|
67 | 68 |
* @see org.eclipse.core.commands.AbstractHandler#execute(org.eclipse.core.commands.ExecutionEvent) |
68 | 69 |
*/ |
69 | 70 |
@Override |
70 | 71 |
public Object execute(ExecutionEvent event) throws ExecutionException { |
71 |
|
|
72 |
if(!this.checkStatsEngine()) { |
|
72 |
|
|
73 |
if (!this.checkStatsEngine()) {
|
|
73 | 74 |
return null; |
74 | 75 |
} |
75 |
|
|
76 |
|
|
76 | 77 |
Object selection = this.getCorporaViewSelectedObject(event); |
77 | 78 |
LexicalTable lexicalTable = null; |
78 | 79 |
|
... | ... | |
92 | 93 |
dialog.setLabelProvider(new LabelProvider()); |
93 | 94 |
dialog.setContentProvider(new ArrayContentProvider()); |
94 | 95 |
dialog.setTitle(LexicalTableUIMessages.selectWhichMarginsYouWantToUse); |
95 |
|
|
96 |
|
|
96 | 97 |
int ret = dialog.open(); |
97 | 98 |
boolean useAllOccurrences = false; |
98 | 99 |
if (ret == ListDialog.OK) { |
99 |
if(dialog.getResult().length == 0) { |
|
100 |
if (dialog.getResult().length == 0) {
|
|
100 | 101 |
return null; |
101 | 102 |
} |
102 | 103 |
String sel = (String) dialog.getResult()[0]; |
103 |
if(sel.equals(LexicalTableUIMessages.useAllOccurrences)) { |
|
104 |
if (sel.equals(LexicalTableUIMessages.useAllOccurrences)) {
|
|
104 | 105 |
useAllOccurrences = true; |
105 | 106 |
} |
106 | 107 |
} |
... | ... | |
111 | 112 |
if (partitionIndexes.size() == 0) { |
112 | 113 |
return false; |
113 | 114 |
} |
114 |
|
|
115 |
|
|
115 | 116 |
partitionIndexes = partitionIndexes.subList(0, 1); |
116 | 117 |
for (PartitionIndex partitionIndex : partitionIndexes) { |
117 | 118 |
if (!partitionIndex.isComputedWithPartition()) { |
... | ... | |
139 | 140 |
} |
140 | 141 |
|
141 | 142 |
final WordProperty property = properties.get(0); |
142 |
|
|
143 |
|
|
143 | 144 |
lexicalTable = new LexicalTable(firstIndex); |
144 | 145 |
lexicalTable.setUseAllOccurrences(useAllOccurrences); |
145 | 146 |
lexicalTable.setUnitProperty(property); |
146 | 147 |
// transmit index fmin/fmax parameters |
147 | 148 |
lexicalTable.setFMinFilter(firstIndex.getFilterFmin()); |
148 | 149 |
lexicalTable.setVMaxFilter(firstIndex.getFilterVmax()); |
149 |
|
|
150 | 150 |
|
151 | 151 |
|
152 | 152 |
|
153 | 153 |
|
154 |
|
|
154 | 155 |
// FIXME: SJ: became useless? |
155 |
//return null; |
|
156 |
// } else if (s instanceof QueryIndex) {
|
|
157 |
// List<QueryIndex> qindexes = selection.toList();
|
|
158 |
// computeWithQueryIndexes(qindexes);
|
|
159 |
// return null;
|
|
156 |
// return null;
|
|
157 |
// } else if (s instanceof QueryIndex) {
|
|
158 |
// List<QueryIndex> qindexes = selection.toList();
|
|
159 |
// computeWithQueryIndexes(qindexes);
|
|
160 |
// return null;
|
|
160 | 161 |
} |
161 | 162 |
// Creating from Partition |
162 | 163 |
else if (selection instanceof Partition) { |
... | ... | |
167 | 168 |
lexicalTable = (LexicalTable) selection; |
168 | 169 |
} |
169 | 170 |
// Error |
170 |
else {
|
|
171 |
else {
|
|
171 | 172 |
this.logCanNotExecuteCommand(selection); |
172 | 173 |
} |
173 | 174 |
|
... | ... | |
175 | 176 |
|
176 | 177 |
return true; |
177 | 178 |
} |
178 |
|
|
179 |
// /** |
|
180 |
// * Compute with partition. |
|
181 |
// * |
|
182 |
// * @param partition the partition |
|
183 |
// */ |
|
184 |
// private void computeWithLexicalTableAble(final LexicalTable lexicalTableAble) { |
|
185 |
// |
|
186 |
// JobHandler jobhandler = new JobHandler( |
|
187 |
// RCPMessages.ComputeLexicalTable_0) { |
|
188 |
// @Override |
|
189 |
// protected IStatus run(IProgressMonitor monitor) { |
|
190 |
// this.runInit(monitor); |
|
191 |
// try { |
|
192 |
// JobsTimer.start(); |
|
193 |
// monitor.beginTask(NLS.bind(RCPMessages.ComputeLexicalTable_1, lexicalTableAble.getName(), "none"), 100); |
|
194 |
// |
|
195 |
// this.acquireSemaphore(); |
|
196 |
// //table = lexicalTableAble.toLexicalTable(); |
|
197 |
// table = lexicalTableAble; |
|
198 |
// this.releaseSemaphore(); |
|
199 |
// |
|
200 |
// monitor.worked(45); |
|
201 |
// |
|
202 |
// lexicalTableAble.getParent().addChild(table); |
|
203 |
// |
|
204 |
// monitor.worked(5); |
|
205 |
// |
|
206 |
// //monitor.subTask(Messages.ComputeSpecifities_10); |
|
207 |
// syncExec(new Runnable() { |
|
208 |
// @Override |
|
209 |
// public void run() { |
|
210 |
// IWorkbenchPage page = window.getActivePage(); |
|
211 |
// LexicalTableEditorInput editorInput = new LexicalTableEditorInput(table); |
|
212 |
// try { |
|
213 |
// StatusLine.setMessage(RCPMessages.ComputeLexicalTable_10); |
|
214 |
// page.openEditor(editorInput, LexicalTableEditor.ID); |
|
215 |
// } catch (PartInitException e) { |
|
216 |
// org.txm.utils.logger.Log.printStackTrace(e); |
|
217 |
// } |
|
218 |
// } |
|
219 |
// }); |
|
220 |
// |
|
221 |
// monitor.worked(50); |
|
222 |
// if (monitor.isCanceled()) |
|
223 |
// return Status.CANCEL_STATUS; |
|
224 |
// |
|
225 |
// //monitor.subTask(Messages.ComputeSpecifities_2); |
|
226 |
// syncExec(new Runnable() { |
|
227 |
// @Override |
|
228 |
// public void run() { |
|
229 |
// CorporaView.refresh(); |
|
230 |
// CorporaView.expand(table.getParent()); |
|
231 |
// QueriesView.refresh(); |
|
232 |
// RVariablesView.refresh(); |
|
233 |
// } |
|
234 |
// }); |
|
235 |
// |
|
236 |
// monitor.worked(100); |
|
237 |
// } catch (ThreadDeath td) { |
|
238 |
// return Status.CANCEL_STATUS; |
|
239 |
// } catch (Exception e) { |
|
240 |
// org.txm.utils.logger.Log.printStackTrace(e); |
|
241 |
// } finally { |
|
242 |
// monitor.done(); |
|
243 |
// JobsTimer.stopAndPrint(); |
|
244 |
// } |
|
245 |
// return Status.OK_STATUS; |
|
246 |
// } |
|
247 |
// }; |
|
248 |
// jobhandler.startJob(); |
|
249 |
// |
|
250 |
// return; |
|
251 |
// } |
|
252 |
|
|
253 |
|
|
254 |
|
|
255 |
// /** |
|
256 |
// * Compute with query index. |
|
257 |
// * |
|
258 |
// * @param fullvocabularies the fullvocabularies |
|
259 |
// * @return true, if successful |
|
260 |
// */ |
|
261 |
// private boolean computeWithQueryIndexes(List<QueryIndex> oqindexes) { |
|
262 |
// if (oqindexes.size() == 0) { |
|
263 |
// return false; |
|
264 |
// } |
|
265 |
// |
|
179 |
|
|
180 |
// /** |
|
181 |
// * Compute with partition. |
|
182 |
// * |
|
183 |
// * @param partition the partition |
|
184 |
// */ |
|
185 |
// private void computeWithLexicalTableAble(final LexicalTable lexicalTableAble) { |
|
266 | 186 |
// |
267 |
// final List<QueryIndex> qindexes = oqindexes.subList(0, 1); |
|
268 |
// for (QueryIndex voc : qindexes) |
|
269 |
// if (!voc.isComputedWithPartition()) { |
|
270 |
// System.out.println(Messages.ComputeLexicalTable_5); |
|
271 |
// StatusLine.setMessage(Messages.ComputeLexicalTable_5); |
|
272 |
// return false; |
|
273 |
// } |
|
187 |
// JobHandler jobhandler = new JobHandler( |
|
188 |
// RCPMessages.ComputeLexicalTable_0) { |
|
189 |
// @Override |
|
190 |
// protected IStatus run(IProgressMonitor monitor) { |
|
191 |
// this.runInit(monitor); |
|
192 |
// try { |
|
193 |
// JobsTimer.start(); |
|
194 |
// monitor.beginTask(NLS.bind(RCPMessages.ComputeLexicalTable_1, lexicalTableAble.getName(), "none"), 100); |
|
274 | 195 |
// |
275 |
// Partition firstPartition = qindexes.get(0).getPartition(); |
|
276 |
// for (QueryIndex voc : qindexes) |
|
277 |
// if (!firstPartition.equals(voc.getPartition())) { |
|
278 |
// Log.warning(NLS.bind(Messages.ComputeLexicalTable_7, firstPartition)); |
|
279 |
// return false; |
|
280 |
// } |
|
196 |
// this.acquireSemaphore(); |
|
197 |
// //table = lexicalTableAble.toLexicalTable(); |
|
198 |
// table = lexicalTableAble; |
|
199 |
// this.releaseSemaphore(); |
|
281 | 200 |
// |
282 |
// final Partition partition = ((QueryIndex) selection.getFirstElement()) |
|
283 |
// .getPartition(); |
|
284 |
// //final Property property = properties.get(0); |
|
285 |
// |
|
286 |
// JobHandler jobhandler = new JobHandler(Messages.ComputeSpecificities_0) { |
|
287 |
// @Override |
|
288 |
// protected IStatus run(IProgressMonitor monitor) { |
|
289 |
// this.runInit(monitor); |
|
290 |
// try { |
|
291 |
// monitor.beginTask(NLS.bind(Messages.ComputeLexicalTable_1, partition.getName(), Messages.ComputeLexicalTable_2), 100); |
|
292 |
// this.acquireSemaphore(); |
|
293 |
// copy = LexicalTableImpl.createLexicalTableImpl(qindexes, |
|
294 |
// QuantitativeDataStructureImpl |
|
295 |
// .createSymbole(LexicalTableImpl.class)); |
|
296 |
// monitor.worked(45); |
|
297 |
// this.releaseSemaphore(); |
|
298 |
// if (copy == null) |
|
299 |
// return Status.CANCEL_STATUS; |
|
201 |
// monitor.worked(45); |
|
300 | 202 |
// |
301 |
// partition.storeResult(copy); |
|
302 |
// monitor.worked(5); |
|
203 |
// lexicalTableAble.getParent().addChild(table); |
|
303 | 204 |
// |
304 |
// monitor.subTask(Messages.ComputeLexicalTable_10); |
|
305 |
// syncExec(new Runnable() { |
|
306 |
// @Override |
|
307 |
// public void run() { |
|
308 |
// IWorkbenchPage page = window.getActivePage(); |
|
309 |
// LexicalTableEditorInput editorInput = new LexicalTableEditorInput( |
|
310 |
// copy, partition, null); |
|
311 |
// try { |
|
312 |
// StatusLine.setMessage(Messages.ComputeLexicalTable_10); |
|
313 |
// page.openEditor(editorInput, |
|
314 |
// "org.txm.rcp.editors.lexicaltable.LexicalTableEditor"); //$NON-NLS-1$ |
|
315 |
// } catch (PartInitException e) { |
|
316 |
// org.txm.utils.logger.Log.printStackTrace(e); |
|
317 |
// } |
|
318 |
// } |
|
319 |
// }); |
|
205 |
// monitor.worked(5); |
|
320 | 206 |
// |
321 |
// monitor.worked(50); |
|
322 |
// if (monitor.isCanceled()) |
|
323 |
// return Status.CANCEL_STATUS; |
|
207 |
// //monitor.subTask(Messages.ComputeSpecifities_10); |
|
208 |
// syncExec(new Runnable() { |
|
209 |
// @Override |
|
210 |
// public void run() { |
|
211 |
// IWorkbenchPage page = window.getActivePage(); |
|
212 |
// LexicalTableEditorInput editorInput = new LexicalTableEditorInput(table); |
|
213 |
// try { |
|
214 |
// StatusLine.setMessage(RCPMessages.ComputeLexicalTable_10); |
|
215 |
// page.openEditor(editorInput, LexicalTableEditor.ID); |
|
216 |
// } catch (PartInitException e) { |
|
217 |
// org.txm.utils.logger.Log.printStackTrace(e); |
|
218 |
// } |
|
219 |
// } |
|
220 |
// }); |
|
324 | 221 |
// |
325 |
// monitor.subTask(Messages.ComputeSpecifities_2); |
|
326 |
// syncExec(new Runnable() { |
|
327 |
// @Override |
|
328 |
// public void run() { |
|
329 |
// CorporaView.refresh(); |
|
330 |
// CorporaView.expand(copy.getPartition()); |
|
331 |
// QueriesView.refresh(); |
|
332 |
// RVariablesView.refresh(); |
|
333 |
// } |
|
334 |
// }); |
|
222 |
// monitor.worked(50); |
|
223 |
// if (monitor.isCanceled()) |
|
224 |
// return Status.CANCEL_STATUS; |
|
335 | 225 |
// |
336 |
// monitor.worked(100); |
|
337 |
// } catch (ThreadDeath td) { |
|
338 |
// return Status.CANCEL_STATUS; |
|
339 |
// } catch (Exception e) { |
|
340 |
// org.txm.utils.logger.Log.printStackTrace(e); |
|
341 |
// } finally { |
|
342 |
// monitor.done(); |
|
343 |
// } |
|
344 |
// return Status.OK_STATUS; |
|
345 |
// } |
|
346 |
// }; |
|
347 |
// jobhandler.startJob(); |
|
226 |
// //monitor.subTask(Messages.ComputeSpecifities_2); |
|
227 |
// syncExec(new Runnable() { |
|
228 |
// @Override |
|
229 |
// public void run() { |
|
230 |
// CorporaView.refresh(); |
|
231 |
// CorporaView.expand(table.getParent()); |
|
232 |
// QueriesView.refresh(); |
|
233 |
// RVariablesView.refresh(); |
|
234 |
// } |
|
235 |
// }); |
|
348 | 236 |
// |
349 |
// return true; |
|
350 |
// } |
|
351 |
|
|
352 |
// /** |
|
353 |
// * Compute with vocabularies. |
|
354 |
// * |
|
355 |
// * @param fullvocabularies the fullvocabularies |
|
356 |
// * @return true, if successful |
|
357 |
// */ |
|
358 |
// private boolean computeWithVocabularies(List<Index> fullvocabularies, final boolean useAllOccurrences) { |
|
359 |
// if (fullvocabularies.size() == 0) { |
|
360 |
// return false; |
|
361 |
// } |
|
362 |
// |
|
363 |
// final List<Index> vocabularies = fullvocabularies.subList(0, 1); |
|
364 |
// for (Index voc : vocabularies) { |
|
365 |
// if (!voc.isComputedWithPartition()) { |
|
366 |
// System.out.println(RCPMessages.ComputeLexicalTable_5); |
|
367 |
// StatusLine.setMessage(RCPMessages.ComputeLexicalTable_5); |
|
368 |
// return false; |
|
369 |
// } |
|
370 |
// } |
|
371 |
// |
|
372 |
// List<Property> properties = vocabularies.get(0).getProperties(); |
|
373 |
// for (Index voc : vocabularies) { |
|
374 |
// if (!properties.equals(voc.getProperties())) { |
|
375 |
// Log.warning(NLS.bind(RCPMessages.ComputeLexicalTable_6, properties)); |
|
376 |
// return false; |
|
377 |
// } |
|
378 |
// } |
|
379 |
// |
|
380 |
// final Index firstIndex = vocabularies.get(0); |
|
381 |
// Partition firstPartition = firstIndex.getPartition(); |
|
382 |
// for (Index voc : vocabularies) { |
|
383 |
// if (!firstPartition.equals(voc.getPartition())) { |
|
384 |
// Log.warning(NLS.bind(RCPMessages.ComputeLexicalTable_7, firstPartition)); |
|
385 |
// return false; |
|
386 |
// } |
|
387 |
// } |
|
388 |
// |
|
389 |
// final Property property = properties.get(0); |
|
390 |
// |
|
391 |
// JobHandler jobhandler = new JobHandler(RCPMessages.bind(RCPMessages.ComputeLexicalTable_0, firstIndex.getName())) { |
|
392 |
// @Override |
|
393 |
// protected IStatus run(IProgressMonitor monitor) { |
|
394 |
// this.runInit(monitor); |
|
395 |
// try { |
|
396 |
// monitor.beginTask("Computing Lexical table with Index: "+firstIndex+" property: "+property, 100); |
|
397 |
// this.acquireSemaphore(); |
|
398 |
// table = new LexicalTable(firstIndex); |
|
399 |
// table.setParameters(null, null, null, useAllOccurrences); |
|
400 |
// table.compute(true, monitor); |
|
401 |
// monitor.worked(45); |
|
402 |
// this.releaseSemaphore(); |
|
403 |
// if (monitor.isCanceled() || table == null) |
|
404 |
// return Status.CANCEL_STATUS; |
|
405 |
// |
|
406 |
// firstIndex.addChild(table); |
|
407 |
// monitor.worked(5); |
|
408 |
// |
|
409 |
// monitor.subTask(RCPMessages.ComputeLexicalTable_10); |
|
410 |
// syncExec(new Runnable() { |
|
411 |
// @Override |
|
412 |
// public void run() { |
|
413 |
// IWorkbenchPage page = window.getActivePage(); |
|
414 |
// LexicalTableEditorInput editorInput = new LexicalTableEditorInput(table); |
|
415 |
// try { |
|
416 |
// StatusLine.setMessage(RCPMessages.ComputeLexicalTable_10); |
|
417 |
// page.openEditor(editorInput, |
|
418 |
// "org.txm.rcp.editors.lexicaltable.LexicalTableEditor"); //$NON-NLS-1$ |
|
419 |
// } catch (PartInitException e) { |
|
420 |
// org.txm.utils.logger.Log.printStackTrace(e); |
|
421 |
// } |
|
422 |
// } |
|
423 |
// }); |
|
424 |
// |
|
425 |
// monitor.worked(50); |
|
426 |
// if (monitor.isCanceled()) |
|
427 |
// return Status.CANCEL_STATUS; |
|
428 |
// |
|
429 |
// monitor.subTask(RCPMessages.ComputeSpecifities_2); |
|
430 |
// syncExec(new Runnable() { |
|
431 |
// @Override |
|
432 |
// public void run() { |
|
433 |
// CorporaView.refresh(); |
|
434 |
// CorporaView.expand(table.getParent()); |
|
435 |
// QueriesView.refresh(); |
|
436 |
// RVariablesView.refresh(); |
|
437 |
// } |
|
438 |
// }); |
|
439 |
// |
|
440 |
// monitor.worked(100); |
|
441 |
// } catch (ThreadDeath td) { |
|
442 |
// return Status.CANCEL_STATUS; |
|
443 |
// } catch (Exception e) { |
|
444 |
// org.txm.utils.logger.Log.printStackTrace(e); |
|
445 |
// } finally { |
|
446 |
// monitor.done(); |
|
447 |
// } |
|
448 |
// return Status.OK_STATUS; |
|
449 |
// } |
|
450 |
// }; |
|
451 |
// jobhandler.startJob(); |
|
452 |
// |
|
453 |
// return true; |
|
454 |
// } |
|
237 |
// monitor.worked(100); |
|
238 |
// } catch (ThreadDeath td) { |
|
239 |
// return Status.CANCEL_STATUS; |
|
240 |
// } catch (Exception e) { |
|
241 |
// org.txm.utils.logger.Log.printStackTrace(e); |
|
242 |
// } finally { |
|
243 |
// monitor.done(); |
|
244 |
// JobsTimer.stopAndPrint(); |
|
245 |
// } |
|
246 |
// return Status.OK_STATUS; |
|
247 |
// } |
|
248 |
// }; |
|
249 |
// jobhandler.startJob(); |
|
250 |
// |
|
251 |
// return; |
|
252 |
// } |
|
455 | 253 |
|
456 | 254 |
|
457 | 255 |
|
256 |
// /** |
|
257 |
// * Compute with query index. |
|
258 |
// * |
|
259 |
// * @param fullvocabularies the fullvocabularies |
|
260 |
// * @return true, if successful |
|
261 |
// */ |
|
262 |
// private boolean computeWithQueryIndexes(List<QueryIndex> oqindexes) { |
|
263 |
// if (oqindexes.size() == 0) { |
|
264 |
// return false; |
|
265 |
// } |
|
266 |
// |
|
267 |
// |
|
268 |
// final List<QueryIndex> qindexes = oqindexes.subList(0, 1); |
|
269 |
// for (QueryIndex voc : qindexes) |
|
270 |
// if (!voc.isComputedWithPartition()) { |
|
271 |
// System.out.println(Messages.ComputeLexicalTable_5); |
|
272 |
// StatusLine.setMessage(Messages.ComputeLexicalTable_5); |
|
273 |
// return false; |
|
274 |
// } |
|
275 |
// |
|
276 |
// Partition firstPartition = qindexes.get(0).getPartition(); |
|
277 |
// for (QueryIndex voc : qindexes) |
|
278 |
// if (!firstPartition.equals(voc.getPartition())) { |
|
279 |
// Log.warning(NLS.bind(Messages.ComputeLexicalTable_7, firstPartition)); |
|
280 |
// return false; |
|
281 |
// } |
|
282 |
// |
|
283 |
// final Partition partition = ((QueryIndex) selection.getFirstElement()) |
|
284 |
// .getPartition(); |
|
285 |
// //final Property property = properties.get(0); |
|
286 |
// |
|
287 |
// JobHandler jobhandler = new JobHandler(Messages.ComputeSpecificities_0) { |
|
288 |
// @Override |
|
289 |
// protected IStatus run(IProgressMonitor monitor) { |
|
290 |
// this.runInit(monitor); |
|
291 |
// try { |
|
292 |
// monitor.beginTask(NLS.bind(Messages.ComputeLexicalTable_1, partition.getName(), Messages.ComputeLexicalTable_2), 100); |
|
293 |
// this.acquireSemaphore(); |
|
294 |
// copy = LexicalTableImpl.createLexicalTableImpl(qindexes, |
|
295 |
// QuantitativeDataStructureImpl |
|
296 |
// .createSymbole(LexicalTableImpl.class)); |
|
297 |
// monitor.worked(45); |
|
298 |
// this.releaseSemaphore(); |
|
299 |
// if (copy == null) |
|
300 |
// return Status.CANCEL_STATUS; |
|
301 |
// |
|
302 |
// partition.storeResult(copy); |
|
303 |
// monitor.worked(5); |
|
304 |
// |
|
305 |
// monitor.subTask(Messages.ComputeLexicalTable_10); |
|
306 |
// syncExec(new Runnable() { |
|
307 |
// @Override |
|
308 |
// public void run() { |
|
309 |
// IWorkbenchPage page = window.getActivePage(); |
|
310 |
// LexicalTableEditorInput editorInput = new LexicalTableEditorInput( |
|
311 |
// copy, partition, null); |
|
312 |
// try { |
|
313 |
// StatusLine.setMessage(Messages.ComputeLexicalTable_10); |
|
314 |
// page.openEditor(editorInput, |
|
315 |
// "org.txm.rcp.editors.lexicaltable.LexicalTableEditor"); //$NON-NLS-1$ |
|
316 |
// } catch (PartInitException e) { |
|
317 |
// org.txm.utils.logger.Log.printStackTrace(e); |
|
318 |
// } |
|
319 |
// } |
|
320 |
// }); |
|
321 |
// |
|
322 |
// monitor.worked(50); |
|
323 |
// if (monitor.isCanceled()) |
|
324 |
// return Status.CANCEL_STATUS; |
|
325 |
// |
|
326 |
// monitor.subTask(Messages.ComputeSpecifities_2); |
|
327 |
// syncExec(new Runnable() { |
|
328 |
// @Override |
|
329 |
// public void run() { |
|
330 |
// CorporaView.refresh(); |
|
331 |
// CorporaView.expand(copy.getPartition()); |
|
332 |
// QueriesView.refresh(); |
|
333 |
// RVariablesView.refresh(); |
|
334 |
// } |
|
335 |
// }); |
|
336 |
// |
|
337 |
// monitor.worked(100); |
|
338 |
// } catch (ThreadDeath td) { |
|
339 |
// return Status.CANCEL_STATUS; |
|
340 |
// } catch (Exception e) { |
|
341 |
// org.txm.utils.logger.Log.printStackTrace(e); |
|
342 |
// } finally { |
|
343 |
// monitor.done(); |
|
344 |
// } |
|
345 |
// return Status.OK_STATUS; |
|
346 |
// } |
|
347 |
// }; |
|
348 |
// jobhandler.startJob(); |
|
349 |
// |
|
350 |
// return true; |
|
351 |
// } |
|
458 | 352 |
|
459 |
} |
|
353 |
// /** |
|
354 |
// * Compute with vocabularies. |
|
355 |
// * |
|
356 |
// * @param fullvocabularies the fullvocabularies |
|
357 |
// * @return true, if successful |
|
358 |
// */ |
|
359 |
// private boolean computeWithVocabularies(List<Index> fullvocabularies, final boolean useAllOccurrences) { |
|
360 |
// if (fullvocabularies.size() == 0) { |
|
361 |
// return false; |
|
362 |
// } |
|
363 |
// |
|
364 |
// final List<Index> vocabularies = fullvocabularies.subList(0, 1); |
|
365 |
// for (Index voc : vocabularies) { |
|
366 |
// if (!voc.isComputedWithPartition()) { |
|
367 |
// System.out.println(RCPMessages.ComputeLexicalTable_5); |
|
368 |
// StatusLine.setMessage(RCPMessages.ComputeLexicalTable_5); |
|
369 |
// return false; |
|
370 |
// } |
|
371 |
// } |
|
372 |
// |
|
373 |
// List<Property> properties = vocabularies.get(0).getProperties(); |
|
374 |
// for (Index voc : vocabularies) { |
|
375 |
// if (!properties.equals(voc.getProperties())) { |
|
376 |
// Log.warning(NLS.bind(RCPMessages.ComputeLexicalTable_6, properties)); |
|
377 |
// return false; |
|
378 |
// } |
|
379 |
// } |
|
380 |
// |
|
381 |
// final Index firstIndex = vocabularies.get(0); |
|
382 |
// Partition firstPartition = firstIndex.getPartition(); |
|
383 |
// for (Index voc : vocabularies) { |
|
384 |
// if (!firstPartition.equals(voc.getPartition())) { |
|
385 |
// Log.warning(NLS.bind(RCPMessages.ComputeLexicalTable_7, firstPartition)); |
|
386 |
// return false; |
|
387 |
// } |
|
388 |
// } |
|
389 |
// |
|
390 |
// final Property property = properties.get(0); |
|
391 |
// |
|
392 |
// JobHandler jobhandler = new JobHandler(RCPMessages.bind(RCPMessages.ComputeLexicalTable_0, firstIndex.getName())) { |
|
393 |
// @Override |
|
394 |
// protected IStatus run(IProgressMonitor monitor) { |
|
395 |
// this.runInit(monitor); |
|
396 |
// try { |
|
397 |
// monitor.beginTask("Computing Lexical table with Index: "+firstIndex+" property: "+property, 100); |
|
398 |
// this.acquireSemaphore(); |
|
399 |
// table = new LexicalTable(firstIndex); |
|
400 |
// table.setParameters(null, null, null, useAllOccurrences); |
|
401 |
// table.compute(true, monitor); |
|
402 |
// monitor.worked(45); |
|
403 |
// this.releaseSemaphore(); |
|
404 |
// if (monitor.isCanceled() || table == null) |
|
405 |
// return Status.CANCEL_STATUS; |
|
406 |
// |
|
407 |
// firstIndex.addChild(table); |
|
408 |
// monitor.worked(5); |
|
409 |
// |
|
410 |
// monitor.subTask(RCPMessages.ComputeLexicalTable_10); |
|
411 |
// syncExec(new Runnable() { |
|
412 |
// @Override |
|
413 |
// public void run() { |
|
414 |
// IWorkbenchPage page = window.getActivePage(); |
|
415 |
// LexicalTableEditorInput editorInput = new LexicalTableEditorInput(table); |
|
416 |
// try { |
|
417 |
// StatusLine.setMessage(RCPMessages.ComputeLexicalTable_10); |
|
418 |
// page.openEditor(editorInput, |
|
419 |
// "org.txm.rcp.editors.lexicaltable.LexicalTableEditor"); //$NON-NLS-1$ |
|
420 |
// } catch (PartInitException e) { |
|
421 |
// org.txm.utils.logger.Log.printStackTrace(e); |
|
422 |
// } |
|
423 |
// } |
|
424 |
// }); |
|
425 |
// |
|
426 |
// monitor.worked(50); |
|
427 |
// if (monitor.isCanceled()) |
|
428 |
// return Status.CANCEL_STATUS; |
|
429 |
// |
|
430 |
// monitor.subTask(RCPMessages.ComputeSpecifities_2); |
|
431 |
// syncExec(new Runnable() { |
|
432 |
// @Override |
|
433 |
// public void run() { |
|
434 |
// CorporaView.refresh(); |
|
435 |
// CorporaView.expand(table.getParent()); |
|
436 |
// QueriesView.refresh(); |
|
437 |
// RVariablesView.refresh(); |
|
438 |
// } |
|
439 |
// }); |
|
440 |
// |
|
441 |
// monitor.worked(100); |
|
442 |
// } catch (ThreadDeath td) { |
|
443 |
// return Status.CANCEL_STATUS; |
|
444 |
// } catch (Exception e) { |
|
445 |
// org.txm.utils.logger.Log.printStackTrace(e); |
|
446 |
// } finally { |
|
447 |
// monitor.done(); |
|
448 |
// } |
|
449 |
// return Status.OK_STATUS; |
|
450 |
// } |
|
451 |
// }; |
|
452 |
// jobhandler.startJob(); |
|
453 |
// |
|
454 |
// return true; |
|
455 |
// } |
|
456 |
|
|
457 |
|
|
458 |
|
|
459 |
|
|
460 |
} |
tmp/org.txm.lexicaltable.rcp/src/org/txm/lexicaltable/rcp/handlers/MergeLines.java (revision 2404) | ||
---|---|---|
43 | 43 |
import org.txm.lexicaltable.rcp.messages.LexicalTableUIMessages; |
44 | 44 |
import org.txm.rcp.StatusLine; |
45 | 45 |
import org.txm.rcp.messages.TXMUIMessages; |
46 |
|
|
46 | 47 |
/** |
47 | 48 |
* Allows the user to merge Lexical Table lines columns values are added to the first and the others lines are deleted. |
48 | 49 |
* |
49 | 50 |
* @author mdecorde |
50 | 51 |
*/ |
51 | 52 |
public class MergeLines extends AbstractHandler { |
52 |
|
|
53 |
|
|
53 |
|
|
54 |
|
|
54 | 55 |
@Override |
55 | 56 |
public Object execute(ExecutionEvent event) throws ExecutionException { |
56 | 57 |
Shell shell = HandlerUtil.getActiveWorkbenchWindowChecked(event) |
57 | 58 |
.getShell(); |
58 |
|
|
59 |
|
|
59 | 60 |
IWorkbenchPart editor = HandlerUtil.getActiveWorkbenchWindow(event) |
60 | 61 |
.getActivePage().getActivePart(); |
61 | 62 |
if (editor instanceof LexicalTableEditor) { |
... | ... | |
64 | 65 |
.getSelectionIndices(); |
65 | 66 |
if (selection.length == 0) |
66 | 67 |
return null; |
67 |
|
|
68 |
|
|
68 | 69 |
String newname = ""; //$NON-NLS-1$ |
69 | 70 |
InputDialog d = new InputDialog(shell, TXMUIMessages.newName, |
70 |
TXMUIMessages.editTheNameOfTheNewLineCreatedByTheMergedLines, "", null); //$NON-NLS-1$
|
|
71 |
TXMUIMessages.editTheNameOfTheNewLineCreatedByTheMergedLines, "", null); //$NON-NLS-1$ |
|
71 | 72 |
if (d.open() == Window.OK) |
72 | 73 |
newname = d.getValue(); |
73 | 74 |
else |
74 | 75 |
return null; |
75 | 76 |
if (newname.trim().equals("")) //$NON-NLS-1$ |
76 | 77 |
return null; |
77 |
|
|
78 |
|
|
78 | 79 |
mergeLines(LTeditor, newname, selection); |
79 |
|
|
80 |
|
|
80 | 81 |
} |
81 | 82 |
return null; |
82 | 83 |
} |
83 |
|
|
84 |
|
|
84 | 85 |
/** |
85 | 86 |
* Merges lines of the table. |
86 | 87 |
* |
... | ... | |
100 | 101 |
for (int i : selection) |
101 | 102 |
for (int j = 0; j < cols.size(); j++) |
102 | 103 |
fuz[j] += cols.get(j)[i]; |
103 |
|
|
104 |
|
|
104 | 105 |
// set values in the first row of the selection |
105 | 106 |
for (int j = 0; j < cols.size(); j++) |
106 | 107 |
table.getData().set(selection[0], j, fuz[j]); |
107 |
|
|
108 |
|
|
108 | 109 |
// keep only the first selected line |
109 | 110 |
int[] lineToDelete = new int[selection.length - 1]; |
110 | 111 |
System.arraycopy(selection, 1, lineToDelete, 0, selection.length - 1); |
111 |
//System.out.println("Lines to delete : "+Arrays.toString(lineToDelete)); |
|
112 |
// System.out.println("Lines to delete : "+Arrays.toString(lineToDelete));
|
|
112 | 113 |
table.getData().removeRows(lineToDelete); |
113 | 114 |
table.setAltered(); |
114 | 115 |
// reset line name |
... | ... | |
116 | 117 |
table.getRowNames().setString(selection[0], newname); |
117 | 118 |
LTeditor.compute(false); |
118 | 119 |
|
119 |
} catch (Exception e) { |
|
120 |
} |
|
121 |
catch (Exception e) { |
|
120 | 122 |
// TODO Auto-generated catch block |
121 | 123 |
e.printStackTrace(); |
122 | 124 |
} |
123 | 125 |
StatusLine.setMessage(""); //$NON-NLS-1$ |
124 | 126 |
} |
125 |
} |
|
127 |
} |
tmp/org.txm.lexicaltable.rcp/src/org/txm/lexicaltable/rcp/handlers/ExportLexicalTable.java (revision 2404) | ||
---|---|---|
46 | 46 |
* The Class ExportTable. |
47 | 47 |
*/ |
48 | 48 |
public class ExportLexicalTable extends AbstractHandler { |
49 |
|
|
49 |
|
|
50 | 50 |
private static final String ID = "org.txm.rcp.commands.editor.ExportLexicalTable"; //$NON-NLS-1$ |
51 |
/* (non-Javadoc) |
|
51 |
/* |
|
52 |
* (non-Javadoc) |
|
52 | 53 |
* @see org.eclipse.core.commands.AbstractHandler#execute(org.eclipse.core.commands.ExecutionEvent) |
53 | 54 |
*/ |
55 |
|
|
54 | 56 |
@Override |
55 | 57 |
public Object execute(ExecutionEvent event) throws ExecutionException { |
56 | 58 |
IWorkbenchPart editor = HandlerUtil.getActiveWorkbenchWindow(event) |
... | ... | |
75 | 77 |
} |
76 | 78 |
} |
77 | 79 |
return event; |
78 |
|
|
80 |
|
|
79 | 81 |
} |
80 |
|
|
82 |
|
|
81 | 83 |
} |
tmp/org.txm.lexicaltable.rcp/src/org/txm/lexicaltable/rcp/handlers/DeleteLines.java (revision 2404) | ||
---|---|---|
46 | 46 |
* @author sjacquot |
47 | 47 |
*/ |
48 | 48 |
public class DeleteLines extends AbstractHandler { |
49 |
|
|
50 |
/* (non-Javadoc) |
|
49 |
|
|
50 |
/* |
|
51 |
* (non-Javadoc) |
|
51 | 52 |
* @see org.eclipse.core.commands.AbstractHandler#execute(org.eclipse.core.commands.ExecutionEvent) |
52 | 53 |
*/ |
53 | 54 |
@Override |
... | ... | |
56 | 57 |
.getShell(); |
57 | 58 |
// ISelection selection = |
58 | 59 |
// HandlerUtil.getActiveWorkbenchWindow(event).getActivePage().getSelection(); |
59 |
|
|
60 |
|
|
60 | 61 |
IWorkbenchPart editor = HandlerUtil.getActiveWorkbenchWindow(event) |
61 | 62 |
.getActivePage().getActivePart(); |
62 | 63 |
if (editor instanceof LexicalTableEditor) { |
63 | 64 |
LexicalTableEditor LTeditor = (LexicalTableEditor) editor; |
64 | 65 |
try { |
65 | 66 |
deleteLexicalTableLines(LTeditor); |
66 |
} catch (Exception e) { |
|
67 |
} |
|
68 |
catch (Exception e) { |
|
67 | 69 |
// TODO Auto-generated catch block |
68 | 70 |
e.printStackTrace(); |
69 | 71 |
} |
70 | 72 |
} |
71 | 73 |
return null; |
72 | 74 |
} |
73 |
|
|
75 |
|
|
74 | 76 |
/** |
75 | 77 |
* |
76 | 78 |
* @param editor |
... | ... | |
80 | 82 |
int[] selection = editor.getlineTableViewer().getTable().getSelectionIndices(); |
81 | 83 |
if (selection.length == 0) |
82 | 84 |
return; |
83 |
|
|
85 |
|
|
84 | 86 |
if (selection.length == editor.getLexicalTable().getNRows()) { |
85 | 87 |
System.out.println(TXMUIMessages.theTableMustContainAtLeastOneLine); |
86 | 88 |
return; |
87 | 89 |
} |
88 |
|
|
90 |
|
|
89 | 91 |
Display d = Display.getCurrent(); |
90 | 92 |
if (d != null) { |
91 | 93 |
Shell shell = d.getActiveShell(); |
... | ... | |
94 | 96 |
if (messageBox.open() != SWT.YES) |
95 | 97 |
return; |
96 | 98 |
} |
97 |
|
|
99 |
|
|
98 | 100 |
editor.getLexicalTable().getData().removeRows(selection); |
99 | 101 |
editor.getLexicalTable().setAltered(); |
100 | 102 |
editor.compute(false); |
101 | 103 |
} |
102 |
|
|
103 |
} |
|
104 |
|
|
105 |
} |
tmp/org.txm.lexicaltable.rcp/src/org/txm/lexicaltable/rcp/handlers/___MergeCols.java (revision 2404) | ||
---|---|---|
43 | 43 |
import org.txm.lexicaltable.rcp.editors.LexicalTableEditor; |
44 | 44 |
import org.txm.rcp.messages.TXMUIMessages; |
45 | 45 |
import org.txm.statsengine.core.StatException; |
46 |
|
|
46 | 47 |
/** |
47 | 48 |
* The Class MergeCols. |
48 | 49 |
*/ |
49 | 50 |
// FIXME: this class is not used? |
50 | 51 |
public class ___MergeCols extends AbstractHandler { |
51 |
|
|
52 |
/* (non-Javadoc) |
|
52 |
|
|
53 |
/* |
|
54 |
* (non-Javadoc) |
|
53 | 55 |
* @see org.eclipse.core.commands.AbstractHandler#execute(org.eclipse.core.commands.ExecutionEvent) |
54 | 56 |
*/ |
55 | 57 |
@Override |
56 | 58 |
public Object execute(ExecutionEvent event) throws ExecutionException { |
57 | 59 |
Shell shell = HandlerUtil.getActiveWorkbenchWindowChecked(event).getShell(); |
58 |
|
|
60 |
|
|
59 | 61 |
IWorkbenchPart editor = HandlerUtil.getActiveWorkbenchWindow(event) |
60 | 62 |
.getActivePage().getActivePart(); |
61 | 63 |
if (editor instanceof LexicalTableEditor) { |
... | ... | |
64 | 66 |
.getSelectionIndices(); |
65 | 67 |
if (selection.length == 0) |
66 | 68 |
return null; |
67 |
|
|
69 |
|
|
68 | 70 |
String newname = ""; //$NON-NLS-1$ |
69 |
InputDialog d = new InputDialog(shell, TXMUIMessages.newName, TXMUIMessages.editTheNameOfTheNewColumnCreatedByTheMergedColumns, "", null); //$NON-NLS-1$
|
|
71 |
InputDialog d = new InputDialog(shell, TXMUIMessages.newName, TXMUIMessages.editTheNameOfTheNewColumnCreatedByTheMergedColumns, "", null); //$NON-NLS-1$ |
|
70 | 72 |
if (d.open() == Window.OK) |
71 | 73 |
newname = d.getValue(); |
72 | 74 |
else |
73 | 75 |
return null; |
74 | 76 |
if (newname.trim().equals("")) //$NON-NLS-1$ |
75 | 77 |
return null; |
76 |
|
|
78 |
|
|
77 | 79 |
// sum the cols |
78 | 80 |
int[] selectedCols = new int[3]; |
79 | 81 |
List<double[]> cols = LTeditor.getCols(); |
... | ... | |
83 | 85 |
int nrows; |
84 | 86 |
try { |
85 | 87 |
nrows = table.getNRows(); |
86 |
} catch (Exception e) { |
|
88 |
} |
|
89 |
catch (Exception e) { |
|
87 | 90 |
// TODO Auto-generated catch block |
88 | 91 |
e.printStackTrace(); |
89 | 92 |
return null; |
... | ... | |
93 | 96 |
firstcol[j] += cols.get(selectedCols[i])[j]; |
94 | 97 |
} |
95 | 98 |
} |
96 |
|
|
99 |
|
|
97 | 100 |
// update table |
98 | 101 |
for (int j = 0; j < nrows; j++) { |
99 | 102 |
table.getData().set(j, selectedCols[0], firstcol[j]); |
100 | 103 |
} |
101 |
|
|
104 |
|
|
102 | 105 |
// keep only the first col |
103 | 106 |
int[] coltodelete = new int[selectedCols.length - 1]; |
104 | 107 |
System.arraycopy(selectedCols, 1, coltodelete, 0, |
... | ... | |
108 | 111 |
// reset col name |
109 | 112 |
table.getColNames().setString(selectedCols[0], newname); |
110 | 113 |
try { |
111 |
System.out.println(NLS.bind(TXMUIMessages.namesColon |
|
112 |
, Arrays.toString(table.getRowNames().asStringsArray())));
|
|
113 |
} catch (Exception e1) {
|
|
114 |
System.out.println(NLS.bind(TXMUIMessages.namesColon, Arrays.toString(table.getRowNames().asStringsArray())));
|
|
115 |
}
|
|
116 |
catch (Exception e1) { |
|
114 | 117 |
// TODO Auto-generated catch block |
115 | 118 |
org.txm.utils.logger.Log.printStackTrace(e1); |
116 | 119 |
} |
... | ... | |
120 | 123 |
} |
121 | 124 |
return null; |
122 | 125 |
} |
123 |
} |
|
126 |
} |
tmp/org.txm.lexicaltable.rcp/src/org/txm/lexicaltable/rcp/handlers/ComputeInterTextDistance.java (revision 2404) | ||
---|---|---|
12 | 12 |
import org.txm.utils.logger.Log; |
13 | 13 |
|
14 | 14 |
public class ComputeInterTextDistance extends AbstractHandler { |
15 |
|
|
15 |
|
|
16 | 16 |
private IStructuredSelection selection; |
17 |
|
|
17 |
|
|
18 | 18 |
@Override |
19 | 19 |
public void addHandlerListener(IHandlerListener handlerListener) { |
20 | 20 |
super.addHandlerListener(handlerListener); |
21 | 21 |
} |
22 |
|
|
22 |
|
|
23 | 23 |
@Override |
24 | 24 |
public void dispose() { |
25 | 25 |
super.dispose(); |
26 | 26 |
} |
27 |
|
|
28 |
|
|
27 |
|
|
28 |
|
|
29 | 29 |
@Override |
30 | 30 |
public Object execute(ExecutionEvent event) throws ExecutionException { |
31 | 31 |
selection = (IStructuredSelection) HandlerUtil.getCurrentSelection(event); |
32 |
|
|
32 |
|
|
33 | 33 |
Object s = selection.getFirstElement(); |
34 | 34 |
if (!(s instanceof LexicalTable)) |
35 | 35 |
return null; |
36 | 36 |
LexicalTable table = (LexicalTable) s; |
37 | 37 |
InterTextDistance dist = new InterTextDistance(table.getData()); |
38 |
|
|
38 |
|
|
39 | 39 |
try { |
40 | 40 |
dist._compute(); |
41 |
} catch (Exception e) { |
|
41 |
} |
|
42 |
catch (Exception e) { |
|
42 | 43 |
System.out.println(TXMCoreMessages.bind(TXMCoreMessages.error_error, e.getLocalizedMessage())); |
43 | 44 |
Log.printStackTrace(e); |
44 | 45 |
} |
45 | 46 |
return null; |
46 | 47 |
} |
47 |
|
|
48 |
|
|
48 | 49 |
@Override |
49 | 50 |
public boolean isEnabled() { |
50 | 51 |
return super.isEnabled(); |
51 | 52 |
} |
52 |
|
|
53 |
|
|
53 | 54 |
@Override |
54 | 55 |
public boolean isHandled() { |
55 | 56 |
return super.isHandled(); |
56 | 57 |
} |
57 |
|
|
58 |
|
|
58 | 59 |
@Override |
59 | 60 |
public void removeHandlerListener(IHandlerListener handlerListener) { |
60 | 61 |
super.removeHandlerListener(handlerListener); |
tmp/org.txm.lexicaltable.rcp/src/org/txm/lexicaltable/rcp/handlers/ImportTable.java (revision 2404) | ||
---|---|---|
53 | 53 |
* The Class ImportTable. |
54 | 54 |
*/ |
55 | 55 |
public class ImportTable extends BaseAbstractHandler { |
56 |
|
|
56 |
|
|
57 | 57 |
private static final String ID = "org.txm.rcp.commands.editor.ImportTable"; //$NON-NLS-1$ |
58 |
/* (non-Javadoc) |
|
58 |
/* |
|
59 |
* (non-Javadoc) |
|
59 | 60 |
* @see org.eclipse.core.commands.AbstractHandler#execute(org.eclipse.core.commands.ExecutionEvent) |
60 | 61 |
*/ |
62 |
|
|
61 | 63 |
@Override |
62 | 64 |
public Object execute(ExecutionEvent event) throws ExecutionException { |
63 | 65 |
IWorkbenchPart editor = HandlerUtil.getActiveWorkbenchWindow(event) |
... | ... | |
86 | 88 |
LTeditor.importData(file); |
87 | 89 |
} |
88 | 90 |
} |
89 |
} else if (sel instanceof LexicalTable) { |
|
90 |
LexicalTable lt = (LexicalTable)sel; |
|
91 |
} |
|
92 |
else if (sel instanceof LexicalTable) { |
|
93 |
LexicalTable lt = (LexicalTable) sel; |
|
91 | 94 |
Shell shell = HandlerUtil.getActiveWorkbenchWindowChecked(event) |
92 | 95 |
.getShell(); |
93 | 96 |
FileDialog d = new FileDialog(shell, SWT.OPEN); |
... | ... | |
104 | 107 |
lt.compute(); |
105 | 108 |
lt.getData().importData(file, encoding, colseparator, txtseparator); |
106 | 109 |
lt.setAltered(); |
107 |
System.out.println(NLS.bind("Data imported: {0} columns and {1} rows.",lt.getNColumns(), lt.getNRows())); |
|
108 |
} catch (Exception e) { |
|
109 |
System.out.println("Error: data import failed: "+e); |
|
110 |
System.out.println(NLS.bind("Data imported: {0} columns and {1} rows.", lt.getNColumns(), lt.getNRows())); |
|
111 |
} |
|
112 |
catch (Exception e) { |
|
113 |
System.out.println("Error: data import failed: " + e); |
|
110 | 114 |
Log.printStackTrace(e); |
111 | 115 |
} |
112 | 116 |
} |
tmp/org.txm.lexicaltable.rcp/.classpath (revision 2404) | ||
---|---|---|
1 | 1 |
<?xml version="1.0" encoding="UTF-8"?> |
2 | 2 |
<classpath> |
3 |
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> |
|
4 |
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"> |
|
5 |
<accessrules> |
|
6 |
<accessrule kind="accessible" pattern="**"/> |
|
7 |
</accessrules> |
|
8 |
</classpathentry> |
|
9 |
<classpathentry kind="src" path="src"/> |
|
10 |
<classpathentry kind="output" path="bin"/> |
|
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" /> |
|
11 | 13 |
</classpath> |
Formats disponibles : Unified diff