diff options
Diffstat (limited to 'java/management/eclipse-plugin/src')
12 files changed, 143 insertions, 172 deletions
diff --git a/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/Constants.java b/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/Constants.java index efd4a7e9a6..127ae22a10 100644 --- a/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/Constants.java +++ b/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/Constants.java @@ -20,8 +20,6 @@ */ package org.apache.qpid.management.ui; -import static org.apache.qpid.management.ui.Constants.CONNECTION_PROTOCOLS; - /** * Contains constants for the application * @author Bhupendra Bhardwaj @@ -86,6 +84,8 @@ public class Constants public final static String ACTION_ADDSERVER = "New Connection"; public final static String ACTION_RECONNECT = "Reconnect"; + public final static String ACTION_CLOSE = "Close Connection"; + public final static String ACTION_EDITATTRIBUTE = "Edit Attribute"; public final static String ACTION_LOGIN = "Login"; public final static String QUEUE_SORT_BY_NAME = "Queue Name"; @@ -125,7 +125,7 @@ public class Constants public final static int OPERATION_IMPACT_ACTIONINFO = 2; public final static int OPERATION_IMPACT_UNKNOWN = 3; - public final static String ERROR_SERVER_CONNECTION = "Server could not be connected"; + public final static String ERROR_SERVER_CONNECTION = "Server Connection Failed"; public final static String INFO_PROTOCOL = "Please select the protocol"; public final static String INFO_HOST_ADDRESS = "Please enter the host address"; public final static String INFO_HOST_PORT = "Please enter the port number"; diff --git a/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/actions/AbstractAction.java b/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/actions/AbstractAction.java new file mode 100644 index 0000000000..0101905bbf --- /dev/null +++ b/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/actions/AbstractAction.java @@ -0,0 +1,58 @@ +package org.apache.qpid.management.ui.actions; + +import static org.apache.qpid.management.ui.Constants.ERROR_SERVER_CONNECTION; + +import org.apache.qpid.management.ui.ApplicationRegistry; +import org.apache.qpid.management.ui.ApplicationWorkbenchAdvisor; +import org.apache.qpid.management.ui.Constants; +import org.apache.qpid.management.ui.jmx.MBeanUtility; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.Status; +import org.eclipse.jface.dialogs.ErrorDialog; +import org.eclipse.ui.IWorkbenchWindow; +import org.eclipse.ui.IWorkbenchWindowActionDelegate; + +public class AbstractAction +{ + protected IWorkbenchWindow _window; + + /** + * We will cache window object in order to + * be able to provide parent shell for the message dialog. + * @see IWorkbenchWindowActionDelegate#init + */ + public void init(IWorkbenchWindow window) + { + this._window = window; + if (_window.getShell() != null) + { + _window.getShell().setImage(ApplicationRegistry.getImage(Constants.CONSOLE_IMAGE)); + } + } + + protected void handleException(Exception ex, String title, String msg) + { + MBeanUtility.printStackTrace(ex); + if (msg == null) + { + msg = ex.getMessage(); + } + if ((msg == null) && (ex.getCause() != null)) + { + msg = ex.getCause().getMessage(); + } + + if (msg == null) + { + msg = ERROR_SERVER_CONNECTION; + } + + if (title == null) + { + title = ERROR_SERVER_CONNECTION; + } + IStatus status = new Status(IStatus.ERROR, ApplicationWorkbenchAdvisor.PERSPECTIVE_ID, + IStatus.OK, msg, null); + ErrorDialog.openError(_window.getShell(), "Error", title, status); + } +} diff --git a/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/actions/AddServer.java b/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/actions/AddServer.java index 0e12c59de4..ff0f42b49e 100644 --- a/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/actions/AddServer.java +++ b/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/actions/AddServer.java @@ -23,15 +23,11 @@ package org.apache.qpid.management.ui.actions; import static org.apache.qpid.management.ui.Constants.*; import org.apache.qpid.management.ui.ApplicationRegistry; -import org.apache.qpid.management.ui.ApplicationWorkbenchAdvisor; import org.apache.qpid.management.ui.exceptions.InfoRequiredException; import org.apache.qpid.management.ui.views.NavigationView; import org.apache.qpid.management.ui.views.NumberVerifyListener; import org.apache.qpid.management.ui.views.ViewUtility; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Status; import org.eclipse.jface.action.IAction; -import org.eclipse.jface.dialogs.ErrorDialog; import org.eclipse.jface.viewers.ISelection; import org.eclipse.swt.SWT; import org.eclipse.swt.events.SelectionAdapter; @@ -45,12 +41,10 @@ import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.Shell; import org.eclipse.swt.widgets.Text; -import org.eclipse.ui.IWorkbenchWindow; import org.eclipse.ui.IWorkbenchWindowActionDelegate; -public class AddServer/* extends Action*/ implements IWorkbenchWindowActionDelegate +public class AddServer extends AbstractAction implements IWorkbenchWindowActionDelegate { - private IWorkbenchWindow _window; private static final String[] _domains ={"org.apache.qpid"}; private NavigationView _navigationView; @@ -96,13 +90,11 @@ public class AddServer/* extends Action*/ implements IWorkbenchWindowActionDeleg } catch(InfoRequiredException ex) { - ViewUtility.popupInfoMessage("New connection", ex.getMessage()); + ViewUtility.popupInfoMessage(ACTION_ADDSERVER, ex.getMessage()); } - catch(Exception ex) + catch (Exception ex) { - IStatus status = new Status(IStatus.ERROR, ApplicationWorkbenchAdvisor.PERSPECTIVE_ID, - IStatus.OK, ex.getMessage(), ex.getCause()); - ErrorDialog.openError(_window.getShell(), "Error", ERROR_SERVER_CONNECTION, status); + handleException(ex, null, null); } } } @@ -133,15 +125,7 @@ public class AddServer/* extends Action*/ implements IWorkbenchWindowActionDeleg * @see IWorkbenchWindowActionDelegate#dispose */ public void dispose() { - } - - /** - * We will cache window object in order to - * be able to provide parent shell for the message dialog. - * @see IWorkbenchWindowActionDelegate#init - */ - public void init(IWorkbenchWindow window) { - this._window = window; + } private NavigationView getNavigationView() diff --git a/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/actions/CloseConnection.java b/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/actions/CloseConnection.java index 3f44274a92..3907424748 100644 --- a/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/actions/CloseConnection.java +++ b/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/actions/CloseConnection.java @@ -20,22 +20,16 @@ */ package org.apache.qpid.management.ui.actions; -import org.apache.qpid.management.ui.ApplicationWorkbenchAdvisor; +import static org.apache.qpid.management.ui.Constants.ACTION_CLOSE; import org.apache.qpid.management.ui.exceptions.InfoRequiredException; import org.apache.qpid.management.ui.views.NavigationView; import org.apache.qpid.management.ui.views.ViewUtility; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Status; import org.eclipse.jface.action.IAction; -import org.eclipse.jface.dialogs.ErrorDialog; import org.eclipse.jface.viewers.ISelection; -import org.eclipse.ui.IWorkbenchWindow; import org.eclipse.ui.IWorkbenchWindowActionDelegate; -public class CloseConnection implements IWorkbenchWindowActionDelegate -{ - private IWorkbenchWindow _window; - +public class CloseConnection extends AbstractAction implements IWorkbenchWindowActionDelegate +{ public CloseConnection() { @@ -52,13 +46,11 @@ public class CloseConnection implements IWorkbenchWindowActionDelegate } catch(InfoRequiredException ex) { - ViewUtility.popupInfoMessage("Close connection", ex.getMessage()); + ViewUtility.popupInfoMessage(ACTION_CLOSE, ex.getMessage()); } catch(Exception ex) { - IStatus status = new Status(IStatus.ERROR, ApplicationWorkbenchAdvisor.PERSPECTIVE_ID, - IStatus.OK, ex.getMessage(), ex.getCause()); - ErrorDialog.openError(_window.getShell(), "Error", "Server could not be removed", status); + handleException(ex, null, null); } } } @@ -79,15 +71,6 @@ public class CloseConnection implements IWorkbenchWindowActionDelegate * @see IWorkbenchWindowActionDelegate#dispose */ public void dispose() { - } - - /** - * We will cache window object in order to - * be able to provide parent shell for the message dialog. - * @see IWorkbenchWindowActionDelegate#init - */ - public void init(IWorkbenchWindow window) { - this._window = window; - } - + + } } diff --git a/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/actions/EditAttribute.java b/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/actions/EditAttribute.java index 0030330b06..69e74898ab 100644 --- a/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/actions/EditAttribute.java +++ b/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/actions/EditAttribute.java @@ -20,22 +20,16 @@ */ package org.apache.qpid.management.ui.actions; -import org.apache.qpid.management.ui.ApplicationWorkbenchAdvisor; +import static org.apache.qpid.management.ui.Constants.ACTION_EDITATTRIBUTE; import org.apache.qpid.management.ui.exceptions.InfoRequiredException; import org.apache.qpid.management.ui.views.MBeanView; import org.apache.qpid.management.ui.views.ViewUtility; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Status; import org.eclipse.jface.action.IAction; -import org.eclipse.jface.dialogs.ErrorDialog; import org.eclipse.jface.viewers.ISelection; -import org.eclipse.ui.IWorkbenchWindow; import org.eclipse.ui.IWorkbenchWindowActionDelegate; -public class EditAttribute implements IWorkbenchWindowActionDelegate -{ - private IWorkbenchWindow _window; - +public class EditAttribute extends AbstractAction implements IWorkbenchWindowActionDelegate +{ public void run(IAction action) { if(_window != null) @@ -47,13 +41,11 @@ public class EditAttribute implements IWorkbenchWindowActionDelegate } catch(InfoRequiredException ex) { - ViewUtility.popupInfoMessage("Edit Attribute", ex.getMessage()); + ViewUtility.popupInfoMessage(ACTION_EDITATTRIBUTE, ex.getMessage()); } catch(Exception ex) { - IStatus status = new Status(IStatus.ERROR, ApplicationWorkbenchAdvisor.PERSPECTIVE_ID, - IStatus.OK, ex.getMessage(), ex.getCause()); - ErrorDialog.openError(_window.getShell(), "Error", "Attribute could not be edited", status); + handleException(ex, "Attribute could not be edited", null); } } } @@ -74,14 +66,6 @@ public class EditAttribute implements IWorkbenchWindowActionDelegate * @see IWorkbenchWindowActionDelegate#dispose */ public void dispose() { - } - - /** - * We will cache window object in order to - * be able to provide parent shell for the message dialog. - * @see IWorkbenchWindowActionDelegate#init - */ - public void init(IWorkbenchWindow window) { - this._window = window; + } } diff --git a/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/actions/ReconnectServer.java b/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/actions/ReconnectServer.java index 9aa265ab3c..3c0dea586e 100644 --- a/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/actions/ReconnectServer.java +++ b/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/actions/ReconnectServer.java @@ -20,19 +20,20 @@ */ package org.apache.qpid.management.ui.actions; -import static org.apache.qpid.management.ui.Constants.*; +import static org.apache.qpid.management.ui.Constants.ACTION_LOGIN; +import static org.apache.qpid.management.ui.Constants.CONSOLE_IMAGE; +import static org.apache.qpid.management.ui.Constants.INFO_PASSWORD; +import static org.apache.qpid.management.ui.Constants.INFO_USERNAME; +import static org.apache.qpid.management.ui.Constants.PASSWORD; +import static org.apache.qpid.management.ui.Constants.USERNAME; import org.apache.qpid.management.ui.ApplicationRegistry; -import org.apache.qpid.management.ui.ApplicationWorkbenchAdvisor; import org.apache.qpid.management.ui.Constants; import org.apache.qpid.management.ui.exceptions.InfoRequiredException; import org.apache.qpid.management.ui.views.NavigationView; import org.apache.qpid.management.ui.views.TreeObject; import org.apache.qpid.management.ui.views.ViewUtility; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Status; import org.eclipse.jface.action.IAction; -import org.eclipse.jface.dialogs.ErrorDialog; import org.eclipse.jface.viewers.ISelection; import org.eclipse.swt.SWT; import org.eclipse.swt.events.SelectionAdapter; @@ -40,18 +41,15 @@ import org.eclipse.swt.events.SelectionEvent; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Button; -import org.eclipse.swt.widgets.Combo; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.Shell; import org.eclipse.swt.widgets.Text; -import org.eclipse.ui.IWorkbenchWindow; import org.eclipse.ui.IWorkbenchWindowActionDelegate; -public class ReconnectServer implements IWorkbenchWindowActionDelegate +public class ReconnectServer extends AbstractAction implements IWorkbenchWindowActionDelegate { - private IWorkbenchWindow _window; private NavigationView _navigationView; private String _title; private String _serverName; @@ -80,16 +78,6 @@ public class ReconnectServer implements IWorkbenchWindowActionDelegate { } - - /** - * We will cache window object in order to - * be able to provide parent shell for the message dialog. - * @see IWorkbenchWindowActionDelegate#init - */ - public void init(IWorkbenchWindow window) - { - this._window = window; - } private NavigationView getNavigationView() { @@ -126,11 +114,9 @@ public class ReconnectServer implements IWorkbenchWindowActionDelegate { ViewUtility.popupInfoMessage("Reconnect Qpid server", ex.getMessage()); } - catch(Exception ex) + catch (Exception ex) { - IStatus status = new Status(IStatus.ERROR, ApplicationWorkbenchAdvisor.PERSPECTIVE_ID, - IStatus.OK, ex.getMessage(), ex.getCause()); - ErrorDialog.openError(_window.getShell(), "Error", ERROR_SERVER_CONNECTION, status); + handleException(ex, null, null); } } } diff --git a/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/actions/Refresh.java b/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/actions/Refresh.java index a2335c5841..b76c36c649 100644 --- a/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/actions/Refresh.java +++ b/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/actions/Refresh.java @@ -25,17 +25,14 @@ import org.apache.qpid.management.ui.views.MBeanView; import org.apache.qpid.management.ui.views.NavigationView; import org.eclipse.jface.action.IAction; import org.eclipse.jface.viewers.ISelection; -import org.eclipse.ui.IWorkbenchWindow; import org.eclipse.ui.IWorkbenchWindowActionDelegate; /** * This action refreshes both the views -Navigation and MBeanView * @author Bhupendra Bhardwaj */ -public class Refresh implements IWorkbenchWindowActionDelegate +public class Refresh extends AbstractAction implements IWorkbenchWindowActionDelegate { - private IWorkbenchWindow _window; - /** * Selection in the workbench has been changed. We * can change the state of the 'real' action here @@ -57,16 +54,6 @@ public class Refresh implements IWorkbenchWindowActionDelegate { } - - /** - * We will cache window object in order to - * be able to provide parent shell for the message dialog. - * @see IWorkbenchWindowActionDelegate#init - */ - public void init(IWorkbenchWindow window) - { - this._window = window; - } public void run(IAction action) { diff --git a/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/actions/RemoveServer.java b/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/actions/RemoveServer.java index 189f0f811b..f8878c44a1 100644 --- a/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/actions/RemoveServer.java +++ b/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/actions/RemoveServer.java @@ -20,22 +20,15 @@ */ package org.apache.qpid.management.ui.actions; -import org.apache.qpid.management.ui.ApplicationWorkbenchAdvisor; import org.apache.qpid.management.ui.exceptions.InfoRequiredException; import org.apache.qpid.management.ui.views.NavigationView; import org.apache.qpid.management.ui.views.ViewUtility; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Status; import org.eclipse.jface.action.IAction; -import org.eclipse.jface.dialogs.ErrorDialog; import org.eclipse.jface.viewers.ISelection; -import org.eclipse.ui.IWorkbenchWindow; import org.eclipse.ui.IWorkbenchWindowActionDelegate; -public class RemoveServer implements IWorkbenchWindowActionDelegate -{ - private IWorkbenchWindow _window; - +public class RemoveServer extends AbstractAction implements IWorkbenchWindowActionDelegate +{ /** * Selection in the workbench has been changed. We * can change the state of the 'real' action here @@ -57,16 +50,6 @@ public class RemoveServer implements IWorkbenchWindowActionDelegate { } - - /** - * We will cache window object in order to - * be able to provide parent shell for the message dialog. - * @see IWorkbenchWindowActionDelegate#init - */ - public void init(IWorkbenchWindow window) - { - this._window = window; - } public void run(IAction action) { @@ -83,9 +66,7 @@ public class RemoveServer implements IWorkbenchWindowActionDelegate } catch(Exception ex) { - IStatus status = new Status(IStatus.ERROR, ApplicationWorkbenchAdvisor.PERSPECTIVE_ID, - IStatus.OK, ex.getMessage(), ex.getCause()); - ErrorDialog.openError(_window.getShell(), "Error", "Server could not be removed", status); + handleException(ex, "Server could not be removed", null); } } } diff --git a/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/jmx/MBeanUtility.java b/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/jmx/MBeanUtility.java index 41db11c10e..2d1883533b 100644 --- a/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/jmx/MBeanUtility.java +++ b/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/jmx/MBeanUtility.java @@ -20,7 +20,6 @@ */ package org.apache.qpid.management.ui.jmx; -import java.io.IOException; import java.math.BigInteger; import java.util.ArrayList; import java.util.Arrays; @@ -149,11 +148,6 @@ public class MBeanUtility ViewUtility.popupErrorMessage("Error", "Managed Object is null \n" + ex.toString()); printStackTrace(ex); } - else if (ex instanceof IOException) - { - ViewUtility.popupErrorMessage(mbean.getInstanceName(), "IO Error occured \n" + ex.toString()); - printStackTrace(ex); - } else if (ex instanceof ReflectionException) { ViewUtility.popupErrorMessage(mbean.getInstanceName(), "Server has thrown error \n" + ex.toString()); @@ -462,7 +456,7 @@ public class MBeanUtility } } - private static void printStackTrace(Throwable ex) + public static void printStackTrace(Throwable ex) { if (ApplicationRegistry.debug) { diff --git a/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/AttributesTabControl.java b/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/AttributesTabControl.java index a7e8bbfc4c..1ffe34d9c5 100644 --- a/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/AttributesTabControl.java +++ b/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/AttributesTabControl.java @@ -21,6 +21,7 @@ package org.apache.qpid.management.ui.views; import static org.apache.qpid.management.ui.Constants.*; + import org.apache.qpid.management.ui.ApplicationRegistry; import org.apache.qpid.management.ui.ManagedBean; import org.apache.qpid.management.ui.jmx.JMXServerRegistry; @@ -51,8 +52,6 @@ import org.eclipse.swt.events.PaintEvent; import org.eclipse.swt.events.PaintListener; import org.eclipse.swt.events.SelectionAdapter; import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.events.VerifyEvent; -import org.eclipse.swt.events.VerifyListener; import org.eclipse.swt.graphics.Color; import org.eclipse.swt.graphics.Font; import org.eclipse.swt.graphics.Image; diff --git a/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/MBeanTypeTabControl.java b/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/MBeanTypeTabControl.java index a8a96e0b5a..31b6cc6221 100644 --- a/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/MBeanTypeTabControl.java +++ b/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/MBeanTypeTabControl.java @@ -1,9 +1,13 @@ package org.apache.qpid.management.ui.views; +import static org.apache.qpid.management.ui.Constants.BUTTON_REFRESH; +import static org.apache.qpid.management.ui.Constants.FONT_BOLD; +import static org.apache.qpid.management.ui.Constants.FONT_ITALIC; +import static org.apache.qpid.management.ui.Constants.FONT_NORMAL; + import java.util.Collections; import java.util.HashMap; -import static org.apache.qpid.management.ui.Constants.*; import org.apache.qpid.management.ui.ApplicationRegistry; import org.apache.qpid.management.ui.ManagedBean; import org.apache.qpid.management.ui.jmx.MBeanUtility; diff --git a/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/NavigationView.java b/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/NavigationView.java index 68f95e01f0..e5f99c2f7b 100644 --- a/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/NavigationView.java +++ b/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/NavigationView.java @@ -20,6 +20,8 @@ */ package org.apache.qpid.management.ui.views; +import static org.apache.qpid.management.ui.Constants.*; + import java.io.File; import java.io.IOException; import java.util.ArrayList; @@ -27,14 +29,12 @@ import java.util.HashMap; import java.util.List; import org.apache.qpid.management.ui.ApplicationRegistry; -import static org.apache.qpid.management.ui.Constants.*; 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.exceptions.InfoRequiredException; import org.apache.qpid.management.ui.jmx.JMXServerRegistry; import org.apache.qpid.management.ui.jmx.MBeanUtility; - import org.eclipse.jface.preference.PreferenceStore; import org.eclipse.jface.viewers.DoubleClickEvent; import org.eclipse.jface.viewers.IDoubleClickListener; @@ -48,7 +48,6 @@ import org.eclipse.jface.viewers.TreeExpansionEvent; import org.eclipse.jface.viewers.TreeViewer; import org.eclipse.jface.viewers.Viewer; import org.eclipse.jface.viewers.ViewerSorter; - import org.eclipse.swt.SWT; import org.eclipse.swt.graphics.Font; import org.eclipse.swt.graphics.Image; @@ -63,7 +62,6 @@ import org.eclipse.swt.widgets.MenuItem; import org.eclipse.swt.widgets.Shell; import org.eclipse.swt.widgets.Tree; import org.eclipse.swt.widgets.TreeItem; - import org.eclipse.ui.part.ViewPart; /** @@ -216,10 +214,9 @@ public class NavigationView extends ViewPart ServerRegistry serverRegistry = new JMXServerRegistry(server); ApplicationRegistry.addServer(server, serverRegistry); } - catch (Exception ex) + catch (IOException ex) { - ex.printStackTrace(); - throw new Exception("Error in connecting to Qpid broker at " + server.getUrl(), ex); + throw (Exception)ex.getCause(); } } @@ -274,7 +271,15 @@ public class NavigationView extends ViewPart _managedServerMap.put(managedServer, serverNode); // populate the server tree - populateServer(serverNode); + try + { + populateServer(serverNode); + } + catch (SecurityException ex) + { + disconnect(managedServer); + throw ex; + } // Add the Queue/Exchanges/Connections from config file into the navigation tree addConfiguredItems(managedServer); @@ -413,38 +418,30 @@ public class NavigationView extends ViewPart * the given server node. * @param serverNode */ - private void populateServer(TreeObject serverNode) + private void populateServer(TreeObject serverNode) throws Exception { ManagedServer server = (ManagedServer) serverNode.getManagedObject(); String domain = server.getDomain(); - try + if (!domain.equals(ALL)) + { + TreeObject domainNode = new TreeObject(domain, NODE_TYPE_DOMAIN); + domainNode.setParent(serverNode); + + populateDomain(domainNode); + } + else { - if (!domain.equals(ALL)) + List<TreeObject> domainList = new ArrayList<TreeObject>(); + List<String> domains = MBeanUtility.getAllDomains(server); + + for (String domainName : domains) { - TreeObject domainNode = new TreeObject(domain, NODE_TYPE_DOMAIN); + TreeObject domainNode = new TreeObject(domainName, NODE_TYPE_DOMAIN); domainNode.setParent(serverNode); + domainList.add(domainNode); populateDomain(domainNode); } - else - { - List<TreeObject> domainList = new ArrayList<TreeObject>(); - List<String> domains = MBeanUtility.getAllDomains(server); - ; - for (String domainName : domains) - { - TreeObject domainNode = new TreeObject(domainName, NODE_TYPE_DOMAIN); - domainNode.setParent(serverNode); - - domainList.add(domainNode); - populateDomain(domainNode); - } - } - } - catch (Exception ex) - { - System.out.println("\nError in connecting to Qpid broker "); - ex.printStackTrace(); } } @@ -726,6 +723,11 @@ public class NavigationView extends ViewPart { TreeObject selectedNode = getSelectedServerNode(); ManagedServer managedServer = (ManagedServer) selectedNode.getManagedObject(); + disconnect(managedServer); + } + + private void disconnect(ManagedServer managedServer) throws Exception + { if (!_managedServerMap.containsKey(managedServer)) { return; @@ -763,8 +765,17 @@ public class NavigationView extends ViewPart // put the server in the managed server map _managedServerMap.put(managedServer, selectedNode); - // populate the server tree now - populateServer(selectedNode); + try + { + // populate the server tree now + populateServer(selectedNode); + } + catch (SecurityException ex) + { + disconnect(managedServer); + throw ex; + } + // Add the Queue/Exchanges/Connections from config file into the navigation tree addConfiguredItems(managedServer); |
