From: luukkainen Date: Mon, 30 Jan 2012 14:55:34 +0000 (+0000) Subject: Issue severity and object. X-Git-Tag: v1.31.0~95 X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=commitdiff_plain;h=3ab008708794d83956059e492de1657ad9da836d;p=simantics%2Finterop.git Issue severity and object. Added more data to Issues View refs #3169 git-svn-id: https://www.simantics.org/svn/simantics/interoperability/trunk@24103 ac1ea38d-2e2b-0410-8846-a27921b304fc --- diff --git a/org.simantics.interop/src/org/simantics/interop/utils/StringColumnComparator.java b/org.simantics.interop/src/org/simantics/interop/utils/StringColumnComparator.java index e2a338a..076559c 100644 --- a/org.simantics.interop/src/org/simantics/interop/utils/StringColumnComparator.java +++ b/org.simantics.interop/src/org/simantics/interop/utils/StringColumnComparator.java @@ -32,56 +32,58 @@ public class StringColumnComparator extends ViewerComparator { @Override public int compare(Viewer viewer, Object e1, Object e2) { + int rc = 0; int cat1 = category(e1); int cat2 = category(e2); if (cat1 != cat2) { - return cat1 - cat2; - } + rc = cat1 - cat2; + } else { - String name1 = null; - String name2 = null; - - - - if (viewer == null || !(viewer instanceof ContentViewer)) { - name1 = e1.toString(); - name2 = e2.toString(); - } else { - IBaseLabelProvider prov = ((ContentViewer) viewer).getLabelProvider(); - if (viewer instanceof TableViewer && ((TableViewer)viewer).getLabelProvider(propertyIndex) != null) { - CellLabelProvider clp = ((TableViewer)viewer).getLabelProvider(propertyIndex); - if (clp instanceof ILabelProvider) { - ILabelProvider ilb = (ILabelProvider)clp; - name1 = ilb.getText(e1); - name2 = ilb.getText(e2); - } - } - if (name1 == null) { - if (prov instanceof ITableLabelProvider) { - ITableLabelProvider lprov = (ITableLabelProvider) prov; - name1 = lprov.getColumnText(e1,propertyIndex); - name2 = lprov.getColumnText(e2,propertyIndex); - } else if (prov instanceof ILabelProvider) { - ILabelProvider lprov = (ILabelProvider) prov; - name1 = lprov.getText(e1); - name2 = lprov.getText(e2); - } else { - name1 = e1.toString(); - name2 = e2.toString(); + String name1 = null; + String name2 = null; + + + + if (viewer == null || !(viewer instanceof ContentViewer)) { + name1 = e1.toString(); + name2 = e2.toString(); + } else { + IBaseLabelProvider prov = ((ContentViewer) viewer).getLabelProvider(); + if (viewer instanceof TableViewer && ((TableViewer)viewer).getLabelProvider(propertyIndex) != null) { + CellLabelProvider clp = ((TableViewer)viewer).getLabelProvider(propertyIndex); + if (clp instanceof ILabelProvider) { + ILabelProvider ilb = (ILabelProvider)clp; + name1 = ilb.getText(e1); + name2 = ilb.getText(e2); + } } - } - } - if (name1 == null) { - name1 = "";//$NON-NLS-1$ - } - if (name2 == null) { - name2 = "";//$NON-NLS-1$ + if (name1 == null) { + if (prov instanceof ITableLabelProvider) { + ITableLabelProvider lprov = (ITableLabelProvider) prov; + name1 = lprov.getColumnText(e1,propertyIndex); + name2 = lprov.getColumnText(e2,propertyIndex); + } else if (prov instanceof ILabelProvider) { + ILabelProvider lprov = (ILabelProvider) prov; + name1 = lprov.getText(e1); + name2 = lprov.getText(e2); + } else { + name1 = e1.toString(); + name2 = e2.toString(); + } + } + } + if (name1 == null) { + name1 = "";//$NON-NLS-1$ + } + if (name2 == null) { + name2 = "";//$NON-NLS-1$ + } + + // use the comparator to compare the strings + rc = getComparator().compare(name1, name2); } - - // use the comparator to compare the strings - int rc = getComparator().compare(name1, name2); if (direction != DESCENDING) rc = -rc; return rc; diff --git a/org.simantics.interop/src/org/simantics/interop/utils/TableUtils.java b/org.simantics.interop/src/org/simantics/interop/utils/TableUtils.java index debe732..aaf87cd 100644 --- a/org.simantics.interop/src/org/simantics/interop/utils/TableUtils.java +++ b/org.simantics.interop/src/org/simantics/interop/utils/TableUtils.java @@ -14,7 +14,6 @@ public class TableUtils { public static TableViewerColumn addColumn(final TableViewer viewer, String text, boolean resize, boolean sort, int width) { final TableViewerColumn twc = new TableViewerColumn(viewer, SWT.NONE); final TableColumn tc = twc.getColumn(); - //final TableColumn tc = new TableColumn(viewer.getTable(), SWT.NONE); tc.setText(text); tc.setResizable(resize); tc.setWidth(width); @@ -22,8 +21,13 @@ public class TableUtils { tc.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { - StringColumnComparator comparator = (StringColumnComparator)viewer.getComparator(); - //TableColumn tc = twc.getColumn(); + StringColumnComparator comparator = null; + if (viewer.getComparator() instanceof StringColumnComparator) { + comparator = (StringColumnComparator)viewer.getComparator(); + } else { + comparator = new StringColumnComparator(); + viewer.setComparator(comparator); + } TableColumn tcs[] = viewer.getTable().getColumns(); int index = -1; for (int i = 0; i