Révision 3592

TXM/trunk/org.txm.rcp/src/main/java/org/txm/rcp/IImageKeys.java (revision 3592)
156 156
	/** The Constant CHECKED. */
157 157
	public static final String CHECKED = "icons/tick.png"; //$NON-NLS-1$
158 158
	
159
	public static final String CHECKEDALL = "icons/tick_all.png"; //$NON-NLS-1$
160
	
159 161
	/** The Constant UNCHECKED. */
160 162
	public static final String UNCHECKED = "icons/cross.png"; //$NON-NLS-1$
161 163
	
164
	/** The Constant UNCHECKED. */
165
	public static final String UNCHECKEDALL = "icons/cross_all.png"; //$NON-NLS-1$
166
	
162 167
	public static final String ACTION_INTERTEXTDIST = "icons/functions/dist.png"; //$NON-NLS-1$
163 168
	
164 169
	public static final String QUERYINDEX = "icons/functions/QueryIndex.png"; //$NON-NLS-1$
TXM/trunk/org.txm.rcp/src/main/java/org/txm/rcp/messages/messages_fr.properties (revision 3592)
31 31
ampRunScript=&Exécuter un script
32 32
ampSortOptions=Options de tri
33 33
ampStructureColon=&Structure \:
34
ampValue=&Valeur 
34
ampValue=&Valeur
35
ampValues=&Valeur(s)  
35 36
andFrom=et de
36 37
AnImportDotXMLImportConfigurationFileWasFoundRestoringImportParametersUsingThisfile=Restauration des paramètres d'importation à partir du fichier de paramètres import.xml.
37 38
AnnotationsEngines=Moteurs d'annotation
TXM/trunk/org.txm.rcp/src/main/java/org/txm/rcp/messages/TXMUIMessages.java (revision 3592)
128 128
	
129 129
	public static String ampValue;
130 130
	
131
	public static String ampValues;
132
	
131 133
	public static String andFrom;
132 134
	
133 135
	public static String lemmatizeTheCorpus;
TXM/trunk/org.txm.rcp/src/main/java/org/txm/rcp/messages/messages.properties (revision 3592)
31 31
ampRunScript=&Run script
32 32
ampSortOptions=&Sort options
33 33
ampStructureColon=&Structure\:
34
ampValue=&Value 
34
ampValue=&Value
35
ampValues=&Valu(e) 
35 36
andFrom=and from
36 37
AnImportDotXMLImportConfigurationFileWasFoundRestoringImportParametersUsingThisfile=Restoring import parameters from the import.xml parameters file.
37 38
AnnotationsEngines=Annotation Engines
TXM/trunk/org.txm.rcp/src/main/java/org/txm/rcp/swt/widget/ComplexSubcorpusPanel.java (revision 3592)
29 29

  
30 30
import java.util.ArrayList;
31 31
import java.util.HashMap;
32
import java.util.LinkedHashSet;
32 33
import java.util.List;
33 34

  
35
import org.apache.commons.lang.StringUtils;
34 36
import org.eclipse.jface.viewers.ArrayContentProvider;
35 37
import org.eclipse.jface.viewers.ISelection;
36 38
import org.eclipse.jface.viewers.IStructuredSelection;
......
62 64
	/** The self. */
63 65
	ComplexSubcorpusPanel self;
64 66
	
65
	/** The struct combo. */
66
	Combo structCombo;
67
	
68 67
	/** The corpus. */
69 68
	CQPCorpus corpus;
70 69
	
......
102 101
	public ComplexSubcorpusPanel(Composite parent, int style, CQPCorpus corpus) {
103 102
		super(parent, style);
104 103
		self = this;
105
		this.setLayout(new GridLayout(2, false));
104
		this.setLayout(new GridLayout(3, false));
106 105
		this.corpus = corpus;
107 106
		
108 107
		try {
......
132 131
			structuralUnitsProperties.put(su, properties);
133 132
		}
134 133
		
134
		Label firstStep = new Label(this, SWT.NONE);
135
		firstStep.setText("1- Configure");
136
		firstStep = new Label(this, SWT.SEPARATOR | SWT.HORIZONTAL);
137
		firstStep.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, false, 2, 1));
138
		
135 139
		Group andorGroup = new Group(this, SWT.SHADOW_ETCHED_IN);
136 140
		andorGroup.setText(TXMUIMessages.match);
137 141
		andorGroup.setLayout(new GridLayout(2, false));
138
		andorGroup.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, false, 2, 1));
142
		andorGroup.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, false, 3, 1));
139 143
		
140 144
		andBtn = new Button(andorGroup, SWT.RADIO);
141 145
		andBtn.setText(TXMUIMessages.allCriteria);
142
		andBtn.setSelection(false);
146
		andBtn.setSelection(true);
143 147
		
144 148
		Button orBtn = new Button(andorGroup, SWT.RADIO);
145 149
		orBtn.setText(TXMUIMessages.someCriteria);
146
		orBtn.setSelection(true);
150
		orBtn.setSelection(false);
147 151
		
148
		// structure choice
149
		Label l = new Label(this, SWT.None);
150
		l.setText(TXMCoreMessages.common_structure);
151
		structCombo = new Combo(this, SWT.READ_ONLY);
152
		structCombo.addSelectionListener(new SelectionListener() {
153
			
154
			@Override
155
			public void widgetSelected(SelectionEvent e) {
156
				for (QueryItem item : queryItems)
157
					item.refreshProps();
158
			}
159
			
160
			@Override
161
			public void widgetDefaultSelected(SelectionEvent e) {}
162
		});
163
		
164
		int i_text = 0, i = 0;
