Use Consumer interface instead of deprecated Callback interface 94/1294/3
authorTuukka Lehtonen <tuukka.lehtonen@semantum.fi>
Thu, 7 Dec 2017 07:32:18 +0000 (09:32 +0200)
committerTuukka Lehtonen <tuukka.lehtonen@semantum.fi>
Thu, 7 Dec 2017 07:42:43 +0000 (09:42 +0200)
Also removed some compilation warnings at the same time.

refs #7655

Change-Id: I8e84652fd50853d598ddec299fc1fc6e30776bc2

63 files changed:
bundles/org.simantics.annotation.ui/src/org/simantics/annotation/ui/actions/AnnotationDropActionFactory.java
bundles/org.simantics.browsing.ui.graph.impl/src/org/simantics/browsing/ui/graph/impl/EnumerationVariableModifier.java
bundles/org.simantics.browsing.ui.graph.impl/src/org/simantics/browsing/ui/graph/impl/EnumerationVariableModifier2.java
bundles/org.simantics.browsing.ui.graph.impl/src/org/simantics/browsing/ui/graph/impl/EnumerationVariableModifier3.java
bundles/org.simantics.browsing.ui.graph.impl/src/org/simantics/browsing/ui/graph/impl/GraphFactoryStringModifier.java
bundles/org.simantics.browsing.ui.graph.impl/src/org/simantics/browsing/ui/graph/impl/GraphStringIndexModifier.java
bundles/org.simantics.browsing.ui.graph.impl/src/org/simantics/browsing/ui/graph/impl/GraphStringModifier.java
bundles/org.simantics.browsing.ui.graph.impl/src/org/simantics/browsing/ui/graph/impl/LabelModifier.java
bundles/org.simantics.browsing.ui.graph.impl/src/org/simantics/browsing/ui/graph/impl/VariableModifier.java
bundles/org.simantics.browsing.ui.model/src/org/simantics/browsing/ui/model/modifiers/VariableModifier2.java
bundles/org.simantics.charts/src/org/simantics/charts/ui/ChartGroupDropActionFactory.java
bundles/org.simantics.charts/src/org/simantics/charts/ui/ChartItemDropActionFactory.java
bundles/org.simantics.db.common/src/org/simantics/db/common/provider/AsyncResourceProvider.java
bundles/org.simantics.db.common/src/org/simantics/db/common/provider/ResourceProviders.java
bundles/org.simantics.db.common/src/org/simantics/db/common/request/DelayedWriteRequest.java
bundles/org.simantics.db.common/src/org/simantics/db/common/request/WriteOnlyRequest.java
bundles/org.simantics.db.common/src/org/simantics/db/common/request/WriteRequest.java
bundles/org.simantics.db.common/src/org/simantics/db/common/utils/Transaction.java
bundles/org.simantics.db.impl/src/org/simantics/db/impl/graph/PossibleObjectProcedure.java
bundles/org.simantics.db.impl/src/org/simantics/db/impl/graph/ReadGraphImpl.java
bundles/org.simantics.db.impl/src/org/simantics/db/impl/procedure/CallWrappedSingleQueryProcedure4.java
bundles/org.simantics.db.impl/src/org/simantics/db/impl/procedure/ResultCallWrappedQueryProcedure4.java
bundles/org.simantics.db.impl/src/org/simantics/db/impl/procedure/ResultCallWrappedSingleQueryProcedure4.java
bundles/org.simantics.db.impl/src/org/simantics/db/impl/query/AssertedPredicates.java
bundles/org.simantics.db.impl/src/org/simantics/db/impl/query/AssertedStatements.java
bundles/org.simantics.db.impl/src/org/simantics/db/impl/query/AsyncMultiReadEntry.java
bundles/org.simantics.db.impl/src/org/simantics/db/impl/query/AsyncReadEntry.java
bundles/org.simantics.db.impl/src/org/simantics/db/impl/query/BinaryQuery.java
bundles/org.simantics.db.impl/src/org/simantics/db/impl/query/CacheEntryBase.java
bundles/org.simantics.db.management/src/org/simantics/db/management/SessionContext.java
bundles/org.simantics.db.management/src/org/simantics/db/management/SessionContextProvider.java
bundles/org.simantics.db.server/.classpath
bundles/org.simantics.db.server/.settings/org.eclipse.jdt.core.prefs [new file with mode: 0644]
bundles/org.simantics.db.server/META-INF/MANIFEST.MF
bundles/org.simantics.debug.ui/src/org/simantics/debug/ui/GraphDebugger.java
bundles/org.simantics.diagram/src/org/simantics/diagram/flag/DiagramFlagPreferences.java
bundles/org.simantics.diagram/src/org/simantics/diagram/handler/ConnectionRoutingMenuContribution.java
bundles/org.simantics.diagram/src/org/simantics/diagram/handler/TerminalConnectionDirectionsMenuContribution.java
bundles/org.simantics.diagram/src/org/simantics/diagram/participant/ConnectionBuilder.java
bundles/org.simantics.diagram/src/org/simantics/diagram/runtime/RuntimeDiagramManager.java
bundles/org.simantics.document.ui/src/org/simantics/document/ui/actions/AddUrlDocument.java
bundles/org.simantics.document.ui/src/org/simantics/document/ui/actions/AddUrlDocumentWithDetail.java
bundles/org.simantics.document.ui/src/org/simantics/document/ui/actions/ImportDocumentWithDetail.java
bundles/org.simantics.document.ui/src/org/simantics/document/ui/graphfile/FileDocumentUtil.java
bundles/org.simantics.document/src/org/simantics/document/FileDocumentUtil.java
bundles/org.simantics.event/src/org/simantics/event/view/handler/ClaimAction.java
bundles/org.simantics.event/src/org/simantics/event/view/handler/Delete.java
bundles/org.simantics.event/src/org/simantics/event/view/handler/DenyAction.java
bundles/org.simantics.g2d/src/org/simantics/g2d/element/ElementHints.java
bundles/org.simantics.issues.ui/src/org/simantics/issues/ui/contribution/IssueContextDropAction.java
bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/diagram/monitor/MonitorClassFactory2.java
bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/diagramEditor/DiagramEditorStates.java
bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/diagramEditor/e4/DiagramViewer.java
bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/modelBrowser/model/Experiment.java
bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/modelBrowser2/model/SubscriptionNode.java
bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/property/RestoreDefaultValueHandler.java
bundles/org.simantics.modeling/src/org/simantics/modeling/actions/DisconnectFlag.java
bundles/org.simantics.modeling/src/org/simantics/modeling/typicals/TypicalDiagramTemplateListener.java
bundles/org.simantics.simulation/src/org/simantics/simulation/project/ExperimentRuns.java
bundles/org.simantics.spreadsheet.ui/src/org/simantics/spreadsheet/ui/SheetClass.java
bundles/org.simantics.spreadsheet.ui/src/org/simantics/spreadsheet/ui/SheetFactory.java
bundles/org.simantics/src/org/simantics/NameLabelUtil.java
tests/org.simantics.db.tests/src/org/simantics/db/tests/api/write/request/WriteCallbackFailureTest.java

index 5d9f939d164efd2128dd021f2e43233fa4acb5c7..4f4480e2bbdd3f43e280038e6bd61041a8d19c8e 100644 (file)
@@ -18,7 +18,6 @@ import org.simantics.db.layer0.adapter.DropActionFactory;
 import org.simantics.db.layer0.request.PossibleModel;
 import org.simantics.layer0.Layer0;
 import org.simantics.utils.ObjectUtils;
-import org.simantics.utils.datastructures.Callback;
 import org.simantics.utils.ui.ErrorLogger;
 import org.simantics.utils.ui.ISelectionUtils;
 
@@ -78,14 +77,9 @@ public class AnnotationDropActionFactory implements DropActionFactory {
                                                CommentMetadata cm = graph.getMetadata(CommentMetadata.class);
                                        graph.addMetadata(cm.add("Moved " + movedAnnotationItems.size() + " annotations to folder " + name + ", resource " + targetFolder));
                                        }
-                               }, new Callback<DatabaseException>() {
-                                       
-                                       @Override
-                                       public void run(DatabaseException e) {
-                                               if (e!= null)
-                                                       ErrorLogger.defaultLogError(e);
-                                               
-                                       }
+                               }, e -> {
+                                       if (e!= null)
+                                               ErrorLogger.defaultLogError(e);
                                });
                                
                        }
index b551adae60a163969ba1ea2b356deefa3fb71be4..412827ffa3d934eca15e33ff376d7c622f1f96e0 100644 (file)
@@ -22,7 +22,6 @@ import org.simantics.db.common.request.ReadRequest;
 import org.simantics.db.exception.DatabaseException;
 import org.simantics.db.layer0.variable.Variable;
 import org.simantics.db.layer0.variable.VariableWrite;
