Révision 1492

tmp/org.txm.rcp/src/main/java/org/txm/rcp/swt/dialog/QueryAssistDialog.java (revision 1492)
171 171

  
172 172
			addWordField();
173 173

  
174
//			Composite withinComposite = new Composite(mainPanel, SWT.NONE);
175
//			withinComposite.setLayout(new GridLayout(2, false));
176
//			withinButton = new Button(withinComposite, SWT.CHECK);
177
//			withinButton.setText("within structure: ");
178
//			withinButton.addSelectionListener(new SelectionListener() {
179
//				@Override
180
//				public void widgetSelected(SelectionEvent e) {
181
//					structsCombo.setEnabled(withinButton.getSelection());
182
//				}
183
//				
184
//				@Override
185
//				public void widgetDefaultSelected(SelectionEvent e) { }
186
//			});
187
//			structsCombo = new Combo(withinComposite, SWT.READ_ONLY);
188
//			structsCombo.setEnabled(false);
189
//			int iText = 0;
190
//			List<StructuralUnit> sus = corpus.getOrderedStructuralUnits();
191
//			for (int i = 0 ; i < sus.size() ; i++) {
192
//				StructuralUnit su = sus.get(i);
193
//				if (su.getName().equals("txmcorpus")) continue;
194
//				structsCombo.add(su.getName());
195
//				if (su.getName().equals("text")) iText = i;
196
//			}
197
//			if (structsCombo.getItemCount() > 0) structsCombo.select(iText);
174
			Composite withinComposite = new Composite(mainPanel, SWT.NONE);
175
			withinComposite.setLayout(new GridLayout(2, false));
176
			withinButton = new Button(withinComposite, SWT.CHECK);
177
			withinButton.setText("within structure: ");
178
			withinButton.setToolTipText("Check to add structure contraint");
179
			withinButton.addSelectionListener(new SelectionListener() {
180
				@Override
181
				public void widgetSelected(SelectionEvent e) {
182
					structsCombo.setEnabled(withinButton.getSelection());
183
				}
184
				
185
				@Override
186
				public void widgetDefaultSelected(SelectionEvent e) { }
187
			});
188
			structsCombo = new Combo(withinComposite, SWT.READ_ONLY);
189
			structsCombo.setToolTipText("The available structures");
190
			structsCombo.setEnabled(false);
191
			int iText = 0;
192
			List<StructuralUnit> sus = corpus.getOrderedStructuralUnits();
193
			for (int i = 0 ; i < sus.size() ; i++) {
194
				StructuralUnit su = sus.get(i);
195
				if (su.getName().equals("txmcorpus")) continue;
196
				structsCombo.add(su.getName());
197
				if (su.getName().equals("text")) iText = i;
198
			}
199
			if (structsCombo.getItemCount() > 0) structsCombo.select(iText);
198 200
			
199 201
			Button addwordButton = new Button(mainPanel, SWT.PUSH);
200 202
			addwordButton.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, false));
......
253 255
		this.query = ""; //$NON-NLS-1$
254 256
		this.query = wordfields.get(0).getQuery();
255 257
		for (int i = 1; i < wordfields.size(); i++) {
258
			query += " "; //$NON-NLS-1$
256 259
			LinkField lf = linkfields.get(i - 1);
257 260
			WordField wf = wordfields.get(i);
258 261
			query += lf.getQuery();
259 262
			query += wf.getQuery();
260
			query += " "; //$NON-NLS-1$
261 263
		}
262 264
		
263 265
		if (withinButton != null && withinButton.getSelection() && structsCombo.getText().length() > 0) {
......
297 299
		/** The value t. */
298 300
		Text valueT;
299 301
		
302
		Button targetButton;
303
		
300 304
		Button removeButton;
301 305

  
302 306
		/**
......
313 317

  
314 318
			Label titleL = new Label(this, SWT.NONE);
315 319
			titleL.setText(NLS.bind(TXMUIMessages.aWordWithItsProperty, no));
316
			GridData datalayout = new GridData(GridData.FILL, GridData.CENTER,
317
					true, false);
320
			GridData datalayout = new GridData(GridData.FILL, GridData.CENTER, true, false);
318 321
			titleL.setLayoutData(datalayout);
319 322

  
320 323
			propCombo = new Combo(this, SWT.READ_ONLY | SWT.SINGLE);
324
			propCombo.setToolTipText("Property to test");
321 325
			if (properties != null) {
322 326
				for (Property p : properties)
323 327
					propCombo.add(p.getName());
......
325 329
			}
326 330

  
327 331
			testCombo = new Combo(this, SWT.READ_ONLY | SWT.SINGLE);
332
			testCombo.setToolTipText("Test to do");
328 333
			testCombo.add(TXMUIMessages.equalsTo);
329 334
			testCombo.add(TXMUIMessages.startsWith);
330 335
			testCombo.add(TXMUIMessages.endsWith);
......
332 337
			testCombo.select(0);
333 338

  
334 339
			valueT = new Text(this, SWT.SINGLE | SWT.BORDER);
340
			valueT.setToolTipText("The word property value");
335 341
			GridData gdata = new GridData(GridData.FILL, GridData.FILL, false, false);
336 342
			gdata.widthHint = 150;
337 343
			gdata.minimumWidth = 150;
338 344
			valueT.setLayoutData(gdata);
345
			
346
			targetButton = new Button(this, SWT.CHECK);
347
			targetButton.setToolTipText("Check to target the word in the query");
348
			targetButton.addSelectionListener(new SelectionListener() {
349
				
350
				@Override
351
				public void widgetSelected(SelectionEvent e) {
352
					if (targetButton.getSelection()) {
353
						for (WordField wf : wordfields) {
354
							wf.targetButton.setSelection(false);
355
						}
356
						targetButton.setSelection(true);
357
					}
358
				}
359
				
360
				@Override
361
				public void widgetDefaultSelected(SelectionEvent e) { }
362
			});
363
			
364
			
339 365
//			removeButton = new Button(this, SWT.PUSH);
340 366
//			removeButton.setImage(IImageKeys.getImage(IImageKeys.ACTION_DELETE));
341 367
//			removeButton.addSelectionListener(new SelectionListener() {
......
376 402
		 * @return the query
377 403
		 */
378 404
		public String getQuery() {
379
			String query = "["; //$NON-NLS-1$
405
			String query = "";
406
			if (targetButton.getSelection()) {
407
				query += "@";
408
			}
409
			query += "["; //$NON-NLS-1$
380 410
			query += propCombo.getItem(propCombo.getSelectionIndex());
381 411
			if (testCombo.getSelectionIndex() == 0)// equals
382 412
				query += "=\"" + valueT.getText().replace("\"", "\\\"") + "\""; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$

Formats disponibles : Unified diff