Author: rob.stryker(a)jboss.com
Date: 2010-04-06 05:26:35 -0400 (Tue, 06 Apr 2010)
New Revision: 21280
Added:
branches/jbosstools-3.1.x/jmx/plugins/org.jboss.tools.jmx.ui/src/org/jboss/tools/jmx/ui/IEditableConnectionWizardPage.java
branches/jbosstools-3.1.x/jmx/plugins/org.jboss.tools.jmx.ui/src/org/jboss/tools/jmx/ui/internal/actions/EditConnectionAction.java
branches/jbosstools-3.1.x/jmx/plugins/org.jboss.tools.jmx.ui/src/org/jboss/tools/jmx/ui/internal/wizards/EditConnectionWizard.java
Modified:
branches/jbosstools-3.1.x/jmx/plugins/org.jboss.tools.jmx.ui/src/org/jboss/tools/jmx/ui/Messages.java
branches/jbosstools-3.1.x/jmx/plugins/org.jboss.tools.jmx.ui/src/org/jboss/tools/jmx/ui/Messages.properties
branches/jbosstools-3.1.x/jmx/plugins/org.jboss.tools.jmx.ui/src/org/jboss/tools/jmx/ui/UIExtensionManager.java
branches/jbosstools-3.1.x/jmx/plugins/org.jboss.tools.jmx.ui/src/org/jboss/tools/jmx/ui/internal/views/navigator/ActionProvider.java
branches/jbosstools-3.1.x/jmx/plugins/org.jboss.tools.jmx.ui/src/org/jboss/tools/jmx/ui/internal/wizards/DefaultConnectionWizardPage.java
Log:
JBIDE-4927 weird commit errors
Added:
branches/jbosstools-3.1.x/jmx/plugins/org.jboss.tools.jmx.ui/src/org/jboss/tools/jmx/ui/IEditableConnectionWizardPage.java
===================================================================
---
branches/jbosstools-3.1.x/jmx/plugins/org.jboss.tools.jmx.ui/src/org/jboss/tools/jmx/ui/IEditableConnectionWizardPage.java
(rev 0)
+++
branches/jbosstools-3.1.x/jmx/plugins/org.jboss.tools.jmx.ui/src/org/jboss/tools/jmx/ui/IEditableConnectionWizardPage.java 2010-04-06
09:26:35 UTC (rev 21280)
@@ -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:
branches/jbosstools-3.1.x/jmx/plugins/org.jboss.tools.jmx.ui/src/org/jboss/tools/jmx/ui/Messages.java
===================================================================
---
branches/jbosstools-3.1.x/jmx/plugins/org.jboss.tools.jmx.ui/src/org/jboss/tools/jmx/ui/Messages.java 2010-04-06
09:24:46 UTC (rev 21279)
+++
branches/jbosstools-3.1.x/jmx/plugins/org.jboss.tools.jmx.ui/src/org/jboss/tools/jmx/ui/Messages.java 2010-04-06
09:26:35 UTC (rev 21280)
@@ -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:
branches/jbosstools-3.1.x/jmx/plugins/org.jboss.tools.jmx.ui/src/org/jboss/tools/jmx/ui/Messages.properties
===================================================================
---
branches/jbosstools-3.1.x/jmx/plugins/org.jboss.tools.jmx.ui/src/org/jboss/tools/jmx/ui/Messages.properties 2010-04-06
09:24:46 UTC (rev 21279)
+++
branches/jbosstools-3.1.x/jmx/plugins/org.jboss.tools.jmx.ui/src/org/jboss/tools/jmx/ui/Messages.properties 2010-04-06
09:26:35 UTC (rev 21280)
@@ -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:
branches/jbosstools-3.1.x/jmx/plugins/org.jboss.tools.jmx.ui/src/org/jboss/tools/jmx/ui/UIExtensionManager.java
===================================================================
---
branches/jbosstools-3.1.x/jmx/plugins/org.jboss.tools.jmx.ui/src/org/jboss/tools/jmx/ui/UIExtensionManager.java 2010-04-06
09:24:46 UTC (rev 21279)
+++
branches/jbosstools-3.1.x/jmx/plugins/org.jboss.tools.jmx.ui/src/org/jboss/tools/jmx/ui/UIExtensionManager.java 2010-04-06
09:26:35 UTC (rev 21280)
@@ -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;
}
Added:
branches/jbosstools-3.1.x/jmx/plugins/org.jboss.tools.jmx.ui/src/org/jboss/tools/jmx/ui/internal/actions/EditConnectionAction.java
===================================================================
---
branches/jbosstools-3.1.x/jmx/plugins/org.jboss.tools.jmx.ui/src/org/jboss/tools/jmx/ui/internal/actions/EditConnectionAction.java
(rev 0)
+++
branches/jbosstools-3.1.x/jmx/plugins/org.jboss.tools.jmx.ui/src/org/jboss/tools/jmx/ui/internal/actions/EditConnectionAction.java 2010-04-06
09:26:35 UTC (rev 21280)
@@ -0,0 +1,33 @@
+/*******************************************************************************
+ * 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.internal.actions;
+
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.wizard.WizardDialog;
+import org.eclipse.swt.widgets.Shell;
+import org.jboss.tools.jmx.core.IConnectionWrapper;
+import org.jboss.tools.jmx.ui.Messages;
+import org.jboss.tools.jmx.ui.internal.wizards.EditConnectionWizard;
+
+public class EditConnectionAction extends Action {
+ private IConnectionWrapper connection;
+ public EditConnectionAction(IConnectionWrapper connection) {
+ this.connection = connection;
+ //setImageDescriptor(PlatformUI.getWorkbench().getSharedImages().getImageDescriptor(key));
+ setEnabled(true);
+ setText(Messages.EditConnectionAction);
+ }
+ public void run() {
+ EditConnectionWizard wizard = new EditConnectionWizard(connection);
+ WizardDialog d = new WizardDialog(new Shell(), wizard);
+ d.open();
+ }
+}
Modified:
branches/jbosstools-3.1.x/jmx/plugins/org.jboss.tools.jmx.ui/src/org/jboss/tools/jmx/ui/internal/views/navigator/ActionProvider.java
===================================================================
---
branches/jbosstools-3.1.x/jmx/plugins/org.jboss.tools.jmx.ui/src/org/jboss/tools/jmx/ui/internal/views/navigator/ActionProvider.java 2010-04-06
09:24:46 UTC (rev 21279)
+++
branches/jbosstools-3.1.x/jmx/plugins/org.jboss.tools.jmx.ui/src/org/jboss/tools/jmx/ui/internal/views/navigator/ActionProvider.java 2010-04-06
09:26:35 UTC (rev 21280)
@@ -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:
branches/jbosstools-3.1.x/jmx/plugins/org.jboss.tools.jmx.ui/src/org/jboss/tools/jmx/ui/internal/wizards/DefaultConnectionWizardPage.java
===================================================================
---
branches/jbosstools-3.1.x/jmx/plugins/org.jboss.tools.jmx.ui/src/org/jboss/tools/jmx/ui/internal/wizards/DefaultConnectionWizardPage.java 2010-04-06
09:24:46 UTC (rev 21279)
+++
branches/jbosstools-3.1.x/jmx/plugins/org.jboss.tools.jmx.ui/src/org/jboss/tools/jmx/ui/internal/wizards/DefaultConnectionWizardPage.java 2010-04-06
09:26:35 UTC (rev 21280)
@@ -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;
}
}
Added:
branches/jbosstools-3.1.x/jmx/plugins/org.jboss.tools.jmx.ui/src/org/jboss/tools/jmx/ui/internal/wizards/EditConnectionWizard.java
===================================================================
---
branches/jbosstools-3.1.x/jmx/plugins/org.jboss.tools.jmx.ui/src/org/jboss/tools/jmx/ui/internal/wizards/EditConnectionWizard.java
(rev 0)
+++
branches/jbosstools-3.1.x/jmx/plugins/org.jboss.tools.jmx.ui/src/org/jboss/tools/jmx/ui/internal/wizards/EditConnectionWizard.java 2010-04-06
09:26:35 UTC (rev 21280)
@@ -0,0 +1,57 @@
+/*******************************************************************************
+ * 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.internal.wizards;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.jface.wizard.Wizard;
+import org.jboss.tools.jmx.core.IConnectionWrapper;
+import org.jboss.tools.jmx.ui.ConnectionWizardPage;
+import org.jboss.tools.jmx.ui.IEditableConnectionWizardPage;
+import org.jboss.tools.jmx.ui.UIExtensionManager;
+import org.jboss.tools.jmx.ui.UIExtensionManager.ConnectionProviderUI;
+
+public class EditConnectionWizard extends Wizard {
+ private IConnectionWrapper connection;
+ public EditConnectionWizard(IConnectionWrapper connection) {
+ super();
+ this.connection = connection;
+ }
+ public String getWindowTitle() {
+ return "TEST TITLE"; //$NON-NLS-1$
+ }
+
+ public void addPages() {
+ ConnectionProviderUI ui =
UIExtensionManager.getConnectionProviderUI(connection.getProvider().getId());
+ ConnectionWizardPage[] pages = ui.createPages();
+ for( int j = 0; j < pages.length; j++ )
+ if( pages[j] instanceof IEditableConnectionWizardPage) {
+ ((IEditableConnectionWizardPage)pages[j]).setInitialConnection(connection);
+ addPage(pages[j]);
+ }
+ }
+
+ @Override
+ public boolean performFinish() {
+ try {
+ IConnectionWrapper xinda = ((ConnectionWizardPage)getPages()[0]).getConnection();
+ if( xinda == connection)
+ connection.getProvider().connectionChanged(connection);
+ else {
+ connection.getProvider().removeConnection(connection);
+ connection.getProvider().addConnection(xinda);
+ }
+ return true;
+ } catch( CoreException ce) {
+ }
+ return false;
+ }
+
+}