Author: rob.stryker(a)jboss.com
Date: 2010-12-01 09:08:35 -0500 (Wed, 01 Dec 2010)
New Revision: 27051
Modified:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/CloudConnectionPage.java
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/NewCloudConnectionWizard.java
Log:
JBIDE-7774 - remember last used connection url at the very least
Modified:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/CloudConnectionPage.java
===================================================================
---
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/CloudConnectionPage.java 2010-12-01
13:46:14 UTC (rev 27050)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/CloudConnectionPage.java 2010-12-01
14:08:35 UTC (rev 27051)
@@ -27,6 +27,7 @@
import org.eclipse.core.databinding.validation.ValidationStatus;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.preferences.InstanceScope;
import org.eclipse.jface.databinding.fieldassist.ControlDecorationSupport;
import org.eclipse.jface.databinding.swt.ISWTObservableValue;
import org.eclipse.jface.databinding.swt.WidgetProperties;
@@ -62,6 +63,7 @@
import
org.jboss.tools.internal.deltacloud.ui.common.databinding.validator.CompositeValidator;
import
org.jboss.tools.internal.deltacloud.ui.common.databinding.validator.MandatoryStringValidator;
import org.jboss.tools.internal.deltacloud.ui.common.swt.JFaceUtils;
+import org.osgi.service.prefs.Preferences;
/**
* @author Jeff Jonhston
@@ -449,6 +451,12 @@
f.top = new FormAttachment(passwordText, 5);
ec2pwLink.setLayoutData(f);
+ if( urlText.getText().equals("")) {
+ // pre-set with previously used
+ Preferences prefs = new InstanceScope().getNode(Activator.PLUGIN_ID);
+ String previousURL = prefs.get(NewCloudConnectionWizard.LAST_USED_URL, "");
+ urlText.setText(previousURL);
+ }
setControl(container);
}
Modified:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/NewCloudConnectionWizard.java
===================================================================
---
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/NewCloudConnectionWizard.java 2010-12-01
13:46:14 UTC (rev 27050)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/NewCloudConnectionWizard.java 2010-12-01
14:08:35 UTC (rev 27051)
@@ -13,6 +13,7 @@
import java.net.MalformedURLException;
import java.text.MessageFormat;
+import org.eclipse.core.runtime.preferences.InstanceScope;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.wizard.Wizard;
import org.eclipse.ui.INewWizard;
@@ -21,11 +22,15 @@
import org.jboss.tools.deltacloud.core.DeltaCloudException;
import org.jboss.tools.deltacloud.core.DeltaCloudManager;
import org.jboss.tools.deltacloud.core.client.DeltaCloudClientImpl.DeltaCloudServerType;
+import org.jboss.tools.deltacloud.ui.Activator;
import org.jboss.tools.deltacloud.ui.ErrorUtils;
+import org.osgi.service.prefs.BackingStoreException;
+import org.osgi.service.prefs.Preferences;
public class NewCloudConnectionWizard extends Wizard implements INewWizard,
CloudConnection {
private static final String MAINPAGE_NAME = "NewCloudConnection.name";
//$NON-NLS-1$
+ public static final String LAST_USED_URL =
"org.jboss.tools.internal.deltacloud.ui.wizards.LAST_CREATED_URL";
private CloudConnectionPage mainPage;
protected DeltaCloud initialCloud;
private String pageTitle;
@@ -118,6 +123,19 @@
String username = mainPage.getModel().getUsername();
String password = mainPage.getModel().getPassword();
String type = getServerType();
+
+ // save URL in some plugin preference key!
+ Preferences prefs = new InstanceScope().getNode(Activator.PLUGIN_ID);
+ String previousURL = prefs.get(LAST_USED_URL, "");
+ if( previousURL == null || previousURL.equals("") ||
!previousURL.equals(url)) {
+ prefs.put(LAST_USED_URL, url);
+ try {
+ prefs.flush();
+ } catch( BackingStoreException bse ) {
+ // intentionally ignore, non-critical
+ }
+ }
+
try {
DeltaCloud newCloud = new DeltaCloud(name, url, username, password, type);
DeltaCloudManager.getDefault().addCloud(newCloud);
Show replies by date