Author: adietish
Date: 2010-11-15 18:26:40 -0500 (Mon, 15 Nov 2010)
New Revision: 26589
Added:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/ErrorUtils.java
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/RSEUtils.java
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/ShowRSEViewRunnable.java
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/NewCloudConnectionWizard.java
Removed:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/NewCloudConnection.java
Modified:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/ChangeLog
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/DeltaCloud.java
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/ChangeLog
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/plugin.xml
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/commands/NewConnectionHandler.java
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/commands/RefreshInstancesHandler.java
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/commands/ShowInRemoteSystemExplorerHandler.java
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/InstanceView.java
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/PerformDestroyInstanceActionThread.java
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/PerformInstanceActionThread.java
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/NewInstanceModel.java
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/NewInstanceWizard.java
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/NewInstanceWizard2.java
Log:
[JBIDE-7603] removed lot of duplicate code, added error dialog when failing to open remote
system explorer
Modified: trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/ChangeLog
===================================================================
--- trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/ChangeLog 2010-11-15 22:55:00
UTC (rev 26588)
+++ trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/ChangeLog 2010-11-15 23:26:40
UTC (rev 26589)
@@ -1,3 +1,13 @@
+2010-11-16 André Dietisheim <adietish(a)redhat.com>
+
+ * src/org/jboss/tools/deltacloud/core/DeltaCloud.java (registerInstanceJob):
+ (getInstanceJob):
+ (registerInstanceJob):
+ (removeInstanceJob):
+ [JBIDE-7603] renamed instance job related methods from action job to instance job (since
jobs are not only used for actions)
+ (waitWhilePending):
+ [JBIDE-7603] moved (duplicate) instance state waiting code to delta cloud and removed
duplication
+
2010-11-11 André Dietisheim <adietish(a)redhat.com>
* src/org/jboss/tools/deltacloud/core/DeltaCloudInstance.java (DeltaCloudInstance):
Modified:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/DeltaCloud.java
===================================================================
---
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/DeltaCloud.java 2010-11-15
22:55:00 UTC (rev 26588)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/DeltaCloud.java 2010-11-15
23:26:40 UTC (rev 26589)
@@ -18,6 +18,7 @@
import java.util.Map;
import java.util.regex.PatternSyntaxException;
+import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.ListenerList;
import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.equinox.security.storage.EncodingUtils;
@@ -256,7 +257,7 @@
((IImageListListener) listeners[i]).listChanged(this, array);
}
- public Job getActionJob(String id) {
+ public Job getInstanceJob(String id) {
synchronized (actionLock) {
Job j = null;
if (actionJobs != null) {
@@ -266,7 +267,7 @@
}
}
- public void registerActionJob(String id, Job j) {
+ public void registerInstanceJob(String id, Job j) {
synchronized (actionLock) {
if (actionJobs == null)
actionJobs = new HashMap<String, Job>();
@@ -274,7 +275,19 @@
}
}
- public void removeActionJob(String id, Job j) {
+ public DeltaCloudInstance waitWhilePending(String instanceId, IProgressMonitor pm)
throws InterruptedException {
+ DeltaCloudInstance instance = null;
+ while (!pm.isCanceled()) {
+ instance = refreshInstance(instanceId);
+ if (instance != null &&
!instance.getState().equals(DeltaCloudInstance.PENDING)) {
+ return instance;
+ }
+ Thread.sleep(400);
+ }
+ return instance;
+ }
+
+ public void removeInstanceJob(String id, Job j) {
synchronized (actionLock) {
if (actionJobs != null && actionJobs.get(id) == j)
actionJobs.remove(id);
Modified: trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/ChangeLog
===================================================================
--- trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/ChangeLog 2010-11-15 22:55:00
UTC (rev 26588)
+++ trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/ChangeLog 2010-11-15 23:26:40
UTC (rev 26589)
@@ -1,3 +1,13 @@
+2010-11-16 André Dietisheim <adietish(a)redhat.com>
+
+ * src/org/jboss/tools/internal/deltacloud/ui/wizards/NewInstanceWizard2.java
(WatchCreateJob.run):
+ * src/org/jboss/tools/internal/deltacloud/ui/wizards/NewInstanceWizard.java
(WatchCreateJob.run):
+ [JBIDE-7603] moved (duplicate) instance state waiting code to delta cloud and removed
duplication
+ * src/org/jboss/tools/deltacloud/ui/commands/ShowInRemoteSystemExplorerHandler.java
(execute):
+ [JBIDE-7603] unified RSE related (duplicate) code with code in NewConnectionHandler2
+ * src/org/jboss/tools/internal/deltacloud/ui/wizards/NewCloudConnectionWizard.java:
+ [JBIDE-7603] renamed NewCloudConnection to NewCloudConnectionWizard (since it is a
wizard)
+
2010-11-15 André Dietisheim <adietish(a)redhat.com>
* src/org/jboss/tools/deltacloud/ui/commands/ShowInRemoteSystemExplorerHandler.java
(launchRemoteSystemExplorer):
Modified: trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/plugin.xml
===================================================================
--- trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/plugin.xml 2010-11-15 22:55:00
UTC (rev 26588)
+++ trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/plugin.xml 2010-11-15 23:26:40
UTC (rev 26589)
@@ -78,7 +78,7 @@
</category>
<wizard
category="org.jboss.tools.deltacloud.ui.wizard.category"
-
class="org.jboss.tools.internal.deltacloud.ui.wizards.NewCloudConnection"
+
class="org.jboss.tools.internal.deltacloud.ui.wizards.NewCloudConnectionWizard"
icon="icons/delta.gif"
id="org.jboss.tools.deltacloud.ui.connection.wizard"
name="%NewWizard.name">
Added:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/ErrorUtils.java
===================================================================
---
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/ErrorUtils.java
(rev 0)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/ErrorUtils.java 2010-11-15
23:26:40 UTC (rev 26589)
@@ -0,0 +1,30 @@
+/*******************************************************************************
+ * 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.ui;
+
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.jface.dialogs.ErrorDialog;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Shell;
+import org.jboss.tools.common.log.StatusFactory;
+
+public class ErrorUtils {
+ public static IStatus openErrorDialog(final String title, final String message,
Exception e, final Shell shell) {
+ final IStatus status = StatusFactory.getInstance(IStatus.ERROR, Activator.PLUGIN_ID,
e.getMessage(), e);
+ // TODO: internationalize strings
+ Display.getDefault().syncExec(new Runnable() {
+ public void run() {
+ ErrorDialog.openError(shell, title, message, status);
+ }
+ });
+ return status;
+ }
+}
Property changes on:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/ErrorUtils.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/RSEUtils.java
===================================================================
---
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/RSEUtils.java
(rev 0)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/RSEUtils.java 2010-11-15
23:26:40 UTC (rev 26589)
@@ -0,0 +1,105 @@
+/*******************************************************************************
+ * 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.ui;
+
+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.Job;
+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.jboss.tools.common.log.StatusFactory;
+import org.jboss.tools.deltacloud.core.DeltaCloudInstance;
+import org.jboss.tools.deltacloud.ui.views.CVMessages;
+
+public class RSEUtils {
+
+ private final static String RSE_CONNECTING_MSG = "ConnectingRSE.msg";
//$NON-NLS-1$
+
+ 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;
+ }
+ return sshType;
+ }
+
+ public static ISystemRegistry getSystemRegistry() {
+ return SystemStartHere.getSystemRegistry();
+ }
+
+ public static String createConnectionName(DeltaCloudInstance instance) {
+ return instance.getName() + " [" + instance.getId() + "]";
//$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ public static String createHostName(DeltaCloudInstance instance) {
+ return instance.getHostName();
+ }
+
+ public static IHost createHost(String connectionName, String hostname) throws Exception
{
+ ISystemRegistry registry = getSystemRegistry();
+ IRSESystemType sshOnlySystemType = getSSHOnlySystemType();
+ // TODO: Internationalize string
+ Assert.isTrue(sshOnlySystemType != null,
+ "Remote System Explorer could not initialize SSH subsystem: ssh type not
found");
+ IHost host = registry.createHost(sshOnlySystemType, 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 void connect(final String instanceName, final IConnectorService service,
String connectionName) {
+ // TODO: internationalize strings
+ Assert.isLegal(service != null, "Remote System Explorer could not connect:
connector service not found.");
+ Job connect = new Job(CVMessages.getFormattedString(RSE_CONNECTING_MSG,
connectionName)) {
+ @Override
+ protected IStatus run(IProgressMonitor monitor) {
+ try {
+ service.connect(monitor);
+ Display.getDefault().asyncExec(new ShowRSEViewRunnable(instanceName));
+ return Status.OK_STATUS;
+ } catch (Exception e) {
+ return StatusFactory.getInstance(IStatus.ERROR, Activator.PLUGIN_ID, e.getMessage(),
e);
+ }
+ }
+ };
+ connect.setUser(true);
+ connect.schedule();
+ }
+
+ public static void launchRemoteSystemExplorer(String instanceName, String
connectionName, IHost host) throws Exception {
+ if (host != null) {
+ IConnectorService service = RSEUtils.getConnectorService(host);
+ RSEUtils.connect(instanceName, service, connectionName);
+ } else {
+ // Assume failure is due to name already in use
+ Display.getDefault().asyncExec(new ShowRSEViewRunnable(instanceName));
+ }
+ }
+}
Property changes on:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/RSEUtils.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/ShowRSEViewRunnable.java
===================================================================
---
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/ShowRSEViewRunnable.java
(rev 0)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/ShowRSEViewRunnable.java 2010-11-15
23:26:40 UTC (rev 26589)
@@ -0,0 +1,44 @@
+/*******************************************************************************
+ * 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.ui;
+
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.jface.dialogs.ErrorDialog;
+import org.eclipse.ui.PartInitException;
+import org.eclipse.ui.PlatformUI;
+import org.jboss.tools.common.log.StatusFactory;
+
+public class ShowRSEViewRunnable implements Runnable {
+
+ private static final String VIEW_REMOTESYSEXPLORER_ID =
"org.eclipse.rse.ui.view.systemView";
+
+ private String instanceName;
+
+ public ShowRSEViewRunnable(String instanceName) {
+ this.instanceName = instanceName;
+ }
+
+ @Override
+ public void run() {
+ try {
+ PlatformUI.getWorkbench().getActiveWorkbenchWindow()
+ .getActivePage()
+ .showView(VIEW_REMOTESYSEXPLORER_ID);
+ } catch (PartInitException e) {
+ IStatus status = StatusFactory.getInstance(IStatus.ERROR, Activator.PLUGIN_ID,
e.getMessage(), e);
+ // TODO: internationalize strings
+ ErrorDialog.openError(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(),
+ "Error",
+ "Could not launch remote system explorer for instance \"" +
instanceName + "\"",
+ status);
+ }
+ }
+}
Property changes on:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/ShowRSEViewRunnable.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/commands/NewConnectionHandler.java
===================================================================
---
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/commands/NewConnectionHandler.java 2010-11-15
22:55:00 UTC (rev 26588)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/commands/NewConnectionHandler.java 2010-11-15
23:26:40 UTC (rev 26589)
@@ -17,7 +17,7 @@
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.jface.wizard.WizardDialog;
import org.eclipse.ui.PlatformUI;
-import org.jboss.tools.internal.deltacloud.ui.wizards.NewCloudConnection;
+import org.jboss.tools.internal.deltacloud.ui.wizards.NewCloudConnectionWizard;
/**
* @author Andre Dietisheim
@@ -26,7 +26,7 @@
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
- NewCloudConnection wizard = new NewCloudConnection();
+ NewCloudConnectionWizard wizard = new NewCloudConnectionWizard();
wizard.init(PlatformUI.getWorkbench(), new StructuredSelection());
WizardDialog dialog = new
WizardDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(),
wizard);
Modified:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/commands/RefreshInstancesHandler.java
===================================================================
---
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/commands/RefreshInstancesHandler.java 2010-11-15
22:55:00 UTC (rev 26588)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/commands/RefreshInstancesHandler.java 2010-11-15
23:26:40 UTC (rev 26589)
@@ -44,10 +44,10 @@
}
private void refresh(final DeltaCloudInstance deltaCloudInstance) {
- // TODO: internationalize strings
if (deltaCloudInstance != null) {
final DeltaCloud cloud = deltaCloudInstance.getDeltaCloud();
if (cloud != null) {
+ // TODO: internationalize strings
new Job("Refreshing instances on cloud " + cloud.getName()) {
@Override
@@ -56,11 +56,8 @@
cloud.loadChildren();
return Status.OK_STATUS;
} catch (Exception e) {
- IStatus status = StatusFactory.getInstance(
- IStatus.ERROR,
- Activator.PLUGIN_ID,
- e.getMessage(),
- e);
+ IStatus status = StatusFactory.getInstance(IStatus.ERROR, Activator.PLUGIN_ID,
+ e.getMessage(), e);
return status;
}
}
Modified:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/commands/ShowInRemoteSystemExplorerHandler.java
===================================================================
---
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/commands/ShowInRemoteSystemExplorerHandler.java 2010-11-15
22:55:00 UTC (rev 26588)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/commands/ShowInRemoteSystemExplorerHandler.java 2010-11-15
23:26:40 UTC (rev 26589)
@@ -14,30 +14,18 @@
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.core.commands.IHandler;
-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.Job;
import org.eclipse.jface.dialogs.ErrorDialog;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
-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.swt.widgets.Shell;
-import org.eclipse.ui.PartInitException;
-import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.handlers.HandlerUtil;
import org.jboss.tools.common.log.StatusFactory;
import org.jboss.tools.deltacloud.core.DeltaCloudInstance;
import org.jboss.tools.deltacloud.ui.Activator;
-import org.jboss.tools.deltacloud.ui.views.CVMessages;
+import org.jboss.tools.deltacloud.ui.RSEUtils;
import org.jboss.tools.internal.deltacloud.ui.utils.UIUtils;
/**
@@ -45,9 +33,6 @@
*/
public class ShowInRemoteSystemExplorerHandler extends AbstractHandler implements
IHandler {
- private static final String VIEW_REMOTESYSEXPLORER_ID =
"org.eclipse.rse.ui.view.systemView";
- private final static String RSE_CONNECTING_MSG = "ConnectingRSE.msg";
//$NON-NLS-1$
-
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
ISelection selection = HandlerUtil.getCurrentSelection(event);
@@ -55,86 +40,19 @@
DeltaCloudInstance instance = UIUtils.getFirstAdaptedElement(selection,
DeltaCloudInstance.class);
Shell shell = HandlerUtil.getActiveShell(event);
try {
- launchRemoteSystemExplorer(instance, shell);
+ String connectionName = RSEUtils.createConnectionName(instance);
+ IHost host = RSEUtils.createHost(connectionName, RSEUtils.createHostName(instance));
+ RSEUtils.launchRemoteSystemExplorer(instance.getName(), connectionName, host);
} catch (Exception e) {
- return showCannotLaunchRSEErrorDialog(instance, shell, e);
+ IStatus status = StatusFactory.getInstance(IStatus.ERROR, Activator.PLUGIN_ID,
e.getMessage(), e);
+ // TODO: internationalize strings
+ ErrorDialog.openError(shell, "Error",
+ "Could not launch remote system explorer for instance \"" +
instance.getName() + "\"",
+ status);
+ return status;
}
}
return Status.OK_STATUS;
}
-
- private void launchRemoteSystemExplorer(final DeltaCloudInstance instance, final Shell
shell) throws Exception {
- String hostname = instance.getHostName();
- IRSESystemType sshType = getRSESystemType();
- // TODO: internationalize string
- Assert.isTrue(sshType != null, "Remote System Explorer could not initialize SSH
subsystem: ssh type not found");
- String connectionName = instance.getName() + " [" + instance.getId() +
"]"; //$NON-NLS-1$ //$NON-NLS-2$
- ISystemRegistry registry = SystemStartHere.getSystemRegistry();
- IHost host = registry.createHost(sshType, connectionName, hostname, null);
- if (host != null) {
- host.setDefaultUserId("root"); //$NON-NLS-1$
- IConnectorService[] services = host.getConnectorServices();
- if (services.length > 0) {
- final IConnectorService service = services[0];
- Job connect = new Job(CVMessages.getFormattedString(RSE_CONNECTING_MSG,
connectionName)) {
- @Override
- protected IStatus run(IProgressMonitor monitor) {
- try {
- service.connect(monitor);
- Display.getDefault().asyncExec(showRSEViewRunnable(instance, shell));
- return Status.OK_STATUS;
- } catch (Exception e) {
- return StatusFactory.getInstance(IStatus.ERROR, Activator.PLUGIN_ID,
e.getMessage(), e);
- }
- }
- };
- connect.setUser(true);
- connect.schedule();
- }
- } else {
- // Assume failure is due to name already in use
- shell.getDisplay().asyncExec(showRSEViewRunnable(instance, shell));
- }
- }
-
- private IRSESystemType getRSESystemType() {
- 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;
- }
- return sshType;
- }
-
- private IStatus showCannotLaunchRSEErrorDialog(final DeltaCloudInstance instance, final
Shell shell,
- Exception e) {
- IStatus status = StatusFactory.getInstance(IStatus.ERROR, Activator.PLUGIN_ID,
e.getMessage(), e);
- // TODO: internationalize strings
- ErrorDialog.openError(shell,
- "Error",
- "Could not launch remote system explorer for instance \"" +
instance.getName() + "\"",
- status);
- return status;
- }
-
- private Runnable showRSEViewRunnable(final DeltaCloudInstance instance, final Shell
shell) {
-
- return new Runnable() {
- @Override
- public void run() {
- try {
- PlatformUI.getWorkbench().getActiveWorkbenchWindow()
- .getActivePage()
- .showView(VIEW_REMOTESYSEXPLORER_ID);
- } catch (PartInitException e) {
- showCannotLaunchRSEErrorDialog(instance, shell, e);
- }
- }
- };
- }
-
}
Modified:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/InstanceView.java
===================================================================
---
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/InstanceView.java 2010-11-15
22:55:00 UTC (rev 26588)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/InstanceView.java 2010-11-15
23:26:40 UTC (rev 26589)
@@ -308,16 +308,16 @@
cloudSelector.addModifyListener(cloudModifyListener);
}
- public void listChanged(DeltaCloud cloud, DeltaCloudInstance[] list) {
+ public void listChanged(DeltaCloud cloud, final DeltaCloudInstance[] instances) {
// Run following under Display thread since this can be
// triggered by a non-display thread notifying listeners.
- final DeltaCloudInstance[] finalList = list;
if (cloud.getName().equals(currCloud.getName())) {
Display.getDefault().syncExec(new Runnable() {
@Override
public void run() {
currCloud.removeInstanceListListener(parentView);
- viewer.setInput(finalList);
+
+ viewer.setInput(instances);
currCloud.addInstanceListListener(parentView);
viewer.refresh();
refreshToolbarCommandStates();
Modified:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/PerformDestroyInstanceActionThread.java
===================================================================
---
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/PerformDestroyInstanceActionThread.java 2010-11-15
22:55:00 UTC (rev 26588)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/PerformDestroyInstanceActionThread.java 2010-11-15
23:26:40 UTC (rev 26589)
@@ -29,7 +29,7 @@
pm.worked(1);
// To handle the user starting a new action when we haven't confirmed the last one
yet,
// cancel the previous job and then go on performing this action
- Job job = cloud.getActionJob(id);
+ Job job = cloud.getInstanceJob(id);
if (job != null) {
job.cancel();
try {
@@ -38,7 +38,7 @@
// do nothing, this is ok
}
}
- cloud.registerActionJob(id, this);
+ cloud.registerInstanceJob(id, this);
Display.getDefault().asyncExec(new Runnable() {
@Override
public void run() {
@@ -46,7 +46,7 @@
}
});
} finally {
- cloud.removeActionJob(id, this);
+ cloud.removeInstanceJob(id, this);
pm.done();
}
return Status.OK_STATUS;
Modified:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/PerformInstanceActionThread.java
===================================================================
---
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/PerformInstanceActionThread.java 2010-11-15
22:55:00 UTC (rev 26588)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/PerformInstanceActionThread.java 2010-11-15
23:26:40 UTC (rev 26589)
@@ -71,14 +71,14 @@
});
} finally {
- cloud.removeActionJob(id, this);
+ cloud.removeInstanceJob(id, this);
pm.done();
}
return Status.OK_STATUS;
}
private void cancelPreviousJob(String id) {
- Job job = cloud.getActionJob(id);
+ Job job = cloud.getInstanceJob(id);
if (job != null) {
job.cancel();
try {
Deleted:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/NewCloudConnection.java
===================================================================
---
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/NewCloudConnection.java 2010-11-15
22:55:00 UTC (rev 26588)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/NewCloudConnection.java 2010-11-15
23:26:40 UTC (rev 26589)
@@ -1,94 +0,0 @@
-/*******************************************************************************
- * 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.internal.deltacloud.ui.wizards;
-
-import java.net.MalformedURLException;
-
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.jface.dialogs.ErrorDialog;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.wizard.Wizard;
-import org.eclipse.ui.INewWizard;
-import org.eclipse.ui.IWorkbench;
-import org.jboss.tools.common.log.StatusFactory;
-import org.jboss.tools.deltacloud.core.DeltaCloud;
-import org.jboss.tools.deltacloud.core.DeltaCloudManager;
-import org.jboss.tools.deltacloud.core.client.DeltaCloudClientException;
-import org.jboss.tools.deltacloud.ui.Activator;
-
-public class NewCloudConnection extends Wizard implements INewWizard, CloudConnection {
-
- private static final String MAINPAGE_NAME = "NewCloudConnection.name";
//$NON-NLS-1$
- private CloudConnectionPage mainPage;
-
- public NewCloudConnection() {
- super();
- }
-
- @Override
- public void init(IWorkbench workbench, IStructuredSelection selection) {
- }
-
- @Override
- public void addPages() {
- mainPage = new CloudConnectionPage(WizardMessages.getString(MAINPAGE_NAME), this);
- addPage(mainPage);
- }
-
- @Override
- public boolean canFinish() {
- return mainPage.isPageComplete();
- }
-
- public boolean performTest() {
- String name = mainPage.getName();
- String url = mainPage.getModel().getUrl();
- String username = mainPage.getModel().getUsername();
- String password = mainPage.getModel().getPassword();
- try {
- DeltaCloud newCloud = new DeltaCloud(name, url, username, password);
- return newCloud.testConnection();
- } catch (MalformedURLException e) {
- Activator.log(e);
- return false;
- } catch (DeltaCloudClientException e) {
- IStatus status = StatusFactory.getInstance(IStatus.ERROR, Activator.PLUGIN_ID,
e.getMessage(), e);
- Activator.log(status);
- ErrorDialog.openError(
- getShell(),
- WizardMessages.getString("CloudConnectionAuthError.title"),
- WizardMessages.getFormattedString("CloudConnectionAuthError.message",
url),
- status);
- return true;
- }
- }
-
- @Override
- public boolean performFinish() {
- String name = mainPage.getModel().getName();
- String url = mainPage.getModel().getUrl();
- String username = mainPage.getModel().getUsername();
- String password = mainPage.getModel().getPassword();
- String type = mainPage.getModel().getType().toString();
- try {
- DeltaCloud newCloud = new DeltaCloud(name, url, username, password, type, true);
- DeltaCloudManager.getDefault().addCloud(newCloud);
- } catch (MalformedURLException e) {
- Activator.log(e);
- }
- return true;
- }
-
- @Override
- public boolean needsProgressMonitor() {
- return true;
- }
-}
Copied:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/NewCloudConnectionWizard.java
(from rev 26556,
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/NewCloudConnection.java)
===================================================================
---
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/NewCloudConnectionWizard.java
(rev 0)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/NewCloudConnectionWizard.java 2010-11-15
23:26:40 UTC (rev 26589)
@@ -0,0 +1,94 @@
+/*******************************************************************************
+ * 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.internal.deltacloud.ui.wizards;
+
+import java.net.MalformedURLException;
+
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.jface.dialogs.ErrorDialog;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.wizard.Wizard;
+import org.eclipse.ui.INewWizard;
+import org.eclipse.ui.IWorkbench;
+import org.jboss.tools.common.log.StatusFactory;
+import org.jboss.tools.deltacloud.core.DeltaCloud;
+import org.jboss.tools.deltacloud.core.DeltaCloudManager;
+import org.jboss.tools.deltacloud.core.client.DeltaCloudClientException;
+import org.jboss.tools.deltacloud.ui.Activator;
+
+public class NewCloudConnectionWizard extends Wizard implements INewWizard,
CloudConnection {
+
+ private static final String MAINPAGE_NAME = "NewCloudConnection.name";
//$NON-NLS-1$
+ private CloudConnectionPage mainPage;
+
+ public NewCloudConnectionWizard() {
+ super();
+ }
+
+ @Override
+ public void init(IWorkbench workbench, IStructuredSelection selection) {
+ }
+
+ @Override
+ public void addPages() {
+ mainPage = new CloudConnectionPage(WizardMessages.getString(MAINPAGE_NAME), this);
+ addPage(mainPage);
+ }
+
+ @Override
+ public boolean canFinish() {
+ return mainPage.isPageComplete();
+ }
+
+ public boolean performTest() {
+ String name = mainPage.getName();
+ String url = mainPage.getModel().getUrl();
+ String username = mainPage.getModel().getUsername();
+ String password = mainPage.getModel().getPassword();
+ try {
+ DeltaCloud newCloud = new DeltaCloud(name, url, username, password);
+ return newCloud.testConnection();
+ } catch (MalformedURLException e) {
+ Activator.log(e);
+ return false;
+ } catch (DeltaCloudClientException e) {
+ IStatus status = StatusFactory.getInstance(IStatus.ERROR, Activator.PLUGIN_ID,
e.getMessage(), e);
+ Activator.log(status);
+ ErrorDialog.openError(
+ getShell(),
+ WizardMessages.getString("CloudConnectionAuthError.title"),
+ WizardMessages.getFormattedString("CloudConnectionAuthError.message",
url),
+ status);
+ return true;
+ }
+ }
+
+ @Override
+ public boolean performFinish() {
+ String name = mainPage.getModel().getName();
+ String url = mainPage.getModel().getUrl();
+ String username = mainPage.getModel().getUsername();
+ String password = mainPage.getModel().getPassword();
+ String type = mainPage.getModel().getType().toString();
+ try {
+ DeltaCloud newCloud = new DeltaCloud(name, url, username, password, type, true);
+ DeltaCloudManager.getDefault().addCloud(newCloud);
+ } catch (MalformedURLException e) {
+ Activator.log(e);
+ }
+ return true;
+ }
+
+ @Override
+ public boolean needsProgressMonitor() {
+ return true;
+ }
+}
Property changes on:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/NewCloudConnectionWizard.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/NewInstanceModel.java
===================================================================
---
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/NewInstanceModel.java 2010-11-15
22:55:00 UTC (rev 26588)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/NewInstanceModel.java 2010-11-15
23:26:40 UTC (rev 26589)
@@ -111,8 +111,8 @@
@Override
public IStatus validate(Object value) {
- Assert.isTrue(value instanceof String);
- if (value != null && ((String) value).length() > 0) {
+ if (value instanceof String
+ && ((String) value).length() > 0) {
return ValidationStatus.ok();
} else {
return ValidationStatus.error(WizardMessages.getString(IMAGE_ID_NOT_FOUND));
Modified:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/NewInstanceWizard.java
===================================================================
---
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/NewInstanceWizard.java 2010-11-15
22:55:00 UTC (rev 26588)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/NewInstanceWizard.java 2010-11-15
23:26:40 UTC (rev 26589)
@@ -96,20 +96,13 @@
try {
pm.beginTask(WizardMessages.getFormattedString(STARTING_INSTANCE_MSG, new String[]
{instanceName}), IProgressMonitor.UNKNOWN);
pm.worked(1);
- cloud.registerActionJob(instanceId, this);
- boolean finished = false;
- while (!finished && !pm.isCanceled()) {
- instance = cloud.refreshInstance(instanceId);
- if (instance != null &&
!instance.getState().equals(DeltaCloudInstance.PENDING))
- break;
- Thread.sleep(400);
- }
-
+ cloud.registerInstanceJob(instanceId, this);
+ instance = cloud.waitWhilePending(instanceId, pm);
} catch (Exception e) {
// do nothing
} finally {
cloud.replaceInstance(instance);
- cloud.removeActionJob(instanceId, this);
+ cloud.removeInstanceJob(instanceId, this);
String hostname = instance.getHostName();
Preferences prefs = new InstanceScope().getNode(Activator.PLUGIN_ID);
boolean autoConnect =
prefs.getBoolean(IDeltaCloudPreferenceConstants.AUTO_CONNECT_INSTANCE, true);
@@ -198,6 +191,7 @@
prefs.putBoolean(IDeltaCloudPreferenceConstants.DONT_CONFIRM_CREATE_INSTANCE,
true);
}
}
+
instance = cloud.createInstance(name, imageId, realmId, profileId, keyname, memory,
storage);
if (instance != null)
result = true;
Modified:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/NewInstanceWizard2.java
===================================================================
---
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/NewInstanceWizard2.java 2010-11-15
22:55:00 UTC (rev 26588)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/NewInstanceWizard2.java 2010-11-15
23:26:40 UTC (rev 26589)
@@ -22,19 +22,14 @@
import org.eclipse.jface.dialogs.ErrorDialog;
import org.eclipse.jface.dialogs.MessageDialogWithToggle;
import org.eclipse.jface.wizard.Wizard;
-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.jboss.tools.deltacloud.core.DeltaCloud;
import org.jboss.tools.deltacloud.core.DeltaCloudException;
import org.jboss.tools.deltacloud.core.DeltaCloudInstance;
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.views.CVMessages;
+import org.jboss.tools.deltacloud.ui.RSEUtils;
import org.osgi.service.prefs.Preferences;
public class NewInstanceWizard2 extends Wizard {
@@ -47,117 +42,80 @@
private final static String DONT_SHOW_THIS_AGAIN_MSG =
"DontShowThisAgain.msg"; //$NON-NLS-1$
private final static String STARTING_INSTANCE_MSG = "StartingInstance.msg";
//$NON-NLS-1$
private final static String STARTING_INSTANCE_TITLE =
"StartingInstance.title"; //$NON-NLS-1$
- private final static String RSE_CONNECTING_MSG = "ConnectingRSE.msg";
//$NON-NLS-1$
-
private NewInstancePage2 mainPage;
-
+
private DeltaCloud cloud;
private DeltaCloudInstance instance;
public NewInstanceWizard2(DeltaCloud cloud) {
this.cloud = cloud;
}
-
+
@Override
public void addPages() {
// TODO Auto-generated method stub
mainPage = new NewInstancePage2(cloud);
addPage(mainPage);
}
-
+
@Override
public boolean canFinish() {
return mainPage.isPageComplete();
}
-
-
+
private class WatchCreateJob extends Job {
-
+
private DeltaCloud cloud;
private String instanceId;
private String instanceName;
-
- public WatchCreateJob(String title, DeltaCloud cloud,
+
+ public WatchCreateJob(String title, DeltaCloud cloud,
String instanceId, String instanceName) {
super(title);
this.cloud = cloud;
this.instanceId = instanceId;
this.instanceName = instanceName;
}
-
+
public IStatus run(IProgressMonitor pm) {
- if (!pm.isCanceled()){
+ if (!pm.isCanceled()) {
DeltaCloudInstance instance = null;
try {
- pm.beginTask(WizardMessages.getFormattedString(STARTING_INSTANCE_MSG, new String[]
{instanceName}), IProgressMonitor.UNKNOWN);
+ pm.beginTask(
+ WizardMessages.getFormattedString(STARTING_INSTANCE_MSG, new String[] {
instanceName }),
+ IProgressMonitor.UNKNOWN);
pm.worked(1);
- cloud.registerActionJob(instanceId, this);
- boolean finished = false;
- while (!finished && !pm.isCanceled()) {
- instance = cloud.refreshInstance(instanceId);
- if (instance != null &&
!instance.getState().equals(DeltaCloudInstance.PENDING))
- break;
- Thread.sleep(400);
- }
-
+ cloud.registerInstanceJob(instanceId, this);
+ instance = cloud.waitWhilePending(instanceId, pm);
} catch (Exception e) {
// do nothing
} finally {
cloud.replaceInstance(instance);
- cloud.removeActionJob(instanceId, this);
- String hostname = instance.getHostName();
+ cloud.removeInstanceJob(instanceId, this);
+ String hostname = RSEUtils.createHostName(instance);
Preferences prefs = new InstanceScope().getNode(Activator.PLUGIN_ID);
boolean autoConnect =
prefs.getBoolean(IDeltaCloudPreferenceConstants.AUTO_CONNECT_INSTANCE, true);
if (hostname != null && hostname.length() > 0 && autoConnect) {
- ISystemRegistry registry = SystemStartHere.getSystemRegistry();
- RSECorePlugin rsep = RSECorePlugin.getDefault();
- IRSECoreRegistry coreRegistry = rsep.getCoreRegistry();
- IRSESystemType[] sysTypes = coreRegistry.getSystemTypes();
- IRSESystemType sshType = null;
- for (IRSESystemType sysType : sysTypes) {
- if (sysType.getId().equals(IRSESystemType.SYSTEMTYPE_SSH_ONLY_ID))
- sshType = sysType;
- }
- String connectionName = instance.getName() + " [" + instance.getId() +
"]"; //$NON-NLS-1$ //$NON-NLS-2$
try {
- IHost host = registry.createHost(sshType, connectionName, hostname, null);
- if (host != null) {
- host.setDefaultUserId("root"); //$NON-NLS-1$
- IConnectorService[] services = host.getConnectorServices();
- if (services.length > 0) {
- final IConnectorService service = services[0];
- Job connect = new Job(CVMessages.getFormattedString(RSE_CONNECTING_MSG,
connectionName)) {
- @Override
- protected IStatus run(IProgressMonitor monitor) {
- try {
- service.connect(monitor);
- return Status.OK_STATUS;
- } catch(Exception e) {
- return Status.CANCEL_STATUS;
- }
- }
- };
- connect.setUser(true);
- connect.schedule();
- }
- }
+ String connectionName = RSEUtils.createConnectionName(instance);
+ IHost host = RSEUtils.createHost(connectionName,
RSEUtils.createHostName(instance));
+ RSEUtils.launchRemoteSystemExplorer(instance.getName(), connectionName, host);
} catch (Exception e) {
- // TODO Auto-generated catch block
- Activator.log(e);
+ ErrorUtils.openErrorDialog("Error", "Could not launch remote system
explorer for instance \"" + instance.getName() + "\"", e,
getShell());
+ return Status.OK_STATUS;
}
}
pm.done();
}
return Status.OK_STATUS;
- }
- else {
+ } else {
pm.done();
return Status.CANCEL_STATUS;
}
};
};
-
+
@Override
public boolean performFinish() {
String imageId = mainPage.getImageId();
@@ -167,36 +125,39 @@
String storage = mainPage.getStorageProperty();
String keyname = mainPage.getKeyName();
String name = null;
-
+
// Save persistent settings for this particular cloud
cloud.setLastImageId(imageId);
cloud.setLastKeyname(keyname);
cloud.save();
Preferences prefs = new InstanceScope().getNode(Activator.PLUGIN_ID);
-
+
try {
name = URLEncoder.encode(mainPage.getInstanceName(), "UTF-8");
} catch (UnsupportedEncodingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} //$NON-NLS-1$
-
+
boolean result = false;
String errorMessage = WizardMessages.getString(DEFAULT_REASON);
try {
- boolean dontShowDialog =
prefs.getBoolean(IDeltaCloudPreferenceConstants.DONT_CONFIRM_CREATE_INSTANCE, false);
+ boolean dontShowDialog =
prefs.getBoolean(IDeltaCloudPreferenceConstants.DONT_CONFIRM_CREATE_INSTANCE,
+ false);
if (!dontShowDialog) {
MessageDialogWithToggle dialog =
- MessageDialogWithToggle.openOkCancelConfirm(getShell(),
WizardMessages.getString(CONFIRM_CREATE_TITLE),
- WizardMessages.getString(CONFIRM_CREATE_MSG),
- WizardMessages.getString(DONT_SHOW_THIS_AGAIN_MSG),
- false, null, null);
+ MessageDialogWithToggle.openOkCancelConfirm(getShell(),
+ WizardMessages.getString(CONFIRM_CREATE_TITLE),
+ WizardMessages.getString(CONFIRM_CREATE_MSG),
+ WizardMessages.getString(DONT_SHOW_THIS_AGAIN_MSG),
+ false, null, null);
int retCode = dialog.getReturnCode();
boolean toggleState = dialog.getToggleState();
if (retCode == Dialog.CANCEL)
return true;
- // If warning turned off by user, set the preference for future usage
+ // If warning turned off by user, set the preference for future
+ // usage
if (toggleState) {
prefs.putBoolean(IDeltaCloudPreferenceConstants.DONT_CONFIRM_CREATE_INSTANCE,
true);
}
@@ -216,9 +177,11 @@
errorMessage = e.getLocalizedMessage();
}
if (!result) {
- ErrorDialog.openError(this.getShell(),
+ ErrorDialog.openError(
+ this.getShell(),
WizardMessages.getString(CREATE_INSTANCE_FAILURE_TITLE),
- WizardMessages.getFormattedString(CREATE_INSTANCE_FAILURE_MSG, new String[] {name,
imageId, realmId, profileId}),
+ WizardMessages.getFormattedString(CREATE_INSTANCE_FAILURE_MSG, new String[] { name,
imageId,
+ realmId, profileId }),
new Status(IStatus.ERROR, Activator.PLUGIN_ID, errorMessage));
}
return result;