Révision 3564

TXM/trunk/org.txm.links.rcp/src/org/txm/links/rcp/handlers/SendSelectionToQueryable.java (revision 3564)
44 44
 * @author sjacquot
45 45
 * 
46 46
 */
47
// FIXME: SJ: improvements:
48
// - create an interface as SeletionSendableAsQueries with method createQueries() or buildQueries() or getQueries()
49
// - instead of subclassing this class, Editors can implement SeletionSendableAsQueries interface and the method
47 50
public abstract class SendSelectionToQueryable extends BaseAbstractHandler {
48 51
	
49 52
	/**
TXM/trunk/org.txm.core/src/java/org/txm/core/preferences/TXMPreferences.java (revision 3564)
211 211
	public static final String N_LINES_PER_PAGE = "n_lines_per_page"; //$NON-NLS-1$
212 212
	
213 213
	/**
214
	 * Current page number.
215
	 */
216
	public static final String CURRENT_PAGE = "current_page"; //$NON-NLS-1$
217
	
218
	/**
214 219
	 * Encoding.
215 220
	 */
216 221
	public final static String ENCODING = "encoding"; //$NON-NLS-1$
TXM/trunk/org.txm.lexicaltable.rcp/src/org/txm/lexicaltable/rcp/editors/LexicalTableEditor.java (revision 3564)
139 139
	/**
140 140
	 * Unit property.
141 141
	 */
142
	@Parameter(key = LexicalTablePreferences.UNIT_PROPERTY)
142
	@Parameter(key = TXMPreferences.UNIT_PROPERTY)
143 143
	protected PropertiesComboViewer unitPropertyComboViewer;
144 144
	
145 145
	
146 146
	/**
147 147
	 * Minimum frequency filter spinner.
148 148
	 */
149
	@Parameter(key = LexicalTablePreferences.F_MIN)
149
	@Parameter(key = TXMPreferences.F_MIN)
150 150
	protected Spinner fMinSpinner;
151 151
	
152 152
	/**
153 153
	 * Minimum frequency filter spinner.
154 154
	 */
155
	@Parameter(key = LexicalTablePreferences.F_MAX)
155
	@Parameter(key = TXMPreferences.F_MAX)
156 156
	protected Spinner fMaxSpinner;
157 157
	
158 158
	/**
159 159
	 * Maximum numbers of lines spinner.
160 160
	 */
161
	@Parameter(key = LexicalTablePreferences.V_MAX)
161
	@Parameter(key = TXMPreferences.V_MAX)
162 162
	protected Spinner vMaxSpinner;
163 163
	
164 164
	/**
TXM/trunk/org.txm.index.rcp/src/org/txm/index/rcp/editors/IndexEditor.java (revision 3564)
222 222
		propertiesSelector.addSelectionListener(computeSelectionListener);
223 223
		
224 224
		
225
		// extended parameters
225
		// Extended parameters
226 226
		
227 227
		// Filters
228 228
		ThresholdsGroup thresholdsGroup = new ThresholdsGroup(this.getExtendedParametersGroup(), this);
......
248 248
		
249 249
		
250 250
		
251
		// Bottom toolbar
251
		// Bottom tool bar
252 252
		navigationArea = new NavigationWidget(infosArea, SWT.NONE);
253 253
		navigationArea.setLayoutData(new GridData(SWT.CENTER, SWT.FILL, true, false));
254 254
		
......
319 319
		lFminInfo.setText(""); //$NON-NLS-1$
320 320
		// lFminInfo.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false));
321 321
		
322
		// results
322
		
323
		
324
		// Result area
323 325
		Composite resultArea = this.getResultArea();
324 326
		
325 327
		viewer = new TableViewer(resultArea, SWT.MULTI | SWT.FULL_SELECTION | SWT.BORDER | SWT.VIRTUAL);
......
414 416
		separatorColumn = new TableColumn(viewer.getTable(), SWT.LEFT);
415 417
		separatorColumn.setText(""); //$NON-NLS-1$
416 418
		separatorColumn.pack();
419
		
420
		
421
		
417 422
		extendedParametersComposite.pack();
418 423
		
419 424
		// Add double click, "Send to" command
TXM/trunk/org.txm.internalview.rcp/src/org/txm/internalview/rcp/handlers/SendInternalViewTo.java (revision 3564)
33 33
import org.eclipse.ui.handlers.HandlerUtil;
34 34
import org.txm.internalview.rcp.editors.InternalViewEditor;
35 35
import org.txm.links.rcp.handlers.SendSelectionToQueryable;
36
import org.txm.searchengine.cqp.corpus.query.CQLQuery;
36 37

  
37 38
/**
38 39
 * Sends the selected lines of an internal view to compute another command.
......
53 54
		return null;
54 55
	}
55 56
	
57
	@Override
58
	public String createQueries(ExecutionEvent event, ISelection selection) {
59
		if (selection instanceof StructuredSelection) {
60
			StructuredSelection sselection = (StructuredSelection) selection;
61
			//FIXME: SJ: the selection is not used
62
			return CQLQuery.queriesToString(((InternalViewEditor) HandlerUtil.getActiveWorkbenchWindow(event).getActivePage().getActivePart()).createQueries());
63
		}
64
		return null;
65
	}
66

  
56 67
	
57
	
58 68
}
TXM/trunk/org.txm.internalview.rcp/src/org/txm/internalview/rcp/editors/InternalViewEditor.java (revision 3564)
25 25
import org.eclipse.swt.widgets.TableColumn;
26 26
import org.eclipse.swt.widgets.TableItem;
27 27
import org.txm.core.messages.TXMCoreMessages;
28
import org.txm.core.preferences.TXMPreferences;
28 29
import org.txm.core.results.Parameter;
29 30
import org.txm.internalview.core.functions.InternalView;
30 31
import org.txm.internalview.core.preferences.InternalViewPreferences;
......
34 35
import org.txm.rcp.editors.listeners.ComputeKeyListener;
35 36
import org.txm.rcp.editors.listeners.ComputeSelectionListener;
36 37
import org.txm.rcp.messages.TXMUIMessages;
38
import org.txm.rcp.swt.GLComposite;
39
import org.txm.rcp.swt.widget.LabeledSpinner;
37 40
import org.txm.rcp.swt.widget.NewNavigationWidget;
38 41
import org.txm.rcp.swt.widget.PropertiesSelector;
39 42
import org.txm.rcp.swt.widget.structures.StructuralUnitsComboViewer;
43
import org.txm.searchengine.core.Query;
40 44
import org.txm.searchengine.cqp.CQPSearchEngine;
41 45
import org.txm.searchengine.cqp.clientExceptions.CqiClientException;
42 46
import org.txm.searchengine.cqp.corpus.CQPCorpus;
......
75 79
	/**
76 80
	 * For current page parameter synchronization.
77 81
	 */
78
	@Parameter(key = InternalViewPreferences.CURRENT_PAGE)
82
	@Parameter(key = TXMPreferences.CURRENT_PAGE)
79 83
	protected NewNavigationWidget navigation;
80 84
	
81 85
	/**
82 86
	 * Structural unit to explore.
83 87
	 */
84
	@Parameter(key = InternalViewPreferences.STRUCTURAL_UNIT)
88
	@Parameter(key = TXMPreferences.STRUCTURAL_UNIT)
85 89
	protected StructuralUnitsComboViewer structuralUnitsComboViewer;
86 90
	
87 91
	/**
88 92
	 * Word properties to display.
89 93
	 */
90
	@Parameter(key = InternalViewPreferences.UNIT_PROPERTIES)
94
	@Parameter(key = TXMPreferences.UNIT_PROPERTIES)
91 95
	protected PropertiesSelector<WordProperty> propertiesSelector;
92 96
	
93 97
	/**
94 98
	 * Structural units to display.
95 99
	 */
96
	@Parameter(key = InternalViewPreferences.STRUCTURAL_UNIT_PROPERTIES)
100
	@Parameter(key = TXMPreferences.STRUCTURAL_UNIT_PROPERTIES)
97 101
	protected PropertiesSelector<StructuralUnitProperty> structuralUnitPropertiesSelector;
98 102
	
99 103
	/**
100 104
	 * Number of lines to display.
101 105
	 */
102
	@Parameter(key = InternalViewPreferences.N_LINES_PER_PAGE)
106
	@Parameter(key = TXMPreferences.N_LINES_PER_PAGE)
103 107
	protected Spinner nLinesPerPagesSpinner;
104 108
	
105 109
	@Override
......
112 116
		ComputeKeyListener computeKeyListener = new ComputeKeyListener(this);
113 117
		
114 118
		
115
		Composite parametersArea = getExtendedParametersGroup();
116
		parametersArea.setLayout(new GridLayout(6, false));
117
		parametersArea.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, false));
