Révision 1481
tmp/org.txm.index.rcp/src/org/txm/index/rcp/editors/PartitionIndexEditor.java (revision 1481) | ||
---|---|---|
68 | 68 |
import org.txm.searchengine.core.Query; |
69 | 69 |
import org.txm.searchengine.cqp.clientExceptions.CqiClientException; |
70 | 70 |
import org.txm.searchengine.cqp.corpus.CQPCorpus; |
71 |
import org.txm.searchengine.cqp.corpus.Part; |
|
71 | 72 |
import org.txm.searchengine.cqp.corpus.Property; |
72 | 73 |
import org.txm.searchengine.cqp.corpus.WordProperty; |
73 | 74 |
import org.txm.statsengine.r.rcp.views.RVariablesView; |
... | ... | |
144 | 145 |
@Parameter(key=TXMPreferences.V_MAX) |
145 | 146 |
protected Spinner vMaxSpinner; |
146 | 147 |
|
147 |
|
|
148 |
|
|
148 | 149 |
/** The N ligne p page spinner. */ |
149 | 150 |
@Parameter(key=TXMPreferences.N_LINES_PER_PAGE) |
150 | 151 |
protected Spinner nLinesPerPageSpinner; |
151 |
|
|
152 |
|
|
152 | 153 |
/** |
153 | 154 |
* Word properties selector. |
154 | 155 |
*/ |
155 | 156 |
@Parameter(key=TXMPreferences.UNIT_PROPERTIES) |
156 | 157 |
protected PropertiesSelector<WordProperty> propertiesSelector; |
157 |
|
|
158 |
|
|
158 | 159 |
/** |
159 | 160 |
* Creates the part control. |
160 | 161 |
* |
... | ... | |
164 | 165 |
@Override |
165 | 166 |
public void _createPartControl() { |
166 | 167 |
|
167 |
|
|
168 |
|
|
168 | 169 |
this.index = (PartitionIndex) this.getResult(); |
169 |
|
|
170 |
|
|
170 | 171 |
// Computing listeners |
171 | 172 |
ComputeSelectionListener computeSelectionListener = new ComputeSelectionListener(this); |
172 | 173 |
ComputeKeyListener computeKeyListener = new ComputeKeyListener(this); |
173 |
|
|
174 |
|
|
174 | 175 |
Composite extendedParametersComposite = this.getExtendedParametersGroup(); |
175 |
// paramArea.setLayout(new FormLayout()); |
|
176 |
// paramArea.setLayout(new FormLayout());
|
|
176 | 177 |
|
177 | 178 |
// info&navigation panel |
178 | 179 |
final GLComposite infosArea = this.getBottomToolbar().installGLComposite(IndexUIMessages.infos, 1, false); |
179 | 180 |
infosArea.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, false)); |
180 | 181 |
infosArea.getLayout().numColumns = 5; // nav panel + labels |
181 |
|
|
182 |
// // on créé une Query, ici le pivot de la concordance est "[]" |
|
183 |
// // Query Area: query itself + view properties |
|
184 |
// Composite queryArea = new Composite(paramArea, SWT.NONE); |
|
185 |
// |
|
186 |
// FormData queryLayoutData = new FormData(); |
|
187 |
// queryLayoutData.top = new FormAttachment(0); |
|
188 |
// queryLayoutData.left = new FormAttachment(0); |
|
189 |
// queryLayoutData.right = new FormAttachment(100); |
|
190 |
// queryArea.setLayoutData(queryLayoutData); |
|
191 |
// |
|
192 |
// queryArea.setLayout(new GridLayout(4, false)); |
|
193 | 182 |
|
183 |
// // on créé une Query, ici le pivot de la concordance est "[]" |
|
184 |
// // Query Area: query itself + view properties |
|
185 |
// Composite queryArea = new Composite(paramArea, SWT.NONE); |
|
186 |
// |
|
187 |
// FormData queryLayoutData = new FormData(); |
|
188 |
// queryLayoutData.top = new FormAttachment(0); |
|
189 |
// queryLayoutData.left = new FormAttachment(0); |
|
190 |
// queryLayoutData.right = new FormAttachment(100); |
|
191 |
// queryArea.setLayoutData(queryLayoutData); |
|
192 |
// |
|
193 |
// queryArea.setLayout(new GridLayout(4, false)); |
|
194 |
|
|
194 | 195 |
// | Query: [ (v)] [Search] | |
195 |
|
|
196 |
|
|
196 | 197 |
// Main parameters |
197 | 198 |
// Query |
198 | 199 |
this.getMainParametersComposite().getLayout().numColumns = 3; |
199 | 200 |
// make the zone expandable to display the longest query field |
200 | 201 |
this.getMainParametersComposite().setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, false)); |
201 |
|
|
202 |
|
|
202 | 203 |
// Query: |
203 | 204 |
queryLabel = new Label(this.getMainParametersComposite(), SWT.NONE); |
204 | 205 |
queryLabel.setText(TXMCoreMessages.common_query); |
... | ... | |
212 | 213 |
queryWidget.setLayoutData(layoutData); |
213 | 214 |
queryWidget.addKeyListener(computeKeyListener); |
214 | 215 |
|
215 |
|
|
216 |
|
|
216 | 217 |
// Word properties selector |
217 | 218 |
propertiesSelector = new PropertiesSelector<WordProperty>(this.getMainParametersComposite(), SWT.NONE); |
218 | 219 |
propertiesSelector.setLayoutData(new GridData(GridData.FILL, GridData.FILL, false, false)); |
... | ... | |
226 | 227 |
} |
227 | 228 |
// Listener |
228 | 229 |
propertiesSelector.addSelectionListener(computeSelectionListener); |
229 |
|
|
230 |
|
|
230 |
|
|
231 |
|
|
231 | 232 |
// extended parameters |
232 |
|
|
233 |
|
|
233 | 234 |
// FIXME: old version |
234 | 235 |
// Filters |
235 |
// Composite filtercontrols = new Composite(paramArea, SWT.NONE); |
|
236 |
// FormData filtersLayoutData = new FormData(); |
|
237 |
// filtersLayoutData.top = new FormAttachment(queryArea, 0); |
|
238 |
// filtersLayoutData.bottom = new FormAttachment(100); |
|
239 |
// filtersLayoutData.left = new FormAttachment(0); |
|
240 |
// filtersLayoutData.right = new FormAttachment(100); |
|
241 |
// filtercontrols.setLayoutData(filtersLayoutData); |
|
242 |
// |
|
243 |
// GridLayout gridLayout = new GridLayout(); |
|
244 |
// gridLayout.numColumns = 9; |
|
245 |
// gridLayout.makeColumnsEqualWidth = false; |
|
246 |
// filtercontrols.setLayout(gridLayout); |
|
247 |
// |
|
248 |
// Label tmp = new Label(filtercontrols, SWT.NONE); |
|
249 |
// tmp.setText(TXMCoreMessages.common_thresholds); |
|
250 |
// tmp.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false)); |
|
251 |
// |
|
252 |
// Label lFmin = new Label(filtercontrols, SWT.NONE); |
|
253 |
// lFmin.setText(TXMCoreMessages.common_fMin); |
|
254 |
// lFmin.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false)); |
|
255 |
// |
|
256 |
// GridData fieldsGridData = new GridData(GridData.VERTICAL_ALIGN_END); |
|
257 |
// fieldsGridData.minimumWidth = 100; |
|
258 |
// |
|
259 |
// fMinSpinner = new Spinner(filtercontrols, SWT.BORDER); |
|
260 |
// fMinSpinner.setMinimum(0); |
|
261 |
// fMinSpinner.setMaximum(9999999); |
|
262 |
// fMinSpinner.setIncrement(1); |
|
263 |
// fMinSpinner.setPageIncrement(100); |
|
264 |
// fMinSpinner.setLayoutData(fieldsGridData); |
|
265 |
// fMinSpinner.addKeyListener(computeKeyListener); |
|
266 |
// fMinSpinner.addSelectionListener(computeSelectionListener); |
|
267 |
// |
|
268 |
// Label lFmax = new Label(filtercontrols, SWT.NONE); |
|
269 |
// lFmax.setText(TXMCoreMessages.common_fMax); |
|
270 |
// lFmax.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false)); |
|
271 |
// |
|
272 |
// fMaxSpinner = new Spinner(filtercontrols, SWT.BORDER); |
|
273 |
// fMaxSpinner.setMinimum(0); |
|
274 |
// fMaxSpinner.setMaximum(9999999); |
|
275 |
// fMaxSpinner.setIncrement(1); |
|
276 |
// fMaxSpinner.setPageIncrement(100); |
|
277 |
// fMaxSpinner.setLayoutData(fieldsGridData); |
|
278 |
// fMaxSpinner.addKeyListener(computeKeyListener); |
|
279 |
// fMaxSpinner.addSelectionListener(computeSelectionListener); |
|
280 |
// |
|
281 |
// Label lVmax = new Label(filtercontrols, SWT.NONE); |
|
282 |
// lVmax.setText(TXMCoreMessages.VMAX_1); |
|
283 |
// lVmax.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false)); |
|
284 |
// |
|
285 |
// vMaxSpinner = new Spinner(filtercontrols, SWT.BORDER); |
|
286 |
// vMaxSpinner.setMinimum(0); |
|
287 |
// vMaxSpinner.setMaximum(9999999); |
|
288 |
// vMaxSpinner.setIncrement(1); |
|
289 |
// vMaxSpinner.setPageIncrement(100); |
|
290 |
// vMaxSpinner.setLayoutData(fieldsGridData); |
|
291 |
// vMaxSpinner.addKeyListener(computeKeyListener); |
|
292 |
// vMaxSpinner.addSelectionListener(computeSelectionListener); |
|
236 |
// Composite filtercontrols = new Composite(paramArea, SWT.NONE);
|
|
237 |
// FormData filtersLayoutData = new FormData();
|
|
238 |
// filtersLayoutData.top = new FormAttachment(queryArea, 0);
|
|
239 |
// filtersLayoutData.bottom = new FormAttachment(100);
|
|
240 |
// filtersLayoutData.left = new FormAttachment(0);
|
|
241 |
// filtersLayoutData.right = new FormAttachment(100);
|
|
242 |
// filtercontrols.setLayoutData(filtersLayoutData);
|
|
243 |
//
|
|
244 |
// GridLayout gridLayout = new GridLayout();
|
|
245 |
// gridLayout.numColumns = 9;
|
|
246 |
// gridLayout.makeColumnsEqualWidth = false;
|
|
247 |
// filtercontrols.setLayout(gridLayout);
|
|
248 |
//
|
|
249 |
// Label tmp = new Label(filtercontrols, SWT.NONE);
|
|
250 |
// tmp.setText(TXMCoreMessages.common_thresholds);
|
|
251 |
// tmp.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false));
|
|
252 |
//
|
|
253 |
// Label lFmin = new Label(filtercontrols, SWT.NONE);
|
|
254 |
// lFmin.setText(TXMCoreMessages.common_fMin);
|
|
255 |
// lFmin.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false));
|
|
256 |
//
|
|
257 |
// GridData fieldsGridData = new GridData(GridData.VERTICAL_ALIGN_END);
|
|
258 |
// fieldsGridData.minimumWidth = 100;
|
|
259 |
//
|
|
260 |
// fMinSpinner = new Spinner(filtercontrols, SWT.BORDER);
|
|
261 |
// fMinSpinner.setMinimum(0);
|
|
262 |
// fMinSpinner.setMaximum(9999999);
|
|
263 |
// fMinSpinner.setIncrement(1);
|
|
264 |
// fMinSpinner.setPageIncrement(100);
|
|
265 |
// fMinSpinner.setLayoutData(fieldsGridData);
|
|
266 |
// fMinSpinner.addKeyListener(computeKeyListener);
|
|
267 |
// fMinSpinner.addSelectionListener(computeSelectionListener);
|
|
268 |
//
|
|
269 |
// Label lFmax = new Label(filtercontrols, SWT.NONE);
|
|
270 |
// lFmax.setText(TXMCoreMessages.common_fMax);
|
|
271 |
// lFmax.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false));
|
|
272 |
//
|
|
273 |
// fMaxSpinner = new Spinner(filtercontrols, SWT.BORDER);
|
|
274 |
// fMaxSpinner.setMinimum(0);
|
|
275 |
// fMaxSpinner.setMaximum(9999999);
|
|
276 |
// fMaxSpinner.setIncrement(1);
|
|
277 |
// fMaxSpinner.setPageIncrement(100);
|
|
278 |
// fMaxSpinner.setLayoutData(fieldsGridData);
|
|
279 |
// fMaxSpinner.addKeyListener(computeKeyListener);
|
|
280 |
// fMaxSpinner.addSelectionListener(computeSelectionListener);
|
|
281 |
//
|
|
282 |
// Label lVmax = new Label(filtercontrols, SWT.NONE);
|
|
283 |
// lVmax.setText(TXMCoreMessages.VMAX_1);
|
|
284 |
// lVmax.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false));
|
|
285 |
//
|
|
286 |
// vMaxSpinner = new Spinner(filtercontrols, SWT.BORDER);
|
|
287 |
// vMaxSpinner.setMinimum(0);
|
|
288 |
// vMaxSpinner.setMaximum(9999999);
|
|
289 |
// vMaxSpinner.setIncrement(1);
|
|
290 |
// vMaxSpinner.setPageIncrement(100);
|
|
291 |
// vMaxSpinner.setLayoutData(fieldsGridData);
|
|
292 |
// vMaxSpinner.addKeyListener(computeKeyListener);
|
|
293 |
// vMaxSpinner.addSelectionListener(computeSelectionListener);
|
|
293 | 294 |
|
294 |
|
|
295 |
|
|
295 | 296 |
// FIXME: new version |
296 | 297 |
// Filters |
297 | 298 |
ThresholdsGroup thresholdsGroup = new ThresholdsGroup(this.getExtendedParametersGroup(), this); |
... | ... | |
299 | 300 |
this.fMaxSpinner = thresholdsGroup.getFMaxSpinner(); |
300 | 301 |
this.vMaxSpinner = thresholdsGroup.getVMaxSpinner(); |
301 | 302 |
|
302 |
|
|
303 |
|
|
304 |
|
|
303 |
|
|
304 |
|
|
305 |
|
|
305 | 306 |
Label lNLigneppage = new Label(this.getExtendedParametersGroup(), SWT.NONE); |
306 | 307 |
lNLigneppage.setText(IndexUIMessages.pageSize); |
307 | 308 |
|
... | ... | |
312 | 313 |
nLinesPerPageSpinner.setPageIncrement(100); |
313 | 314 |
|
314 | 315 |
// FIXME; became useless? |
315 |
// nLinesPerPageSpinner.addSelectionListener(new SelectionListener() { |
|
316 |
// @Override |
|
317 |
// public void widgetSelected(SelectionEvent e) { } |
|
318 |
// |
|
319 |
// @Override |
|
320 |
// public void widgetDefaultSelected(SelectionEvent e) { |
|
321 |
// index.setTopLine(0); |
|
322 |
// index.setNLinesPerPage(nLinesPerPageSpinner.getSelection()); |
|
323 |
// fillResultArea(); |
|
324 |
// viewer.getTable().select(0); |
|
325 |
// viewer.getTable().showSelection(); |
|
326 |
// } |
|
327 |
// }); |
|
316 |
// nLinesPerPageSpinner.addSelectionListener(new SelectionListener() {
|
|
317 |
// @Override
|
|
318 |
// public void widgetSelected(SelectionEvent e) { }
|
|
319 |
//
|
|
320 |
// @Override
|
|
321 |
// public void widgetDefaultSelected(SelectionEvent e) {
|
|
322 |
// index.setTopLine(0);
|
|
323 |
// index.setNLinesPerPage(nLinesPerPageSpinner.getSelection());
|
|
324 |
// fillResultArea();
|
|
325 |
// viewer.getTable().select(0);
|
|
326 |
// viewer.getTable().showSelection();
|
|
327 |
// }
|
|
328 |
// });
|
|
328 | 329 |
|
329 | 330 |
nLinesPerPageSpinner.addSelectionListener(computeSelectionListener); |
330 | 331 |
nLinesPerPageSpinner.addKeyListener(computeKeyListener); |
331 |
|
|
332 |
|
|
332 |
|
|
333 |
|
|
333 | 334 |
navigationArea = new NavigationWidget(infosArea, SWT.NONE); |
334 | 335 |
navigationArea.setLayoutData(new GridData(SWT.CENTER, SWT.FILL, true, false)); |
335 | 336 |
|
... | ... | |
356 | 357 |
public void widgetSelected(SelectionEvent e) { |
357 | 358 |
int i = (index.getV()/nLinesPerPageSpinner.getSelection()); |
358 | 359 |
int top = i*nLinesPerPageSpinner.getSelection(); |
359 |
|
|
360 |
|
|
360 | 361 |
index.setTopLine(top); |
361 | 362 |
fillResultArea(); |
362 |
|
|
363 |
|
|
363 | 364 |
viewer.getTable().select(0); |
364 | 365 |
viewer.getTable().showSelection(); |
365 | 366 |
} |
... | ... | |
396 | 397 |
// Labels added after the top toolbar |
397 | 398 |
lTInfo = new Label(infosArea, SWT.NONE); |
398 | 399 |
lTInfo.setText(""); //$NON-NLS-1$ |
399 |
// lTInfo.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false)); |
|
400 |
// lTInfo.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false));
|
|
400 | 401 |
|
401 | 402 |
lVInfo = new Label(infosArea, SWT.NONE); |
402 | 403 |
lVInfo.setText(""); //$NON-NLS-1$ |
403 |
// lVInfo.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false)); |
|
404 |
// lVInfo.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false));
|
|
404 | 405 |
|
405 | 406 |
lFminInfo = new Label(infosArea, SWT.NONE); |
406 | 407 |
lFminInfo.setText(""); //$NON-NLS-1$ |
407 |
// lFminInfo.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false)); |
|
408 |
// lFminInfo.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false));
|
|
408 | 409 |
|
409 | 410 |
lFmaxInfo = new Label(infosArea, SWT.NONE); |
410 | 411 |
lFmaxInfo.setText(""); //$NON-NLS-1$ |
411 |
// lFmaxInfo.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false)); |
|
412 |
// lFmaxInfo.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false));
|
|
412 | 413 |
|
413 | 414 |
// results |
414 | 415 |
Composite resultArea = this.getResultArea(); |
415 | 416 |
|
416 | 417 |
viewer = new TableViewer(resultArea, SWT.MULTI | SWT.FULL_SELECTION | SWT.BORDER); |
417 |
|
|
418 |
|
|
418 | 419 |
viewer.getTable().setLinesVisible(true); |
419 | 420 |
viewer.getTable().setHeaderVisible(true); |
420 | 421 |
viewer.getTable().addKeyListener(new TableKeyListener(viewer)); |
... | ... | |
469 | 470 |
} |
470 | 471 |
}); |
471 | 472 |
|
472 |
freqColumn = new TableColumn(viewer.getTable(), SWT.RIGHT); |
|
473 |
try { |
|
474 |
if (index.getPartition() != null) |
|
473 |
// columns build later |
|
474 |
|
|
475 |
// Register the context menu |
|
476 |
TXMEditor.initContextMenu(this.viewer.getTable(), this.getSite(), this.viewer); |
|
477 |
|
|
478 |
|
|
479 |
if (queryWidget != null && !queryWidget.isDisposed()) { |
|
480 |
queryWidget.setFocus(); |
|
481 |
} |
|
482 |
|
|
483 |
} |
|
484 |
|
|
485 |
|
|
486 |
|
|
487 |
|
|
488 |
@Override |
|
489 |
public void updateResultFromEditor() { |
|
490 |
// nothing to do |
|
491 |
} |
|
492 |
|
|
493 |
|
|
494 |
/** |
|
495 |
* Computes index. |
|
496 |
*/ |
|
497 |
@Override |
|
498 |
public void updateEditorFromResult(final boolean update) { |
|
499 |
|
|
500 |
if (freqColumn == null) { |
|
501 |
freqColumn = new TableColumn(viewer.getTable(), SWT.RIGHT); |
|
502 |
try { |
|
475 | 503 |
freqColumn.setText(TXMCoreMessages.common_frequency+" T="+index.getPartition().getTotalSize()); //$NON-NLS-1$ |
476 |
else |
|
477 |
freqColumn.setText(TXMCoreMessages.common_frequency); |
|
478 |
} catch (CqiClientException e2) { |
|
479 |
// TODO Auto-generated catch block |
|
480 |
org.txm.rcp.utils.Logger.printStackTrace(e2); |
|
481 |
} |
|
482 |
freqColumn.setToolTipText(TXMCoreMessages.common_frequency); |
|
483 |
freqColumn.setWidth(100); |
|
484 |
freqColumn.addSelectionListener(new SelectionListener() { |
|
485 |
@Override |
|
486 |
public void widgetSelected(SelectionEvent e) { |
|
487 |
if (viewer.getTable().getSortColumn() != freqColumn) { |
|
488 |
viewer.getTable().setSortColumn(freqColumn); |
|
489 |
viewer.getTable().setSortDirection(SWT.UP); |
|
490 |
index.sortLines(SortMode.FREQUNIT, false); |
|
491 |
} else { |
|
492 |
if (viewer.getTable().getSortDirection() == SWT.UP) { |
|
493 |
viewer.getTable().setSortDirection(SWT.DOWN); |
|
494 |
index.sortLines(SortMode.FREQUNIT, true); |
|
495 |
} else { |
|
504 |
} catch (CqiClientException e2) { |
|
505 |
// TODO Auto-generated catch block |
|
506 |
org.txm.rcp.utils.Logger.printStackTrace(e2); |
|
507 |
} |
|
508 |
freqColumn.setToolTipText(TXMCoreMessages.common_frequency); |
|
509 |
freqColumn.setWidth(100); |
|
510 |
freqColumn.addSelectionListener(new SelectionListener() { |
|
511 |
@Override |
|
512 |
public void widgetSelected(SelectionEvent e) { |
|
513 |
if (viewer.getTable().getSortColumn() != freqColumn) { |
|
514 |
viewer.getTable().setSortColumn(freqColumn); |
|
496 | 515 |
viewer.getTable().setSortDirection(SWT.UP); |
497 | 516 |
index.sortLines(SortMode.FREQUNIT, false); |
517 |
} else { |
|
518 |
if (viewer.getTable().getSortDirection() == SWT.UP) { |
|
519 |
viewer.getTable().setSortDirection(SWT.DOWN); |
|
520 |
index.sortLines(SortMode.FREQUNIT, true); |
|
521 |
} else { |
|
522 |
viewer.getTable().setSortDirection(SWT.UP); |
|
523 |
index.sortLines(SortMode.FREQUNIT, false); |
|
524 |
} |
|
498 | 525 |
} |
526 |
StatusLine.setMessage(TXMUIMessages.sortDone); |
|
527 |
fillResultArea(); |
|
499 | 528 |
} |
500 |
StatusLine.setMessage(TXMUIMessages.sortDone); |
|
501 |
fillResultArea(); |
|
502 |
} |
|
503 | 529 |
|
504 |
@Override |
|
505 |
public void widgetDefaultSelected(SelectionEvent e) { |
|
506 |
} |
|
507 |
}); |
|
530 |
@Override
|
|
531 |
public void widgetDefaultSelected(SelectionEvent e) {
|
|
532 |
}
|
|
533 |
});
|
|
508 | 534 |
|
509 |
// rmv/creates parts columns if needed |
|
510 |
if (index.getPartition() != null) {
|
|
535 |
// rmv/creates parts columns if needed
|
|
536 |
List<Part> parts = index.getPartition().getParts();
|
|
511 | 537 |
List<String> partnames = index.getPartition().getPartNames(); |
512 |
if (partnames.size() > 1) |
|
538 |
if (partnames.size() > 1) {
|
|
513 | 539 |
if (viewer.getTable().getColumnCount() < partnames.size() + 3) { |
514 | 540 |
for (int i = 0; i < partnames.size(); i++) { |
515 | 541 |
final TableColumn partColumn = new TableColumn(viewer.getTable(), SWT.RIGHT); |
516 | 542 |
try { |
517 |
partColumn.setText(partnames.get(i) + " t=" + index.getPartition().getParts().get(i).getSize()); //$NON-NLS-1$
|
|
543 |
partColumn.setText(partnames.get(i) + " t=" + parts.get(i).getSize()); //$NON-NLS-1$
|
|
518 | 544 |
} catch (CqiClientException e1) { |
519 | 545 |
org.txm.rcp.utils.Logger.printStackTrace(e1); |
520 | 546 |
} |
... | ... | |
522 | 548 |
partColumn.setWidth(100); |
523 | 549 |
} |
524 | 550 |
} |
525 |
} |
|
526 |
separatorColumn = new TableColumn(viewer.getTable(), SWT.LEFT); |
|
527 |
separatorColumn.setText(""); //$NON-NLS-1$ |
|
528 |
separatorColumn.pack(); |
|
529 |
extendedParametersComposite.pack(); |
|
551 |
} |
|
530 | 552 |
|
531 |
// Add double click, "Send to" command |
|
532 |
TXMEditor.addDoubleClickCommandListener(viewer.getTable(), 1, "org.txm.concordance.rcp.handlers.ComputeConcordance"); //$NON-NLS-1$ |
|
533 |
TXMEditor.addDoubleClickCommandListener(viewer.getTable(), 2, viewer.getTable().getColumnCount() - 1, "org.txm.progression.rcp.handlers.ComputeProgression"); //$NON-NLS-1$ |
|
534 |
|
|
535 |
// Register the context menu |
|
536 |
TXMEditor.initContextMenu(this.viewer.getTable(), this.getSite(), this.viewer); |
|
553 |
separatorColumn = new TableColumn(viewer.getTable(), SWT.LEFT); |
|
554 |
separatorColumn.setText(""); //$NON-NLS-1$ |
|
555 |
separatorColumn.pack(); |
|
537 | 556 |
|
538 |
|
|
539 |
if (queryWidget != null && !queryWidget.isDisposed()) {
|
|
540 |
queryWidget.setFocus();
|
|
557 |
// Add double click, "Send to" command |
|
558 |
TXMEditor.addDoubleClickCommandListener(viewer.getTable(), 1, "org.txm.concordance.rcp.handlers.ComputeConcordance"); //$NON-NLS-1$
|
|
559 |
TXMEditor.addDoubleClickCommandListener(viewer.getTable(), 2, viewer.getTable().getColumnCount() - 1, "org.txm.progression.rcp.handlers.ComputeProgression"); //$NON-NLS-1$
|
|
541 | 560 |
} |
542 | 561 |
|
543 |
} |
|
544 |
|
|
545 |
|
|
546 |
|
|
547 |
|
|
548 |
@Override |
|
549 |
public void updateResultFromEditor() { |
|
550 |
// nothing to do |
|
551 |
} |
|
552 |
|
|
553 |
|
|
554 |
/** |
|
555 |
* Computes index. |
|
556 |
*/ |
|
557 |
@Override |
|
558 |
public void updateEditorFromResult(final boolean update) { |
|
559 |
|
|
560 | 562 |
QueriesView.refresh(); |
561 | 563 |
RVariablesView.refresh(); |
562 | 564 |
|
... | ... | |
564 | 566 |
queryWidget.memorize(); |
565 | 567 |
} |
566 | 568 |
|
569 |
|
|
570 |
|
|
567 | 571 |
fillResultArea(); |
568 | 572 |
|
569 | 573 |
viewer.getTable().setFocus(); |
... | ... | |
578 | 582 |
public void fillResultArea() { |
579 | 583 |
// System.out.println("call fill from "+from+" to "+to); |
580 | 584 |
int from = index.getTopIndex(); |
581 |
|
|
585 |
|
|
582 | 586 |
int to = from + index.getNLinesPerPage(); |
583 | 587 |
to = Math.min(to, index.getV()); |
584 |
|
|
588 |
|
|
585 | 589 |
List<Line> lines = null; |
586 | 590 |
if (index.getV() > 0) { |
587 | 591 |
lines = index.getLines(from, to); |
... | ... | |
617 | 621 |
|
618 | 622 |
// Refresh and pack the columns |
619 | 623 |
TXMEditor.packColumns(viewer); |
620 |
|
|
624 |
|
|
621 | 625 |
} |
622 | 626 |
|
623 | 627 |
/** |
tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/corpus/MainCorpus.java (revision 1481) | ||
---|---|---|
193 | 193 |
*/ |
194 | 194 |
@Override |
195 | 195 |
public int getSize() throws CqiClientException { |
196 |
if (!hasBeenComputedOnce) return 0; |
|
197 |
|
|
196 | 198 |
if (this.size == -1) { |
197 | 199 |
try { |
198 | 200 |
this.size = CorpusManager.getCorpusManager().getCqiClient() |
tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/corpus/Subcorpus.java (revision 1481) | ||
---|---|---|
159 | 159 |
*/ |
160 | 160 |
@Override |
161 | 161 |
public int getSize() throws CqiClientException { |
162 |
if (!hasBeenComputedOnce) return 0; |
|
163 |
|
|
162 | 164 |
if (this.size == -1) { |
163 | 165 |
//Log.finest(TXMCoreMessages.bind(TXMCoreMessages.SUBCORPUS_SIZE, new Object[]{this.pName, "N/A"})); |
164 | 166 |
long start = System.currentTimeMillis(); |
tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/corpus/Partition.java (revision 1481) | ||
---|---|---|
77 | 77 |
|
78 | 78 |
/** sum of parts size, stored for efficiency reasons**/ |
79 | 79 |
int totalsize = -1; |
80 |
|
|
80 |
|
|
81 | 81 |
/** The property, if not null the partition will forge its own queries */ |
82 | 82 |
@Parameter(key=TXMPreferences.STRUCTURAL_UNIT_PROPERTY) |
83 | 83 |
protected StructuralUnitProperty pProperty; |
84 |
|
|
84 |
|
|
85 | 85 |
/** |
86 | 86 |
* The parts property values to use, may be null. |
87 | 87 |
*/ |
88 | 88 |
@Parameter(key=TXMPreferences.VALUES) |
89 | 89 |
protected List<String> pValues; |
90 |
|
|
90 |
|
|
91 | 91 |
/** |
92 | 92 |
* The parts queries |
93 | 93 |
*/ |
94 | 94 |
@Parameter(key=TXMPreferences.QUERIES) |
95 | 95 |
protected List<String> pQueries; |
96 |
|
|
96 |
|
|
97 | 97 |
/** |
98 | 98 |
* The parts names -> do the parts order |
99 | 99 |
*/ |
100 | 100 |
@Parameter(key=CQPPreferences.PART_NAMES) |
101 | 101 |
protected List<String> pPartNames; |
102 |
|
|
103 |
|
|
102 |
|
|
103 |
|
|
104 | 104 |
/** |
105 | 105 |
* |
106 | 106 |
* @param parent |
... | ... | |
117 | 117 |
public Partition(String parametersNodePath) { |
118 | 118 |
super(parametersNodePath); |
119 | 119 |
} |
120 |
|
|
121 | 120 |
|
121 |
|
|
122 | 122 |
/** |
123 | 123 |
* Instantiates a new partition. |
124 | 124 |
* |
... | ... | |
133 | 133 |
if (this.userName == null || this.userName.length() == 0) { |
134 | 134 |
this.userName = "no_name"; |
135 | 135 |
} |
136 |
|
|
136 |
|
|
137 | 137 |
Log.info(NLS.bind(SearchEngineCoreMessages.info_creatingNewPartition, this.getParent(), this.userName)); |
138 | 138 |
long start = System.currentTimeMillis(); |
139 | 139 |
for (int i = 0; i < pQueries.size(); i++) { |
... | ... | |
244 | 244 |
@Override |
245 | 245 |
protected boolean _compute() throws Exception { |
246 | 246 |
|
247 |
// Parts already created
|
|
247 |
// Parts already created |
|
248 | 248 |
if (this.getParts().size() > 0) { |
249 |
// //FIXME: temporary fix, compute all the children parts |
|
250 |
// List<Part> parts = (List<Part>)getChildren(Part.class); |
|
251 |
// for (int i = 0; i < parts.size(); i++) { |
|
252 |
// if(!parts.get(i).hasBeenComputedOnce()) { |
|
253 |
// parts.get(i).compute(this, true); |
|
254 |
// } |
|
255 |
// } |
|
256 |
return true; |
|
249 |
// //FIXME: temporary fix, compute all the children parts |
|
250 |
List<Part> parts = (List<Part>)getChildren(Part.class); |
|
251 |
for (int i = 0; i < parts.size(); i++) { |
|
252 |
parts.get(i).compute(); |
|
253 |
} |
|
254 |
} else { |
|
255 |
Log.finest(NLS.bind(SearchEngineCoreMessages.info_creatingNewPartition, this.getParent(), this.userName)); |
|
256 |
|
|
257 |
if (this.pProperty != null) { |
|
258 |
_compute_with_property(); |
|
259 |
} |
|
260 |
else { |
|
261 |
_compute_with_lists(); |
|
262 |
} |
|
257 | 263 |
} |
258 |
|
|
259 |
Log.finest(NLS.bind(SearchEngineCoreMessages.info_creatingNewPartition, this.getParent(), this.userName)); |
|
260 |
|
|
261 |
if (this.pProperty != null) { |
|
262 |
_compute_with_property(); |
|
263 |
} |
|
264 |
else { |
|
265 |
_compute_with_lists(); |
|
266 |
} |
|
267 |
|
|
268 | 264 |
totalsize = -1; // refresh total size at next call of getTotalSize |
269 | 265 |
return true; |
270 | 266 |
} |
... | ... | |
274 | 270 |
*/ |
275 | 271 |
protected boolean _load(Element e) { |
276 | 272 |
|
277 |
// partition already computed
|
|
273 |
// partition already computed |
|
278 | 274 |
if (this.hasBeenComputedOnce) { |
279 | 275 |
return true; |
280 | 276 |
} |
281 |
|
|
277 |
|
|
282 | 278 |
if (e != null && this.getParent() != null) { |
283 | 279 |
NodeList partList = e.getChildNodes(); |
284 | 280 |
for (int i = 0; i < partList.getLength(); i++) { |
... | ... | |
325 | 321 |
return output; |
326 | 322 |
} |
327 | 323 |
|
328 |
// /** |
|
329 |
// * TODO Part should be create lazily |
|
330 |
// * |
|
331 |
// * Create a part with a raw query. |
|
332 |
// * |
|
333 |
// * @param partitionName the partition name |
|
334 |
// * @param partName the part name |
|
335 |
// * @param query the query |
|
336 |
// * @return the part |
|
337 |
// * @throws CqiClientException the cqi client exception |
|
338 |
// * |
|
339 |
// * @author Sylvain Loiseau, mdecorde |
|
340 |
// */ |
|
341 |
// public Part createPart(String partitionName, String partName, String query) throws CqiClientException { |
|
342 |
// Part part; |
|
343 |
// String partCqpId = CqpObject.partNamePrefix + CQPCorpus.getNextSubcorpusCounter(); |
|
344 |
// Log.finest(NLS.bind(TXMCoreMessages.CREATING_PART, partName, query)); |
|
345 |
// long start = System.currentTimeMillis(); |
|
346 |
// try { |
|
347 |
// CorpusManager.getCorpusManager().getCqiClient().cqpQuery(this.getParent().getQualifiedCqpId(), partCqpId, query); |
|
348 |
// part = new Part(this); |
|
349 |
// part.setParameters(partCqpId, partName, new CQLQuery(query)); |
|
350 |
// part.compute(); |
|
351 |
// // FIXME: persistence tests: define the UUID as the concatenation of all part CQP id |
|
352 |
//// this.uniqueID += partCqpId; |
|
353 |
// |
|
354 |
// } catch (Exception e) { |
|
355 |
// try { |
|
356 |
// throw new CqiClientException(TXMCoreMessages.failedToCreatePartColon + partitionName + "_" + partName + e + " last error: " + CQPSearchEngine.getCqiClient().getLastCQPError()); //$NON-NLS-1$ //$NON-NLS-2$ |
|
357 |
// } catch (Exception e1) { |
|
358 |
// Log.severe(TXMCoreMessages.failedToGetLastCQPErrorColon + e1); |
|
359 |
// org.txm.utils.logger.Log.printStackTrace(e1); |
|
360 |
// return null; |
|
361 |
// } |
|
362 |
// } |
|
363 |
// long end = System.currentTimeMillis(); |
|
364 |
// Log.finest(NLS.bind(TXMCoreMessages.info_partCreatedInXMs, partitionName + "_" + partName, (end - start))); //$NON-NLS-1 |
|
365 |
// |
|
366 |
// return part; |
|
367 |
// } |
|
368 |
|
|
324 |
// /** |
|
325 |
// * TODO Part should be create lazily |
|
326 |
// * |
|
327 |
// * Create a part with a raw query. |
|
328 |
// * |
|
329 |
// * @param partitionName the partition name |
|
330 |
// * @param partName the part name |
|
331 |
// * @param query the query |
|
332 |
// * @return the part |
|
333 |
// * @throws CqiClientException the cqi client exception |
|
334 |
// * |
|
335 |
// * @author Sylvain Loiseau, mdecorde |
|
336 |
// */ |
|
337 |
// public Part createPart(String partitionName, String partName, String query) throws CqiClientException { |
|
338 |
// Part part; |
|
339 |
// String partCqpId = CqpObject.partNamePrefix + CQPCorpus.getNextSubcorpusCounter(); |
|
340 |
// Log.finest(NLS.bind(TXMCoreMessages.CREATING_PART, partName, query)); |
|
341 |
// long start = System.currentTimeMillis(); |
|
342 |
// try { |
|
343 |
// CorpusManager.getCorpusManager().getCqiClient().cqpQuery(this.getParent().getQualifiedCqpId(), partCqpId, query); |
|
344 |
// part = new Part(this); |
|
345 |
// part.setParameters(partCqpId, partName, new CQLQuery(query)); |
|
346 |
// part.compute(); |
|
347 |
// // FIXME: persistence tests: define the UUID as the concatenation of all part CQP id |
|
348 |
//// this.uniqueID += partCqpId; |
|
349 |
// |
|
350 |
// } catch (Exception e) { |
|
351 |
// try { |
|
352 |
// throw new CqiClientException(TXMCoreMessages.failedToCreatePartColon + partitionName + "_" + partName + e + " last error: " + CQPSearchEngine.getCqiClient().getLastCQPError()); //$NON-NLS-1$ //$NON-NLS-2$ |
|
353 |
// } catch (Exception e1) { |
|
354 |
// Log.severe(TXMCoreMessages.failedToGetLastCQPErrorColon + e1); |
|
355 |
// org.txm.utils.logger.Log.printStackTrace(e1); |
|
356 |
// return null; |
|
357 |
// } |
|
358 |
// } |
|
359 |
// long end = System.currentTimeMillis(); |
|
360 |
// Log.finest(NLS.bind(TXMCoreMessages.info_partCreatedInXMs, partitionName + "_" + partName, (end - start))); //$NON-NLS-1 |
|
361 |
// |
|
362 |
// return part; |
|
363 |
// } |
|
369 | 364 |
|
365 |
|
|
370 | 366 |
@Override |
371 | 367 |
public String getDetails() { |
372 | 368 |
return NLS.bind(getName()+" ({0})", getPartsCount()); |
... | ... | |
380 | 376 |
public int getPartsCount() { |
381 | 377 |
// FIXME: later should just return the direct children count |
382 | 378 |
try { |
383 |
// if (!hasBeenComputedOnce()) { |
|
384 |
// compute(); |
|
385 |
// } |
|
386 |
// |
|
379 |
// if (!hasBeenComputedOnce()) {
|
|
380 |
// compute();
|
|
381 |
// }
|
|
382 |
//
|
|
387 | 383 |
return getParts().size(); |
388 | 384 |
} catch(Exception e) { } |
389 | 385 |
return 0; |
... | ... | |
396 | 392 |
*/ |
397 | 393 |
public List<String> getPartNames() { |
398 | 394 |
if (hasBeenComputedOnce()) { |
399 |
List<Part> parts = getParts(); |
|
400 |
List<String> partNames = new ArrayList<String>(parts.size()); |
|
401 |
for (Subcorpus part : getParts()) { |
|
402 |
partNames.add(part.getName()); |
|
403 |
} |
|
404 |
return partNames; |
|
395 |
List<Part> parts = getParts();
|
|
396 |
List<String> partNames = new ArrayList<String>(parts.size());
|
|
397 |
for (Subcorpus part : getParts()) {
|
|
398 |
partNames.add(part.getName());
|
|
399 |
}
|
|
400 |
return partNames;
|
|
405 | 401 |
} else { |
406 | 402 |
return this.pPartNames; |
407 | 403 |
} |
... | ... | |
417 | 413 |
return (List<Part>) getChildren(Part.class); |
418 | 414 |
} |
419 | 415 |
|
420 |
// /** |
|
421 |
// * Gets the short name of the parts. |
|
422 |
// * |
|
423 |
// * @return the part names |
|
424 |
// */ |
|
425 |
// public List<String> getPartShortNames() { |
|
426 |
// List<Part> parts = getParts(); |
|
427 |
// List<String> partNames = new ArrayList<String>(parts.size()); |
|
428 |
// for (Part part : parts) { |
|
429 |
// partNames.add(part.getShortName()); |
|
430 |
// } |
|
431 |
// return partNames; |
|
432 |
// } |
|
416 |
// /**
|
|
417 |
// * Gets the short name of the parts.
|
|
418 |
// *
|
|
419 |
// * @return the part names
|
|
420 |
// */
|
|
421 |
// public List<String> getPartShortNames() {
|
|
422 |
// List<Part> parts = getParts();
|
|
423 |
// List<String> partNames = new ArrayList<String>(parts.size());
|
|
424 |
// for (Part part : parts) {
|
|
425 |
// partNames.add(part.getShortName());
|
|
426 |
// }
|
|
427 |
// return partNames;
|
|
428 |
// }
|
|
433 | 429 |
|
434 | 430 |
/** |
435 | 431 |
* Gets the part sizes as int array. |
... | ... | |
478 | 474 |
* @throws CqiClientException |
479 | 475 |
*/ |
480 | 476 |
public int getTotalSize() throws CqiClientException { |
481 |
|
|
477 |
|
|
482 | 478 |
if (totalsize == -1) { |
483 | 479 |
totalsize = 0; |
484 | 480 |
for (Part p : getParts()) { |
... | ... | |
512 | 508 |
return results; |
513 | 509 |
} |
514 | 510 |
|
515 |
// /** |
|
516 |
// * Register to parent. |
|
517 |
// */ |
|
518 |
// public void registerToParent() { |
|
519 |
// //registerToParent(this.name); |
|
520 |
// } |
|
521 |
// |
|
522 |
// /** |
|
523 |
// * Register to parent. |
|
524 |
// * |
|
525 |
// * @param partitionName the partition name |
|
526 |
// */ |
|
527 |
// private void registerToParent(String partitionName) { |
|
528 |
//// if (this.getSelfElement() == null && this.getParent() != null) |
|
529 |
//// try { |
|
530 |
//// Element parentElem = (Element) this.getParent().getSelfElement(); |
|
531 |
//// if (parentElem == null) return; |
|
532 |
//// Document doc = parentElem.getOwnerDocument(); |
|
533 |
//// Element corporaElem; |
|
534 |
//// if (this.getParent() instanceof MainCorpus) { |
|
535 |
//// NodeList corporaList = parentElem.getElementsByTagName("preBuild"); //$NON-NLS-1$ |
|
536 |
//// corporaElem = (Element) corporaList.item(0); |
|
537 |
//// } else { |
|
538 |
//// corporaElem = parentElem; |
|
539 |
//// } |
|
540 |
//// Element partitionElem = doc.createElement("partition"); //$NON-NLS-1$ |
|
541 |
//// partitionElem.setAttribute("name", partitionName); //$NON-NLS-1$ |
|
542 |
//// corporaElem.appendChild(partitionElem); |
|
543 |
//// this.setSelfElement(partitionElem); |
|
544 |
//// for (Part p : getParts()) { |
|
545 |
//// Element partElem = doc.createElement("part"); //$NON-NLS-1$ |
|
546 |
//// partElem.setAttribute("name", p.getName()); //$NON-NLS-1$ |
|
547 |
//// partElem.setAttribute("shortname", p.getShortName()); //$NON-NLS-1$ |
|
548 |
//// partElem.setAttribute("query", p.getQuery().getQueryString()); //$NON-NLS-1$ |
|
549 |
//// partitionElem.appendChild(partElem); |
|
550 |
//// } |
|
551 |
//// } catch (Exception e) { |
|
552 |
//// System.out.println(TXMCoreMessages.Partition_21+e); |
|
553 |
//// } |
|
554 |
//// this._load(); |
|
555 |
// } |
|
511 |
// /**
|
|
512 |
// * Register to parent.
|
|
513 |
// */
|
|
514 |
// public void registerToParent() {
|
|
515 |
// //registerToParent(this.name);
|
|
516 |
// }
|
|
517 |
//
|
|
518 |
// /**
|
|
519 |
// * Register to parent.
|
|
520 |
// *
|
|
521 |
// * @param partitionName the partition name
|
|
522 |
// */
|
|
523 |
// private void registerToParent(String partitionName) {
|
|
524 |
//// if (this.getSelfElement() == null && this.getParent() != null)
|
|
525 |
//// try {
|
|
526 |
//// Element parentElem = (Element) this.getParent().getSelfElement();
|
|
527 |
//// if (parentElem == null) return;
|
|
528 |
//// Document doc = parentElem.getOwnerDocument();
|
|
529 |
//// Element corporaElem;
|
|
530 |
//// if (this.getParent() instanceof MainCorpus) {
|
|
531 |
//// NodeList corporaList = parentElem.getElementsByTagName("preBuild"); //$NON-NLS-1$
|
|
532 |
//// corporaElem = (Element) corporaList.item(0);
|
|
533 |
//// } else {
|
|
534 |
//// corporaElem = parentElem;
|
|
535 |
//// }
|
|
536 |
//// Element partitionElem = doc.createElement("partition"); //$NON-NLS-1$
|
|
537 |
//// partitionElem.setAttribute("name", partitionName); //$NON-NLS-1$
|
|
538 |
//// corporaElem.appendChild(partitionElem);
|
|
539 |
//// this.setSelfElement(partitionElem);
|
|
540 |
//// for (Part p : getParts()) {
|
|
541 |
//// Element partElem = doc.createElement("part"); //$NON-NLS-1$
|
|
542 |
//// partElem.setAttribute("name", p.getName()); //$NON-NLS-1$
|
|
543 |
//// partElem.setAttribute("shortname", p.getShortName()); //$NON-NLS-1$
|
|
544 |
//// partElem.setAttribute("query", p.getQuery().getQueryString()); //$NON-NLS-1$
|
|
545 |
//// partitionElem.appendChild(partElem);
|
|
546 |
//// }
|
|
547 |
//// } catch (Exception e) {
|
|
548 |
//// System.out.println(TXMCoreMessages.Partition_21+e);
|
|
549 |
//// }
|
|
550 |
//// this._load();
|
|
551 |
// }
|
|
556 | 552 |
|
557 |
// public TxmObject removeChildren(TxmObject children) { |
|
558 |
// if (children instanceof Part) { |
|
559 |
// if (children.getSelfElement() != null && children.getSelfElement().getParentNode() == getSelfElement()) |
|
560 |
// getSelfElement().removeChild(children.getSelfElement()); |
|
561 |
// return children; |
|
562 |
// } |
|
563 |
// return null; |
|
564 |
// } |
|
553 |
// public TxmObject removeChildren(TxmObject children) {
|
|
554 |
// if (children instanceof Part) {
|
|
555 |
// if (children.getSelfElement() != null && children.getSelfElement().getParentNode() == getSelfElement())
|
|
556 |
// getSelfElement().removeChild(children.getSelfElement());
|
|
557 |
// return children;
|
|
558 |
// }
|
|
559 |
// return null;
|
|
560 |
// }
|
|
565 | 561 |
|
566 | 562 |
public CQPCorpus getParent() { |
567 | 563 |
return (CQPCorpus) super.getParent(); |
... | ... | |
657 | 653 |
// TODO Auto-generated catch block |
658 | 654 |
e.printStackTrace(); |
659 | 655 |
} |
660 |
|
|
656 |
|
|
661 | 657 |
tmp = this.getStringParameterValue(CQPPreferences.PART_NAMES); |
662 | 658 |
if (tmp != null) { |
663 | 659 |
this.pPartNames = Arrays.asList(tmp.split("\t")); |
... | ... | |
687 | 683 |
if (this.pProperty != null) { |
688 | 684 |
this.saveParameter(TXMPreferences.STRUCTURAL_UNIT_PROPERTY, this.pProperty.getName()); |
689 | 685 |
} |
690 |
|
|
686 |
|
|
691 | 687 |
if (this.pPartNames != null) { |
692 | 688 |
this.saveParameter(CQPPreferences.PART_NAMES, StringUtils.join(pPartNames, "\t")); |
693 | 689 |
} |
694 |
|
|
690 |
|
|
695 | 691 |
if (this.pQueries != null) { |
696 | 692 |
this.saveParameter(TXMPreferences.QUERIES, StringUtils.join(pQueries, "\t")); |
697 | 693 |
} |
698 |
|
|
694 |
|
|
699 | 695 |
if (this.pValues != null) { |
700 | 696 |
this.saveParameter(TBXPreferences.VALUES, StringUtils.join(pValues, "\t")); |
701 | 697 |
} |
702 | 698 |
|
703 | 699 |
return true; |
704 | 700 |
} |
705 |
|
|
701 |
|
|
706 | 702 |
/** |
707 | 703 |
* Get the safe values (special char regexp safe). |
708 | 704 |
* |
... | ... | |
723 | 719 |
public String getResultype() { |
724 | 720 |
return "Partition"; |
725 | 721 |
} |
726 |
|
|
722 |
|
|
727 | 723 |
/** |
728 | 724 |
* Gets the parent Partition of the specified result if exists. |
729 | 725 |
* @param result |
... | ... | |
737 | 733 |
public String getName() { |
738 | 734 |
return this.userName; |
739 | 735 |
} |
740 |
|
|
736 |
|
|
741 | 737 |
public CQPCorpus getCorpus() { |
742 | 738 |
return (CQPCorpus) parent; |
743 | 739 |
} |
744 |
|
|
740 |
|
|
745 | 741 |
} |
tmp/org.txm.rcp/src/main/java/org/txm/rcp/handlers/results/SetTXMResultLockState.java (revision 1481) | ||
---|---|---|
34 | 34 |
import org.eclipse.ui.commands.IElementUpdater; |
35 | 35 |
import org.eclipse.ui.menus.UIElement; |
36 | 36 |
import org.txm.core.results.TXMResult; |
37 |
import org.txm.rcp.editors.TXMEditor; |
|
37 | 38 |
import org.txm.rcp.handlers.BaseAbstractHandler; |
39 |
import org.txm.rcp.utils.SWTEditorsUtils; |
|
38 | 40 |
import org.txm.rcp.views.corpora.CorporaView; |
39 | 41 |
|
40 | 42 |
/** |
... | ... | |
54 | 56 |
TXMResult result = ((TXMResult)object); |
55 | 57 |
result.setLocked(!result.isLocked()); |
56 | 58 |
|
59 |
if (result.isLocked()) { |
|
60 |
result.setUserPersistable(true); |
|
61 |
} |
|
62 |
|
|
57 | 63 |
CorporaView.refresh(); |
64 |
//TODO should be done with a listener |
|
65 |
for (TXMEditor<?> editor : SWTEditorsUtils.getEditors()) { |
|
66 |
editor.setLocked(editor.getResult().isLocked()); |
|
67 |
} |
|
58 | 68 |
|
59 | 69 |
return null; |
60 | 70 |
} |
tmp/org.txm.rcp/src/main/java/org/txm/rcp/IImageKeys.java (revision 1481) | ||
---|---|---|
245 | 245 |
} |
246 | 246 |
|
247 | 247 |
/** |
248 |
* |
|
249 |
* @param plugin ID |
|
250 |
* @param imageFilePath |
|
251 |
* @return |
|
252 |
*/ |
|
253 |
public static ImageDescriptor getImageDescriptor(String plugin, String imageFilePath) { |
|
254 |
return AbstractUIPlugin.imageDescriptorFromPlugin(plugin, imageFilePath); |
|
255 |
} |
|
256 |
|
|
257 |
/** |
|
258 |
* |
|
259 |
* @param class of plugin to find |
|
260 |
* @param imageFilePath |
|
261 |
* @return |
|
262 |
*/ |
|
263 |
public static ImageDescriptor getImageDescriptor(Class classOfPlugin, String imageFilePath) { |
|
264 |
return getImageDescriptor(FrameworkUtil.getBundle(classOfPlugin).getSymbolicName(), imageFilePath); |
|
265 |
} |
|
266 |
|
|
267 |
/** |
|
248 | 268 |
* @param objectOfPlugin |
249 | 269 |
* @param imageFilePath |
250 | 270 |
* @return |
tmp/org.txm.rcp/src/main/java/org/txm/rcp/editors/TXMEditor.java (revision 1481) | ||
---|---|---|
191 | 191 |
* To store or edit the dirty state of the editor from widget. |
192 | 192 |
*/ |
193 | 193 |
protected boolean dirty; |
194 |
private boolean locked; |
|
194 | 195 |
|
195 | 196 |
|
196 | 197 |
/** |
... | ... | |
436 | 437 |
} |
437 | 438 |
|
438 | 439 |
if (this.getResult().isLocked()) { |
439 |
this.firstLineComposite.setEnabled(false);
|
|
440 |
setLocked(true);
|
|
440 | 441 |
} |
441 | 442 |
|
442 | 443 |
// disable the compute button, it will be re-enable or not later when the UI will check if the editor is dirty or not |
... | ... | |
452 | 453 |
} |
453 | 454 |
} |
454 | 455 |
|
456 |
public void setLocked(boolean b) { |
|
457 |
this.locked = b; |
|
458 |
this.firstLineComposite.setEnabled(!b); |
|
459 |
} |
|
460 |
|
|
461 |
public boolean isLocked() { |
|
462 |
return locked; |
|
463 |
} |
|
464 |
|
|
455 | 465 |
/** |
456 | 466 |
* shortcut to call the notify* methods of all extension |
457 | 467 |
* |
... | ... | |
760 | 770 |
*/ |
761 | 771 |
public JobHandler compute(final boolean update) { |
762 | 772 |
|
773 |
|
|
763 | 774 |
StatusLine.setMessage(TXMCoreMessages.bind(TXMUIMessages.computing, this.getResult().getName())); |
764 | 775 |
|
765 | 776 |
|
... | ... | |
770 | 781 |
|
771 | 782 |
this.runInit(monitor); |
772 | 783 |
|
784 |
if (isLocked()) return Status.CANCEL_STATUS; |
|
785 |
|
|
773 | 786 |
try { |
774 | 787 |
JobsTimer.start(); |
775 | 788 |
|
tmp/org.txm.rcp/plugin.xml (revision 1481) | ||
---|---|---|
2001 | 2001 |
</visibleWhen> |
2002 | 2002 |
</command> |
2003 | 2003 |
<command |
2004 |
commandId="org.txm.rcp.handlers.results.SetTXMResultLockState" |
|
2005 |
mode="FORCE_TEXT" |
|
2006 |
style="toggle"> |
|
2007 |
<visibleWhen |
|
2008 |
checkEnabled="false"> |
|
2009 |
<and> |
|
2010 |
<reference |
|
2011 |
definitionId="OneTXMResultSelected"> |
|
2012 |
</reference> |
|
2013 |
</and> |
|
2014 |
</visibleWhen> |
|
2015 |
</command> |
|
2016 |
<command |
|
2017 | 2004 |
commandId="org.txm.rcp.commands.function.RenameResult" |
2018 | 2005 |
label="%command.label.26" |
2019 | 2006 |
style="push"> |
tmp/org.txm.index.core/src/org/txm/index/core/functions/PartitionIndex.java (revision 1481) | ||
---|---|---|
158 | 158 |
* @param parent |
159 | 159 |
*/ |
160 | 160 |
public PartitionIndex(Partition parent) { |
161 |
super(parent); |
|
161 |
super(null, parent);
|
|
162 | 162 |
} |
163 | 163 |
|
164 | 164 |
/** |
... | ... | |
166 | 166 |
* @param parametersNodePath |
167 | 167 |
*/ |
168 | 168 |
public PartitionIndex(String parametersNodePath) { |
169 |
super(parametersNodePath);
|
|
169 |
this(parametersNodePath, null);
|
|
170 | 170 |
} |
171 |
|
|
172 |
/** |
|
173 |
* |
|
174 |
* @param parent |
|
175 |
*/ |
|
176 |
public PartitionIndex(String parametersNodePath, Partition parent) { |
|
177 |
super(parametersNodePath, parent); |
|
178 |
|
|
179 |
Partition partition = getParent(); |
|
180 |
partnames.clear(); |
|
181 |
for (Part part : partition.getParts()) { |
|
182 |
partnames.add(part.getName()); |
|
183 |
} |
|
184 |
} |
|
171 | 185 |
|
172 |
|
|
186 |
public Partition getParent() { |
|
187 |
return (Partition)parent; |
|
188 |
} |
|
189 |
|
|
173 | 190 |
@Override |
174 | 191 |
protected boolean _compute() throws Exception { |
175 | 192 |
lines.clear(); |
... | ... | |
178 | 195 |
currentpartid = 0; |
179 | 196 |
nTotalTokens = 0; |
180 | 197 |
|
181 |
Partition partition = (Partition)parent; |
|
198 |
Partition partition = getParent(); |
|
199 |
partnames.clear(); |
|
182 | 200 |
for (Part part : partition.getParts()) { |
183 | 201 |
scanCorpus(part); |
184 | 202 |
currentpartid++; |
185 | 203 |
partnames.add(part.getName()); |
186 | 204 |
} |
187 |
|
|
205 |
|
|
188 | 206 |
setLineCounts(); |
189 | 207 |
|
190 | 208 |
getAllLines(); |
tmp/org.txm.core/src/java/org/txm/core/results/TXMResult.java (revision 1481) | ||
---|---|---|
185 | 185 |
*/ |
186 | 186 |
@Parameter(key=TBXPreferences.CREATE_DATE, type=Parameter.INTERNAL) |
187 | 187 |
private Date pCreationDate; |
188 |
|
|
189 |
// true if the result is computing = in compute(,) method |
|
190 |
private boolean computing = false; |
|
188 | 191 |
|
189 | 192 |
|
190 | 193 |
/** |
... | ... | |
2016 | 2019 |
* @throws IOException |
2017 | 2020 |
*/ |
2018 | 2021 |
protected boolean compute(IProgressMonitor monitor, boolean deepComputing) { |
2019 |
|
|
2022 |
if (computing) return true; |
|
2023 |
computing = true; |
|
2020 | 2024 |
// no changes to do |
2021 | 2025 |
// FIXME: SJ: we need to do do some actions even if the object is locked, eg. updating parameters, saving parameters, etc. |
2022 | 2026 |
// FIXME MD: nope the parameters must not move and will be saved in the current state |
2023 | 2027 |
if (hasBeenComputedOnce && locked) { |
2028 |
computing = false; |
|
2024 | 2029 |
return true; |
2025 | 2030 |
} |
2026 | 2031 |
|
... | ... | |
2043 | 2048 |
|
2044 | 2049 |
if (!this.parent.compute(monitor, true)) { |
2045 | 2050 |
Log.finest("TXMResult.compute(): " + this.getClass().getSimpleName() + ": failed to compute parent result."); |
2046 |
|
|
2051 |
computing = false; |
|
2047 | 2052 |
return false; |
2048 | 2053 |
} |
2049 | 2054 |
} |
... | ... | |
2064 | 2069 |
// Computing requirements test |
2065 | 2070 |
if (!this.canCompute()) { |
2066 | 2071 |
Log.finest("TXMResult.compute(): " + this.getClass().getSimpleName() + ": can not compute, missing or wrong parameters or error with parent computing, computing aborted."); |
2072 |
computing = false; |
|
2067 | 2073 |
return false; |
2068 | 2074 |
} |
2069 | 2075 |
|
2070 | 2076 |
// Computing |
2071 | 2077 |
if (!this._compute()) { |
2072 | 2078 |
Log.finest("TXMResult.compute(): " + this.getClass().getSimpleName() + ": computing failed."); |
2079 |
computing = false; |
|
2073 | 2080 |
return false; |
2074 | 2081 |
} |
2075 | 2082 |
} |
... | ... | |
2140 | 2147 |
// TODO Auto-generated catch block |
2141 | 2148 |
e.printStackTrace(); |
2142 | 2149 |
Log.severe(TXMCoreMessages.bind("TXMResult.compute(): Exception occurs during computing: {0}.", e)); |
2150 |
computing = false; |
|
2143 | 2151 |
return false; |
2144 | 2152 |
} |
2145 | 2153 |
|
2154 |
computing = false; |
|
2146 | 2155 |
return true; |
2147 | 2156 |
} |
2148 | 2157 |
|
tmp/org.txm.edition.rcp/src/org/txm/edition/rcp/preferences/SynopticEditionPreferencePage.java (revision 1481) | ||
---|---|---|
1 | 1 |
package org.txm.edition.rcp.preferences; |
2 | 2 |
|
3 | 3 |
import org.eclipse.jface.preference.BooleanFieldEditor; |
4 |
import org.eclipse.jface.preference.FieldEditorPreferencePage; |
|
5 | 4 |
import org.eclipse.ui.IWorkbench; |
6 |
import org.eclipse.ui.IWorkbenchPreferencePage; |
|
7 |
import org.eclipse.ui.preferences.ScopedPreferenceStore; |
|
8 | 5 |
import org.txm.edition.rcp.messages.EditionUIMessages; |
9 |
import org.txm.rcp.Application; |
|
6 |
import org.txm.rcp.IImageKeys; |
|
7 |
import org.txm.rcp.preferences.TXMPreferencePage; |
|
8 |
import org.txm.rcp.preferences.TXMPreferenceStore; |
|
10 | 9 |
|
11 | 10 |
/** |
12 | 11 |
* Edition preference page. |
... | ... | |
15 | 14 |
* @author sjacquot |
16 | 15 |
* |
17 | 16 |
*/ |
18 |
// FIXME: must inherit TXMPreferencePage |
|
19 |
public class SynopticEditionPreferencePage extends FieldEditorPreferencePage implements IWorkbenchPreferencePage { |
|
17 |
public class SynopticEditionPreferencePage extends TXMPreferencePage { |
|
20 | 18 |
|
21 |
ScopedPreferenceStore preferences; |
|
22 |
|
|
23 | 19 |
private BooleanFieldEditor fast_highlight; |
24 | 20 |
|
25 |
|
|
26 |
public SynopticEditionPreferencePage() { |
|
27 |
super(); |
|
28 |
preferences = new ScopedPreferenceStore(org.eclipse.core.runtime.preferences.InstanceScope.INSTANCE, Application.PLUGIN_ID); |
|
29 |
setPreferenceStore(preferences); |
|
30 |
setTitle(EditionUIMessages.edition); |
|
31 |
} |
|
32 |
|
|
33 | 21 |
@Override |
34 |
public void init(IWorkbench workbench) { } |
|
22 |
public void init(IWorkbench workbench) { |
|
23 |
this.setPreferenceStore(new TXMPreferenceStore(SynopticEditionPreferences.getInstance().getPreferencesNodeQualifier())); |
|
24 |
this.setTitle(EditionUIMessages.edition); |
|
25 |
this.setImageDescriptor(IImageKeys.getImageDescriptor(SynopticEditionPreferencePage.class, "icons/edition.png")); |
|
26 |
} |
|
35 | 27 |
|
36 | 28 |
@Override |
37 | 29 |
protected void createFieldEditors() { |
tmp/org.txm.edition.rcp/plugin.xml (revision 1481) | ||
---|---|---|
161 | 161 |
</with> |
162 | 162 |
</definition> |
163 | 163 |
</extension> |
164 |
<extension |
|
165 |
point="org.eclipse.core.runtime.preferences"> |
|
166 |
<initializer |
|
167 |
class="org.txm.edition.rcp.preferences.SynopticEditionPreferences"> |
|
168 |
</initializer> |
|
169 |
</extension> |
|
164 | 170 |
|
165 | 171 |
</plugin> |
Formats disponibles : Unified diff