165
		for (StructuralUnit su : structuralunits) {
166
			structCombo.add(su.getName());
167
			if (su.getName().equals("text")) i_text = i; //$NON-NLS-1$
168
			i++;
169
		}
170
		
171
		if (structuralunits.size() > 0)
172
			structCombo.select(i_text);
173
		
174 152
		queriesPanel = new Composite(this, SWT.NONE);
175 153
		queriesPanel.setLayout(new GridLayout(1, false));
176
		queriesPanel.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, false, 2, 1));
154
		queriesPanel.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, false, 3, 1));
177 155
		QueryItem item = new QueryItem(queriesPanel, SWT.NONE);
178 156
		item.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, false));
179 157
		queryItems.add(item);
......
181 159
		// 3 combos : struc, prop, value
182 160
		// Add/Rmv contrainte
183 161
		// affichage requete
184
		l = new Label(this, SWT.NONE);
162
		
163
		Label secondStep = new Label(this, SWT.NONE);
164
		secondStep.setText("2- Generate query");
165
		secondStep = new Label(this, SWT.SEPARATOR | SWT.HORIZONTAL);
166
		secondStep.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, false, 2, 1));
167
		
168
		Label l = new Label(this, SWT.NONE);
185 169
		l.setText(TXMUIMessages.query);
170
		
186 171
		queryField = new Text(this, SWT.BORDER);
187 172
		queryField.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, false));
173
		
188 174
		Button refreshBtn = new Button(this, SWT.PUSH);
189 175
		refreshBtn.setText("Refresh the query");
190 176
		refreshBtn.addSelectionListener(new SelectionListener() {
......
196 182
			
197 183
			@Override
198 184
			public void widgetDefaultSelected(SelectionEvent e) {
199
			
185
				
200 186
			}
201 187
		});
202
			
188
		
203 189
		// first init
204 190
		updateQueryField();
205 191
	}
......
227 213
	 * @return the query string
228 214
	 */
229 215
	public String getQueryString() {
230
		String structName = this.structCombo.getText();
231 216
		
232
		String query = "/region[" + structName + ",a]::"; //$NON-NLS-1$ //$NON-NLS-2$
233
		int nbitem = 0;
217
		LinkedHashSet<String> parts = new LinkedHashSet<>(); // to avoid duplicates 
234 218
		for (QueryItem item : queryItems) {
235
			if (nbitem != 0)
236
				if (andBtn.getSelection())
237
					query += " &"; //$NON-NLS-1$
238
				else
239
					query += " |"; //$NON-NLS-1$
219
			
220
			String query = "";
221
			
240 222
			String prop = item.selectedSup.getFullName();
241
			ISelection sel = item.valueCombo.getSelection();
242
			String value = ""; //$NON-NLS-1$
243
			if (sel instanceof IStructuredSelection) {
244
				value = ((IStructuredSelection) sel).getFirstElement().toString();
245
			}
246
			int equals = item.testCombo.getSelectionIndex();
223
			IStructuredSelection sel = item.valueCombo.getStructuredSelection();
224
			String value = StringUtils.join(sel.toList(), "|");
247 225
			
248
			if (equals == 0) // is
249
				query += " a." + prop + "=\"" + value + "\""; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
250
			else if (equals == 1) // is not
251
				query += " a." + prop + "!=\"" + value + "\""; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
252
			else if (equals == 2) // contains
253
				query += " a." + prop + "=\".*" + value + ".*\""; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
226
			int test = item.testCombo.getSelectionIndex();
227
			
228
			if (test == 0) // is
229
				query = " _."+ prop + "=\"" + value + "\""; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
230
			else if (test == 1) // is not
231
				query = " _."+ prop + "!=\"" + value + "\""; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
232
			else if (test == 2) // contains
233
				query = " _."+ prop + "=\".*" + value + ".*\""; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
254 234
			else // does not contain
255
				query += " a." + prop + "!=\".*" + value + ".*\""; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
235
				query = " _."+ prop + "!=\".*" + value + ".*\""; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
256 236
			
257
			nbitem++;
237
			parts.add(query);
258 238
		}
259 239
		
260
		/*
261
		 * String query = "["; //$NON-NLS-1$ //$NON-NLS-2$
262
		 * int nbitem = 0;
263
		 * for (QueryItem item : queryItems) {
264
		 * if (nbitem != 0)
265
		 * if (andBtn.getSelection())
266
		 * query += " &"; //$NON-NLS-1$
267
		 * else
268
		 * query += " |"; //$NON-NLS-1$
269
		 * String prop = item.selectedSup.getFullName();
270
		 * ISelection sel = item.valueCombo.getSelection();
271
		 * String value = ""; //$NON-NLS-1$
272
		 * if (sel instanceof IStructuredSelection) {
273
		 * value = ((IStructuredSelection)sel).getFirstElement().toString();
274
		 * }
275
		 * int equals = item.testCombo.getSelectionIndex();
276
		 * if (equals == 0) // is
277
		 * query += " a."+prop+"=\""+value+"\""; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
278
		 * else if (equals == 1) // is not
279
		 * query += " a."+prop+"!=\""+value+"\""; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
280
		 * else if (equals == 2) // contains
281
		 * query += " a."+prop+"=\".*"+value+".*\""; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
282
		 * else // does not contain
283
		 * query += " a."+prop+"!=\".*"+value+".*\""; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
284
		 * nbitem++;
285
		 * }
286
		 */
240
		String sep = " | ";
241
		if (andBtn.getSelection())
242
			sep = " & "; //$NON-NLS-1$
287 243
		
288
		/**
289
		 * //
290
		 * for (QueryItem item : queryItems) {
291
		 * if (nbitem != 0) { // adding a constraint
292
		 * if (andBtn.getSelection())
293
		 * query += " &"; //$NON-NLS-1$
294
		 * else
295
		 * query += " |"; //$NON-NLS-1$
296
		 * }
297
		 * String prop = item.selectedSup.getFullName();
298
		 * ISelection sel = item.valueCombo.getSelection();
299
		 * String value = ""; //$NON-NLS-1$
300
		 * if (sel instanceof IStructuredSelection) {
301
		 * value = ((IStructuredSelection)sel).getFirstElement().toString();
302
		 * }
303
		 * int equals = item.testCombo.getSelectionIndex();
304
		 * 
305
		 * if (equals == 0) // is
306
		 * query += " _."+prop+"=\""+value+"\""; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
307
		 * else if (equals == 1) // is not
308
		 * query += " _."+prop+"!=\""+value+"\""; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
309
		 * else if (equals == 2) // contains
310
		 * query += " _."+prop+"=\".*"+value+".*\""; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
311
		 * else // does not contain
312
		 * query += " _."+prop+"!=\".*"+value+".*\""; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
313
		 * 
314
		 * nbitem++;
315
		 * }
316
		 * query += "] expand to "+structName;
317
		 */
318
		return query;
244
		return "["+ StringUtils.join(parts, sep)+"]+ expand to "+queryItems.get(queryItems.size() - 1).structCombo.getText();
245
		
319 246
	}
