]> gerrit.simantics Code Review - simantics/platform.git/commitdiff
Merge "Log an error if there are two resources with the same GUID."
authorTuukka Lehtonen <tuukka.lehtonen@semantum.fi>
Thu, 11 Oct 2018 12:52:33 +0000 (12:52 +0000)
committerGerrit Code Review <gerrit2@simantics>
Thu, 11 Oct 2018 12:52:33 +0000 (12:52 +0000)
bundles/org.simantics.browsing.ui.graph.impl/src/org/simantics/browsing/ui/graph/impl/contribution/FinalLabelerContributionImpl.java
bundles/org.simantics.browsing.ui.graph.impl/src/org/simantics/browsing/ui/graph/impl/contributor/labeler/ColumnLabelerContributorImpl.java
bundles/org.simantics.browsing.ui.swt/src/org/simantics/browsing/ui/swt/GraphExplorerToolTip.java
bundles/org.simantics.jdbc/.project
bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/modelBrowser/handlers/ContextualHelp.java
bundles/org.simantics.scenegraph.profile/src/org/simantics/scenegraph/profile/common/ProfileObserver.java

index ed56886944644b453c3d6f07d6c4a7cfc9a3337c..cf1e3223d1e28fa2d5f48600a86abbe78e9f70ab 100644 (file)
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2007, 2010 Association for Decentralized Information Management
+ * Copyright (c) 2007, 2018 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,12 +8,15 @@
  *
  * Contributors:
  *     VTT Technical Research Centre of Finland - initial API and implementation
+ *     Semantum Oy - gitlab #146 - tooltip support
  *******************************************************************************/
 package org.simantics.browsing.ui.graph.impl.contribution;
 
 import java.util.Collections;
 import java.util.Map;
 
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Event;
 import org.simantics.Simantics;
 import org.simantics.browsing.ui.BuiltinKeys;
 import org.simantics.browsing.ui.BuiltinKeys.LabelerKey;
@@ -24,6 +27,7 @@ import org.simantics.browsing.ui.PrimitiveQueryUpdater;
 import org.simantics.browsing.ui.common.labelers.LabelerContent;
 import org.simantics.browsing.ui.common.labelers.LabelerStub;
 import org.simantics.browsing.ui.common.node.IModifiableNode;
+import org.simantics.browsing.ui.graph.impl.contributor.labeler.ColumnLabelerContributorImpl;
 import org.simantics.browsing.ui.graph.impl.request.ResourceQuery;
 import org.simantics.db.AsyncReadGraph;
 import org.simantics.db.ReadGraph;
@@ -161,6 +165,16 @@ public abstract class FinalLabelerContributionImpl extends LabelerStub {
         
     }
 
+    @Override
+    public boolean shouldCreateToolTip(Event event, NodeContext nodeContext) {
+        return createToolTip(event, nodeContext);
+    }
+
+    @Override
+    public Composite createToolTipContentArea(Event event, Composite parent, NodeContext nodeContext) {
+        return (Composite)createToolTipContent(event, parent, nodeContext);
+    }
+
     // OVERRIDE
 
     public Modifier getModifier(ReadGraph graph, UndoContext undoContext, NodeContext context, String columnKey) throws DatabaseException {
@@ -171,4 +185,12 @@ public abstract class FinalLabelerContributionImpl extends LabelerStub {
 
     public abstract int category(ReadGraph graph, NodeContext context) throws DatabaseException;
 
+    public boolean createToolTip(Object event, NodeContext nodeContext) {
+        return false;
+    }
+
+    public Object createToolTipContent(Object event, Object parent, NodeContext nodeContext) {
+        return null;
+    }
+
 }
index d1dab0fb97adc521097769b14d88e115f15be79f..47dcf92c255a4b3a5015931e6d6aab7212e0d688 100644 (file)
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2007, 2010 Association for Decentralized Information Management
+ * Copyright (c) 2007, 2018 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 - gitlab #146 - tooltip support
  *******************************************************************************/
 package org.simantics.browsing.ui.graph.impl.contributor.labeler;
 
@@ -55,6 +56,14 @@ abstract public class ColumnLabelerContributorImpl<T> implements Contributor<Lab
         this.clazz = clazz;
     }
 
