Also removed some compilation warnings at the same time.
refs #7655
Change-Id: I8e84652fd50853d598ddec299fc1fc6e30776bc2
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;
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);
});
}
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;
/**
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);
});
}
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;
/**
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);
});
}
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;
/**
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);
});
}
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;
/**
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);
});
}
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;
/**
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);
});
}
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;
/**
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);
});
}
*******************************************************************************/
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;
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;
*
* @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;
}
@Override
- public void run(DatabaseException parameter) {
+ public void accept(DatabaseException parameter) {
if (parameter != null) {
ExceptionUtils.logError("Label modification failed, see exception for details.", parameter);
}
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;
} 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();
});
}
}
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
}
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();
});
}
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;
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);
});
}
};
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;
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);
});
}
};
*******************************************************************************/
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
* @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);
}
*******************************************************************************/
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
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);
}
};
}
import org.simantics.db.request.DelayedWrite;
import org.simantics.db.request.UndoTraits;
import org.simantics.db.request.WriteInterface;
-import org.simantics.utils.datastructures.Callback;
/**
@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);
});
}
import org.simantics.db.procedure.Procedure;
import org.simantics.db.request.WriteInterface;
import org.simantics.db.request.WriteOnly;
-import org.simantics.utils.datastructures.Callback;
/**
@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);
});
}
import org.simantics.db.request.UndoTraits;
import org.simantics.db.request.Write;
import org.simantics.db.request.WriteInterface;
-import org.simantics.utils.datastructures.Callback;
/**
@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);
});
}
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;
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>
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() {
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() {
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;
}
- final AsyncProcedure NONE = new AsyncProcedure() {
+ final AsyncProcedure<?> NONE = new AsyncProcedure<Object>() {
@Override
public void execute(AsyncReadGraph graph, Object result) {
if (parent != null || listener != null || ((request.getFlags() & RequestFlags.SCHEDULE) > 0)) {
- Object syncParent = request;
+// Object syncParent = request;
// final ReadGraphImpl newGraph = newSync();
// 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();
if (parent != null || listener != null) {
- Object syncParent = request;
+// Object syncParent = request;
// final ReadGraphImpl newGraph = newSync();
} else {
- Object syncParent = request;
+// Object syncParent = request;
// final ReadGraphImpl newGraph = newSync();
if (parent != null || listener != null) {
- Object syncParent = request;
+// Object syncParent = request;
// final ReadGraphImpl newGraph = newSync();
if (parent != null || listener != null) {
- Object syncParent = request;
+// Object syncParent = request;
// final ReadGraphImpl newGraph = newSync();
} else {
- Object syncParent = request;
+// Object syncParent = request;
// final ReadGraphImpl newGraph = newSync();
}
}
- @SuppressWarnings("unchecked")
@Override
public Variant getVariantValue2(Resource r, Object context) throws DatabaseException {
Layer0 L0 = processor.getL0(this);
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> {
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> {
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> {
*******************************************************************************/
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;
*******************************************************************************/
package org.simantics.db.impl.query;
-import java.util.ArrayList;
import java.util.concurrent.Semaphore;
import java.util.concurrent.atomic.AtomicInteger;
}
- final synchronized public void addOrSet(Object item) {
+ @SuppressWarnings("unchecked")
+ final synchronized public void addOrSet(Object item) {
assert(isPending());
}
+ @SuppressWarnings("unchecked")
@Override
public void performFromCache(ReadGraphImpl graph, Object provider, Object procedure) {
*******************************************************************************/
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;
}
+ @SuppressWarnings("unchecked")
public void performFromCache(ReadGraphImpl graph, Object provider, Object procedure) {
AsyncProcedure<T> proc = (AsyncProcedure<T>)procedure;
recompute(graph, (QueryProcessor)provider);
}
+ @SuppressWarnings("unchecked")
@Override
public void performFromCache(ReadGraphImpl graph, Object provider, Object procedure) {
performFromCache(graph, (QueryProcessor)provider, (Procedure)procedure);
this.result = result;
}
+ @SuppressWarnings("unchecked")
@Override
final public <T> T getResult() {
assert(statusOrException != DISCARDED);
*******************************************************************************/
package org.simantics.db.management;
-import java.io.IOException;
import java.lang.reflect.Method;
import java.util.Arrays;
import java.util.UUID;
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;
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.
private Session session;
- private UserAuthenticationAgent authenticator;
-
private boolean servicesRegistered = false;
private IStatus servicesRegisteredStatus = null;
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));
*/
public class SessionContextProvider implements ISessionContextProvider {
- private ListenerList listeners = new ListenerList();
+ private ListenerList<ISessionContextChangedListener> listeners = new ListenerList<>();
private Object handle;
-<?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
--- /dev/null
+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
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,
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;
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);
//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;
}
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;
/**
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);
});
}
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;
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);
});
}
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);
});
}
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;
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);
});
}
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;
}
}
}
- }, new Callback<DatabaseException>() {
- @Override
- public void run(DatabaseException e) {
- if (e != null)
- ErrorLogger.defaultLogError(e);
- }
+ }, e -> {
+ if (e != null)
+ ErrorLogger.defaultLogError(e);
});
}
}
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;
/**
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);
});
}
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;
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);
});
}
};
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;
/**
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);
});
}
};
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;
/**
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);
});
}
};
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);
});
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);
});
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;
/**
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);
});
}
}
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;
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;
}
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;
/**
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);
});
}
}
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;
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;
* 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.
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);
});
}
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;
}) {
@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
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
}
});
}
- }, new Callback<DatabaseException>() {
- @Override
- public void run(DatabaseException parameter) {
- if (parameter != null)
- support.exception(parameter);
- }
+ }, e -> {
+ if (e != null)
+ support.exception(e);
});
}
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;
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);
});
}
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);
}
}
};
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;
}
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);
});
}
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;
}
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);
});
}
}
}
}
- }, 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;
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;
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);
});
}
*******************************************************************************/
package org.simantics.modeling.typicals;
-import gnu.trove.set.hash.THashSet;
-
import java.util.Map;
import org.simantics.db.MetadataI;
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.
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);
});
}
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;
/**
_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);
}
});
}
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);
});
}
}
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;
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;
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));
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;
import org.simantics.scenegraph.INode;
import org.simantics.spreadsheet.graph.GraphUI;
import org.simantics.spreadsheet.resource.SpreadsheetResource;
-import org.simantics.utils.datastructures.Callback;
/**
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;
}
}
- 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;
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
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();
}
});