Revision 533

tmp/org.txm.rcp/src/main/java/org/txm/rcp/AdapterFactory.java (revision 533)
39 39
import org.eclipse.ui.model.IWorkbenchAdapter;
40 40
import org.eclipse.ui.plugin.AbstractUIPlugin;
41 41
import org.txm.core.results.TXMResult;
42
import org.txm.objects.SavedQuery;
43
import org.txm.objects.Text;
42 44
//import org.txm.functions.queryindex.QueryIndex;
43 45
import org.txm.rcp.adapters.TXMResultAdapter;
44 46
import org.txm.searchengine.cqp.clientExceptions.CqiClientException;
......
55 57
 * @author jmague
56 58
 */
57 59
public class AdapterFactory implements IAdapterFactory {
58
	
60

  
59 61
	private static boolean firstCorpusDiag = true;
60
	
62

  
61 63
	private HashMap<Class, IWorkbenchAdapter> externalAdapters = new HashMap<Class, IWorkbenchAdapter>();
62
	
64

  
63 65
	/** The corpus manager adapter. */
64 66
	private IWorkbenchAdapter corpusManagerAdapter = new IWorkbenchAdapter() {
65 67

  
......
74 76
						return o1.getName().compareTo(o2.getName());
75 77
					}
76 78
				});
77
				
79

  
78 80
				// check if each corpus has a Base
79 81
				if (firstCorpusDiag) {	
80 82
					firstCorpusDiag = false;
......
117 119
			//List<Subcorpus> subcorpora = ((Corpus) corpus).getSubcorpora();
118 120
			ArrayList<TXMResult> results = ((Corpus) corpus).getResults(true);
119 121
			for (int i = 0; i < results.size(); i++) {
120
				Object result = results.get(i);
121
				
122
//				// remove "id" Lexicon from displayed results
123
//				if (result instanceof Lexicon) {
124
//					Lexicon lex = (Lexicon) result;
125
//					if (lex.getProperty().getName().equals("id")) { //$NON-NLS-1$
126
//						results.remove(result);
127
//						i--;
128
//					}
129
//				}
122
				Object element = results.get(i);
123

  
124
				if (element instanceof Text || element instanceof SavedQuery) {
125
					results.remove(i);
126
					i--;
127
				}
130 128
			}
131 129
			List<Object> children = new ArrayList<Object>();
132 130
			//children.addAll(subcorpora);
......
184 182
			return ((Partition) partition).getCorpus();
185 183
		}
186 184
	};
187
		
188
//	/** The partition adapter. */
189
//	private IWorkbenchAdapter queryIndexAdapter = new IWorkbenchAdapter() {
190
//		@Override
191
//		public Object[] getChildren(Object obj) {
192
//			return new Object[0];
193
//		}
194
//
195
//		@Override
196
//		public ImageDescriptor getImageDescriptor(Object object) {
197
//			return AbstractUIPlugin.imageDescriptorFromPlugin(
198
//					Application.PLUGIN_ID, IImageKeys.QUERYINDEX);
199
//		}
200
//
201
//		@Override
202
//		public String getLabel(Object qindex) {
203
//			return "" + ((QueryIndex) qindex).getName(); //$NON-NLS-1$
204
//		}
205
//
206
//		@Override
207
//		public Object getParent(Object qindex) {
208
//			return ((QueryIndex) qindex).getParent();
209
//		}
210
//	};
211 185

  
212
//	/** The lexical table adapter. */
213
//	private IWorkbenchAdapter lexicalTableAdapter = new IWorkbenchAdapter() {
214
//		@Override
215
//		public Object[] getChildren(Object lexicaltable) {
216
//			// List<Object> children = ((LexicalTable)
217
//			// lexicaltable).getResults();
218
//			// System.out.println("PARTITION RESULTS "+children);
219
//			return ((LexicalTable)lexicaltable).getResults().toArray();
220
//		}
221
//
222
//		@Override
223
//		public ImageDescriptor getImageDescriptor(Object object) {
224
//			return AbstractUIPlugin.imageDescriptorFromPlugin(
225
//					Application.PLUGIN_ID, IImageKeys.LEXICALTABLE);
226
//		}
227
//
228
//		@Override
229
//		public String getLabel(Object lexicaltable) {
230
//			return "" + ((LexicalTable) lexicaltable).getProperty(); //$NON-NLS-1$
231
//		}
232
//
233
//		@Override
234
//		public Object getParent(Object lexicaltable) {
235
//			return ((LexicalTable) lexicaltable).getPartition();
236
//		}
237
//	};
186
	//	/** The partition adapter. */
187
	//	private IWorkbenchAdapter queryIndexAdapter = new IWorkbenchAdapter() {
188
	//		@Override
189
	//		public Object[] getChildren(Object obj) {
