10 |
10 |
import org.eclipse.jface.viewers.ITreeContentProvider;
|
11 |
11 |
import org.eclipse.jface.viewers.TableViewer;
|
12 |
12 |
import org.eclipse.jface.viewers.TableViewerColumn;
|
|
13 |
import org.eclipse.jface.viewers.Viewer;
|
13 |
14 |
import org.eclipse.jface.viewers.ViewerCell;
|
|
15 |
import org.eclipse.jface.viewers.ViewerSorter;
|
14 |
16 |
import org.eclipse.osgi.util.NLS;
|
15 |
17 |
import org.eclipse.swt.SWT;
|
16 |
18 |
import org.eclipse.swt.events.KeyEvent;
|
... | ... | |
27 |
29 |
import org.eclipse.swt.widgets.Event;
|
28 |
30 |
import org.eclipse.swt.widgets.Group;
|
29 |
31 |
import org.eclipse.swt.widgets.Label;
|
|
32 |
import org.eclipse.swt.widgets.Table;
|
|
33 |
import org.eclipse.swt.widgets.TableColumn;
|
30 |
34 |
import org.eclipse.swt.widgets.Text;
|
31 |
35 |
import org.txm.core.preferences.TXMPreferences;
|
32 |
36 |
import org.txm.core.results.Parameter;
|
|
37 |
import org.txm.core.results.TXMResult;
|
33 |
38 |
import org.txm.rcp.IImageKeys;
|
34 |
39 |
import org.txm.rcp.editors.TXMEditor;
|
35 |
40 |
import org.txm.rcp.editors.listeners.ComputeKeyListener;
|
... | ... | |
41 |
46 |
import org.txm.rcp.swt.widget.structures.SimplePartitionPanel;
|
42 |
47 |
import org.txm.rcp.views.corpora.CorporaView;
|
43 |
48 |
import org.txm.searchengine.cqp.clientExceptions.CqiClientException;
|
|
49 |
import org.txm.searchengine.cqp.corpus.CQPCorpus;
|
44 |
50 |
import org.txm.searchengine.cqp.corpus.Part;
|
45 |
51 |
import org.txm.searchengine.cqp.corpus.Partition;
|
|
52 |
import org.txm.searchengine.cqp.corpus.Subcorpus;
|
46 |
53 |
import org.txm.utils.logger.Log;
|
47 |
54 |
|
48 |
55 |
public class PartitionEditor extends TXMEditor<Partition> {
|
... | ... | |
64 |
71 |
private Button updateQueryFromAssistance;
|
65 |
72 |
private Composite assistantPanel;
|
66 |
73 |
|
|
74 |
@SuppressWarnings("deprecation")
|
67 |
75 |
@Override
|
68 |
76 |
public void _createPartControl() throws Exception {
|
69 |
77 |
|
... | ... | |
72 |
80 |
ComputeKeyListener computeKeyListener = new ComputeKeyListener(this);
|
73 |
81 |
|
74 |
82 |
getMainParametersComposite().getLayout().numColumns = 7;
|
|
83 |
getMainParametersComposite().getLayout().horizontalSpacing = 2;
|
75 |
84 |
|
76 |
85 |
Label l = new Label(getMainParametersComposite(), SWT.NONE);
|
77 |
86 |
l.setText(TXMUIMessages.name);
|
... | ... | |
297 |
306 |
|
298 |
307 |
// RESULT AREA
|
299 |
308 |
|
|
309 |
this.getResultArea().getLayout().verticalSpacing = 2;
|
|
310 |
|
300 |
311 |
GLComposite buttons = new GLComposite(this.getResultArea(), SWT.NONE, "buttons");
|
301 |
312 |
buttons.getLayout().numColumns = 10;
|
302 |
313 |
buttons.getLayout().horizontalSpacing = 2;
|
... | ... | |
312 |
323 |
p.delete();
|
313 |
324 |
}
|
314 |
325 |
|
315 |
|
partsViewer.setInput(getResult());
|
316 |
326 |
try {
|
317 |
327 |
updateEditorFromResult(false);
|
318 |
328 |
} catch (Exception e1) {
|
... | ... | |
335 |
345 |
partsViewer.getTable().setHeaderVisible(true);
|
336 |
346 |
partsViewer.getTable().setLinesVisible(true);
|
337 |
347 |
|
|
348 |
partsViewer.setSorter(new ViewerSorter() {
|
|
349 |
|
|
350 |
@Override
|
|
351 |
public int compare(Viewer viewer, Object e1, Object e2) {
|
|
352 |
Part p1 = (Part)e1;
|
|
353 |
Part p2 = (Part)e2;
|
|
354 |
int s = 0;
|
|
355 |
if (partsViewer.getTable().getSortColumn() == nameColumn.getColumn()) {
|
|
356 |
s = p1.getName().compareTo(p2.getName());
|
|
357 |
} else if (partsViewer.getTable().getSortColumn() == queryColumn.getColumn()) {
|
|
358 |
s = p1.getQuery().getQueryString().compareTo(p2.getQuery().getQueryString());
|
|
359 |
} else if (partsViewer.getTable().getSortColumn() == sizeColumn.getColumn()) {
|
|
360 |
try {
|
|
361 |
s = p1.getSize() - p2.getSize();
|
|
362 |
}
|
|
363 |
catch (CqiClientException e) {
|
|
364 |
// TODO Auto-generated catch block
|
|
365 |
e.printStackTrace();
|
|
366 |
}
|
|
367 |
}
|
|
368 |
|
|
369 |
if (partsViewer.getTable().getSortDirection() == SWT.DOWN) s = -s;
|
|
370 |
|
|
371 |
return s;
|
|
372 |
}
|
|
373 |
});
|
|
374 |
|
|
375 |
|
338 |
376 |
partsViewer.getTable().addKeyListener(new KeyListener() {
|
339 |
377 |
|
340 |
378 |
@Override
|
... | ... | |
349 |
387 |
}
|
350 |
388 |
}
|
351 |
389 |
|
352 |
|
partsViewer.setInput(getResult());
|
353 |
390 |
try {
|
354 |
391 |
updateEditorFromResult(false);
|
355 |
392 |
} catch (Exception e1) {
|
... | ... | |
408 |
445 |
}
|
409 |
446 |
});
|
410 |
447 |
|
|
448 |
SelectionListener colSelection = new SelectionListener() {
|
|
449 |
|
|
450 |
@Override
|
|
451 |
public void widgetSelected(SelectionEvent e) {
|
|
452 |
|
|
453 |
TableColumn col = (TableColumn) e.widget;
|
|
454 |
Table table = partsViewer.getTable();
|
|
455 |
if (table.getSortColumn() == col) {
|
|
456 |
if (table.getSortDirection() == SWT.DOWN) {
|
|
457 |
table.setSortDirection(SWT.UP);
|
|
458 |
} else {
|
|
459 |
table.setSortDirection(SWT.DOWN);
|
|
460 |
}
|
|
461 |
} else {
|
|
462 |
table.setSortDirection(SWT.DOWN);
|
|
463 |
}
|
|
464 |
|
|
465 |
table.setSortColumn(col);
|
|
466 |
partsViewer.refresh();
|
|
467 |
}
|
|
468 |
|
|
469 |
@Override
|
|
470 |
public void widgetDefaultSelected(SelectionEvent e) { }
|
|
471 |
};
|
|
472 |
|
411 |
473 |
queryColumn = new TableViewerColumn(partsViewer, SWT.NONE);
|
412 |
474 |
queryColumn.getColumn().setText("Query");
|
413 |
475 |
queryColumn.getColumn().pack();
|
... | ... | |
448 |
510 |
}
|
449 |
511 |
});
|
450 |
512 |
|
|
513 |
TableViewerColumn tmpColumn = new TableViewerColumn(partsViewer, SWT.NONE);
|
|
514 |
tmpColumn.getColumn().setText("");
|
|
515 |
tmpColumn.getColumn().pack();
|
|
516 |
tmpColumn.setLabelProvider(new CellLabelProvider() {
|
|
517 |
|
|
518 |
private String EMPTY = "";
|
|
519 |
|
|
520 |
@Override
|
|
521 |
public void update(ViewerCell cell) {
|
|
522 |
cell.setText(EMPTY);
|
|
523 |
}
|
|
524 |
});
|
|
525 |
|
|
526 |
nameColumn.getColumn().addSelectionListener(colSelection);
|
|
527 |
queryColumn.getColumn().addSelectionListener(colSelection);
|
|
528 |
sizeColumn.getColumn().addSelectionListener(colSelection);
|
|
529 |
|
451 |
530 |
partsViewer.setInput(getResult());
|
|
531 |
|
|
532 |
TXMEditor.packColumns(this.partsViewer);
|
452 |
533 |
}
|
453 |
534 |
|
454 |
535 |
/**
|
... | ... | |
539 |
620 |
|
540 |
621 |
@Override
|
541 |
622 |
public void updateEditorFromResult(boolean update) throws Exception {
|
|
623 |
|
542 |
624 |
partsViewer.setInput(getResult());
|
|
625 |
|
|
626 |
TXMEditor.packColumns(this.partsViewer);
|
543 |
627 |
}
|
544 |
628 |
}
|