diff options
| author | Robert Gemmell <robbie@apache.org> | 2009-07-27 23:54:54 +0000 |
|---|---|---|
| committer | Robert Gemmell <robbie@apache.org> | 2009-07-27 23:54:54 +0000 |
| commit | 6bee7da9ede9546ed2bf0eb5dea031f36b56c5ba (patch) | |
| tree | b63d9b47c72f2ab5a0c03461c4917cf76e743e6d /java/management/eclipse-plugin/src | |
| parent | 77e93f5453f3b9878c3e27b0e99a365356c5264c (diff) | |
| download | qpid-python-6bee7da9ede9546ed2bf0eb5dea031f36b56c5ba.tar.gz | |
QPID-1977: add back buton to the mbean view toolbar to navigate back after opening mbeans in the mbean view (eg opening a queue directly from the Queues selection area, or from an Exchange mbean)
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk/qpid@798337 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'java/management/eclipse-plugin/src')
2 files changed, 147 insertions, 3 deletions
diff --git a/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/actions/BackAction.java b/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/actions/BackAction.java new file mode 100644 index 0000000000..2998c5db53 --- /dev/null +++ b/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/actions/BackAction.java @@ -0,0 +1,59 @@ +/* + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ +package org.apache.qpid.management.ui.actions; + +import org.apache.qpid.management.ui.jmx.MBeanUtility; +import org.apache.qpid.management.ui.views.MBeanView; +import org.eclipse.jface.action.Action; +import org.eclipse.ui.PlatformUI; +import org.eclipse.ui.actions.ActionFactory.IWorkbenchAction; + + +public class BackAction extends Action implements IWorkbenchAction +{ + private static final String ID = "org.apache.qpid.management.ui.actions.back"; + + public BackAction() + { + setText("Back"); + setImageDescriptor(org.apache.qpid.management.ui.Activator.getImageDescriptor("/icons/back.gif")); + setId(ID); + } + + public void run() + { + MBeanView mbeanview = (MBeanView)PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().findView(MBeanView.ID); + try + { + mbeanview.back(); + } + catch (Exception ex) + { + MBeanUtility.handleException(ex); + } + + } + + public void dispose() + { + + } +} diff --git a/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/MBeanView.java b/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/MBeanView.java index 35d1b4a34f..ffb601fdca 100644 --- a/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/MBeanView.java +++ b/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/MBeanView.java @@ -20,6 +20,8 @@ */ package org.apache.qpid.management.ui.views; +import java.util.LinkedList; + import javax.management.MBeanServerConnection; import static org.apache.qpid.management.ui.Constants.*; @@ -29,6 +31,7 @@ import org.apache.qpid.management.ui.ApplicationRegistry; import org.apache.qpid.management.ui.ManagedBean; import org.apache.qpid.management.ui.ManagedServer; import org.apache.qpid.management.ui.ServerRegistry; +import org.apache.qpid.management.ui.actions.BackAction; import org.apache.qpid.management.ui.jmx.JMXManagedObject; import org.apache.qpid.management.ui.jmx.JMXServerRegistry; import org.apache.qpid.management.ui.jmx.MBeanUtility; @@ -71,6 +74,10 @@ public class MBeanView extends ViewPart private TabFolder _typeTabFolder = null; private TabFolder _notificationTabFolder = null; + + private LinkedList<Object> _backHistory; + private BackAction _backAction; + /* * Listener for the selection events in the navigation view */ @@ -90,6 +97,10 @@ public class MBeanView extends ViewPart _mbean = null; clearView(); + //clear the back history, it is only for use when opening subsequent mbeans not in the nav tree + _backHistory.clear(); + _backAction.setEnabled(false); + // If a selected node(mbean) gets unregistered from mbean server, mbeanview should // make the tabfolber for that mbean invisible if (_selectedNode == null) @@ -111,22 +122,48 @@ public class MBeanView extends ViewPart public void openMBean(ManagedBean mbean) { + openMBean(mbean, false); + } + + private void openMBean(ManagedBean mbean, boolean undoing) + { if(mbean == null) { return; } + //if an mbean is about to be opened (but not returning to using back) from the mbean view, + //then record the current viewed area/object as a means of back history + if(!undoing) + { + if(_backHistory.isEmpty()) + { + //ensure the button is enabled if this is to be the first history item + _backAction.setEnabled(true); + } + + if(_mbean == null) + { + //queue etc selection area is open, record the tree object + _backHistory.addLast(_selectedNode); + } + else + { + _backHistory.addLast(_mbean); + } + } + _mbean = mbean; try { clearView(); + + setFormTitle(); showMBean(mbean); _form.layout(true); _form.getBody().layout(true, true); - - setFormTitle(); } catch(Exception ex) { @@ -311,6 +348,11 @@ public class MBeanView extends ViewPart createNotificationsTabFolder(); ViewUtility.setMBeanView(this); + + _backAction = new BackAction(); + getViewSite().getActionBars().getToolBarManager().add(_backAction); + _backAction.setEnabled(false); + _backHistory = new LinkedList<Object>(); } private void refreshTab(TabItem tab) @@ -433,10 +475,12 @@ public class MBeanView extends ViewPart public void mbeanUnregistered(ManagedBean mbean) { - //if the mbean is actually open, clear the view + //if the mbean is actually open, clear the view and empty the Back history if(mbean == _mbean) { clearView(); + _backHistory.clear(); + _backAction.setEnabled(false); ViewUtility.popupInfoMessage("MBean Unregistered", "The open MBean was unregistered from the server."); } @@ -502,4 +546,45 @@ public class MBeanView extends ViewPart IActionBars bars = getViewSite().getActionBars(); bars.getStatusLineManager().setMessage(message); } + + public void back() throws Exception + { + if(_backHistory.isEmpty()) + { + return; + } + + Object previous = _backHistory.removeLast(); + if(_backHistory.isEmpty()) + { + //if this is the last history item, disable the action button + _backAction.setEnabled(false); + } + + if(previous instanceof ManagedBean) + { + openMBean((ManagedBean)previous, true); + } + else if (previous instanceof TreeObject) + { + _mbean = null; + clearView(); + setFormTitle(); + + TreeObject node = (TreeObject) previous; + String mbeanType = node.getType(); + + if (NODE_TYPE_TYPEINSTANCE.equals(mbeanType)) + { + generateTypeTabFolder(); + } + else if (NODE_TYPE_MBEANTYPE.equals(mbeanType)) + { + showTypeTabFolder(node.getName()); + } + } + + _form.layout(true); + _form.getBody().layout(true, true); + } } |