190
	//			return new Object[0];
191
	//		}
192
	//
193
	//		@Override
194
	//		public ImageDescriptor getImageDescriptor(Object object) {
195
	//			return AbstractUIPlugin.imageDescriptorFromPlugin(
196
	//					Application.PLUGIN_ID, IImageKeys.QUERYINDEX);
197
	//		}
198
	//
199
	//		@Override
200
	//		public String getLabel(Object qindex) {
201
	//			return "" + ((QueryIndex) qindex).getName(); //$NON-NLS-1$
202
	//		}
203
	//
204
	//		@Override
205
	//		public Object getParent(Object qindex) {
206
	//			return ((QueryIndex) qindex).getParent();
207
	//		}
208
	//	};
238 209

  
239
//	/** The Progression adapter. */
240
//	private IWorkbenchAdapter ProgressionAdapter = new IWorkbenchAdapter() {
241
//		@Override
242
//		public Object[] getChildren(Object progression) {
243
//			return new Object[0];
244
//		}
245
//
246
//		@Override
247
//		public ImageDescriptor getImageDescriptor(Object object) {
248
//			return AbstractUIPlugin.imageDescriptorFromPlugin(
249
//					Application.PLUGIN_ID, IImageKeys.ACTION_PROGRESSION);
250
//		}
251
//
252
//		@Override
253
//		public String getLabel(Object progression) {
254
//			return ((Progression) progression).getDetails(); 
255
//		}
256
//
257
//		@Override
258
//		public Object getParent(Object progression) {
259
//			return ((Progression) progression).getCorpus();
260
//		}
261
//	};
262
	
263
//	/** The CAH adapter. */
264
//	private IWorkbenchAdapter CAHAdapter = new IWorkbenchAdapter() {
265
//		@Override
266
//		public Object[] getChildren(Object cah) {
267
//			return new Object[0];
268
//		}
269
//
270
//		@Override
271
//		public ImageDescriptor getImageDescriptor(Object object) {
272
//			return AbstractUIPlugin.imageDescriptorFromPlugin(
273
//					Application.PLUGIN_ID, IImageKeys.ACTION_CAH);
274
//		}
275
//
276
//		@Override
277
//		public String getLabel(Object cah) {
278
//			return "" + ((CAH) cah).getName(); //$NON-NLS-1$
279
//		}
280
//
281
//		@Override
282
//		public Object getParent(Object cah) {
283
//			return ((CAH) cah).getParent();
284
//		}
285
//	};
286
//
287
//	/** The Cooccurrence adapter. */
288
//	private IWorkbenchAdapter CooccurrenceAdapter = new IWorkbenchAdapter() {
289
//
290
//		@Override
291
//		public Object[] getChildren(Object cooccurrence) {
292
//			return new Object[0];
293
//		}
294
//
295
//		@Override
296
//		public ImageDescriptor getImageDescriptor(Object object) {
297
//			return AbstractUIPlugin.imageDescriptorFromPlugin(
298
//					Application.PLUGIN_ID, IImageKeys.ACTION_COOCCURRENCE);
299
//		}
300
//
301
//		@Override
302
//		public String getLabel(Object cooccurrence) {
303
//			return ((Cooccurrence) cooccurrence).getName(); 
304
//		}
305
//
306
//		@Override
307
//		public Object getParent(Object cooccurrence) {
308
//			return ((Cooccurrence) cooccurrence).getCorpus();
309
//		}
310
//	};
210
	//	/** The lexical table adapter. */
211
	//	private IWorkbenchAdapter lexicalTableAdapter = new IWorkbenchAdapter() {
212
	//		@Override
213
	//		public Object[] getChildren(Object lexicaltable) {
214
	//			// List<Object> children = ((LexicalTable)
215
	//			// lexicaltable).getResults();
216
	//			// System.out.println("PARTITION RESULTS "+children);
217
	//			return ((LexicalTable)lexicaltable).getResults().toArray();
218
	//		}
219
	//
220
	//		@Override
221
	//		public ImageDescriptor getImageDescriptor(Object object) {
222
	//			return AbstractUIPlugin.imageDescriptorFromPlugin(
223
	//					Application.PLUGIN_ID, IImageKeys.LEXICALTABLE);
224
	//		}
225
	//
226
	//		@Override
227
	//		public String getLabel(Object lexicaltable) {
228
	//			return "" + ((LexicalTable) lexicaltable).getProperty(); //$NON-NLS-1$
229
	//		}
230
	//
231
	//		@Override
232
	//		public Object getParent(Object lexicaltable) {
233
	//			return ((LexicalTable) lexicaltable).getPartition();
234
	//		}
235
	//	};