320 247
	
321 248
	public String getQueryFieldValue() {
......
327 254
	}
328 255
	
329 256
	public String getGeneratedName() {
330
		String generated = ""; //$NON-NLS-1$
331
		if (this.queryItems.size() > 0) {
332
			QueryItem queryItem = this.queryItems.get(0);
333
			generated += queryItem.selectedSup.asFullNameString() + "=" + queryItem.valueCombo.getList().getSelection()[0];
257
		
258
		LinkedHashSet<String> parts = new LinkedHashSet<>();
259
		
260
		for (QueryItem queryItem : queryItems) {
334 261
			
262
			String testString = "=";
263
			int test = queryItem.testCombo.getSelectionIndex();
264
			if (test == 0) // is
265
				testString = "=";
266
			else if (test == 1) // is not
267
				testString = "!=";
268
			else if (test == 2) // contains
269
				testString = " contains ";
270
			else // does not contain
271
				testString = " does not contains";
272
			
273
			String generated = queryItem.selectedSup.asFullNameString() + testString + queryItem.valueCombo.getList().getSelection()[0];
274
			parts.add(generated);
335 275
		}
336
		return generated;
276
		
277
		String sep = " | ";
278
		if (andBtn.getSelection())
279
			sep = " & "; //$NON-NLS-1$
280
		
281
		return StringUtils.join(parts, sep);
337 282
	}
338 283
	
339 284
	/**
......
341 286
	 */
342 287
	class QueryItem extends Composite {
343 288
		
289
		/** The struct combo. */
290
		Combo structCombo;
291
		
344 292
		/** The prop combo. */
345 293
		Combo propCombo;
346 294
		
......
368 316
		public QueryItem(Composite parent, int style) {
369 317
			super(parent, style);
370 318
			
371
			this.setLayout(new GridLayout(5, false));
319
			this.setLayout(new GridLayout(7, false));
320
			
321
			// structure choice
322
			Label l = new Label(this, SWT.None);
323
			l.setText(TXMCoreMessages.common_structure);
324
			
325
			structCombo = new Combo(this, SWT.READ_ONLY);
326
			structCombo.addSelectionListener(new SelectionListener() {
327
				
328
				@Override
329
				public void widgetSelected(SelectionEvent e) {
330
					for (QueryItem item : queryItems)
331
						item.refreshProps();
332
				}
333
				
334
				@Override
335
				public void widgetDefaultSelected(SelectionEvent e) {}
336
			});
337
			
338
			int i_text = 0, i = 0;
339
			for (StructuralUnit su : structuralunits) {
340
				structCombo.add(su.getName());
341
				if (su.getName().equals("text")) i_text = i; //$NON-NLS-1$
342
				i++;
343
			}
344
			
345
			if (structuralunits.size() > 0) {
346
				structCombo.select(i_text);
347
			}
348
			
372 349
			propCombo = new Combo(this, SWT.READ_ONLY);
373 350
			propCombo.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, false));
374 351
			propCombo.addSelectionListener(new SelectionListener() {
......
390 367
			testCombo.add(TXMUIMessages.doesNotContain);
391 368
			testCombo.select(0);
392 369
			
393
			valueCombo = new ListViewer(this, SWT.SINGLE | SWT.V_SCROLL | SWT.BORDER | SWT.VIRTUAL);
370
			valueCombo = new ListViewer(this, SWT.MULTI | SWT.V_SCROLL | SWT.BORDER | SWT.VIRTUAL);
394 371
			valueCombo.setContentProvider(new ArrayContentProvider());
395 372
			GridData data = new GridData(GridData.FILL, GridData.FILL, true, false);
396 373
			data.heightHint = testCombo.getItemHeight();
TXM/trunk/org.txm.rcp/src/main/java/org/txm/rcp/swt/widget/structures/SuperListViewer.java (revision 3592)
1
package org.txm.rcp.swt.widget.structures;
2

  
3
import java.util.ArrayList;
4
import java.util.Arrays;
5

  
6
import org.eclipse.jface.dialogs.InputDialog;
7
import org.eclipse.jface.viewers.ArrayContentProvider;
8
import org.eclipse.jface.viewers.IStructuredSelection;
9
import org.eclipse.jface.viewers.ListViewer;
10
import org.eclipse.swt.SWT;
11
import org.eclipse.swt.dnd.DND;
12
import org.eclipse.swt.dnd.DropTargetAdapter;
13
import org.eclipse.swt.dnd.DropTargetEvent;
14
import org.eclipse.swt.dnd.DropTargetListener;
15
import org.eclipse.swt.dnd.TextTransfer;
16
import org.eclipse.swt.dnd.Transfer;
17
import org.eclipse.swt.dnd.TransferData;
18
import org.eclipse.swt.events.SelectionEvent;
19
import org.eclipse.swt.events.SelectionListener;
20
import org.eclipse.swt.layout.GridData;
21
import org.eclipse.swt.widgets.Button;
22
import org.eclipse.swt.widgets.Composite;
23
import org.eclipse.swt.widgets.List;
24
import org.txm.rcp.IImageKeys;
25
import org.txm.rcp.swt.GLComposite;
26

  
27
public class SuperListViewer extends GLComposite {
28
	
29
	ListViewer valueCombo;
30
	Button selectByListButton;
31
	String lastValuesSelected = "";
32
	Button selectByRegex;
33
	String lastRegexSelected = "";
34
	
35
	public SuperListViewer(Composite parent, int listStyle) {
36
		
37
		super(parent, SWT.NONE, "SuperListViewer");
38
		
39
		this.getLayout().numColumns = 2;
40
		this.getLayout().verticalSpacing = 1;
41
		this.getLayout().horizontalSpacing = 1;
42
		
43
		valueCombo = new ListViewer(this, listStyle);
44
		valueCombo.setContentProvider(new ArrayContentProvider());
45
		valueCombo.getList().setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, true, 1, 4));
46
		int operations = DND.DROP_COPY | DND.DROP_MOVE;
47
		Transfer[] transferTypes = new Transfer[]{TextTransfer.getInstance()};
48
		valueCombo.addDropSupport(operations, transferTypes, new DropTargetAdapter() {
49
			   @Override
50
			    public void drop(DropTargetEvent event) {
51
				   //System.out.println("DROP: "+event);
52
				   
53
				   if (event.data instanceof String) {
54
					   selectByString((String)event.data);
55
				   }
56
			    }
57
		});
58
		
59
		selectByListButton = new Button(this, SWT.PUSH);
60
		selectByListButton.setToolTipText("Select values using a list of values");
61
		selectByListButton.setImage(IImageKeys.getImage("icons/functions/data.png"));
62
		selectByListButton.setLayoutData(new GridData(GridData.CENTER, GridData.CENTER, false, false));
63
		selectByListButton.addSelectionListener(new SelectionListener() {
64
			
65
			
66

  
67
			@Override
68
			public void widgetSelected(SelectionEvent e) {
69
				
70
				InputDialog dialog = new InputDialog(e.display.getActiveShell(), "Select values using a list of values", "List of values to select", lastValuesSelected, null);
71
				
72
				if (dialog.open() == InputDialog.OK) {
73
					String str = dialog.getValue();
74
					str = str.trim();
75
					selectByString(str);
76
					lastValuesSelected = str;
77
				}
78
			}
79
			
80
			@Override
81
			public void widgetDefaultSelected(SelectionEvent e) { }
82
		});
83

  
84
		selectByRegex = new Button(this, SWT.PUSH);
85
		selectByRegex.setToolTipText("Select values using a regular expression");
86
		selectByRegex.setImage(IImageKeys.getImage(IImageKeys.ACTION_SEARCH));
87
		selectByRegex.setLayoutData(new GridData(GridData.BEGINNING, GridData.BEGINNING, false, false));
88
		selectByRegex.addSelectionListener(new SelectionListener() {
89
			
90
			@Override
91
			public void widgetSelected(SelectionEvent e) {
92
				
93
				InputDialog dialog = new InputDialog(e.display.getActiveShell(), "Select values by regular expression", "Regular expression to use", lastRegexSelected, null);
94
				if (dialog.open() == InputDialog.OK) {
95
					String str = dialog.getValue();
96
					str = str.trim();
97
					if (str.length() == 0) return;
98
					
99
					selectByRegex(str);
100
					lastRegexSelected = str;
101
				}
102
			}
103
			
104
			@Override
105
			public void widgetDefaultSelected(SelectionEvent e) { }
106
		});
107
		
108
		Button allButton = new Button(this, SWT.PUSH);
109
		allButton.setToolTipText("Select all");
110
		allButton.setImage(IImageKeys.getImage(IImageKeys.CHECKEDALL));
111
		allButton.setLayoutData(new GridData(GridData.BEGINNING, GridData.BEGINNING, false, false));
112
		allButton.addSelectionListener(new SelectionListener() {
113
			
114
			@Override
115
			public void widgetSelected(SelectionEvent e) {
116
				
117
				valueCombo.getList().selectAll();
118
			}
119
			
120
			@Override
121
			public void widgetDefaultSelected(SelectionEvent e) { }
122
		});
123
		
124
		Button clearButton = new Button(this, SWT.PUSH);
125
		clearButton.setToolTipText("De-select all");
126
		clearButton.setImage(IImageKeys.getImage(IImageKeys.UNCHECKEDALL));
127
		clearButton.setLayoutData(new GridData(GridData.BEGINNING, GridData.BEGINNING, false, false));
128
		clearButton.addSelectionListener(new SelectionListener() {
129
			
130
			@Override
131
			public void widgetSelected(SelectionEvent e) {
132
				
133
				valueCombo.getList().deselectAll();
134
			}
135
			
136
			@Override
137
			public void widgetDefaultSelected(SelectionEvent e) { }
138
		});
139
	}
140
	
141
	public void selectAll() {
142
		valueCombo.getList().selectAll();
143
	}
144
	
145
	public void deSelectAll() {
146
		valueCombo.getList().deselectAll();
147
	}
148
	
149
	public void selectByRegex(String regex) {
150
		String[] listValues = valueCombo.getList().getItems();
151
		ArrayList<Integer> indices = new ArrayList<>();
152
		
153
		for (int i = 0 ; i < listValues.length ; i++) {
154
			if (listValues[i].matches(regex)) {
155
				indices.add(i);
156
			}
157
		}
158
	
159
		int[] iindices = new int[indices.size()];
160
		for (int i = 0 ; i < indices.size() ; i++) iindices[i] = indices.get(i);
161
		
162
		//valueCombo.getList().deselectAll();
163
		valueCombo.getList().select(iindices);
164
	}
165
	
166
	public void selectByString(String str) {
167
		if (str == null) return;
168
		if (str.length() == 0) return;
169
		
170
		selectByStringValues(str.split("[\t\n|]"));
171
	}
172
	
173
	public void selectByStringValues(String[] values) {
174
		String[] listValues = valueCombo.getList().getItems();
175
		ArrayList<Integer> indices = new ArrayList<>();
176
		for (String v : values) {
177
			int i = Arrays.binarySearch(listValues, v);
178
			if (i >= 0) {
179
				indices.add(i);
180
			}
181
		}
182
		int[] iindices = new int[indices.size()];
183
		for (int i = 0 ; i < indices.size() ; i++) iindices[i] = indices.get(i);
184
		
185
		//valueCombo.getList().deselectAll();
186
		valueCombo.getList().select(iindices);
187
	}
188
	
189
	public void setInput(Object input) {
190
		valueCombo.setInput(input);
191
	}
192
	
193
	public ListViewer getListviewer() {
194
		
195
		return valueCombo;
196
	}
197

  
198
	public List getList() {
199
		
200
		return valueCombo.getList();
201
	}
202

  
203
	public IStructuredSelection getSelection() {
204
		
205
		return valueCombo.getStructuredSelection();
206
	}
207

  
208
}
0 209

  
TXM/trunk/org.txm.rcp/src/main/java/org/txm/rcp/swt/widget/structures/SimpleSubcorpusPanel.java (revision 3592)
38 38

  
39 39
	Combo structuralUnitsCombo;
40 40
	Combo propertyCombo;
41
	ListViewer valueCombo;
41
	SuperListViewer valueCombo;
42 42

  
43 43
	List<StructuralUnit> structuralUnitsFinal;
44 44
	private Button validationButton;
......
69 69
		propertyCombo.setLayoutData(new GridData(GridData.FILL,GridData.FILL, true, false));
70 70

  
71 71
		Label valuesLabel = new Label(this, SWT.NONE);
72
		valuesLabel.setText(TXMUIMessages.ampValue);
72
		valuesLabel.setText(TXMUIMessages.ampValues);
73 73
		valuesLabel.setLayoutData(new GridData(GridData.END, GridData.CENTER, false, false));
74 74

  
75
		valueCombo = new ListViewer(this, SWT.MULTI |SWT.V_SCROLL | SWT.BORDER | SWT.VIRTUAL);
76
		valueCombo.setContentProvider(new ArrayContentProvider());
77
		//		valueCombo.setLabelProvider(new LabelProvider() {
78
		//
79
		//	        @Override
80
		//	        public String getText(Object element) {
81
		//	            return Activator.getSomeService().key2Value((Integer) element);
82
		//	        }
83
		//
84
		//	    });
75
		valueCombo = new SuperListViewer(this, SWT.MULTI |SWT.V_SCROLL | SWT.BORDER | SWT.VIRTUAL);
85 76
		GridData data = new GridData(GridData.FILL,GridData.FILL, true, false);
86 77
		data.heightHint = 100;
87
		valueCombo.getList().setLayoutData(data);
88

  
89

  
78
		valueCombo.setLayoutData(data);
90 79
		// Load StructuralUnit
91 80
		// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
92 81
		List<StructuralUnit> structuralUnits = null;
......
153 142

  
154 143
		propertyCombo.addSelectionListener(new SelectionListener() {
155 144
			@Override
156
			public void widgetDefaultSelected(SelectionEvent e) {
157
			}
145
			public void widgetDefaultSelected(SelectionEvent e) { }
158 146

  
159 147
			@Override
160 148
			public void widgetSelected(SelectionEvent event) {
......
165 153
		valueCombo.getList().addSelectionListener(new SelectionListener() {
166 154
			@Override
167 155
			public void widgetSelected(SelectionEvent e) {
168
				ISelection sel = valueCombo.getSelection();
169
				if (sel instanceof IStructuredSelection) {
170
					selectedValues = ((IStructuredSelection)sel).toList();
171
				}
156
				selectedValues = valueCombo.getSelection().toList();
172 157
			}
173 158

  
174 159
			@Override
175
			public void widgetDefaultSelected(SelectionEvent e) {
176
				// TODO Auto-generated method stub
177

  
178
			}
160
			public void widgetDefaultSelected(SelectionEvent e) { }
179 161
		});
180 162

  
181 163
		reloadProperties();
......
209 191
		}
210 192
		GridData data = new GridData(GridData.FILL_BOTH);
211 193
		data.heightHint = 10 * valueCombo.getList().getItemHeight();
212
		valueCombo.getList().setLayoutData(data);
213
		valueCombo.getList().getParent().layout();
194
		valueCombo.setLayoutData(data);
195
		valueCombo.getParent().layout();
214 196
	}
215 197

  
216 198
	/**
TXM/trunk/org.txm.rcp/src/main/java/org/txm/rcp/swt/widget/PartitionComposer.java (revision 3592)
101 101
	 * @param corpus the corpus
102 102
	 */
103 103
	public PartitionComposer(Composite parent, int style, CQPCorpus corpus) {
104
		
104 105
		super(parent, style);
105 106
		self = this;
106 107
		this.setLayout(new GridLayout(1, true));
107 108
		this.corpus = corpus;
108 109
		
109 110
		firstArea = new Composite(this, SWT.NONE);
110
		firstArea.setLayoutData(new GridData(GridData.FILL, GridData.FILL,
111
				true, false));
111
		firstArea.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, false));
112 112
		dispoArea = new Composite(this, SWT.NONE);
113
		dispoArea.setLayoutData(new GridData(GridData.FILL, GridData.FILL,
114
				true, false));
113
		dispoArea.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, false));
