From: Tuukka Lehtonen Date: Thu, 7 Dec 2017 07:32:18 +0000 (+0200) Subject: Use Consumer interface instead of deprecated Callback interface X-Git-Tag: v1.31.0~4^2 X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=commitdiff_plain;h=627664d06302d454ea3b3fe14d13bb5ab739d666;p=simantics%2Fplatform.git Use Consumer interface instead of deprecated Callback interface Also removed some compilation warnings at the same time. refs #7655 Change-Id: I8e84652fd50853d598ddec299fc1fc6e30776bc2 --- diff --git a/bundles/org.simantics.annotation.ui/src/org/simantics/annotation/ui/actions/AnnotationDropActionFactory.java b/bundles/org.simantics.annotation.ui/src/org/simantics/annotation/ui/actions/AnnotationDropActionFactory.java index 5d9f939d1..4f4480e2b 100644 --- a/bundles/org.simantics.annotation.ui/src/org/simantics/annotation/ui/actions/AnnotationDropActionFactory.java +++ b/bundles/org.simantics.annotation.ui/src/org/simantics/annotation/ui/actions/AnnotationDropActionFactory.java @@ -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() { - - @Override - public void run(DatabaseException e) { - if (e!= null) - ErrorLogger.defaultLogError(e); - - } + }, e -> { + if (e!= null) + ErrorLogger.defaultLogError(e); }); } diff --git a/bundles/org.simantics.browsing.ui.graph.impl/src/org/simantics/browsing/ui/graph/impl/EnumerationVariableModifier.java b/bundles/org.simantics.browsing.ui.graph.impl/src/org/simantics/browsing/ui/graph/impl/EnumerationVariableModifier.java index b551adae6..412827ffa 100644 --- a/bundles/org.simantics.browsing.ui.graph.impl/src/org/simantics/browsing/ui/graph/impl/EnumerationVariableModifier.java +++ b/bundles/org.simantics.browsing.ui.graph.impl/src/org/simantics/browsing/ui/graph/impl/EnumerationVariableModifier.java @@ -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() { - @Override - public void run(DatabaseException parameter) { - if (parameter != null) - ErrorLogger.defaultLogError(parameter); - } + parameter -> { + if (parameter != null) + ErrorLogger.defaultLogError(parameter); }); } diff --git a/bundles/org.simantics.browsing.ui.graph.impl/src/org/simantics/browsing/ui/graph/impl/EnumerationVariableModifier2.java b/bundles/org.simantics.browsing.ui.graph.impl/src/org/simantics/browsing/ui/graph/impl/EnumerationVariableModifier2.java index 48c4ab4fb..78672a21d 100644 --- a/bundles/org.simantics.browsing.ui.graph.impl/src/org/simantics/browsing/ui/graph/impl/EnumerationVariableModifier2.java +++ b/bundles/org.simantics.browsing.ui.graph.impl/src/org/simantics/browsing/ui/graph/impl/EnumerationVariableModifier2.java @@ -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() { - @Override - public void run(DatabaseException parameter) { - if (parameter != null) - ErrorLogger.defaultLogError(parameter); - } + parameter -> { + if (parameter != null) + ErrorLogger.defaultLogError(parameter); }); } diff --git a/bundles/org.simantics.browsing.ui.graph.impl/src/org/simantics/browsing/ui/graph/impl/EnumerationVariableModifier3.java b/bundles/org.simantics.browsing.ui.graph.impl/src/org/simantics/browsing/ui/graph/impl/EnumerationVariableModifier3.java index 63e5a771f..32bd28c17 100644 --- a/bundles/org.simantics.browsing.ui.graph.impl/src/org/simantics/browsing/ui/graph/impl/EnumerationVariableModifier3.java +++ b/bundles/org.simantics.browsing.ui.graph.impl/src/org/simantics/browsing/ui/graph/impl/EnumerationVariableModifier3.java @@ -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() { - @Override - public void run(DatabaseException parameter) { - if (parameter != null) - ErrorLogger.defaultLogError(parameter); - } + parameter -> { + if (parameter != null) + ErrorLogger.defaultLogError(parameter); }); } diff --git a/bundles/org.simantics.browsing.ui.graph.impl/src/org/simantics/browsing/ui/graph/impl/GraphFactoryStringModifier.java b/bundles/org.simantics.browsing.ui.graph.impl/src/org/simantics/browsing/ui/graph/impl/GraphFactoryStringModifier.java index 6d0e43d17..99e053bda 100644 --- a/bundles/org.simantics.browsing.ui.graph.impl/src/org/simantics/browsing/ui/graph/impl/GraphFactoryStringModifier.java +++ b/bundles/org.simantics.browsing.ui.graph.impl/src/org/simantics/browsing/ui/graph/impl/GraphFactoryStringModifier.java @@ -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() { - @Override - public void run(DatabaseException parameter) { - if (parameter != null) - ErrorLogger.defaultLogError(parameter); - } + }, parameter -> { + if (parameter != null) + ErrorLogger.defaultLogError(parameter); }); } diff --git a/bundles/org.simantics.browsing.ui.graph.impl/src/org/simantics/browsing/ui/graph/impl/GraphStringIndexModifier.java b/bundles/org.simantics.browsing.ui.graph.impl/src/org/simantics/browsing/ui/graph/impl/GraphStringIndexModifier.java index e9adba21e..cbde1d845 100644 --- a/bundles/org.simantics.browsing.ui.graph.impl/src/org/simantics/browsing/ui/graph/impl/GraphStringIndexModifier.java +++ b/bundles/org.simantics.browsing.ui.graph.impl/src/org/simantics/browsing/ui/graph/impl/GraphStringIndexModifier.java @@ -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() { - @Override - public void run(DatabaseException parameter) { - if (parameter != null) - ErrorLogger.defaultLogError(parameter); - } + }, parameter -> { + if (parameter != null) + ErrorLogger.defaultLogError(parameter); }); } diff --git a/bundles/org.simantics.browsing.ui.graph.impl/src/org/simantics/browsing/ui/graph/impl/GraphStringModifier.java b/bundles/org.simantics.browsing.ui.graph.impl/src/org/simantics/browsing/ui/graph/impl/GraphStringModifier.java index a3635e3b8..1e3ddf696 100644 --- a/bundles/org.simantics.browsing.ui.graph.impl/src/org/simantics/browsing/ui/graph/impl/GraphStringModifier.java +++ b/bundles/org.simantics.browsing.ui.graph.impl/src/org/simantics/browsing/ui/graph/impl/GraphStringModifier.java @@ -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() { - @Override - public void run(DatabaseException parameter) { - if (parameter != null) - ErrorLogger.defaultLogError(parameter); - } + }, parameter -> { + if (parameter != null) + ErrorLogger.defaultLogError(parameter); }); } diff --git a/bundles/org.simantics.browsing.ui.graph.impl/src/org/simantics/browsing/ui/graph/impl/LabelModifier.java b/bundles/org.simantics.browsing.ui.graph.impl/src/org/simantics/browsing/ui/graph/impl/LabelModifier.java index f0583a500..8f3c72993 100644 --- a/bundles/org.simantics.browsing.ui.graph.impl/src/org/simantics/browsing/ui/graph/impl/LabelModifier.java +++ b/bundles/org.simantics.browsing.ui.graph.impl/src/org/simantics/browsing/ui/graph/impl/LabelModifier.java @@ -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 { +public class LabelModifier implements Modifier, Consumer { private final Session session; protected final Resource resource; @@ -97,7 +98,7 @@ public class LabelModifier implements Modifier, Callback { } @Override - public void run(DatabaseException parameter) { + public void accept(DatabaseException parameter) { if (parameter != null) { ExceptionUtils.logError("Label modification failed, see exception for details.", parameter); } diff --git a/bundles/org.simantics.browsing.ui.graph.impl/src/org/simantics/browsing/ui/graph/impl/VariableModifier.java b/bundles/org.simantics.browsing.ui.graph.impl/src/org/simantics/browsing/ui/graph/impl/VariableModifier.java index c5d2f81b4..cfceaaf4b 100644 --- a/bundles/org.simantics.browsing.ui.graph.impl/src/org/simantics/browsing/ui/graph/impl/VariableModifier.java +++ b/bundles/org.simantics.browsing.ui.graph.impl/src/org/simantics/browsing/ui/graph/impl/VariableModifier.java @@ -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() { - @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(); }); } } diff --git a/bundles/org.simantics.browsing.ui.model/src/org/simantics/browsing/ui/model/modifiers/VariableModifier2.java b/bundles/org.simantics.browsing.ui.model/src/org/simantics/browsing/ui/model/modifiers/VariableModifier2.java index d8d2bc165..5eee1be58 100644 --- a/bundles/org.simantics.browsing.ui.model/src/org/simantics/browsing/ui/model/modifiers/VariableModifier2.java +++ b/bundles/org.simantics.browsing.ui.model/src/org/simantics/browsing/ui/model/modifiers/VariableModifier2.java @@ -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() { - @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(); }); } diff --git a/bundles/org.simantics.charts/src/org/simantics/charts/ui/ChartGroupDropActionFactory.java b/bundles/org.simantics.charts/src/org/simantics/charts/ui/ChartGroupDropActionFactory.java index 285f2d13e..6149d0611 100644 --- a/bundles/org.simantics.charts/src/org/simantics/charts/ui/ChartGroupDropActionFactory.java +++ b/bundles/org.simantics.charts/src/org/simantics/charts/ui/ChartGroupDropActionFactory.java @@ -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() { - @Override - public void run(DatabaseException e) { - if (e != null) - ErrorLogger.defaultLogError(e); - } + }, e -> { + if (e != null) + ErrorLogger.defaultLogError(e); }); } }; diff --git a/bundles/org.simantics.charts/src/org/simantics/charts/ui/ChartItemDropActionFactory.java b/bundles/org.simantics.charts/src/org/simantics/charts/ui/ChartItemDropActionFactory.java index 454a3baa4..e66c64713 100644 --- a/bundles/org.simantics.charts/src/org/simantics/charts/ui/ChartItemDropActionFactory.java +++ b/bundles/org.simantics.charts/src/org/simantics/charts/ui/ChartItemDropActionFactory.java @@ -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() { - @Override - public void run(DatabaseException e) { - if (e != null) - ErrorLogger.defaultLogError(e); - } + }, e -> { + if (e != null) + ErrorLogger.defaultLogError(e); }); } }; diff --git a/bundles/org.simantics.db.common/src/org/simantics/db/common/provider/AsyncResourceProvider.java b/bundles/org.simantics.db.common/src/org/simantics/db/common/provider/AsyncResourceProvider.java index 2cb5a3575..7db748a3e 100644 --- a/bundles/org.simantics.db.common/src/org/simantics/db/common/provider/AsyncResourceProvider.java +++ b/bundles/org.simantics.db.common/src/org/simantics/db/common/provider/AsyncResourceProvider.java @@ -11,10 +11,11 @@ *******************************************************************************/ 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 callback); + void get(AsyncReadGraph graph, Consumer callback); } diff --git a/bundles/org.simantics.db.common/src/org/simantics/db/common/provider/ResourceProviders.java b/bundles/org.simantics.db.common/src/org/simantics/db/common/provider/ResourceProviders.java index b5957e636..955266aa9 100644 --- a/bundles/org.simantics.db.common/src/org/simantics/db/common/provider/ResourceProviders.java +++ b/bundles/org.simantics.db.common/src/org/simantics/db/common/provider/ResourceProviders.java @@ -11,10 +11,11 @@ *******************************************************************************/ 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 callback) { - callback.run(resource); + public void get(AsyncReadGraph g, Consumer callback) { + callback.accept(resource); } }; } diff --git a/bundles/org.simantics.db.common/src/org/simantics/db/common/request/DelayedWriteRequest.java b/bundles/org.simantics.db.common/src/org/simantics/db/common/request/DelayedWriteRequest.java index 044e91acc..d634cb715 100644 --- a/bundles/org.simantics.db.common/src/org/simantics/db/common/request/DelayedWriteRequest.java +++ b/bundles/org.simantics.db.common/src/org/simantics/db/common/request/DelayedWriteRequest.java @@ -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 procedure) { - processor.asyncRequest(this, new Callback() { - - @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); }); } diff --git a/bundles/org.simantics.db.common/src/org/simantics/db/common/request/WriteOnlyRequest.java b/bundles/org.simantics.db.common/src/org/simantics/db/common/request/WriteOnlyRequest.java index 654bf32bf..e3f8edb1e 100644 --- a/bundles/org.simantics.db.common/src/org/simantics/db/common/request/WriteOnlyRequest.java +++ b/bundles/org.simantics.db.common/src/org/simantics/db/common/request/WriteOnlyRequest.java @@ -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 procedure) { - processor.asyncRequest(this, new Callback() { - - @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); }); } diff --git a/bundles/org.simantics.db.common/src/org/simantics/db/common/request/WriteRequest.java b/bundles/org.simantics.db.common/src/org/simantics/db/common/request/WriteRequest.java index cb9460d13..97386a861 100644 --- a/bundles/org.simantics.db.common/src/org/simantics/db/common/request/WriteRequest.java +++ b/bundles/org.simantics.db.common/src/org/simantics/db/common/request/WriteRequest.java @@ -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 procedure) { - processor.asyncRequest(this, new Callback() { - - @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); }); } diff --git a/bundles/org.simantics.db.common/src/org/simantics/db/common/utils/Transaction.java b/bundles/org.simantics.db.common/src/org/simantics/db/common/utils/Transaction.java index 0a8dcea41..9e5d563a5 100644 --- a/bundles/org.simantics.db.common/src/org/simantics/db/common/utils/Transaction.java +++ b/bundles/org.simantics.db.common/src/org/simantics/db/common/utils/Transaction.java @@ -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.

