Révision 620

tmp/org.txm.index.rcp/src/org/txm/index/rcp/editors/IndexEditor.java (revision 620)
195 195
		final Integer fMax = Integer.parseInt(fMaxSpinner.getText());
196 196
		final Integer tMax = Integer.parseInt(this.vMaxSpinner.getText());
197 197
		final Integer nLines = Integer.parseInt(this.nLinesPerPageSpinner.getText());
198
		final List<Property> properties = propsArea.getProperties();
198
		final List<Property> properties = propsArea.getSelectedProperties();
199 199
		
200 200
		index.setNLinesPerPage(nLinesPerPageSpinner.getSelection());
201 201
		index.setVMax(vMaxSpinner.getSelection());
tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/corpus/Corpus.java (revision 620)
789 789

  
790 790
	/**
791 791
	 * Get the ordered Structural unit properties (by name)
792
	 * @return
792
	 * @return all the StructuralUnitProperty ordered by name
793 793
	 * @throws CqiClientException
794 794
	 */
795
	public Collection<? extends Property> getOrderedStructuralUnitProperties()
795
	public Collection<StructuralUnitProperty> getOrderedStructuralUnitProperties()
796 796
			throws CqiClientException {
797 797
		List<StructuralUnitProperty> properties = new ArrayList<StructuralUnitProperty>();
798 798
		for (StructuralUnit su : this.getOrderedStructuralUnits())
tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/ReferencePattern.java (revision 620)
199 199
		}
200 200
		return StringUtils.join(names, "\t"); //$NON-NLS-1$
201 201
	}
202

  
203
	public Corpus getCorpus() {
204
		if (properties.size() == 0) {
205
			return null;
206
		}
207
		return properties.get(0).getCorpus();
208
	}