+    public boolean shouldCreateToolTip(Object event, T input) {
+        return false;
+    }
+
+    public Object createToolTipContentArea(Object event, Object parent, T input) {
+        return null;
+    }
+
     @Override
     public LabelerFactory getFactory() {
 
@@ -100,6 +109,18 @@ abstract public class ColumnLabelerContributorImpl<T> implements Contributor<Lab
                         return ColumnLabelerContributorImpl.this.toString();
                     }
 
+                    @Override
+                    public boolean createToolTip(Object event, NodeContext nodeContext) {
+                        T input = (T)context.getConstant(BuiltinKeys.INPUT);
+                        return ColumnLabelerContributorImpl.this.shouldCreateToolTip(event, input);
+                    }
+
+                    @Override
+                    public Object createToolTipContent(Object event, Object parent, NodeContext nodeContext) {
+                        T input = (T)context.getConstant(BuiltinKeys.INPUT);
+                        return ColumnLabelerContributorImpl.this.createToolTipContentArea(event, parent, input);
+                    }
+
                 };
 
             }
index f23d4ee1943ae1afb6ce4b1cb167ff197b473c7f..0cc2e71a8c768ddce6c08a2a85cb648794b0a4e5 100644 (file)
@@ -5,6 +5,7 @@ import org.eclipse.swt.graphics.Point;
 import org.eclipse.swt.widgets.Composite;
 import org.eclipse.swt.widgets.Event;
 import org.eclipse.swt.widgets.Tree;
+import org.eclipse.swt.widgets.TreeColumn;
 import org.eclipse.swt.widgets.TreeItem;
 import org.simantics.browsing.ui.BuiltinKeys;
 import org.simantics.browsing.ui.NodeContext;