311 236

  
312
//	/** The specificities result adapter. */
313
//	private IWorkbenchAdapter specificitiesResultAdapter = new IWorkbenchAdapter() {
314
//
315
//		@Override
316
//		public Object[] getChildren(Object o) {
317
//			return new Object[0];
318
//		}
319
//
320
//		@Override
321
//		public ImageDescriptor getImageDescriptor(Object object) {
322
//			return AbstractUIPlugin.imageDescriptorFromPlugin(
323
//					Application.PLUGIN_ID, IImageKeys.ACTION_SPECIFICITIES);
324
//		}
325
//
326
//		@Override
327
//		public String getLabel(Object o) {
328
//			return ((SpecificitesResult) o).getName();
329
//		}
330
//
331
//		@Override
332
//		public Object getParent(Object o) {
333
//			return ((SpecificitesResult) o).getParent();
334
//		}
335
//
336
//	};
237
	//	/** The Progression adapter. */
238
	//	private IWorkbenchAdapter ProgressionAdapter = new IWorkbenchAdapter() {
239
	//		@Override
240
	//		public Object[] getChildren(Object progression) {
241
	//			return new Object[0];
242
	//		}
243
	//
244
	//		@Override
245
	//		public ImageDescriptor getImageDescriptor(Object object) {
246
	//			return AbstractUIPlugin.imageDescriptorFromPlugin(
247
	//					Application.PLUGIN_ID, IImageKeys.ACTION_PROGRESSION);
248
	//		}
249
	//
250
	//		@Override
251
	//		public String getLabel(Object progression) {
252
	//			return ((Progression) progression).getDetails(); 
253
	//		}
254
	//
255
	//		@Override
256
	//		public Object getParent(Object progression) {
257
	//			return ((Progression) progression).getCorpus();
258
	//		}
259
	//	};
337 260

  
261
	//	/** The CAH adapter. */
262
	//	private IWorkbenchAdapter CAHAdapter = new IWorkbenchAdapter() {
263
	//		@Override
264
	//		public Object[] getChildren(Object cah) {
265
	//			return new Object[0];
266
	//		}
267
	//
268
	//		@Override
269
	//		public ImageDescriptor getImageDescriptor(Object object) {
270
	//			return AbstractUIPlugin.imageDescriptorFromPlugin(
271
	//					Application.PLUGIN_ID, IImageKeys.ACTION_CAH);
272
	//		}
273
	//
274
	//		@Override
275
	//		public String getLabel(Object cah) {
276
	//			return "" + ((CAH) cah).getName(); //$NON-NLS-1$
277
	//		}
278
	//
279
	//		@Override
280
	//		public Object getParent(Object cah) {
281
	//			return ((CAH) cah).getParent();
282
	//		}
283
	//	};
284
	//
285
	//	/** The Cooccurrence adapter. */
286
	//	private IWorkbenchAdapter CooccurrenceAdapter = new IWorkbenchAdapter() {
287
	//
288
	//		@Override
289
	//		public Object[] getChildren(Object cooccurrence) {
290
	//			return new Object[0];
291
	//		}
292
	//
293
	//		@Override
294
	//		public ImageDescriptor getImageDescriptor(Object object) {
295
	//			return AbstractUIPlugin.imageDescriptorFromPlugin(
296
	//					Application.PLUGIN_ID, IImageKeys.ACTION_COOCCURRENCE);
297
	//		}
298
	//
299
	//		@Override
300
	//		public String getLabel(Object cooccurrence) {
301
	//			return ((Cooccurrence) cooccurrence).getName(); 
302
	//		}
303
	//
304
	//		@Override
305
	//		public Object getParent(Object cooccurrence) {
306
	//			return ((Cooccurrence) cooccurrence).getCorpus();
307
	//		}
308
	//	};
309

  
310
	//	/** The specificities result adapter. */
311
	//	private IWorkbenchAdapter specificitiesResultAdapter = new IWorkbenchAdapter() {
312
	//
313
	//		@Override
314
	//		public Object[] getChildren(Object o) {
315
	//			return new Object[0];
316
	//		}
317
	//
318
	//		@Override
319
	//		public ImageDescriptor getImageDescriptor(Object object) {
320
	//			return AbstractUIPlugin.imageDescriptorFromPlugin(
321
	//					Application.PLUGIN_ID, IImageKeys.ACTION_SPECIFICITIES);
322
	//		}
323
	//
324
	//		@Override
325
	//		public String getLabel(Object o) {
326
	//			return ((SpecificitesResult) o).getName();
327
	//		}
328
	//
329
	//		@Override
330
	//		public Object getParent(Object o) {
331
	//			return ((SpecificitesResult) o).getParent();
332
	//		}
333
	//
334
	//	};
335

  
338 336
	/** The Lexicon adapter. */
