Author: rob.stryker(a)jboss.com
Date: 2010-04-06 05:36:30 -0400 (Tue, 06 Apr 2010)
New Revision: 21282
Added:
trunk/jmx/plugins/org.jboss.tools.jmx.ui/src/org/jboss/tools/jmx/ui/IEditableConnectionWizardPage.java
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/extensions/jmx/JBossServerConnectionProvider.java
trunk/as/plugins/org.jboss.ide.eclipse.as.wtp.ui/src/org/jboss/ide/eclipse/as/wtp/ui/propertypage/NewReferenceWizard.java
trunk/jmx/plugins/org.jboss.tools.jmx.core/src/org/jboss/tools/jmx/core/IConnectionProvider.java
trunk/jmx/plugins/org.jboss.tools.jmx.core/src/org/jboss/tools/jmx/core/JMXCoreMessages.java
trunk/jmx/plugins/org.jboss.tools.jmx.core/src/org/jboss/tools/jmx/core/JMXCoreMessages.properties
trunk/jmx/plugins/org.jboss.tools.jmx.core/src/org/jboss/tools/jmx/core/providers/DefaultConnectionProvider.java
trunk/jmx/plugins/org.jboss.tools.jmx.core/src/org/jboss/tools/jmx/core/providers/DefaultConnectionWrapper.java
trunk/jmx/plugins/org.jboss.tools.jmx.core/src/org/jboss/tools/jmx/core/providers/MBeanServerConnectionDescriptor.java
trunk/jmx/plugins/org.jboss.tools.jmx.ui/plugin.xml
trunk/jmx/plugins/org.jboss.tools.jmx.ui/schema/providerUI.exsd
trunk/jmx/plugins/org.jboss.tools.jmx.ui/src/org/jboss/tools/jmx/ui/Messages.java
trunk/jmx/plugins/org.jboss.tools.jmx.ui/src/org/jboss/tools/jmx/ui/Messages.properties
trunk/jmx/plugins/org.jboss.tools.jmx.ui/src/org/jboss/tools/jmx/ui/UIExtensionManager.java
trunk/jmx/plugins/org.jboss.tools.jmx.ui/src/org/jboss/tools/jmx/ui/internal/views/navigator/ActionProvider.java
trunk/jmx/plugins/org.jboss.tools.jmx.ui/src/org/jboss/tools/jmx/ui/internal/wizards/DefaultConnectionWizardPage.java
trunk/jmx/tests/org.jboss.tools.jmx.core.test/src/org/jboss/tools/jmx/core/test/DefaultProviderTest.java
Log:
JBIDE-4927 to trunk
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/extensions/jmx/JBossServerConnectionProvider.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/extensions/jmx/JBossServerConnectionProvider.java 2010-04-06
09:27:27 UTC (rev 21281)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/extensions/jmx/JBossServerConnectionProvider.java 2010-04-06
09:36:30 UTC (rev 21282)
@@ -192,4 +192,7 @@
public boolean canDelete(IConnectionWrapper wrapper) {
return false;
}
+ public void connectionChanged(IConnectionWrapper connection) {
+ // do nothing
+ }
}
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.wtp.ui/src/org/jboss/ide/eclipse/as/wtp/ui/propertypage/NewReferenceWizard.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.wtp.ui/src/org/jboss/ide/eclipse/as/wtp/ui/propertypage/NewReferenceWizard.java 2010-04-06
09:27:27 UTC (rev 21281)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.wtp.ui/src/org/jboss/ide/eclipse/as/wtp/ui/propertypage/NewReferenceWizard.java 2010-04-06
09:36:30 UTC (rev 21282)
@@ -1,3 +1,13 @@
+/*******************************************************************************
+ * Copyright (c) 2010 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
package org.jboss.ide.eclipse.as.wtp.ui.propertypage;
import java.util.List;
Modified:
trunk/jmx/plugins/org.jboss.tools.jmx.core/src/org/jboss/tools/jmx/core/IConnectionProvider.java
===================================================================
---
trunk/jmx/plugins/org.jboss.tools.jmx.core/src/org/jboss/tools/jmx/core/IConnectionProvider.java 2010-04-06
09:27:27 UTC (rev 21281)
+++
trunk/jmx/plugins/org.jboss.tools.jmx.core/src/org/jboss/tools/jmx/core/IConnectionProvider.java 2010-04-06
09:36:30 UTC (rev 21282)
@@ -69,6 +69,8 @@
*/
public void addConnection(IConnectionWrapper connection);
public void removeConnection(IConnectionWrapper connection);
+ public void connectionChanged(IConnectionWrapper connection);
+
public void addListener(IConnectionProviderListener listener);
public void removeListener(IConnectionProviderListener listener);
Modified:
trunk/jmx/plugins/org.jboss.tools.jmx.core/src/org/jboss/tools/jmx/core/JMXCoreMessages.java
===================================================================
---
trunk/jmx/plugins/org.jboss.tools.jmx.core/src/org/jboss/tools/jmx/core/JMXCoreMessages.java 2010-04-06
09:27:27 UTC (rev 21281)
+++
trunk/jmx/plugins/org.jboss.tools.jmx.core/src/org/jboss/tools/jmx/core/JMXCoreMessages.java 2010-04-06
09:36:30 UTC (rev 21282)
@@ -18,6 +18,7 @@
public static String ExtensionManagerError1;
public static String DefaultConnection_ErrorAdding;
public static String DefaultConnection_ErrorRemoving;
+ public static String DefaultConnection_ErrorChanging;
public static String DefaultConnection_ErrorLoading;
public static String DefaultConnection_ErrorRunningJMXCode;
public static String ProblemWritingToFile;
Modified:
trunk/jmx/plugins/org.jboss.tools.jmx.core/src/org/jboss/tools/jmx/core/JMXCoreMessages.properties
===================================================================
---
trunk/jmx/plugins/org.jboss.tools.jmx.core/src/org/jboss/tools/jmx/core/JMXCoreMessages.properties 2010-04-06
09:27:27 UTC (rev 21281)
+++
trunk/jmx/plugins/org.jboss.tools.jmx.core/src/org/jboss/tools/jmx/core/JMXCoreMessages.properties 2010-04-06
09:36:30 UTC (rev 21282)
@@ -7,6 +7,7 @@
DefaultConnection_ErrorLoading=Error loading connection
DefaultConnection_ErrorAdding=Error adding connection.
DefaultConnection_ErrorRemoving=Error removing connection.
+DefaultConnection_ErrorChanging=Error changing connection.
DefaultConnection_ErrorRunningJMXCode=Error executing JMX request.
ProblemWritingToFile=Problem writing to file {0}
LoadMBeans=Load MBeans
Modified:
trunk/jmx/plugins/org.jboss.tools.jmx.core/src/org/jboss/tools/jmx/core/providers/DefaultConnectionProvider.java
===================================================================
---
trunk/jmx/plugins/org.jboss.tools.jmx.core/src/org/jboss/tools/jmx/core/providers/DefaultConnectionProvider.java 2010-04-06
09:27:27 UTC (rev 21281)
+++
trunk/jmx/plugins/org.jboss.tools.jmx.core/src/org/jboss/tools/jmx/core/providers/DefaultConnectionProvider.java 2010-04-06
09:36:30 UTC (rev 21282)
@@ -91,6 +91,10 @@
public boolean canDelete(IConnectionWrapper wrapper) {
return wrapper instanceof DefaultConnectionWrapper;
}
+
+ public boolean canEdit(IConnectionWrapper wrapper) {
+ return wrapper instanceof DefaultConnectionWrapper;
+ }
public DefaultConnectionWrapper createConnection(Map map) throws CoreException {
String id = (String)map.get(ID);
@@ -151,6 +155,17 @@
}
}
}
+ public void connectionChanged(IConnectionWrapper connection) {
+ if( connection instanceof DefaultConnectionWrapper ) {
+ try {
+ save();
+ fireChanged(connection);
+ } catch( IOException ioe ) {
+ IStatus s = new Status(IStatus.ERROR, JMXActivator.PLUGIN_ID,
JMXCoreMessages.DefaultConnection_ErrorChanging, ioe);
+ JMXActivator.log(s);
+ }
+ }
+ }
protected void loadConnections() {
String filename =
JMXActivator.getDefault().getStateLocation().append(STORE_FILE).toOSString();
Modified:
trunk/jmx/plugins/org.jboss.tools.jmx.core/src/org/jboss/tools/jmx/core/providers/DefaultConnectionWrapper.java
===================================================================
---
trunk/jmx/plugins/org.jboss.tools.jmx.core/src/org/jboss/tools/jmx/core/providers/DefaultConnectionWrapper.java 2010-04-06
09:27:27 UTC (rev 21281)
+++
trunk/jmx/plugins/org.jboss.tools.jmx.core/src/org/jboss/tools/jmx/core/providers/DefaultConnectionWrapper.java 2010-04-06
09:36:30 UTC (rev 21282)
@@ -35,7 +35,6 @@
import org.jboss.tools.jmx.core.tree.Root;
public class DefaultConnectionWrapper implements IConnectionWrapper {
- private JMXServiceURL url;
private JMXConnector connector;
private MBeanServerConnection connection;
private Root root;
@@ -55,8 +54,6 @@
String[] credentials = new String[] { username, descriptor.getPassword() };
environment.put(JMXConnector.CREDENTIALS, credentials);
}
-
- url = new JMXServiceURL(descriptor.getURL());
}
public MBeanServerConnectionDescriptor getDescriptor() {
@@ -77,7 +74,7 @@
public synchronized void connect() throws IOException {
// try to connect
- connector = JMXConnectorFactory.connect(url, environment);
+ connector = JMXConnectorFactory.connect(new JMXServiceURL(descriptor.getURL()),
environment);
connection = connector.getMBeanServerConnection();
isConnected = true;
((DefaultConnectionProvider)getProvider()).fireChanged(this);
Modified:
trunk/jmx/plugins/org.jboss.tools.jmx.core/src/org/jboss/tools/jmx/core/providers/MBeanServerConnectionDescriptor.java
===================================================================
---
trunk/jmx/plugins/org.jboss.tools.jmx.core/src/org/jboss/tools/jmx/core/providers/MBeanServerConnectionDescriptor.java 2010-04-06
09:27:27 UTC (rev 21281)
+++
trunk/jmx/plugins/org.jboss.tools.jmx.core/src/org/jboss/tools/jmx/core/providers/MBeanServerConnectionDescriptor.java 2010-04-06
09:36:30 UTC (rev 21282)
@@ -17,10 +17,10 @@
private static final long serialVersionUID = -8358701879017195518L;
- private final String id;
- private final String url;
- private final String userName;
- private final String password;
+ private String id;
+ private String url;
+ private String userName;
+ private String password;
public MBeanServerConnectionDescriptor(
String id, String url,
@@ -31,6 +31,22 @@
this.password = password;
}
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ public void setUrl(String url) {
+ this.url = url;
+ }
+
+ public void setUserName(String userName) {
+ this.userName = userName;
+ }
+
+ public void setPassword(String password) {
+ this.password = password;
+ }
+
public String getID() {
return id;
}
Modified: trunk/jmx/plugins/org.jboss.tools.jmx.ui/plugin.xml
===================================================================
--- trunk/jmx/plugins/org.jboss.tools.jmx.ui/plugin.xml 2010-04-06 09:27:27 UTC (rev
21281)
+++ trunk/jmx/plugins/org.jboss.tools.jmx.ui/plugin.xml 2010-04-06 09:36:30 UTC (rev
21282)
@@ -253,6 +253,7 @@
<extension
point="org.jboss.tools.jmx.ui.providerUI">
<providerUI
+ editable="true"
icon="icons/full/obj16/write_obj.gif"
id="org.jboss.tools.jmx.core.providers.DefaultConnectionProvider"
name="%DefaultJMXConnectionProvider.name">
Modified: trunk/jmx/plugins/org.jboss.tools.jmx.ui/schema/providerUI.exsd
===================================================================
--- trunk/jmx/plugins/org.jboss.tools.jmx.ui/schema/providerUI.exsd 2010-04-06 09:27:27
UTC (rev 21281)
+++ trunk/jmx/plugins/org.jboss.tools.jmx.ui/schema/providerUI.exsd 2010-04-06 09:36:30
UTC (rev 21282)
@@ -2,9 +2,9 @@
<!-- Schema file written by PDE -->
<schema targetNamespace="org.jboss.tools.jmx.ui"
xmlns="http://www.w3.org/2001/XMLSchema">
<annotation>
- <appinfo>
+ <appInfo>
<meta.schema plugin="org.jboss.tools.jmx.ui"
id="org.jboss.tools.jmx.ui.wizards.connectionPage" name="Connection Wizard
Page"/>
- </appinfo>
+ </appInfo>
<documentation>
[Enter description of this extension point.]
</documentation>
@@ -12,9 +12,9 @@
<element name="extension">
<annotation>
- <appinfo>
+ <appInfo>
<meta.element />
- </appinfo>
+ </appInfo>
</annotation>
<complexType>
<sequence minOccurs="1" maxOccurs="unbounded">
@@ -39,9 +39,9 @@
<documentation>
</documentation>
- <appinfo>
+ <appInfo>
<meta.attribute translatable="true"/>
- </appinfo>
+ </appInfo>
</annotation>
</attribute>
</complexType>
@@ -71,11 +71,18 @@
<documentation>
</documentation>
- <appinfo>
+ <appInfo>
<meta.attribute kind="resource"/>
- </appinfo>
+ </appInfo>
</annotation>
</attribute>
+ <attribute name="editable" type="boolean">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
</complexType>
</element>
@@ -86,45 +93,45 @@
<documentation>
</documentation>
- <appinfo>
+ <appInfo>
<meta.attribute kind="java"
basedOn=":org.jboss.tools.jmx.ui.IWizardPageWithFinish"/>
- </appinfo>
+ </appInfo>
</annotation>
</attribute>
</complexType>
</element>
<annotation>
- <appinfo>
+ <appInfo>
<meta.section type="since"/>
- </appinfo>
+ </appInfo>
<documentation>
[Enter the first release in which this extension point appears.]
</documentation>
</annotation>
<annotation>
- <appinfo>
+ <appInfo>
<meta.section type="examples"/>
- </appinfo>
+ </appInfo>
<documentation>
[Enter extension point usage example here.]
</documentation>
</annotation>
<annotation>
- <appinfo>
+ <appInfo>
<meta.section type="apiinfo"/>
- </appinfo>
+ </appInfo>
<documentation>
[Enter API information here.]
</documentation>
</annotation>
<annotation>
- <appinfo>
+ <appInfo>
<meta.section type="implementation"/>
- </appinfo>
+ </appInfo>
<documentation>
[Enter information about supplied implementation of this extension point.]
</documentation>
Added:
trunk/jmx/plugins/org.jboss.tools.jmx.ui/src/org/jboss/tools/jmx/ui/IEditableConnectionWizardPage.java
===================================================================
---
trunk/jmx/plugins/org.jboss.tools.jmx.ui/src/org/jboss/tools/jmx/ui/IEditableConnectionWizardPage.java
(rev 0)
+++
trunk/jmx/plugins/org.jboss.tools.jmx.ui/src/org/jboss/tools/jmx/ui/IEditableConnectionWizardPage.java 2010-04-06
09:36:30 UTC (rev 21282)
@@ -0,0 +1,17 @@
+/*******************************************************************************
+ * Copyright (c) 2010 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.jmx.ui;
+
+import org.jboss.tools.jmx.core.IConnectionWrapper;
+
+public interface IEditableConnectionWizardPage extends ConnectionWizardPage {
+ public void setInitialConnection(IConnectionWrapper wrapper);
+}
Modified:
trunk/jmx/plugins/org.jboss.tools.jmx.ui/src/org/jboss/tools/jmx/ui/Messages.java
===================================================================
---
trunk/jmx/plugins/org.jboss.tools.jmx.ui/src/org/jboss/tools/jmx/ui/Messages.java 2010-04-06
09:27:27 UTC (rev 21281)
+++
trunk/jmx/plugins/org.jboss.tools.jmx.ui/src/org/jboss/tools/jmx/ui/Messages.java 2010-04-06
09:36:30 UTC (rev 21282)
@@ -11,6 +11,7 @@
public class Messages extends NLS {
public static String NewConnectionAction;
+ public static String EditConnectionAction;
public static String NewConnectionWizard;
public static String NewConnectionWizard_CreateNewConnection;
public static String DefaultConnectionWizardPage_Title;
Modified:
trunk/jmx/plugins/org.jboss.tools.jmx.ui/src/org/jboss/tools/jmx/ui/Messages.properties
===================================================================
---
trunk/jmx/plugins/org.jboss.tools.jmx.ui/src/org/jboss/tools/jmx/ui/Messages.properties 2010-04-06
09:27:27 UTC (rev 21281)
+++
trunk/jmx/plugins/org.jboss.tools.jmx.ui/src/org/jboss/tools/jmx/ui/Messages.properties 2010-04-06
09:36:30 UTC (rev 21282)
@@ -1,4 +1,5 @@
NewConnectionAction=New Connection...
+EditConnectionAction=Edit Connection...
NewConnectionWizard=New Connection Wizard
NewConnectionWizard_CreateNewConnection=Create a new JMX Connection
DefaultConnectionWizardPage_Title=Create JMX Connection
Modified:
trunk/jmx/plugins/org.jboss.tools.jmx.ui/src/org/jboss/tools/jmx/ui/UIExtensionManager.java
===================================================================
---
trunk/jmx/plugins/org.jboss.tools.jmx.ui/src/org/jboss/tools/jmx/ui/UIExtensionManager.java 2010-04-06
09:27:27 UTC (rev 21281)
+++
trunk/jmx/plugins/org.jboss.tools.jmx.ui/src/org/jboss/tools/jmx/ui/UIExtensionManager.java 2010-04-06
09:36:30 UTC (rev 21282)
@@ -34,14 +34,17 @@
private static final String NAME = "name"; //$NON-NLS-1$
private static final String ICON = "icon"; //$NON-NLS-1$
private static final String CLASS = "class"; //$NON-NLS-1$
+ private static final String EDITABLE = "editable"; //$NON-NLS-1$
public static class ConnectionProviderUI {
String id, name, icon;
+ boolean editable;
IConfigurationElement[] wizardPages;
ImageDescriptor imageDescriptor;
public ConnectionProviderUI(IConfigurationElement element) {
id = element.getAttribute(ID);
name = element.getAttribute(NAME);
icon = element.getAttribute(ICON);
+ editable = Boolean.parseBoolean(element.getAttribute(EDITABLE));
wizardPages = element.getChildren();
String pluginName = element.getDeclaringExtension().getContributor().getName();
imageDescriptor = AbstractUIPlugin.imageDescriptorFromPlugin(pluginName, icon);
@@ -55,6 +58,10 @@
public String getIcon() {
return icon;
}
+ public boolean isEditable() {
+ return editable;
+ }
+
public ImageDescriptor getImageDescriptor() {
return imageDescriptor;
}
Modified:
trunk/jmx/plugins/org.jboss.tools.jmx.ui/src/org/jboss/tools/jmx/ui/internal/views/navigator/ActionProvider.java
===================================================================
---
trunk/jmx/plugins/org.jboss.tools.jmx.ui/src/org/jboss/tools/jmx/ui/internal/views/navigator/ActionProvider.java 2010-04-06
09:27:27 UTC (rev 21281)
+++
trunk/jmx/plugins/org.jboss.tools.jmx.ui/src/org/jboss/tools/jmx/ui/internal/views/navigator/ActionProvider.java 2010-04-06
09:36:30 UTC (rev 21282)
@@ -13,7 +13,6 @@
import java.util.ArrayList;
import java.util.Iterator;
-
import org.eclipse.jface.action.IMenuManager;
import org.eclipse.jface.action.Separator;
import org.eclipse.jface.viewers.ISelection;
@@ -23,8 +22,11 @@
import org.eclipse.ui.navigator.ICommonActionConstants;
import org.eclipse.ui.navigator.ICommonActionExtensionSite;
import org.jboss.tools.jmx.core.IConnectionWrapper;
+import org.jboss.tools.jmx.ui.UIExtensionManager;
+import org.jboss.tools.jmx.ui.UIExtensionManager.ConnectionProviderUI;
import org.jboss.tools.jmx.ui.internal.actions.DeleteConnectionAction;
import org.jboss.tools.jmx.ui.internal.actions.DoubleClickAction;
+import org.jboss.tools.jmx.ui.internal.actions.EditConnectionAction;
import org.jboss.tools.jmx.ui.internal.actions.MBeanServerConnectAction;
import org.jboss.tools.jmx.ui.internal.actions.MBeanServerDisconnectAction;
import org.jboss.tools.jmx.ui.internal.actions.NewConnectionAction;
@@ -60,7 +62,12 @@
menu.add(new MBeanServerConnectAction(connections));
else if( allControlable(connections))
menu.add(new MBeanServerDisconnectAction(connections));
-
+ if( connections.length == 1 ) {
+ String id = connections[0].getProvider().getId();
+ ConnectionProviderUI ui = UIExtensionManager.getConnectionProviderUI(id);
+ if( ui != null && ui.isEditable() &&
!connections[0].isConnected())
+ menu.add(new EditConnectionAction(connections[0]));
+ }
menu.add(new DeleteConnectionAction(connections));
}
Modified:
trunk/jmx/plugins/org.jboss.tools.jmx.ui/src/org/jboss/tools/jmx/ui/internal/wizards/DefaultConnectionWizardPage.java
===================================================================
---
trunk/jmx/plugins/org.jboss.tools.jmx.ui/src/org/jboss/tools/jmx/ui/internal/wizards/DefaultConnectionWizardPage.java 2010-04-06
09:27:27 UTC (rev 21281)
+++
trunk/jmx/plugins/org.jboss.tools.jmx.ui/src/org/jboss/tools/jmx/ui/internal/wizards/DefaultConnectionWizardPage.java 2010-04-06
09:36:30 UTC (rev 21282)
@@ -14,7 +14,6 @@
import java.net.UnknownHostException;
import java.util.HashMap;
-
import org.eclipse.core.runtime.CoreException;
import org.eclipse.jface.wizard.WizardPage;
import org.eclipse.swt.SWT;
@@ -35,22 +34,29 @@
import org.jboss.tools.jmx.core.IConnectionProvider;
import org.jboss.tools.jmx.core.IConnectionWrapper;
import org.jboss.tools.jmx.core.providers.DefaultConnectionProvider;
-import org.jboss.tools.jmx.ui.ConnectionWizardPage;
+import org.jboss.tools.jmx.core.providers.DefaultConnectionWrapper;
+import org.jboss.tools.jmx.ui.IEditableConnectionWizardPage;
import org.jboss.tools.jmx.ui.Messages;
/**
* The connection page for the default wizard implementation.
*/
public class DefaultConnectionWizardPage extends WizardPage implements
- ConnectionWizardPage {
+ IEditableConnectionWizardPage {
private static final String _BLANK_ = ""; //$NON-NLS-1$
+ private static final String SIMPLE_PREFIX = "service:jmx:rmi:///jndi/rmi://";
//$NON-NLS-1$
+ private static final String SIMPLE_SUFFIX = "/jmxrmi"; //$NON-NLS-1$
private TabFolder folder;
private TabItem simpleItem, advancedItem;
private Text hostText, portText, urlText;
private Text nameText, userNameText, passwordText;
private Text advancedNameText, advancedUserNameText, advancedPasswordText;
private String name, url, userName, password;
-
+ private DefaultConnectionWrapper initialConnection;
+ public void setInitialConnection(IConnectionWrapper wrapper) {
+ this.initialConnection = (DefaultConnectionWrapper)wrapper;
+ }
+
private void addListeners() {
ModifyListener listener = new ModifyListener() {
public void modifyText(ModifyEvent e) {
@@ -120,7 +126,6 @@
nameLabel.setText(Messages.DefaultConnectionWizardPage_Name);
nameText = new Text(fieldComposite, SWT.BORDER);
- nameText.setText(getNextName());
data = new GridData(GridData.FILL_HORIZONTAL);
data.grabExcessHorizontalSpace = true;
nameText.setLayoutData(data);
@@ -131,7 +136,6 @@
// 2 host text entry
hostText = new Text(fieldComposite, SWT.BORDER);
- hostText.setText("localhost"); //$NON-NLS-1$
data = new GridData(GridData.FILL_HORIZONTAL);
data.grabExcessHorizontalSpace = true;
hostText.setLayoutData(data);
@@ -143,7 +147,6 @@
// 4 port text entry
portText = new Text(fieldComposite, SWT.BORDER);
portText.setTextLimit(5);
- portText.setText("3000"); //$NON-NLS-1$
data = new GridData(GridData.FILL_HORIZONTAL);
data.grabExcessHorizontalSpace = true;
portText.setLayoutData(data);
@@ -154,7 +157,6 @@
// 6 user name text entry
userNameText = new Text(fieldComposite, SWT.BORDER);
- userNameText.setText(_BLANK_);
data = new GridData(GridData.FILL_HORIZONTAL);
data.grabExcessHorizontalSpace = true;
@@ -166,13 +168,30 @@
// 8 user name text entry
passwordText = new Text(fieldComposite, SWT.BORDER | SWT.PASSWORD);
- passwordText.setText(_BLANK_);
data = new GridData(GridData.FILL_HORIZONTAL);
data.grabExcessHorizontalSpace = true;
passwordText.setLayoutData(data);
+
+ if( initialConnection == null ) {
+ nameText.setText(getNextName());
+ hostText.setText("localhost"); //$NON-NLS-1$
+ portText.setText("3000"); //$NON-NLS-1$
+ userNameText.setText(_BLANK_);
+ passwordText.setText(_BLANK_);
+ } else {
+ nameText.setText(initialConnection.getDescriptor().getID());
+ userNameText.setText(initialConnection.getDescriptor().getUserName());
+ passwordText.setText(initialConnection.getDescriptor().getPassword());
+ String url = initialConnection.getDescriptor().getURL();
+ if( url.startsWith(SIMPLE_PREFIX)) {
+ String host = url.substring(SIMPLE_PREFIX.length(), url.indexOf(":",
SIMPLE_PREFIX.length())); //$NON-NLS-1$
+ String port = url.substring(url.indexOf(":", SIMPLE_PREFIX.length())+1,
url.indexOf("/", SIMPLE_PREFIX.length()));//$NON-NLS-1$//$NON-NLS-2$
+ hostText.setText(host);
+ portText.setText(port);
+ }
+ }
return fieldComposite;
-
}
private Control createAdvancedConnectionPage(Composite parent) {
@@ -197,7 +216,6 @@
// 2 URL text entry
urlText = new Text(fieldComposite, SWT.BORDER);
- urlText.setText("service:jmx:rmi:"); //$NON-NLS-1$
data = new GridData(GridData.FILL_HORIZONTAL);
data.grabExcessHorizontalSpace = true;
urlText.setLayoutData(data);
@@ -208,7 +226,6 @@
// 4 user name text entry
advancedUserNameText = new Text(fieldComposite, SWT.BORDER);
- advancedUserNameText.setText(_BLANK_);
data = new GridData(GridData.FILL_HORIZONTAL);
data.grabExcessHorizontalSpace = true;
advancedUserNameText.setLayoutData(data);
@@ -220,11 +237,19 @@
// 6 user name text entry
advancedPasswordText = new Text(fieldComposite, SWT.BORDER
| SWT.PASSWORD);
- advancedPasswordText.setText(_BLANK_);
data = new GridData(GridData.FILL_HORIZONTAL);
data.grabExcessHorizontalSpace = true;
advancedPasswordText.setLayoutData(data);
+ if( initialConnection == null ) {
+ urlText.setText("service:jmx:rmi:"); //$NON-NLS-1$
+ advancedUserNameText.setText(_BLANK_);
+ advancedPasswordText.setText(_BLANK_);
+ } else {
+ urlText.setText(initialConnection.getDescriptor().getURL());
+ userNameText.setText(initialConnection.getDescriptor().getUserName());
+ passwordText.setText(initialConnection.getDescriptor().getPassword());
+ }
return fieldComposite;
}
@@ -241,7 +266,6 @@
}
protected void validate() {
- // TODO Validation
if (folder.getSelectionIndex() == 0) {
name = nameText.getText();
userName = userNameText.getText();
@@ -267,7 +291,7 @@
showError(Messages.DefaultConnectionWizardPage_Blank_Invalid);
return;
}
- url = "service:jmx:rmi:///jndi/rmi://" + host + ":" + port +
"/jmxrmi"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ url = SIMPLE_PREFIX + host + ":" + port + SIMPLE_SUFFIX; //$NON-NLS-1$
} else if (folder.getSelectionIndex() == 1) {
name = advancedNameText.getText();
userName = advancedUserNameText.getText();
@@ -315,35 +339,32 @@
protected boolean nameTaken(String s) {
IConnectionProvider provider =
ExtensionManager.getProvider(DefaultConnectionProvider.PROVIDER_ID);
- IConnectionWrapper[] connections = provider.getConnections();
- for( int i = 0; i < connections.length; i++ ) {
- if( provider.getName(connections[i]).equals(s)) {
- return true;
+ if( initialConnection == null || !s.equals(provider.getName(initialConnection))) {
+ IConnectionWrapper[] connections = provider.getConnections();
+ for( int i = 0; i < connections.length; i++ ) {
+ if( provider.getName(connections[i]).equals(s)) {
+ return true;
+ }
}
}
return false;
}
- String getURL() {
- return url;
- }
-
- String getUserName() {
- return userName;
- }
-
- String getPassword() {
- return password;
- }
-
public IConnectionWrapper getConnection() throws CoreException {
- HashMap<String,String> map = new HashMap<String,String>();
- map.put(DefaultConnectionProvider.ID, name);
- map.put(DefaultConnectionProvider.URL, url);
- map.put(DefaultConnectionProvider.USERNAME, userName);
- map.put(DefaultConnectionProvider.PASSWORD, password);
- IConnectionProvider provider =
ExtensionManager.getProvider(DefaultConnectionProvider.PROVIDER_ID);
-
- return provider.createConnection(map);
+ if( initialConnection == null ) {
+ HashMap<String,String> map = new HashMap<String,String>();
+ map.put(DefaultConnectionProvider.ID, name);
+ map.put(DefaultConnectionProvider.URL, url);
+ map.put(DefaultConnectionProvider.USERNAME, userName);
+ map.put(DefaultConnectionProvider.PASSWORD, password);
+ IConnectionProvider provider =
ExtensionManager.getProvider(DefaultConnectionProvider.PROVIDER_ID);
+
+ return provider.createConnection(map);
+ }
+ initialConnection.getDescriptor().setId(name);
+ initialConnection.getDescriptor().setUrl(url);
+ initialConnection.getDescriptor().setUserName(userName);
+ initialConnection.getDescriptor().setPassword(password);
+ return initialConnection;
}
}
Modified:
trunk/jmx/tests/org.jboss.tools.jmx.core.test/src/org/jboss/tools/jmx/core/test/DefaultProviderTest.java
===================================================================
---
trunk/jmx/tests/org.jboss.tools.jmx.core.test/src/org/jboss/tools/jmx/core/test/DefaultProviderTest.java 2010-04-06
09:27:27 UTC (rev 21281)
+++
trunk/jmx/tests/org.jboss.tools.jmx.core.test/src/org/jboss/tools/jmx/core/test/DefaultProviderTest.java 2010-04-06
09:36:30 UTC (rev 21282)
@@ -109,8 +109,7 @@
ExtensionManager.getProvider(DefaultConnectionProvider.PROVIDER_ID);
HashMap map = new HashMap();
map.put(DefaultConnectionProvider.ID, "Test Connection");
- map.put(DefaultConnectionProvider.URL,
"service:jmx:rmi:///jndi/rmi://localhost:9999" +
- "/jmxrmi");
+ map.put(DefaultConnectionProvider.URL,
"service:jmx:rmi:///jndi/rmi://localhost:9999/jmxrmi");
map.put(DefaultConnectionProvider.USERNAME, "");
map.put(DefaultConnectionProvider.PASSWORD, "");
IConnectionWrapper wrapper = defProvider.createConnection(map);