118
		
119
		Composite resultPanel = getResultArea();
120
		
119
		// Main parameters
120
		GLComposite mainParametersArea = this.getMainParametersComposite();
121
		mainParametersArea.getLayout().numColumns = 2;
122

  
121 123
		// Structural unit selector
122
		Label structComboLabel = new Label(parametersArea, SWT.NONE);
124
		Label structComboLabel = new Label(mainParametersArea, SWT.NONE);
123 125
		structComboLabel.setText(InternalViewUIMessages.structure);
124 126
		structComboLabel.setLayoutData(new GridData(GridData.CENTER, GridData.CENTER, false, true));
125
		this.structuralUnitsComboViewer = new StructuralUnitsComboViewer(parametersArea, this, true);
127
		this.structuralUnitsComboViewer = new StructuralUnitsComboViewer(mainParametersArea, this, true);
126 128
		// Listener
127 129
		this.structuralUnitsComboViewer.addSelectionChangedListener(new ISelectionChangedListener() {
128 130
			
......
132 134
				structuralUnitPropertiesSelector.setSelectedProperty(0);
133 135
			}
134 136
		});
137

  
135 138
		
139
		// Extended parameters
140
		Composite parametersArea = getExtendedParametersGroup();
141
		parametersArea.setLayout(new GridLayout(4, false));
