You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by bh...@apache.org on 2007/03/26 16:33:12 UTC
svn commit: r522528 - in
/incubator/qpid/branches/M2/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui:
./ actions/ jmx/ views/
Author: bhupendrab
Date: Mon Mar 26 07:33:11 2007
New Revision: 522528
URL: http://svn.apache.org/viewvc?view=rev&rev=522528
Log:
QPID-428 Added login functionality
Added:
incubator/qpid/branches/M2/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/NumberVerifyListener.java (with props)
Modified:
incubator/qpid/branches/M2/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/Constants.java
incubator/qpid/branches/M2/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/ManagedServer.java
incubator/qpid/branches/M2/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/actions/AddServer.java
incubator/qpid/branches/M2/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/actions/ReconnectServer.java
incubator/qpid/branches/M2/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/jmx/JMXServerRegistry.java
incubator/qpid/branches/M2/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/AttributesTabControl.java
incubator/qpid/branches/M2/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/NavigationView.java
Modified: incubator/qpid/branches/M2/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/Constants.java
URL: http://svn.apache.org/viewvc/incubator/qpid/branches/M2/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/Constants.java?view=diff&rev=522528&r1=522527&r2=522528
==============================================================================
--- incubator/qpid/branches/M2/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/Constants.java (original)
+++ incubator/qpid/branches/M2/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/Constants.java Mon Mar 26 07:33:11 2007
@@ -20,6 +20,8 @@
*/
package org.apache.qpid.management.ui;
+import static org.apache.qpid.management.ui.Constants.CONNECTION_PROTOCOLS;
+
/**
* Contains constants for the application
* @author Bhupendra Bhardwaj
@@ -44,6 +46,11 @@
public final static String RESULT = "Result";
public final static String VIRTUAL_HOST = "VirtualHost";
public final static String DEFAULT_VH = "Default";
+ public final static String DEFAULT_USERNAME = "guest";
+ public final static String DEFAULT_PASSWORD = "guest";
+
+ public final static String USERNAME = "Username";
+ public final static String PASSWORD = "Password";
// Attributes and operations are used to customize the GUI for Qpid. If these are changes in the
// Qpid server, then these should be updated accordingly
@@ -65,9 +72,13 @@
public final static String EXCHANGE_TYPE = "ExchangeType";
public final static String[] EXCHANGE_TYPE_VALUES = {"direct", "topic", "headers"};
public final static String[] BOOLEAN_TYPE_VALUES = {"false", "true"};
- public final static String[] ATTRIBUTE_TABLE_TITLES = {"Attribute Name", "Value"};
+ public final static String[] ATTRIBUTE_TABLE_TITLES = {"Attribute Name", "Value"};
+ public static final String[] CONNECTION_PROTOCOLS ={"RMI"};
+ public static final String DEFAULT_PROTOCOL = CONNECTION_PROTOCOLS[0];
public final static String ACTION_ADDSERVER = "New Connection";
+ public final static String ACTION_RECONNECT = "Reconnect";
+ public final static String ACTION_LOGIN = "Login";
public final static String QUEUE_SORT_BY_NAME = "Queue Name";
public final static String QUEUE_SORT_BY_DEPTH = "Queue Depth";
@@ -105,4 +116,11 @@
public final static int OPERATION_IMPACT_ACTION = 1;
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 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";
+ public final static String INFO_USERNAME = "Please enter the " + USERNAME;
+ public final static String INFO_PASSWORD = "Please enter the " + PASSWORD;
}
Modified: incubator/qpid/branches/M2/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/ManagedServer.java
URL: http://svn.apache.org/viewvc/incubator/qpid/branches/M2/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/ManagedServer.java?view=diff&rev=522528&r1=522527&r2=522528
==============================================================================
--- incubator/qpid/branches/M2/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/ManagedServer.java (original)
+++ incubator/qpid/branches/M2/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/ManagedServer.java Mon Mar 26 07:33:11 2007
@@ -20,60 +20,84 @@
*/
package org.apache.qpid.management.ui;
+import static org.apache.qpid.management.ui.Constants.DEFAULT_PROTOCOL;
/**
* Class representing a server being managed eg. MBeanServer
* @author Bhupendra Bhardwaj
*/
public class ManagedServer extends ManagedObject
{
- private String host;
- private String port;
- private String url;
- private String domain;
-
- public ManagedServer(String host, String port, String domain)
- {
- this.host = host;
- this.port = port;
- this.domain = domain;
- setName(host + ":" + port);
+ private String _host;
+ private int _port;
+ private String _url;
+ private String _domain;
+ private String _user;
+ private String _password;
+ private String _protocol = DEFAULT_PROTOCOL;
+
+ public ManagedServer(String host, int port, String domain)
+ {
+ this(host, port, domain, null, null);
}
- public ManagedServer(String url, String domain)
+ public ManagedServer(String host, int port, String domain, String user, String password)
{
- this.url = url;
- this.domain = domain;
+ setName(host + ":" + port);
+ _host = host;
+ _port = port;
+ _domain = domain;
+ _url = getRMIURL(host, port);
+ _user = user;
+ _password = password;
}
-
+
public String getDomain()
{
- return domain;
+ return _domain;
}
public String getHost()
{
- return host;
+ return _host;
}
- public String getPort()
+ public int getPort()
{
- return port;
+ return _port;
}
public String getUrl()
{
- return url;
+ return _url;
+ }
+
+ public String getProtocol()
+ {
+ return _protocol;
}
- public void setHostAndPort(String host, String port)
+ public String getPassword()
{
- this.host = host;
- this.port = port;
- setName(host + ":" + port);
+ return _password;
+ }
+
+ public void setPassword(String password)
+ {
+ _password = password;
+ }
+
+ public String getUser()
+ {
+ return _user;
+ }
+
+ public void setUser(String user)
+ {
+ _user = user;
}
- public void setUrl(String url)
+ private String getRMIURL(String host, int port)
{
- this.url = url;
+ return "service:jmx:rmi:///jndi/rmi://" + host + ":" + port + "/jmxrmi";
}
}
Modified: incubator/qpid/branches/M2/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/actions/AddServer.java
URL: http://svn.apache.org/viewvc/incubator/qpid/branches/M2/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/actions/AddServer.java?view=diff&rev=522528&r1=522527&r2=522528
==============================================================================
--- incubator/qpid/branches/M2/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/actions/AddServer.java (original)
+++ incubator/qpid/branches/M2/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/actions/AddServer.java Mon Mar 26 07:33:11 2007
@@ -20,11 +20,13 @@
*/
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.Constants;
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;
@@ -34,8 +36,6 @@
import org.eclipse.swt.SWT;
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.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
@@ -51,8 +51,17 @@
public class AddServer/* extends Action*/ implements IWorkbenchWindowActionDelegate
{
private IWorkbenchWindow _window;
- private static final String[] _connectionTypes ={"RMI"};
private static final String[] _domains ={"org.apache.qpid"};
+
+ private NavigationView _navigationView;
+ private String _transport = DEFAULT_PROTOCOL;
+ private String _host;
+ private String _port;
+ private String _domain;
+ private String _user;
+ private String _password;
+
+ private boolean _addServer;
public AddServer()
{
@@ -76,20 +85,38 @@
{
if(_window != null)
{
+ reset();
+ createAddServerPopup();
try
{
- // TODO
- //_window.getActivePage().showView(NavigationView.ID, Integer.toString(0), IWorkbenchPage.VIEW_ACTIVATE);
- //_window.getActivePage().showView(MBeanView.ID, Integer.toString(0), IWorkbenchPage.VIEW_ACTIVATE);
+ if (_addServer)
+ {
+ getNavigationView().addNewServer(_transport, _host, Integer.parseInt(_port), _domain, _user, _password);
+ }
}
- catch (Exception ex)
+ catch(InfoRequiredException ex)
{
-
+ ViewUtility.popupInfoMessage("New connection", 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", ERROR_SERVER_CONNECTION, status);
}
- createWidgets();
}
}
+ private void reset()
+ {
+ _addServer = false;
+ _host = null;
+ _port = null;
+ _domain = null;
+ _user = null;
+ _password = null;
+ }
+
/**
* Selection in the workbench has been changed. We
* can change the state of the 'real' action here
@@ -117,6 +144,15 @@
this._window = window;
}
+ private NavigationView getNavigationView()
+ {
+ if (_navigationView == null)
+ {
+ _navigationView = (NavigationView)_window.getActivePage().findView(NavigationView.ID);
+ }
+
+ return _navigationView;
+ }
/*
public void run()
@@ -127,18 +163,49 @@
}
}
*/
- private void createWidgets()
+
+ /**
+ * 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()
{
Display display = Display.getCurrent();
final Shell shell = new Shell(display, SWT.BORDER | SWT.CLOSE);
- shell.setText(Constants.ACTION_ADDSERVER);
- shell.setImage(ApplicationRegistry.getImage(Constants.CONSOLE_IMAGE));
+ shell.setText(ACTION_ADDSERVER);
+ shell.setImage(ApplicationRegistry.getImage(CONSOLE_IMAGE));
shell.setLayout(new GridLayout());
int x = display.getBounds().width;
int y = display.getBounds().height;
- shell.setBounds(x/4, y/4, 425, 250);
-
+ shell.setBounds(x/3, y/3, 425, 275);
+
+ createWidgets(shell);
+
+ shell.open();
+ _window.getShell().setEnabled(false);
+
+ while (!shell.isDisposed())
+ {
+ if (!display.readAndDispatch())
+ {
+ display.sleep();
+ }
+ }
+
+ //If you create it, you dispose it.
+ shell.dispose();
+
+ // 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);
@@ -148,15 +215,18 @@
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(_connectionTypes);
+ 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");
@@ -166,20 +236,6 @@
textHost.setText("");
textHost.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false));
textHost.setFocus();
- /*
- //Commented so that it lets users copy paste the host name from somewhere else
- textHost.addVerifyListener(new VerifyListener(){
- public void verifyText(VerifyEvent event)
- {
- if (!(Character.isLetterOrDigit(event.character) ||
- (event.character == '.') ||
- (event.character == '\b') ))
- {
- event.doit = false;
- }
- }
- });
- */
Label port = new Label(composite, SWT.NONE);
port.setText("Port");
@@ -188,20 +244,9 @@
final Text textPort = new Text(composite, SWT.BORDER);
textPort.setText("");
textPort.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false));
- /* commented to allow copy paste on this window
- textPort.addVerifyListener(new VerifyListener(){
- public void verifyText(VerifyEvent event)
- {
- if (textPort.getText().length() == 4)
- event.doit = false;
- else if (!(Character.isDigit(event.character) ||
- (event.character == '\b')))
- {
- event.doit = false;
- }
- }
- });
- */
+ // Verify if the value entered is numeric
+ textPort.addVerifyListener(new NumberVerifyListener());
+
Label domain = new Label(composite, SWT.NONE);
domain.setText("Domain");
@@ -212,75 +257,96 @@
comboDomain.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false));
comboDomain.select(0);
+
+ 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(DEFAULT_USERNAME);
+ 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(DEFAULT_PASSWORD);
+ //textPwd.setEchoChar('*');
+ textPwd.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false));
+
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);
+ connectButton.setText(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.setFont(ApplicationRegistry.getFont(FONT_BUTTON));
connectButton.addSelectionListener(new SelectionAdapter(){
- public void widgetSelected(SelectionEvent event)
+ public void widgetSelected(SelectionEvent event)
+ {
+ _host = textHost.getText();
+ if ((_host == null) || (_host.trim().length() == 0))
{
- String transport = comboTransport.getText();
- String host = textHost.getText();
- String port = textPort.getText();
- String domain = comboDomain.getText();
-
- NavigationView view = (NavigationView)_window.getActivePage().findView(NavigationView.ID);
- try
- {
- view.addNewServer(transport, host, port, domain);
-
- if (!connectButton.getShell().isDisposed())
- connectButton.getShell().dispose();
- }
- catch(InfoRequiredException ex)
- {
- ViewUtility.popupInfoMessage("New connection", ex.getMessage());
- }
- catch(Exception ex)
- {
- IStatus status = new Status(IStatus.ERROR, ApplicationWorkbenchAdvisor.PERSPECTIVE_ID,
- IStatus.OK, ex.getMessage(), ex.getCause());
- ErrorDialog.openError(shell, "Error", "Server could not be added", status);
- }
+ 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;
+ }
+
+ _domain = comboDomain.getText();
+ _addServer = true;
+
+ if (!connectButton.getShell().isDisposed())
+ {
+ connectButton.getShell().dispose();
+ }
+ }
+ });
final Button cancelButton = new Button(buttonsComposite, SWT.PUSH);
- cancelButton.setText(Constants.BUTTON_CANCEL);
+ cancelButton.setText(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.setFont(ApplicationRegistry.getFont(FONT_BUTTON));
cancelButton.addSelectionListener(new SelectionAdapter(){
- public void widgetSelected(SelectionEvent event)
- {
- shell.dispose();
- }
- });
-
- shell.open();
- _window.getShell().setEnabled(false);
- while (!shell.isDisposed())
- {
- if (!display.readAndDispatch())
+ public void widgetSelected(SelectionEvent event)
{
- display.sleep();
+ shell.dispose();
}
- }
-
- //If you create it, you dispose it.
- shell.dispose();
-
- // enable the main shell
- _window.getShell().setEnabled(true);
- _window.getShell().open();
+ });
}
}
Modified: incubator/qpid/branches/M2/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/actions/ReconnectServer.java
URL: http://svn.apache.org/viewvc/incubator/qpid/branches/M2/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/actions/ReconnectServer.java?view=diff&rev=522528&r1=522527&r2=522528
==============================================================================
--- incubator/qpid/branches/M2/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/actions/ReconnectServer.java (original)
+++ incubator/qpid/branches/M2/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/actions/ReconnectServer.java Mon Mar 26 07:33:11 2007
@@ -20,21 +20,44 @@
*/
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.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;
+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
{
private IWorkbenchWindow _window;
+ private NavigationView _navigationView;
+ private String _title;
+ private String _serverName;
+ private String _user;
+ private String _password;
+ private boolean _connect;
/**
* Selection in the workbench has been changed. We
@@ -68,14 +91,36 @@
this._window = window;
}
+ private NavigationView getNavigationView()
+ {
+ if (_navigationView == null)
+ {
+ _navigationView = (NavigationView)_window.getActivePage().findView(NavigationView.ID);
+ }
+
+ return _navigationView;
+ }
+
public void run(IAction action)
{
if(_window != null)
{
- NavigationView view = (NavigationView)_window.getActivePage().findView(NavigationView.ID);
try
{
- view.reconnect();
+ 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)
{
@@ -85,8 +130,136 @@
{
IStatus status = new Status(IStatus.ERROR, ApplicationWorkbenchAdvisor.PERSPECTIVE_ID,
IStatus.OK, ex.getMessage(), ex.getCause());
- ErrorDialog.openError(_window.getShell(), "Error", "Server could not be connected", status);
+ ErrorDialog.openError(_window.getShell(), "Error", ERROR_SERVER_CONNECTION, status);
}
}
}
+
+ private void reset()
+ {
+ _connect = false;
+ _user = null;
+ _password = null;
+ }
+
+ // Create the login popup fot th user to enter usernaem and password
+ private void createLoginPopup()
+ {
+ 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());
+
+ int x = display.getBounds().width;
+ int y = display.getBounds().height;
+ shell.setBounds(x/3, y/3, 350, 200);
+
+ createWidgets(shell);
+
+ shell.open();
+ _window.getShell().setEnabled(false);
+
+ while (!shell.isDisposed())
+ {
+ if (!display.readAndDispatch())
+ {
+ display.sleep();
+ }
+ }
+
+ //If you create it, you dispose it.
+ shell.dispose();
+
+ // 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(DEFAULT_USERNAME);
+ 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(DEFAULT_PASSWORD);
+ textPwd.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false));
+
+ 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;
+
+ if (!connectButton.getShell().isDisposed())
+ {
+ connectButton.getShell().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();
+ }
+ });
+ }
+
}
Modified: incubator/qpid/branches/M2/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/jmx/JMXServerRegistry.java
URL: http://svn.apache.org/viewvc/incubator/qpid/branches/M2/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/jmx/JMXServerRegistry.java?view=diff&rev=522528&r1=522527&r2=522528
==============================================================================
--- incubator/qpid/branches/M2/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/jmx/JMXServerRegistry.java (original)
+++ incubator/qpid/branches/M2/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/jmx/JMXServerRegistry.java Mon Mar 26 07:33:11 2007
@@ -83,7 +83,9 @@
{
super(server);
JMXServiceURL jmxUrl = new JMXServiceURL(server.getUrl());
- Map<String, Object> env = null;
+ Map<String, Object> env = new HashMap<String, Object>();
+ String[] creds = {server.getUser(), server.getPassword()};
+ env.put(JMXConnector.CREDENTIALS, creds);
_jmxc = JMXConnectorFactory.connect(jmxUrl, env);
_mbsc = _jmxc.getMBeanServerConnection();
Modified: incubator/qpid/branches/M2/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/AttributesTabControl.java
URL: http://svn.apache.org/viewvc/incubator/qpid/branches/M2/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/AttributesTabControl.java?view=diff&rev=522528&r1=522527&r2=522528
==============================================================================
--- incubator/qpid/branches/M2/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/AttributesTabControl.java (original)
+++ incubator/qpid/branches/M2/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/AttributesTabControl.java Mon Mar 26 07:33:11 2007
@@ -527,23 +527,7 @@
{
style = SWT.BEGINNING | SWT.BORDER;
value = new Text(parent, style);
- value.addVerifyListener(new VerifyListener()
- {
- public void verifyText(VerifyEvent event)
- {
- String string = event.text;
- char [] chars = new char [string.length ()];
- string.getChars (0, chars.length, chars, 0);
- for (int i=0; i<chars.length; i++)
- {
- if (!('0' <= chars [i] && chars [i] <= '9'))
- {
- event.doit = false;
- return;
- }
- }
- }
- });
+ value.addVerifyListener(new NumberVerifyListener());
// set data to access in the listener
parent.setData(attribute);
Modified: incubator/qpid/branches/M2/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/NavigationView.java
URL: http://svn.apache.org/viewvc/incubator/qpid/branches/M2/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/NavigationView.java?view=diff&rev=522528&r1=522527&r2=522528
==============================================================================
--- incubator/qpid/branches/M2/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/NavigationView.java (original)
+++ incubator/qpid/branches/M2/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/NavigationView.java Mon Mar 26 07:33:11 2007
@@ -215,11 +215,6 @@
}
}
- private String getRMIURL(String host)
- {
- return "service:jmx:rmi:///jndi/rmi://" + host + "/jmxrmi";
- }
-
/**
* Adds a new server node in the navigation view if server connection is successful.
* @param transportProtocol
@@ -228,24 +223,30 @@
* @param domain
* @throws Exception
*/
- public void addNewServer(String transportProtocol, String host, String port, String domain)
- throws Exception
+ public void addNewServer(String transportProtocol, String host, int port,
+ String domain, String user, String pwd) throws Exception
{
String serverAddress = host + ":" + port;
String url = null;
- ManagedServer managedServer = null;
+ ManagedServer managedServer = new ManagedServer(host, port, domain, user, pwd);
if ("RMI".equals(transportProtocol))
{
- url = getRMIURL(serverAddress);
+ url = managedServer.getUrl();
List<TreeObject> list = _serversRootNode.getChildren();
for (TreeObject node : list)
{
if (url.equals(node.getUrl()))
- throw new InfoRequiredException("Server " + serverAddress + " is already added");
+ {
+ // Server is already in the list of added servers, so now connect it.
+ // Set the server node as selected and then connect it.
+ _treeViewer.setSelection(new StructuredSelection(node));
+ reconnect(user, pwd);
+ return;
+ }
}
- managedServer = new ManagedServer(url, domain);
+ // The server is not in the list of already added servers, so now connect and add it.
managedServer.setName(serverAddress);
createRMIServerConnection(managedServer);
}
@@ -710,14 +711,16 @@
* Connects the selected server node
* @throws Exception
*/
- public void reconnect() throws Exception
+ public void reconnect(String user, String password) throws Exception
{
TreeObject selectedNode = getSelectedServerNode();
ManagedServer managedServer = (ManagedServer)selectedNode.getManagedObject();
if(_managedServerMap.containsKey(managedServer))
{
throw new InfoRequiredException("Server " + managedServer.getName() + " is already connected");
- }
+ }
+ managedServer.setUser(user);
+ managedServer.setPassword(password);
createRMIServerConnection(managedServer);
// put the server in the managed server map
@@ -880,7 +883,7 @@
return list;
}
- private TreeObject getSelectedServerNode() throws Exception
+ public TreeObject getSelectedServerNode() throws Exception
{
IStructuredSelection ss = (IStructuredSelection)_treeViewer.getSelection();
TreeObject selectedNode = (TreeObject)ss.getFirstElement();
@@ -935,11 +938,9 @@
{
for (String serverAddress : serversList)
{
- String url = getRMIURL(serverAddress);
- ManagedServer managedServer = new ManagedServer(url, "org.apache.qpid");
- managedServer.setName(serverAddress);
+ String[] server = serverAddress.split(":");
+ ManagedServer managedServer = new ManagedServer(server[0], Integer.parseInt(server[1]), "org.apache.qpid");
TreeObject serverNode = new TreeObject(serverAddress, NODE_TYPE_SERVER);
- serverNode.setUrl(url);
serverNode.setManagedObject(managedServer);
_serversRootNode.addChild(serverNode);
}
Added: incubator/qpid/branches/M2/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/NumberVerifyListener.java
URL: http://svn.apache.org/viewvc/incubator/qpid/branches/M2/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/NumberVerifyListener.java?view=auto&rev=522528
==============================================================================
--- incubator/qpid/branches/M2/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/NumberVerifyListener.java (added)
+++ incubator/qpid/branches/M2/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/NumberVerifyListener.java Mon Mar 26 07:33:11 2007
@@ -0,0 +1,46 @@
+/*
+ *
+ * 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.views;
+
+import org.eclipse.swt.events.VerifyEvent;
+import org.eclipse.swt.events.VerifyListener;
+
+/**
+ * Implementation of VeryfyListener for numeric values
+ * @author Bhupendra Bhardwaj
+ */
+public class NumberVerifyListener implements VerifyListener
+{
+ public void verifyText(VerifyEvent event)
+ {
+ String string = event.text;
+ char [] chars = new char [string.length ()];
+ string.getChars (0, chars.length, chars, 0);
+ for (int i=0; i<chars.length; i++)
+ {
+ if (!('0' <= chars [i] && chars [i] <= '9'))
+ {
+ event.doit = false;
+ return;
+ }
+ }
+ }
+}
Propchange: incubator/qpid/branches/M2/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/NumberVerifyListener.java
------------------------------------------------------------------------------
svn:eol-style = native