Add utility class org.simantics.modeling.help.HelpContexts
[simantics/platform.git] / bundles / org.simantics.modeling / src / org / simantics / modeling / actions / Help.java
index ba124310800bb29b87988d85144176fa19f7bc96..22327aeb3f71b833ea002af5705ca7080a87ac96 100644 (file)
@@ -16,38 +16,36 @@ import org.simantics.Simantics;
 import org.simantics.databoard.Bindings;
 import org.simantics.db.Resource;
 import org.simantics.db.common.primitiverequest.PossibleRelatedValue2;
-import org.simantics.db.common.utils.Logger;
 import org.simantics.db.exception.DatabaseException;
 import org.simantics.db.layer0.adapter.ActionFactory;
 import org.simantics.modeling.ModelingResources;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 public class Help implements ActionFactory {
 
+       private static final Logger LOGGER = LoggerFactory.getLogger(Help.class);
+
        @Override
        public Runnable create(Object target) {
-
-               if(!(target instanceof Resource))
+               if (!(target instanceof Resource))
                        return null;
 
-               final Resource resource = (Resource)target;
-               
-               return new Runnable() {
-                       @Override
-                       public void run() {
-                               
-                               try {
-                                       ModelingResources MOD = ModelingResources.getInstance(Simantics.getSession());
-                                       String id = Simantics.sync(new PossibleRelatedValue2<String>(resource, MOD.contextualHelpId, Bindings.STRING));
-                                       if(id == null) {
-                                               PlatformUI.getWorkbench().getHelpSystem().displayDynamicHelp();
-                                               return;
-                                       }
-                                       PlatformUI.getWorkbench().getHelpSystem().displayHelp(id);
-                               } catch (DatabaseException e) {
-                                       Logger.defaultLogError(e);
+               final Resource resource = (Resource) target;
+
+               return () -> {
+                       try {
+                               ModelingResources MOD = ModelingResources.getInstance(Simantics.getSession());
+                               String id = Simantics.sync(new PossibleRelatedValue2<String>(resource, MOD.contextualHelpId, Bindings.STRING));
+                               if (id == null) {
+                                       PlatformUI.getWorkbench().getHelpSystem().displayDynamicHelp();
+                                       return;
                                }
-                               
+                               PlatformUI.getWorkbench().getHelpSystem().displayHelp(id);
+                       } catch (DatabaseException e) {
+                               LOGGER.error("Failed to display help for resource {}", resource, e);
                        }
                }; 
        }
+
 }