@@ -216,12 +216,9 @@ public class Transaction { t.ts = new Semaphore(0); transactions.set(t); - Callback callback = new Callback() { - @Override - public void run(DatabaseException parameter) { - t.error = parameter; - t.es.release(9999); - } + Consumer 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 callback = new Callback() { - @Override - public void run(DatabaseException parameter) { - t.error = parameter; - t.es.release(9999); - } + Consumer callback = parameter -> { + t.error = parameter; + t.es.release(9999); }; DelayedWrite request = new DelayedWriteRequest() { diff --git a/bundles/org.simantics.db.impl/src/org/simantics/db/impl/graph/PossibleObjectProcedure.java b/bundles/org.simantics.db.impl/src/org/simantics/db/impl/graph/PossibleObjectProcedure.java index 066e61055..f3e01a76f 100644 --- a/bundles/org.simantics.db.impl/src/org/simantics/db/impl/graph/PossibleObjectProcedure.java +++ b/bundles/org.simantics.db.impl/src/org/simantics/db/impl/graph/PossibleObjectProcedure.java @@ -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; diff --git a/bundles/org.simantics.db.impl/src/org/simantics/db/impl/graph/ReadGraphImpl.java b/bundles/org.simantics.db.impl/src/org/simantics/db/impl/graph/ReadGraphImpl.java index b853ed519..ff127a09b 100644 --- a/bundles/org.simantics.db.impl/src/org/simantics/db/impl/graph/ReadGraphImpl.java +++ b/bundles/org.simantics.db.impl/src/org/simantics/db/impl/graph/ReadGraphImpl.java @@ -1949,7 +1949,7 @@ public class ReadGraphImpl implements ReadGraph { } - final AsyncProcedure NONE = new AsyncProcedure() { + final AsyncProcedure NONE = new AsyncProcedure() { @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); diff --git a/bundles/org.simantics.db.impl/src/org/simantics/db/impl/procedure/CallWrappedSingleQueryProcedure4.java b/bundles/org.simantics.db.impl/src/org/simantics/db/impl/procedure/CallWrappedSingleQueryProcedure4.java index c7affc4af..14a64dac8 100644 --- a/bundles/org.simantics.db.impl/src/org/simantics/db/impl/procedure/CallWrappedSingleQueryProcedure4.java +++ b/bundles/org.simantics.db.impl/src/org/simantics/db/impl/procedure/CallWrappedSingleQueryProcedure4.java @@ -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 implements AsyncProcedure { diff --git a/bundles/org.simantics.db.impl/src/org/simantics/db/impl/procedure/ResultCallWrappedQueryProcedure4.java b/bundles/org.simantics.db.impl/src/org/simantics/db/impl/procedure/ResultCallWrappedQueryProcedure4.java index c24e87668..3b65f2c2e 100644 --- a/bundles/org.simantics.db.impl/src/org/simantics/db/impl/procedure/ResultCallWrappedQueryProcedure4.java +++ b/bundles/org.simantics.db.impl/src/org/simantics/db/impl/procedure/ResultCallWrappedQueryProcedure4.java @@ -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 implements AsyncMultiProcedure { diff --git a/bundles/org.simantics.db.impl/src/org/simantics/db/impl/procedure/ResultCallWrappedSingleQueryProcedure4.java b/bundles/org.simantics.db.impl/src/org/simantics/db/impl/procedure/ResultCallWrappedSingleQueryProcedure4.java index a6717c9d9..1a0522dd3 100644 --- a/bundles/org.simantics.db.impl/src/org/simantics/db/impl/procedure/ResultCallWrappedSingleQueryProcedure4.java +++ b/bundles/org.simantics.db.impl/src/org/simantics/db/impl/procedure/ResultCallWrappedSingleQueryProcedure4.java @@ -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 implements AsyncProcedure { diff --git a/bundles/org.simantics.db.impl/src/org/simantics/db/impl/query/AssertedPredicates.java b/bundles/org.simantics.db.impl/src/org/simantics/db/impl/query/AssertedPredicates.java index 31b0f3e90..af8858e5a 100644 --- a/bundles/org.simantics.db.impl/src/org/simantics/db/impl/query/AssertedPredicates.java +++ b/bundles/org.simantics.db.impl/src/org/simantics/db/impl/query/AssertedPredicates.java @@ -11,12 +11,12 @@ *******************************************************************************/ 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; diff --git a/bundles/org.simantics.db.impl/src/org/simantics/db/impl/query/AssertedStatements.java b/bundles/org.simantics.db.impl/src/org/simantics/db/impl/query/AssertedStatements.java index 6e7ca62e5..41b8e08d5 100644 --- a/bundles/org.simantics.db.impl/src/org/simantics/db/impl/query/AssertedStatements.java +++ b/bundles/org.simantics.db.impl/src/org/simantics/db/impl/query/AssertedStatements.java @@ -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; diff --git a/bundles/org.simantics.db.impl/src/org/simantics/db/impl/query/AsyncMultiReadEntry.java b/bundles/org.simantics.db.impl/src/org/simantics/db/impl/query/AsyncMultiReadEntry.java index 8a8b18b7d..fac6b011f 100644 --- a/bundles/org.simantics.db.impl/src/org/simantics/db/impl/query/AsyncMultiReadEntry.java +++ b/bundles/org.simantics.db.impl/src/org/simantics/db/impl/query/AsyncMultiReadEntry.java @@ -100,7 +100,8 @@ final public class AsyncMultiReadEntry 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 extends CacheEntryBase { } + @SuppressWarnings("unchecked") @Override public void performFromCache(ReadGraphImpl graph, Object provider, Object procedure) { diff --git a/bundles/org.simantics.db.impl/src/org/simantics/db/impl/query/AsyncReadEntry.java b/bundles/org.simantics.db.impl/src/org/simantics/db/impl/query/AsyncReadEntry.java index 010f55446..a9726a75d 100644 --- a/bundles/org.simantics.db.impl/src/org/simantics/db/impl/query/AsyncReadEntry.java +++ b/bundles/org.simantics.db.impl/src/org/simantics/db/impl/query/AsyncReadEntry.java @@ -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 extends CacheEntryBase { } + @SuppressWarnings("unchecked") public void performFromCache(ReadGraphImpl graph, Object provider, Object procedure) { AsyncProcedure proc = (AsyncProcedure)procedure; diff --git a/bundles/org.simantics.db.impl/src/org/simantics/db/impl/query/BinaryQuery.java b/bundles/org.simantics.db.impl/src/org/simantics/db/impl/query/BinaryQuery.java index e7af8d04d..cb2df4eea 100644 --- a/bundles/org.simantics.db.impl/src/org/simantics/db/impl/query/BinaryQuery.java +++ b/bundles/org.simantics.db.impl/src/org/simantics/db/impl/query/BinaryQuery.java @@ -71,6 +71,7 @@ abstract public class BinaryQuery 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); diff --git a/bundles/org.simantics.db.impl/src/org/simantics/db/impl/query/CacheEntryBase.java b/bundles/org.simantics.db.impl/src/org/simantics/db/impl/query/CacheEntryBase.java index 5776857d3..d30d59320 100644 --- a/bundles/org.simantics.db.impl/src/org/simantics/db/impl/query/CacheEntryBase.java +++ b/bundles/org.simantics.db.impl/src/org/simantics/db/impl/query/CacheEntryBase.java @@ -168,6 +168,7 @@ abstract public class CacheEntryBase extends CacheEntry { this.result = result; } + @SuppressWarnings("unchecked") @Override final public T getResult() { assert(statusOrException != DISCARDED); diff --git a/bundles/org.simantics.db.management/src/org/simantics/db/management/SessionContext.java b/bundles/org.simantics.db.management/src/org/simantics/db/management/SessionContext.java index ef5f27053..dae8bea75 100644 --- a/bundles/org.simantics.db.management/src/org/simantics/db/management/SessionContext.java +++ b/bundles/org.simantics.db.management/src/org/simantics/db/management/SessionContext.java @@ -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)); diff --git a/bundles/org.simantics.db.management/src/org/simantics/db/management/SessionContextProvider.java b/bundles/org.simantics.db.management/src/org/simantics/db/management/SessionContextProvider.java index 6f434c13f..7b76b24bb 100644 --- a/bundles/org.simantics.db.management/src/org/simantics/db/management/SessionContextProvider.java +++ b/bundles/org.simantics.db.management/src/org/simantics/db/management/SessionContextProvider.java @@ -18,7 +18,7 @@ import org.eclipse.core.runtime.ListenerList; */ public class SessionContextProvider implements ISessionContextProvider { - private ListenerList listeners = new ListenerList(); + private ListenerList listeners = new ListenerList<>(); private Object handle; diff --git a/bundles/org.simantics.db.server/.classpath b/bundles/org.simantics.db.server/.classpath index 751c8f2e5..b862a296d 100644 --- a/bundles/org.simantics.db.server/.classpath +++ b/bundles/org.simantics.db.server/.classpath @@ -1,7 +1,7 @@ - - - - - - - + + + + + + + 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 index 000000000..295926d96 --- /dev/null +++ b/bundles/org.simantics.db.server/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,7 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/bundles/org.simantics.db.server/META-INF/MANIFEST.MF b/bundles/org.simantics.db.server/META-INF/MANIFEST.MF index b95a655f3..0fcdaca67 100644 --- a/bundles/org.simantics.db.server/META-INF/MANIFEST.MF +++ b/bundles/org.simantics.db.server/META-INF/MANIFEST.MF @@ -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, diff --git a/bundles/org.simantics.debug.ui/src/org/simantics/debug/ui/GraphDebugger.java b/bundles/org.simantics.debug.ui/src/org/simantics/debug/ui/GraphDebugger.java index 158c37a36..b51ed4d00 100644 --- a/bundles/org.simantics.debug.ui/src/org/simantics/debug/ui/GraphDebugger.java +++ b/bundles/org.simantics.debug.ui/src/org/simantics/debug/ui/GraphDebugger.java @@ -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() { - - @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() { - @Override - public void run(DatabaseException parameter) { - if (parameter != null) - ErrorLogger.defaultLogError(parameter); - refreshBrowser(); - } + }, parameter -> { + if (parameter != null) + ErrorLogger.defaultLogError(parameter); + refreshBrowser(); }); return; } diff --git a/bundles/org.simantics.diagram/src/org/simantics/diagram/flag/DiagramFlagPreferences.java b/bundles/org.simantics.diagram/src/org/simantics/diagram/flag/DiagramFlagPreferences.java index b11d89151..c1f6a837a 100644 --- a/bundles/org.simantics.diagram/src/org/simantics/diagram/flag/DiagramFlagPreferences.java +++ b/bundles/org.simantics.diagram/src/org/simantics/diagram/flag/DiagramFlagPreferences.java @@ -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() { - @Override - public void run(DatabaseException parameter) { - if (parameter != null) - ErrorLogger.defaultLogError(parameter); - } + }, parameter -> { + if (parameter != null) + ErrorLogger.defaultLogError(parameter); }); } diff --git a/bundles/org.simantics.diagram/src/org/simantics/diagram/handler/ConnectionRoutingMenuContribution.java b/bundles/org.simantics.diagram/src/org/simantics/diagram/handler/ConnectionRoutingMenuContribution.java index 7f98894ed..78ac6361c 100644 --- a/bundles/org.simantics.diagram/src/org/simantics/diagram/handler/ConnectionRoutingMenuContribution.java +++ b/bundles/org.simantics.diagram/src/org/simantics/diagram/handler/ConnectionRoutingMenuContribution.java @@ -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() { - @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() { - @Override - public void run(DatabaseException parameter) { - if (parameter != null) - ExceptionUtils.logError(parameter); - } + }, parameter -> { + if (parameter != null) + ExceptionUtils.logError(parameter); }); } diff --git a/bundles/org.simantics.diagram/src/org/simantics/diagram/handler/TerminalConnectionDirectionsMenuContribution.java b/bundles/org.simantics.diagram/src/org/simantics/diagram/handler/TerminalConnectionDirectionsMenuContribution.java index 22760ef95..b5aa65951 100644 --- a/bundles/org.simantics.diagram/src/org/simantics/diagram/handler/TerminalConnectionDirectionsMenuContribution.java +++ b/bundles/org.simantics.diagram/src/org/simantics/diagram/handler/TerminalConnectionDirectionsMenuContribution.java @@ -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() { - @Override - public void run(DatabaseException parameter) { - if (parameter != null) - ExceptionUtils.logError(parameter); - } + }, parameter -> { + if (parameter != null) + ExceptionUtils.logError(parameter); }); } diff --git a/bundles/org.simantics.diagram/src/org/simantics/diagram/participant/ConnectionBuilder.java b/bundles/org.simantics.diagram/src/org/simantics/diagram/participant/ConnectionBuilder.java index 72cdb1752..599aba0d0 100644 --- a/bundles/org.simantics.diagram/src/org/simantics/diagram/participant/ConnectionBuilder.java +++ b/bundles/org.simantics.diagram/src/org/simantics/diagram/participant/ConnectionBuilder.java @@ -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() { - @Override - public void run(DatabaseException e) { - if (e != null) - ErrorLogger.defaultLogError(e); - } + }, e -> { + if (e != null) + ErrorLogger.defaultLogError(e); }); } } diff --git a/bundles/org.simantics.diagram/src/org/simantics/diagram/runtime/RuntimeDiagramManager.java b/bundles/org.simantics.diagram/src/org/simantics/diagram/runtime/RuntimeDiagramManager.java index 10c2d8904..bfc439101 100644 --- a/bundles/org.simantics.diagram/src/org/simantics/diagram/runtime/RuntimeDiagramManager.java +++ b/bundles/org.simantics.diagram/src/org/simantics/diagram/runtime/RuntimeDiagramManager.java @@ -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() { - @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); }); } diff --git a/bundles/org.simantics.document.ui/src/org/simantics/document/ui/actions/AddUrlDocument.java b/bundles/org.simantics.document.ui/src/org/simantics/document/ui/actions/AddUrlDocument.java index b5fbe0add..6e312cb37 100644 --- a/bundles/org.simantics.document.ui/src/org/simantics/document/ui/actions/AddUrlDocument.java +++ b/bundles/org.simantics.document.ui/src/org/simantics/document/ui/actions/AddUrlDocument.java @@ -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() { - @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); }); } }; diff --git a/bundles/org.simantics.document.ui/src/org/simantics/document/ui/actions/AddUrlDocumentWithDetail.java b/bundles/org.simantics.document.ui/src/org/simantics/document/ui/actions/AddUrlDocumentWithDetail.java index 5ed7a1a2b..61210a222 100644 --- a/bundles/org.simantics.document.ui/src/org/simantics/document/ui/actions/AddUrlDocumentWithDetail.java +++ b/bundles/org.simantics.document.ui/src/org/simantics/document/ui/actions/AddUrlDocumentWithDetail.java @@ -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() { - @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); }); } }; diff --git a/bundles/org.simantics.document.ui/src/org/simantics/document/ui/actions/ImportDocumentWithDetail.java b/bundles/org.simantics.document.ui/src/org/simantics/document/ui/actions/ImportDocumentWithDetail.java index 42a0a7c94..091f33e7d 100644 --- a/bundles/org.simantics.document.ui/src/org/simantics/document/ui/actions/ImportDocumentWithDetail.java +++ b/bundles/org.simantics.document.ui/src/org/simantics/document/ui/actions/ImportDocumentWithDetail.java @@ -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() { - @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); }); } }; diff --git a/bundles/org.simantics.document.ui/src/org/simantics/document/ui/graphfile/FileDocumentUtil.java b/bundles/org.simantics.document.ui/src/org/simantics/document/ui/graphfile/FileDocumentUtil.java index 4933ca251..9a9e3f8f1 100644 --- a/bundles/org.simantics.document.ui/src/org/simantics/document/ui/graphfile/FileDocumentUtil.java +++ b/bundles/org.simantics.document.ui/src/org/simantics/document/ui/graphfile/FileDocumentUtil.java @@ -61,14 +61,9 @@ public class FileDocumentUtil { importFile(graph, fileName,lib,rel); } - },new org.simantics.utils.datastructures.Callback() { - - @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); }); diff --git a/bundles/org.simantics.document/src/org/simantics/document/FileDocumentUtil.java b/bundles/org.simantics.document/src/org/simantics/document/FileDocumentUtil.java index cab7e9a2c..4fc2eb93d 100644 --- a/bundles/org.simantics.document/src/org/simantics/document/FileDocumentUtil.java +++ b/bundles/org.simantics.document/src/org/simantics/document/FileDocumentUtil.java @@ -60,14 +60,9 @@ public class FileDocumentUtil { importFile(graph, fileName,lib,rel); } - },new org.simantics.utils.datastructures.Callback() { - - @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); }); diff --git a/bundles/org.simantics.event/src/org/simantics/event/view/handler/ClaimAction.java b/bundles/org.simantics.event/src/org/simantics/event/view/handler/ClaimAction.java index e46e35442..81f205f26 100644 --- a/bundles/org.simantics.event/src/org/simantics/event/view/handler/ClaimAction.java +++ b/bundles/org.simantics.event/src/org/simantics/event/view/handler/ClaimAction.java @@ -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() { - @Override - public void run(DatabaseException parameter) { - if (parameter != null) - ErrorLogger.defaultLogError(parameter); - } + }, e -> { + if (e != null) + ErrorLogger.defaultLogError(e); }); } } diff --git a/bundles/org.simantics.event/src/org/simantics/event/view/handler/Delete.java b/bundles/org.simantics.event/src/org/simantics/event/view/handler/Delete.java index 768c2834e..1b147abe1 100644 --- a/bundles/org.simantics.event/src/org/simantics/event/view/handler/Delete.java +++ b/bundles/org.simantics.event/src/org/simantics/event/view/handler/Delete.java @@ -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() { - @Override - public void run(DatabaseException e) { - if (e != null) Logger.defaultLogError(e); - } + }, e -> { + if (e != null) Logger.defaultLogError(e); }); return null; } diff --git a/bundles/org.simantics.event/src/org/simantics/event/view/handler/DenyAction.java b/bundles/org.simantics.event/src/org/simantics/event/view/handler/DenyAction.java index de2a12ce6..abbdba800 100644 --- a/bundles/org.simantics.event/src/org/simantics/event/view/handler/DenyAction.java +++ b/bundles/org.simantics.event/src/org/simantics/event/view/handler/DenyAction.java @@ -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() { - @Override - public void run(DatabaseException parameter) { - if (parameter != null) - ErrorLogger.defaultLogError(parameter); - } + }, e -> { + if (e != null) + ErrorLogger.defaultLogError(e); }); } } diff --git a/bundles/org.simantics.g2d/src/org/simantics/g2d/element/ElementHints.java b/bundles/org.simantics.g2d/src/org/simantics/g2d/element/ElementHints.java index dc8f91474..35f3a8591 100644 --- a/bundles/org.simantics.g2d/src/org/simantics/g2d/element/ElementHints.java +++ b/bundles/org.simantics.g2d/src/org/simantics/g2d/element/ElementHints.java @@ -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. diff --git a/bundles/org.simantics.issues.ui/src/org/simantics/issues/ui/contribution/IssueContextDropAction.java b/bundles/org.simantics.issues.ui/src/org/simantics/issues/ui/contribution/IssueContextDropAction.java index 6187159a4..80be3d185 100644 --- a/bundles/org.simantics.issues.ui/src/org/simantics/issues/ui/contribution/IssueContextDropAction.java +++ b/bundles/org.simantics.issues.ui/src/org/simantics/issues/ui/contribution/IssueContextDropAction.java @@ -50,12 +50,9 @@ public class IssueContextDropAction implements DropActionFactory { graph.claim(issue, ISSUE.Issue_HasContext, ISSUE.Issue_HasContext, ctx); } } - }, new Callback() { - @Override - public void run(DatabaseException e) { - if (e != null) - ErrorLogger.defaultLogError(e); - } + }, e -> { + if (e != null) + ErrorLogger.defaultLogError(e); }); } diff --git a/bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/diagram/monitor/MonitorClassFactory2.java b/bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/diagram/monitor/MonitorClassFactory2.java index 5c3d7fbe3..17c26f483 100644 --- a/bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/diagram/monitor/MonitorClassFactory2.java +++ b/bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/diagram/monitor/MonitorClassFactory2.java @@ -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() { - @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 diff --git a/bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/diagramEditor/DiagramEditorStates.java b/bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/diagramEditor/DiagramEditorStates.java index baf9cc3a2..1af22dc87 100644 --- a/bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/diagramEditor/DiagramEditorStates.java +++ b/bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/diagramEditor/DiagramEditorStates.java @@ -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() { - @Override - public void run(DatabaseException parameter) { - if (parameter != null) - support.exception(parameter); - } + }, e -> { + if (e != null) + support.exception(e); }); } diff --git a/bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/diagramEditor/e4/DiagramViewer.java b/bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/diagramEditor/e4/DiagramViewer.java index 61afc48f4..0b3afd8a5 100644 --- a/bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/diagramEditor/e4/DiagramViewer.java +++ b/bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/diagramEditor/e4/DiagramViewer.java @@ -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() { - @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); }); } diff --git a/bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/modelBrowser/model/Experiment.java b/bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/modelBrowser/model/Experiment.java index 78be9060a..702b6b4ea 100644 --- a/bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/modelBrowser/model/Experiment.java +++ b/bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/modelBrowser/model/Experiment.java @@ -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); } } }; diff --git a/bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/modelBrowser2/model/SubscriptionNode.java b/bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/modelBrowser2/model/SubscriptionNode.java index 161607de6..1729db540 100644 --- a/bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/modelBrowser2/model/SubscriptionNode.java +++ b/bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/modelBrowser2/model/SubscriptionNode.java @@ -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 references) { - SimanticsUI.getSession().asyncRequest(new AddSubscriptionItems(resource, references), new Callback() { - @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); }); } diff --git a/bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/property/RestoreDefaultValueHandler.java b/bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/property/RestoreDefaultValueHandler.java index a439527ca..d19e6dbfb 100644 --- a/bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/property/RestoreDefaultValueHandler.java +++ b/bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/property/RestoreDefaultValueHandler.java @@ -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() { - @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() { - @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; diff --git a/bundles/org.simantics.modeling/src/org/simantics/modeling/actions/DisconnectFlag.java b/bundles/org.simantics.modeling/src/org/simantics/modeling/actions/DisconnectFlag.java index 4618d6aaa..8ba0e340a 100644 --- a/bundles/org.simantics.modeling/src/org/simantics/modeling/actions/DisconnectFlag.java +++ b/bundles/org.simantics.modeling/src/org/simantics/modeling/actions/DisconnectFlag.java @@ -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() { - @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); }); } diff --git a/bundles/org.simantics.modeling/src/org/simantics/modeling/typicals/TypicalDiagramTemplateListener.java b/bundles/org.simantics.modeling/src/org/simantics/modeling/typicals/TypicalDiagramTemplateListener.java index 18ae27137..71ddc664d 100644 --- a/bundles/org.simantics.modeling/src/org/simantics/modeling/typicals/TypicalDiagramTemplateListener.java +++ b/bundles/org.simantics.modeling/src/org/simantics/modeling/typicals/TypicalDiagramTemplateListener.java @@ -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 changes = this.changedElementsByDiagram; this.changedElementsByDiagram = new MapSet.Hash(); - graph.asyncRequest(new SyncTypicalTemplatesToInstances(null, templates, changes), new Callback() { - @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); }); } diff --git a/bundles/org.simantics.simulation/src/org/simantics/simulation/project/ExperimentRuns.java b/bundles/org.simantics.simulation/src/org/simantics/simulation/project/ExperimentRuns.java index 23d6e386a..c708153f2 100644 --- a/bundles/org.simantics.simulation/src/org/simantics/simulation/project/ExperimentRuns.java +++ b/bundles/org.simantics.simulation/src/org/simantics/simulation/project/ExperimentRuns.java @@ -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() { - @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() { - @Override - public void run(DatabaseException e) { - if (e != null) - ErrorLogger.defaultLogError(e); - } + }, e -> { + if (e != null) + ErrorLogger.defaultLogError(e); }); } } diff --git a/bundles/org.simantics.spreadsheet.ui/src/org/simantics/spreadsheet/ui/SheetClass.java b/bundles/org.simantics.spreadsheet.ui/src/org/simantics/spreadsheet/ui/SheetClass.java index 1df4a90e5..3c7c0cbab 100644 --- a/bundles/org.simantics.spreadsheet.ui/src/org/simantics/spreadsheet/ui/SheetClass.java +++ b/bundles/org.simantics.spreadsheet.ui/src/org/simantics/spreadsheet/ui/SheetClass.java @@ -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 callback = e.getHint(ElementHints.KEY_SG_CALLBACK); + Consumer 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)); diff --git a/bundles/org.simantics.spreadsheet.ui/src/org/simantics/spreadsheet/ui/SheetFactory.java b/bundles/org.simantics.spreadsheet.ui/src/org/simantics/spreadsheet/ui/SheetFactory.java index 9c1fc296a..4669fdf4d 100644 --- a/bundles/org.simantics.spreadsheet.ui/src/org/simantics/spreadsheet/ui/SheetFactory.java +++ b/bundles/org.simantics.spreadsheet.ui/src/org/simantics/spreadsheet/ui/SheetFactory.java @@ -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() { + element.setHint(ElementHints.KEY_SG_CALLBACK, new Consumer() { @Override - public void run(INode _node) { + public void accept(INode _node) { final SheetNode node = (SheetNode)_node; diff --git a/bundles/org.simantics/src/org/simantics/NameLabelUtil.java b/bundles/org.simantics/src/org/simantics/NameLabelUtil.java index 5b315d6c0..6b8719a22 100644 --- a/bundles/org.simantics/src/org/simantics/NameLabelUtil.java +++ b/bundles/org.simantics/src/org/simantics/NameLabelUtil.java @@ -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; diff --git a/tests/org.simantics.db.tests/src/org/simantics/db/tests/api/write/request/WriteCallbackFailureTest.java b/tests/org.simantics.db.tests/src/org/simantics/db/tests/api/write/request/WriteCallbackFailureTest.java index fff066acf..3bb11b60c 100644 --- a/tests/org.simantics.db.tests/src/org/simantics/db/tests/api/write/request/WriteCallbackFailureTest.java +++ b/tests/org.simantics.db.tests/src/org/simantics/db/tests/api/write/request/WriteCallbackFailureTest.java @@ -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() { - @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(); } });