]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.debug.ui/src/org/simantics/debug/ui/GraphDebuggerEditor.java
Externalize strings in org.simantics.debug.ui
[simantics/platform.git] / bundles / org.simantics.debug.ui / src / org / simantics / debug / ui / GraphDebuggerEditor.java
index a4103deb91478d6f0ff0bdb21e4ec53833478363..890036afcb623fbeeba3dc03367a06ed7eb5b45c 100644 (file)
-/*******************************************************************************\r
- * Copyright (c) 2007, 2013 Association for Decentralized Information Management\r
- * in Industry THTH ry.\r
- * All rights reserved. This program and the accompanying materials\r
- * are made available under the terms of the Eclipse Public License v1.0\r
- * which accompanies this distribution, and is available at\r
- * http://www.eclipse.org/legal/epl-v10.html\r
- *\r
- * Contributors:\r
- *     VTT Technical Research Centre of Finland - initial API and implementation\r
- *     Semantum Oy - index based searching and graph manipulation (#4255)\r
- *******************************************************************************/\r
-package org.simantics.debug.ui;\r
-\r
-import org.eclipse.core.runtime.IStatus;\r
-import org.eclipse.core.runtime.Status;\r
-import org.eclipse.jface.action.Action;\r
-import org.eclipse.jface.action.ActionContributionItem;\r
-import org.eclipse.jface.action.IAction;\r
-import org.eclipse.jface.action.Separator;\r
-import org.eclipse.jface.layout.GridDataFactory;\r
-import org.eclipse.swt.SWT;\r
-import org.eclipse.swt.layout.GridData;\r
-import org.eclipse.swt.layout.GridLayout;\r
-import org.eclipse.swt.widgets.Composite;\r
-import org.eclipse.swt.widgets.Control;\r
-import org.eclipse.swt.widgets.ToolBar;\r
-import org.eclipse.ui.ISharedImages;\r
-import org.eclipse.ui.PlatformUI;\r
-import org.simantics.Simantics;\r
-import org.simantics.db.exception.DatabaseException;\r
-import org.simantics.debug.ui.internal.Activator;\r
-import org.simantics.debug.ui.internal.DebugUtils;\r
-import org.simantics.ui.SimanticsUI;\r
-import org.simantics.ui.workbench.ResourceEditorPart;\r
-import org.simantics.utils.ui.BundleUtils;\r
-import org.simantics.utils.ui.LayoutUtils;\r
-\r
-public class GraphDebuggerEditor extends ResourceEditorPart {\r
-\r
-    public static final String EDITOR_ID = "org.simantics.debug.graphDebuggerEditor";\r
-\r
-    private GraphDebugger      debugger;\r
-    private IAction            backAction;\r
-    private IAction            forwardAction;\r
-    private IAction            refreshAction;\r
-    private IAction            findAction;\r
-    private IAction            addStatementAction;\r
-    private IAction            addResourceAction;\r
-\r
-    @Override\r
-    public void createPartControl(Composite parent) {\r
-        // Create UI\r
-        parent.setLayout(LayoutUtils.createNoBorderGridLayout(1));\r
-\r
-        debugger = new GraphDebugger(parent, SWT.NONE, getSession(), getInputResource(), getSite());\r
-        debugger.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));\r
-        debugger.setLayout(LayoutUtils.createNoBorderGridLayout(1));\r
-\r
-        Composite bar = new Composite(debugger, SWT.NONE);\r
-        bar.setLayout(new GridLayout(3, false));\r
-        bar.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));\r
-\r
-        backAction = new BackAction();\r
-        forwardAction = new ForwardAction();\r
-        refreshAction = new RefreshAction();\r
-        findAction = new FindAction();\r
-        addStatementAction = new AddStatementAction();\r
-        addResourceAction = new AddResourceAction();\r
-\r
-        ToolBar toolBar = new ToolBar(bar, SWT.HORIZONTAL | SWT.FLAT);\r
-\r
-        new ActionContributionItem(backAction).fill(toolBar, 0);\r
-        new ActionContributionItem(forwardAction).fill(toolBar, 1);\r
-        new Separator().fill(toolBar, 2);\r
-        new ActionContributionItem(refreshAction).fill(toolBar, 3);\r
-        new Separator().fill(toolBar, 4);\r
-        new ActionContributionItem(findAction).fill(toolBar, 5);\r
-        new ActionContributionItem(addStatementAction).fill(toolBar, 6);\r
-        new ActionContributionItem(addResourceAction).fill(toolBar, 7);\r
-\r
-        debugger.createResourceText(bar);\r
-        Control dropLabel = debugger.createDropLabel(bar);\r
-        GridDataFactory.fillDefaults().grab(true, false).align(SWT.FILL, SWT.FILL).hint(SWT.DEFAULT, 20).span(3, 1).applyTo(dropLabel);\r
-        Control browser = debugger.createBrowser(debugger);\r
-        GridDataFactory.fillDefaults().grab(true, true).span(3, 1).applyTo(browser);\r
-\r
-        debugger.addHistoryListener(new GraphDebugger.HistoryListener() {\r
-            @Override\r
-            public void historyChanged() {\r
-                updateActionStates();\r
-            }\r
-        });\r
-\r
-        updateActionStates();\r
-    }\r
-\r
-    @Override\r
-    public void setFocus() {\r
-        if (debugger != null)\r
-            debugger.setFocus();\r
-    }\r
-\r
-    public void back() {\r
-        debugger.back();\r
-    }\r
-\r
-    public void forward() {\r
-        debugger.forward();\r
-    }\r
-\r
-    public void refreshBrowser() {\r
-        debugger.refreshBrowser();\r
-    }\r
-\r
-    private void updateActionStates() {\r
-        backAction.setEnabled(!debugger.hasBackHistory());\r
-        forwardAction.setEnabled(!debugger.hasForwardHistory());\r
-    }\r
-\r
-    class RefreshAction extends Action {\r
-        public RefreshAction() {\r
-            super("Refresh", BundleUtils.getImageDescriptorFromPlugin(SimanticsUI.PLUGIN_ID, "icons/refresh.gif"));\r
-            setToolTipText("Refresh");\r
-        }\r
-        @Override\r
-        public void run() {\r
-            refreshBrowser();\r
-        }\r
-    }\r
-\r
-    class FindAction extends Action {\r
-        public FindAction() {\r
-            super("Find", BundleUtils.getImageDescriptorFromPlugin(Activator.PLUGIN_ID, "icons/cog_blue.png"));\r
-            setToolTipText("Find Resource");\r
-        }\r
-        @Override\r
-        public void run() {\r
-            DebugUtils.find(Simantics.getSession(), debugger);\r
-        }\r
-    }\r
-\r
-    class AddStatementAction extends Action {\r
-        public AddStatementAction() {\r
-            super("AddStatement", BundleUtils.getImageDescriptorFromPlugin(Activator.PLUGIN_ID, "icons/cog_add.png"));\r
-            setToolTipText("Add Statement Between Existing Resources");\r
-        }\r
-        @Override\r
-        public void run() {\r
-            try {\r
-                DebugUtils.addStatement(Simantics.getSession(), debugger);\r
-            } catch (DatabaseException e) {\r
-                Activator.getDefault().getLog().log(new Status(IStatus.ERROR, Activator.PLUGIN_ID, e.getMessage(), e));\r
-            }\r
-        }\r
-    }\r
-\r
-    class AddResourceAction extends Action {\r
-        public AddResourceAction() {\r
-            super("AddResource", BundleUtils.getImageDescriptorFromPlugin(Activator.PLUGIN_ID, "icons/cog_add.png"));\r
-            setToolTipText("Add New Related Resource");\r
-        }\r
-        @Override\r
-        public void run() {\r
-            try {\r
-                DebugUtils.addResource(Simantics.getSession(), debugger);\r
-            } catch (DatabaseException e) {\r
-                Activator.getDefault().getLog().log(new Status(IStatus.ERROR, Activator.PLUGIN_ID, e.getMessage(), e));\r
-            }\r
-        }\r
-    }\r
-\r
-    class BackAction extends Action {\r
-        public BackAction() {\r
-            super("Back", Action.AS_PUSH_BUTTON);\r
-            setToolTipText("Back");\r
-            setImageDescriptor(PlatformUI.getWorkbench().getSharedImages().getImageDescriptor(ISharedImages.IMG_TOOL_BACK));\r
-            setDisabledImageDescriptor(PlatformUI.getWorkbench().getSharedImages().getImageDescriptor(ISharedImages.IMG_TOOL_BACK_DISABLED));\r
-        }\r
-        @Override\r
-        public void run() {\r
-            back();\r
-            updateActionStates();\r
-        }\r
-    }\r
-\r
-    class ForwardAction extends Action {\r
-        public ForwardAction() {\r
-            super("Forward", Action.AS_PUSH_BUTTON);\r
-            setToolTipText("Forward");\r
-            setImageDescriptor(PlatformUI.getWorkbench().getSharedImages().getImageDescriptor(ISharedImages.IMG_TOOL_FORWARD));\r
-            setDisabledImageDescriptor(PlatformUI.getWorkbench().getSharedImages().getImageDescriptor(ISharedImages.IMG_TOOL_FORWARD_DISABLED));\r
-        }\r
-        @Override\r
-        public void run() {\r
-            forward();\r
-            updateActionStates();\r
-        }\r
-    }\r
-\r
-}\r
+/*******************************************************************************
+ * Copyright (c) 2007, 2013 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
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     VTT Technical Research Centre of Finland - initial API and implementation
+ *     Semantum Oy - index based searching and graph manipulation (#4255)
+ *******************************************************************************/
+package org.simantics.debug.ui;
+
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.action.ActionContributionItem;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.action.Separator;
+import org.eclipse.jface.layout.GridDataFactory;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.ToolBar;
+import org.eclipse.ui.ISharedImages;
+import org.eclipse.ui.PlatformUI;
+import org.simantics.Simantics;
+import org.simantics.db.exception.DatabaseException;
+import org.simantics.debug.ui.internal.Activator;
+import org.simantics.debug.ui.internal.DebugUtils;
+import org.simantics.ui.SimanticsUI;
+import org.simantics.ui.workbench.ResourceEditorPart;
+import org.simantics.utils.ui.BundleUtils;
+import org.simantics.utils.ui.LayoutUtils;
+
+public class GraphDebuggerEditor extends ResourceEditorPart {
+
+    public static final String EDITOR_ID = "org.simantics.debug.graphDebuggerEditor"; //$NON-NLS-1$
+
+    private GraphDebugger      debugger;
+    private IAction            backAction;
+    private IAction            forwardAction;
+    private IAction            refreshAction;
+    private IAction            findAction;
+    private IAction            addStatementAction;
+    private IAction            addResourceAction;
+
+    @Override
+    public void createPartControl(Composite parent) {
+        // Create UI
+        parent.setLayout(LayoutUtils.createNoBorderGridLayout(1));
+
+        debugger = new GraphDebugger(parent, SWT.NONE, getSession(), getInputResource(), getSite());
+        debugger.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
+        debugger.setLayout(LayoutUtils.createNoBorderGridLayout(1));
+
+        Composite bar = new Composite(debugger, SWT.NONE);
+        bar.setLayout(new GridLayout(3, false));
+        bar.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
+
+        backAction = new BackAction();
+        forwardAction = new ForwardAction();
+        refreshAction = new RefreshAction();
+        findAction = new FindAction();
+        addStatementAction = new AddStatementAction();
+        addResourceAction = new AddResourceAction();
+
+        ToolBar toolBar = new ToolBar(bar, SWT.HORIZONTAL | SWT.FLAT);
+
+        new ActionContributionItem(backAction).fill(toolBar, 0);
+        new ActionContributionItem(forwardAction).fill(toolBar, 1);
+        new Separator().fill(toolBar, 2);
+        new ActionContributionItem(refreshAction).fill(toolBar, 3);
+        new Separator().fill(toolBar, 4);
+        new ActionContributionItem(findAction).fill(toolBar, 5);
+        new ActionContributionItem(addStatementAction).fill(toolBar, 6);
+        new ActionContributionItem(addResourceAction).fill(toolBar, 7);
+
+        debugger.createResourceText(bar);
+        Control dropLabel = debugger.createDropLabel(bar);
+        GridDataFactory.fillDefaults().grab(true, false).align(SWT.FILL, SWT.FILL).hint(SWT.DEFAULT, 20).span(3, 1).applyTo(dropLabel);
+        Control browser = debugger.createBrowser(debugger);
+        GridDataFactory.fillDefaults().grab(true, true).span(3, 1).applyTo(browser);
+
+        debugger.addHistoryListener(new GraphDebugger.HistoryListener() {
+            @Override
+            public void historyChanged() {
+                updateActionStates();
+            }
+        });
+
+        updateActionStates();
+    }
+
+    @Override
+    public void setFocus() {
+        if (debugger != null)
+            debugger.setFocus();
+    }
+
+    public void back() {
+        debugger.back();
+    }
+
+    public void forward() {
+        debugger.forward();
+    }
+
+    public void refreshBrowser() {
+        debugger.refreshBrowser();
+    }
+
+    private void updateActionStates() {
+        backAction.setEnabled(!debugger.hasBackHistory());
+        forwardAction.setEnabled(!debugger.hasForwardHistory());
+    }
+
+    class RefreshAction extends Action {
+        public RefreshAction() {
+            super(Messages.GraphDebuggerEditor_Refresh, BundleUtils.getImageDescriptorFromPlugin(SimanticsUI.PLUGIN_ID, "icons/refresh.gif")); //$NON-NLS-2$
+            setToolTipText(Messages.GraphDebuggerEditor_RefreshTT);
+        }
+        @Override
+        public void run() {
+            refreshBrowser();
+        }
+    }
+
+    class FindAction extends Action {
+        public FindAction() {
+            super(Messages.GraphDebuggerEditor_Find, BundleUtils.getImageDescriptorFromPlugin(Activator.PLUGIN_ID, "icons/cog_blue.png")); //$NON-NLS-2$
+            setToolTipText(Messages.GraphDebuggerEditor_FindTT);
+        }
+        @Override
+        public void run() {
+            DebugUtils.find(Simantics.getSession(), debugger);
+        }
+    }
+
+    class AddStatementAction extends Action {
+        public AddStatementAction() {
+            super(Messages.GraphDebuggerEditor_AddStatement, BundleUtils.getImageDescriptorFromPlugin(Activator.PLUGIN_ID, "icons/cog_add.png")); //$NON-NLS-2$
+            setToolTipText(Messages.GraphDebuggerEditor_AddStatementTT);
+        }
+        @Override
+        public void run() {
+            try {
+                DebugUtils.addStatement(Simantics.getSession(), debugger);
+            } catch (DatabaseException e) {
+                Activator.getDefault().getLog().log(new Status(IStatus.ERROR, Activator.PLUGIN_ID, e.getMessage(), e));
+            }
+        }
+    }
+
+    class AddResourceAction extends Action {
+        public AddResourceAction() {
+            super(Messages.GraphDebuggerEditor_AddResource, BundleUtils.getImageDescriptorFromPlugin(Activator.PLUGIN_ID, "icons/cog_add.png")); //$NON-NLS-2$
+            setToolTipText(Messages.GraphDebuggerEditor_AddResourceTT);
+        }
+        @Override
+        public void run() {
+            try {
+                DebugUtils.addResource(Simantics.getSession(), debugger);
+            } catch (DatabaseException e) {
+                Activator.getDefault().getLog().log(new Status(IStatus.ERROR, Activator.PLUGIN_ID, e.getMessage(), e));
+            }
+        }
+    }
+
+    class BackAction extends Action {
+        public BackAction() {
+            super(Messages.GraphDebuggerEditor_Back, Action.AS_PUSH_BUTTON);
+            setToolTipText(Messages.GraphDebuggerEditor_BackTT);
+            setImageDescriptor(PlatformUI.getWorkbench().getSharedImages().getImageDescriptor(ISharedImages.IMG_TOOL_BACK));
+            setDisabledImageDescriptor(PlatformUI.getWorkbench().getSharedImages().getImageDescriptor(ISharedImages.IMG_TOOL_BACK_DISABLED));
+        }
+        @Override
+        public void run() {
+            back();
+            updateActionStates();
+        }
+    }
+
+    class ForwardAction extends Action {
+        public ForwardAction() {
+            super(Messages.GraphDebuggerEditor_Forward, Action.AS_PUSH_BUTTON);
+            setToolTipText(Messages.GraphDebuggerEditor_ForwardTT);
+            setImageDescriptor(PlatformUI.getWorkbench().getSharedImages().getImageDescriptor(ISharedImages.IMG_TOOL_FORWARD));
+            setDisabledImageDescriptor(PlatformUI.getWorkbench().getSharedImages().getImageDescriptor(ISharedImages.IMG_TOOL_FORWARD_DISABLED));
+        }
+        @Override
+        public void run() {
+            forward();
+            updateActionStates();
+        }
+    }
+
+}