]> gerrit.simantics Code Review - simantics/platform.git/commitdiff
Replaced use of deprecated BinaryFunction et al with BiFunction et al 89/389/1
authorTuukka Lehtonen <tuukka.lehtonen@semantum.fi>
Fri, 31 Mar 2017 13:14:02 +0000 (16:14 +0300)
committerTuukka Lehtonen <tuukka.lehtonen@semantum.fi>
Sat, 1 Apr 2017 06:30:48 +0000 (09:30 +0300)
Also added missing logic to GraphExplorerComposite.SelectionElement to
discover Resource from Variable when WorkbenchSelectionElement is asked
for AnyResource. This is part of the fix for #7116.

Fixed breakage from ContextualHelp F1 keystroke handler which was
introduced in the original SVN commit r32734 (#6446).

refs #7116
refs #7117

Change-Id: Ia7c88d2c1b274fd788a0a18d95c2f059cea36086
(cherry picked from commit e84008c029ef2336cf55ad371256c9a12a889e98)

19 files changed:
bundles/org.simantics.browsing.ui.nattable/src/org/simantics/browsing/ui/nattable/NatTableGraphExplorer.java
bundles/org.simantics.browsing.ui.swt/META-INF/MANIFEST.MF
bundles/org.simantics.browsing.ui.swt/src/org/simantics/browsing/ui/swt/GraphExplorerFactory.java
bundles/org.simantics.browsing.ui.swt/src/org/simantics/browsing/ui/swt/GraphExplorerImpl.java
bundles/org.simantics.browsing.ui.swt/src/org/simantics/browsing/ui/swt/GraphExplorerImpl2.java
bundles/org.simantics.browsing.ui.swt/src/org/simantics/browsing/ui/swt/widgets/GraphExplorerComposite.java
bundles/org.simantics.browsing.ui/src/org/simantics/browsing/ui/GraphExplorer.java
bundles/org.simantics.db.layer0/src/org/simantics/db/layer0/request/PossibleVariableRepresents.java [new file with mode: 0644]
bundles/org.simantics.diagram/src/org/simantics/diagram/handler/Paster.java
bundles/org.simantics.diagram/src/org/simantics/diagram/synchronization/graph/CopyAdvisorUtil.java
bundles/org.simantics.graph.db/src/org/simantics/graph/db/TransferableGraphs.java
bundles/org.simantics.graph.db/src/org/simantics/graph/db/old/OldTransferableGraphs.java
bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/modelBrowser/handlers/ContextualHelp.java
bundles/org.simantics.modeling/src/org/simantics/modeling/mapping/ElementCopyAdvisor.java
bundles/org.simantics.ui/src/org/simantics/ui/selection/WorkbenchSelectionUtils.java
bundles/org.simantics.utils.datastructures/src/org/simantics/utils/datastructures/BinaryCallback.java
bundles/org.simantics.utils.datastructures/src/org/simantics/utils/datastructures/Callable.java
bundles/org.simantics.utils.datastructures/src/org/simantics/utils/datastructures/TimingUtil.java
bundles/org.simantics.utils.datastructures/src/org/simantics/utils/datastructures/UnaryFunction.java

index cc978e7e8b6ce599957ff6fbb859c76ec96a0d96..3bb05553dc7456e073d52b44e526688c2beffdc0 100644 (file)
@@ -19,6 +19,7 @@ import java.util.concurrent.Semaphore;
 import java.util.concurrent.TimeUnit;
 import java.util.concurrent.atomic.AtomicBoolean;
 import java.util.concurrent.atomic.AtomicReference;
+import java.util.function.BiFunction;
 import java.util.function.Consumer;
 
 import org.eclipse.core.runtime.Assert;
@@ -89,7 +90,6 @@ import org.eclipse.nebula.widgets.nattable.painter.NatTableBorderOverlayPainter;
 import org.eclipse.nebula.widgets.nattable.reorder.ColumnReorderLayer;
 import org.eclipse.nebula.widgets.nattable.selection.SelectionLayer;
 import org.eclipse.nebula.widgets.nattable.selection.SelectionLayer.MoveDirectionEnum;
-import org.eclipse.nebula.widgets.nattable.selection.command.SelectCellCommand;
 import org.eclipse.nebula.widgets.nattable.sort.config.SingleClickSortConfiguration;
 import org.eclipse.nebula.widgets.nattable.style.CellStyleAttributes;
 import org.eclipse.nebula.widgets.nattable.style.DisplayMode;
@@ -190,7 +190,6 @@ import org.simantics.browsing.ui.swt.ViewerCellReference;
 import org.simantics.browsing.ui.swt.ViewerRowReference;
 import org.simantics.browsing.ui.swt.internal.Threads;
 import org.simantics.db.layer0.SelectionHints;
-import org.simantics.utils.datastructures.BinaryFunction;
 import org.simantics.utils.datastructures.MapList;
 import org.simantics.utils.datastructures.disposable.AbstractDisposable;
 import org.simantics.utils.datastructures.hints.IHintContext;
@@ -297,10 +296,10 @@ public class NatTableGraphExplorer extends GraphExplorerImplBase implements Grap
     private boolean expand;
     private boolean verticalBarVisible = false;
     
-    private BinaryFunction<Object[], GraphExplorer, Object[]>  selectionTransformation = new BinaryFunction<Object[], GraphExplorer, Object[]>() {
+    private BiFunction<GraphExplorer, Object[], Object[]>  selectionTransformation = new BiFunction<GraphExplorer, Object[], Object[]>() {
 
         @Override
-        public Object[] call(GraphExplorer explorer, Object[] objects) {
+        public Object[] apply(GraphExplorer explorer, Object[] objects) {
             Object[] result = new Object[objects.length];
             for (int i = 0; i < objects.length; i++) {
                 IHintContext context = new AdaptableHintContext(SelectionHints.KEY_MAIN);
@@ -846,7 +845,7 @@ public class NatTableGraphExplorer extends GraphExplorerImplBase implements Grap
     }
     
     protected Object[] transformSelection(Object[] objects) {
-        return selectionTransformation.call(this, objects);
+        return selectionTransformation.apply(this, objects);
     }
     
     protected static Object[] filter(SelectionFilter filter, NodeContext[] contexts) {
@@ -859,7 +858,7 @@ public class NatTableGraphExplorer extends GraphExplorerImplBase implements Grap
 
        @Override
        public void setSelectionTransformation(
-                       BinaryFunction<Object[], GraphExplorer, Object[]> f) {
+                       BiFunction<GraphExplorer, Object[], Object[]> f) {
                this.selectionTransformation = f;
        }
        
index 9869cab3d663ac1d4049c13fb2ac6bb6ba337600..37466aedaec815dd3ae618a0c57592d90bfedc92 100644 (file)
@@ -16,7 +16,8 @@ Require-Bundle: org.simantics.utils.thread.swt;bundle-version="1.0.0",
  com.lowagie.text;bundle-version="2.1.5",
  org.simantics.scl.ui.editor;bundle-version="0.1.3";visibility:=reexport,
  org.simantics.scl.compiler.dummy;bundle-version="0.1.3",
- org.eclipse.e4.core.contexts;bundle-version="1.4.0"
+ org.eclipse.e4.core.contexts;bundle-version="1.4.0",
+ org.slf4j.api;bundle-version="1.7.20"
 Bundle-RequiredExecutionEnvironment: JavaSE-1.8
 Export-Package: org.simantics.browsing.ui.swt,
  org.simantics.browsing.ui.swt.contentassist,
index de421565951a2a3b025856676954f469c897e534..b99962bf00d579c6ceb3cf8e0d4eea39a85abe73 100644 (file)
@@ -12,6 +12,7 @@
 package org.simantics.browsing.ui.swt;
 
 import java.lang.reflect.Method;
+import java.util.function.BiFunction;
 
 import org.eclipse.core.runtime.Platform;
 import org.eclipse.swt.SWT;
@@ -34,7 +35,6 @@ import org.simantics.db.layer0.SelectionHints;
 import org.simantics.db.layer0.variable.Variable;
 import org.simantics.db.layer0.variable.Variables;
 import org.simantics.simulation.ontology.SimulationResource;
-import org.simantics.utils.datastructures.BinaryFunction;
 import org.simantics.utils.datastructures.hints.IHintContext;
 import org.simantics.utils.ui.ExceptionUtils;
 
@@ -50,7 +50,7 @@ public class GraphExplorerFactory {
 
     private IServiceLocator        serviceLocator;
 
-    private BinaryFunction<Object[], GraphExplorer, Object[]>  selectionTransformation = new BinaryFunction<Object[], GraphExplorer, Object[]>() {
+    private BiFunction<GraphExplorer, Object[], Object[]> selectionTransformation = new BiFunction<GraphExplorer, Object[], Object[]>() {
 
        private Resource getModel(final Object object) {
                if(object instanceof NodeContext) {
@@ -90,9 +90,8 @@ public class GraphExplorerFactory {
                return null;
        }
        
-       
         @Override
-        public Object[] call(GraphExplorer explorer, Object[] objects) {
+        public Object[] apply(GraphExplorer explorer, Object[] objects) {
             Object[] result = new Object[objects.length];
             for (int i = 0; i < objects.length; i++) {
                 IHintContext context = new AdaptableHintContext(SelectionHints.KEY_MAIN);
@@ -120,7 +119,7 @@ public class GraphExplorerFactory {
         return this;
     }
 
-    public GraphExplorerFactory selectionTransformation(BinaryFunction<Object[], GraphExplorer, Object[]> transformation) {
+    public GraphExplorerFactory selectionTransformation(BiFunction<GraphExplorer, Object[], Object[]> transformation) {
         this.selectionTransformation = transformation;
         return this;
     }
@@ -194,7 +193,8 @@ public class GraphExplorerFactory {
         //GraphExplorerImpl2 explorer = new GraphExplorerImpl2(parent, style);
        try {
                Bundle bundle = Platform.getBundle("org.simantics.browsing.ui.nattable");
-               Class<GraphExplorer> clazz = (Class<GraphExplorer>)bundle.loadClass("org.simantics.browsing.ui.nattable.NatTableGraphExplorer");
+               @SuppressWarnings("unchecked")
+                       Class<GraphExplorer> clazz = (Class<GraphExplorer>)bundle.loadClass("org.simantics.browsing.ui.nattable.NatTableGraphExplorer");
                //Class<GraphExplorer> clazz = (Class<GraphExplorer>)bundle.getClass().getClassLoader().loadClass("org.simantics.browsing.ui.nattable.NatTableGraphExplorer");
                GraphExplorer explorer = clazz.getConstructor(Composite.class, int.class).newInstance(parent,style);
                explorer.setSelectionDataResolver(selectionDataResolver);
index 62b284858cd9893383719e5ec7b89632437335f9..0e45f86ca4843fe53233ecec6217a07026ee4954 100644 (file)
@@ -31,6 +31,7 @@ import java.util.concurrent.ScheduledExecutorService;
 import java.util.concurrent.TimeUnit;
 import java.util.concurrent.atomic.AtomicBoolean;
 import java.util.concurrent.atomic.AtomicReference;
+import java.util.function.BiFunction;
 import java.util.function.Consumer;
 
 import org.eclipse.core.runtime.Assert;
@@ -161,7 +162,6 @@ import org.simantics.browsing.ui.swt.internal.Threads;
 import org.simantics.db.layer0.SelectionHints;
 import org.simantics.utils.ObjectUtils;
 import org.simantics.utils.datastructures.BijectionMap;
-import org.simantics.utils.datastructures.BinaryFunction;
 import org.simantics.utils.datastructures.disposable.AbstractDisposable;
 import org.simantics.utils.datastructures.hints.IHintContext;
 import org.simantics.utils.threads.IThreadWorkQueue;
@@ -544,10 +544,10 @@ class GraphExplorerImpl extends GraphExplorerImplBase implements Listener, Graph
     protected BasePostSelectionProvider          selectionProvider        = new BasePostSelectionProvider();
     protected SelectionDataResolver              selectionDataResolver;
     protected SelectionFilter                    selectionFilter;
-    protected BinaryFunction<Object[], GraphExplorer, Object[]>  selectionTransformation = new BinaryFunction<Object[], GraphExplorer, Object[]>() {
+    protected BiFunction<GraphExplorer, Object[], Object[]> selectionTransformation = new BiFunction<GraphExplorer, Object[], Object[]>() {
 
         @Override
-        public Object[] call(GraphExplorer explorer, Object[] objects) {
+        public Object[] apply(GraphExplorer explorer, Object[] objects) {
             Object[] result = new Object[objects.length];
             for (int i = 0; i < objects.length; i++) {
                 IHintContext context = new AdaptableHintContext(SelectionHints.KEY_MAIN);
@@ -1812,7 +1812,7 @@ class GraphExplorerImpl extends GraphExplorerImplBase implements Listener, Graph
     }
 
     @Override
-    public void setSelectionTransformation(BinaryFunction<Object[], GraphExplorer, Object[]> f) {
+    public void setSelectionTransformation(BiFunction<GraphExplorer, Object[], Object[]> f) {
         this.selectionTransformation = f;
     }
 
@@ -3168,7 +3168,7 @@ class GraphExplorerImpl extends GraphExplorerImplBase implements Listener, Graph
     }
 
     protected Object[] transformSelection(Object[] objects) {
-        return selectionTransformation.call(this, objects);
+        return selectionTransformation.apply(this, objects);
     }
 
     protected static Object[] filter(SelectionFilter filter, NodeContext[] contexts) {
index 79bd35b872b2991a05537aedede0b62aa50a6561..928bed03facc844eea8ef2603307e0a2c988f965 100644 (file)
@@ -30,6 +30,7 @@ import java.util.concurrent.Semaphore;
 import java.util.concurrent.TimeUnit;
 import java.util.concurrent.atomic.AtomicBoolean;
 import java.util.concurrent.atomic.AtomicReference;
+import java.util.function.BiFunction;
 import java.util.function.Consumer;
 
 import org.eclipse.core.runtime.Assert;
@@ -164,7 +165,6 @@ import org.simantics.browsing.ui.swt.internal.Threads;
 import org.simantics.db.layer0.SelectionHints;
 import org.simantics.ui.SimanticsUI;
 import org.simantics.utils.datastructures.BijectionMap;
-import org.simantics.utils.datastructures.BinaryFunction;
 import org.simantics.utils.datastructures.MapList;
 import org.simantics.utils.datastructures.disposable.AbstractDisposable;
 import org.simantics.utils.datastructures.hints.IHintContext;
@@ -251,10 +251,10 @@ public class GraphExplorerImpl2 extends GraphExplorerImplBase implements GraphEx
     private boolean expand;
     private boolean verticalBarVisible = false;
     
-    private BinaryFunction<Object[], GraphExplorer, Object[]>  selectionTransformation = new BinaryFunction<Object[], GraphExplorer, Object[]>() {
+    private BiFunction<GraphExplorer, Object[], Object[]> selectionTransformation = new BiFunction<GraphExplorer, Object[], Object[]>() {
 
         @Override
-        public Object[] call(GraphExplorer explorer, Object[] objects) {
+        public Object[] apply(GraphExplorer explorer, Object[] objects) {
             Object[] result = new Object[objects.length];
             for (int i = 0; i < objects.length; i++) {
                 IHintContext context = new AdaptableHintContext(SelectionHints.KEY_MAIN);
@@ -885,7 +885,7 @@ public class GraphExplorerImpl2 extends GraphExplorerImplBase implements GraphEx
     }
     
     protected Object[] transformSelection(Object[] objects) {
-        return selectionTransformation.call(this, objects);
+        return selectionTransformation.apply(this, objects);
     }
     
     protected static Object[] filter(SelectionFilter filter, NodeContext[] contexts) {
@@ -898,7 +898,7 @@ public class GraphExplorerImpl2 extends GraphExplorerImplBase implements GraphEx
 
        @Override
        public void setSelectionTransformation(
-                       BinaryFunction<Object[], GraphExplorer, Object[]> f) {
+                       BiFunction<GraphExplorer, Object[], Object[]> f) {
                this.selectionTransformation = f;
        }
        
index 4b5a48e14acdb79f0cee6f1e42a798b2b142312b..f583d7e7f1df374f0466232cf40d786a4b14cf2b 100644 (file)
@@ -16,6 +16,7 @@ import java.util.Collections;
 import java.util.HashSet;
 import java.util.Map;
 import java.util.Set;
+import java.util.function.BiFunction;
 import java.util.function.Consumer;
 
 import org.eclipse.core.runtime.IAdaptable;
@@ -102,12 +103,11 @@ import org.simantics.db.AsyncReadGraph;
 import org.simantics.db.ReadGraph;
 import org.simantics.db.Resource;
 import org.simantics.db.Session;
-import org.simantics.db.common.request.ResourceRead;
-import org.simantics.db.common.utils.Logger;
 import org.simantics.db.exception.DatabaseException;
 import org.simantics.db.layer0.SelectionHints;
+import org.simantics.db.layer0.request.PossibleVariable;
+import org.simantics.db.layer0.request.PossibleVariableRepresents;
 import org.simantics.db.layer0.variable.Variable;
-import org.simantics.db.layer0.variable.Variables;
 import org.simantics.db.management.ISessionContext;
 import org.simantics.db.management.ISessionContextChangedListener;
 import org.simantics.db.management.ISessionContextProvider;
@@ -126,7 +126,6 @@ import org.simantics.ui.selection.WorkbenchSelectionContentType;
 import org.simantics.ui.selection.WorkbenchSelectionElement;
 import org.simantics.ui.selection.WorkbenchSelectionUtils;
 import org.simantics.utils.ObjectUtils;
-import org.simantics.utils.datastructures.BinaryFunction;
 import org.simantics.utils.datastructures.Function;
 import org.simantics.utils.datastructures.disposable.DisposeState;
 import org.simantics.utils.datastructures.hints.HintListenerAdapter;
@@ -135,10 +134,14 @@ import org.simantics.utils.datastructures.hints.IHintContext.Key;
 import org.simantics.utils.datastructures.hints.IHintListener;
 import org.simantics.utils.datastructures.hints.IHintObservable;
 import org.simantics.utils.datastructures.hints.IHintTracker;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 
 public class GraphExplorerComposite extends Composite implements Widget, IAdaptable {
 
+    private static final Logger LOGGER = LoggerFactory.getLogger(GraphExplorerComposite.class);
+
     protected UserSelectedComparableFactoryQueryProcessor userSelectedComparableFactoryQueryProcessor;
     protected UserSelectedViewpointFactoryQueryProcessor  userSelectedViewpointFactoryQueryProcessor;
     protected FilterSelectionRequestQueryProcessor        filterSelectionRequestQueryProcessor;
@@ -248,39 +251,41 @@ public class GraphExplorerComposite extends Composite implements Widget, IAdapta
         @SuppressWarnings("unchecked")
         @Override
         public <T> T getContent(WorkbenchSelectionContentType<T> contentType) {
-
-            if(wse != null) {
+            if (wse != null) {
                 T result = wse.getContent(contentType);
-                if(result != null) return result;
+                if (result != null)
+                    return result;
             }
-            
-            if(contentType instanceof AnyResource) return (T)resource;
-            else if(contentType instanceof AnyVariable) {
-                AnyVariable type = (AnyVariable)contentType;
+
+            if (contentType instanceof AnyResource) {
+                if (resource != null)
+                    return (T) resource;
+                if (variable == null)
+                    return null;
+                try {
+                    return (T) ((AnyResource) contentType).processor.syncRequest(new PossibleVariableRepresents(variable));
+                } catch (DatabaseException e) {
+                    LOGGER.error("Unexpected error occurred while resolving Resource from Variable " + variable, e);
+                }
+            }
+            else if (contentType instanceof AnyVariable) {
+                if (variable != null)
+                    return (T) variable;
+                if (resource == null)
+                    return null;
                 try {
-                       
-                       if(variable != null) return (T)variable;
-                       
-                       if(resource == null) return null;
-                       
-                    return (T) type.processor.sync(new ResourceRead<Variable>(resource) {
-                        @Override
-                        public Variable perform(ReadGraph graph) throws DatabaseException {
-                            return Variables.getPossibleVariable(graph, resource);
-                        }
-                        
-                    });
+                    return (T) ((AnyVariable) contentType).processor.syncRequest(new PossibleVariable(resource));
                 } catch (DatabaseException e) {
-                    Logger.defaultLogError(e);
+                    LOGGER.error("Unexpected error occurred while resolving Variable from Resource " + resource, e);
                 }
             } else if (contentType instanceof ExplorerInputContentType) {
-               return (T)input;
+                return (T) input;
             } else if (contentType instanceof ExplorerColumnContentType) {
-               return (T)explorerState.getActiveColumn();
+                return (T) explorerState.getActiveColumn();
             }
             return null;
         }
-        
+
         @SuppressWarnings("rawtypes")
         @Override
         public Object getAdapter(Class adapter) {
@@ -297,12 +302,12 @@ public class GraphExplorerComposite extends Composite implements Widget, IAdapta
         }
 
     }
-    private BinaryFunction<Object[], GraphExplorer, Object[]> selectionTransformation = new BinaryFunction<Object[], GraphExplorer, Object[]>() {
+    private BiFunction<GraphExplorer, Object[], Object[]> selectionTransformation = new BiFunction<GraphExplorer, Object[], Object[]>() {
 
        private Key[] KEYS = new Key[] { SelectionHints.KEY_MAIN };
        
         @Override
-        public Object[] call(GraphExplorer explorer, Object[] objects) {
+        public Object[] apply(GraphExplorer explorer, Object[] objects) {
             Object[] result = new Object[objects.length];
             for (int i = 0; i < objects.length; i++) {
                SelectionElement context = new SelectionElement(explorer, KEYS, objects[i]);
@@ -723,7 +728,7 @@ public class GraphExplorerComposite extends Composite implements Widget, IAdapta
                                                        event.data = WorkbenchSelectionUtils.getPossibleJSON(selectionProvider.getSelection());
                                                } catch (DatabaseException e) {
                                                        event.data = "{ type:\"Exception\" }";
-                                                       Logger.defaultLogError(e);
+                                                       LOGGER.error("Failed to get current selection as JSON.", e);
                                                }
                                        } else if (LocalObjectTransfer.getTransfer().isSupportedType(event.dataType)) {
                                                ls.dragSetData(event);
@@ -863,7 +868,7 @@ public class GraphExplorerComposite extends Composite implements Widget, IAdapta
        this.filterAreaSource = provider;
     }
 
-    public void setSelectionTransformation(BinaryFunction<Object[], GraphExplorer, Object[]> transformation) {
+    public void setSelectionTransformation(BiFunction<GraphExplorer, Object[], Object[]> transformation) {
         this.selectionTransformation = transformation;
         if(explorer != null) explorer.setSelectionTransformation(transformation);
     }
index 0bc3e02158018f79da1b9c24e2b4229fe1644a56..0745d1d81cae3e2cd866cab0aa4210c85b9e0fe2 100644 (file)
@@ -14,6 +14,7 @@ package org.simantics.browsing.ui;
 import java.util.Collection;
 import java.util.Map;
 import java.util.Set;
+import java.util.function.BiFunction;
 import java.util.function.Consumer;
 
 import org.eclipse.core.runtime.IAdaptable;
@@ -22,7 +23,6 @@ import org.simantics.browsing.ui.NodeContext.PrimitiveQueryKey;
 import org.simantics.browsing.ui.NodeContext.QueryKey;
 import org.simantics.browsing.ui.content.Labeler;
 import org.simantics.browsing.ui.content.Labeler.Modifier;
-import org.simantics.utils.datastructures.BinaryFunction;
 import org.simantics.utils.threads.IThreadWorkQueue;
 
 /**
@@ -205,7 +205,7 @@ public interface GraphExplorer extends IAdaptable {
      */
     void setSelectionFilter(SelectionFilter f);
 
-    void setSelectionTransformation(BinaryFunction<Object[], GraphExplorer, Object[]> f);
+    void setSelectionTransformation(BiFunction<GraphExplorer, Object[], Object[]> f);
 
     //ISelectionProvider getSelectionProvider();
 
diff --git a/bundles/org.simantics.db.layer0/src/org/simantics/db/layer0/request/PossibleVariableRepresents.java b/bundles/org.simantics.db.layer0/src/org/simantics/db/layer0/request/PossibleVariableRepresents.java
new file mode 100644 (file)
index 0000000..bb6a77d
--- /dev/null
@@ -0,0 +1,34 @@
+/*******************************************************************************
+ * Copyright (c) 2017 Association for Decentralized Information Management
+ * in Industry THTH ry.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     Semantum Oy - initial API and implementation
+ *******************************************************************************/
+package org.simantics.db.layer0.request;
+
+import org.simantics.db.ReadGraph;
+import org.simantics.db.Resource;
+import org.simantics.db.exception.DatabaseException;
+import org.simantics.db.layer0.variable.Variable;
+
+/**
+ * @author Tuukka Lehtonen
+ * @since 1.28.0
+ */
+public class PossibleVariableRepresents extends VariableRead<Resource> {
+
+    public PossibleVariableRepresents(Variable var) {
+        super(var);
+    }
+
+    @Override
+    public Resource perform(ReadGraph graph) throws DatabaseException {
+        return variable.getPossibleRepresents(graph);
+    }
+
+}
index 0f243db4816d72976fee02048a961531a21c6677..03edda6bdbc428762fc84516f52404c1eeb2aea2 100644 (file)
@@ -1,8 +1,6 @@
 package org.simantics.diagram.handler;
 
 import static org.simantics.diagram.handler.Paster.ComposedCutProcedure.compose;
-import gnu.trove.map.hash.THashMap;
-import gnu.trove.set.hash.THashSet;
 
 import java.awt.geom.AffineTransform;
 import java.awt.geom.Point2D;
@@ -14,6 +12,7 @@ import java.util.HashSet;
 import java.util.Map;
 import java.util.Queue;
 import java.util.Set;
+import java.util.function.BiFunction;
 
 import org.simantics.databoard.Bindings;
 import org.simantics.db.ReadGraph;
@@ -62,9 +61,11 @@ import org.simantics.structural.stubs.StructuralResource2;
 import org.simantics.structural2.modelingRules.CPTerminal;
 import org.simantics.structural2.modelingRules.ConnectionJudgement;
 import org.simantics.structural2.modelingRules.IConnectionPoint;
-import org.simantics.utils.datastructures.BinaryFunction;
 import org.simantics.utils.datastructures.map.Tuple;
 
+import gnu.trove.map.hash.THashMap;
+import gnu.trove.set.hash.THashSet;
+
 /**
  * @author Tuukka Lehtonen
  */
@@ -688,10 +689,10 @@ public class Paster {
      * Diagram mapping will have problems and potentially break the
      * configuration if the type is not the same as in the source.
      */
-    BinaryFunction<StatementEvaluation, ReadGraph, Statement> statementAdvisor =
-            new BinaryFunction<StatementEvaluation, ReadGraph, Statement>() {
+    BiFunction<ReadGraph, Statement, StatementEvaluation> statementAdvisor =
+            new BiFunction<ReadGraph, Statement, StatementEvaluation>() {
         @Override
-        public StatementEvaluation call(ReadGraph graph, Statement stm) {
+        public StatementEvaluation apply(ReadGraph graph, Statement stm) {
             if (DIA.HasFlagType.equals(stm.getPredicate()))
                 return StatementEvaluation.INCLUDE;
             return StatementEvaluation.USE_DEFAULT;
index 60d4c56aeaa54d9c5d0559dcea7b189d188e6a06..61d09acdd3cb18981d53c67e9300d255a3fc23d6 100644 (file)
@@ -15,6 +15,7 @@ import gnu.trove.map.hash.THashMap;
 
 import java.util.Map;
 import java.util.Set;
+import java.util.function.BiFunction;
 
 import org.simantics.databoard.Bindings;
 import org.simantics.databoard.binding.Binding;
@@ -44,7 +45,6 @@ import org.simantics.diagram.synchronization.SynchronizationHints;
 import org.simantics.graph.db.TransferableGraphs;
 import org.simantics.graph.representation.TransferableGraph1;
 import org.simantics.layer0.Layer0;
-import org.simantics.utils.datastructures.BinaryFunction;
 
 /**
  * This class contains utility methods for the basic cut/copy operations
@@ -223,7 +223,7 @@ public class CopyAdvisorUtil {
      * @return the copied resource
      * @throws DatabaseException
      */
-    public static Resource copy(WriteGraph graph, Resource source, BinaryFunction<Boolean, ReadGraph, Statement> advisor) throws DatabaseException {
+    public static Resource copy(WriteGraph graph, Resource source, BiFunction<ReadGraph, Statement, Boolean> advisor) throws DatabaseException {
         return copy(graph, source, 0, advisor, new THashMap<Object, Object>());
     }
 
@@ -238,11 +238,11 @@ public class CopyAdvisorUtil {
      * @return
      * @throws DatabaseException
      */
-    public static Resource copy(WriteGraph graph, Resource source, BinaryFunction<Boolean, ReadGraph, Statement> advisor, Map<Object, Object> copyMap) throws DatabaseException {
+    public static Resource copy(WriteGraph graph, Resource source, BiFunction<ReadGraph, Statement, Boolean> advisor, Map<Object, Object> copyMap) throws DatabaseException {
         return copy(graph, source, 0, advisor, copyMap);
     }
 
-    private static Resource copy(WriteGraph graph, Resource source, int level, BinaryFunction<Boolean, ReadGraph, Statement> advisor, Map<Object, Object> copyMap) throws DatabaseException {
+    private static Resource copy(WriteGraph graph, Resource source, int level, BiFunction<ReadGraph, Statement, Boolean> advisor, Map<Object, Object> copyMap) throws DatabaseException {
         if (DEBUG_COPY)
             System.out.println("[" + level + "] CopyAdvisorUtil.copy(" + NameUtils.getSafeName(graph, source) + ", advisor=" + advisor + ")");
 
@@ -320,7 +320,7 @@ public class CopyAdvisorUtil {
                 }
             } else {
                 if (advisor != null) {
-                    Boolean result = advisor.call(graph, stm);
+                    Boolean result = advisor.apply(graph, stm);
                     if (Boolean.TRUE.equals(result)) {
                         // Don't clone the object, just add relation to the same object.
                         if (inverse != null)
@@ -363,7 +363,7 @@ public class CopyAdvisorUtil {
      * @throws DatabaseException
      */
     public static Resource copy2(WriteGraph graph, Resource source,
-            BinaryFunction<StatementEvaluation, ReadGraph, Statement> advisor) throws DatabaseException {
+            BiFunction<ReadGraph, Statement, StatementEvaluation> advisor) throws DatabaseException {
         return copy2(graph, source, 0, advisor, new THashMap<Object, Object>());
     }
 
@@ -379,13 +379,13 @@ public class CopyAdvisorUtil {
      * @throws DatabaseException 
      */
     public static Resource copy2(WriteGraph graph, Resource source,
-            BinaryFunction<StatementEvaluation, ReadGraph, Statement> advisor, Map<Object, Object> copyMap)
+            BiFunction<ReadGraph, Statement, StatementEvaluation> advisor, Map<Object, Object> copyMap)
             throws DatabaseException {
         return copy2(graph, source, 0, advisor, copyMap);
     }
 
     private static Resource copy2(final WriteGraph graph, final Resource source, final int level,
-            BinaryFunction<StatementEvaluation, ReadGraph, Statement> advisor, Map<Object, Object> copyMap)
+            BiFunction<ReadGraph, Statement, StatementEvaluation> advisor, Map<Object, Object> copyMap)
     throws DatabaseException {
         if (DEBUG_COPY)
             System.out.println("[" + level + "] CopyAdvisorUtil.copy(" + NameUtils.getSafeName(graph, source) + ", advisor=" + advisor + ")");
@@ -536,7 +536,7 @@ public class CopyAdvisorUtil {
      * @throws DatabaseException
      */
     public static Resource copy3(WriteGraph graph, Resource source, Resource model,
-            BinaryFunction<StatementEvaluation, ReadGraph, Statement> advisor) throws DatabaseException {
+            BiFunction<ReadGraph, Statement, StatementEvaluation> advisor) throws DatabaseException {
         String modelURI = graph.getURI(model);
         return copy3(graph, modelURI, source, 0, advisor, new THashMap<Object, Object>());
     }
@@ -554,13 +554,13 @@ public class CopyAdvisorUtil {
      * @throws DatabaseException
      */
     public static Resource copy3(WriteGraph graph, Resource source, Resource model,
-            BinaryFunction<StatementEvaluation, ReadGraph, Statement> advisor, Map<Object, Object> copyMap) throws DatabaseException {
+            BiFunction<ReadGraph, Statement, StatementEvaluation> advisor, Map<Object, Object> copyMap) throws DatabaseException {
         String modelURI = graph.getURI(model);
         return copy3(graph, modelURI, source, 0, advisor, copyMap);
     }
 
     private static Resource copy3(WriteGraph graph, String modelURI, Resource source, int level,
-            BinaryFunction<StatementEvaluation, ReadGraph, Statement> advisor, Map<Object, Object> copyMap)
+            BiFunction<ReadGraph, Statement, StatementEvaluation> advisor, Map<Object, Object> copyMap)
     throws DatabaseException {
         if (DEBUG_COPY)
             System.out.println("[" + level + "] CopyAdvisorUtil.copy(" + NameUtils.getSafeName(graph, source) + ", advisor=" + advisor + ")");
@@ -698,10 +698,10 @@ public class CopyAdvisorUtil {
         return copy;
     }
 
-    protected static StatementEvaluation evaluate(ReadGraph graph, Statement stm, BinaryFunction<StatementEvaluation, ReadGraph, Statement> tester) {
+    protected static StatementEvaluation evaluate(ReadGraph graph, Statement stm, BiFunction<ReadGraph, Statement, StatementEvaluation> tester) {
         if (tester == null)
             return StatementEvaluation.USE_DEFAULT;
-        return tester.call(graph, stm);
+        return tester.apply(graph, stm);
     }
 
     /**
index bdfd3de6e2ae326ad739468ac913f1f58fcbe274..cd9111ec10b89b55db21110cf9d0032b44d1ac8b 100644 (file)
@@ -21,6 +21,7 @@ import java.util.Collection;
 import java.util.HashSet;
 import java.util.TreeMap;
 import java.util.UUID;
+import java.util.function.BiFunction;
 
 import org.simantics.databoard.Accessors;
 import org.simantics.databoard.Bindings;
@@ -61,7 +62,6 @@ import org.simantics.graph.representation.External;
 import org.simantics.graph.representation.Identity;
 import org.simantics.graph.representation.TransferableGraph1;
 import org.simantics.graph.representation.Value;
-import org.simantics.utils.datastructures.BinaryFunction;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -154,7 +154,7 @@ public class TransferableGraphs {
                                session.getService(SerialisationSupport.class));
        }
 
-       public static void importGraph1(Session session, final TransferableGraph1 tg, IImportAdvisor advisor, final BinaryFunction<Boolean, WriteOnlyGraph, TransferableGraphImportProcess> callback) throws DatabaseException, TransferableGraphException {
+       public static void importGraph1(Session session, final TransferableGraph1 tg, IImportAdvisor advisor, final BiFunction<WriteOnlyGraph, TransferableGraphImportProcess, Boolean> callback) throws DatabaseException, TransferableGraphException {
                final TransferableGraphImportProcess process = new TransferableGraphImportProcess(tg, 
                                advisor == null ? new ImportAdvisor() : advisor);
                session.syncRequest(new ReadRequest() {
@@ -168,7 +168,7 @@ public class TransferableGraphs {
                        public void perform(WriteOnlyGraph graph) throws DatabaseException {
                                process.write(graph);
                                if(callback != null)
-                                       callback.call(graph, process);
+                                       callback.apply(graph, process);
                        }
                });
        }
@@ -235,7 +235,7 @@ public class TransferableGraphs {
                });
        }
 
-       public static void importGraph1WithChanges(Session session, final TransferableGraph1 tg, IImportAdvisor advisor, final BinaryFunction<Boolean, WriteGraph, TransferableGraphImportProcess> callback) throws DatabaseException, TransferableGraphException {
+       public static void importGraph1WithChanges(Session session, final TransferableGraph1 tg, IImportAdvisor advisor, final BiFunction<WriteGraph, TransferableGraphImportProcess, Boolean> callback) throws DatabaseException, TransferableGraphException {
                final TransferableGraphImportProcess process = new TransferableGraphImportProcess(tg, 
                                advisor == null ? new ImportAdvisor() : advisor);
                session.syncRequest(new ReadRequest() {
@@ -252,7 +252,7 @@ public class TransferableGraphs {
                 comments.add("Imported transferable graph with " + tg.resourceCount + " resources");
                 graph.addMetadata(comments);
                                if(callback != null)
-                                       callback.call(graph, process);
+                                       callback.apply(graph, process);
                        }
                });
        }
index 2d786a580cc70437f2975a70548418c9921122ce..4786abd3b6d30aaa8ea0250e09a814c280cf9e0f 100644 (file)
@@ -11,6 +11,8 @@
  *******************************************************************************/
 package org.simantics.graph.db.old;
 
+import java.util.function.BiFunction;
+
 import org.simantics.db.ReadGraph;
 import org.simantics.db.Session;
 import org.simantics.db.WriteGraph;
@@ -22,11 +24,10 @@ import org.simantics.graph.db.IImportAdvisor;
 import org.simantics.graph.db.ImportAdvisor;
 import org.simantics.graph.db.TransferableGraphException;
 import org.simantics.graph.representation.old.OldTransferableGraph1;
-import org.simantics.utils.datastructures.BinaryFunction;
 
 public class OldTransferableGraphs {
 
-    public static void importGraph1(Session session, final OldTransferableGraph1 tg, IImportAdvisor advisor, final BinaryFunction<Boolean, WriteOnlyGraph, OldTransferableGraphImportProcess1> callback) throws DatabaseException, TransferableGraphException {
+    public static void importGraph1(Session session, final OldTransferableGraph1 tg, IImportAdvisor advisor, final BiFunction<WriteOnlyGraph, OldTransferableGraphImportProcess1, Boolean> callback) throws DatabaseException, TransferableGraphException {
         final OldTransferableGraphImportProcess1 process = new OldTransferableGraphImportProcess1(tg, 
                 advisor == null ? new ImportAdvisor() : advisor);
         session.syncRequest(new ReadRequest() {
@@ -40,7 +41,7 @@ public class OldTransferableGraphs {
             public void perform(WriteOnlyGraph graph) throws DatabaseException {
                 process.write(graph);
                 if(callback != null)
-                    callback.call(graph, process);
+                    callback.apply(graph, process);
             }
         });
     }
index df01fe5d267207d55881afff88007f6273545df3..9a1ea8360a751fe67aa294523be125f10a3f5150 100644 (file)
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2007, 2010 Association for Decentralized Information Management
+ * Copyright (c) 2007, 2017 Association for Decentralized Information Management
  * in Industry THTH ry.
  * All rights reserved. This program and the accompanying materials
  * are made available under the terms of the Eclipse Public License v1.0
@@ -8,6 +8,7 @@
  *
  * Contributors:
  *     VTT Technical Research Centre of Finland - initial API and implementation
+ *     Semantum Oy - #7116 regression fix
  *******************************************************************************/
 package org.simantics.modeling.ui.modelBrowser.handlers;
 
@@ -21,61 +22,71 @@ import org.simantics.Simantics;
 import org.simantics.databoard.Bindings;
 import org.simantics.db.ReadGraph;
 import org.simantics.db.Resource;
-import org.simantics.db.common.request.ResourceRead;
-import org.simantics.db.common.utils.Logger;
+import org.simantics.db.common.request.UniqueRead;
 import org.simantics.db.exception.DatabaseException;
 import org.simantics.db.layer0.variable.Variable;
 import org.simantics.modeling.ModelingResources;
 import org.simantics.modeling.PropertyVariables;
 import org.simantics.ui.selection.WorkbenchSelectionUtils;
 import org.simantics.utils.ui.AdaptionUtils;
+import org.slf4j.LoggerFactory;
 
 public class ContextualHelp extends AbstractHandler {
 
+    private static final org.slf4j.Logger LOGGER = LoggerFactory.getLogger(ContextualHelp.class);
+
     private static String getPossibleId(ExecutionEvent event) {
-        String id = null;
         try {
-            Resource element = WorkbenchSelectionUtils.getPossibleResource(event);
-            id = Simantics.getSession().syncRequest(new ResourceRead<String>(element) {
+            ISelection sel = HandlerUtil.getCurrentSelection(event);
+            Resource resource = WorkbenchSelectionUtils.getPossibleResource(sel);
+            Variable variable = WorkbenchSelectionUtils.getPossibleVariable(sel);
+            if (sel.isEmpty() && resource == null && variable == null)
+                return null;
 
+            return Simantics.getSession().syncRequest(new UniqueRead<String>() {
                 @Override
                 public String perform(ReadGraph graph) throws DatabaseException {
                     ModelingResources MOD = ModelingResources.getInstance(graph);
-                    Resource component = graph.getPossibleObject(element, MOD.ElementToComponent);
-                    if (component != null)
-                        return graph.getPossibleRelatedValue2(component, MOD.contextualHelpId, Bindings.STRING);
+                    if (resource != null) {
+                        Resource component = graph.getPossibleObject(resource, MOD.ElementToComponent);
+                        String id = component != null ? graph.getPossibleRelatedValue2(component, MOD.contextualHelpId, Bindings.STRING) : null;
+                        if (id != null)
+                            return id;
+                        id = graph.getPossibleRelatedValue2(resource, MOD.contextualHelpId, Bindings.STRING);
+                        if (id != null)
+                            return id;
+                    }
 
-                    Variable var = WorkbenchSelectionUtils.getPossibleVariable(event);
-                    if (var != null)
-                        return var.getPossiblePropertyValue(graph, MOD.contextualHelpId, Bindings.STRING);
+                    if (variable != null) {
+                        String id = variable.getPossiblePropertyValue(graph, MOD.contextualHelpId, Bindings.STRING);
+                        if (id != null)
+                            return id;
+                    }
 
-                    ISelection sel = HandlerUtil.getCurrentSelection(event);
+                    // TODO: consider removing this block
                     if (sel != null) {
                         PropertyVariables vars = AdaptionUtils.adaptToSingle(sel, PropertyVariables.class);
-                        if (vars != null) {
-                            var = vars.getConfiguration();
-                            if (var != null)
-                                var.getPossiblePropertyValue(graph, MOD.contextualHelpId, Bindings.STRING);
-                        }
+                        Variable var = vars != null ? vars.getConfiguration() : null;
+                        String id = var != null ? var.getPossiblePropertyValue(graph, MOD.contextualHelpId, Bindings.STRING) : null;
+                        if (id != null)
+                            return id;
                     }
+
                     return null;
                 }
             });
         } catch (DatabaseException e) {
-            Logger.defaultLogError(e);
+            LOGGER.error("", e);
+            return null;
         }
-        return id;
     }
 
     @Override
     public Object execute(ExecutionEvent event) throws ExecutionException {
-
         String id = getPossibleId(event);
         if (id != null)
             PlatformUI.getWorkbench().getHelpSystem().displayHelp(id);
-
         return null;
-
     }
 
 }
index be13d8cf8ebd42c9a7c65084966f8eeea0856d54..994aa1ab13feb132f6a9ce5ebaa5270c01bf6582 100644 (file)
@@ -11,9 +11,8 @@
  *******************************************************************************/
 package org.simantics.modeling.mapping;
 
-import gnu.trove.map.hash.THashMap;
-
 import java.util.Map;
+import java.util.function.BiFunction;
 
 import org.simantics.db.ReadGraph;
 import org.simantics.db.Resource;
@@ -33,7 +32,8 @@ import org.simantics.diagram.synchronization.graph.CopyAdvisorUtil;
 import org.simantics.diagram.synchronization.graph.GraphCopyAdvisor;
 import org.simantics.diagram.synchronization.graph.GraphSynchronizationHints;
 import org.simantics.layer0.Layer0;
-import org.simantics.utils.datastructures.BinaryFunction;
+
+import gnu.trove.map.hash.THashMap;
 
 /**
  * @author Tuukka Lehtonen
@@ -48,10 +48,10 @@ public class ElementCopyAdvisor extends GraphCopyAdvisor {
      * Diagram mapping will have problems and potentially break the
      * configuration if the type is not the same as in the source.
      */
-    BinaryFunction<StatementEvaluation, ReadGraph, Statement> statementAdvisor =
-            new BinaryFunction<StatementEvaluation, ReadGraph, Statement>() {
+    BiFunction<ReadGraph, Statement, StatementEvaluation> statementAdvisor =
+            new BiFunction<ReadGraph, Statement, StatementEvaluation>() {
         @Override
-        public StatementEvaluation call(ReadGraph graph, Statement stm) {
+        public StatementEvaluation apply(ReadGraph graph, Statement stm) {
             if (DIA.HasFlagType.equals(stm.getPredicate()))
                 return StatementEvaluation.INCLUDE;
             if (G2D.HasFontStyle.equals(stm.getPredicate()))
index 34b01b8f21a09a3e71ff3999b9bba102f7bf12fe..765a37c2a8e60c8c4f009bf513a659044a4a8863 100644 (file)
@@ -119,8 +119,8 @@ public class WorkbenchSelectionUtils {
        }
 
        public static Resource getPossibleResource(RequestProcessor processor, Object input, Resource type) throws DatabaseException {
-           if(input instanceof Collection && !((Collection)input).isEmpty()) {
-               Object element = ((Collection)input).iterator().next();
+           if(input instanceof Collection && !((Collection<?>)input).isEmpty()) {
+               Object element = ((Collection<?>)input).iterator().next();
                if(element instanceof Resource)
                    return (Resource)element;
            }
index e384efeb981a1bfd4e3b89f787eefcc99c74b991..331a81cd0d02905c332c46832885717ceeeda89b 100644 (file)
  *******************************************************************************/
 package org.simantics.utils.datastructures;
 
-public interface BinaryCallback<T1, T2> {
+import java.util.function.BiConsumer;
+
+/**
+ * @deprecated use {@link BiConsumer} instead
+ */
+@Deprecated
+public interface BinaryCallback<T1, T2> extends BiConsumer<T1, T2> {
 
     void run(T1 arg1, T2 arg2);
-    
+
+    @Override
+    default void accept(T1 arg, T2 arg2) {
+        run(arg, arg2);
+    }
+
 }
index 6bf58494bbf673cf8f66a16e73735e16c97ac5d2..5ba3face27335128c7014737be237c0fb5f3a97e 100644 (file)
@@ -18,8 +18,13 @@ import java.util.function.Supplier;
  */
 @Deprecated
 @FunctionalInterface
-public interface Callable<T> {
+public interface Callable<T> extends Supplier<T> {
 
     public T call();
 
+    @Override
+    default T get() {
+        return call();
+    }
+
 }
index 42eed9b89040873ef7d26a4cbe9e0cc3045420d7..99e952bb4d7de707524981b6c4a122fdee8bd20d 100644 (file)
@@ -13,6 +13,7 @@ package org.simantics.utils.datastructures;
 
 import java.io.PrintStream;
 import java.util.concurrent.TimeUnit;
+import java.util.function.BiConsumer;
 
 
 /**
@@ -31,7 +32,7 @@ public final class TimingUtil {
         }
     }
 
-    public static class PrintCallback implements BinaryCallback<Long, TimeUnit> {
+    public static class PrintCallback implements BiConsumer<Long, TimeUnit> {
         String task;
         PrintStream stream;
         PrintCallback(String task) {
@@ -42,7 +43,7 @@ public final class TimingUtil {
             this.stream = stream;
         }
         @Override
-        public void run(Long arg1, TimeUnit arg2) {
+        public void accept(Long arg1, TimeUnit arg2) {
             stream.println(task + " took " + arg1 + " " + arg2.toString());
         }
     };
@@ -59,11 +60,11 @@ public final class TimingUtil {
         time(runnable, reportTimeUnit, new PrintCallback(runnable.toString(), stream));
     }
 
-    public static void time(Runnable runnable, TimeUnit reportTimeUnit, BinaryCallback<Long, TimeUnit> result) {
+    public static void time(Runnable runnable, TimeUnit reportTimeUnit, BiConsumer<Long, TimeUnit> result) {
         long start = System.nanoTime();
         runnable.run();
         long end = System.nanoTime();
-        result.run(reportTimeUnit.convert(end-start, TimeUnit.NANOSECONDS), reportTimeUnit);
+        result.accept(reportTimeUnit.convert(end-start, TimeUnit.NANOSECONDS), reportTimeUnit);
     }
 
 }
index bb38164b79dfb0d2f9dbe5f43d99185d3ba6ac14..bb2148f4803d4923c7a70ad15bb778924f21ca13 100644 (file)
  *******************************************************************************/
 package org.simantics.utils.datastructures;
 
-public interface UnaryFunction<R, A> {
+import java.util.function.Function;
+
+/**
+ * @deprecated use {@link Function} instead
+ */
+@Deprecated
+public interface UnaryFunction<R, A> extends Function<A, R> {
 
     public R call(A arg);
-    
+
+    @Override
+    default R apply(A t) {
+        return call(t);
+    }
+
 }