-/*******************************************************************************\r
- * Copyright (c) 2007, 2010 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
- *******************************************************************************/\r
-package org.simantics.debug.ui.graph;\r
-\r
-import org.eclipse.jface.action.Action;\r
-import org.eclipse.jface.action.IToolBarManager;\r
-import org.eclipse.jface.action.Separator;\r
-import org.eclipse.swt.SWT;\r
-import org.eclipse.swt.widgets.Composite;\r
-import org.eclipse.ui.IActionBars;\r
-import org.eclipse.ui.ISharedImages;\r
-import org.eclipse.ui.PlatformUI;\r
-import org.eclipse.ui.part.ViewPart;\r
-import org.simantics.db.Resource;\r
-import org.simantics.db.Session;\r
-import org.simantics.db.exception.DatabaseException;\r
-import org.simantics.ui.SimanticsUI;\r
-import org.simantics.ui.workbench.ResourceInput;\r
-import org.simantics.utils.ui.BundleUtils;\r
-import org.simantics.utils.ui.ErrorLogger;\r
-import org.simantics.utils.ui.LayoutUtils;\r
-\r
-public class GraphicalDebuggerView extends ViewPart {\r
-\r
- public static final String VIEW_ID = "org.simantics.debug.graphicalDebugger";\r
-\r
-// private final boolean DEFAULT_RECYCLE_VIEW = true;\r
-\r
- private ResourceInput input;\r
-\r
- private Session session;\r
-\r
- private GraphicalDebugger debugger;\r
-\r
-// private Action recycleToggle;\r
- private Action backAction;\r
- private Action forwardAction;\r
- private Action refreshAction;\r
- private Action homeAction;\r
- private Action increaseDepthAction;\r
- private Action decreaseDepthAction;\r
-\r
- @Override\r
- public void createPartControl(Composite parent) {\r
-// System.out.println("koss: " + getViewSite().getSecondaryId());\r
- session = SimanticsUI.getSession();\r
-\r
- // Initialize input\r
- String sid = getViewSite().getSecondaryId();\r
- Resource r = null;\r
- if (sid != null) {\r
- input = ResourceInput.unmarshall(sid);\r
- try {\r
- r = input.toResource(session);\r
- } catch (DatabaseException e) {\r
- ErrorLogger.defaultLogError(e);\r
- }\r
- }\r
-\r
- // Create UI\r
- parent.setLayout(LayoutUtils.createNoBorderGridLayout(1));\r
- debugger = new GraphicalDebugger(parent, SWT.NONE, session, r);\r
- debugger.defaultInitializeUI();\r
-\r
- // Contribute actions\r
- makeActions();\r
- contributeActions(getViewSite().getActionBars());\r
- updateActionStates();\r
- }\r
-\r
- @Override\r
- public void dispose() {\r
- super.dispose();\r
- }\r
-\r
- private void makeActions() {\r
-// recycleToggle = new RecycleToggle();\r
-// recycleToggle.setChecked(DEFAULT_RECYCLE_VIEW);\r
-\r
- backAction = new BackAction();\r
- forwardAction = new ForwardAction();\r
- refreshAction = new RefreshAction();\r
- homeAction = new HomeAction();\r
- increaseDepthAction = new IncreaseDepthAction();\r
- decreaseDepthAction = new DecreaseDepthAction();\r
- }\r
-\r
- private void contributeActions(IActionBars actionBars) {\r
- IToolBarManager toolBar = actionBars.getToolBarManager();\r
- toolBar.add(backAction);\r
- toolBar.add(forwardAction);\r
- toolBar.add(new Separator());\r
- toolBar.add(refreshAction);\r
- toolBar.add(homeAction);\r
- toolBar.add(new Separator());\r
- toolBar.add(decreaseDepthAction);\r
- toolBar.add(increaseDepthAction);\r
-// toolBar.add(recycleToggle);\r
- }\r
-\r
- @Override\r
- public void setFocus() {\r
- if (debugger != null)\r
- debugger.setFocus();\r
- }\r
-\r
- private void refreshBrowser() {\r
- debugger.refreshBrowser();\r
- }\r
-\r
-// class RecycleToggle extends Action {\r
-// public RecycleToggle() {\r
-// super("Open New Views", Action.AS_CHECK_BOX);\r
-// setImageDescriptor(Activator.getImageDescriptor("icons/reload.gif"));\r
-// setToolTipText("Toggles whether or not to open new views when resource links are clicked.");\r
-// }\r
-// }\r
-//\r
- class RefreshAction extends Action {\r
- public RefreshAction() {\r
- super("Refresh", BundleUtils.getImageDescriptorFromPlugin(SimanticsUI.PLUGIN_ID, "icons/refresh.gif"));\r
- }\r
- @Override\r
- public void run() {\r
- refreshBrowser();\r
- }\r
- }\r
-\r
- class BackAction extends Action {\r
- public BackAction() {\r
- super("Back", Action.AS_PUSH_BUTTON);\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
- }\r
- }\r
-\r
- class ForwardAction extends Action {\r
- public ForwardAction() {\r
- super("Forward", Action.AS_PUSH_BUTTON);\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
- }\r
- }\r
-\r
- class HomeAction extends Action {\r
- public HomeAction() {\r
- super("Home", Action.AS_PUSH_BUTTON);\r
- setToolTipText("Navigate to root library");\r
- setImageDescriptor(PlatformUI.getWorkbench().getSharedImages().getImageDescriptor(ISharedImages.IMG_ETOOL_HOME_NAV));\r
- setDisabledImageDescriptor(PlatformUI.getWorkbench().getSharedImages().getImageDescriptor(ISharedImages.IMG_ETOOL_HOME_NAV_DISABLED));\r
- }\r
- @Override\r
- public void run() {\r
- navigateHome();\r
- }\r
- }\r
- \r
- class DecreaseDepthAction extends Action {\r
- public DecreaseDepthAction() {\r
- super("Decrease", Action.AS_PUSH_BUTTON);\r
- setToolTipText("Decrease Depth");\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
- decreaseDepth();\r
- }\r
- }\r
-\r
- class IncreaseDepthAction extends Action {\r
- public IncreaseDepthAction() {\r
- super("Increase", Action.AS_PUSH_BUTTON);\r
- setToolTipText("Increase Depth");\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
- increaseDepth();\r
- }\r
- }\r
-\r
- private void back() {\r
- debugger.back();\r
- }\r
-\r
- private void forward() {\r
- debugger.forward();\r
- }\r
- \r
- private void decreaseDepth() {\r
- debugger.setDepth(debugger.getDepth() - 1);\r
- }\r
-\r
- private void increaseDepth() {\r
- debugger.setDepth(debugger.getDepth() + 1);\r
- }\r
-\r
- private void navigateHome() {\r
- Resource rootLibrary = session.getRootLibrary();\r
- debugger.changeLocation(rootLibrary);\r
- }\r
-\r
- private void updateActionStates() {\r
- backAction.setEnabled(debugger.hasBackHistory());\r
- forwardAction.setEnabled(debugger.hasForwardHistory());\r
- }\r
-\r
-}\r
+/*******************************************************************************
+ * Copyright (c) 2007, 2010 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
+ *******************************************************************************/
+package org.simantics.debug.ui.graph;
+
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.action.IToolBarManager;
+import org.eclipse.jface.action.Separator;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.ui.IActionBars;
+import org.eclipse.ui.ISharedImages;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.part.ViewPart;
+import org.simantics.db.Resource;
+import org.simantics.db.Session;
+import org.simantics.db.exception.DatabaseException;
+import org.simantics.ui.SimanticsUI;
+import org.simantics.ui.workbench.ResourceInput;
+import org.simantics.utils.ui.BundleUtils;
+import org.simantics.utils.ui.ErrorLogger;
+import org.simantics.utils.ui.LayoutUtils;
+
+public class GraphicalDebuggerView extends ViewPart {
+
+ public static final String VIEW_ID = "org.simantics.debug.graphicalDebugger";
+
+// private final boolean DEFAULT_RECYCLE_VIEW = true;
+
+ private ResourceInput input;
+
+ private Session session;
+
+ private GraphicalDebugger debugger;
+
+// private Action recycleToggle;
+ private Action backAction;
+ private Action forwardAction;
+ private Action refreshAction;
+ private Action homeAction;
+ private Action increaseDepthAction;
+ private Action decreaseDepthAction;
+
+ @Override
+ public void createPartControl(Composite parent) {
+// System.out.println("koss: " + getViewSite().getSecondaryId());
+ session = SimanticsUI.getSession();
+
+ // Initialize input
+ String sid = getViewSite().getSecondaryId();
+ Resource r = null;
+ if (sid != null) {
+ input = ResourceInput.unmarshall(sid);
+ try {
+ r = input.toResource(session);
+ } catch (DatabaseException e) {
+ ErrorLogger.defaultLogError(e);
+ }
+ }
+
+ // Create UI
+ parent.setLayout(LayoutUtils.createNoBorderGridLayout(1));
+ debugger = new GraphicalDebugger(parent, SWT.NONE, session, r);
+ debugger.defaultInitializeUI();
+
+ // Contribute actions
+ makeActions();
+ contributeActions(getViewSite().getActionBars());
+ updateActionStates();
+ }
+
+ @Override
+ public void dispose() {
+ super.dispose();
+ }
+
+ private void makeActions() {
+// recycleToggle = new RecycleToggle();
+// recycleToggle.setChecked(DEFAULT_RECYCLE_VIEW);
+
+ backAction = new BackAction();
+ forwardAction = new ForwardAction();
+ refreshAction = new RefreshAction();
+ homeAction = new HomeAction();
+ increaseDepthAction = new IncreaseDepthAction();
+ decreaseDepthAction = new DecreaseDepthAction();
+ }
+
+ private void contributeActions(IActionBars actionBars) {
+ IToolBarManager toolBar = actionBars.getToolBarManager();
+ toolBar.add(backAction);
+ toolBar.add(forwardAction);
+ toolBar.add(new Separator());
+ toolBar.add(refreshAction);
+ toolBar.add(homeAction);
+ toolBar.add(new Separator());
+ toolBar.add(decreaseDepthAction);
+ toolBar.add(increaseDepthAction);
+// toolBar.add(recycleToggle);
+ }
+
+ @Override
+ public void setFocus() {
+ if (debugger != null)
+ debugger.setFocus();
+ }
+
+ private void refreshBrowser() {
+ debugger.refreshBrowser();
+ }
+
+// class RecycleToggle extends Action {
+// public RecycleToggle() {
+// super("Open New Views", Action.AS_CHECK_BOX);
+// setImageDescriptor(Activator.getImageDescriptor("icons/reload.gif"));
+// setToolTipText("Toggles whether or not to open new views when resource links are clicked.");
+// }
+// }
+//
+ class RefreshAction extends Action {
+ public RefreshAction() {
+ super("Refresh", BundleUtils.getImageDescriptorFromPlugin(SimanticsUI.PLUGIN_ID, "icons/refresh.gif"));
+ }
+ @Override
+ public void run() {
+ refreshBrowser();
+ }
+ }
+
+ class BackAction extends Action {
+ public BackAction() {
+ super("Back", Action.AS_PUSH_BUTTON);
+ setImageDescriptor(PlatformUI.getWorkbench().getSharedImages().getImageDescriptor(ISharedImages.IMG_TOOL_BACK));
+ setDisabledImageDescriptor(PlatformUI.getWorkbench().getSharedImages().getImageDescriptor(ISharedImages.IMG_TOOL_BACK_DISABLED));
+ }
+ @Override
+ public void run() {
+ back();
+ }
+ }
+
+ class ForwardAction extends Action {
+ public ForwardAction() {
+ super("Forward", Action.AS_PUSH_BUTTON);
+ setImageDescriptor(PlatformUI.getWorkbench().getSharedImages().getImageDescriptor(ISharedImages.IMG_TOOL_FORWARD));
+ setDisabledImageDescriptor(PlatformUI.getWorkbench().getSharedImages().getImageDescriptor(ISharedImages.IMG_TOOL_FORWARD_DISABLED));
+ }
+ @Override
+ public void run() {
+ forward();
+ }
+ }
+
+ class HomeAction extends Action {
+ public HomeAction() {
+ super("Home", Action.AS_PUSH_BUTTON);
+ setToolTipText("Navigate to root library");
+ setImageDescriptor(PlatformUI.getWorkbench().getSharedImages().getImageDescriptor(ISharedImages.IMG_ETOOL_HOME_NAV));
+ setDisabledImageDescriptor(PlatformUI.getWorkbench().getSharedImages().getImageDescriptor(ISharedImages.IMG_ETOOL_HOME_NAV_DISABLED));
+ }
+ @Override
+ public void run() {
+ navigateHome();
+ }
+ }
+
+ class DecreaseDepthAction extends Action {
+ public DecreaseDepthAction() {
+ super("Decrease", Action.AS_PUSH_BUTTON);
+ setToolTipText("Decrease Depth");
+ setImageDescriptor(PlatformUI.getWorkbench().getSharedImages().getImageDescriptor(ISharedImages.IMG_TOOL_BACK));
+ setDisabledImageDescriptor(PlatformUI.getWorkbench().getSharedImages().getImageDescriptor(ISharedImages.IMG_TOOL_BACK_DISABLED));
+ }
+ @Override
+ public void run() {
+ decreaseDepth();
+ }
+ }
+
+ class IncreaseDepthAction extends Action {
+ public IncreaseDepthAction() {
+ super("Increase", Action.AS_PUSH_BUTTON);
+ setToolTipText("Increase Depth");
+ setImageDescriptor(PlatformUI.getWorkbench().getSharedImages().getImageDescriptor(ISharedImages.IMG_TOOL_FORWARD));
+ setDisabledImageDescriptor(PlatformUI.getWorkbench().getSharedImages().getImageDescriptor(ISharedImages.IMG_TOOL_FORWARD_DISABLED));
+ }
+ @Override
+ public void run() {
+ increaseDepth();
+ }
+ }
+
+ private void back() {
+ debugger.back();
+ }
+
+ private void forward() {
+ debugger.forward();
+ }
+
+ private void decreaseDepth() {
+ debugger.setDepth(debugger.getDepth() - 1);
+ }
+
+ private void increaseDepth() {
+ debugger.setDepth(debugger.getDepth() + 1);
+ }
+
+ private void navigateHome() {
+ Resource rootLibrary = session.getRootLibrary();
+ debugger.changeLocation(rootLibrary);
+ }
+
+ private void updateActionStates() {
+ backAction.setEnabled(debugger.hasBackHistory());
+ forwardAction.setEnabled(debugger.hasForwardHistory());
+ }
+
+}