X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=org.simantics.interop.update%2Fsrc%2Forg%2Fsimantics%2Finterop%2Fupdate%2Feditor%2FModelUpdateEditor.java;h=2c7f1ce03b0c000499dbc285accf7083b0c83a83;hb=f169a988f57b3b22f3076104fab445ef7e75b5da;hp=1779b8f6bbdaf188b1556a2c61d69669a3035374;hpb=b0205b09bbd81755eb69452eae0142d5a93f95a4;p=simantics%2Finterop.git diff --git a/org.simantics.interop.update/src/org/simantics/interop/update/editor/ModelUpdateEditor.java b/org.simantics.interop.update/src/org/simantics/interop/update/editor/ModelUpdateEditor.java index 1779b8f..2c7f1ce 100644 --- a/org.simantics.interop.update/src/org/simantics/interop/update/editor/ModelUpdateEditor.java +++ b/org.simantics.interop.update/src/org/simantics/interop/update/editor/ModelUpdateEditor.java @@ -40,6 +40,7 @@ import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.Text; +import org.simantics.Simantics; import org.simantics.db.ReadGraph; import org.simantics.db.Resource; import org.simantics.db.Session; @@ -51,16 +52,14 @@ import org.simantics.db.request.Read; import org.simantics.interop.test.GraphChanges; import org.simantics.interop.update.Activator; import org.simantics.interop.update.model.ModelUpdate; -import org.simantics.interop.update.model.PropertyChange; import org.simantics.interop.update.model.ModelUpdate.WarningListener; +import org.simantics.interop.update.model.PropertyChange; import org.simantics.interop.update.model.UpdateList; import org.simantics.interop.update.model.UpdateNode; import org.simantics.interop.update.model.UpdateOp; import org.simantics.interop.update.model.UpdateStatus; import org.simantics.interop.update.model.UpdateTree; import org.simantics.interop.utils.TableUtils; -import org.simantics.ui.SimanticsUI; -import org.simantics.utils.datastructures.Callback; import org.simantics.utils.datastructures.Pair; import org.simantics.utils.ui.ExceptionUtils; @@ -196,18 +195,15 @@ public abstract class ModelUpdateEditor extends Composite implements WarningList changeViewer.setUseHashlookup(true); - TableViewerColumn selection = TableUtils.addColumn(changeViewer, getColumntTitle(0), false, false, 20); - TableViewerColumn diagram = TableUtils.addColumn(changeViewer, getColumntTitle(1), true, true, 100); - TableViewerColumn symbol = TableUtils.addColumn(changeViewer, getColumntTitle(2), true, true, 100); - TableViewerColumn property = TableUtils.addColumn(changeViewer, getColumntTitle(3), true, true, 100); - TableViewerColumn oldValue = TableUtils.addColumn(changeViewer, getColumntTitle(4), true, true, 100); - TableViewerColumn newValue = TableUtils.addColumn(changeViewer, getColumntTitle(5), true, true, 100); - - diagram.setLabelProvider(getLabelProvider(1)); - symbol.setLabelProvider(getLabelProvider(2)); - property.setLabelProvider(getLabelProvider(3)); - oldValue.setLabelProvider(getLabelProvider(4)); - newValue.setLabelProvider(getLabelProvider(5)); + TableViewerColumn cols[] = new TableViewerColumn[getChangeListColumnCount()]; + TableViewerColumn selection = TableUtils.addColumn(changeViewer, getColumntTitle(0), false, false, getChangeListColumnWidth(0)); + cols[0] = selection; + for (int i = 1 ; i < getChangeListColumnCount(); i++) { + TableViewerColumn column = TableUtils.addColumn(changeViewer, getColumntTitle(i), true, getChangeListColumnSortable(i), getChangeListColumnWidth(i)); + cols[i] = column; + column.setLabelProvider(getLabelProvider(i)); + configureChangeListColumn(i, column); + } selection.setLabelProvider(new SelectionLabelProvider()); selection.getColumn().addSelectionListener(new SelectionAdapter() { @@ -265,8 +261,28 @@ public abstract class ModelUpdateEditor extends Composite implements WarningList }); } + protected int getChangeListColumnCount() { + return 6; + } + + protected int getChangeListColumnWidth(int col) { + if (col == 0) + return 20; + return 100; + } + + protected boolean getChangeListColumnSortable(int col) { + if (col == 0) + return false; + return true; + } + + protected void configureChangeListColumn(int col, TableViewerColumn column) { + + } + protected Session getSession() { - return SimanticsUI.getSession(); + return Simantics.getSession(); } protected String getColumntTitle(int i) { @@ -433,12 +449,9 @@ public abstract class ModelUpdateEditor extends Composite implements WarningList } - }, new Callback() { - @Override - public void run(DatabaseException parameter) { - if (parameter != null) - ExceptionUtils.logAndShowError("Cannot update model", parameter); - } + }, e -> { + if (e != null) + ExceptionUtils.logAndShowError("Cannot update model", e); }); } @@ -609,10 +622,8 @@ public abstract class ModelUpdateEditor extends Composite implements WarningList private class SelectionEditingSupport extends EditingSupport { - @SuppressWarnings("rawtypes") public SelectionEditingSupport(ColumnViewer viewer) { super(viewer); - } @Override @@ -633,7 +644,6 @@ public abstract class ModelUpdateEditor extends Composite implements WarningList return pc.selected(); } - @SuppressWarnings("unchecked") @Override protected void setValue(Object element, Object value) { if (update == null || !update.isInit())