339 337
	private IWorkbenchAdapter LexiconAdapter = new TXMResultAdapter() {
340 338
		@Override
......
343 341
		}
344 342
	};
345 343

  
346
//	/** The Index adapter. */
347
//	private IWorkbenchAdapter IndexAdapter = new IWorkbenchAdapter() {
348
//
349
//		@Override
350
//		public Object[] getChildren(Object o) {
351
//			return ((Index)o).getResults().toArray();
352
//		}
353
//
354
//		@Override
355
//		public ImageDescriptor getImageDescriptor(Object object) {
356
//			return AbstractUIPlugin.imageDescriptorFromPlugin(
357
//					Application.PLUGIN_ID, IImageKeys.ACTION_INDEX);
358
//		}
359
//
360
//		@Override
361
//		public String getLabel(Object o) {
362
//			return ((Index) o).getName();
363
//		}
364
//
365
//		@Override
366
//		public Object getParent(Object o) {
367
//			return ((Index) o).getParent();
368
//		}
369
//	};
344
	//	/** The Index adapter. */
345
	//	private IWorkbenchAdapter IndexAdapter = new IWorkbenchAdapter() {
346
	//
347
	//		@Override
348
	//		public Object[] getChildren(Object o) {
349
	//			return ((Index)o).getResults().toArray();
350
	//		}
351
	//
352
	//		@Override
353
	//		public ImageDescriptor getImageDescriptor(Object object) {
354
	//			return AbstractUIPlugin.imageDescriptorFromPlugin(
355
	//					Application.PLUGIN_ID, IImageKeys.ACTION_INDEX);
356
	//		}
357
	//
358
	//		@Override
359
	//		public String getLabel(Object o) {
360
	//			return ((Index) o).getName();
361
	//		}
362
	//
363
	//		@Override
364
	//		public Object getParent(Object o) {
365
	//			return ((Index) o).getParent();
366
	//		}
367
	//	};
