summaryrefslogtreecommitdiff
path: root/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/actions
diff options
context:
space:
mode:
Diffstat (limited to 'qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/actions')
-rw-r--r--qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/actions/AbstractAction.java220
-rw-r--r--qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/actions/AddServer.java313
-rw-r--r--qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/actions/BackAction.java59
-rw-r--r--qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/actions/CloseConnection.java56
-rw-r--r--qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/actions/ReconnectServer.java264
-rw-r--r--qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/actions/Refresh.java53
-rw-r--r--qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/actions/RemoveServer.java50
-rw-r--r--qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/actions/VersionAction.java94
8 files changed, 1109 insertions, 0 deletions
diff --git a/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/actions/AbstractAction.java b/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/actions/AbstractAction.java
new file mode 100644
index 0000000000..5d892f5503
--- /dev/null
+++ b/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/actions/AbstractAction.java
@@ -0,0 +1,220 @@
+/*
+ *
+ * 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 static org.apache.qpid.management.ui.Constants.ERROR_SERVER_CONNECTION;
+
+import java.io.IOException;
+
+import javax.net.ssl.SSLException;
+import javax.net.ssl.SSLHandshakeException;
+import javax.net.ssl.SSLKeyException;
+import javax.net.ssl.SSLPeerUnverifiedException;
+
+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.ManagementConsoleException;
+import org.apache.qpid.management.ui.jmx.MBeanUtility;
+import org.apache.qpid.management.ui.views.NavigationView;
+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 AbstractAction
+{
+ private NavigationView _navigationView;
+
+ protected IWorkbenchWindow _window;
+
+ public static final String INVALID_PERSPECTIVE = "Invalid Perspective";
+ public static final String CHANGE_PERSPECTIVE = "Please use the Qpid Management Perspective";
+
+ private static final String SSL_EMPTY_TRUSTANCHORS = "the trustAnchors parameter must be non-empty";
+ private static final String SSL_UNABLE_TO_FIND_CERTPATH = "sun.security.provider.certpath.SunCertPathBuilderException: " +
+ "unable to find valid certification path to requested target";
+
+ /**
+ * 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 NavigationView getNavigationView()
+ {
+ if (_navigationView == null)
+ {
+ _navigationView = (NavigationView)_window.getActivePage().findView(NavigationView.ID);
+ }
+
+ return _navigationView;
+ }
+
+ protected void handleException(Throwable ex, String title, String msg)
+ {
+ //ensure first that the exception is not due to running in the wrong eclipse perspective
+ NavigationView view = (NavigationView)_window.getActivePage().findView(NavigationView.ID);
+ if (view == null)
+ {
+ IStatus status = new Status(IStatus.WARNING, ApplicationWorkbenchAdvisor.PERSPECTIVE_ID,
+ IStatus.OK, CHANGE_PERSPECTIVE, null);
+ ErrorDialog.openError(_window.getShell(), "Warning", INVALID_PERSPECTIVE, status);
+ return;
+ }
+
+ //default title if none given
+ if (title == null)
+ {
+ title = ERROR_SERVER_CONNECTION;
+ }
+
+ //determine the error message to display
+ if (msg == null)
+ {
+ if (ex instanceof SSLException)
+ {
+ if (ex instanceof SSLKeyException)
+ {
+ msg = "SSL key was invalid, please check the certificate configuration.";
+ //Display error dialogue and return
+ displayErrorDialogue(msg, title);
+ return;
+ }
+ else if (ex instanceof SSLPeerUnverifiedException)
+ {
+ msg = "SSL peer identity could not be verified, please ensure valid certificate configuration.";
+ //Display error dialogue and return
+ displayErrorDialogue(msg, title);
+ return;
+ }
+ else if (ex instanceof SSLHandshakeException)
+ {
+ if (ex.getMessage().contains(SSL_UNABLE_TO_FIND_CERTPATH))
+ {
+ msg = "Unable to certify the provided SSL certificate using the current SSL trust store.";
+ }
+ else
+ {
+ //cause unknown, provide a trace too
+ MBeanUtility.printStackTrace(ex);
+ msg = "SSL handhshake error.";
+ }
+ //Display error dialogue and return
+ displayErrorDialogue(msg, title);
+ return;
+ }
+ else
+ {
+ //general SSL Exception.
+ if (ex.getMessage().contains(SSL_EMPTY_TRUSTANCHORS))
+ {
+ msg = "Unable to locate the specified SSL certificate trust store, please check the configuration.";
+ }
+ else
+ {
+ //cause unknown, print stack trace
+ MBeanUtility.printStackTrace(ex);
+ msg = "SSL connection error.";
+ }
+ //Display error dialogue and return
+ displayErrorDialogue(msg, title);
+ return;
+ }
+ }
+ else if (ex instanceof IOException || ex instanceof SecurityException )
+ {
+ msg = ex.getMessage();
+
+ //if msg is still null, try reporting the cause.
+ if ((msg == null) && (ex.getCause() != null))
+ {
+ msg = ex.getCause().getMessage();
+ }
+
+ //Display error dialogue and return
+ displayErrorDialogue(msg, title);
+ return;
+ }
+ else if (ex instanceof ManagementConsoleException)
+ {
+ msg = ex.getMessage();
+ displayErrorDialogue(msg, title);
+ return;
+ }
+ else
+ {
+ //Unknown exception type/reason.
+ msg = ex.getMessage();
+ }
+
+ //if msg is still null, try reporting the cause.
+ if ((msg == null) && (ex.getCause() != null))
+ {
+ msg = ex.getCause().getMessage();
+ }
+
+ //failing all else, default non-descript error message.
+ if (msg == null)
+ {
+ msg = "An unknown error has occured.";
+ }
+ }
+
+ //Display error dialogue and print the exception stack trace
+ MBeanUtility.printStackTrace(ex);
+ displayErrorDialogue(msg, title);
+ }
+
+ private void displayErrorDialogue(String msg, String title)
+ {
+ IStatus status = new Status(IStatus.ERROR, ApplicationWorkbenchAdvisor.PERSPECTIVE_ID,
+ IStatus.OK, msg, null);
+ ErrorDialog.openError(_window.getShell(), "Error", title, status);
+ }
+
+ /**
+ * Selection in the workbench has been changed. We can change the state of the 'real' action here
+ * if we want, but this can only happen after the delegate has been created.
+ * @see IWorkbenchWindowActionDelegate#selectionChanged
+ */
+ public void selectionChanged(IAction action, ISelection selection) {
+ }
+
+ /**
+ * We can use this method to dispose of any system resources we previously allocated.
+ * @see IWorkbenchWindowActionDelegate#dispose
+ */
+ public void dispose() {
+
+ }
+}
diff --git a/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/actions/AddServer.java b/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/actions/AddServer.java
new file mode 100644
index 0000000000..e487c02a67
--- /dev/null
+++ b/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/actions/AddServer.java
@@ -0,0 +1,313 @@
+/*
+ *
+ * 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 static org.apache.qpid.management.ui.Constants.*;
+
+import org.apache.qpid.management.ui.ApplicationRegistry;
+import org.apache.qpid.management.ui.exceptions.InfoRequiredException;
+import org.apache.qpid.management.ui.views.NumberVerifyListener;
+import org.apache.qpid.management.ui.views.ViewUtility;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.KeyAdapter;
+import org.eclipse.swt.events.KeyEvent;
+import org.eclipse.swt.events.SelectionAdapter;
+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.Composite;
+import org.eclipse.swt.widgets.Control;
+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.IWorkbenchWindowActionDelegate;
+
+public class AddServer extends AbstractAction implements IWorkbenchWindowActionDelegate
+{
+ private String _host;
+ private String _port;
+ private String _domain = DEFAULT_DOMAIN;
+ private String _user;
+ private String _password;
+
+ private boolean _addServer;
+
+ public AddServer()
+ {
+
+ }
+
+ public void run(IAction action)
+ {
+ if(_window == null)
+ return;
+
+ reset();
+ createAddServerPopup();
+ try
+ {
+ if (_addServer)
+ {
+ getNavigationView().addNewServer(_host, Integer.parseInt(_port), _domain, _user, _password);
+ }
+ }
+ catch(InfoRequiredException ex)
+ {
+ ViewUtility.popupInfoMessage(ACTION_ADDSERVER, ex.getMessage());
+ }
+ catch (Exception ex)
+ {
+ handleException(ex, null, null);
+ }
+ }
+
+ private void reset()
+ {
+ _addServer = false;
+ _host = null;
+ _port = null;
+ _user = null;
+ _password = null;
+ }
+
+ /**
+ * Creates the shell and then opens the popup where user can enter new connection details.
+ * Connects to the new server and adds the server in the navigation page.
+ * Pops up any error occured in connecting to the new server
+ */
+ private void createAddServerPopup()
+ {
+ final Shell appShell = _window.getShell();
+
+ Display display = Display.getCurrent();
+ final Shell shell = new Shell(display, SWT.BORDER | SWT.CLOSE);
+ shell.setText(ACTION_ADDSERVER);
+ shell.setImage(ApplicationRegistry.getImage(CONSOLE_IMAGE));
+ shell.setLayout(new GridLayout());
+
+ createWidgets(shell);
+ shell.pack();
+
+ //get current size dialog, and application window size and location
+ int appWidth = appShell.getBounds().width;
+ int appHeight = appShell.getBounds().height;
+ int appLocX = appShell.getBounds().x;
+ int appLocY = appShell.getBounds().y;
+ int currentShellWidth = shell.getSize().x;
+ int currentShellHeight = shell.getSize().y;
+
+ //default sizes for the dialog
+ int minShellWidth = 425;
+ int minShellHeight= 265;
+ //ensure this is large enough, increase it if its not
+ int newShellWidth = currentShellWidth > minShellWidth ? currentShellWidth : minShellWidth;
+ int newShellHeight = currentShellHeight > minShellHeight ? currentShellHeight : minShellHeight;
+
+ //set the final size and centre the dialog within the app window
+ shell.setBounds((appWidth - newShellWidth)/2 + appLocX, (appHeight - newShellHeight)/2 + appLocY, newShellWidth, newShellHeight);
+
+ shell.open();
+ _window.getShell().setEnabled(false);
+
+ while (!shell.isDisposed())
+ {
+ if (!display.readAndDispatch())
+ {
+ display.sleep();
+ }
+ }
+
+ // enable the main shell
+ _window.getShell().setEnabled(true);
+ _window.getShell().open();
+ }
+
+ // Creates SWT widgets for the user to add server connection details.
+ // Adds listeners to the widgets to take appropriate action
+ private void createWidgets(final Shell shell)
+ {
+ Composite composite = new Composite(shell, SWT.NONE);
+ composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
+ GridLayout layout = new GridLayout(2, false);
+ layout.horizontalSpacing = 10;
+ layout.verticalSpacing = 10;
+ layout.marginHeight = 20;
+ layout.marginWidth = 20;
+ composite.setLayout(layout);
+
+ /* Commenting this, as there is only one protocol at the moment.
+ * This can be uncommented and enhanced, if more protocols are added in future
+ Label name = new Label(composite, SWT.NONE);
+ name.setText("Connection Type");
+ GridData layoutData = new GridData(SWT.TRAIL, SWT.TOP, false, false);
+ name.setLayoutData(layoutData);
+
+ final Combo comboTransport = new Combo(composite, SWT.READ_ONLY);
+ comboTransport.setItems(CONNECTION_PROTOCOLS);
+ comboTransport.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false));
+ comboTransport.select(0);
+ */
+
+ Label host = new Label(composite, SWT.NONE);
+ host.setText("Host");
+ host.setLayoutData(new GridData(SWT.TRAIL, SWT.TOP, false, false));
+
+ final Text textHost = new Text(composite, SWT.BORDER);
+ textHost.setText("");
+ textHost.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false));
+ textHost.setFocus();
+
+ Label port = new Label(composite, SWT.NONE);
+ port.setText("Port");
+ port.setLayoutData(new GridData(SWT.TRAIL, SWT.TOP, false, false));
+
+ final Text textPort = new Text(composite, SWT.BORDER);
+ textPort.setText("");
+ textPort.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false));
+ // Verify if the value entered is numeric
+ textPort.addVerifyListener(new NumberVerifyListener());
+
+ Label user = new Label(composite, SWT.NONE);
+ user.setText(USERNAME);
+ user.setLayoutData(new GridData(SWT.TRAIL, SWT.TOP, false, false));
+
+ final Text textUser = new Text(composite, SWT.BORDER);
+ textUser.setText("");
+ textUser.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false));
+
+ Label password = new Label(composite, SWT.NONE);
+ password.setText(PASSWORD);
+ password.setLayoutData(new GridData(SWT.TRAIL, SWT.TOP, false, false));
+
+ final Text textPwd = new Text(composite, SWT.BORDER | SWT.SINGLE | SWT.PASSWORD);
+ textPwd.setText("");
+ //textPwd.setEchoChar('*');
+ textPwd.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false));
+
+ //Get the text widgets
+ Control[] widgets = composite.getChildren();
+ for (int i=0; i < widgets.length; i++)
+ {
+ widgets[i].addKeyListener(new KeyAdapter()
+ {
+ public void keyPressed(KeyEvent event)
+ {
+ if (event.character == SWT.ESC)
+ {
+ //Escape key acts as cancel on all widgets
+ shell.dispose();
+ }
+ }
+ });
+ }
+
+ Composite buttonsComposite = new Composite(composite, SWT.NONE);
+ buttonsComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 2, 1));
+ buttonsComposite.setLayout(new GridLayout(2, true));
+
+ final Button connectButton = new Button(buttonsComposite, SWT.PUSH | SWT.CENTER);
+ connectButton.setText(BUTTON_CONNECT);
+ GridData gridData = new GridData (SWT.TRAIL, SWT.BOTTOM, true, true);
+ gridData.widthHint = 100;
+ connectButton.setLayoutData(gridData);
+ connectButton.setFont(ApplicationRegistry.getFont(FONT_BUTTON));
+ connectButton.addSelectionListener(new SelectionAdapter(){
+ public void widgetSelected(SelectionEvent event)
+ {
+ _host = textHost.getText();
+ if ((_host == null) || (_host.trim().length() == 0))
+ {
+ ViewUtility.popupInfoMessage(ACTION_ADDSERVER, INFO_HOST_ADDRESS);
+ textHost.setText("");
+ textHost.setFocus();
+ return;
+ }
+
+ _port = textPort.getText();
+ if ((_port == null) || (_port.trim().length() == 0))
+ {
+ ViewUtility.popupInfoMessage(ACTION_ADDSERVER, INFO_HOST_PORT);
+ textPort.setText("");
+ textPort.setFocus();
+ return;
+ }
+
+ _user = textUser.getText();
+ if ((_user == null) || (_user.trim().length() == 0))
+ {
+ ViewUtility.popupInfoMessage(ACTION_ADDSERVER, INFO_USERNAME);
+ textUser.setText("");
+ textUser.setFocus();
+ return;
+ }
+
+ _password = textPwd.getText();
+ if (_password == null)
+ {
+ ViewUtility.popupInfoMessage(ACTION_ADDSERVER, INFO_PASSWORD);
+ textPwd.setText("");
+ textPwd.setFocus();
+ return;
+ }
+
+ _addServer = true;
+ shell.dispose();
+ }
+ });
+
+ final Button cancelButton = new Button(buttonsComposite, SWT.PUSH);
+ cancelButton.setText(BUTTON_CANCEL);
+ gridData = new GridData (SWT.LEAD, SWT.BOTTOM, true, true);
+ gridData.widthHint = 100;
+ cancelButton.setLayoutData(gridData);
+ cancelButton.setFont(ApplicationRegistry.getFont(FONT_BUTTON));
+ cancelButton.addSelectionListener(new SelectionAdapter()
+ {
+ public void widgetSelected(SelectionEvent event)
+ {
+ shell.dispose();
+ }
+ });
+
+ //Get the ok/cancel button widgets and add a new key listener
+ widgets = buttonsComposite.getChildren();
+ for (int i=0; i < widgets.length; i++)
+ {
+ widgets[i].addKeyListener(new KeyAdapter()
+ {
+ public void keyPressed(KeyEvent event)
+ {
+ if (event.character == SWT.ESC)
+ {
+ //Escape key acts as cancel on all widgets
+ shell.dispose();
+ }
+ }
+ });
+ }
+
+ shell.setDefaultButton(connectButton);
+ }
+
+}
diff --git a/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/actions/BackAction.java b/qpid/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/qpid/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/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/actions/CloseConnection.java b/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/actions/CloseConnection.java
new file mode 100644
index 0000000000..a3e52149df
--- /dev/null
+++ b/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/actions/CloseConnection.java
@@ -0,0 +1,56 @@
+/*
+ *
+ * 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 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.jface.action.IAction;
+import org.eclipse.ui.IWorkbenchWindowActionDelegate;
+
+public class CloseConnection extends AbstractAction implements IWorkbenchWindowActionDelegate
+{
+ public CloseConnection()
+ {
+
+ }
+
+ public void run(IAction action)
+ {
+ if(_window != null)
+ {
+ NavigationView view = (NavigationView)_window.getActivePage().findView(NavigationView.ID);
+ try
+ {
+ view.disconnect();
+ }
+ catch(InfoRequiredException ex)
+ {
+ ViewUtility.popupInfoMessage(ACTION_CLOSE, ex.getMessage());
+ }
+ catch(Exception ex)
+ {
+ handleException(ex, null, null);
+ }
+ }
+ }
+}
diff --git a/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/actions/ReconnectServer.java b/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/actions/ReconnectServer.java
new file mode 100644
index 0000000000..5eb9d9a168
--- /dev/null
+++ b/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/actions/ReconnectServer.java
@@ -0,0 +1,264 @@
+/*
+ *
+ * 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 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.Constants;
+import org.apache.qpid.management.ui.exceptions.InfoRequiredException;
+import org.apache.qpid.management.ui.views.TreeObject;
+import org.apache.qpid.management.ui.views.ViewUtility;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.KeyAdapter;
+import org.eclipse.swt.events.KeyEvent;
+import org.eclipse.swt.events.SelectionAdapter;
+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.Composite;
+import org.eclipse.swt.widgets.Control;
+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.IWorkbenchWindowActionDelegate;
+
+public class ReconnectServer extends AbstractAction implements IWorkbenchWindowActionDelegate
+{
+ private String _title;
+ private String _serverName;
+ private String _user;
+ private String _password;
+ private boolean _connect;
+
+ public void run(IAction action)
+ {
+ if(_window == null)
+ return;
+
+ try
+ {
+ reset();
+ // Check if a server node is selected to be reconnected.
+ TreeObject serverNode = getNavigationView().getSelectedServerNode();
+ _serverName = serverNode.getName();
+ _title = ACTION_LOGIN + " (" + _serverName + ")";
+
+ // Get the login details(username/password)
+ createLoginPopup();
+
+ if (_connect)
+ {
+ // Connect the server
+ getNavigationView().reconnect(_user, _password);
+ }
+ }
+ catch(InfoRequiredException ex)
+ {
+ ViewUtility.popupInfoMessage("Reconnect Qpid server", ex.getMessage());
+ }
+ catch (Exception ex)
+ {
+ handleException(ex, null, null);
+ }
+ }
+
+ private void reset()
+ {
+ _connect = false;
+ _user = null;
+ _password = null;
+ }
+
+ // Create the login popup fot th user to enter usernaem and password
+ private void createLoginPopup()
+ {
+ final Shell appShell = _window.getShell();
+
+ Display display = Display.getCurrent();
+ final Shell shell = new Shell(display, SWT.BORDER | SWT.CLOSE);
+ shell.setText(_title);
+ shell.setImage(ApplicationRegistry.getImage(CONSOLE_IMAGE));
+ shell.setLayout(new GridLayout());
+
+ createWidgets(shell);
+ shell.pack();
+
+ //get current size dialog, and application window size and location
+ int appWidth = appShell.getBounds().width;
+ int appHeight = appShell.getBounds().height;
+ int appLocX = appShell.getBounds().x;
+ int appLocY = appShell.getBounds().y;
+ int currentShellWidth = shell.getSize().x;
+ int currentShellHeight = shell.getSize().y;
+
+ //default sizes for the dialog
+ int minShellWidth = 350;
+ int minShellHeight= 200;
+ //ensure this is large enough, increase it if its not
+ int newShellWidth = currentShellWidth > minShellWidth ? currentShellWidth : minShellWidth;
+ int newShellHeight = currentShellHeight > minShellHeight ? currentShellHeight : minShellHeight;
+
+ //set the final size and centre the dialog within the app window
+ shell.setBounds((appWidth - newShellWidth)/2 + appLocX, (appHeight - newShellHeight)/2 + appLocY, newShellWidth, newShellHeight);
+
+ shell.open();
+ _window.getShell().setEnabled(false);
+
+ while (!shell.isDisposed())
+ {
+ if (!display.readAndDispatch())
+ {
+ display.sleep();
+ }
+ }
+
+ // enable the main shell
+ _window.getShell().setEnabled(true);
+ _window.getShell().open();
+ }
+
+ // Creates the SWT widgets in the popup shell, to enter username and password.
+ // Adds listeners to the widgets to take appropriate action
+ private void createWidgets(final Shell shell)
+ {
+ Composite composite = new Composite(shell, SWT.NONE);
+ composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
+ GridLayout layout = new GridLayout(2, false);
+ layout.horizontalSpacing = 10;
+ layout.verticalSpacing = 10;
+ layout.marginHeight = 20;
+ layout.marginWidth = 20;
+ composite.setLayout(layout);
+
+ Label user = new Label(composite, SWT.NONE);
+ user.setText(USERNAME);
+ user.setLayoutData(new GridData(SWT.TRAIL, SWT.TOP, false, false));
+
+ final Text textUser = new Text(composite, SWT.BORDER);
+ textUser.setText("");
+ textUser.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false));
+ // Put cursor on this field
+ textUser.setFocus();
+
+ Label password = new Label(composite, SWT.NONE);
+ password.setText(PASSWORD);
+ password.setLayoutData(new GridData(SWT.TRAIL, SWT.TOP, false, false));
+
+ final Text textPwd = new Text(composite, SWT.BORDER | SWT.SINGLE | SWT.PASSWORD);
+ textPwd.setText("");
+ textPwd.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false));
+
+ //Get the text widgets
+ Control[] widgets = composite.getChildren();
+ for (int i=0; i < widgets.length; i++)
+ {
+ widgets[i].addKeyListener(new KeyAdapter()
+ {
+ public void keyPressed(KeyEvent event)
+ {
+ if (event.character == SWT.ESC)
+ {
+ //Escape key acts as cancel on all widgets
+ shell.dispose();
+ }
+ }
+ });
+ }
+
+ Composite buttonsComposite = new Composite(composite, SWT.NONE);
+ buttonsComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 2, 1));
+ buttonsComposite.setLayout(new GridLayout(2, true));
+
+ final Button connectButton = new Button(buttonsComposite, SWT.PUSH | SWT.CENTER);
+ connectButton.setText(Constants.BUTTON_CONNECT);
+ GridData gridData = new GridData (SWT.TRAIL, SWT.BOTTOM, true, true);
+ gridData.widthHint = 100;
+ connectButton.setLayoutData(gridData);
+ connectButton.setFont(ApplicationRegistry.getFont(Constants.FONT_BUTTON));
+ connectButton.addSelectionListener(new SelectionAdapter(){
+ public void widgetSelected(SelectionEvent event)
+ {
+ _user = textUser.getText();
+ if ((_user == null) || (_user.trim().length() == 0))
+ {
+ ViewUtility.popupInfoMessage(_title, INFO_USERNAME);
+ textUser.setText("");
+ textUser.setFocus();
+ return;
+ }
+
+ _password = textPwd.getText();
+ if (_password == null)
+ {
+ ViewUtility.popupInfoMessage(_title, INFO_PASSWORD);
+ textPwd.setText("");
+ textPwd.setFocus();
+ return;
+ }
+
+ _connect = true;
+ shell.dispose();
+ }
+ });
+
+ final Button cancelButton = new Button(buttonsComposite, SWT.PUSH);
+ cancelButton.setText(Constants.BUTTON_CANCEL);
+ gridData = new GridData (SWT.LEAD, SWT.BOTTOM, true, true);
+ gridData.widthHint = 100;
+ cancelButton.setLayoutData(gridData);
+ cancelButton.setFont(ApplicationRegistry.getFont(Constants.FONT_BUTTON));
+ cancelButton.addSelectionListener(new SelectionAdapter(){
+ public void widgetSelected(SelectionEvent event)
+ {
+ shell.dispose();
+ }
+ });
+
+ //Get the ok/cancel button widgets and add a new key listener
+ widgets = buttonsComposite.getChildren();
+ for (int i=0; i < widgets.length; i++)
+ {
+ widgets[i].addKeyListener(new KeyAdapter()
+ {
+ public void keyPressed(KeyEvent event)
+ {
+ if (event.character == SWT.ESC)
+ {
+ //Escape key acts as cancel on all widgets
+ shell.dispose();
+ }
+ }
+ });
+ }
+
+ shell.setDefaultButton(connectButton);
+ }
+
+}
diff --git a/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/actions/Refresh.java b/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/actions/Refresh.java
new file mode 100644
index 0000000000..dd4cbffd84
--- /dev/null
+++ b/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/actions/Refresh.java
@@ -0,0 +1,53 @@
+/*
+ *
+ * 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.apache.qpid.management.ui.views.NavigationView;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.ui.IWorkbenchWindowActionDelegate;
+
+/**
+ * This action refreshes both the views -Navigation and MBeanView
+ * @author Bhupendra Bhardwaj
+ */
+public class Refresh extends AbstractAction implements IWorkbenchWindowActionDelegate
+{
+ public void run(IAction action)
+ {
+ if(_window != null)
+ {
+ NavigationView view = (NavigationView)_window.getActivePage().findView(NavigationView.ID);
+ view.refresh();
+
+ MBeanView mbeanview = (MBeanView)_window.getActivePage().findView(MBeanView.ID);
+ try
+ {
+ mbeanview.refresh();
+ }
+ catch (Exception ex)
+ {
+ MBeanUtility.handleException(ex);
+ }
+ }
+ }
+}
diff --git a/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/actions/RemoveServer.java b/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/actions/RemoveServer.java
new file mode 100644
index 0000000000..e329255414
--- /dev/null
+++ b/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/actions/RemoveServer.java
@@ -0,0 +1,50 @@
+/*
+ *
+ * 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.exceptions.InfoRequiredException;
+import org.apache.qpid.management.ui.views.NavigationView;
+import org.apache.qpid.management.ui.views.ViewUtility;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.ui.IWorkbenchWindowActionDelegate;
+
+public class RemoveServer extends AbstractAction implements IWorkbenchWindowActionDelegate
+{
+ public void run(IAction action)
+ {
+ if(_window != null)
+ {
+ NavigationView view = (NavigationView)_window.getActivePage().findView(NavigationView.ID);
+ try
+ {
+ view.removeServer();
+ }
+ catch(InfoRequiredException ex)
+ {
+ ViewUtility.popupInfoMessage("Remove Qpid server", ex.getMessage());
+ }
+ catch(Exception ex)
+ {
+ handleException(ex, "Server could not be removed", null);
+ }
+ }
+ }
+}
diff --git a/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/actions/VersionAction.java b/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/actions/VersionAction.java
new file mode 100644
index 0000000000..be69fadbe8
--- /dev/null
+++ b/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/actions/VersionAction.java
@@ -0,0 +1,94 @@
+/*
+ *
+ * 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 java.io.InputStream;
+import java.util.Properties;
+
+import org.apache.qpid.management.ui.Constants;
+import org.apache.qpid.management.ui.jmx.MBeanUtility;
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.ui.IWorkbenchWindow;
+
+public class VersionAction extends Action
+{
+ private IWorkbenchWindow _window;
+ public static final String VERSION_RESOURCE = "qpidversion.properties";
+
+ public static final String PRODUCT_NAME_PROPERTY = "qpid.name";
+ public static final String RELEASE_VERSION_PROPERTY = "qpid.version";
+ public static final String BUILD_VERSION_PROPERTY = "qpid.svnversion";
+
+ private static final String DEFAULT = "unknown";
+ private static String _releaseVersion;
+ private static String _buildVersion;
+ private static String _text;
+
+ static
+ {
+ Properties props = new Properties();
+ try
+ {
+ InputStream propertyStream = VersionAction.class.getClassLoader().getResourceAsStream(VERSION_RESOURCE);
+ if (propertyStream != null)
+ {
+ props.load(propertyStream);
+ _releaseVersion = readPropertyValue(props, RELEASE_VERSION_PROPERTY);
+ _buildVersion = readPropertyValue(props, BUILD_VERSION_PROPERTY);
+ _text = "Build Version : " + _buildVersion + "\n" +
+ "Release Version : " + _releaseVersion;
+ }
+ else
+ {
+ _text = "Build Version : \n" +
+ "Release Version : ";
+ }
+ }
+ catch (Exception ex)
+ {
+ MBeanUtility.printStackTrace(ex);
+ }
+ }
+
+ public VersionAction(IWorkbenchWindow window)
+ {
+ _window = window;
+ setText("About " + Constants.APPLICATION_NAME);
+ setId("qpidmc.about");
+ setActionDefinitionId("qpidmc.about");
+ }
+
+ private static String readPropertyValue(Properties props, String propertyName)
+ {
+ String retVal = (String) props.get(propertyName);
+ if (retVal == null)
+ {
+ retVal = DEFAULT;
+ }
+ return retVal;
+ }
+
+ public void run()
+ {
+ MessageDialog.openInformation(_window.getShell(), Constants.APPLICATION_NAME, _text);
+ }
+}