115 114
		btnArea = new Composite(this, SWT.NONE);
116
		btnArea.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true,
117
				false));
115
		btnArea.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, false));
118 116
		
119 117
		sc1 = new ScrolledComposite(this, SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER);
120 118
		sc1.setLayout(new GridLayout(1, true));
......
125 123
		
126 124
		partArea = new Composite(sc1, SWT.NONE);
127 125
		sc1.setContent(partArea);
128
		partArea.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true,
129
				true));
126
		partArea.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, true));
130 127
		
131 128
		// struct&prop
132 129
		RowLayout layout = new RowLayout();
......
164 161
			
165 162
			@Override
166 163
			public void widgetSelected(SelectionEvent e) {
164
				
167 165
				reloadProperties();
168 166
				updateDisplay();
169 167
			}
......
182 180
			
183 181
			@Override
184 182
			public void widgetSelected(SelectionEvent e) {
183
				
185 184
				reloadPropertyValues();
186 185
				updateDisplay();
187 186
			}
......
193 192
		// dispo
194 193
		GridLayout layout2 = new GridLayout(2, false);
195 194
		dispoArea.setLayout(layout2);
195
		
196 196
		Label dispoLabel = new Label(dispoArea, SWT.NONE);
197 197
		dispoLabel.setText(TXMUIMessages.selectValuesToAssignColon);