@@ -44,6 +45,19 @@ public class GraphExplorerToolTip extends ToolTip {
         TreeItem treeItem = parent.getItem(new Point(event.x, event.y));
         if (treeItem == null)
             return false;
+        // Locate the column, and add the column reference to Event object.
+        TreeColumn columns[] = parent.getColumns();
+        TreeColumn column = null;
+        int x = 0;
+        for (TreeColumn c : columns) {
+            int w = c.getWidth();
+            if (event.x >= x && event.x < (x+w)) {
+                column = c;
+                break;
+            }
+            x+=w;
+        }
+        event.data = column.getData();
         GENodeQueryManager manager = new GENodeQueryManager(explorerContext, null, null, TreeItemReference.create(treeItem.getParentItem()));
         nodeContext = (NodeContext) treeItem.getData();
         if (nodeContext != null)
index 3af9a2f8fff560d9a2f9dae94f6d909890449a6f..8ce9c486afe5fcf4196fc90648b7f7dc2d990dda 100644 (file)
@@ -1,34 +1,28 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<projectDescription>
-       <name>org.simantics.jdbc</name>
-       <comment></comment>
-       <projects>
-       </projects>
-       <buildSpec>
-               <buildCommand>
-                       <name>org.simantics.graph.builder</name>
-                       <arguments>
-                       </arguments>
-               </buildCommand>
-               <buildCommand>
-                       <name>org.eclipse.jdt.core.javabuilder</name>
-                       <arguments>
-                       </arguments>
-               </buildCommand>
-               <buildCommand>
-                       <name>org.eclipse.pde.ManifestBuilder</name>
-                       <arguments>
-                       </arguments>
-               </buildCommand>
-               <buildCommand>
-                       <name>org.eclipse.pde.SchemaBuilder</name>
-                       <arguments>
-                       </arguments>
-               </buildCommand>
-       </buildSpec>
-       <natures>
-               <nature>org.eclipse.pde.PluginNature</nature>
-               <nature>org.eclipse.jdt.core.javanature</nature>
-               <nature>org.simantics.graph.nature</nature>
-       </natures>
-</projectDescription>
+<?xml version="1.0" encoding="UTF-8"?>\r
+<projectDescription>\r
+       <name>org.simantics.jdbc</name>\r
+       <comment></comment>\r
+       <projects>\r
+       </projects>\r
+       <buildSpec>\r
+               <buildCommand>\r
+                       <name>org.eclipse.jdt.core.javabuilder</name>\r
+                       <arguments>\r
+                       </arguments>\r
+               </buildCommand>\r
+               <buildCommand>\r
+                       <name>org.eclipse.pde.ManifestBuilder</name>\r
+                       <arguments>\r
+                       </arguments>\r
+               </buildCommand>\r
+               <buildCommand>\r
+                       <name>org.eclipse.pde.SchemaBuilder</name>\r
+                       <arguments>\r
+                       </arguments>\r
+               </buildCommand>\r
+       </buildSpec>\r
+       <natures>\r
+               <nature>org.eclipse.pde.PluginNature</nature>\r
+               <nature>org.eclipse.jdt.core.javanature</nature>\r
+       </natures>\r
+</projectDescription>\r
index 9a1ea8360a751fe67aa294523be125f10a3f5150..0d0ec7ce64d5554b46e1913ebb3cd33a21f3ddde 100644 (file)
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2007, 2017 Association for Decentralized Information Management
+ * Copyright (c) 2007, 2018 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
@@ -9,6 +9,7 @@
  * Contributors:
  *     VTT Technical Research Centre of Finland - initial API and implementation
  *     Semantum Oy - #7116 regression fix
+ *     Semantum Oy - gitlab #147 - expose getPossibleId implementation
  *******************************************************************************/
 package org.simantics.modeling.ui.modelBrowser.handlers;
 
@@ -46,33 +47,7 @@ public class ContextualHelp extends AbstractHandler {
             return Simantics.getSession().syncRequest(new UniqueRead<String>() {
                 @Override
                 public String perform(ReadGraph graph) throws DatabaseException {
-                    ModelingResources MOD = ModelingResources.getInstance(graph);
-                    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;
-                    }
-
-                    if (variable != null) {
-                        String id = variable.getPossiblePropertyValue(graph, MOD.contextualHelpId, Bindings.STRING);
-                        if (id != null)
-                            return id;
-                    }
-
-                    // TODO: consider removing this block
-                    if (sel != null) {
-                        PropertyVariables vars = AdaptionUtils.adaptToSingle(sel, PropertyVariables.class);
-                        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;
+                    return getPossibleId(graph, resource, variable, sel);
                 }
             });
         } catch (DatabaseException e) {
@@ -89,4 +64,34 @@ public class ContextualHelp extends AbstractHandler {
         return null;
     }
 
+    public static String getPossibleId(ReadGraph graph, Resource resource, Variable variable, ISelection sel) throws DatabaseException {
+        ModelingResources MOD = ModelingResources.getInstance(graph);
+        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;
+        }
+
+        if (variable != null) {
+            String id = variable.getPossiblePropertyValue(graph, MOD.contextualHelpId, Bindings.STRING);
+            if (id != null)
+                return id;
+        }
+
+        // TODO: consider removing this block
+        if (sel != null) {
+            PropertyVariables vars = AdaptionUtils.adaptToSingle(sel, PropertyVariables.class);
+            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;
+    }
+
 }
index 6fc72b3d3ea35d87a36cbe0792793f24c68600bf..efac19055944c8a2ab3bc713dd3100647755d9f8 100644 (file)
@@ -252,7 +252,7 @@ public class ProfileObserver implements EvaluationContext {
         if (value == null) {
             map.remove(key);
             if (map.isEmpty())
-                properties.remove(element);
+                temporaryProperties.remove(element);
         } else
             map.put(key, value);
     }