-import org.simantics.utils.datastructures.Callback;
 import org.simantics.utils.ui.ErrorLogger;
 
 /**
@@ -65,12 +64,9 @@ public class EnumerationVariableModifier implements EnumerationModifier {
 
     protected void doModify(final String label) {
         session.asyncRequest(new VariableWrite(variable, label, null, null),
-                new Callback<DatabaseException>() {
-            @Override
-            public void run(DatabaseException parameter) {
-                if (parameter != null)
-                    ErrorLogger.defaultLogError(parameter);
-            }
+                parameter -> {
+                    if (parameter != null)
+                        ErrorLogger.defaultLogError(parameter);
         });
     }
 
index 48c4ab4fb5bc207e83828f4226e64bb69e280e7f..78672a21d342bef5b29dd3b5ca5dde1da8fe9ded 100644 (file)
@@ -33,7 +33,6 @@ import org.simantics.db.layer0.variable.Variable;
 import org.simantics.db.layer0.variable.Variables;
 import org.simantics.db.request.Read;
 import org.simantics.layer0.Layer0;
-import org.simantics.utils.datastructures.Callback;
 import org.simantics.utils.ui.ErrorLogger;
 
 /**
@@ -116,12 +115,9 @@ public class EnumerationVariableModifier2 implements EnumerationModifier {
     
     protected void doModify(final String label) {
         session.asyncRequest(new Write(variable, label),
-                new Callback<DatabaseException>() {
-            @Override
-            public void run(DatabaseException parameter) {
-                if (parameter != null)
-                    ErrorLogger.defaultLogError(parameter);
-            }
+                parameter -> {
+                    if (parameter != null)
+                        ErrorLogger.defaultLogError(parameter);
         });
     }
 
index 63e5a771f3e8bb96bf94aecae53323705a61b047..32bd28c17f789f1658a271a5e064807c4932f833 100644 (file)
@@ -23,9 +23,7 @@ import org.simantics.db.WriteGraph;
 import org.simantics.db.common.request.WriteRequest;
 import org.simantics.db.exception.DatabaseException;
 import org.simantics.db.layer0.variable.Variable;
-import org.simantics.db.layer0.variable.Variables;
 import org.simantics.db.request.Read;
-import org.simantics.utils.datastructures.Callback;
 import org.simantics.utils.ui.ErrorLogger;
 
 /**
@@ -84,12 +82,9 @@ public class EnumerationVariableModifier3 implements EnumerationModifier {
     
     protected void doModify(final String label) {
         session.asyncRequest(new Write(variable, label),
-                new Callback<DatabaseException>() {
-            @Override
-            public void run(DatabaseException parameter) {
-                if (parameter != null)
-                    ErrorLogger.defaultLogError(parameter);
-            }
+                parameter -> {
+                    if (parameter != null)
+                        ErrorLogger.defaultLogError(parameter);
         });
     }
 
index 6d0e43d176ca0ced2ccc7be8457a12ec42ccfcd3..99e053bdaa24dc2e227c5d3107dda632049c40c1 100644 (file)
@@ -16,7 +16,6 @@ import org.simantics.db.Resource;
 import org.simantics.db.WriteGraph;
 import org.simantics.db.common.request.WriteRequest;
 import org.simantics.db.exception.DatabaseException;
-import org.simantics.utils.datastructures.Callback;
 import org.simantics.utils.ui.ErrorLogger;
 
 /**
@@ -55,12 +54,9 @@ public class GraphFactoryStringModifier extends AbstractFactoryStringModifier {
             public void perform(WriteGraph graph) throws DatabaseException {
                 doModifyWithFactory(graph, label);
             }
-        }, new Callback<DatabaseException>() {
-            @Override
-            public void run(DatabaseException parameter) {
-                if (parameter != null)
-                    ErrorLogger.defaultLogError(parameter);
-            }
+        }, parameter -> {
+            if (parameter != null)
+                ErrorLogger.defaultLogError(parameter);
         });
     }
 
index e9adba21e6ad2f2fe886d1d37dba8d19149d52a6..cbde1d845232f4551e7f52f7c3d2bedc6cdcdb65 100644 (file)
@@ -27,7 +27,6 @@ import org.simantics.db.layer0.adapter.StringIndexModifier;
 import org.simantics.db.layer0.adapter.StringModifier;
 import org.simantics.db.layer0.adapter.TObjectIntPair;
 import org.simantics.layer0.utils.representation.StringRepresentation2;
-import org.simantics.utils.datastructures.Callback;
 import org.simantics.utils.ui.ErrorLogger;
 
 /**
@@ -189,12 +188,9 @@ public abstract class GraphStringIndexModifier implements Modifier {
             public void perform(WriteGraph graph) throws DatabaseException {
                 doModify(graph, t);
             }
-        }, new Callback<DatabaseException>() {
-            @Override
-            public void run(DatabaseException parameter) {
-                if (parameter != null)
-                    ErrorLogger.defaultLogError(parameter);
-            }
+        }, parameter -> {
+            if (parameter != null)
+                ErrorLogger.defaultLogError(parameter);
         });
     }
 
index a3635e3b8970b95b0f2c00c4987aaa7280d02f5e..1e3ddf696275cd84da27102f76c52264ce7121c2 100644 (file)
@@ -16,7 +16,6 @@ import org.simantics.db.RequestProcessor;
 import org.simantics.db.WriteGraph;
 import org.simantics.db.common.request.WriteRequest;
 import org.simantics.db.exception.DatabaseException;
-import org.simantics.utils.datastructures.Callback;
 import org.simantics.utils.ui.ErrorLogger;
 
 /**
@@ -55,12 +54,9 @@ public abstract class GraphStringModifier extends AbstractStringModifier {
             public void perform(WriteGraph graph) throws DatabaseException {
                 doModify(graph, label);
             }
-        }, new Callback<DatabaseException>() {
-            @Override
-            public void run(DatabaseException parameter) {
-                if (parameter != null)
-                    ErrorLogger.defaultLogError(parameter);
-            }
+        }, parameter -> {
+            if (parameter != null)
+                ErrorLogger.defaultLogError(parameter);
         });
     }
 
index f0583a500c6075eb7475e2676f29e8c8ef4c246d..8f3c729936295f037e75717f7433b0d12b5e8cc3 100644 (file)
@@ -11,6 +11,8 @@
  *******************************************************************************/
 package org.simantics.browsing.ui.graph.impl;
 
+import java.util.function.Consumer;
+
 import org.simantics.browsing.ui.content.Labeler.Modifier;
 import org.simantics.browsing.ui.graph.impl.request.GetLabel;
 import org.simantics.databoard.Bindings;
@@ -22,7 +24,6 @@ import org.simantics.db.exception.DatabaseException;
 import org.simantics.db.layer0.util.Layer0Utils;
 import org.simantics.db.request.Write;
 import org.simantics.layer0.Layer0;
-import org.simantics.utils.datastructures.Callback;
 import org.simantics.utils.ui.ErrorLogger;
 import org.simantics.utils.ui.ExceptionUtils;
 
@@ -33,7 +34,7 @@ import org.simantics.utils.ui.ExceptionUtils;
  * 
  * @author Tuukka Lehtonen
  */