198
		dispoLabel.setLayoutData(new GridData(GridData.FILL, GridData.FILL,
199
				false, false));
200
		availableList = new org.eclipse.swt.widgets.List(dispoArea, SWT.MULTI
201
				| SWT.READ_ONLY | SWT.V_SCROLL | SWT.BORDER);
198
		dispoLabel.setLayoutData(new GridData(GridData.FILL, GridData.FILL, false, false));
199
		
200
		availableList = new org.eclipse.swt.widgets.List(dispoArea, SWT.MULTI | SWT.READ_ONLY | SWT.V_SCROLL | SWT.BORDER);
202 201
		GridData data = new GridData(GridData.FILL, GridData.FILL, true, true);
203 202
		data.heightHint = 10 * availableList.getItemHeight();
204 203
		availableList.setLayoutData(data);
......
212 211
			
213 212
			@Override
214 213
			public void widgetSelected(SelectionEvent e) {
214
				
215 215
				// System.out.println(Messages.PartitionComposer_4);
216 216
				PartItem p = new PartItem(partArea, SWT.BORDER, self);
217 217
				GridData gdata = new GridData(GridData.FILL, GridData.FILL, true, true);
......
233 233
			
234 234
			@Override
235 235
			public void widgetSelected(SelectionEvent e) {
236
				
236 237
				for (PartItem p : parts) {
237 238
					for (String s : p.getColumns())
238 239
						self.add(s);
......
262 263
	 * Update display.
263 264
	 */
264 265
	public void updateDisplay() {
266
		
265 267
		firstArea.layout();
266 268
		dispoArea.layout();
267 269
		partArea.layout();
......
274 276
	 * Reload properties.
275 277
	 */
276 278
	protected void reloadProperties() {
279
		
277 280
		if (propCombo == null) return;
278 281
		
279 282
		propCombo.removeAll();
......
306 309
	 * @param values the values
307 310
	 */
308 311
	protected void remove(List<String> values) {
312
		
309 313
		for (String s : values)
310 314
			this.availableList.remove(s);
311 315
		availableList.update();
......
317 321
	 * @param s the s
318 322
	 */
319 323
	protected void add(String s) {
324
		
320 325
		this.availableList.add(s);
321 326
		availableList.update();
322 327
	}
......
325 330
	 * Reload property values.
326 331
	 */
327 332
	private void reloadPropertyValues() {
333
		
328 334
		if (availableList == null) return;
329 335
		
330 336
		String[] items;
......
360 366
	 * @return the structure
361 367
	 */
362 368
	public StructuralUnit getStructure() {
369
		
363 370
		try {
364 371
			int index = structCombo.getSelectionIndex();
365 372
			if (index < 0)
366 373
				if (structCombo.getItemCount() > 0)
367 374
					index = 0;
368
				else
369
					return null;
375
				else return null;
370 376
			structure = corpus.getStructuralUnit(structCombo.getItem(index));
371 377
		}
372 378
		catch (CqiClientException e) {
......
382 388
	 * @return the property
383 389
	 */
384 390
	public StructuralUnitProperty getProperty() {
391
		
385 392
		if (getStructure() == null)
386 393
			return null;
387 394
		int index = propCombo.getSelectionIndex();
388 395
		if (index < 0)
389 396
			if (propCombo.getItemCount() > 0)
390 397
				index = 0;
391
			else
392
				return null;
398
			else return null;
393 399
		property = structure.getProperty(propCombo.getItem(index));
394 400
		return property;
395 401
	}
......
400 406
	 * @return the part queries
401 407
	 */
402 408
	public List<String> getPartQueries() {
409
		
403 410
		ArrayList<String> queries = new ArrayList<>();
404 411
		for (PartItem p : parts)
405 412
			queries.add(p.getQuery());
......
412 419
	 * @return the selection
413 420
	 */
414 421
	public List<String> getSelection() {
422
		
415 423
		return Arrays.asList(availableList.getSelection());
416 424
	}
417 425
	
......
440 448
		 * @param _composer the _composer
441 449
		 */
442 450
		public PartItem(Composite parent, int style, PartitionComposer _composer) {
451
			
443 452
			super(parent, style);
444 453
			selfP = this;
445 454
			this.composer = _composer;
......
467 476
				
468 477
				@Override
469 478
				public void widgetSelected(SelectionEvent e) {
479
					
470 480
					PartItem p = selfP;
471 481
					
472 482
					for (String s : p.getColumns())
......
489 499
				
490 500
				@Override
491 501
				public void widgetSelected(SelectionEvent e) {
502
					
492 503
					// System.out.println(Messages.bind(Messages.PartitionComposer_10, composer.getSelection()));
493 504
					for (String s : composer.getSelection())
494 505
						columns.add(s);
......
512 523
				
513 524
				@Override
514 525
				public void widgetSelected(SelectionEvent e) {
526
					
515 527
					// System.out.println(Messages.bind(Messages.PartitionComposer_12, getSelection()));
516 528
					for (String s : getSelection())
517 529
						composer.add(s);
......
541 553
		 * Removes the all.
542 554
		 */
543 555
		public void removeAll() {
556
			
544 557
			columns.removeAll();
545 558
		}
546 559
		
......
550 563
		 * @param string the new title
551 564
		 */
552 565
		public void setTitle(String string) {
566
			
553 567
			this.title.setText(string);
554 568
		}
555 569
		
......
559 573
		 * @return the columns
560 574
		 */
561 575
		public String[] getColumns() {
576
			
562 577
			return columns.getItems();
563 578
		}
564 579
		
......
568 583
		 * @return the query
569 584
		 */
570 585
		public String getQuery() {
586
			
571 587
			return getSelection().toString();
572 588
		}
573 589
		
......
577 593
		 * @return the selection
578 594
		 */
579 595
		public List<String> getSelection() {
596
			
580 597
			return Arrays.asList(columns.getSelection());
581 598
		}
582 599
	}
......
587 604
	 * @return the partition
588 605
	 */
589 606
	public Partition createPartition(String name) {
607
		
590 608
		if (this.parts.size() == 0) {
591 609
			System.out.println(TXMUIMessages.errorColonThisPartitionHasNoPart);
592 610
			return null;
......
624 642
	 * @return true, if successful
625 643
	 */
626 644
	public boolean hasUnassigned() {
645
		
627 646
		return this.availableList.getItemCount() > 0;
628 647
	}
629 648
	
630 649
	public String getGeneratedName() {
650
		
631 651
		// TODO Auto-generated method stub
632 652
		return null;
633 653
	}
TXM/trunk/org.txm.rcp/src/main/java/org/txm/rcp/actions/CreateSubcorpusDialog.java (revision 3592)
148 148
		// TODO : we just put a composite into another composite. Everything
149 149
		// should be directly put into parent
150 150
		GridLayout layout4inclosing = new GridLayout(1, true);
151
		layout4inclosing.verticalSpacing = 0;
152
		layout4inclosing.horizontalSpacing = 0;
151 153
		inclosing.setLayout(layout4inclosing);
152
		inclosing.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, false));
154
		inclosing.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, true));
153 155
		
154 156
		// name panel
155 157
		Composite nameComposite = new Composite(inclosing, SWT.NONE);
TXM/trunk/org.txm.rcp/src/main/java/org/txm/rcp/actions/CreatePartitionDialog.java (revision 3592)
147 147
	 * @param corpus the corpus
148 148
	 */
149 149
	public CreatePartitionDialog(Shell parentShell, CQPCorpus corpus) {
150
		
150 151
		super(parentShell);
151 152
		this.corpus = corpus;
152 153
		this.setShellStyle(this.getShellStyle() | SWT.RESIZE);
......
159 160
	 */
160 161
	@Override
161 162
	protected void configureShell(Shell newShell) {
163
		
162 164
		super.configureShell(newShell);
163 165
		newShell.setText(TXMUIMessages.createPartition);
164 166
		newShell.setMinimumSize(400, 400);
......
170 172
	 */
171 173
	@Override
172 174
	protected Control createDialogArea(Composite parent) {
175
		
173 176
		Composite c = new Composite(parent, SWT.NONE);
174 177
		c.setLayout(new GridLayout(2, false));
175 178
		GridData maindatalayout = new GridData(GridData.FILL, GridData.FILL, true, false);
......
282 285
			
283 286
			@Override
284 287
			public void widgetSelected(SelectionEvent event) {
288
				
285 289
				reloadProperties();
286 290
			}
287 291
		});
......
302 306
			
303 307
			@Override
304 308
			public void widgetSelected(SelectionEvent event) {
309
				
305 310
				selectedStructuralUnitProperty = selectedStructuralUnit
306 311
						.getOrderedProperties().get(propertyCombo.getSelectionIndex());
307 312
			}
......
314 319
		
315 320
		assistedTab.setText(TXMUIMessages.assisted);
316 321
		
317
		compositeForAssisted = new PartitionComposer(tabFolder, SWT.NONE,
318
				this.corpus);
322
		compositeForAssisted = new PartitionComposer(tabFolder, SWT.NONE, this.corpus);
319 323
		assistedTab.setControl(compositeForAssisted);
320 324
		
321 325
		// Third tab: avanced mode
......
329 333
		advanceContainer.setLayout(advanceLayout);
330 334
		advancedTab.setControl(advanceContainer);
331 335
		
332
		scrollComposite = new ScrolledComposite(advanceContainer, SWT.V_SCROLL
333
				| SWT.BORDER);
334
		scrollComposite.setLayoutData(new GridData(GridData.FILL,
335
				GridData.FILL, true, true, 2, 1));
336
		scrollComposite = new ScrolledComposite(advanceContainer, SWT.V_SCROLL | SWT.BORDER);
337
		scrollComposite.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, true, 2, 1));
336 338
		
337 339
		Button plusButton = new Button(advanceContainer, SWT.NONE);
338
		plusButton.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_CENTER,
339
				GridData.FILL, false, false));
340
		plusButton.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_CENTER, GridData.FILL, false, false));
340 341
		plusButton.setText("+"); //$NON-NLS-1$
341 342
		plusButton.addListener(SWT.Selection, new Listener() {
342 343
			
343 344
			@Override
344 345
			public void handleEvent(Event event) {
346
				
345 347
				addQueryField();
346 348
			}
347 349
		});
......
386 388
			
387 389
			@Override
388 390
			public void controlResized(ControlEvent e) {
391
				
389 392
				Rectangle r = scrollComposite.getClientArea();
390 393
				scrollComposite.setMinSize(compositeForAdvanced.computeSize(
391 394
						r.width, SWT.DEFAULT));
......
404 407
			
405 408
			@Override
406 409
			public void widgetSelected(SelectionEvent e) {
410
				
407 411
				// record the tab currently in use
408 412
				if (tabFolder.getSelectionIndex() == 0) {
409 413
					isSimpleSelected = true;
......
430 434
	 * Reload properties.
431 435
	 */
432 436
	private void reloadProperties() {
437
		
433 438
		List<StructuralUnitProperty> properties = null;
434 439
		selectedStructuralUnit = structuralUnitsFinal.get(structuralUnitsCombo
435 440
				.getSelectionIndex());
......
469 474
	 * @return true, if successful
470 475
	 */
471 476
	private boolean noquery() {
477
		
472 478
		for (QueryWidget query : queries) {
473 479
			if (query.getText().length() == 0)
474 480
				return true;
......
482 488
	 * @param composite the composite
483 489
	 */
484 490
	private void createAdvancedQueryField() {
491
		
485 492
		addQueryField();
486 493
		Rectangle r = scrollComposite.getClientArea();
487 494
		scrollComposite.setMinSize(compositeForAdvanced.computeSize(r.width,
......
494 501
	 * @param composite the composite
495 502
	 */
496 503
	private QueryWidget addQueryField() {
504
		
497 505
		return addQueryField(null, null);
498 506
	}
499 507
	
......
504 512
	 * @param value the query
505 513
	 */
506 514
	private QueryWidget addQueryField(String name, String value) {
515
		
507 516
		final Text advancedPartLabel = new Text(compositeForAdvanced, SWT.BORDER);
508 517
		advancedPartLabel.setText(TXMUIMessages.part
509 518
				+ (partNames.size() + 1));
......
533 542
			
534 543
			@Override
535 544
			public void handleEvent(Event event) {
545
				
536 546
				queries.remove(queryText);
537 547
				partNames.remove(advancedPartLabel);
538 548
				advancedPartLabel.dispose();
......
589 599
	 * @return true, if is advanced selected
590 600
	 */
591 601
	public boolean isAdvancedSelected() {
602
		
592 603
		return isAdvancedSelected;
593 604
	}
594 605
	
......
598 609
	 * @return the structural unit
599 610
	 */
600 611
	public StructuralUnit getStructuralUnit() {
612
		
601 613
		if (isAdvancedSelected())
602 614
			throw new IllegalStateException(TXMUIMessages.cannotAskForTheSimpleTabWhenTheUserHasSelectedTheAdvancedTab);
603 615
		return selectedStructuralUnit;
......
609 621
	 * @return the structural unit property
610 622
	 */
611 623
	public StructuralUnitProperty getStructuralUnitProperty() {
624
		
612 625
		if (isAdvancedSelected())
613 626
			throw new IllegalStateException(TXMUIMessages.cannotAskForTheSimpleTabWhenTheUserHasSelectedTheAdvancedTab);
614 627
		return selectedStructuralUnitProperty;
......
620 633
	 * @return the queries
621 634
	 */
622 635
	public List<String> getQueries() {
636
		
623 637
		if (!isAdvancedSelected())
624 638
			throw new IllegalStateException(TXMUIMessages.cannotAskForTheSimpleTabWhenTheUserHasSelectedTheAdvancedTab);
625 639
		return queriesString;
......
702 716
	 * @return the advance part names
703 717
	 */
704 718
	private List<String> getAdvancePartNames() {
719
		
705 720
		ArrayList<String> values = new ArrayList<>();
706 721
		int count = 0;
707 722
		for (Text t : partNames) {
......
719 734
	 * @return the partition
720 735
	 */
721 736
	public Partition getPartition() {
737
		
722 738
		return partition;
723 739
	}
724 740
}

Formats disponibles : Unified diff