142
		
136 143
		// Word properties selector
137 144
		propertiesSelector = new PropertiesSelector<>(parametersArea);
138 145
		propertiesSelector.setLayoutData(new GridData(GridData.CENTER, GridData.CENTER, false, true));
......
155 162
		structuralUnitPropertiesSelector.setTitle(InternalViewUIMessages.structuralProperties);
156 163
		structuralUnitPropertiesSelector.addSelectionListener(computeSelectionListener);
157 164
		
158
		new Label(parametersArea, SWT.NONE).setText(TXMUIMessages.numberOfLines);
159
		nLinesPerPagesSpinner = new Spinner(parametersArea, SWT.NONE);
165
		
166
		// Number of lines per page
167
		LabeledSpinner nLinesPerPagesLabeledSpinner= new LabeledSpinner(this.getExtendedParametersGroup(), this, TXMUIMessages.numberOfLines);
168
		nLinesPerPagesSpinner = nLinesPerPagesLabeledSpinner.getSpinner();
160 169
		nLinesPerPagesSpinner.setMinimum(1);
161 170
		nLinesPerPagesSpinner.setMaximum(Integer.MAX_VALUE);
162
		nLinesPerPagesSpinner.addSelectionListener(computeSelectionListener);
163
		nLinesPerPagesSpinner.addKeyListener(computeKeyListener);
171

  
164 172
		
165
		navigationPanel = getBottomToolbar().installGLComposite(InternalViewUIMessages.navigation, 4, false);
166
		navigationPanel.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, false));
173
		// Result area
174
		Composite resultPanel = getResultArea();
167 175
		
168
		
169
		// Navigation widget
170
		navigation = new NewNavigationWidget(navigationPanel);
171
		navigation.setLayoutData(new GridData(GridData.FILL, GridData.FILL, false, true));
172
		navigation.addGoToKeyListener(computeKeyListener);
173
		
174
		
175
		// Listeners
176
		navigation.addFirstListener(computeSelectionListener);
177
		navigation.addPreviousListener(computeSelectionListener);
178
		navigation.addNextListener(computeSelectionListener);
179
		navigation.addLastListener(computeSelectionListener);
