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;
|