Author: jjohnstn
Date: 2010-09-03 16:43:31 -0400 (Fri, 03 Sep 2010)
New Revision: 24719
Modified:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/ChangeLog
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/IDeltaCloudPreferenceConstants.java
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/CVMessages.properties
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/ImageView.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/internal/deltacloud/ui/wizards/ManageKeysPage.java
Log:
2010-09-03 Jeff Johnston <jjohnstn(a)redhat.com>
* src/org/jboss/tools/deltacloud/ui/IDeltaCloudPreferenceConstants.java: Add constants
for saving last cloud looked at in Instances and Images view.
* src/org/jboss/tools/deltacloud/ui/views/CVMessages.properties: Add new messages.
* src/org/jboss/tools/deltacloud/ui/views/ImageView.java (.modifyText): Set the
last cloud preference when the cloud changes.
(createPartControl): Set the initial values from the current cloud set by
initializeCloudSelector.
(initializeCloudSelector): Use last cloud preference if the cloud is in the list.
* src/org/jboss/tools/deltacloud/ui/views/InstanceView.java (changeEvent):
White-space changes.
(.modifyText): Save the last cloud preference when the cloud changes.
(createPartControl): Set the initial values from the current cloud set by
initializeCloudSelector.
(initializeCloudSelector): Use last cloud preference if the cloud is in the list.
(.run): For RSE connection, try and make the connection within a Job.
(..run): New Job action for connecting to hostname via RSE.
* src/org/jboss/tools/internal/deltacloud/ui/wizards/ManageKeysPage.java (.compare):
(loadFileList): Add alphabetical sort.
(createControl): Use default directory preference to set initial directory.
(validate): Save directory as default if it is valid.
Modified: trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/ChangeLog
===================================================================
--- trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/ChangeLog 2010-09-03 17:44:05
UTC (rev 24718)
+++ trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/ChangeLog 2010-09-03 20:43:31
UTC (rev 24719)
@@ -1,5 +1,28 @@
2010-09-03 Jeff Johnston <jjohnstn(a)redhat.com>
+ * src/org/jboss/tools/deltacloud/ui/IDeltaCloudPreferenceConstants.java: Add constants
+ for saving last cloud looked at in Instances and Images view.
+ * src/org/jboss/tools/deltacloud/ui/views/CVMessages.properties: Add new messages.
+ * src/org/jboss/tools/deltacloud/ui/views/ImageView.java (.modifyText): Set the
+ last cloud preference when the cloud changes.
+ (createPartControl): Set the initial values from the current cloud set by
+ initializeCloudSelector.
+ (initializeCloudSelector): Use last cloud preference if the cloud is in the list.
+ * src/org/jboss/tools/deltacloud/ui/views/InstanceView.java (changeEvent):
+ White-space changes.
+ (.modifyText): Save the last cloud preference when the cloud changes.
+ (createPartControl): Set the initial values from the current cloud set by
+ initializeCloudSelector.
+ (initializeCloudSelector): Use last cloud preference if the cloud is in the list.
+ (.run): For RSE connection, try and make the connection within a Job.
+ (..run): New Job action for connecting to hostname via RSE.
+ * src/org/jboss/tools/internal/deltacloud/ui/wizards/ManageKeysPage.java (.compare):
+ (loadFileList): Add alphabetical sort.
+ (createControl): Use default directory preference to set initial directory.
+ (validate): Save directory as default if it is valid.
+
+2010-09-03 Jeff Johnston <jjohnstn(a)redhat.com>
+
* src/org/jboss/tools/internal/deltacloud/ui/wizards/NewInstance.java
(WatchCreateJob.run): Add
instance logic fixed.
Modified:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/IDeltaCloudPreferenceConstants.java
===================================================================
---
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/IDeltaCloudPreferenceConstants.java 2010-09-03
17:44:05 UTC (rev 24718)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/IDeltaCloudPreferenceConstants.java 2010-09-03
20:43:31 UTC (rev 24719)
@@ -15,5 +15,7 @@
public final static String DONT_CONFIRM_CREATE_INSTANCE =
"dont_confirm_create_instance"; //$NON-NLS-1$
public final static String LAST_EC2_KEYNAME = "last_ec2_keyname";
//$NON-NLS-1$
public final static String DEFAULT_KEY_DIR = "default_key_directory";
//$NON-NLS-1$
+ public final static String LAST_CLOUD_INSTANCE_VIEW =
"last_cloud_instance_view"; //$NON-NLS-1$
+ public final static String LAST_CLOUD_IMAGE_VIEW = "last_cloud_image_view";
//$NON-NLS-1$
}
Modified:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/CVMessages.properties
===================================================================
---
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/CVMessages.properties 2010-09-03
17:44:05 UTC (rev 24718)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/CVMessages.properties 2010-09-03
20:43:31 UTC (rev 24719)
@@ -49,6 +49,7 @@
RebootingInstance.msg=Rebooting Instance: {0}
DestroyingInstance.title=Destroying Instance
DestroyingInstance.msg=Destroying Instance: {0}
+ConnectingRSE.msg=Connecting instance as: {0}
NAME=Name
ID=ID
Modified:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/ImageView.java
===================================================================
---
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/ImageView.java 2010-09-03
17:44:05 UTC (rev 24718)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/ImageView.java 2010-09-03
20:43:31 UTC (rev 24719)
@@ -10,6 +10,7 @@
*******************************************************************************/
package org.jboss.tools.deltacloud.ui.views;
+import org.eclipse.core.runtime.preferences.InstanceScope;
import org.eclipse.jface.action.Action;
import org.eclipse.jface.action.IMenuListener;
import org.eclipse.jface.action.IMenuManager;
@@ -53,7 +54,10 @@
import org.jboss.tools.deltacloud.core.DeltaCloudManager;
import org.jboss.tools.deltacloud.core.ICloudManagerListener;
import org.jboss.tools.deltacloud.core.IImageListListener;
+import org.jboss.tools.deltacloud.ui.Activator;
+import org.jboss.tools.deltacloud.ui.IDeltaCloudPreferenceConstants;
import org.jboss.tools.internal.deltacloud.ui.wizards.NewInstance;
+import org.osgi.service.prefs.Preferences;
public class ImageView extends ViewPart implements ICloudManagerListener,
IImageListListener {
@@ -89,6 +93,13 @@
if (currCloud != null)
currCloud.removeImageListListener(parentView);
currCloud = clouds[index];
+ Preferences prefs = new InstanceScope().getNode(Activator.PLUGIN_ID);
+ try {
+ prefs.put(IDeltaCloudPreferenceConstants.LAST_CLOUD_IMAGE_VIEW,
currCloud.getName());
+ } catch(Exception exc) {
+ // do nothing
+ }
+
viewer.setInput(new DeltaCloudImage[0]);
viewer.refresh();
Display.getCurrent().asyncExec(new Runnable() {
@@ -189,10 +200,9 @@
}
table.setSortDirection(SWT.NONE);
- if (clouds.length > 0) {
- currCloud = clouds[0];
+ if (currCloud != null) {
currCloud.removeImageListListener(parentView);
- viewer.setInput(clouds[0]);
+ viewer.setInput(currCloud);
currCloud.addImageListListener(parentView);
}
@@ -322,15 +332,22 @@
}
private void initializeCloudSelector() {
+ int defaultIndex = 0;
clouds = DeltaCloudManager.getDefault().getClouds();
String[] cloudNames = new String[clouds.length];
+ // If we have saved the last cloud used from a previous session,
+ // default to using that cloud to start unless it no longer exists
+ Preferences prefs = new InstanceScope().getNode(Activator.PLUGIN_ID);
+ String lastCloudUsed = prefs.get(IDeltaCloudPreferenceConstants.LAST_CLOUD_IMAGE_VIEW,
"");
for (int i = 0; i < clouds.length; ++i) {
cloudNames[i] = clouds[i].getName();
+ if (cloudNames[i].equals(lastCloudUsed))
+ defaultIndex = i;
}
cloudSelector.setItems(cloudNames);
if (clouds.length > 0) {
- cloudSelector.setText(cloudNames[0]);
- currCloud = clouds[0];
+ cloudSelector.setText(cloudNames[defaultIndex]);
+ currCloud = clouds[defaultIndex];
}
}
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-09-03
17:44:05 UTC (rev 24718)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/InstanceView.java 2010-09-03
20:43:31 UTC (rev 24719)
@@ -18,6 +18,7 @@
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.core.runtime.preferences.InstanceScope;
import org.eclipse.jface.action.Action;
import org.eclipse.jface.action.IMenuListener;
import org.eclipse.jface.action.IMenuManager;
@@ -37,6 +38,7 @@
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.SWT;
import org.eclipse.swt.events.ModifyEvent;
import org.eclipse.swt.events.ModifyListener;
@@ -59,13 +61,15 @@
import org.eclipse.ui.IWorkbenchActionConstants;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.part.ViewPart;
-import org.jboss.tools.deltacloud.ui.Activator;
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.core.DeltaCloudManager;
import org.jboss.tools.deltacloud.core.ICloudManagerListener;
import org.jboss.tools.deltacloud.core.IInstanceListListener;
+import org.jboss.tools.deltacloud.ui.Activator;
+import org.jboss.tools.deltacloud.ui.IDeltaCloudPreferenceConstants;
+import org.osgi.service.prefs.Preferences;
public class InstanceView extends ViewPart implements ICloudManagerListener,
IInstanceListListener {
@@ -83,6 +87,7 @@
private final static String REBOOTING_INSTANCE_MSG = "RebootingInstance.msg";
//$NON-NLS-1$
private final static String DESTROYING_INSTANCE_TITLE =
"DestroyingInstance.title"; //$NON-NLS-1$
private final static String DESTROYING_INSTANCE_MSG =
"DestroyingInstance.msg"; //$NON-NLS-1$
+ private final static String RSE_CONNECTING_MSG = "ConnectingRSE.msg";
//$NON-NLS-1$
private static final String REFRESH = "Refresh.label"; //$NON-NLS-1$
@@ -120,6 +125,12 @@
if (currCloud != null)
currCloud.removeInstanceListListener(parentView);
currCloud = clouds[index];
+ Preferences prefs = new InstanceScope().getNode(Activator.PLUGIN_ID);
+ try {
+ prefs.put(IDeltaCloudPreferenceConstants.LAST_CLOUD_INSTANCE_VIEW,
currCloud.getName());
+ } catch(Exception exc) {
+ // do nothing
+ }
viewer.setInput(new DeltaCloudInstance[0]);
viewer.refresh();
Display.getCurrent().asyncExec(new Runnable() {
@@ -219,10 +230,9 @@
}
table.setSortDirection(SWT.NONE);
- if (clouds.length > 0) {
- currCloud = clouds[0];
+ if (currCloud != null) {
currCloud.removeInstanceListListener(parentView);
- viewer.setInput(clouds[0]);
+ viewer.setInput(currCloud);
currCloud.addInstanceListListener(parentView);
}
@@ -500,8 +510,26 @@
String connectionName = instance.getName() + " [" + instance.getId() +
"]"; //$NON-NLS-1$ //$NON-NLS-2$
try {
IHost host = registry.createHost(sshType, connectionName, hostname, null);
- if (host != 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();
+ }
+ }
} catch (Exception e) {
// TODO Auto-generated catch block
Activator.log(e);
@@ -536,15 +564,22 @@
}
private void initializeCloudSelector() {
+ int defaultIndex = 0;
clouds = DeltaCloudManager.getDefault().getClouds();
String[] cloudNames = new String[clouds.length];
+ // If we have saved the last cloud used from a previous session,
+ // default to using that cloud to start unless it no longer exists
+ Preferences prefs = new InstanceScope().getNode(Activator.PLUGIN_ID);
+ String lastCloudUsed =
prefs.get(IDeltaCloudPreferenceConstants.LAST_CLOUD_INSTANCE_VIEW, "");
for (int i = 0; i < clouds.length; ++i) {
cloudNames[i] = clouds[i].getName();
+ if (cloudNames[i].equals(lastCloudUsed))
+ defaultIndex = i;
}
cloudSelector.setItems(cloudNames);
if (clouds.length > 0) {
- cloudSelector.setText(cloudNames[0]);
- currCloud = clouds[0];
+ cloudSelector.setText(cloudNames[defaultIndex]);
+ currCloud = clouds[defaultIndex];
}
}
@@ -571,7 +606,7 @@
currCloud = null;
cloudSelector.setText("");
viewer.setInput(new DeltaCloudInstance[0]);
- }
+ }
cloudSelector.addModifyListener(cloudModifyListener);
}
Modified:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/ManageKeysPage.java
===================================================================
---
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/ManageKeysPage.java 2010-09-03
17:44:05 UTC (rev 24718)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/ManageKeysPage.java 2010-09-03
20:43:31 UTC (rev 24719)
@@ -2,6 +2,8 @@
import java.io.File;
import java.io.FilenameFilter;
+import java.util.Arrays;
+import java.util.Comparator;
import org.eclipse.core.runtime.preferences.InstanceScope;
import org.eclipse.jface.dialogs.IDialogConstants;
@@ -153,6 +155,12 @@
hasError = true;
setErrorMessage(WizardMessages.getString(INVALID_DIRECTORY));
} else {
+ Preferences prefs = new InstanceScope().getNode(Activator.PLUGIN_ID);
+ try {
+ prefs.put(IDeltaCloudPreferenceConstants.DEFAULT_KEY_DIR, directory.getText());
+ } catch(Exception e) {
+ // do nothing
+ }
loadFileList();
}
}
@@ -165,6 +173,14 @@
File dir = new File(directory.getText());
if (dir.exists() && dir.isDirectory()) {
File[] files = dir.listFiles(extensionFilter);
+ Arrays.sort(files, new Comparator<File>() {
+ @Override
+ public int compare(File arg0, File arg1) {
+ String name0 = arg0.getName();
+ String name1 = arg1.getName();
+ return name0.compareTo(name1);
+ }
+ });
fileList.removeAll();
for (File f : files) {
fileList.add(f.getName());
@@ -270,6 +286,7 @@
fileList.setLayoutData(f);
setControl(container);
+ loadFileList();
}
}