180
		
181
		
182
		structInfos = new Label(navigationPanel, SWT.NONE);
183
		structInfos.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true, true));
184
		structInfos.setText(""); //$NON-NLS-1$
185
		
186
		// Button style = new Button(navigationPanel, SWT.RADIO);
187
		// style.setText("table");
188
		
189 176
		viewer = new TableViewer(resultPanel, SWT.FULL_SELECTION | SWT.VIRTUAL);
190 177
		viewer.getTable().addKeyListener(new TableKeyListener(viewer));
191 178
		viewer.getTable().setLinesVisible(true);
......
244 231
			}
245 232
		});
246 233
		
234
		
235

  
236
		// Bottom tool bar 
237
		navigationPanel = getBottomToolbar().installGLComposite(InternalViewUIMessages.navigation, 4, false);
238
		navigationPanel.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, false));
239
		
240
		// Navigation widget
241
		navigation = new NewNavigationWidget(navigationPanel);
242
		navigation.setLayoutData(new GridData(GridData.FILL, GridData.FILL, false, true));
243
		navigation.addGoToKeyListener(computeKeyListener);
244
		
245
		// Listeners
246
		navigation.addFirstListener(computeSelectionListener);
247
		navigation.addPreviousListener(computeSelectionListener);
248
		navigation.addNextListener(computeSelectionListener);
249
		navigation.addLastListener(computeSelectionListener);
250
		
251
		
252
		structInfos = new Label(navigationPanel, SWT.NONE);
253
		structInfos.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true, true));
254
		structInfos.setText(""); //$NON-NLS-1$
255
		
256
		// Button style = new Button(navigationPanel, SWT.RADIO);
257
		// style.setText("table");
258

  
259
		
247 260
		// Register the context menu
248 261
		TXMEditor.initContextMenu(this.viewer.getTable(), this.getSite(), this.viewer);
249 262
		
......
317 330
			}
318 331
		}
319 332
	}
333

  
320 334
	
335
	/**
336
	 * Creates a queries list from the selected table lines.
337
	 * @return a queries list based on the selected lines
338
	 */
339
	public List<Query> createQueries() {
340
		List<Query> queries = new ArrayList<>();
341
		queries.add(new CQLQuery(this.createQuery()));
342
		return queries;
343
	}
321 344
	
345

  
346
	/**
347
	 * Creates a query string from the selected table lines.
348
	 * @return a query string based on the selected lines
349
	 */
322 350
	public String createQuery() {
323 351
		TableColumn[] cols = viewer.getTable().getColumns();
324 352
		TableItem[] items = viewer.getTable().getItems();
......
354 382
			query.append("\""); //$NON-NLS-1$
355 383
		}
356 384
		query.append("]"); //$NON-NLS-1$
357
		System.out.println(NLS.bind(InternalViewUIMessages.queryColonP0, query));
385
		Log.info(NLS.bind(InternalViewUIMessages.queryColonP0, query));
358 386
		return query.toString();
359 387
	}
360 388
	
389
	
390
	
391
	
361 392
	public boolean backToText(Match m) {
362 393
		// Match m = line.getMatch();
363 394
		internalView.getCurrentPage();
......
373 404
			return goToPage(n[0]);
374 405
		}
375 406
		catch (Exception e) {
376
			System.out.println(NLS.bind(InternalViewUIMessages.errorWhileInternalViewGoBackToP0, m));
407
			Log.info(NLS.bind(InternalViewUIMessages.errorWhileInternalViewGoBackToP0, m));
377 408
			Log.printStackTrace(e);
378 409
		}
379 410
		return false;
TXM/trunk/org.txm.internalview.core/src/org/txm/internalview/core/preferences/InternalViewPreferences.java (revision 3564)
13 13
 */
14 14
public class InternalViewPreferences extends TXMPreferences {
15 15
	
16
	/**
17
	 * Current page number.
18
	 */
19
	public static final String CURRENT_PAGE = "current_page"; //$NON-NLS-1$
20 16
	
21
	
22 17
	/**
23 18
	 * Gets the instance.
24 19
	 * 

Formats disponibles : Unified diff