X-Git-Url: https://gerrit.simantics.org/r/gitweb?p=simantics%2Fplatform.git;a=blobdiff_plain;f=bundles%2Forg.simantics.debug.ui%2Fsrc%2Forg%2Fsimantics%2Fdebug%2Fui%2FVariableDebuggerView.java;h=56736670115fa7956b78e69b01a02dc83e8240f8;hp=7fc66f7f630913d7b74647235b85a910fd8d2553;hb=refs%2Fchanges%2F38%2F238%2F2;hpb=24e2b34260f219f0d1644ca7a138894980e25b14 diff --git a/bundles/org.simantics.debug.ui/src/org/simantics/debug/ui/VariableDebuggerView.java b/bundles/org.simantics.debug.ui/src/org/simantics/debug/ui/VariableDebuggerView.java index 7fc66f7f6..567366701 100644 --- a/bundles/org.simantics.debug.ui/src/org/simantics/debug/ui/VariableDebuggerView.java +++ b/bundles/org.simantics.debug.ui/src/org/simantics/debug/ui/VariableDebuggerView.java @@ -1,184 +1,184 @@ -/******************************************************************************* - * 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; - -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.common.uri.ResourceToPossibleURI; -import org.simantics.db.common.uri.ResourceToURI; -import org.simantics.db.common.utils.Logger; -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 VariableDebuggerView extends ViewPart { - - public static final String VIEW_ID = "org.simantics.debug.variableDebugger"; - - private ResourceInput input; - - private Session session; - - private VariableDebugger debugger; - - private Action backAction; - private Action forwardAction; - private Action refreshAction; - private Action homeAction; - - @Override - public void createPartControl(Composite parent) { - - 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)); - String initialURI = null; - try { - if(r != null) - initialURI = session.sync(new ResourceToPossibleURI(r)); - } catch (Throwable e) { - } - debugger = new VariableDebugger(parent, SWT.NONE, session, initialURI); - debugger.defaultInitializeUI(); - - // Contribute actions - makeActions(); - contributeActions(getViewSite().getActionBars()); - updateActionStates(); - } - - @Override - public void dispose() { - super.dispose(); - } - - private void makeActions() { - backAction = new BackAction(); - forwardAction = new ForwardAction(); - refreshAction = new RefreshAction(); - homeAction = new HomeAction(); - } - - 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); - } - - @Override - public void setFocus() { - if (debugger != null) - debugger.setFocus(); - } - - private void refreshBrowser() { - debugger.refreshBrowser(); - } -// - 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(); - } - } - - private void back() { - debugger.back(); - } - - private void forward() { - debugger.forward(); - } - - private void navigateHome() { - Resource rootLibrary = session.getRootLibrary(); - try { - debugger.changeLocation(session.sync(new ResourceToURI(rootLibrary))); - } catch (DatabaseException e) { - Logger.defaultLogError(e); - } - } - - 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; + +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.common.uri.ResourceToPossibleURI; +import org.simantics.db.common.uri.ResourceToURI; +import org.simantics.db.common.utils.Logger; +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 VariableDebuggerView extends ViewPart { + + public static final String VIEW_ID = "org.simantics.debug.variableDebugger"; + + private ResourceInput input; + + private Session session; + + private VariableDebugger debugger; + + private Action backAction; + private Action forwardAction; + private Action refreshAction; + private Action homeAction; + + @Override + public void createPartControl(Composite parent) { + + 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)); + String initialURI = null; + try { + if(r != null) + initialURI = session.sync(new ResourceToPossibleURI(r)); + } catch (Throwable e) { + } + debugger = new VariableDebugger(parent, SWT.NONE, session, initialURI); + debugger.defaultInitializeUI(); + + // Contribute actions + makeActions(); + contributeActions(getViewSite().getActionBars()); + updateActionStates(); + } + + @Override + public void dispose() { + super.dispose(); + } + + private void makeActions() { + backAction = new BackAction(); + forwardAction = new ForwardAction(); + refreshAction = new RefreshAction(); + homeAction = new HomeAction(); + } + + 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); + } + + @Override + public void setFocus() { + if (debugger != null) + debugger.setFocus(); + } + + private void refreshBrowser() { + debugger.refreshBrowser(); + } +// + 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(); + } + } + + private void back() { + debugger.back(); + } + + private void forward() { + debugger.forward(); + } + + private void navigateHome() { + Resource rootLibrary = session.getRootLibrary(); + try { + debugger.changeLocation(session.sync(new ResourceToURI(rootLibrary))); + } catch (DatabaseException e) { + Logger.defaultLogError(e); + } + } + + private void updateActionStates() { + backAction.setEnabled(debugger.hasBackHistory()); + forwardAction.setEnabled(debugger.hasForwardHistory()); + } + +}