370 368

  
371 369
	/**
372 370
	 * Gets the adapter.
......
388 386
		if (adapterType == IWorkbenchAdapter.class
389 387
				&& adaptableObject instanceof Partition)
390 388
			return partitionAdapter;
391
//		if (adapterType == IWorkbenchAdapter.class
392
//				&& adaptableObject instanceof SpecificitesResult)
393
//			return specificitiesResultAdapter;
394
//		if (adapterType == IWorkbenchAdapter.class
395
//				&& adaptableObject instanceof Concordance)
396
//			return concordanceAdapter;
397
//		if (adapterType == IWorkbenchAdapter.class
398
//				&& adaptableObject instanceof Referencer)
399
//			return referencerAdapter;
400
//		if (adapterType == IWorkbenchAdapter.class
401
//				&& adaptableObject instanceof Lexicon)
402
//			return LexiconAdapter;
403
//		if (adapterType == IWorkbenchAdapter.class
404
//				&& adaptableObject instanceof Index)
405
//			return IndexAdapter;
406
//		if (adapterType == IWorkbenchAdapter.class
407
//				&& adaptableObject instanceof Progression)
408
//			return ProgressionAdapter;
409
//		if (adapterType == IWorkbenchAdapter.class
410
//				&& adaptableObject instanceof Cooccurrence)
411
//			return CooccurrenceAdapter;
412
//		if (adapterType == IWorkbenchAdapter.class
413
//				&& adaptableObject instanceof LexicalTable)
414
//			return lexicalTableAdapter;
415
//		if (adapterType == IWorkbenchAdapter.class
416
//				&& adaptableObject instanceof CAH)
417
//			return CAHAdapter;	
418
//		if (adapterType == IWorkbenchAdapter.class
419
//				&& adaptableObject instanceof InterTextDistance)
420
//			return interTextDistAdapter;
389
		//		if (adapterType == IWorkbenchAdapter.class
390
		//				&& adaptableObject instanceof SpecificitesResult)
391
		//			return specificitiesResultAdapter;
392
		//		if (adapterType == IWorkbenchAdapter.class
393
		//				&& adaptableObject instanceof Concordance)
394
		//			return concordanceAdapter;
395
		//		if (adapterType == IWorkbenchAdapter.class
396
		//				&& adaptableObject instanceof Referencer)
397
		//			return referencerAdapter;
398
		//		if (adapterType == IWorkbenchAdapter.class
399
		//				&& adaptableObject instanceof Lexicon)
400
		//			return LexiconAdapter;
401
		//		if (adapterType == IWorkbenchAdapter.class
402
		//				&& adaptableObject instanceof Index)
403
		//			return IndexAdapter;
404
		//		if (adapterType == IWorkbenchAdapter.class
405
		//				&& adaptableObject instanceof Progression)
406
		//			return ProgressionAdapter;
407
		//		if (adapterType == IWorkbenchAdapter.class
408
		//				&& adaptableObject instanceof Cooccurrence)
409
		//			return CooccurrenceAdapter;
410
		//		if (adapterType == IWorkbenchAdapter.class
411
		//				&& adaptableObject instanceof LexicalTable)
412
		//			return lexicalTableAdapter;
413
		//		if (adapterType == IWorkbenchAdapter.class
414
		//				&& adaptableObject instanceof CAH)
415
		//			return CAHAdapter;	
416
		//		if (adapterType == IWorkbenchAdapter.class
417
		//				&& adaptableObject instanceof InterTextDistance)
418
		//			return interTextDistAdapter;
421 419

  
422 420
		//check adapters from plugins
423 421
		if (externalAdapters.containsKey(adaptableObject.getClass())) {
tmp/org.txm.rcp/src/main/java/org/txm/rcp/views/corpora/TXMResultContentProvider.java (revision 533)
163 163
	@Override
164 164
	public boolean hasChildren(Object element) {
165 165
		if (element instanceof TXMResult) {
166
			return ((TXMResult)element).hasResults();
166
			return getChildren(element).length > 0;
167 167
		} else {
168 168
			int n = getChildren(element).length;
169 169
			return n > 0;
tmp/org.txm.rcp/src/main/java/org/txm/rcp/views/corpora/CorporaView.java (revision 533)
182 182
		PlatformUI.getWorkbench().getHelpSystem().setHelp(
183 183
				treeViewer.getControl(), RCPMessages.CorporaView_0);
184 184
		getSite().setSelectionProvider(treeViewer);
185
		treeViewer.addFilter(new ViewerFilter() {
186
			@Override
187
			public boolean select(Viewer viewer, Object parentElement, Object element) {
188
				if (element instanceof Text) return false;
189
				if (element instanceof SavedQuery) return false;
190
				return true;
191
			}
192
		});
185
//		treeViewer.addFilter(new ViewerFilter() {
186
//			@Override
187
//			public boolean select(Viewer viewer, Object parentElement, Object element) {
188
//				if (element instanceof Text) return false;
189
//				if (element instanceof SavedQuery) return false;
190
//				return true;
191
//			}
192
//		});
193 193
		treeViewer.setContentProvider(new TXMResultContentProvider(this));
194 194
		//treeViewer.setLabelProvider(new TextometrieLabelProvider());
195 195
		treeViewer.setLabelProvider(
tmp/org.txm.rcp/src/main/java/org/txm/rcp/editors/TXMEditorPart.java (revision 533)
310 310
							System.out.println(title);
311 311
							Log.info("Start computing Index...");
312 312

  
313
							//result.compute(monitor);
313
							result.compute(true, monitor);
314 314
						} else {
315 315
							return Status.CANCEL_STATUS;
316 316
						}
tmp/org.txm.index.core/src/org/txm/index/core/functions/Index.java (revision 533)
57 57
import org.txm.searchengine.cqp.corpus.Property;
58 58
import org.txm.searchengine.cqp.corpus.QueryResult;
59 59
import org.txm.searchengine.cqp.corpus.StructuralUnitProperty;
60
import org.txm.searchengine.cqp.corpus.WordProperty;
61 60
import org.txm.searchengine.cqp.corpus.query.Match;
62 61
import org.txm.searchengine.cqp.corpus.query.Query;
63 62
import org.txm.searchengine.cqp.serverException.CqiServerError;
......
141 140
	public boolean getLexiconMode() {
142 141
		return this.lexiconMode;
143 142
	}
143
	
144 144
	/**
145
	 * Create a CQL query using an Index lines
146
	 *
147
	 * @param selection the selection
148
	 * @return the query
149
	 */
150
	public static String createQuery(List<Line> lines) {
151
		String query = ""; //$NON-NLS-1$
152
		if (lines.size() == 0) return query;
153
		
154
		Line line = lines.get(0);
155
		int nbToken = line.getUnitsProperties().get(0).size();
156
		int nbProps = line.getProperties().size();
157
		int nbLines = lines.size();
158
		List<Property> props = line.getProperties();
159
		for (int t = 0; t < nbToken; t++) {
160
			query += "["; //$NON-NLS-1$
161
			for (int p = 0; p < nbProps; p++) {
162
				if (props.get(p) instanceof StructuralUnitProperty) {
163
					query += "_."+((StructuralUnitProperty)props.get(p)).getFullName() + "=\""; //$NON-NLS-1$ //$NON-NLS-2$
164
				} else {
165
					query += props.get(p) + "=\""; //$NON-NLS-1$
166
				}
167
				for (int l = 0; l < nbLines; l++) {
168
					line = lines.get(l);
169
					List<List<String>> values = line.getUnitsProperties();
170
					String s = values.get(p).get(t);
171
					s = Query.addBackSlash(s);
172
					query += s + "|"; //$NON-NLS-1$
173
				}
174
				query = query.substring(0, query.length() - 1);
175
				query += "\" & "; //$NON-NLS-1$
176
			}
177
			query = query.substring(0, query.length() - 3);
178
			query += "] "; //$NON-NLS-1$
179
		}
180
		query = query.substring(0, query.length() - 1);
181
		return query;
182
	}
