X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;ds=sidebyside;f=bundles%2Forg.simantics.debug.ui%2Fsrc%2Forg%2Fsimantics%2Fdebug%2Fui%2Fgraph%2FGraphicalDebuggerView.java;h=a47f48e23eaad757a509ad3295ebe1e326f04878;hb=ad0e5bf4b34705988e23c9ee3f8e4fcbb760c701;hp=d8c2d36788150a59c09fcb325c6a0311c8043bdd;hpb=969bd23cab98a79ca9101af33334000879fb60c5;p=simantics%2Fplatform.git diff --git a/bundles/org.simantics.debug.ui/src/org/simantics/debug/ui/graph/GraphicalDebuggerView.java b/bundles/org.simantics.debug.ui/src/org/simantics/debug/ui/graph/GraphicalDebuggerView.java index d8c2d3678..a47f48e23 100644 --- a/bundles/org.simantics.debug.ui/src/org/simantics/debug/ui/graph/GraphicalDebuggerView.java +++ b/bundles/org.simantics.debug.ui/src/org/simantics/debug/ui/graph/GraphicalDebuggerView.java @@ -1,227 +1,228 @@ -/******************************************************************************* - * 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()); - } - -} +/******************************************************************************* + * 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.Simantics; +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"; //$NON-NLS-1$ + +// 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 = Simantics.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(Messages.GraphicalDebuggerView_Refresh, BundleUtils.getImageDescriptorFromPlugin(SimanticsUI.PLUGIN_ID, "icons/refresh.gif")); //$NON-NLS-2$ + } + @Override + public void run() { + refreshBrowser(); + } + } + + class BackAction extends Action { + public BackAction() { + super(Messages.GraphicalDebuggerView_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(Messages.GraphicalDebuggerView_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(Messages.GraphicalDebuggerView_Home, Action.AS_PUSH_BUTTON); + setToolTipText(Messages.GraphicalDebuggerView_HomeTT); + 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(Messages.GraphicalDebuggerView_Decrease, Action.AS_PUSH_BUTTON); + setToolTipText(Messages.GraphicalDebuggerView_DecreaseTT); + 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(Messages.GraphicalDebuggerView_Increase, Action.AS_PUSH_BUTTON); + setToolTipText(Messages.GraphicalDebuggerView_IncreaseTT); + 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()); + } + +}