-public class LabelModifier implements Modifier, Callback<DatabaseException> {
+public class LabelModifier implements Modifier, Consumer<DatabaseException> {
 
     private final Session  session;
     protected final Resource resource;
@@ -97,7 +98,7 @@ public class LabelModifier implements Modifier, Callback<DatabaseException> {
     }
 
     @Override
-    public void run(DatabaseException parameter) {
+    public void accept(DatabaseException parameter) {
         if (parameter != null) {
             ExceptionUtils.logError("Label modification failed, see exception for details.", parameter);
         }
index c5d2f81b42c36c74ac29eb304a99d9d1d86ef62d..cfceaaf4bae468d2608e98189391c0828787b548 100644 (file)
@@ -42,7 +42,6 @@ import org.simantics.db.layer0.variable.Variable;
 import org.simantics.db.layer0.variable.VariableWrite;
 import org.simantics.db.layer0.variable.Variables;
 import org.simantics.scl.runtime.function.Function1;
-import org.simantics.utils.datastructures.Callback;
 import org.simantics.utils.format.FormattingUtils;
 import org.simantics.utils.ui.ErrorLogger;
 
@@ -189,14 +188,11 @@ public class VariableModifier implements Modifier {
                                } catch (DatabaseException e) {
                                        e.printStackTrace();
                                }
-               session.asyncRequest(new VariableWrite(variable, label, null, targetUnit), new Callback<DatabaseException>() {
-                   @Override               
-                   public void run(DatabaseException parameter) {
-                       if (parameter != null)
-                           ErrorLogger.defaultLogError(parameter);
-                       else
-                               modifySuccessful();
-                   }
+               session.asyncRequest(new VariableWrite(variable, label, null, targetUnit), parameter -> {
+                   if (parameter != null)
+                       ErrorLogger.defaultLogError(parameter);
+                   else
+                       modifySuccessful();
                });
        }
     }
index d8d2bc165caa8f3ab9c9cf364208b26f604b5db1..5eee1be5891b3cec1ad06f32fbf5cd9f56b4399f 100644 (file)
@@ -25,7 +25,6 @@ import org.simantics.db.layer0.variable.Variable;
 import org.simantics.db.layer0.variable.VariableWrite;
 import org.simantics.db.layer0.variable.Variables;
 import org.simantics.scl.runtime.function.Function1;
-import org.simantics.utils.datastructures.Callback;
 
 /**
  * @author Tuukka Lehtonen
@@ -85,14 +84,11 @@ public class VariableModifier2 implements Modifier {
     }
 
     protected void doModify(final String label) {
-        session.asyncRequest(new VariableWrite(variable, label), new Callback<DatabaseException>() {
-            @Override
-            public void run(DatabaseException parameter) {
-                if (parameter != null)
-                    ErrorLogger.defaultLogError(parameter);
-                else
-                       modifySuccessful();
-            }
+        session.asyncRequest(new VariableWrite(variable, label), parameter -> {
+            if (parameter != null)
+                ErrorLogger.defaultLogError(parameter);
+            else
+                modifySuccessful();
         });
     }
 
index 285f2d13ee8680ba3e658f9ccd07868b3d74758e..6149d0611552db784e97c30a3c683e17a3e98648 100644 (file)
@@ -39,7 +39,6 @@ import org.simantics.db.layer0.util.SimanticsKeys;
 import org.simantics.graph.db.TransferableGraphs;
 import org.simantics.graph.representation.TransferableGraph1;
 import org.simantics.layer0.Layer0;
-import org.simantics.utils.datastructures.Callback;
 import org.simantics.utils.ui.ErrorLogger;
 import org.simantics.utils.ui.ISelectionUtils;
 import org.simantics.utils.ui.dialogs.ShowError;
@@ -120,12 +119,9 @@ public class ChartGroupDropActionFactory implements DropActionFactory {
                                                        throws DatabaseException {
                                graph.syncRequest(moveChartsRequest(chartGroup, chartsToMove));
                                        }
-                }, new Callback<DatabaseException>() {
-                    @Override
-                    public void run(DatabaseException e) {
-                        if (e != null)
-                            ErrorLogger.defaultLogError(e);
-                    }
+                }, e -> {
+                    if (e != null)
+                        ErrorLogger.defaultLogError(e);
                 });
             }
         };
index 454a3baa43975be213be22524417fed09e506776..e66c64713c0dcf2644227515af0fa56fb0646ee8 100644 (file)
@@ -25,7 +25,6 @@ import org.simantics.db.layer0.SelectionHints;
 import org.simantics.db.layer0.adapter.DropActionFactory;
 import org.simantics.db.layer0.request.PossibleModel;
 import org.simantics.modeling.ModelingResources;
-import org.simantics.utils.datastructures.Callback;
 import org.simantics.utils.ui.ErrorLogger;
 import org.simantics.utils.ui.ISelectionUtils;
 
@@ -77,12 +76,9 @@ public class ChartItemDropActionFactory implements DropActionFactory {
                        graph.deny(chartItem, CHART.Chart_Item_HasSubscriptionItem);
                        graph.claim(chartItem, CHART.Chart_Item_HasSubscriptionItem, subscriptionItem);
                     }
-                }, new Callback<DatabaseException>() {
-                    @Override
-                    public void run(DatabaseException e) {
-                        if (e != null)
-                            ErrorLogger.defaultLogError(e);
-                    }
+                }, e -> {
+                    if (e != null)
+                        ErrorLogger.defaultLogError(e);
                 });
             }
         };
index 2cb5a35759b1a8e5330be6e5965d4777c6410890..7db748a3e274d28316732d0bc216c5a36b4abf88 100644 (file)
  *******************************************************************************/
 package org.simantics.db.common.provider;
 
+import java.util.function.Consumer;
+
 import org.simantics.db.AsyncReadGraph;
 import org.simantics.db.ReadGraph;
 import org.simantics.db.Resource;
-import org.simantics.utils.datastructures.Callback;
 
 /**
  * An interface for externalizing the logic of retrieving an arbitrary resource
@@ -40,6 +41,6 @@ public interface AsyncResourceProvider {
      * @param graph an asynchronous graph for retrieving the resource to return
      * @param callback a callback that is invoked with the provided resource
      */
-    void get(AsyncReadGraph graph, Callback<Resource> callback);
+    void get(AsyncReadGraph graph, Consumer<Resource> callback);
 
 }
index b5957e6362bf9be0187dc07fe4bfc82c2448e4e9..955266aa92b51384e7990cf233ee2b02ba27e61e 100644 (file)
  *******************************************************************************/
 package org.simantics.db.common.provider;
 
+import java.util.function.Consumer;
+
 import org.simantics.db.AsyncReadGraph;
 import org.simantics.db.ReadGraph;
 import org.simantics.db.Resource;
-import org.simantics.utils.datastructures.Callback;
 
 /**
  * @author Tuukka Lehtonen
@@ -33,8 +34,8 @@ public final class ResourceProviders {
     public static final AsyncResourceProvider createAsync(final Resource resource) {
         return new AsyncResourceProvider() {
             @Override
-            public void get(AsyncReadGraph g, Callback<Resource> callback) {
-                callback.run(resource);
+            public void get(AsyncReadGraph g, Consumer<Resource> callback) {
+                callback.accept(resource);
             }
         };
     }
index 044e91acc7e6e9922158f3b18d833f99846daae1..d634cb71502281fce1eb8521794a2d62397658d5 100644 (file)
@@ -22,7 +22,6 @@ import org.simantics.db.procedure.Procedure;
 import org.simantics.db.request.DelayedWrite;
 import org.simantics.db.request.UndoTraits;
 import org.simantics.db.request.WriteInterface;
-import org.simantics.utils.datastructures.Callback;
 
 
 /**
@@ -90,14 +89,9 @@ public abstract class DelayedWriteRequest implements DelayedWrite, UndoTraits, W
 
     @Override
     public void request(AsyncRequestProcessor processor, final Procedure<Object> procedure) {
-       processor.asyncRequest(this, new Callback<DatabaseException>() {
-                       
-                       @Override
-                       public void run(DatabaseException parameter) {
-                               if(parameter != null) procedure.exception(parameter);
-                               else procedure.execute(null);
-                       }
-                       
+       processor.asyncRequest(this, parameter -> {
+               if(parameter != null) procedure.exception(parameter);
+               else procedure.execute(null);
                });
     }
     
index 654bf32bf2baf2861bf274d21263cba66e249a25..e3f8edb1e50fe6c687030ad2454d69590fcb3cce 100644 (file)
@@ -18,7 +18,6 @@ import org.simantics.db.exception.DatabaseException;
 import org.simantics.db.procedure.Procedure;
 import org.simantics.db.request.WriteInterface;
 import org.simantics.db.request.WriteOnly;
-import org.simantics.utils.datastructures.Callback;
 
 
 /**
@@ -89,14 +88,9 @@ public abstract class WriteOnlyRequest implements WriteOnly, WriteInterface<Obje
 
     @Override
     public void request(AsyncRequestProcessor processor, final Procedure<Object> procedure) {
-       processor.asyncRequest(this, new Callback<DatabaseException>() {
-                       
-                       @Override
-                       public void run(DatabaseException parameter) {
-                               if(parameter != null) procedure.exception(parameter);
-                               else procedure.execute(null);
-                       }
-                       
+       processor.asyncRequest(this, parameter -> {
+               if(parameter != null) procedure.exception(parameter);
+               else procedure.execute(null);
                });
     }
     
index cb9460d13a2b49286b8b554683be9a81157122e7..97386a861c6f8484c46da9b31729c19b42b658f7 100644 (file)
@@ -20,7 +20,6 @@ import org.simantics.db.procedure.Procedure;
 import org.simantics.db.request.UndoTraits;
 import org.simantics.db.request.Write;
 import org.simantics.db.request.WriteInterface;
-import org.simantics.utils.datastructures.Callback;
 
 
 /**
@@ -95,14 +94,9 @@ public abstract class WriteRequest implements Write, UndoTraits, WriteInterface<
 
     @Override
     public void request(AsyncRequestProcessor processor, final Procedure<Object> procedure) {
-       processor.asyncRequest(this, new Callback<DatabaseException>() {
-                       
-                       @Override
-                       public void run(DatabaseException parameter) {
-                               if(parameter != null) procedure.exception(parameter);
-                               else procedure.execute(null);
-                       }
-                       
+       processor.asyncRequest(this, parameter -> {
+               if(parameter != null) procedure.exception(parameter);
+               else procedure.execute(null);
                });
     }
     
index 0a8dcea413295cdf1cd436d6a2b04995f4642b39..9e5d563a51205fd2855400458fac64bf69111ff5 100644 (file)
@@ -13,6 +13,7 @@ package org.simantics.db.common.utils;
 import java.util.Collection;
 import java.util.Set;
 import java.util.concurrent.Semaphore;
+import java.util.function.Consumer;
 
 import org.simantics.databoard.accessor.Accessor;
 import org.simantics.databoard.binding.Binding;
@@ -40,7 +41,6 @@ import org.simantics.db.procedure.Procedure;
 import org.simantics.db.request.DelayedWrite;
 import org.simantics.db.request.Read;
 import org.simantics.db.request.Write;
-import org.simantics.utils.datastructures.Callback;
 
 /**
  * Synchronous Transaction. <p>
@@ -216,12 +216,9 @@ public class Transaction {
                                t.ts = new Semaphore(0);
                                transactions.set(t);
 
-                               Callback<DatabaseException> callback = new Callback<DatabaseException>() {
-                                       @Override
-                                       public void run(DatabaseException parameter) {
-                                               t.error = parameter;
-                                               t.es.release(9999);
-                                       }
+                               Consumer<DatabaseException> callback = parameter -> {
+                                       t.error = parameter;
+                                       t.es.release(9999);
                                };
 
                                Write request =  new Write() { 
@@ -260,12 +257,9 @@ public class Transaction {
                                t.ts = new Semaphore(0);
                                transactions.set(t);
 
-                               Callback<DatabaseException> callback = new Callback<DatabaseException>() {
-                                       @Override
-                                       public void run(DatabaseException parameter) {
-                                               t.error = parameter;
-                                               t.es.release(9999);
-                                       }
+                               Consumer<DatabaseException> callback = parameter -> {
+                                       t.error = parameter;
+                                       t.es.release(9999);
                                };
 
                                DelayedWrite request =  new DelayedWriteRequest() { 
index 066e61055098dd8b89bb57ea9728d66806979982..f3e01a76f2bc93c33dd46121fb36b7a3abb04f8e 100644 (file)
@@ -2,7 +2,6 @@ package org.simantics.db.impl.graph;
 
 import org.simantics.db.Resource;
 import org.simantics.db.exception.DatabaseException;
-import org.simantics.db.exception.NoSingleResultException;
 import org.simantics.db.impl.query.IntProcedure;
 import org.simantics.db.impl.query.QueryProcessor;
 
index b853ed5191e3654f5cfbddea240b33c48b77bff1..ff127a09b93fae51ac2c3793e7169f417b444d5e 100644 (file)
@@ -1949,7 +1949,7 @@ public class ReadGraphImpl implements ReadGraph {
 
        }
 
-       final AsyncProcedure NONE = new AsyncProcedure() {
+       final AsyncProcedure<?> NONE = new AsyncProcedure<Object>() {
 
                @Override
                public void execute(AsyncReadGraph graph, Object result) {
@@ -2152,7 +2152,7 @@ public class ReadGraphImpl implements ReadGraph {
 
                if (parent != null || listener != null || ((request.getFlags() & RequestFlags.SCHEDULE) > 0)) {
 
-                       Object syncParent = request;
+//                     Object syncParent = request;
 
 //                     final ReadGraphImpl newGraph = newSync();
 
@@ -2180,7 +2180,7 @@ public class ReadGraphImpl implements ReadGraph {
                        // System.out.println("direct call " + request );
 
                        // Do not set the sync state.parent for external threads
-                       Object syncParent = request;
+//                     Object syncParent = request;
 
 //                     final ReadGraphImpl newGraph = newSync();
 
@@ -2342,7 +2342,7 @@ public class ReadGraphImpl implements ReadGraph {
 
                if (parent != null || listener != null) {
 
-                       Object syncParent = request;
+//                     Object syncParent = request;
 
 //                     final ReadGraphImpl newGraph = newSync();
 
@@ -2352,7 +2352,7 @@ public class ReadGraphImpl implements ReadGraph {
 
                } else {
 
-                       Object syncParent = request;
+//                     Object syncParent = request;
 
 //                     final ReadGraphImpl newGraph = newSync();
 
@@ -2471,7 +2471,7 @@ public class ReadGraphImpl implements ReadGraph {
 
                if (parent != null || listener != null) {
 
-                       Object syncParent = request;
+//                     Object syncParent = request;
 
 //                     final ReadGraphImpl newGraph = newSync();
 
@@ -2519,7 +2519,7 @@ public class ReadGraphImpl implements ReadGraph {
 
                if (parent != null || listener != null) {
 
-                       Object syncParent = request;
+//                     Object syncParent = request;
 
 //                     final ReadGraphImpl newGraph = newSync();
 
@@ -2529,7 +2529,7 @@ public class ReadGraphImpl implements ReadGraph {
 
                } else {
 
-                       Object syncParent = request;
+//                     Object syncParent = request;
 
 //                     final ReadGraphImpl newGraph = newSync();
 
@@ -6470,7 +6470,6 @@ public class ReadGraphImpl implements ReadGraph {
        }
     }
 
-    @SuppressWarnings("unchecked")
     @Override
     public Variant getVariantValue2(Resource r, Object context) throws DatabaseException {
         Layer0 L0 = processor.getL0(this);
index c7affc4afae3671d320f46032743bee74c993857..14a64dac8f594f078481b347fd4c6d8450a69f4f 100644 (file)
@@ -15,7 +15,6 @@ import java.util.concurrent.atomic.AtomicBoolean;
 
 import org.simantics.db.AsyncReadGraph;
 import org.simantics.db.common.utils.Logger;
-import org.simantics.db.impl.graph.AsyncBarrierImpl;
 import org.simantics.db.procedure.AsyncProcedure;
 
 public class CallWrappedSingleQueryProcedure4<Result> implements AsyncProcedure<Result> {
index c24e8766811bf073cd48eeb5029634c53005a1ad..3b65f2c2ebcc50979aad09079ab423e666d0c4a1 100644 (file)
@@ -16,7 +16,6 @@ import java.util.concurrent.atomic.AtomicBoolean;
 
 import org.simantics.db.AsyncReadGraph;
 import org.simantics.db.common.utils.Logger;
-import org.simantics.db.impl.query.QueryProcessor.AsyncBarrier;
 import org.simantics.db.procedure.AsyncMultiProcedure;
 
 public class ResultCallWrappedQueryProcedure4<Result> implements AsyncMultiProcedure<Result> {
index a6717c9d9ec991c48fd8150eca4de5b17e9f78ec..1a0522dd36f42347573175333260608804f163f4 100644 (file)
@@ -15,7 +15,6 @@ import java.util.concurrent.atomic.AtomicBoolean;
 
 import org.simantics.db.AsyncReadGraph;
 import org.simantics.db.common.utils.Logger;
-import org.simantics.db.impl.graph.AsyncBarrierImpl;
 import org.simantics.db.procedure.AsyncProcedure;
 
 public class ResultCallWrappedSingleQueryProcedure4<Result> implements AsyncProcedure<Result> {
index 31b0f3e90e977c9d7d496739e9f9cafdaae19ccf..af8858e5a9954ba59415d1f915c204ec653cdfbf 100644 (file)
  *******************************************************************************/
 package org.simantics.db.impl.query;
 
-import java.util.ArrayList;
 import java.util.concurrent.Semaphore;
 
 import org.simantics.db.RelationInfo;
 import org.simantics.db.impl.graph.ReadGraphImpl;
-import org.simantics.db.impl.procedure.IntProcedureAdapter;import org.simantics.db.impl.procedure.InternalProcedure;
+import org.simantics.db.impl.procedure.IntProcedureAdapter;
+import org.simantics.db.impl.procedure.InternalProcedure;
 import org.simantics.db.procedure.ListenerBase;
 
 
index 6e7ca62e55c3cdb824177528e65808856e845928..41b8e08d59486690543fd79494195c76395a01f9 100644 (file)
@@ -11,7 +11,6 @@
  *******************************************************************************/
 package org.simantics.db.impl.query;
 
-import java.util.ArrayList;
 import java.util.concurrent.Semaphore;
 import java.util.concurrent.atomic.AtomicInteger;
 
index 8a8b18b7dda5641113207102d8c43f54c5608716..fac6b011f23d2137e14755430efd88fa1365cc1e 100644 (file)
@@ -100,7 +100,8 @@ final public class AsyncMultiReadEntry<T> extends CacheEntryBase {
         
     }
 
-    final synchronized public void addOrSet(Object item) {
+    @SuppressWarnings("unchecked")
+       final synchronized public void addOrSet(Object item) {
 
        assert(isPending());
        
@@ -173,6 +174,7 @@ final public class AsyncMultiReadEntry<T> extends CacheEntryBase {
         
     }
 
+       @SuppressWarnings("unchecked")
        @Override
        public void performFromCache(ReadGraphImpl graph, Object provider, Object procedure) {
                
index 010f554463373ace1edf3ac21cef13a4cc17122a..a9726a75d6ac4eb5df323625ffd19da9369bcb9b 100644 (file)
@@ -11,8 +11,6 @@
  *******************************************************************************/
 package org.simantics.db.impl.query;
 
-import java.util.ArrayList;
-
 import org.simantics.db.AsyncReadGraph;
 import org.simantics.db.impl.DebugPolicy;
 import org.simantics.db.impl.graph.ReadGraphImpl;
@@ -147,6 +145,7 @@ final public class AsyncReadEntry<T> extends CacheEntryBase {
         
     }
 
+       @SuppressWarnings("unchecked")
        public void performFromCache(ReadGraphImpl graph, Object provider, Object procedure) {
                
         AsyncProcedure<T> proc = (AsyncProcedure<T>)procedure;
index e7af8d04d683f15fd9677ad6573596cd40851ab5..cb2df4eea79b5f25d0e0ffb63912c5e63d7c07f7 100644 (file)
@@ -71,6 +71,7 @@ abstract public class BinaryQuery<Procedure> extends CacheEntryBase implements Q
         recompute(graph, (QueryProcessor)provider);
     }
     
+    @SuppressWarnings("unchecked")
     @Override
     public void performFromCache(ReadGraphImpl graph, Object provider, Object procedure) {
         performFromCache(graph, (QueryProcessor)provider, (Procedure)procedure);
index 5776857d330ad98374d9b8c07d575ddb0118f7b2..d30d59320b656b1178d9dab10730fa2d2ca61d0d 100644 (file)
@@ -168,6 +168,7 @@ abstract public class CacheEntryBase extends CacheEntry {
        this.result = result;
     }
     
+    @SuppressWarnings("unchecked")
     @Override
     final public <T> T getResult() {
         assert(statusOrException != DISCARDED);
index ef5f270531021b890888c3016ae2f08e8ed096f9..dae8bea7545184cbf7faf82dbc76f6ababa8ab35 100644 (file)
@@ -11,7 +11,6 @@
  *******************************************************************************/
 package org.simantics.db.management;
 
-import java.io.IOException;
 import java.lang.reflect.Method;
 import java.util.Arrays;
 import java.util.UUID;
@@ -20,17 +19,12 @@ import java.util.concurrent.TimeoutException;
 import org.eclipse.core.runtime.IStatus;
 import org.simantics.db.Disposable;
 import org.simantics.db.ReadGraph;
-import org.simantics.db.ServerReference;
 import org.simantics.db.Session;
-import org.simantics.db.SessionManager;
-import org.simantics.db.SessionReference;
 import org.simantics.db.VirtualGraph;
-import org.simantics.db.authentication.UserAuthenticationAgent;
 import org.simantics.db.common.processor.MergingDelayedWriteProcessor;
 import org.simantics.db.common.processor.MergingGraphRequestProcessor;
 import org.simantics.db.common.request.ReadRequest;
 import org.simantics.db.exception.DatabaseException;
-import org.simantics.db.exception.InternalException;
 import org.simantics.db.management.internal.Activator;
 import org.simantics.db.service.LifecycleSupport;
 import org.simantics.db.service.VirtualGraphSupport;
@@ -43,10 +37,6 @@ import org.simantics.utils.datastructures.hints.HintContext;
 import org.simantics.utils.threads.IThreadWorkQueue;
 import org.simantics.utils.threads.SyncListenerList;
 
-import fi.vtt.simantics.procore.ProCoreServerReference;
-import fi.vtt.simantics.procore.ProCoreSessionReference;
-import fi.vtt.simantics.procore.SessionManagerSource;
-
 /**
  * Holds all information that is needed to create and manage a single database
  * session in the Simantics workbench UI.
@@ -62,8 +52,6 @@ public class SessionContext extends HintContext implements ISessionContext, Disp
 
     private Session                 session;
 
-    private UserAuthenticationAgent authenticator;
-
     private boolean                 servicesRegistered       = false;
 
     private IStatus                 servicesRegisteredStatus = null;
@@ -72,72 +60,12 @@ public class SessionContext extends HintContext implements ISessionContext, Disp
         return new SessionContext(session, initialize);
     }
 
-//    public static SessionContext openSession(IServerAddress info, UserAuthenticationAgent auth) throws IOException, DatabaseException {
-//        return new SessionContext(info, auth, false);
-//    }
-//
-//    public static SessionContext openAndInitializeSession(IServerAddress info, UserAuthenticationAgent auth) throws IOException, DatabaseException {
-//        return new SessionContext(info, auth, true);
-//    }
-
-    private static SessionReference createSessionReference(/*IServerAddress address,*/ long sessionId) throws InternalException {
-        ProCoreServerReference server = new ProCoreServerReference();
-        ProCoreSessionReference ref = new ProCoreSessionReference(server, sessionId);
-        return ref;
-    }
-
-//    private SessionContext(IServerAddress addr, UserAuthenticationAgent auth, boolean initialize) throws IOException, DatabaseException {
-//        if (addr == null)
-//            throw new IllegalArgumentException("null address");
-////        this.address = addr;
-//        this.authenticator = auth;
-//
-//        SessionManager sessionManager = SessionManagerProvider.getInstance().getSessionManager();
-//
-//        if (initialize) {
-//            initializeSession(sessionManager);
-//            if (SESSION_DEBUG) {
-//                System.err.println("Initialized session: " + addr);
-//                System.err.flush();
-//            }
-//        } else {
-//            SessionReference ref = createSessionReference(SessionManagerSource.NullSessionId);
-//            this.session = sessionManager.createSession(ref, auth);
-//            if (SESSION_DEBUG) {
-//                System.err.println("Opened session: " + addr);
-//                System.err.flush();
-//            }
-//        }
-//
-//    }
-
     private SessionContext(Session session, boolean initialize) throws DatabaseException {
         if (initialize)
             initializeSession(session);
-        ServerReference ref = session.getService( LifecycleSupport.class ).getSessionReference().getServerReference();
-//        this.address = ref.serverAddress();
         this.session = session;
     }
 
-    private void initializeSession(SessionManager sessionManager) throws DatabaseException, IOException {
-        Session s = null;
-        boolean success = false;
-        try {
-            SessionReference ref = createSessionReference(SessionManagerSource.NullSessionId);
-            s = sessionManager.createSession(ref, authenticator);
-            initializeSession(s);
-            this.session = s;
-            success = true;
-        } finally {
-            if (!success) {
-                if (s != null) {
-                    LifecycleSupport support = s.getService(LifecycleSupport.class);
-                    support.close();
-                }
-            }
-        }
-    }
-
     private void initializeSession(Session s) throws DatabaseException {
         s.registerService(MergingGraphRequestProcessor.class, new MergingGraphRequestProcessor("SessionService", s, 20));
         s.registerService(MergingDelayedWriteProcessor.class, new MergingDelayedWriteProcessor(s, 20));
index 6f434c13fb26dbe03fafede32f0a71bcc87b740e..7b76b24bbf62e2c24b98c1340ba5f437bdc652ae 100644 (file)
@@ -18,7 +18,7 @@ import org.eclipse.core.runtime.ListenerList;
  */
 public class SessionContextProvider implements ISessionContextProvider {
 
-    private ListenerList    listeners = new ListenerList();
+    private ListenerList<ISessionContextChangedListener> listeners = new ListenerList<>();
     
     private Object          handle;
 
index 751c8f2e504c40d1c41ebbd87d8f8968529e9c30..b862a296d38fe04269faeee6c9d77d11ff77380d 100644 (file)
@@ -1,7 +1,7 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<classpath>
-       <classpathentry kind="src" path="src"/>
-       <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
-       <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
-       <classpathentry kind="output" path="bin"/>
-</classpath>
+<?xml version="1.0" encoding="UTF-8"?>\r
+<classpath>\r
+       <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>\r
+       <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>\r
+       <classpathentry kind="src" path="src"/>\r
+       <classpathentry kind="output" path="bin"/>\r
+</classpath>\r
diff --git a/bundles/org.simantics.db.server/.settings/org.eclipse.jdt.core.prefs b/bundles/org.simantics.db.server/.settings/org.eclipse.jdt.core.prefs
new file mode 100644 (file)
index 0000000..295926d
--- /dev/null
@@ -0,0 +1,7 @@
+eclipse.preferences.version=1\r
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled\r
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8\r
+org.eclipse.jdt.core.compiler.compliance=1.8\r
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error\r
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error\r
+org.eclipse.jdt.core.compiler.source=1.8\r
index b95a655f36153dedf0ea4e8fc61b142be193c4c6..0fcdaca677b1bd54773d510029e7114fee34433f 100644 (file)
@@ -7,7 +7,7 @@ Bundle-Activator: org.simantics.db.server.internal.Activator
 Bundle-Vendor: VTT Technical Research Centre of Finland
 Export-Package: org.simantics.db.server,
  org.simantics.db.server.internal
-Bundle-RequiredExecutionEnvironment: JavaSE-1.7
+Bundle-RequiredExecutionEnvironment: JavaSE-1.8
 Import-Package: gnu.trove.impl.hash,
  gnu.trove.iterator,
  gnu.trove.map.hash,
index 158c37a360bccc308d7a127c29bd0aa8a9293573..b51ed4d000ca0b2b8aa6a889546a0fa93950c93d 100644 (file)
@@ -126,7 +126,6 @@ import org.simantics.ui.utils.ResourceAdaptionUtils;
 import org.simantics.utils.Container;
 import org.simantics.utils.FileUtils;
 import org.simantics.utils.datastructures.BijectionMap;
-import org.simantics.utils.datastructures.Callback;
 import org.simantics.utils.strings.AlphanumComparator;
 import org.simantics.utils.ui.ErrorLogger;
 import org.simantics.utils.ui.PathUtils;
@@ -601,14 +600,8 @@ public class GraphDebugger extends Composite {
                             g.denyStatement(s, p, o);
                         }
 
-                    }, new Callback<DatabaseException>() {
-
-                        @Override
-                        public void run(DatabaseException parameter) {
-                            refreshBrowser();
-                        }
-
-                    });
+                    }, parameter -> refreshBrowser()
+                    );
                 } else if (location.startsWith("about:-edit-value")) {
                     String target = location.replace("about:-edit-value", "");
                     final Resource o = links.getRight(target);
@@ -692,13 +685,10 @@ public class GraphDebugger extends Composite {
                                             //modifier.modify( g, htmlEscape( value ) );
                                             modifier.modify( g, value );
                                         }
-                                    }, new Callback<DatabaseException>() {
-                                        @Override
-                                        public void run(DatabaseException parameter) {
-                                            if (parameter != null)
-                                                ErrorLogger.defaultLogError(parameter);
-                                            refreshBrowser();
-                                        }
+                                    }, parameter -> {
+                                        if (parameter != null)
+                                            ErrorLogger.defaultLogError(parameter);
+                                        refreshBrowser();
                                     });
                                     return;
                                 }
index b11d89151b0c0aada933c9a96fb52233dde92df7..c1f6a837ad13e45868f4d210370656bb2d30a598 100644 (file)
@@ -11,7 +11,6 @@ import org.simantics.db.common.request.ResourceRead;
 import org.simantics.db.common.request.WriteRequest;
 import org.simantics.db.exception.DatabaseException;
 import org.simantics.diagram.stubs.DiagramResource;
-import org.simantics.utils.datastructures.Callback;
 import org.simantics.utils.ui.ErrorLogger;
 
 /**
@@ -91,12 +90,9 @@ public class DiagramFlagPreferences {
             public void perform(WriteGraph graph) throws DatabaseException {
                 setFlagLabelingScheme(graph, forTarget, scheme);
             }
-        }, new Callback<DatabaseException>() {
-            @Override
-            public void run(DatabaseException parameter) {
-                if (parameter != null)
-                    ErrorLogger.defaultLogError(parameter);
-            }
+        }, parameter -> {
+            if (parameter != null)
+                ErrorLogger.defaultLogError(parameter);
         });
     }
 
index 7f98894edd4b71be512e2e200e3770877ba5f2d9..78ac6361cbb0d757192a0d377a8f50c1574734eb 100644 (file)
@@ -44,7 +44,6 @@ import org.simantics.scl.commands.Command;
 import org.simantics.scl.commands.Commands;
 import org.simantics.structural.stubs.StructuralResource2;
 import org.simantics.ui.contribution.DynamicMenuContribution;
-import org.simantics.utils.datastructures.Callback;
 import org.simantics.utils.ui.AdaptionUtils;
 import org.simantics.utils.ui.ExceptionUtils;
 
@@ -296,12 +295,9 @@ public class ConnectionRoutingMenuContribution extends DynamicMenuContribution {
                         graph.claim(connection, routingTag, connection);
                     }
                 }
-            }, new Callback<DatabaseException>() {
-                @Override
-                public void run(DatabaseException parameter) {
-                    if (parameter != null)
-                        ExceptionUtils.logError(parameter);
-                }
+            }, parameter -> {
+                if (parameter != null)
+                    ExceptionUtils.logError(parameter);
             });
         }
 
@@ -344,12 +340,9 @@ public class ConnectionRoutingMenuContribution extends DynamicMenuContribution {
                     CommentMetadata cm = graph.getMetadata(CommentMetadata.class);
                     graph.addMetadata(cm.add("Set routing for an element."));
                 }
-            }, new Callback<DatabaseException>() {
-                @Override
-                public void run(DatabaseException parameter) {
-                    if (parameter != null)
-                        ExceptionUtils.logError(parameter);
-                }
+            }, parameter -> {
+                if (parameter != null)
+                    ExceptionUtils.logError(parameter);
             });
         }
 
index 22760ef95af81d1f560fe6b7c213bf55ce8363ba..b5aa65951c2699eee348350723365dd67a022dbb 100644 (file)
@@ -33,7 +33,6 @@ import org.simantics.db.common.request.WriteRequest;
 import org.simantics.db.exception.DatabaseException;
 import org.simantics.diagram.stubs.DiagramResource;
 import org.simantics.ui.contribution.DynamicMenuContribution;
-import org.simantics.utils.datastructures.Callback;
 import org.simantics.utils.ui.AdaptionUtils;
 import org.simantics.utils.ui.ExceptionUtils;
 
@@ -136,12 +135,9 @@ public class TerminalConnectionDirectionsMenuContribution extends DynamicMenuCon
                                                graph.claimLiteral(terminal, DIA.Terminal_AllowedDirections, mask, Bindings.INTEGER);
                                        }
                                }
-                       }, new Callback<DatabaseException>() {
-                               @Override
-                               public void run(DatabaseException parameter) {
-                                       if (parameter != null)
-                                               ExceptionUtils.logError(parameter);
-                               }
+                       }, parameter -> {
+                               if (parameter != null)
+                                       ExceptionUtils.logError(parameter);
                        });
                }
 
index 72cdb17524fa3def3ae8acc771836153590ffcfe..599aba0d042d49b72c380fb8c66981a1869a9122 100644 (file)
@@ -79,7 +79,6 @@ import org.simantics.structural2.modelingRules.CPTerminal;
 import org.simantics.structural2.modelingRules.ConnectionJudgement;
 import org.simantics.structural2.modelingRules.IConnectionPoint;
 import org.simantics.structural2.modelingRules.IModelingRules;
-import org.simantics.utils.datastructures.Callback;
 import org.simantics.utils.datastructures.Pair;
 import org.simantics.utils.ui.ErrorLogger;
 
@@ -222,12 +221,9 @@ public class ConnectionBuilder {
                                         }
                                     }
                                 }
-                            }, new Callback<DatabaseException>() {
-                                @Override
-                                public void run(DatabaseException e) {
-                                    if (e != null)
-                                        ErrorLogger.defaultLogError(e);
-                                }
+                            }, e -> {
+                                if (e != null)
+                                    ErrorLogger.defaultLogError(e);
                             });
                         }
                     }
index 10c2d89040b1fe2a800091cda84767be54982f09..bfc439101a81593c895d29da41a6183c0bbfec5c 100644 (file)
@@ -33,7 +33,6 @@ import org.simantics.diagram.stubs.DiagramResource;
 import org.simantics.layer0.Layer0;
 import org.simantics.operation.Layer0X;
 import org.simantics.ui.workbench.IResourceEditorInput2;
-import org.simantics.utils.datastructures.Callback;
 import org.simantics.utils.ui.ErrorLogger;
 
 /**
@@ -300,13 +299,10 @@ public class RuntimeDiagramManager {
                         if (runtime != null)
                             writeConfig(graph, runtime, diagram, desc);
                     }
-                }, new Callback<DatabaseException>() {
-                    @Override
-                    public void run(DatabaseException e) {
-                        ListenerSupport s = support;
-                        if (e != null && s != null)
-                            s.exception(e);
-                    }
+                }, e -> {
+                    ListenerSupport s = support;
+                    if (e != null && s != null)
+                        s.exception(e);
                 });
             }
 
index b5fbe0adddad16de16acc3f5694caf847aa1a9a5..6e312cb37897081638c77d9b49ce4584d53b26b6 100644 (file)
@@ -22,7 +22,6 @@ import org.simantics.db.exception.DatabaseException;
 import org.simantics.document.AddDocumentAction;
 import org.simantics.document.DocumentResource;
 import org.simantics.layer0.Layer0;
-import org.simantics.utils.datastructures.Callback;
 import org.simantics.utils.ui.ExceptionUtils;
 import org.simantics.utils.ui.validators.URLValidator;
 
@@ -68,14 +67,9 @@ public class AddUrlDocument extends AddDocumentAction {
                                                
                                                linkDocument(graph, resource, urlDocument);
                                        }
-                               },new Callback<DatabaseException>() {
-                                       @Override
-                                       public void run(DatabaseException parameter) {
-                                               if (parameter != null) {
-                                                       ExceptionUtils.logAndShowError("Cannot add URL link.", parameter);
-                                               }
-                                               
-                                       }
+                               }, e -> {
+                                       if (e != null)
+                                               ExceptionUtils.logAndShowError("Cannot add URL link.", e);
                                });
                        }
                };
index 5ed7a1a2bcf0926fb20a5fc417bafc86e877da49..61210a222b4f64dce3b2ea9dc3091b5d9efb0e2b 100644 (file)
@@ -25,7 +25,6 @@ import org.simantics.document.AddDocumentAction;
 import org.simantics.document.DocumentResource;
 import org.simantics.document.ui.dialogs.UrlDetailDialog;
 import org.simantics.layer0.Layer0;
-import org.simantics.utils.datastructures.Callback;
 import org.simantics.utils.ui.ExceptionUtils;
 
 /**
@@ -67,15 +66,10 @@ public class AddUrlDocumentWithDetail extends AddDocumentAction {
                                            linkDocument(graph, resource, urlDocument);
                                                dialog.getAnnotationConfigurator().apply(graph,urlDocument);
                                        }
-                               },new Callback<DatabaseException>() {
-                                       @Override
-                                       public void run(DatabaseException parameter) {
-                                               dialog.getAnnotationConfigurator().dispose();
-                                               if (parameter != null) {
-                                                       ExceptionUtils.logAndShowError("Cannot add URL link.", parameter);
-                                               }
-                                               
-                                       }
+                               }, e -> {
+                                       dialog.getAnnotationConfigurator().dispose();
+                                       if (e != null)
+                                               ExceptionUtils.logAndShowError("Cannot add URL link.", e);
                                });
                        }
                };
index 42a0a7c94fa8bd9476b069a73bf00698796fd8e9..091f33e7d931acc87257f5eb1a33821298b4731f 100644 (file)
@@ -25,7 +25,6 @@ import org.simantics.document.AddDocumentAction;
 import org.simantics.document.FileDocumentUtil;
 import org.simantics.document.ui.dialogs.FileDetailDialog;
 import org.simantics.layer0.Layer0;
-import org.simantics.utils.datastructures.Callback;
 import org.simantics.utils.ui.ExceptionUtils;
 
 /**
@@ -72,15 +71,10 @@ public class ImportDocumentWithDetail extends AddDocumentAction {
                                            Resource newDoc = doDocumentImport(graph, resource, filename, name);
                                                dialog.getAnnotationConfigurator().apply(graph,newDoc);
                                        }
-                               },new Callback<DatabaseException>() {                           
-                                       @Override
-                                       public void run(DatabaseException parameter) {
-                                               dialog.getAnnotationConfigurator().dispose();
-                                               if (parameter != null) {
-                                                       ExceptionUtils.logAndShowError("Cannot import document.", parameter);
-                                               }
-                                               
-                                       }
+                               }, e -> {
+                                       dialog.getAnnotationConfigurator().dispose();
+                                       if (e != null)
+                                               ExceptionUtils.logAndShowError("Cannot import document.", e);
                                });
                        }
                };
index 4933ca25162a49a25f126ee5f27447aaa1602e75..9a9e3f8f10723ddb925f13ae6795df53f1ad36b2 100644 (file)
@@ -61,14 +61,9 @@ public class FileDocumentUtil {
                                 importFile(graph, fileName,lib,rel);
                                
                        }
-               },new org.simantics.utils.datastructures.Callback<DatabaseException>() {
-                       
-                       @Override
-                       public void run(DatabaseException parameter) {
-                               if (parameter != null)
-                                       ExceptionUtils.logAndShowError("Cannot import file " + fileName, parameter);
-                               
-                       }
+               }, e -> {
+                       if (e != null)
+                               ExceptionUtils.logAndShowError("Cannot import file " + fileName, e);
                });
                        
                
index cab7e9a2c10ca615ee5d234f164757a2f4bf781c..4fc2eb93d7e00452bea8db4f0f188d7714495d8d 100644 (file)
@@ -60,14 +60,9 @@ public class FileDocumentUtil {
                                 importFile(graph, fileName,lib,rel);
                                
                        }
-               },new org.simantics.utils.datastructures.Callback<DatabaseException>() {
-                       
-                       @Override
-                       public void run(DatabaseException parameter) {
-                               if (parameter != null)
-                                       ExceptionUtils.logAndShowError("Cannot import file " + fileName, parameter);
-                               
-                       }
+               }, e -> {
+                       if (e != null)
+                               ExceptionUtils.logAndShowError("Cannot import file " + fileName, e);
                });
                        
                
index e46e3544273052b335ed6bbe702ef6bbcaad043b..81f205f2613159f1edc0fe314c850f464ce708b7 100644 (file)
@@ -11,7 +11,6 @@ import org.simantics.db.common.request.WriteRequest;
 import org.simantics.db.exception.DatabaseException;
 import org.simantics.db.service.VirtualGraphSupport;
 import org.simantics.layer0.Layer0;
-import org.simantics.utils.datastructures.Callback;
 import org.simantics.utils.ui.ErrorLogger;
 
 /**
@@ -52,12 +51,9 @@ public class ClaimAction extends Action {
                 public void perform(WriteGraph graph) throws DatabaseException {
                     claim(graph);
                 }
-            }, new Callback<DatabaseException>() {
-                @Override
-                public void run(DatabaseException parameter) {
-                    if (parameter != null)
-                        ErrorLogger.defaultLogError(parameter);
-                }
+            }, e -> {
+                if (e != null)
+                    ErrorLogger.defaultLogError(e);
             });
         }
     }
index 768c2834e819e31ba31542c208c4a32383cfc4f2..1b147abe18a35f5f76a5dc52c15be33b97ff28e0 100644 (file)
@@ -32,7 +32,6 @@ import org.simantics.db.layer0.SelectionHints;
 import org.simantics.db.service.VirtualGraphSupport;
 import org.simantics.event.ontology.EventResource;
 import org.simantics.layer0.Layer0;
-import org.simantics.utils.datastructures.Callback;
 import org.simantics.utils.ui.ISelectionUtils;
 
 
@@ -78,11 +77,8 @@ public class Delete extends AbstractHandler {
                            graph.syncRequest( new CorrectMilestoneLabelsAction(eventlog, vg) );
                }
             }
-        }, new Callback<DatabaseException>() {
-            @Override
-            public void run(DatabaseException e) {
-                if (e != null) Logger.defaultLogError(e);
-            }
+        }, e -> {
+            if (e != null) Logger.defaultLogError(e);
         });
         return null;
     }
index de2a12ce6c8cd3ee1b7d51be508b3ab259d7bba9..abbdba8001b1bdcab0bf0c38f4c408d955e45664 100644 (file)
@@ -12,7 +12,6 @@ import org.simantics.db.WriteGraph;
 import org.simantics.db.common.request.WriteRequest;
 import org.simantics.db.exception.DatabaseException;
 import org.simantics.db.service.VirtualGraphSupport;
-import org.simantics.utils.datastructures.Callback;
 import org.simantics.utils.ui.ErrorLogger;
 
 /**
@@ -53,12 +52,9 @@ public class DenyAction extends Action {
                     for (Resource subject : subjects)
                         graph.deny(subject, relation);
                 }
-            }, new Callback<DatabaseException>() {
-                @Override
-                public void run(DatabaseException parameter) {
-                    if (parameter != null)
-                        ErrorLogger.defaultLogError(parameter);
-                }
+            }, e -> {
+                if (e != null)
+                    ErrorLogger.defaultLogError(e);
             });
         }
     }
index dc8f914748d0f661d2a2c9925d78fdb29e8e1fa0..35f3a8591fb3de903c94e8d69f3ca3f24d3090f6 100644 (file)
@@ -22,6 +22,7 @@ import java.util.Collection;
 import java.util.HashMap;
 import java.util.Map;
 import java.util.Set;
+import java.util.function.Consumer;
 
 import org.simantics.g2d.canvas.Hints;
 import org.simantics.g2d.connection.ConnectionEntity;
@@ -32,7 +33,6 @@ import org.simantics.g2d.element.handler.SceneGraph;
 import org.simantics.g2d.image.Image;
 import org.simantics.g2d.utils.Alignment;
 import org.simantics.scenegraph.Node;
-import org.simantics.utils.datastructures.Callback;
 import org.simantics.utils.datastructures.hints.IHintContext.Key;
 import org.simantics.utils.datastructures.hints.IHintContext.KeyOf;
 
@@ -50,7 +50,7 @@ public class ElementHints {
      * For attaching a callback to an element that is invoked when KEY_SG_NODE
      * is initialized and set.
      */
-    public static final Key KEY_SG_CALLBACK = new SceneGraphNodeKey(Callback.class, "SG_NODE_CALLBACK");
+    public static final Key KEY_SG_CALLBACK = new SceneGraphNodeKey(Consumer.class, "SG_NODE_CALLBACK");
 
     /**
      * For describing the local affine transformation of an element.
index 6187159a4bdfba185c92d550fa644f8cd12d6ce5..80be3d185e36c7956b48d92c3145e9d6ef6d8ecc 100644 (file)
@@ -50,12 +50,9 @@ public class IssueContextDropAction implements DropActionFactory {
                     graph.claim(issue, ISSUE.Issue_HasContext, ISSUE.Issue_HasContext, ctx);
                 }
             }
-        }, new Callback<DatabaseException>() {
-            @Override
-            public void run(DatabaseException e) {
-                if (e != null)
-                    ErrorLogger.defaultLogError(e);
-            }
+        }, e -> {
+            if (e != null)
+                ErrorLogger.defaultLogError(e);
         });
     }
 
index 5c3d7fbe3a26318d0761461b8765ce042c87a9b2..17c26f48386e6455ae85301da8506b0fcd4b35d2 100644 (file)
@@ -60,7 +60,6 @@ import org.simantics.scl.runtime.function.Function1;
 import org.simantics.ui.colors.Colors;
 import org.simantics.ui.fonts.FontDescriptor;
 import org.simantics.ui.fonts.Fonts;
-import org.simantics.utils.datastructures.Callback;
 import org.simantics.utils.datastructures.hints.IHintContext.Key;
 import org.simantics.utils.datastructures.hints.IHintContext.KeyOf;
 
@@ -195,12 +194,9 @@ public class MonitorClassFactory2 extends SyncElementFactory {
                         }) {
                             @Override
                             public void accepted(MonitorVariable var) {
-                                session.asyncRequest(new MonitorVariableWrite(var.getVariable(), text), new Callback<DatabaseException>() {
-                                    @Override
-                                    public void run(DatabaseException e) {
-                                        if (e != null)
-                                            ErrorLogger.defaultLogError(e);
-                                    }
+                                session.asyncRequest(new MonitorVariableWrite(var.getVariable(), text), e -> {
+                                    if (e != null)
+                                        ErrorLogger.defaultLogError(e);
                                 });
                             }
                             @Override
index baf9cc3a2564d6309a1e919960c4562e4c07fb91..1af22dc87f192b46357a72b6989ee9b185bd4904 100644 (file)
@@ -41,7 +41,6 @@ import org.simantics.g2d.diagram.participant.Selection;
 import org.simantics.g2d.element.ElementUtils;
 import org.simantics.g2d.element.IElement;
 import org.simantics.layer0.Layer0;
-import org.simantics.utils.datastructures.Callback;
 
 /**
  * @author Tuukka Lehtonen
@@ -127,12 +126,9 @@ public class DiagramEditorStates {
                     }
                 });
             }
-        }, new Callback<DatabaseException>() {
-            @Override
-            public void run(DatabaseException parameter) {
-                if (parameter != null)
-                    support.exception(parameter);
-            }
+        }, e -> {
+            if (e != null)
+                support.exception(e);
         });
     }
 
index 61afc48f439a34724a8806f3cab6efd3b117aa48..0b3afd8a517ac1d63d41794418b61aec32e1d3cc 100644 (file)
@@ -158,7 +158,6 @@ import org.simantics.ui.workbench.TitleUpdater;
 import org.simantics.ui.workbench.ToolTipRequest;
 import org.simantics.ui.workbench.editor.input.InputValidationCombinators;
 import org.simantics.utils.DataContainer;
-import org.simantics.utils.datastructures.Callback;
 import org.simantics.utils.datastructures.hints.HintContext;
 import org.simantics.utils.datastructures.hints.HintListenerAdapter;
 import org.simantics.utils.datastructures.hints.IHintContext;
@@ -804,12 +803,9 @@ public class DiagramViewer
                        CommonDBUtils.selectClusterSet(graph, diagramResource);
                     DiagramGraphUtil.setDiagramDesc(graph, diagramResource, desc);
                 }
-            }, new Callback<DatabaseException>() {
-                @Override
-                public void run(DatabaseException parameter) {
-                    if (parameter != null)
-                        ErrorLogger.defaultLogError("Failed to write default diagram page description to database, see exception for details", parameter);
-                }
+            }, e -> {
+                if (e != null)
+                    ErrorLogger.defaultLogError("Failed to write default diagram page description to database, see exception for details", e);
             });
         }
 
index 78be9060a2136d58176d0a74f49ff15a860d2cfd..702b6b4ea09b7346dab4ab21c9138cf3b25dddd5 100644 (file)
@@ -171,11 +171,11 @@ public class Experiment extends Node implements INode2, IPathNode, IRefreshable,
     public Modifier getModifier(String columnId) {
         return new LabelModifier(session, resource) {
             @Override
-            public void run(DatabaseException ex) {
+            public void accept(DatabaseException ex) {
                 if (ex == null) {
                     refreshName();
                 } else {
-                    super.run(ex);
+                    super.accept(ex);
                 }
             }
         };
index 161607de6d2d3cc0928e00086de7657de1b14022..1729db5409fbc8d7b23e7c3d46c6d5b8f83f4b3e 100644 (file)
@@ -24,7 +24,6 @@ import org.simantics.modeling.subscription.AddSubscriptionItems;
 import org.simantics.modeling.utils.VariableReferences;
 import org.simantics.structural.ui.modelBrowser.nodes.AbstractNode;
 import org.simantics.ui.SimanticsUI;
-import org.simantics.utils.datastructures.Callback;
 import org.simantics.utils.ui.ErrorLogger;
 import org.simantics.utils.ui.ISelectionUtils;
 
@@ -59,12 +58,9 @@ public class SubscriptionNode extends AbstractNode implements IDeletable, IDropT
     }
 
     private void addSubscriptions(List<VariableReference> references) {
-        SimanticsUI.getSession().asyncRequest(new AddSubscriptionItems(resource, references), new Callback<DatabaseException>() {
-            @Override
-            public void run(DatabaseException e) {
-                if (e != null)
-                    ErrorLogger.defaultLogError(e);
-            }
+        SimanticsUI.getSession().asyncRequest(new AddSubscriptionItems(resource, references), e -> {
+            if (e != null)
+                ErrorLogger.defaultLogError(e);
         });
     }
 
index a439527ca4b73bc364c10304946236d7d6b1e5d7..d19e6dbfbc1415c8afe9142e6384938937dee65a 100644 (file)
@@ -33,7 +33,6 @@ import org.simantics.db.layer0.variable.Variable;
 import org.simantics.db.management.ISessionContext;
 import org.simantics.ui.SimanticsUI;
 import org.simantics.ui.workbench.IPropertyPage;
-import org.simantics.utils.datastructures.Callback;
 import org.simantics.utils.ui.ISelectionUtils;
 
 
@@ -113,12 +112,9 @@ public class RestoreDefaultValueHandler extends AbstractHandler {
                 }
                 graph.addMetadata(cm);
             }
-        }, new Callback<DatabaseException>() {
-            @Override
-            public void run(DatabaseException parameter) {
-                if (parameter != null)
-                    ErrorLogger.defaultLogError("Failed to restore default property values, see exception for details.", parameter);
-            }
+        }, e -> {
+            if (e != null)
+                ErrorLogger.defaultLogError("Failed to restore default property values, see exception for details.", e);
         });
     }
 
@@ -142,12 +138,9 @@ public class RestoreDefaultValueHandler extends AbstractHandler {
                         }
                     }
                 }
-            }, new Callback<DatabaseException>() {
-                @Override
-                public void run(DatabaseException parameter) {
-                    if (parameter != null)
-                        ErrorLogger.defaultLogError("Failed to restore default property values, see exception for details.", parameter);
-                }
+            }, e -> {
+                if (e != null)
+                    ErrorLogger.defaultLogError("Failed to restore default property values, see exception for details.", e);
             });
         }
         return changes;
index 4618d6aaa81edac2f5e424eb04de45f07c97d698..8ba0e340a0bceddcc9cdf603785e6ef47ff123dd 100644 (file)
@@ -24,7 +24,6 @@ import org.simantics.db.exception.DatabaseException;
 import org.simantics.diagram.flag.FlagUtil;
 import org.simantics.layer0.Layer0;
 import org.simantics.layer0.utils.operations.Operation;
-import org.simantics.utils.datastructures.Callback;
 import org.simantics.utils.datastructures.persistent.IContextMap;
 import org.simantics.utils.ui.ErrorLogger;
 
@@ -42,12 +41,9 @@ public class DisconnectFlag extends Operation {
             public void perform(WriteGraph g) throws DatabaseException {
                 disconnectFlags(g, Collections.singletonList(flag));
             }
-        }, new Callback<DatabaseException>() {
-            @Override
-            public void run(DatabaseException parameter) {
-                if (parameter != null)
-                    ErrorLogger.defaultLogError("Flag disconnect failed, see exception for details.", parameter);
-            }
+        }, e -> {
+            if (e != null)
+                ErrorLogger.defaultLogError("Flag disconnect failed, see exception for details.", e);
         });
     }
 
index 18ae271374bc1c236cb9d5f1eaaaf28be59ddafa..71ddc664d40f260b25bed85cacce04f192d84b30 100644 (file)
@@ -11,8 +11,6 @@
  *******************************************************************************/
 package org.simantics.modeling.typicals;
 
-import gnu.trove.set.hash.THashSet;
-
 import java.util.Map;
 
 import org.simantics.db.MetadataI;
@@ -31,10 +29,11 @@ import org.simantics.diagram.stubs.DiagramResource;
 import org.simantics.layer0.Layer0;
 import org.simantics.modeling.ModelingResources;
 import org.simantics.structural.stubs.StructuralResource2;
-import org.simantics.utils.datastructures.Callback;
 import org.simantics.utils.datastructures.MapSet;
 import org.simantics.utils.ui.ErrorLogger;
 
+import gnu.trove.set.hash.THashSet;
+
 /**
  * This listener needs to discover if changes are made to typical diagram
  * templates.
@@ -119,12 +118,9 @@ public class TypicalDiagramTemplateListener extends GenericChangeListener<Depend
         MapSet<Resource, Resource> changes = this.changedElementsByDiagram;
         this.changedElementsByDiagram = new MapSet.Hash<Resource, Resource>();
 
-        graph.asyncRequest(new SyncTypicalTemplatesToInstances(null, templates, changes), new Callback<DatabaseException>() {
-            @Override
-            public void run(DatabaseException parameter) {
-                if (parameter != null)
-                    ErrorLogger.defaultLogError("Typical template diagram synchronization to instances failes, see exception for details.", parameter);
-            }
+        graph.asyncRequest(new SyncTypicalTemplatesToInstances(null, templates, changes), e -> {
+            if (e != null)
+                ErrorLogger.defaultLogError("Typical template diagram synchronization to instances failes, see exception for details.", e);
         });
     }
 
index 23d6e386a2ef4f9bb7373088a2e0fc683150262e..c708153f22706365d3ba6638279cb8bbf88cf115 100644 (file)
@@ -19,7 +19,6 @@ import org.simantics.simulation.experiment.ExperimentState;
 import org.simantics.simulation.experiment.IExperiment;
 import org.simantics.simulation.experiment.IExperimentListener;
 import org.simantics.simulation.ontology.SimulationResource;
-import org.simantics.utils.datastructures.Callback;
 import org.simantics.utils.ui.ErrorLogger;
 
 /**
@@ -112,21 +111,18 @@ public class ExperimentRuns {
 
                 _run.set(run);
             }
-        }, new Callback<DatabaseException>() {
-            @Override
-            public void run(DatabaseException e) {
-                if (e != null) {
-                    if (listener != null)
-                        listener.onFailure(e);
-                    else
-                        ErrorLogger.defaultLogError(e);
-                } else {
-                    attachStateListener(session, experiment, _run.get());
-                    if (successCallback != null)
-                        successCallback.accept(_run.get());
-                    if (listener != null)
-                        listener.onExperimentActivated(experiment);
-                }
+        }, e -> {
+            if (e != null) {
+                if (listener != null)
+                    listener.onFailure(e);
+                else
+                    ErrorLogger.defaultLogError(e);
+            } else {
+                attachStateListener(session, experiment, _run.get());
+                if (successCallback != null)
+                    successCallback.accept(_run.get());
+                if (listener != null)
+                    listener.onExperimentActivated(experiment);
             }
         });
     }
@@ -153,12 +149,9 @@ public class ExperimentRuns {
                             CommentMetadata cm = graph.getMetadata(CommentMetadata.class);
                             graph.addMetadata(cm.add("Attaching state listener to track isActive for run"));
                         }
-                    }, new Callback<DatabaseException>() {
-                        @Override
-                        public void run(DatabaseException e) {
-                            if (e != null)
-                                ErrorLogger.defaultLogError(e);
-                        }
+                    }, e -> {
+                        if (e != null)
+                            ErrorLogger.defaultLogError(e);
                     });
                 }
             }
index 1df4a90e54c045f902845db5d8144f06e2047734..3c7c0cbab194be970c129cb459f99c46a36036f4 100644 (file)
@@ -12,6 +12,7 @@ package org.simantics.spreadsheet.ui;
 
 import java.awt.Shape;
 import java.awt.geom.Rectangle2D;
+import java.util.function.Consumer;
 
 import org.simantics.db.Resource;
 import org.simantics.g2d.element.ElementClass;
@@ -28,7 +29,6 @@ import org.simantics.g2d.element.handler.impl.SimpleElementLayers;
 import org.simantics.scenegraph.Node;
 import org.simantics.scenegraph.g2d.G2DParentNode;
 import org.simantics.spreadsheet.Adaptable;
-import org.simantics.utils.datastructures.Callback;
 import org.simantics.utils.datastructures.hints.IHintContext.Key;
 import org.simantics.utils.datastructures.hints.IHintContext.KeyOf;
 
@@ -63,9 +63,9 @@ public class SheetClass {
                                Adaptable serverInterface = e.getHint(KEY_SERVER_INTERFACE);
                                node.init(serverInterface);
 
-                               Callback<Node> callback = e.getHint(ElementHints.KEY_SG_CALLBACK);
+                               Consumer<Node> callback = e.getHint(ElementHints.KEY_SG_CALLBACK);
                                if(callback != null)
-                                       callback.run(node);
+                                       callback.accept(node);
 
                                System.out.println("SHEET PARENT NODE: " + parent);
                                node.setBounds(new Rectangle2D.Double(0, 0, 400, 200));
index 9c1fc296a1cfcf9aaead4974f352319a2879c5dc..4669fdf4da1d4078372665d510a0f35effd354da 100644 (file)
@@ -11,6 +11,7 @@
 package org.simantics.spreadsheet.ui;
 
 import java.awt.geom.AffineTransform;
+import java.util.function.Consumer;
 
 import org.simantics.db.AsyncReadGraph;
 import org.simantics.db.ReadGraph;
@@ -34,7 +35,6 @@ import org.simantics.operation.Layer0X;
 import org.simantics.scenegraph.INode;
 import org.simantics.spreadsheet.graph.GraphUI;
 import org.simantics.spreadsheet.resource.SpreadsheetResource;
-import org.simantics.utils.datastructures.Callback;
 
 
 /**
@@ -117,10 +117,10 @@ public class SheetFactory implements ElementFactory {
                             element.setHint(SheetClass.KEY_SHEET, sheet);
                             element.setHint(SheetClass.KEY_RVI, rvi);
 
-                            element.setHint(ElementHints.KEY_SG_CALLBACK, new Callback<INode>() {
+                            element.setHint(ElementHints.KEY_SG_CALLBACK, new Consumer<INode>() {
 
                                 @Override
-                                public void run(INode _node) {
+                                public void accept(INode _node) {
 
                                     final SheetNode node = (SheetNode)_node;
 
index 5b315d6c057b7a6cdf878b4bf72d5fd9c6902ec0..6b8719a227f2812349239b9b61c8268ad9ec32f5 100644 (file)
@@ -125,7 +125,7 @@ public class NameLabelUtil {
                }
        }
 
-       public static String modalName(String name, String label, NameLabelMode mode) throws DatabaseException {
+       public static String modalName(String name, String label, NameLabelMode mode) {
                switch (mode) {
                case NAME:
                        return name;
index fff066acf80af53e9dfa977f1e3fcf2b7ae981b3..3bb11b60c1667e720062463cd06cc22c2669371b 100644 (file)
@@ -20,7 +20,6 @@ import org.simantics.db.common.request.WriteRequest;
 import org.simantics.db.exception.DatabaseException;
 import org.simantics.db.testing.base.ExistingDatabaseTest;
 import org.simantics.layer0.Layer0;
-import org.simantics.utils.datastructures.Callback;
 
 /**
  * Checks that unexpected write callback failures do not crash the session and
@@ -50,14 +49,11 @@ public class WriteCallbackFailureTest extends ExistingDatabaseTest {
 
                 written = test;
             }
-        }, new Callback<DatabaseException>() {
-            @Override
-            public void run(DatabaseException parameter) {
-                try {
-                    throw new NullPointerException("intentional failure");
-                } finally {
-                    sem.release();
-                }
+        }, parameter -> {
+            try {
+                throw new NullPointerException("intentional failure");
+            } finally {
+                sem.release();
             }
         });