183
	
184
	/**
145 185
	 * This method alter the index first column frequencies using a table stored in the R workspace
146 186
	 * 
147 187
	 * @param referenceCorpus the R table variable name
tmp/org.txm.partition.rcp/src/org/txm/partition/rcp/handlers/ComputePartitionDimensionsBarChart.java (revision 533)
68 68
		}
69 69

  
70 70
		
71
		Object selection = this.getSelection();
71
		Object selection = this.getSelection(event);
72 72
		PartitionDimensions partitionDimensions = null;
73 73
		
74 74
		
tmp/org.txm.cooccurrence.rcp/src/org/txm/cooccurrence/rcp/handlers/ComputeCooccurrences.java (revision 533)
79 79
			return null;
80 80
		}
81 81
		
82
		Object selection = this.getSelection();
82
		Object selection = this.getSelection(event);
83 83
		TXMResultEditorInput editorInput = null;
84 84
		
85 85
		// new editor from concordance
tmp/org.txm.ca.rcp/src/org/txm/ca/rcp/handlers/ComputeCA.java (revision 533)
87 87
		}
88 88

  
89 89
		final IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindow(event);
90
		final Object selection = this.getSelection();
90
		final Object selection = this.getSelection(event);
91 91

  
92 92
		try {
93 93
			// final Property property = d.getProperty();
tmp/org.txm.core/src/java/org/txm/objects/Corpus.java (revision 533)
39 39
import org.eclipse.core.runtime.IProgressMonitor;
40 40
import org.txm.Toolbox;
41 41
import org.txm.core.messages.TXMCoreMessages;
42
import org.txm.core.preferences.TBXPreferences;
43 42
import org.txm.metadatas.DateMetadata;
44 43
import org.txm.metadatas.Metadata;
45 44
import org.txm.metadatas.MetadataGroup;
tmp/org.txm.index.rcp/src/org/txm/index/rcp/handlers/ComputeIndex.java (revision 533)
65 65
		}
66 66

  
67 67
		TXMResultEditorInput editorInput = null;
68
		Object selection = this.getSelection();
68
		Object selection = this.getSelection(event);
69 69
		
70 70
		// New editor from corpus
71 71
		Index index = null;
tmp/org.txm.index.rcp/src/org/txm/index/rcp/handlers/ComputeLexicon.java (revision 533)
39 39
			return false;
40 40
		}
41 41
		
42
		Object selection = this.getSelection();
42
		Object selection = this.getSelection(event);
43 43
		
44 44
		TXMResultEditorInput editorInput;
45 45
		// New lexicon from corpus
tmp/org.txm.chartsengine.rcp/src/org/txm/chartsengine/rcp/handlers/ExportChart.java (revision 533)
70 70
	@Override
71 71
	public Object execute(ExecutionEvent event) throws ExecutionException {
72 72

  
73
		Object selection = this.getSelection();
73
		Object selection = this.getSelection(event);
74 74

  
75 75
		if(!(selection instanceof ChartResult))	{
76 76
			return null;
tmp/org.txm.chartsengine.rcp/src/org/txm/chartsengine/rcp/SWTChartsComponentsProvider.java (revision 533)
211 211
	public boolean updateChart(ChartEditorPart editor)	{
212 212
		try {
213 213
			return editor.getResultData().compute(true);
214
		}
215
		catch(Exception e) {
214
		} catch(Exception e) {
216 215
			// TODO Auto-generated catch block
217 216
			e.printStackTrace();
218 217
		}
tmp/org.txm.progression.rcp/src/org/txm/progression/rcp/handlers/ComputeProgression.java (revision 533)
85 85
			return false;
86 86
		}
87 87

  
88
		Object selection = this.getSelection();
88
		Object selection = this.getSelection(event);
89 89
		Progression progression = null;
90 90
		
91 91
		
tmp/org.txm.progression.core/src/org/txm/progression/core/functions/Progression.java (revision 533)
266 266
				for(long j = 0; j < 100000000L; j++)	{
267 267
					;
268 268
				}
269

  
270
				
271 269
			}
272 270
		}
273 271
		return npositions > 0;
tmp/org.txm.concordance.rcp/src/org/txm/concordance/rcp/handlers/ComputeConcordance.java (revision 533)
27 27
//
28 28
package org.txm.concordance.rcp.handlers;
29 29

  
30
import java.util.Map;
31

  
30 32
import javax.inject.Inject;
31 33

  
32 34
import org.eclipse.core.commands.ExecutionEvent;
......
37 39
import org.txm.concordance.core.functions.Concordance;
38 40
import org.txm.concordance.rcp.editors.ConcordanceEditor;
39 41
import org.txm.concordance.rcp.messages.Messages;
40
import org.txm.rcp.RCPMessages;
42
import org.txm.core.results.TXMParameters;
43
import org.txm.core.results.TXMResult;
41 44
import org.txm.rcp.StatusLine;
42 45
import org.txm.rcp.TXMWindows;
43 46
import org.txm.rcp.editors.TXMResultEditorInput;
......
62 65
	@Override
63 66
	public Object execute(ExecutionEvent event) throws ExecutionException {
64 67
		
65
		Object selection = this.getSelection();
68
		// if a TXMParameters is linked to the command call, uses its parent to create the concordance
69
		TXMParameters parameters = null;
70
		Map cmdparameters = event.getParameters();
71
		System.out.println(cmdparameters);
72
		if (cmdparameters.containsKey(TXMParameters.class.getName())) {
73
			Object iparam = cmdparameters.get(TXMParameters.class.getName());
74
			if (iparam instanceof TXMParameters) {
75
				parameters = (TXMParameters)iparam;
76
			}
77
		}
78
		Object selection = null;
79
		if (parameters == null) { // no parameters provided
80
			selection = this.getSelection(event);
81
		} else {
82
			selection = parameters;
83
		}
84
		
66 85
		if (!openEditor(selection)) {
67 86
			System.out.println(Messages.ComputeConcordance_1);
68 87
		}
......
84 103
			concordance = new Concordance(corpus);
85 104
		} else if (o instanceof Concordance) {
86 105
			concordance = (Concordance)o;
106
//		} else if (o instanceof TXMResult) { // called from CorporaView
107
//			TXMResult result = (TXMResult)o;
108
//			TXMParameters parameters = result.getTXMParameters();
109
//			Object p = parameters.get("corpus");
110
//			if (p == null) {
111
//				System.out.println("Error: no 'corpus' parameter provided");
112
//				return false;
113
//			}
114
//			if (!(p instanceof Corpus)) {
115
//				System.out.println("Error: 'corpus' parameter is not a Corpus");
116
//				return false;
117
//			}
118
//			Corpus corpus = (Corpus) p;
119
//			concordance = new Concordance(corpus);
120
//			concordance.setParameters(parameters);
87 121
		} else {
88 122
			System.out.println("Could not call ComputeConcordance with: "+o);
89 123
			return false;
tmp/org.txm.concordance.rcp/plugin.xml (revision 533)
99 99
            defaultHandler="org.txm.concordance.rcp.handlers.ComputeConcordance"
100 100
            id="org.txm.concordance.rcp.handlers.ComputeConcordance"
101 101
            name="%command.name">
102
         <commandParameter
103
               id="org.txm.core.results.TXMParameters"
104
               name="TXM Parameter"
105
               optional="true">
106
         </commandParameter>
102 107
      </command>
103 108
      <command
104 109
            defaultHandler="org.txm.concordance.rcp.handlers.DeleteLines"
tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/corpus/MainCorpus.java (revision 533)
44 44
import org.eclipse.core.runtime.IProgressMonitor;
45 45
import org.txm.objects.Base;
46 46
import org.txm.objects.BaseParameters;
47
import org.txm.objects.SavedQuery;
48
import org.txm.objects.Text;
47 49
import org.txm.objects.TxmObject;
48 50
import org.txm.searchengine.cqp.AbstractCqiClient;
49 51
import org.txm.searchengine.cqp.CQPEngine;
......
81 83
		super(cqpId);
82 84
		this.motherMainCorpus = this;
83 85
		this.name = cqpId;
84
		
85 86
	}
86 87

  
87 88
	/**
......
161 162
		}
162 163
		return this.size;
163 164
	}
165
	
166
	@Override
167
	public List<? extends TxmObject> getChildren() {
168
		List<? extends TxmObject> ret = super.getChildren();
169
		for (int i = 0 ; i < ret.size() ; i++) {
170
			Object element = ret.get(i);
171
			
172
			if (element instanceof Text || element instanceof SavedQuery) {
173
				ret.remove(i);
174
				i--;
175
			}
176
		}
177
		return ret;
178
	}
164 179

  
165 180
	/**
166 181
	 * Gets the properties available in this corpus.
tmp/org.txm.concordance.core/src/org/txm/concordance/core/functions/Concordance.java (revision 533)
136 136
			this.parameters.put(ConcordancePreferences.LEFT_VIEW_PROPERTIES, this.getStringParameterValue(ConcordancePreferences.LEFT_VIEW_PROPERTIES));
137 137
			this.parameters.put(ConcordancePreferences.KEYWORD_VIEW_PROPERTIES, this.getStringParameterValue(ConcordancePreferences.KEYWORD_VIEW_PROPERTIES));
138 138
			this.parameters.put(ConcordancePreferences.RIGHT_VIEW_PROPERTIES, this.getStringParameterValue(ConcordancePreferences.RIGHT_VIEW_PROPERTIES));
139
			
139

  
140 140
			this.parameters.put(ConcordancePreferences.LEFT_CONTEXT_SIZE, this.getIntParameterValue(ConcordancePreferences.LEFT_CONTEXT_SIZE));
141 141
			this.parameters.put(ConcordancePreferences.RIGHT_CONTEXT_SIZE, this.getIntParameterValue(ConcordancePreferences.RIGHT_CONTEXT_SIZE));
142 142

  
......
148 148
				this.parameters.put(ConcordancePreferences.VIEW_REFERENCEPATTERN, "text_id");
149 149
				this.parameters.put(ConcordancePreferences.ANALYSIS_REFERENCEPATTERN, "text_id");
150 150
			}
151
			
151

  
152 152
			this.setParameters(this.parameters);
153 153
		} catch (CqiClientException e) {
154 154
			// TODO Auto-generated catch block
......
1050 1050
	}
1051 1051

  
1052 1052
	@Override
1053
	public boolean setParameters(TXMParameters parameters) throws CqiClientException {
1053
	public boolean setParameters(TXMParameters parameters) {
1054 1054
		this.parameters = parameters;
1055 1055

  
1056 1056
		Object p = parameters.get(ConcordancePreferences.QUERY);
......
1143 1143
		return true;
1144 1144
	}
1145 1145

  
1146
	private static ReferencePattern stringToReferencePattern(Corpus corpus, String v) throws CqiClientException {
1147
		
1148
		ReferencePattern props = new ReferencePattern();
1149
		if (v == null) return props;
1150
		if (v.length() == 0) return props;
1151
		
1152
		String[] split = v.split("\t");
1153
		for (String s : split) {
1154
			if (s.contains("_")) {
1155
				String[] split2 = s.split("_", 2);
1156
				StructuralUnit su = corpus.getStructuralUnit(split2[0]);
1157
				if (su != null) {
1158
					Property prop = su.getProperty(split2[1]);
1146
	private static ReferencePattern stringToReferencePattern(Corpus corpus, String v) {
1147
		try {
1148
			ReferencePattern props = new ReferencePattern();
1149
			if (v == null) return props;
1150
			if (v.length() == 0) return props;
1151

  
1152
			String[] split = v.split("\t");
1153
			for (String s : split) {
1154
				if (s.contains("_")) {
1155
					String[] split2 = s.split("_", 2);
1156
					StructuralUnit su = corpus.getStructuralUnit(split2[0]);
1157
					if (su != null) {
1158
						Property prop = su.getProperty(split2[1]);
1159
						if (prop != null) {
1160
							props.addProperty(prop);
1161
						}
1162
					}
1163
				} else {
1164
					Property prop = corpus.getProperty(s);
1159 1165
					if (prop != null) {
1160 1166
						props.addProperty(prop);
1161 1167
					}
1162 1168
				}
1163
			} else {
1164
				Property prop = corpus.getProperty(s);
1165
				if (prop != null) {
1166
					props.addProperty(prop);
1167
				}
1168 1169
			}
1170
			return props;
1171
		} catch (Exception e) {
1172
			System.out.println("Error: "+v+" property not found in "+corpus);
1173
			return null;
1169 1174
		}
1170
		return props;
1171 1175
	}
1172 1176

  
1173
	private static List<Property> stringToProperties(Corpus corpus, String v) throws CqiClientException {
1174
		
1177
	private static List<Property> stringToProperties(Corpus corpus, String v)  {
1178

  
1175 1179
		ArrayList<Property> props = new ArrayList<Property>();
1176 1180
		if (v == null) return props;
1177 1181
		if (v.length() == 0) return props;
1178
		
1182

  
1179 1183
		String[] split = v.split("\t");
1180 1184
		for (String s : split) {
1181
			Property prop = corpus.getProperty(s);
1185
			Property prop;
1186
			try {
1187
				prop = corpus.getProperty(s);
1188
			} catch (CqiClientException e) {
1189
				System.out.println("Error: "+v+" property not found in "+corpus);
1190
				Log.printStackTrace(e);
1191
				return null;
1192
			}
1182 1193
			if (prop != null) {
1183 1194
				props.add(prop);
1184 1195
			}

Also available in: Unified diff