/*******************************************************************************
- * 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
*
* 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;
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.ReadGraph;
import org.simantics.db.UndoContext;
}
+ @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 {
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;
+ }
+
}
/*******************************************************************************
- * 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
*
* 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;
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() {
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);
+ }
+
};
}
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;
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)