202 209
}
tmp/org.txm.internalview.rcp/src/org/txm/internal/rcp/editors/InternalViewEditor.java (revision 620)
221 221
		propSelector.addSelectionListener(new SelectionListener() {
222 222
			@Override
223 223
			public void widgetSelected(SelectionEvent e) {
224
				internalView.setParameters(propSelector.getProperties(), null, null, null);
224
				internalView.setParameters(propSelector.getSelectedProperties(), null, null, null);
225 225
				compute(true);
226 226
			}
227 227

  
......
237 237
			@Override
238 238
			public void widgetSelected(SelectionEvent e) {
239 239
				ArrayList<StructuralUnitProperty> supList = new ArrayList<StructuralUnitProperty>();
240
				for (Property property : structSelector.getProperties()) if (property instanceof StructuralUnitProperty) supList.add((StructuralUnitProperty) property);
240
				for (Property property : structSelector.getSelectedProperties()) if (property instanceof StructuralUnitProperty) supList.add((StructuralUnitProperty) property);
241 241
				internalView.setStructuralUnitProperties(supList);
242 242
				try {
243 243
					lines = internalView.getCurrentPage();
......
661 661
	@Override
662 662
	public void updateResultFromEditor() {
663 663
		final StructuralUnit struct = internalView.getAvailableStructs().get(this.structCombo.getSelectionIndex());
664
		final  List<Property> properties = propSelector.getProperties();
664
		final  List<Property> properties = propSelector.getSelectedProperties();
665 665
		final List<StructuralUnitProperty> supList = new ArrayList<StructuralUnitProperty>();
666
		List<StructuralUnitProperty> pList = structSelector.getProperties();
666
		List<StructuralUnitProperty> pList = structSelector.getSelectedProperties();
667 667
		for (Property property : pList) if (property instanceof StructuralUnitProperty) supList.add((StructuralUnitProperty) property);
668 668
		
669 669
		Integer currentPage = internalView.getCurrentSegmentNo();
tmp/org.txm.referencer.rcp/src/org/txm/rcp/editors/referencer/ReferencerEditor.java (revision 620)
270 270
		propsArea.addSelectionListener(new SelectionListener() {
271 271
			@Override
272 272
			public void widgetSelected(SelectionEvent e) {
273
				referencer.setProperty(propsArea.getProperties().get(0));
273
				referencer.setProperty(propsArea.getSelectedProperties().get(0));
274 274
				compute(true);
275 275
			}
276 276
			
......
309 309
		patternArea.addSelectionListener(new SelectionListener() {
310 310
			@Override
311 311
			public void widgetSelected(SelectionEvent e) {
312
				referencer.setPattern(patternArea.getProperties());
312
				referencer.setPattern(patternArea.getSelectedProperties());
313 313
				compute(true);
314 314
			}
315 315
			
......
628 628
	@Override
629 629
	public void updateResultFromEditor() {
630 630
		final Query query = querywidget.getQuery();
631
		final List<Property> queryprops = propsArea.getProperties();
632
		final List<StructuralUnitProperty> refs = patternArea.getProperties();
631
		final List<Property> queryprops = propsArea.getSelectedProperties();
632
		final List<StructuralUnitProperty> refs = patternArea.getSelectedProperties();
633 633
		boolean hierarchicSort = TXMPreferences.getBoolean(RCPPreferences.SORTBYFREQ, RCPPreferences.PREFERENCES_NODE);
634 634
		
635 635
		referencer.setParameters(query, queryprops.get(0), refs, hierarchicSort);
tmp/org.txm.cooccurrence.rcp/src/org/txm/cooccurrence/rcp/editors/CooccurrencesEditor.java (revision 620)
599 599

  
600 600
		TXMParameters parameters = new TXMParameters();
601 601
		parameters.put(CooccurrencePreferences.QUERY, this.queryWidget.getQueryString());
602
		parameters.put(CooccurrencePreferences.PROPERTIES, new ArrayList<Property>(this.propsArea.getProperties()));
602
		parameters.put(CooccurrencePreferences.PROPERTIES, new ArrayList<Property>(this.propsArea.getSelectedProperties()));
603 603
		parameters.put(CooccurrencePreferences.STRUCTURE_LIMIT, this.empantPanel.getStruct());
604 604
		parameters.put(CooccurrencePreferences.MAX_LEFT, this.empantPanel.getMaxLeft() + 1);
605 605
		parameters.put(CooccurrencePreferences.MIN_LEFT, this.empantPanel.getMinLeft() + 1);
tmp/org.txm.concordance.rcp/src/org/txm/concordance/rcp/editors/ConcordanceEditor.java (revision 620)
980 980
		propsArea.addValueChangeListener(new Listener() {
981 981
			@Override
982 982
			public void handleEvent(Event event) {
983
				concordance.setKeywordViewProperties(propsArea.getProperties());
983
				concordance.setKeywordViewProperties(propsArea.getSelectedProperties());
984 984
				refreshViewProperties();
985 985
//				if (!TXMPreferences.getBoolean(RCPPreferences.AUTO_UPDATE_EDITOR, RCPPreferences.PREFERENCES_NODE)) {
986 986
//					try {
tmp/org.txm.rcp/src/main/java/org/txm/rcp/editors/TXMEditorPart.java (revision 620)
160 160
			
161 161
			this.__createPartControl(parent); // essentially for the ChartEditor
162 162
			this._createPartControl(parent); // child editor create its parameters and display widgets
163
			//TODO this._lol_createPartControl(parent); // essentially for the LolEditor
164
			//TODO this._omgiforgotthisonealso_createPartControl(parent); // essentially for the OMGIForgotThisOneAlsoEditor
163 165
			
164 166
			
165
			
166 167
			if (!this.getResultData().isDirty()) {
167 168
				this.topToolBar.setComputingParametersVisible(false);
168 169
			}
......
380 381
	}
381 382

  
382 383
	/**
383
	 * Internal method to mutualize compute editor creation
384
	 * Internal method to mutualise compute editor creation
384 385
	 * 
385 386
	 * @param result
386
	 * @param update
387
	 * @param update force the editor to update its result parameters
387 388
	 * @param editor
388 389
	 * @param chartsComponentsProvider
389 390
	 * @param resetView
......
405 406
				try {
406 407
					JobsTimer.start();
407 408

  
408

  
409 409
					currentEditor = editor;
410 410

  
411

  
412 411
					// FIXME: define if we update here the result from the editor fields
413 412
					if (currentEditor != null)	{
414 413
						this.syncExec(new Runnable() {
tmp/org.txm.rcp/src/main/java/org/txm/rcp/swt/widget/PropertiesSelector.java (revision 620)
36 36
import org.eclipse.swt.events.SelectionEvent;
37 37
import org.eclipse.swt.events.SelectionListener;
38 38
import org.eclipse.swt.layout.GridData;
39
import org.eclipse.swt.layout.GridLayout;
39 40
import org.eclipse.swt.widgets.Button;
40 41
import org.eclipse.swt.widgets.Composite;
41 42
import org.eclipse.swt.widgets.Label;
......
57 58
	Corpus corpus;
58 59
	
59 60
	/** The properties. */
60
	List<P> properties;
61
	final List<P> selectedProperties = new ArrayList<P>();
61 62
	
62 63
	/** The availableprops. */
63
	List<P> availableprops;
64
	final List<P> availableProperties = new ArrayList<P>();
64 65
	
65 66
	/** The maxprops. */
66 67
	int maxprops = -1;
......
86 87
	public PropertiesSelector(Composite parent, int style) {
87 88
		super(parent, style);
88 89

  
90
		this.setLayout(new GridLayout(3, false));
89 91
		// = properties
90 92
		propLabel = new Label(this, SWT.NONE);
91 93
		propLabel.setText(RCPMessages.PropertiesSelector_1);
......
136 138
		String previous = propertiesLabel.getText();
137 139
		StringBuffer buffer = new StringBuffer();
138 140
		boolean first = true;
139
		for (Property p : properties) {
141
		for (Property p : selectedProperties) {
140 142
			if (first) {
141 143
				first = false;
142 144
			} else {
......
168 170
	 * Show editor dialog.
169 171
	 */
170 172
	public void showEditorDialog() {
171
		if (availableprops == null) return;
172
		new ViewPropertySelectionDialog(this.getShell(), availableprops,
173
				properties, maxprops).open();
173
		if (availableProperties == null) return;
174
		new ViewPropertySelectionDialog(this.getShell(), availableProperties,
175
				selectedProperties, maxprops).open();
174 176
	}
175 177

  
176 178
	/**
......
180 182
	 */
181 183
	public void setCorpus(Corpus corpus) {
182 184
		this.corpus = corpus;
183
		this.properties = new ArrayList<P>();
184 185
		if (corpus == null)
185 186
			return;
187
		
188
		availableProperties.clear();
189
		selectedProperties.clear();
186 190
		try {
187
			availableprops = new ArrayList<P>();
188
			availableprops.addAll((Collection<? extends P>) corpus.getOrderedProperties());
191
			availableProperties.addAll((Collection<? extends P>) corpus.getOrderedProperties());
189 192
			//availableprops.addAll(corpus.getStructuralUnitProperties());
190 193
			
191
			for (int i = 0; i < availableprops.size(); i++) {
194
			for (int i = 0; i < availableProperties.size(); i++) {
192 195
				// remove TXM internal properties
193
				if (availableprops.get(i).getName().equals("id")) { //$NON-NLS-1$
194
					availableprops.remove(i);
196
				if (availableProperties.get(i).getName().equals("id")) { //$NON-NLS-1$
197
					availableProperties.remove(i);
195 198
					i--;
196 199
				}
197 200
			}
198

  
199
			if (availableprops.size() > 0) {
200
				this.properties = new ArrayList<P>();
201
				for (int i = 0 ; i < availableprops.size() ; i++) {
202
					if (availableprops.get(i).getName().equals("word")) { //$NON-NLS-1$
203
						properties.add(availableprops.get(i));
204
						availableprops.remove(i);
205
						refresh();
206
						break;
207
					}
208
				}
209
			}
210 201
		} catch (CqiClientException e) {
211 202
			Log.severe(NLS.bind(RCPMessages.PropertiesSelector_0, e.getMessage()));
212 203
		}
......
217 208
	 *
218 209
	 * @return the properties
219 210
	 */
220
	public List<P> getProperties() {
221
		return this.properties;
211
	public List<P> getSelectedProperties() {
212
		return this.selectedProperties;
222 213
	}
223 214
	
224 215
	/**
......
227 218
	 * @return the Available properties
228 219
	 */
229 220
	public List<P> getAvailableProperties() {
230
		return this.availableprops;
221
		return this.availableProperties;
231 222
	}
232 223

  
233 224
	/**
234 225
	 * Sets the properties.
235 226
	 *
236
	 * @param available the available
237
	 * @param selected the selected
227
	 * @param available the available properties
228
	 * @param selected the selected properties
238 229
	 */
239 230
	public void setProperties(List<P> available, List<P> selected) {
240 231
		// System.out.println("initialize prop selector with: "+available+" and "+selected);
241
		availableprops = available;
242
		this.properties = selected;
232
		availableProperties.clear();
233
		selectedProperties.clear();
234
		availableProperties.addAll(available);
235
		this.selectedProperties.addAll(selected);
243 236
		refresh();
244 237
	}
238
	
239
	/**
240
	 * Sets the properties.
241
	 *
242
	 * @param available the available
243
	 * @param selected a selected value
244
	 */
245
	public void setProperties(List<P> available, P selected) {
246
		// System.out.println("initialize prop selector with: "+available+" and "+selected);
247
		availableProperties.clear();
248
		selectedProperties.clear();
249
		if (available != null) availableProperties.addAll(available);
250
		if (selected != null) this.selectedProperties.add(selected);
251
		refresh();
252
	}
245 253

  
246 254
	/**
247 255
	 * Sets the text.
......
253 261
		propLabel.update();
254 262
	}
255 263

  
264
	/**
265
	 * reset available and selected properties
266
	 */
267
	public void clearSelected() {
268
		availableProperties.addAll(selectedProperties);
269
		selectedProperties.clear();
270
	}
271
	
272
	/**
273
	 * reset available and selected properties
274
	 */
256 275
	public void clear() {
257 276
		setText(""); //$NON-NLS-1$
258 277
		setProperties(new ArrayList<P>(), new ArrayList<P>());
tmp/org.txm.rcp/src/main/java/org/txm/rcp/views/cmdparameters/ParametersView.java (revision 620)
27 27
//
28 28
package org.txm.rcp.views.cmdparameters;
29 29

  
30
import java.io.File;
31
import java.lang.reflect.Array;
32
import java.lang.reflect.Field;
33
import java.lang.reflect.GenericArrayType;
34
import java.lang.reflect.ParameterizedType;
35
import java.lang.reflect.Type;
36
import java.lang.reflect.TypeVariable;
37
import java.util.ArrayList;
38
import java.util.Arrays;
39
import java.util.Collection;
40
import java.util.Collections;
41
import java.util.Comparator;
42
import java.util.HashMap;
43
import java.util.List;
44
import java.util.Map;
45

  
46
import org.eclipse.jface.layout.GridDataFactory;
30 47
import org.eclipse.swt.SWT;
31
import org.eclipse.swt.browser.Browser;
48
import org.eclipse.swt.custom.ScrolledComposite;
49
import org.eclipse.swt.events.SelectionEvent;
50
import org.eclipse.swt.events.SelectionListener;
51
import org.eclipse.swt.layout.GridData;
52
import org.eclipse.swt.layout.GridLayout;
53
import org.eclipse.swt.widgets.Button;
32 54
import org.eclipse.swt.widgets.Composite;
55
import org.eclipse.swt.widgets.Control;
56
import org.eclipse.swt.widgets.DirectoryDialog;
57
import org.eclipse.swt.widgets.Event;
58
import org.eclipse.swt.widgets.FileDialog;
33 59
import org.eclipse.swt.widgets.Label;
60
import org.eclipse.swt.widgets.Listener;
61
import org.eclipse.swt.widgets.Spinner;
62
import org.eclipse.swt.widgets.Text;
34 63
import org.eclipse.ui.IPartListener;
35 64
import org.eclipse.ui.IPartService;
65
import org.eclipse.ui.IPropertyListener;
36 66
import org.eclipse.ui.IWorkbenchPart;
37 67
import org.eclipse.ui.PlatformUI;
38 68
import org.eclipse.ui.part.EditorPart;
39 69
import org.eclipse.ui.part.ViewPart;
70
import org.txm.core.results.Parameter;
40 71
import org.txm.core.results.TXMResult;
72
import org.txm.rcp.IImageKeys;
41 73
import org.txm.rcp.editors.TXMEditorPart;
74
import org.txm.rcp.swt.widget.PropertiesSelector;
75
import org.txm.rcp.swt.widget.QueryWidget;
76
import org.txm.rcp.swt.widget.StructuralUnitsGroup;
77
import org.txm.searchengine.cqp.ReferencePattern;
78
import org.txm.searchengine.cqp.clientExceptions.CqiClientException;
79
import org.txm.searchengine.cqp.corpus.Corpus;
80
import org.txm.searchengine.cqp.corpus.Property;
81
import org.txm.searchengine.cqp.corpus.StructuralUnitProperty;
82
import org.txm.searchengine.cqp.corpus.WordProperty;
42 83
//import org.txm.rcp.editors.referencer.ReferencerEditor;
84
import org.txm.searchengine.cqp.corpus.query.Query;
43 85

  
86
import sun.reflect.generics.reflectiveObjects.TypeVariableImpl;
87

  
44 88
/**
45 89
 * Alternative display of the TXMEditor form fields
46 90
 * 
47 91
 * @author mdecorde.
48 92
 */
49
public class ParametersView extends ViewPart implements IPartListener {
93
public class ParametersView extends ViewPart implements IPartListener, IPropertyListener {
50 94

  
51
	Browser currentEditorLabel;
52

  
53 95
	/** The ID. */
54 96
	public static String ID = ParametersView.class.getName(); //$NON-NLS-1$
55 97

  
......
71 113
	 * Refresh.
72 114
	 */
73 115
	public static void refresh() {
74
		
116

  
75 117
	}
76 118

  
77
	EditorPart desactivated, activated, broughtToTop, closed, opened;
119
	TXMEditorPart<? extends TXMResult> activated;
120
	private Composite panel;
121
	private ScrolledComposite scrollC;
122
	private Button recompute;
78 123

  
79
	public void updateEditorParameters() {
124
	public void updateEditorParameters() throws Exception {
80 125

  
81 126
		EditorPart editor = activated;
82
		if (editor == null) editor = broughtToTop;
83
		if (editor == null) editor = opened;
84 127

  
85
		if (editor == null) currentEditorLabel.setText("No editor selected.");
128
		for (Control c : panel.getChildren()) {
129
			c.dispose();
130
		}
86 131

  
87
		if (editor instanceof TXMEditorPart) {
88
			TXMEditorPart reditor = (TXMEditorPart)editor;
89
			StringBuffer buffer = new StringBuffer();
90
			
91
			TXMResult result = reditor.getResultData();
92
			buffer.append("<h4>"+result.getClass().getSimpleName()+" details</h4>");
93
			buffer.append("<p><ul>");
94
			buffer.append("<li>Result: <br/>" + result.toString() + "</li>\n");
95
			buffer.append("<li>UUID: <br/>" + result.getUUID() + "</li>\n");
96
			buffer.append("<li>Simple name: <br/>" + result.getSimpleName() + "</li>\n");
97
			buffer.append("<li>Name: <br/>" + result.getName() + "</li>\n");
98
			buffer.append("<li>Valid filename: <br/>" + result.getValidFileName() + "</li>\n");
99
			buffer.append("<li>Compute details: <br/>" + result.getDetails() + "</li>\n\n");
100
			buffer.append("</ul></p>");
132
		if (editor == null) {
133
			new Label(panel, SWT.NONE).setText("No editor selected.");
134
			recompute.setEnabled(false);
135
			return;
136
		}
101 137

  
102
			try {
103
				// Command preferences
104
				buffer.append(result.htmlDumpPreferences());
105
				
106
				// Object parameters
107
				buffer.append(result.htmlDumpParameters());
108
				
109
				// Object parameters
110
				buffer.append(result.htmlDumpLastParameters());
111
				
138
		if (!(editor instanceof TXMEditorPart)) {
139
			new Label(panel, SWT.NONE).setText("Editor is not a TXMPartEditor: " + editor);
140
			return;
141
		}
142
		recompute.setEnabled(true);
143
		TXMEditorPart reditor = (TXMEditorPart) editor;
144
		final TXMResult result = reditor.getResultData();
145

  
146
		List<Field> allfields = result.getAllFields();
147
		List<Field> fields = new ArrayList<Field>();
148
		for (Field f : allfields) {
149
			Parameter parameter = f.getAnnotation(Parameter.class);
150
			if (parameter == null) {
151
				continue;
112 152
			}
113
			catch (Exception e) {
114
				System.out.println("Error: "+e);
115
				e.printStackTrace();
153
			fields.add(f);
154
		}
155

  
156
		Collections.sort(fields, new Comparator<Field>() {
157

  
158
			@Override
159
			public int compare(Field o1, Field o2) {
160
				Parameter parameter1 = o1.getAnnotation(Parameter.class);
161
				Parameter parameter2 = o2.getAnnotation(Parameter.class);
162

  
163
				if (parameter1.type() == parameter2.type()) {
164
					return o1.getName().compareTo(o2.getName());
165
				} else {
166
					return parameter1.type() - parameter2.type();
167
				}
116 168
			}
169
		});
170

  
171
		for (final Field f : fields) {
172
			Parameter parameter = f.getAnnotation(Parameter.class);
173
			if (parameter == null) {
174
				continue;
175
			}
176

  
177
			String name;
178
			if (!parameter.key().isEmpty()) {
179
				name = parameter.key();
180
			} else {
181
				name = f.getName();
182
			}
183
			Class<?> clazz = f.getType();
184
			f.setAccessible(true);
185
			final Object value = f.get(result);
186

  
187
			new Label(panel, SWT.NONE).setText(name);
188
			clazz.equals(Integer.class);
189
			Control c = null;
190
			if (clazz.equals(Integer.class)) {
191
				final Spinner sp = new Spinner(panel, SWT.BORDER);
192
				if (value != null) {
193
					sp.setSelection((Integer) value);
194
				}
195
				sp.addSelectionListener(new SelectionListener() {
196

  
197
					@Override
198
					public void widgetSelected(SelectionEvent e) {
199
						try {
200
							f.set(result, sp.getSelection());
201
							if (activated != null && !activated.getParametersGroupsComposite().isDisposed()) {
202
								activated.compute(false);
203
							}
204
						} catch (Exception e1) {
205
							// TODO Auto-generated catch block
206
							e1.printStackTrace();
207
						}
208
					}
209

  
210
					@Override
211
					public void widgetDefaultSelected(SelectionEvent e) {
212
					}
213
				});
214
				c = sp;
215
			} else if (clazz.equals(String.class)) {
216
				final Text t = new Text(panel, SWT.BORDER);
217
				if (value != null) {
218
					t.setText(value.toString());
219
				}
220
				t.addKeyListener(new org.eclipse.swt.events.KeyListener() {
221

  
222
					@Override
223
					public void keyReleased(org.eclipse.swt.events.KeyEvent e) {
224
						try {
225
							f.set(result, t.getText());
226
							if (activated != null && !activated.getParametersGroupsComposite().isDisposed()) {
227
								activated.compute(false);
228
							}
229
						} catch (Exception e1) {
230
							// TODO Auto-generated catch block
231
							e1.printStackTrace();
232
						}
233
					}
234

  
235
					@Override
236
					public void keyPressed(org.eclipse.swt.events.KeyEvent e) {
237
						// TODO Auto-generated method stub
238

  
239
					}
240
				});
241
				c = t;
242
			} else if (clazz.equals(Float.class)) {
243
				final Spinner sp = new Spinner(panel, SWT.BORDER);
244
				sp.setSelection((int) ((Float) value * 2));
245
				sp.addSelectionListener(new SelectionListener() {
246

  
247
					@Override
248
					public void widgetSelected(SelectionEvent e) {
249
						try {
250
							f.set(result, sp.getSelection());
251
							if (activated != null && !activated.getParametersGroupsComposite().isDisposed()) {
252
								activated.compute(false);
253
							}
254
						} catch (Exception e1) {
255
							e1.printStackTrace();
256
						}
257
					}
258

  
259
					@Override
260
					public void widgetDefaultSelected(SelectionEvent e) {
261
					}
262
				});
263
				c = sp;
264
				((Spinner) c).setDigits(2);
265
			} else if (clazz.equals(Query.class)) {
266
				final QueryWidget qw = new QueryWidget(panel, SWT.NONE);
267
				if (value != null) {
268
					qw.setText(((Query) value).getQueryString());
269
				}
270
				qw.addSelectionListener(new SelectionListener() {
271

  
272
					@Override
273
					public void widgetSelected(SelectionEvent e) {
274
						try {
275
							f.set(result, qw.getQuery());
276
							if (activated != null && !activated.getParametersGroupsComposite().isDisposed()) {
277
								activated.compute(false);
278
							}
279
						} catch (Exception e1) {
280
							// TODO Auto-generated catch block
281
							e1.printStackTrace();
282
						}
283
					}
284

  
285
					@Override
286
					public void widgetDefaultSelected(SelectionEvent e) {
287
					}
288
				});
289
				qw.addKeyListener(new org.eclipse.swt.events.KeyListener() {
290

  
291
					@Override
292
					public void keyReleased(org.eclipse.swt.events.KeyEvent e) {
293
						if (e.keyCode != SWT.KEYPAD_CR && e.keyCode != SWT.CR) {
294
							return;
295
						}
296
						try {
297
							f.set(result, qw.getQuery());
298
							if (activated != null && !activated.getParametersGroupsComposite().isDisposed()) {
299
								activated.compute(false);
300
							}
301
						} catch (Exception e1) {
302
							// TODO Auto-generated catch block
303
							e1.printStackTrace();
304
						}
305
					}
306

  
307
					@Override
308
					public void keyPressed(org.eclipse.swt.events.KeyEvent e) {
309
					}
310
				});
311
				c = qw;
312
			} else if (clazz.equals(File.class)) {
313
				final Button b = new Button(panel, SWT.PUSH);
314
				if (value != null) {
315
					b.setText(value.toString());
316

  
317
				}
318

  
319
				b.addSelectionListener(new SelectionListener() {
320

  
321
					@Override
322
					public void widgetSelected(SelectionEvent e) {
323
						File file = (File) value;
324
						if (file.isDirectory()) {
325
							DirectoryDialog dialog = new DirectoryDialog(panel.getDisplay().getActiveShell());
326
							dialog.setText("Choose directory");
327
							dialog.setFilterPath(file.getAbsolutePath());
328
							String path = dialog.open();
329
							if (path != null) {
330
								try {
331
									f.set(result, path);
332
									b.setText(path);
333
									if (activated != null && !activated.getParametersGroupsComposite().isDisposed()) {
334
										activated.compute(false);
335
									}
336
								} catch (IllegalArgumentException e1) {
337
									// TODO Auto-generated catch block
338
									e1.printStackTrace();
339
								} catch (IllegalAccessException e1) {
340
									// TODO Auto-generated catch block
341
									e1.printStackTrace();
342
								}
343
							}
344
						} else {
345
							FileDialog dialog = new FileDialog(panel.getDisplay().getActiveShell());
346
							dialog.setText("Choose directory");
347
							dialog.setFilterPath(file.getAbsolutePath());
348
							String path = dialog.open();
349
							if (path != null) {
350
								try {
351
									f.set(result, path);
352
									b.setText(path);
353
									if (activated != null && !activated.getParametersGroupsComposite().isDisposed()) {
354
										activated.compute(false);
355
									}
356
								} catch (IllegalArgumentException e1) {
357
									// TODO Auto-generated catch block
358
									e1.printStackTrace();
359
								} catch (IllegalAccessException e1) {
360
									// TODO Auto-generated catch block
361
									e1.printStackTrace();
362
								}
363
							}
364
						}
365
					}
366

  
367
					@Override
368
					public void widgetDefaultSelected(SelectionEvent e) {
369
					}
370
				});
371
			} else if (clazz.equals(List.class)) {
372
				List list = (List) value;
373
				if (list.isEmpty()) {
374
					Label l3 = new Label(panel, SWT.NONE);
375
					l3.setText("no value");
376
					c = l3;
377
				} else {
378
					Object first = list.get(0);
379
					if (first instanceof WordProperty) {
380
						c = createWordPropertyField(f, result, list);
381
					} else if (first instanceof StructuralUnitProperty) {
382
						c = createStructuralUnitPropertyField(f, result, list);
383
					}
384
				}
385
				// } else if (value instanceof StructuralUnit) {
386
			} else if (clazz.equals(WordProperty.class)) {
387
				ArrayList<WordProperty> selected = new ArrayList<WordProperty>();
388
				selected.add((WordProperty) value);
389
				c = createWordPropertyField(f, result, selected);
390
				// } else if (value instanceof StructuralUnit) {
391
				// Label l2 = new Label(panel,
392
				// SWT.NONE).setText("="+value.toString());
393
			} else if (clazz.equals(StructuralUnitProperty.class)) {
394
				ArrayList<StructuralUnitProperty> selected = new ArrayList<StructuralUnitProperty>();
395
				selected.add((StructuralUnitProperty) value);
396
				c = createWordPropertyField(f, result, selected);
397
				// } else if (value instanceof ReferencePattern) {
398
				// c = new Label(panel, SWT.NONE).setText("="+value.toString());
399
			} else if (clazz.equals(ReferencePattern.class)) {
400
				c = createReferencePatternField(f, result, (ReferencePattern)value);
401
				// } else if (value instanceof ReferencePattern) {
402
				// c = new Label(panel, SWT.NONE).setText("="+value.toString());
403
			} else {
404
				Label l2 = new Label(panel, SWT.NONE);
405
				if (value != null) {
406
					TypeVariable<?>[] pp = value.getClass().getTypeParameters();
407
					l2.setText("" + value);
408
				}
409
				c = l2;
410
			}
411
			// if (c != null)
412
			c.setLayoutData(GridDataFactory.fillDefaults().grab(true, false).create());
413
		}
414
		scrollC.setContent(panel);
415
		scrollC.setMinSize(panel.computeSize(SWT.DEFAULT, SWT.DEFAULT));
416
		scrollC.setExpandHorizontal(true);
417
		scrollC.setExpandVertical(true);
418
		scrollC.layout(true);
419
	}
420

  
421
	private Control createReferencePatternField(final Field f, final TXMResult result, ReferencePattern value) throws Exception {
422
		final List<Property> selected = new ArrayList<Property>();
423
		selected.addAll(value.getProperties());
424
		Corpus corpus = value.getCorpus();
425
		PropertiesSelector<Property> selector = new PropertiesSelector<Property>(panel, SWT.NONE);
426
		if (corpus != null) {
427
			List<Property> availables = new ArrayList<Property>();
428
			availables.addAll(corpus.getOrderedProperties());
429
			availables.addAll(corpus.getOrderedStructuralUnitProperties());
430
			availables.remove(value);
117 431
			
118
			
119
			currentEditorLabel.setText(buffer.toString());
120
		} else {
121
			currentEditorLabel.setText("Editor is not a TXMPartEditor: "+editor);
432
			selector.setProperties(availables, selected);
122 433
		}
123
		//		StringBuffer buffer = new StringBuffer();
124
		//		if (activated != null)
125
		//			buffer.append("\neditor activated: "+activated.getTitle());
126
		//		if (broughtToTop != null)
127
		//			buffer.append("\neditor on top: "+broughtToTop.getTitle());
128
		//		if (closed != null)
129
		//			buffer.append("\neditor closed: "+closed.getTitle());
130
		//		if (desactivated != null)
131
		//			buffer.append("\neditor desactivated: "+desactivated.getTitle());
132
		//		if (opened != null)
133
		//			buffer.append("\neditor opened: "+opened.getTitle());
134
		//		if (editor instanceof ConcordanceEditor) {
135
		//			currentEditorLabel.setText("Concordances "+editor.getTitle()+":\n\tquery\n\tproperty\n\tsort\n\t...");
136
		//		} else if (editor instanceof IndexEditor) {
137
		//			currentEditorLabel.setText("Index "+editor.getTitle()+":\n\tquery\n\tproperty\n\tsort\n\t...");
138
		//		} else if (editor instanceof CooccurrencesEditor) {
139
		//			currentEditorLabel.setText("Cooccurences "+editor.getTitle()+":\n\tquery\n\tproperty\n\tsort\n\t...");
140
		////		} else if (editor instanceof CAEditor) {
141
		//			currentEditorLabel.setText("CaEditor "+editor.getTitle()+":\n\tquery\n\tproperty\n\tsort\n\t...");
142
		//		} else if (editor instanceof ReferencerEditor) {
143
		//			currentEditorLabel.setText("References "+editor.getTitle()+":\n\tquery\n\tproperty\n\tsort\n\t...");
144
		//		}
434
		selector.addSelectionListener(new SelectionListener() {
435

  
436
			@Override
437
			public void widgetSelected(SelectionEvent e) {
438
				if (activated != null && !activated.getParametersGroupsComposite().isDisposed()) {
439
					ReferencePattern p = new ReferencePattern(selected);
440
					try {
441
						f.set(result, p);
442
					} catch (IllegalArgumentException e1) {
443
						// TODO Auto-generated catch block
444
						e1.printStackTrace();
445
					} catch (IllegalAccessException e1) {
446
						// TODO Auto-generated catch block
447
						e1.printStackTrace();
448
					}
449
					activated.compute(false);
450
				}
451
			}
452

  
453
			@Override
454
			public void widgetDefaultSelected(SelectionEvent e) { }
455
		});
456
		//		selector.setLayoutData(layoutData);
457
		return selector;
145 458
	}
146 459

  
147
	/* (non-Javadoc)
148
	 * @see org.eclipse.ui.part.WorkbenchPart#createPartControl(org.eclipse.swt.widgets.Composite)
460
	protected PropertiesSelector<WordProperty> createWordPropertyField(final Field f, final TXMResult result, final List selected) throws CqiClientException {
461

  
462
		Object value = selected.get(0);
463
		Corpus corpus = ((WordProperty) value).getCorpus();
464
		List<WordProperty> availables = corpus.getOrderedProperties();
465
		availables.remove(value);
466
		PropertiesSelector<WordProperty> selector = new PropertiesSelector<WordProperty>(panel, SWT.NONE);
467
		selector.setProperties(availables, selected);
468
		selector.addSelectionListener(new SelectionListener() {
469

  
470
			@Override
471
			public void widgetSelected(SelectionEvent e) {
472
				if (activated != null && !activated.getParametersGroupsComposite().isDisposed()) {
473
					try {
474
						f.set(result, selected);
475
					} catch (Exception e1) {
476
						// TODO Auto-generated catch block
477
						e1.printStackTrace();
478
					}
479
					activated.compute(false);
480
				}
481
			}
482

  
483
			@Override
484
			public void widgetDefaultSelected(SelectionEvent e) { }
485
		});
486
		//		selector.setLayoutData(layoutData);
487
		return selector;
488
	}
489

  
490
	private PropertiesSelector<StructuralUnitProperty> createStructuralUnitPropertyField(final Field f, final TXMResult result, final List selected) throws CqiClientException {
491
		Object value = selected.get(0);
492
		Corpus corpus = ((StructuralUnitProperty) value).getCorpus();
493
		ArrayList<StructuralUnitProperty> availables = new ArrayList<StructuralUnitProperty>();
494
		availables.addAll(corpus.getOrderedStructuralUnitProperties());
495
		availables.remove(value);
496
		PropertiesSelector<StructuralUnitProperty> selector = new PropertiesSelector<StructuralUnitProperty>(panel, SWT.NONE);
497
		selector.setProperties(availables, selected);
498
		selector.addSelectionListener(new SelectionListener() {
499

  
500
			@Override
501
			public void widgetSelected(SelectionEvent e) {
502
				if (activated != null && !activated.getParametersGroupsComposite().isDisposed()) {
503
					try {
504
						f.set(result, selected);
505
					} catch (Exception e1) {
506
						// TODO Auto-generated catch block
507
						e1.printStackTrace();
508
					}
509
					activated.compute(false);
510
				}
511
			}
512

  
513
			@Override
514
			public void widgetDefaultSelected(SelectionEvent e) { }
515
		});
516
		return selector;
517
	}
518

  
519
	/*
520
	 * (non-Javadoc)
521
	 * 
522
	 * @see
523
	 * org.eclipse.ui.part.WorkbenchPart#createPartControl(org.eclipse.swt.widgets
524
	 * .Composite)
149 525
	 */
150 526
	@Override
151 527
	public void createPartControl(Composite parent) {
152
		System.out.println("createPartControl: "+parent);
153
		currentEditorLabel = new Browser(parent, SWT.NONE);
154
		updateEditorParameters();
528

  
529
		parent.setLayout(new GridLayout(1, true));
530

  
531
		recompute = new Button(parent, SWT.PUSH);
532
		recompute.setImage(IImageKeys.getImage(IImageKeys.START));
533
		recompute.addSelectionListener(new SelectionListener() {
534

  
535
			@Override
536
			public void widgetSelected(SelectionEvent e) {
537
				if (activated != null && !activated.getParametersGroupsComposite().isDisposed()) {
538
					activated.compute(false);
539
				}
540
			}
541

  
542
			@Override
543
			public void widgetDefaultSelected(SelectionEvent e) { }
544
		});
545
		recompute.setLayoutData(GridDataFactory.fillDefaults().align(GridData.BEGINNING, GridData.BEGINNING).grab(false, false).create());
546
		recompute.setEnabled(false);
547

  
548
		scrollC = new ScrolledComposite(parent, SWT.H_SCROLL | SWT.V_SCROLL);
549
		scrollC.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create());
550

  
551
		panel = new Composite(scrollC, SWT.NONE);
552
		panel.setLayout(new GridLayout(2, true));
553

  
554
		try {
555
			updateEditorParameters();
556
		} catch (Exception e) {
557
			// TODO Auto-generated catch block
558
			e.printStackTrace();
559
		}
155 560
	}
156 561

  
157 562
	@Override
158 563
	public void partActivated(IWorkbenchPart part) {
159
		System.out.println("partActivated: "+part);
160
		if (part instanceof EditorPart)
161
			activated = (EditorPart)part;
162
		updateEditorParameters();
564
		if (part == null)
565
			return;
566
		// System.out.println("partActivated: "+part);
567
		if (part instanceof TXMEditorPart)
568
			activated = (TXMEditorPart) part;
569
		if (activated == null)
570
			return;
571
		activated.addPropertyListener(this);
572
		recompute.setEnabled(true);
573
		// activated.addPartPropertyListener(this);
574
		try {
575
			updateEditorParameters();
576
		} catch (Exception e) {
577
			// TODO Auto-generated catch block
578
			e.printStackTrace();
579
		}
163 580
	}
164 581

  
165 582
	@Override
166 583
	public void partBroughtToTop(IWorkbenchPart part) {
167
		System.out.println("partBroughtToTop: "+part);
168
		if (part instanceof EditorPart)
169
			broughtToTop = (EditorPart)part;
170
		//updateLabel();
584
		if (part == null)
585
			return;
171 586
	}
172 587

  
173 588
	@Override
174 589
	public void partClosed(IWorkbenchPart part) {
175
		System.out.println("partClosed: "+part);
176
		if (part instanceof EditorPart) {
177
			closed = (EditorPart)part;
590
		if (part == null)
591
			return;
592
		if (part == activated) {
593
			activated = null;
594
			try {
595
				updateEditorParameters();
596
			} catch (Exception e) {
597
				// TODO Auto-generated catch block
598
				e.printStackTrace();
599
			}
178 600
		}
179
		updateEditorParameters();
180 601
	}
181 602

  
182 603
	@Override
183 604
	public void partDeactivated(IWorkbenchPart part) {
184
		System.out.println("partDeactivated: "+part);
185
		if (part instanceof EditorPart)
186
			desactivated = (EditorPart)part;
187
		//updateLabel();
605
		if (part == null)
606
			return;
607
		// System.out.println("partDeactivated: "+part);
608
		//		if (part instanceof TXMEditorPart)
609
		//			activated = null;
610
		//		try {
611
		//			updateEditorParameters();
612
		//		} catch (Exception e) {
613
		//			// TODO Auto-generated catch block
614
		//			e.printStackTrace();
615
		//		}
188 616
	}
189 617

  
190 618
	@Override
619
	public void propertyChanged(Object source, int propId) {
620
		// System.out.println("Editor property changed: "+propId);
621
		if (propId == EditorPart.PROP_DIRTY) {
622
			try {
623
				updateEditorParameters();
624
			} catch (Exception e) {
625
				// TODO Auto-generated catch block
626
				e.printStackTrace();
627
			}
628
		}
629
	}
630

  
631
	@Override
191 632
	public void partOpened(IWorkbenchPart part) {
192
		System.out.println("partOpened: "+part);
193
		if (part instanceof EditorPart)
194
			opened = (EditorPart)part;
195
		//updateLabel();
633
		if (part == null)
634
			return;
196 635
	}
197 636

  
198 637
	@Override
tmp/org.txm.rcp/src/main/java/org/txm/rcp/views/SummaryView.java (revision 620)
261 261
		//System.out.println("Set properties "+availables+", "+selectorSelectedProps);
262 262
		this.propsArea.setProperties(availables, selectorSelectedProps);
263 263
		//init default props
264
		selectedProps = propsArea.getProperties();
264
		selectedProps = propsArea.getSelectedProperties();
265 265

  
266 266
		if (tv.getContentProvider() != null)
267 267
			tv.setInput(null);
tmp/org.txm.core/src/java/org/txm/core/results/TXMResult.java (revision 620)
159 159

  
160 160
	/**
161 161
	 * Returns all the member fields of the class instance.
162
	 * @return
162
	 * @return the list of declared fields
163 163
	 */
164
	protected List<Field> getAllFields()	{
164
	public List<Field> getAllFields()	{
165 165

  
166 166
		List<Field> fields = new ArrayList<Field>();
167 167
		Class<?> clazz = this.getClass();
tmp/org.txm.concordance.core/src/org/txm/concordance/core/functions/Concordance.java (revision 620)
304 304
			buf
305 305
			.append("\tKeyword View property: " + this.getKeywordViewProperties() + "\n"); //$NON-NLS-1$ //$NON-NLS-2$
306 306
			buf
307
			.append("\right Context View property: " + this.getRightViewProperties() + "\n"); //$NON-NLS-1$ //$NON-NLS-2$
307
			.append("\tRight Context View property: " + this.getRightViewProperties() + "\n"); //$NON-NLS-1$ //$NON-NLS-2$
308 308
			buf
309 309
			.append("\tLeft Context Sort property: " + this.getLeftAnalysisProperties() + "\n"); //$NON-NLS-1$ //$NON-NLS-2$
310 310
			buf
311 311
			.append("\tKeyword Sort property: " + this.getKeywordAnalysisProperties() + "\n"); //$NON-NLS-1$ //$NON-NLS-2$
312 312
			buf
313
			.append("\right Context Sort property: " + this.getRightAnalysisProperties() + "\n"); //$NON-NLS-1$ //$NON-NLS-2$
313
			.append("\tRight Context Sort property: " + this.getRightAnalysisProperties() + "\n"); //$NON-NLS-1$ //$NON-NLS-2$
314 314
			buf.append("\tReference View Pattern: " + this.getRefViewPattern() + "\n"); //$NON-NLS-1$ //$NON-NLS-2$
315 315
			buf.append("\tReference Sort Pattern: " + this.getRefAnalysePattern() + "\n"); //$NON-NLS-1$ //$NON-NLS-2$
316 316
			return buf.toString();

Formats disponibles : Unified diff