From 972fd5be2b27129dd53bbf885d9a95314e47ddc2 Mon Sep 17 00:00:00 2001 From: Marko Luukkainen Date: Thu, 11 Oct 2018 14:12:36 +0300 Subject: [PATCH] Allow column specific tooltips in the GraphExplorer gitlab #146 Change-Id: I8c07e3013783ffd31fba95391e0b8ba35b855b84 (cherry picked from commit d4cdaa8ea386ab9f6432854db9481f42c70983fd) --- .../FinalLabelerContributionImpl.java | 24 ++++++++++++++++++- .../labeler/ColumnLabelerContributorImpl.java | 23 +++++++++++++++++- .../browsing/ui/swt/GraphExplorerToolTip.java | 14 +++++++++++ 3 files changed, 59 insertions(+), 2 deletions(-) diff --git a/bundles/org.simantics.browsing.ui.graph.impl/src/org/simantics/browsing/ui/graph/impl/contribution/FinalLabelerContributionImpl.java b/bundles/org.simantics.browsing.ui.graph.impl/src/org/simantics/browsing/ui/graph/impl/contribution/FinalLabelerContributionImpl.java index ed5688694..cf1e3223d 100644 --- a/bundles/org.simantics.browsing.ui.graph.impl/src/org/simantics/browsing/ui/graph/impl/contribution/FinalLabelerContributionImpl.java +++ b/bundles/org.simantics.browsing.ui.graph.impl/src/org/simantics/browsing/ui/graph/impl/contribution/FinalLabelerContributionImpl.java @@ -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; + } + } diff --git a/bundles/org.simantics.browsing.ui.graph.impl/src/org/simantics/browsing/ui/graph/impl/contributor/labeler/ColumnLabelerContributorImpl.java b/bundles/org.simantics.browsing.ui.graph.impl/src/org/simantics/browsing/ui/graph/impl/contributor/labeler/ColumnLabelerContributorImpl.java index d1dab0fb9..47dcf92c2 100644 --- a/bundles/org.simantics.browsing.ui.graph.impl/src/org/simantics/browsing/ui/graph/impl/contributor/labeler/ColumnLabelerContributorImpl.java +++ b/bundles/org.simantics.browsing.ui.graph.impl/src/org/simantics/browsing/ui/graph/impl/contributor/labeler/ColumnLabelerContributorImpl.java @@ -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 implements Contributor implements Contributor= 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) -- 2.43.2