Commit 2d1af22e authored by Maxym Borodenko's avatar Maxym Borodenko
Browse files

Draft: MCPD descriptor list

parent 8d9d3a91
......@@ -45,6 +45,7 @@ import org.eclipse.jface.viewers.TableViewerColumn;
import org.eclipse.jface.viewers.TreeSelection;
import org.eclipse.jface.viewers.TreeViewer;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.jface.viewers.ViewerComparator;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.CTabFolder;
import org.eclipse.swt.custom.CTabItem;
......@@ -67,6 +68,7 @@ import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.FileDialog;
import org.eclipse.swt.widgets.Item;
import org.eclipse.swt.widgets.Menu;
import org.eclipse.swt.widgets.MenuItem;
import org.eclipse.swt.widgets.MessageBox;
......@@ -493,10 +495,11 @@ public class AppWindow {
DragSource dragSource = new DragSource(table, DND.DROP_LINK);
dragSource.setTransfer(new Transfer[] { LocalSelectionTransfer.getTransfer() });
final String PREFERRED_NAME_COLUMN = "Preferred name";
TableViewerColumn tableViewerColumn = new TableViewerColumn(tableViewer, SWT.NONE);
TableColumn tblclmnPreferredName = tableViewerColumn.getColumn();
tblclmnPreferredName.setWidth(100);
tblclmnPreferredName.setText("Preferred name");
tblclmnPreferredName.setText(PREFERRED_NAME_COLUMN);
TableViewerColumn tableViewerColumn_2 = new TableViewerColumn(tableViewer, SWT.NONE);
TableColumn tblclmnTerm = tableViewerColumn_2.getColumn();
......@@ -508,6 +511,44 @@ public class AppWindow {
tblclmnRdfTerm.setWidth(100);
tblclmnRdfTerm.setText("RDF URL");
table.setSortColumn(tblclmnPreferredName); // set default sorted column
table.setSortDirection(SWT.DOWN);
for (TableColumn column : table.getColumns()) {
column.addListener(SWT.Selection, e -> {
if (column.equals(tblclmnRdfTerm))
return; // skip 'RDF URL' column
final Item sortColumn = table.getSortColumn();
int direction = table.getSortDirection();
if (column.equals(sortColumn)) {
direction = direction == SWT.UP ? SWT.DOWN : SWT.UP;
} else {
table.setSortColumn(column);
direction = SWT.DOWN;
}
table.setSortDirection(direction);
tableViewer.refresh();
});
}
tableViewer.setComparator(new ViewerComparator() {
@Override
public int compare(Viewer viewer, Object e1, Object e2) {
TableColumn sortColumn = table.getSortColumn();
int sortDirection = table.getSortDirection();
if (sortColumn.getText().equals(PREFERRED_NAME_COLUMN)) {
if (sortDirection == SWT.UP) {
return ((ColumnDef) e2).getPreferredName().compareTo(((ColumnDef) e1).getPreferredName());
}
return ((ColumnDef) e1).getPreferredName().compareTo(((ColumnDef) e2).getPreferredName());
}
if (sortDirection == SWT.UP) {
return ((ColumnDef) e2).getTitle().compareTo(((ColumnDef) e1).getTitle());
}
return ((ColumnDef) e1).getTitle().compareTo(((ColumnDef) e2).getTitle());
}
});
table.pack();
dragSource.addDragListener(new DragSourceAdapter() {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment