Author: rob.stryker(a)jboss.com
Date: 2010-04-06 05:37:38 -0400 (Tue, 06 Apr 2010)
New Revision: 21283
Added:
trunk/jmx/plugins/org.jboss.tools.jmx.ui/src/org/jboss/tools/jmx/ui/internal/actions/EditConnectionAction.java
trunk/jmx/plugins/org.jboss.tools.jmx.ui/src/org/jboss/tools/jmx/ui/internal/wizards/EditConnectionWizard.java
Log:
JBIDE-4927 to trunk
Added:
trunk/jmx/plugins/org.jboss.tools.jmx.ui/src/org/jboss/tools/jmx/ui/internal/actions/EditConnectionAction.java
===================================================================
---
trunk/jmx/plugins/org.jboss.tools.jmx.ui/src/org/jboss/tools/jmx/ui/internal/actions/EditConnectionAction.java
(rev 0)
+++
trunk/jmx/plugins/org.jboss.tools.jmx.ui/src/org/jboss/tools/jmx/ui/internal/actions/EditConnectionAction.java 2010-04-06
09:37:38 UTC (rev 21283)
@@ -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();
+ }
+}
Added:
trunk/jmx/plugins/org.jboss.tools.jmx.ui/src/org/jboss/tools/jmx/ui/internal/wizards/EditConnectionWizard.java
===================================================================
---
trunk/jmx/plugins/org.jboss.tools.jmx.ui/src/org/jboss/tools/jmx/ui/internal/wizards/EditConnectionWizard.java
(rev 0)
+++
trunk/jmx/plugins/org.jboss.tools.jmx.ui/src/org/jboss/tools/jmx/ui/internal/wizards/EditConnectionWizard.java 2010-04-06
09:37:38 UTC (rev 21283)
@@ -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;
+ }
+
+}