Author: rob.stryker(a)jboss.com
Date: 2010-12-14 04:47:38 -0500 (Tue, 14 Dec 2010)
New Revision: 27435
Added:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.integration/plugin.properties
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.integration/plugin.xml
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.integration/schema/
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.integration/src/org/jboss/tools/deltacloud/integration/DeltaCloudIntegrationPlugin.java
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.integration/src/org/jboss/tools/deltacloud/integration/Messages.java
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.integration/src/org/jboss/tools/deltacloud/integration/messages.properties
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.integration/src/org/jboss/tools/deltacloud/integration/rse/
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.integration/src/org/jboss/tools/deltacloud/integration/rse/util/
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.integration/src/org/jboss/tools/deltacloud/integration/rse/util/RSEUtils.java
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.integration/src/org/jboss/tools/deltacloud/integration/rse/util/ShowInRemoteSystemExplorerHandler.java
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.integration/src/org/jboss/tools/deltacloud/integration/wizard/
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.integration/src/org/jboss/tools/deltacloud/integration/wizard/RSEandASWizardPage.java
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/schema/
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/schema/newInstanceWizardPage.exsd
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/DeltacloudUIExtensionManager.java
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/INewInstanceWizardPage.java
Log:
"JBIDE-7889 deltacloud integration stuff"
Added: trunk/deltacloud/plugins/org.jboss.tools.deltacloud.integration/plugin.properties
===================================================================
--- trunk/deltacloud/plugins/org.jboss.tools.deltacloud.integration/plugin.properties
(rev 0)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.integration/plugin.properties 2010-12-14
09:47:38 UTC (rev 27435)
@@ -0,0 +1,3 @@
+command.showInRemoteSysExplorer=Show in Remote System Explorer...
+command.showInRemoteSysExplorer.tooltip=Show in Remote System Explorer...
+command.showInRemoteSysExplorer.description=Show in Remote System Explorer
\ No newline at end of file
Added: trunk/deltacloud/plugins/org.jboss.tools.deltacloud.integration/plugin.xml
===================================================================
--- trunk/deltacloud/plugins/org.jboss.tools.deltacloud.integration/plugin.xml
(rev 0)
+++ trunk/deltacloud/plugins/org.jboss.tools.deltacloud.integration/plugin.xml 2010-12-14
09:47:38 UTC (rev 27435)
@@ -0,0 +1,73 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.4"?>
+<plugin>
+ <!-- Show in remote system explorer handler -->
+ <extension
+ point="org.eclipse.ui.handlers">
+ <handler
+
class="org.jboss.tools.deltacloud.integration.rse.util.ShowInRemoteSystemExplorerHandler"
+
commandId="org.jboss.tools.deltacloud.integration.rse.showremotesysexplorer">
+ <activeWhen>
+ <with
+ variable="selection">
+ <iterate operator="and">
+ <and>
+ <adapt
+
type="org.jboss.tools.deltacloud.core.DeltaCloudInstance">
+ <test property="org.jboss.tools.deltacloud.ui.commands.isRunning"
+ value="true"/>
+ </adapt>
+ </and>
+ </iterate>
+ </with>
+ </activeWhen>
+ <enabledWhen>
+ <with
+ variable="selection">
+ <count value="+" />
+ </with>
+ </enabledWhen>
+ </handler>
+ </extension>
+ <extension
+ point="org.eclipse.ui.commands">
+ <command
+ description="%command.showInRemoteSysExplorer.description"
+
id="org.jboss.tools.deltacloud.integration.rse.showremotesysexplorer"
+ name="%command.showInRemoteSysExplorer">
+ </command>
+ </extension>
+ <extension point="org.eclipse.ui.menus">
+ <menuContribution
+ allPopups="true"
+
locationURI="popup:org.jboss.tools.deltacloud.ui.views.InstanceView?after=additions">
+ <command
+
commandId="org.jboss.tools.deltacloud.integration.rse.showremotesysexplorer"
+ disabledIcon="icons/system_viewd.gif"
+ icon="icons/system_view.gif"
+ label="%command.showInRemoteSysExplorer"
+ style="push"
+ tooltip="%command.showInRemoteSysExplorer.tooltip">
+ </command>
+ </menuContribution>
+ </extension>
+ <menuContribution
+ allPopups="true"
+
locationURI="toolbar:org.jboss.tools.deltacloud.ui.views.InstanceView?after=instances">
+ <command
+
commandId="org.jboss.tools.deltacloud.integration.rse.showremotesysexplorer"
+ disabledIcon="icons/system_viewd.gif"
+ icon="icons/system_view.gif"
+ label="%command.showInRemoteSysExplorer"
+ style="push"
+ tooltip="%command.showInRemoteSysExplorer.tooltip">
+ </command>
+ </menuContribution>
+ <extension
+ point="org.jboss.tools.deltacloud.ui.newInstanceWizardPage">
+ <page
+
class="org.jboss.tools.deltacloud.integration.wizard.RSEandASWizardPage"
+ id="org.jboss.tools.deltacloud.integration.RSEandASPage">
+ </page>
+ </extension>
+</plugin>
Added:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.integration/src/org/jboss/tools/deltacloud/integration/DeltaCloudIntegrationPlugin.java
===================================================================
---
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.integration/src/org/jboss/tools/deltacloud/integration/DeltaCloudIntegrationPlugin.java
(rev 0)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.integration/src/org/jboss/tools/deltacloud/integration/DeltaCloudIntegrationPlugin.java 2010-12-14
09:47:38 UTC (rev 27435)
@@ -0,0 +1,47 @@
+package org.jboss.tools.deltacloud.integration;
+
+import org.eclipse.core.runtime.Plugin;
+import org.osgi.framework.BundleContext;
+
+public class DeltaCloudIntegrationPlugin extends Plugin {
+
+ // The plug-in ID
+ public static final String PLUGIN_ID =
"org.jboss.tools.deltacloud.integration";
+
+ // The shared instance
+ private static DeltaCloudIntegrationPlugin plugin;
+
+ /**
+ * The constructor
+ */
+ public DeltaCloudIntegrationPlugin() {
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.core.runtime.Plugins#start(org.osgi.framework.BundleContext)
+ */
+ public void start(BundleContext context) throws Exception {
+ super.start(context);
+ plugin = this;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.core.runtime.Plugin#stop(org.osgi.framework.BundleContext)
+ */
+ public void stop(BundleContext context) throws Exception {
+ plugin = null;
+ super.stop(context);
+ }
+
+ /**
+ * Returns the shared instance
+ *
+ * @return the shared instance
+ */
+ public static DeltaCloudIntegrationPlugin getDefault() {
+ return plugin;
+ }
+
+}
Added:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.integration/src/org/jboss/tools/deltacloud/integration/Messages.java
===================================================================
---
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.integration/src/org/jboss/tools/deltacloud/integration/Messages.java
(rev 0)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.integration/src/org/jboss/tools/deltacloud/integration/Messages.java 2010-12-14
09:47:38 UTC (rev 27435)
@@ -0,0 +1,18 @@
+package org.jboss.tools.deltacloud.integration;
+
+import org.eclipse.osgi.util.NLS;
+
+public class Messages {
+ private static final String BUNDLE_NAME = DeltaCloudIntegrationPlugin.PLUGIN_ID +
".Messages"; //$NON-NLS-1$
+
+ public static String ERROR;
+ public static String COULD_NOT_LAUNCH_RSE_EXPLORER;
+ public static String COULD_NOT_LAUNCH_RSE_EXPLORER2;
+ public static String RSE_CONNECTING_MESSAGE;
+
+ static {
+ NLS.initializeMessages(BUNDLE_NAME, Messages.class);
+ }
+ private Messages() {
+ }
+}
Added:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.integration/src/org/jboss/tools/deltacloud/integration/messages.properties
===================================================================
---
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.integration/src/org/jboss/tools/deltacloud/integration/messages.properties
(rev 0)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.integration/src/org/jboss/tools/deltacloud/integration/messages.properties 2010-12-14
09:47:38 UTC (rev 27435)
@@ -0,0 +1,4 @@
+RSE_CONNECTING_MESSAGE=Connecting instance as: {0}
+COULD_NOT_LAUNCH_RSE_EXPLORER=Could not open remote system explorer
+COULD_NOT_LAUNCH_RSE_EXPLORER2=Could not launch remote system explorer for instance
"{0}"
+ERROR=Error
\ No newline at end of file
Added:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.integration/src/org/jboss/tools/deltacloud/integration/rse/util/RSEUtils.java
===================================================================
---
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.integration/src/org/jboss/tools/deltacloud/integration/rse/util/RSEUtils.java
(rev 0)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.integration/src/org/jboss/tools/deltacloud/integration/rse/util/RSEUtils.java 2010-12-14
09:47:38 UTC (rev 27435)
@@ -0,0 +1,162 @@
+/*******************************************************************************
+ * 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.deltacloud.integration.rse.util;
+
+import java.text.MessageFormat;
+
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.jobs.IJobChangeEvent;
+import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.core.runtime.jobs.JobChangeAdapter;
+import org.eclipse.jface.dialogs.ErrorDialog;
+import org.eclipse.osgi.util.NLS;
+import org.eclipse.rse.core.IRSECoreRegistry;
+import org.eclipse.rse.core.IRSESystemType;
+import org.eclipse.rse.core.RSECorePlugin;
+import org.eclipse.rse.core.model.IHost;
+import org.eclipse.rse.core.model.ISystemRegistry;
+import org.eclipse.rse.core.model.SystemStartHere;
+import org.eclipse.rse.core.subsystems.IConnectorService;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.ui.PartInitException;
+import org.jboss.tools.deltacloud.core.DeltaCloudInstance;
+import org.jboss.tools.deltacloud.integration.DeltaCloudIntegrationPlugin;
+import org.jboss.tools.deltacloud.integration.Messages;
+import org.jboss.tools.internal.deltacloud.ui.utils.UIUtils;
+
+/**
+ * @author André Dietisheim
+ */
+public class RSEUtils {
+
+ private static final String VIEW_REMOTESYSEXPLORER_ID =
"org.eclipse.rse.ui.view.systemView";
+
+ public static IRSESystemType getSSHOnlySystemType() {
+ IRSESystemType sshType = null;
+ RSECorePlugin rsep = RSECorePlugin.getDefault();
+ IRSECoreRegistry coreRegistry = rsep.getCoreRegistry();
+ IRSESystemType[] sysTypes = coreRegistry.getSystemTypes();
+ for (IRSESystemType sysType : sysTypes) {
+ if (sysType.getId().equals(IRSESystemType.SYSTEMTYPE_SSH_ONLY_ID))
+ sshType = sysType;
+ }
+ Assert.isTrue(sshType != null,
+ "Remote System Explorer could not initialize SSH subsystem: ssh type not
found");
+ return sshType;
+ }
+
+ public static ISystemRegistry getSystemRegistry() {
+ return SystemStartHere.getSystemRegistry();
+ }
+
+ public static String createConnectionName(DeltaCloudInstance instance) {
+ Assert.isLegal(instance != null, "Cannot create connection name: instance is not
defined");
+ return instance.getName() + " [" + instance.getId() + "]";
//$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ public static String createHostName(DeltaCloudInstance instance) {
+ Assert.isLegal(instance != null, "Cannot get hostname: instance is not
defined");
+
+ String hostName = instance.getHostName();
+ System.out.println(instance.getHostName());
+ Assert.isTrue(hostName != null && hostName.length() > 0,
+ MessageFormat.format("Cannot get host name: not defined for instance {0}",
instance.getName()));
+ return hostName;
+ }
+
+ public static IHost createHost(String connectionName, String hostname, IRSESystemType
systemType,
+ ISystemRegistry systemRegistry) throws Exception {
+ // TODO: Internationalize strings
+ Assert.isLegal(connectionName != null && connectionName.length() > 0,
+ "Cannot create Host: connectionName is not defined");
+ Assert.isLegal(hostname != null && hostname.length() > 0, "Cannot
create Host: hostname is not defined");
+ Assert.isLegal(systemType != null, "Cannot create Host: system type is not
defined");
+ Assert.isLegal(systemRegistry != null, "Cannot create Host: system registry is not
defined");
+
+ IHost host = systemRegistry.createHost(systemType, connectionName, hostname, null);
+ host.setDefaultUserId("root"); //$NON-NLS-1$
+ return host;
+ }
+
+ public static IConnectorService getConnectorService(IHost host) {
+ IConnectorService[] services = host.getConnectorServices();
+ if (services == null || services.length <= 0) {
+ return null;
+ }
+ return services[0];
+ }
+
+ public static Job connect(String connectionName, final IConnectorService service)
+ throws Exception {
+ // TODO: internationalize strings
+ Assert.isLegal(connectionName != null,
+ "Remote System Explorer could not connect: connection name is not
defined");
+ Assert.isLegal(service != null, "Remote System Explorer could not connect:
connector service not found.");
+
+ Job job = new Job(NLS.bind(Messages.RSE_CONNECTING_MESSAGE, connectionName)) {
+ @Override
+ protected IStatus run(IProgressMonitor monitor) {
+ try {
+ monitor.worked(1);
+ service.connect(monitor);
+ monitor.done();
+ return Status.OK_STATUS;
+ } catch (Exception e) {
+ // odd behavior: service reports connection failure even if things seem to work
(view opens up with connection in it)
+ // ignore errors since things work
+ //
+ // return StatusFactory.getInstance(IStatus.ERROR,
+ // Activator.PLUGIN_ID, e.getMessage(), e);
+ return Status.OK_STATUS;
+ }
+ }
+ };
+ job.setUser(true);
+ job.schedule();
+ return job;
+ }
+
+ public static void showRemoteSystemExplorer(Job job) {
+ job.addJobChangeListener(new JobChangeAdapter() {
+
+ @Override
+ public void done(IJobChangeEvent event) {
+ super.done(event);
+ showRemoteSystemExplorer();
+ }
+ });
+ }
+
+ public static void showRemoteSystemExplorer() {
+ Display.getDefault().asyncExec(new Runnable() {
+
+ @Override
+ public void run() {
+ try {
+ UIUtils.showView(VIEW_REMOTESYSEXPLORER_ID);
+ } catch (PartInitException e) {
+ // I have no idea wtf is wrong here
+ // but my dev environment will not let me use common classes
+// IStatus status = StatusFactory.getInstance(IStatus.ERROR,
+// DeltaCloudIntegrationPlugin.PLUGIN_ID, e.getMessage(), e);
+ Status status = new Status(IStatus.ERROR, DeltaCloudIntegrationPlugin.PLUGIN_ID,
e.getMessage(), e);
+ ErrorDialog.openError(UIUtils.getActiveShell(),
+ Messages.ERROR,
+ Messages.COULD_NOT_LAUNCH_RSE_EXPLORER,
+ status);
+ }
+ }
+ });
+ }
+}
Added:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.integration/src/org/jboss/tools/deltacloud/integration/rse/util/ShowInRemoteSystemExplorerHandler.java
===================================================================
---
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.integration/src/org/jboss/tools/deltacloud/integration/rse/util/ShowInRemoteSystemExplorerHandler.java
(rev 0)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.integration/src/org/jboss/tools/deltacloud/integration/rse/util/ShowInRemoteSystemExplorerHandler.java 2010-12-14
09:47:38 UTC (rev 27435)
@@ -0,0 +1,55 @@
+/*******************************************************************************
+ * 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.deltacloud.integration.rse.util;
+
+import org.eclipse.core.commands.AbstractHandler;
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.commands.IHandler;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.rse.core.model.IHost;
+import org.eclipse.ui.handlers.HandlerUtil;
+import org.jboss.tools.deltacloud.core.DeltaCloudInstance;
+import org.jboss.tools.deltacloud.integration.DeltaCloudIntegrationPlugin;
+import org.jboss.tools.deltacloud.integration.Messages;
+import org.jboss.tools.internal.deltacloud.ui.utils.UIUtils;
+
+/**
+ * @author Andre Dietisheim
+ */
+public class ShowInRemoteSystemExplorerHandler extends AbstractHandler implements
IHandler {
+
+ @Override
+ public Object execute(ExecutionEvent event) throws ExecutionException {
+ ISelection selection = HandlerUtil.getCurrentSelection(event);
+ if (selection instanceof IStructuredSelection) {
+ DeltaCloudInstance instance = UIUtils.getFirstAdaptedElement(selection,
DeltaCloudInstance.class);
+ try {
+ String connectionName = RSEUtils.createConnectionName(instance);
+ IHost host = RSEUtils.createHost(connectionName,
+ RSEUtils.createHostName(instance),
+ RSEUtils.getSSHOnlySystemType(),
+ RSEUtils.getSystemRegistry());
+ Job connectJob = RSEUtils.connect(connectionName,
RSEUtils.getConnectorService(host));
+ RSEUtils.showRemoteSystemExplorer(connectJob);
+ } catch (Exception e) {
+ return new Status(IStatus.ERROR, DeltaCloudIntegrationPlugin.PLUGIN_ID,
+ Messages.COULD_NOT_LAUNCH_RSE_EXPLORER2, e);
+ }
+ }
+
+ return Status.OK_STATUS;
+ }
+}
Added:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.integration/src/org/jboss/tools/deltacloud/integration/wizard/RSEandASWizardPage.java
===================================================================
---
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.integration/src/org/jboss/tools/deltacloud/integration/wizard/RSEandASWizardPage.java
(rev 0)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.integration/src/org/jboss/tools/deltacloud/integration/wizard/RSEandASWizardPage.java 2010-12-14
09:47:38 UTC (rev 27435)
@@ -0,0 +1,130 @@
+package org.jboss.tools.deltacloud.integration.wizard;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.preferences.IEclipsePreferences;
+import org.eclipse.core.runtime.preferences.InstanceScope;
+import org.eclipse.jface.wizard.WizardPage;
+import org.eclipse.osgi.util.NLS;
+import org.eclipse.rse.core.model.IHost;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.layout.FormLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Widget;
+import org.jboss.tools.common.jobs.ChainedJob;
+import org.jboss.tools.deltacloud.core.DeltaCloudInstance;
+import org.jboss.tools.deltacloud.integration.DeltaCloudIntegrationPlugin;
+import org.jboss.tools.deltacloud.integration.Messages;
+import org.jboss.tools.deltacloud.integration.rse.util.RSEUtils;
+import org.jboss.tools.deltacloud.ui.Activator;
+import org.jboss.tools.deltacloud.ui.ErrorUtils;
+import org.jboss.tools.deltacloud.ui.IDeltaCloudPreferenceConstants;
+import org.jboss.tools.deltacloud.ui.INewInstanceWizardPage;
+import org.jboss.tools.internal.deltacloud.ui.utils.UIUtils;
+import org.osgi.service.prefs.BackingStoreException;
+import org.osgi.service.prefs.Preferences;
+
+public class RSEandASWizardPage extends WizardPage implements INewInstanceWizardPage {
+
+ private Button createRSE;
+ private Button createServer;
+ private final static String CREATE_RSE_PREF_KEY =
"org.jboss.tools.deltacloud.integration.wizard.RSEandASWizard.CREATE_RSE_PREF_KEY";
+ private final static String CREATE_SERVER_PREF_KEY =
"org.jboss.tools.deltacloud.integration.wizard.RSEandASWizard.CREATE_SERVER_PREF_KEY";
+
+ public RSEandASWizardPage() {
+ super("Blah Wizard Page");
+ setTitle("Blah Title");
+ setDescription("Blah Desc");
+ }
+
+ public void createControl(Composite parent) {
+ Composite c2 = new Composite(parent, SWT.NONE);
+ c2.setLayout(new FormLayout());
+ createRSE = new Button(c2, SWT.CHECK);
+ createRSE.setText("Create RSE Connection");
+ createRSE.setLayoutData(UIUtils.createFormData(0, 5, null, 0, 0, 5, 100, -5));
+ createServer = new Button(c2, SWT.CHECK);
+ createServer.setText("Create Server Adapter");
+ createServer.setLayoutData(UIUtils.createFormData(createRSE, 5, null, 0, 0, 5, 100,
-5));
+
+ IEclipsePreferences prefs = new
InstanceScope().getNode(DeltaCloudIntegrationPlugin.PLUGIN_ID);
+ boolean initRSE, initServer;
+ initRSE = prefs.getBoolean(CREATE_RSE_PREF_KEY, true);
+ initServer = prefs.getBoolean(CREATE_SERVER_PREF_KEY, true);
+ createRSE.setSelection(initRSE);
+ createServer.setSelection(initServer);
+
+ SelectionListener listener = new SelectionListener(){
+ public void widgetSelected(SelectionEvent e) {
+ handleSelection(e.widget);
+ }
+ public void widgetDefaultSelected(SelectionEvent e) {
+ handleSelection(e.widget);
+ }
+ };
+
+ createRSE.addSelectionListener(listener);
+ createServer.addSelectionListener(listener);
+ setControl(c2);
+ }
+
+ private void handleSelection(Widget w) {
+ if( w == createRSE ) {
+ if( !createRSE.getSelection()) {
+ createServer.setEnabled(false);
+ createServer.setSelection(false);
+ } else {
+ createServer.setEnabled(true);
+ }
+ }
+ }
+
+ public ChainedJob getPerformFinishJob(final DeltaCloudInstance instance) {
+ IEclipsePreferences prefs = new
InstanceScope().getNode(DeltaCloudIntegrationPlugin.PLUGIN_ID);
+ prefs.putBoolean(CREATE_RSE_PREF_KEY, createRSE.getSelection());
+ prefs.putBoolean(CREATE_SERVER_PREF_KEY, createServer.getSelection());
+ try {
+ prefs.flush();
+ } catch (BackingStoreException e1) {
+ // ignore
+ }
+
+ ChainedJob j = new ChainedJob("Register RSE Connection",
INewInstanceWizardPage.NEW_INSTANCE_FAMILY) {
+ public IStatus run(IProgressMonitor monitor) {
+ return runJob(instance, monitor);
+ }
+ };
+ return j;
+ }
+
+
+ private IStatus runJob(DeltaCloudInstance instance, IProgressMonitor monitor) {
+ String hostname = RSEUtils.createHostName(instance);
+ if (hostname != null && hostname.length() > 0 && isAutoconnect()) {
+ try {
+ String connectionName = RSEUtils.createConnectionName(instance);
+ IHost host = RSEUtils.createHost(connectionName,
+ RSEUtils.createHostName(instance),
+ RSEUtils.getSSHOnlySystemType(),
+ RSEUtils.getSystemRegistry());
+ RSEUtils.connect(connectionName, RSEUtils.getConnectorService(host));
+ } catch (Exception e) {
+ return ErrorUtils.handleError(Messages.ERROR,
+ NLS.bind(Messages.COULD_NOT_LAUNCH_RSE_EXPLORER2, instance.getName()),
+ e, getShell());
+ }
+ }
+ return Status.OK_STATUS;
+ }
+
+ private boolean isAutoconnect() {
+ Preferences prefs = new InstanceScope().getNode(Activator.PLUGIN_ID);
+ boolean autoConnect =
prefs.getBoolean(IDeltaCloudPreferenceConstants.AUTO_CONNECT_INSTANCE, true);
+ return autoConnect;
+ }
+
+}
Added:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/schema/newInstanceWizardPage.exsd
===================================================================
---
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/schema/newInstanceWizardPage.exsd
(rev 0)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/schema/newInstanceWizardPage.exsd 2010-12-14
09:47:38 UTC (rev 27435)
@@ -0,0 +1,111 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<!-- Schema file written by PDE -->
+<schema targetNamespace="org.jboss.tools.deltacloud.ui"
xmlns="http://www.w3.org/2001/XMLSchema">
+<annotation>
+ <appinfo>
+ <meta.schema plugin="org.jboss.tools.deltacloud.ui"
+ id="newInstanceWizardPage"
+ name="org.jboss.tools.deltacloud.ui.newInstanceWizardPage"/>
+ </appinfo>
+ <documentation>
+ [Enter description of this extension point.]
+ </documentation>
+ </annotation>
+
+ <element name="extension">
+ <annotation>
+ <appinfo>
+ <meta.element />
+ </appinfo>
+ </annotation>
+ <complexType>
+ <sequence>
+ <element ref="page" minOccurs="1"
maxOccurs="unbounded"/>
+ </sequence>
+ <attribute name="point" type="string"
use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="id" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="name" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ <appinfo>
+ <meta.attribute translatable="true"/>
+ </appinfo>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <element name="page">
+ <complexType>
+ <attribute name="id" type="string"
use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="class" type="string"
use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ <appinfo>
+ <meta.attribute kind="java"
basedOn=":org.jboss.tools.deltacloud.ui.INewInstanceWizardPage"/>
+ </appinfo>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <annotation>
+ <appinfo>
+ <meta.section type="since"/>
+ </appinfo>
+ <documentation>
+ [Enter the first release in which this extension point appears.]
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appinfo>
+ <meta.section type="examples"/>
+ </appinfo>
+ <documentation>
+ [Enter extension point usage example here.]
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appinfo>
+ <meta.section type="apiinfo"/>
+ </appinfo>
+ <documentation>
+ [Enter API information here.]
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appinfo>
+ <meta.section type="implementation"/>
+ </appinfo>
+ <documentation>
+ [Enter information about supplied implementation of this extension point.]
+ </documentation>
+ </annotation>
+
+
+</schema>
Added:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/DeltacloudUIExtensionManager.java
===================================================================
---
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/DeltacloudUIExtensionManager.java
(rev 0)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/DeltacloudUIExtensionManager.java 2010-12-14
09:47:38 UTC (rev 27435)
@@ -0,0 +1,52 @@
+/*******************************************************************************
+ * Copyright (c) 2010 Red Hat Inc..
+ * All rights reserved. This program and the accompanying materials
+ * are 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 Incorporated - initial API and implementation
+ *******************************************************************************/
+package org.jboss.tools.deltacloud.ui;
+
+import java.util.ArrayList;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.IExtensionRegistry;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.jface.wizard.WizardPage;
+
+
+public class DeltacloudUIExtensionManager {
+ /** Singleton instance of the manager */
+ private static DeltacloudUIExtensionManager instance;
+
+ /** Singleton getter */
+ public static DeltacloudUIExtensionManager getDefault() {
+ if( instance == null )
+ instance = new DeltacloudUIExtensionManager();
+ return instance;
+ }
+
+ public INewInstanceWizardPage[] loadNewInstanceWizardPages() {
+ ArrayList<WizardPage> pages = new ArrayList<WizardPage>();
+ IExtensionRegistry registry = Platform.getExtensionRegistry();
+ IConfigurationElement[] cf = registry.getConfigurationElementsFor(Activator.PLUGIN_ID,
"newInstanceWizardPage"); //$NON-NLS-1$
+ Object o = null;
+ for( int i = 0; i < cf.length; i++ ) {
+ o = null;
+ try {
+ o = cf[i].createExecutableExtension("class");
+ } catch(CoreException ce) {
+ ce.printStackTrace();
+ }
+ if( o != null ) {
+ pages.add((WizardPage)o);
+ }
+ }
+ return (INewInstanceWizardPage[]) pages.toArray(new
INewInstanceWizardPage[pages.size()]);
+ }
+
+}
Added:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/INewInstanceWizardPage.java
===================================================================
---
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/INewInstanceWizardPage.java
(rev 0)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/INewInstanceWizardPage.java 2010-12-14
09:47:38 UTC (rev 27435)
@@ -0,0 +1,20 @@
+/*******************************************************************************
+ * Copyright (c) 2010 Red Hat Inc..
+ * All rights reserved. This program and the accompanying materials
+ * are 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 Incorporated - initial API and implementation
+ *******************************************************************************/
+package org.jboss.tools.deltacloud.ui;
+
+import org.eclipse.jface.wizard.IWizardPage;
+import org.jboss.tools.common.jobs.ChainedJob;
+import org.jboss.tools.deltacloud.core.DeltaCloudInstance;
+
+public interface INewInstanceWizardPage extends IWizardPage {
+ public static final String NEW_INSTANCE_FAMILY = "newInstanceFamily";
+ public ChainedJob getPerformFinishJob(DeltaCloudInstance addedInstance);
+}