1 /*******************************************************************************
2 * Copyright (c) 2017 Association for Decentralized Information Management
4 * All rights reserved. This program and the accompanying materials
5 * are made available under the terms of the Eclipse Public License v1.0
6 * which accompanies this distribution, and is available at
7 * http://www.eclipse.org/legal/epl-v10.html
10 * Semantum Oy - initial API and implementation
11 *******************************************************************************/
12 package org.simantics.issues.ui.handler;
14 import org.eclipse.ui.PlatformUI;
15 import org.simantics.Simantics;
16 import org.simantics.databoard.Bindings;
17 import org.simantics.databoard.binding.Binding;
18 import org.simantics.db.ReadGraph;
19 import org.simantics.db.common.request.TernaryRead;
20 import org.simantics.db.common.utils.Logger;
21 import org.simantics.db.exception.DatabaseException;
22 import org.simantics.db.layer0.adapter.ActionFactory;
23 import org.simantics.db.layer0.variable.Variable;
26 * @author Tuukka Lehtonen
29 public class Help implements ActionFactory {
32 public Runnable create(Object target) {
33 if (target instanceof Variable) {
36 String id = Simantics.sync(new PossibleVariablePropertyValue<String>((Variable) target, "contextualHelpId", Bindings.STRING));
38 PlatformUI.getWorkbench().getHelpSystem().displayDynamicHelp();
41 PlatformUI.getWorkbench().getHelpSystem().displayHelp(id);
42 } catch (DatabaseException e) {
43 Logger.defaultLogError(e);
51 static class PossibleVariablePropertyValue<T> extends TernaryRead<Variable, String, Binding, T> {
53 public PossibleVariablePropertyValue(Variable variable, String property, Binding binding) {
54 super(variable, property, binding);
58 public T perform(ReadGraph graph) throws DatabaseException {
59 return parameter.getPossiblePropertyValue(graph, parameter2, parameter3);