Author: adietish
Date: 2011-02-18 11:45:00 -0500 (Fri, 18 Feb 2011)
New Revision: 29246
Added:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/preferences/AbstractPreferenceValue.java
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/preferences/StringPreferenceValue.java
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/preferences/StringsPreferenceValue.java
Removed:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/preferences/AbstractPreferenceValue.java
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/preferences/StringPreferenceValue.java
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/preferences/StringsPreferenceValue.java
Modified:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/ChangeLog
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/META-INF/MANIFEST.MF
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/cloudelements/AbstractCloudElementTableView.java
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloudelements/ImageView.java
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloudelements/InstanceView.java
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/utils/UIUtils.java
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
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/NewInstancePage.java
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/NewInstancePageModel.java
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/SshPrivateKeysPreferences.java
Log:
[JBIDE-8333] now persisting last selected realm and profile per cloud.
Modified: trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/ChangeLog
===================================================================
--- trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/ChangeLog 2011-02-18 16:42:58
UTC (rev 29245)
+++ trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/ChangeLog 2011-02-18 16:45:00
UTC (rev 29246)
@@ -1,3 +1,12 @@
+2011-02-18 André Dietisheim <André Dietisheim@adietisheim-thinkpad>
+
+ * src/org/jboss/tools/internal/deltacloud/ui/wizards/NewInstancePageModel.java
+ (getProfileIndex):
+ (setSelectedProfileIndex):
+ (getRealmIndex):
+ (setSelectedRealm):
+ [JBIDE-8333] now persisting last selected realm and profile per cloud.
+
2011-02-04 André Dietisheim <André Dietisheim@adietisheim-thinkpad>
* src/org/jboss/tools/deltacloud/ui/commands/StopInstanceHandler.java
Modified: trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/META-INF/MANIFEST.MF
===================================================================
--- trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/META-INF/MANIFEST.MF 2011-02-18
16:42:58 UTC (rev 29245)
+++ trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/META-INF/MANIFEST.MF 2011-02-18
16:45:00 UTC (rev 29246)
@@ -26,6 +26,7 @@
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Bundle-ActivationPolicy: lazy
Export-Package: org.jboss.tools.deltacloud.ui,
+ org.jboss.tools.deltacloud.ui.preferences,
org.jboss.tools.deltacloud.ui.wizard,
org.jboss.tools.internal.deltacloud.ui.preferences;x-friends:="org.jboss.tools.deltacloud.test",
org.jboss.tools.internal.deltacloud.ui.utils
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 2011-02-18
16:42:58 UTC (rev 29245)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/IDeltaCloudPreferenceConstants.java 2011-02-18
16:45:00 UTC (rev 29246)
@@ -12,12 +12,19 @@
public interface IDeltaCloudPreferenceConstants {
- public final static String DONT_CONFIRM_CREATE_INSTANCE =
"dont_confirm_create_instance"; //$NON-NLS-1$
- public final static String DONT_CONFIRM_STOP_INSTANCE =
"dont_confirm_stop_instance"; //$NON-NLS-1$
- public final static String AUTO_CONNECT_INSTANCE = "auto_connect_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$
+ public static final String DONT_CONFIRM_CREATE_INSTANCE =
"dont_confirm_create_instance"; //$NON-NLS-1$
+ public static final String DONT_CONFIRM_STOP_INSTANCE =
"dont_confirm_stop_instance"; //$NON-NLS-1$
+ public static final String AUTO_CONNECT_INSTANCE = "auto_connect_instance";
//$NON-NLS-1$
+ public static final String LAST_EC2_KEYNAME = "last_ec2_keyname";
//$NON-NLS-1$
+ public static final String DEFAULT_KEY_DIR = "default_key_directory";
//$NON-NLS-1$
+ public static final String CLOUD_NAME_PROPOSAL_KEY =
"cloud_name";//$NON-NLS-1$
+ public static final String CLOUD_USERNAME_PROPOSAL_KEY =
"cloud_username";//$NON-NLS-1$
+ public static final String CLOUD_URL_PROPOSAL_KEY = "cloud_url";//$NON-NLS-1$
+ public static final String CLOUD_LAST_INSTANCE_KEY =
"last_cloud_instance_view"; //$NON-NLS-1$
+ public static final String CLOUD_LAST_IMAGE_KEY = "last_cloud_image_view";
//$NON-NLS-1$
+
+ public static final String INSTANCE_NAME_PROPOSAL_KEY =
"instance_name";//$NON-NLS-1$
+ public static final String INSTANCE_IMAGE_PROPOSAL_KEY =
"instance_image";//$NON-NLS-1$
+ public static final String INSTANCE_KEY_PROPOSAL_KEY =
"instance_key";//$NON-NLS-1$
}
Copied:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/preferences/AbstractPreferenceValue.java
(from rev 29034,
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/preferences/AbstractPreferenceValue.java)
===================================================================
---
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/preferences/AbstractPreferenceValue.java
(rev 0)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/preferences/AbstractPreferenceValue.java 2011-02-18
16:45:00 UTC (rev 29246)
@@ -0,0 +1,77 @@
+/*******************************************************************************
+ * 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.preferences;
+
+import org.eclipse.core.runtime.preferences.InstanceScope;
+import org.osgi.service.prefs.BackingStoreException;
+import org.osgi.service.prefs.Preferences;
+
+/**
+ * @author Andre Dietisheim
+ */
+public abstract class AbstractPreferenceValue<TYPE> {
+
+ private String pluginId;
+ private String prefsKey;
+
+ public AbstractPreferenceValue(String prefsKey, String pluginId) {
+ this.pluginId = pluginId;
+ this.prefsKey = prefsKey;
+ }
+
+ public abstract TYPE get();
+
+ protected String doGet() {
+ return doGet(null);
+ }
+
+ public abstract TYPE get(TYPE currentValue);
+
+ protected String doGet(String currentValue) {
+ if( currentValue == null || currentValue.equals("")) {
+ // pre-set with previously used
+ Preferences prefs = getPreferences(this.pluginId);
+ return prefs.get(prefsKey, "");
+ } else {
+ return currentValue;
+ }
+ }
+
+ public void remove() {
+ String prefsValue = doGet();
+ if (prefsValue == null
+ || prefsValue == null) {
+ return;
+ }
+ store(null);
+ }
+
+ public abstract void store(TYPE value);
+
+ protected void doStore(String value) {
+ Preferences prefs = getPreferences(this.pluginId);
+ String prefsValue = prefs.get(prefsKey, "");
+ if (prefsValue == null
+ || prefsValue.equals("")
+ || !prefsValue.equals(value)) {
+ prefs.put(prefsKey, value);
+ try {
+ prefs.flush();
+ } catch (BackingStoreException bse) {
+ // intentionally ignore, non-critical
+ }
+ }
+ }
+
+ protected Preferences getPreferences(String pluginId) {
+ return new InstanceScope().getNode(pluginId);
+ }
+}
Property changes on:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/preferences/AbstractPreferenceValue.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Copied:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/preferences/StringPreferenceValue.java
(from rev 29034,
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/preferences/StringPreferenceValue.java)
===================================================================
---
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/preferences/StringPreferenceValue.java
(rev 0)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/preferences/StringPreferenceValue.java 2011-02-18
16:45:00 UTC (rev 29246)
@@ -0,0 +1,35 @@
+/*******************************************************************************
+ * 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.preferences;
+
+
+
+/**
+ * @author Andre Dietisheim
+ */
+public class StringPreferenceValue extends AbstractPreferenceValue<String> {
+
+ public StringPreferenceValue(String prefsKey, String pluginId) {
+ super(prefsKey, pluginId);
+ }
+
+ public String get() {
+ return get(null);
+ }
+
+ public String get(String currentValue) {
+ return doGet(currentValue);
+ }
+
+ public void store(String value) {
+ doStore(value);
+ }
+}
Property changes on:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/preferences/StringPreferenceValue.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Copied:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/preferences/StringsPreferenceValue.java
(from rev 29067,
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/preferences/StringsPreferenceValue.java)
===================================================================
---
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/preferences/StringsPreferenceValue.java
(rev 0)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/preferences/StringsPreferenceValue.java 2011-02-18
16:45:00 UTC (rev 29246)
@@ -0,0 +1,189 @@
+/*******************************************************************************
+ * 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.preferences;
+
+import java.io.UnsupportedEncodingException;
+import java.net.URLEncoder;
+import java.util.ArrayList;
+import java.util.StringTokenizer;
+
+
+/**
+ * A class that offers access to a collection of values that is stored in the
+ * preferences under a single key.
+ *
+ * @author Andre Dietisheim
+ */
+public class StringsPreferenceValue extends AbstractPreferenceValue<String[]> {
+
+ private String delimiter;
+ private String escapedDelimiter;
+
+ public StringsPreferenceValue(char delimiter, String prefsKey, String pluginId) {
+ super(prefsKey, pluginId);
+ this.delimiter = String.valueOf(delimiter);
+ try {
+ this.escapedDelimiter = URLEncoder.encode(String.valueOf(delimiter),
"UTF-8");
+ } catch (UnsupportedEncodingException e) {
+ // cannot happen since we use a fixed, known encoding
+ }
+ }
+
+ public String[] get() {
+ return get(null);
+ }
+
+ public String[] get(String[] currentValues) {
+
+ String string = doGet(null);
+ String[] prefValues = split(string);
+ return overrideValues(currentValues, prefValues);
+ }
+
+ private String[] split(String string) {
+ ArrayList<String> values = new ArrayList<String>();
+ StringTokenizer tokenizer = new StringTokenizer(string, delimiter);
+ while (tokenizer.hasMoreTokens()) {
+ String value = tokenizer.nextToken();
+ String unescapedValue = unescapeDelimiterCharacter(value);
+ values.add(unescapedValue);
+ }
+ return values.toArray(new String[values.size()]);
+ }
+
+ private String[] overrideValues(String[] newValues, String[] prefValues) {
+ if (prefValues == null) {
+ return newValues;
+ }
+
+ for (int i = 0; i < prefValues.length; i++) {
+ if (newValues == null
+ || newValues.length < i) {
+ break;
+ }
+ prefValues[i] = newValues[i];
+ }
+ return prefValues;
+ }
+
+ /**
+ * Adds the given string value to this preference value(s). Duplicate values
+ * are not added.
+ *
+ * @param value
+ * the value to add
+ */
+ public void add(String value) {
+ String currentValues = doGet();
+ StringBuilder builder = new StringBuilder(currentValues);
+ value = escapeDelimiterCharacter(value);
+ if (!contains(value, currentValues)) {
+ if (hasValues(currentValues)) {
+ builder.append(delimiter);
+ }
+ builder.append(value);
+ doStore(builder.toString());
+ }
+ }
+
+ private String escapeDelimiterCharacter(String value) {
+ if (value == null || value.length() == 0) {
+ return value;
+ }
+
+ int index = value.indexOf(delimiter);
+ if (index < 0) {
+ return value;
+ }
+ StringBuilder builder = new StringBuilder(value.substring(0, index));
+ builder.append(escapedDelimiter);
+ builder.append(value.substring(index + 1));
+ return builder.toString();
+ }
+
+ private String unescapeDelimiterCharacter(String value) {
+ if (value == null || value.length() == 0) {
+ return value;
+ }
+
+ int index = value.indexOf(escapedDelimiter);
+ if (index < 0) {
+ return value;
+ }
+ StringBuilder builder = new StringBuilder(value.substring(0, index));
+ builder.append(delimiter);
+ builder.append(value.substring(index + 1));
+ return builder.toString();
+ }
+
+ private boolean contains(String value, String currentValues) {
+ return currentValues != null
+ && currentValues.length() > 0
+ && currentValues.indexOf(value) >= 0;
+ }
+
+ private boolean hasValues(String currentValues) {
+ return currentValues != null && currentValues.length() > 0;
+ }
+
+ /**
+ * Removes the given values from the strings stored in the preferences and
+ * stores the preferences.
+ *
+ * @param values
+ * the values
+ */
+ public void remove(String... valuesToRemove) {
+ boolean removed = false;
+ String[] currentValues = get();
+ if (valuesToRemove != null) {
+ for (int i = 0; i < currentValues.length; i++) {
+ for (String valueToRemove : valuesToRemove) {
+ if (valueToRemove.equals(currentValues[i])) {
+ currentValues[i] = null;
+ removed = true;
+ }
+ }
+ }
+ }
+ if (removed) {
+ store(currentValues);
+ }
+ }
+
+ /**
+ * Overrides the current values in the preferences with the values in the
+ * given array (value in the preferences at index x is overridden with the
+ * value in the given array at index x) and stores the preferences.
+ */
+ public void store(String[] newValues) {
+ String[] currentValues = get();
+ overrideValues(newValues, currentValues);
+ doStore(concatenate(currentValues));
+ }
+
+ public void store() {
+ store(null);
+ }
+
+ protected String concatenate(String[] values) {
+ StringBuilder builder = new StringBuilder();
+ for (int i = 0; i < values.length; i++) {
+ if (values[i] != null) {
+ if (builder.length() > 0) {
+ builder.append(delimiter);
+ }
+ builder.append(values[i]);
+ }
+ }
+ return builder.toString();
+ }
+}
Property changes on:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/preferences/StringsPreferenceValue.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Modified:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloudelements/AbstractCloudElementTableView.java
===================================================================
---
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloudelements/AbstractCloudElementTableView.java 2011-02-18
16:42:58 UTC (rev 29245)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloudelements/AbstractCloudElementTableView.java 2011-02-18
16:45:00 UTC (rev 29246)
@@ -52,10 +52,10 @@
import org.jboss.tools.deltacloud.core.IInstanceFilter;
import org.jboss.tools.deltacloud.ui.Activator;
import org.jboss.tools.deltacloud.ui.ErrorUtils;
+import org.jboss.tools.deltacloud.ui.preferences.StringPreferenceValue;
import org.jboss.tools.deltacloud.ui.views.CVMessages;
import org.jboss.tools.deltacloud.ui.views.Columns;
import org.jboss.tools.deltacloud.ui.views.Columns.Column;
-import org.jboss.tools.internal.deltacloud.ui.preferences.StringPreferenceValue;
import org.jboss.tools.internal.deltacloud.ui.utils.WorkbenchUtils;
/**
Modified:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloudelements/ImageView.java
===================================================================
---
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloudelements/ImageView.java 2011-02-18
16:42:58 UTC (rev 29245)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloudelements/ImageView.java 2011-02-18
16:45:00 UTC (rev 29246)
@@ -29,7 +29,7 @@
@Override
protected String getSelectedCloudPrefsKey() {
- return IDeltaCloudPreferenceConstants.LAST_CLOUD_IMAGE_VIEW;
+ return IDeltaCloudPreferenceConstants.CLOUD_LAST_IMAGE_KEY;
}
@Override
Modified:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloudelements/InstanceView.java
===================================================================
---
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloudelements/InstanceView.java 2011-02-18
16:42:58 UTC (rev 29245)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloudelements/InstanceView.java 2011-02-18
16:45:00 UTC (rev 29246)
@@ -30,7 +30,7 @@
public class InstanceView extends AbstractCloudElementTableView<DeltaCloudInstance>
{
protected String getSelectedCloudPrefsKey() {
- return IDeltaCloudPreferenceConstants.LAST_CLOUD_INSTANCE_VIEW;
+ return IDeltaCloudPreferenceConstants.CLOUD_LAST_INSTANCE_KEY;
}
@Override
Deleted:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/preferences/AbstractPreferenceValue.java
===================================================================
---
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/preferences/AbstractPreferenceValue.java 2011-02-18
16:42:58 UTC (rev 29245)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/preferences/AbstractPreferenceValue.java 2011-02-18
16:45:00 UTC (rev 29246)
@@ -1,77 +0,0 @@
-/*******************************************************************************
- * 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.internal.deltacloud.ui.preferences;
-
-import org.eclipse.core.runtime.preferences.InstanceScope;
-import org.osgi.service.prefs.BackingStoreException;
-import org.osgi.service.prefs.Preferences;
-
-/**
- * @author Andre Dietisheim
- */
-public abstract class AbstractPreferenceValue<TYPE> {
-
- private String pluginId;
- private String prefsKey;
-
- public AbstractPreferenceValue(String prefsKey, String pluginId) {
- this.pluginId = pluginId;
- this.prefsKey = prefsKey;
- }
-
- public abstract TYPE get();
-
- protected String doGet() {
- return doGet(null);
- }
-
- public abstract TYPE get(TYPE currentValue);
-
- protected String doGet(String currentValue) {
- if( currentValue == null || currentValue.equals("")) {
- // pre-set with previously used
- Preferences prefs = getPreferences(this.pluginId);
- return prefs.get(prefsKey, "");
- } else {
- return currentValue;
- }
- }
-
- public void remove() {
- String prefsValue = doGet();
- if (prefsValue == null
- || prefsValue == null) {
- return;
- }
- store(null);
- }
-
- public abstract void store(TYPE value);
-
- protected void doStore(String value) {
- Preferences prefs = getPreferences(this.pluginId);
- String prefsValue = prefs.get(prefsKey, "");
- if (prefsValue == null
- || prefsValue.equals("")
- || !prefsValue.equals(value)) {
- prefs.put(prefsKey, value);
- try {
- prefs.flush();
- } catch (BackingStoreException bse) {
- // intentionally ignore, non-critical
- }
- }
- }
-
- protected Preferences getPreferences(String pluginId) {
- return new InstanceScope().getNode(pluginId);
- }
-}
Deleted:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/preferences/StringPreferenceValue.java
===================================================================
---
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/preferences/StringPreferenceValue.java 2011-02-18
16:42:58 UTC (rev 29245)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/preferences/StringPreferenceValue.java 2011-02-18
16:45:00 UTC (rev 29246)
@@ -1,34 +0,0 @@
-/*******************************************************************************
- * 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.internal.deltacloud.ui.preferences;
-
-
-/**
- * @author Andre Dietisheim
- */
-public class StringPreferenceValue extends AbstractPreferenceValue<String> {
-
- public StringPreferenceValue(String prefsKey, String pluginId) {
- super(prefsKey, pluginId);
- }
-
- public String get() {
- return get(null);
- }
-
- public String get(String currentValue) {
- return doGet(currentValue);
- }
-
- public void store(String value) {
- doStore(value);
- }
-}
Deleted:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/preferences/StringsPreferenceValue.java
===================================================================
---
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/preferences/StringsPreferenceValue.java 2011-02-18
16:42:58 UTC (rev 29245)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/preferences/StringsPreferenceValue.java 2011-02-18
16:45:00 UTC (rev 29246)
@@ -1,188 +0,0 @@
-/*******************************************************************************
- * 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.internal.deltacloud.ui.preferences;
-
-import java.io.UnsupportedEncodingException;
-import java.net.URLEncoder;
-import java.util.ArrayList;
-import java.util.StringTokenizer;
-
-/**
- * A class that offers access to a collection of values that is stored in the
- * preferences under a single key.
- *
- * @author Andre Dietisheim
- */
-public class StringsPreferenceValue extends AbstractPreferenceValue<String[]> {
-
- private String delimiter;
- private String escapedDelimiter;
-
- public StringsPreferenceValue(char delimiter, String prefsKey, String pluginId) {
- super(prefsKey, pluginId);
- this.delimiter = String.valueOf(delimiter);
- try {
- this.escapedDelimiter = URLEncoder.encode(String.valueOf(delimiter),
"UTF-8");
- } catch (UnsupportedEncodingException e) {
- // cannot happen since we use a fixed, known encoding
- }
- }
-
- public String[] get() {
- return get(null);
- }
-
- public String[] get(String[] currentValues) {
-
- String string = doGet(null);
- String[] prefValues = split(string);
- return overrideValues(currentValues, prefValues);
- }
-
- private String[] split(String string) {
- ArrayList<String> values = new ArrayList<String>();
- StringTokenizer tokenizer = new StringTokenizer(string, delimiter);
- while (tokenizer.hasMoreTokens()) {
- String value = tokenizer.nextToken();
- String unescapedValue = unescapeDelimiterCharacter(value);
- values.add(unescapedValue);
- }
- return values.toArray(new String[values.size()]);
- }
-
- private String[] overrideValues(String[] newValues, String[] prefValues) {
- if (prefValues == null) {
- return newValues;
- }
-
- for (int i = 0; i < prefValues.length; i++) {
- if (newValues == null
- || newValues.length < i) {
- break;
- }
- prefValues[i] = newValues[i];
- }
- return prefValues;
- }
-
- /**
- * Adds the given string value to this preference value(s). Duplicate values
- * are not added.
- *
- * @param value
- * the value to add
- */
- public void add(String value) {
- String currentValues = doGet();
- StringBuilder builder = new StringBuilder(currentValues);
- value = escapeDelimiterCharacter(value);
- if (!contains(value, currentValues)) {
- if (hasValues(currentValues)) {
- builder.append(delimiter);
- }
- builder.append(value);
- doStore(builder.toString());
- }
- }
-
- private String escapeDelimiterCharacter(String value) {
- if (value == null || value.length() == 0) {
- return value;
- }
-
- int index = value.indexOf(delimiter);
- if (index < 0) {
- return value;
- }
- StringBuilder builder = new StringBuilder(value.substring(0, index));
- builder.append(escapedDelimiter);
- builder.append(value.substring(index + 1));
- return builder.toString();
- }
-
- private String unescapeDelimiterCharacter(String value) {
- if (value == null || value.length() == 0) {
- return value;
- }
-
- int index = value.indexOf(escapedDelimiter);
- if (index < 0) {
- return value;
- }
- StringBuilder builder = new StringBuilder(value.substring(0, index));
- builder.append(delimiter);
- builder.append(value.substring(index + 1));
- return builder.toString();
- }
-
- private boolean contains(String value, String currentValues) {
- return currentValues != null
- && currentValues.length() > 0
- && currentValues.indexOf(value) >= 0;
- }
-
- private boolean hasValues(String currentValues) {
- return currentValues != null && currentValues.length() > 0;
- }
-
- /**
- * Removes the given values from the strings stored in the preferences and
- * stores the preferences.
- *
- * @param values
- * the values
- */
- public void remove(String... valuesToRemove) {
- boolean removed = false;
- String[] currentValues = get();
- if (valuesToRemove != null) {
- for (int i = 0; i < currentValues.length; i++) {
- for (String valueToRemove : valuesToRemove) {
- if (valueToRemove.equals(currentValues[i])) {
- currentValues[i] = null;
- removed = true;
- }
- }
- }
- }
- if (removed) {
- store(currentValues);
- }
- }
-
- /**
- * Overrides the current values in the preferences with the values in the
- * given array (value in the preferences at index x is overridden with the
- * value in the given array at index x) and stores the preferences.
- */
- public void store(String[] newValues) {
- String[] currentValues = get();
- overrideValues(newValues, currentValues);
- doStore(concatenate(currentValues));
- }
-
- public void store() {
- store(null);
- }
-
- protected String concatenate(String[] values) {
- StringBuilder builder = new StringBuilder();
- for (int i = 0; i < values.length; i++) {
- if (values[i] != null) {
- if (builder.length() > 0) {
- builder.append(delimiter);
- }
- builder.append(values[i]);
- }
- }
- return builder.toString();
- }
-}
Modified:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/utils/UIUtils.java
===================================================================
---
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/utils/UIUtils.java 2011-02-18
16:42:58 UTC (rev 29245)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/utils/UIUtils.java 2011-02-18
16:45:00 UTC (rev 29246)
@@ -28,7 +28,7 @@
import org.eclipse.swt.widgets.Text;
import org.jboss.tools.deltacloud.ui.Activator;
import org.jboss.tools.deltacloud.ui.IDeltaCloudPreferenceConstants;
-import org.jboss.tools.internal.deltacloud.ui.preferences.StringsPreferenceValue;
+import org.jboss.tools.deltacloud.ui.preferences.StringsPreferenceValue;
import org.osgi.service.prefs.Preferences;
/**
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 2011-02-18
16:42:58 UTC (rev 29245)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/CloudConnectionPage.java 2011-02-18
16:45:00 UTC (rev 29246)
@@ -60,12 +60,13 @@
import org.jboss.tools.deltacloud.core.DeltaCloudException;
import org.jboss.tools.deltacloud.core.DeltaCloudManager;
import org.jboss.tools.deltacloud.ui.Activator;
+import org.jboss.tools.deltacloud.ui.IDeltaCloudPreferenceConstants;
import org.jboss.tools.deltacloud.ui.SWTImagesFactory;
+import org.jboss.tools.deltacloud.ui.preferences.StringPreferenceValue;
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.jboss.tools.internal.deltacloud.ui.preferences.IPreferenceKeys;
-import org.jboss.tools.internal.deltacloud.ui.preferences.StringPreferenceValue;
import org.jboss.tools.internal.deltacloud.ui.utils.UIUtils;
/**
@@ -74,10 +75,6 @@
*/
public class CloudConnectionPage extends WizardPage {
- private static final String NAME_PROPOSAL_KEY = "cloud_name";
- private static final String USERNAME_PROPOSAL_KEY = "cloud_username";
- private static final String URL_PROPOSAL_KEY = "cloud_url";
-
private static final int CLOUDTYPE_CHECK_DELAY = 1000;
private static final String DESCRIPTION = "CloudConnection.desc";
//$NON-NLS-1$
@@ -335,7 +332,7 @@
Label nameLabel = new Label(container, SWT.NULL);
nameLabel.setText(WizardMessages.getString(NAME_LABEL));
Text nameText = new Text(container, SWT.BORDER | SWT.SINGLE);
- UIUtils.createPreferencesProposalAdapter(nameText, NAME_PROPOSAL_KEY);
+ UIUtils.createPreferencesProposalAdapter(nameText,
IDeltaCloudPreferenceConstants.CLOUD_NAME_PROPOSAL_KEY);
bindName(dbc, nameText);
// url
@@ -343,7 +340,7 @@
urlLabel.setText(WizardMessages.getString(URL_LABEL));
Point p1 = urlLabel.computeSize(SWT.DEFAULT, SWT.DEFAULT);
Text urlText = new Text(container, SWT.BORDER | SWT.SINGLE);
- UIUtils.createPreferencesProposalAdapter(urlText, URL_PROPOSAL_KEY);
+ UIUtils.createPreferencesProposalAdapter(urlText,
IDeltaCloudPreferenceConstants.CLOUD_URL_PROPOSAL_KEY);
dbc.bindValue(
WidgetProperties.text(SWT.Modify).observe(urlText),
BeanProperties.value(
@@ -368,7 +365,7 @@
Label usernameLabel = new Label(container, SWT.NULL);
usernameLabel.setText(WizardMessages.getString(USERNAME_LABEL));
Text usernameText = new Text(container, SWT.BORDER | SWT.SINGLE);
- UIUtils.createPreferencesProposalAdapter(usernameText, USERNAME_PROPOSAL_KEY);
+ UIUtils.createPreferencesProposalAdapter(usernameText,
IDeltaCloudPreferenceConstants.CLOUD_USERNAME_PROPOSAL_KEY);
IObservableValue usernameObservable =
WidgetProperties.text(SWT.Modify).observe(usernameText);
dbc.bindValue(
usernameObservable,
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 2011-02-18
16:42:58 UTC (rev 29245)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/NewCloudConnectionWizard.java 2011-02-18
16:45:00 UTC (rev 29246)
@@ -27,8 +27,8 @@
import org.jboss.tools.deltacloud.core.DeltaCloudManager;
import org.jboss.tools.deltacloud.ui.Activator;
import org.jboss.tools.deltacloud.ui.ErrorUtils;
+import org.jboss.tools.deltacloud.ui.preferences.StringPreferenceValue;
import org.jboss.tools.internal.deltacloud.ui.preferences.IPreferenceKeys;
-import org.jboss.tools.internal.deltacloud.ui.preferences.StringPreferenceValue;
import org.jboss.tools.internal.deltacloud.ui.utils.WizardUtils;
/**
Modified:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/NewInstancePage.java
===================================================================
---
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/NewInstancePage.java 2011-02-18
16:42:58 UTC (rev 29245)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/NewInstancePage.java 2011-02-18
16:45:00 UTC (rev 29246)
@@ -68,6 +68,7 @@
import org.jboss.tools.deltacloud.core.job.AbstractCloudElementJob;
import org.jboss.tools.deltacloud.core.job.AbstractCloudElementJob.CLOUDELEMENT;
import org.jboss.tools.deltacloud.ui.Activator;
+import org.jboss.tools.deltacloud.ui.IDeltaCloudPreferenceConstants;
import org.jboss.tools.deltacloud.ui.SWTImagesFactory;
import
org.jboss.tools.internal.deltacloud.ui.common.databinding.validator.MandatoryStringValidator;
import
org.jboss.tools.internal.deltacloud.ui.common.databinding.validator.SelectedComboItemValidator;
@@ -80,10 +81,6 @@
*/
public class NewInstancePage extends WizardPage {
- private static final String NAME_PROPOSAL_KEY = "instance_name";
- private static final String IMAGE_PROPOSAL_KEY = "instance_image";
- private static final String KEY_PROPOSAL_KEY = "instance_key";
-
private static final int IMAGE_CHECK_DELAY = 500;
private static final int KEY_CHECK_DELAY = 500;
@@ -155,7 +152,7 @@
super(WizardMessages.getString(NAME));
this.cloud = cloud;
String defaultKeyname = cloud.getLastKeyname();
- model = new NewInstancePageModel(defaultKeyname, image); //$NON-NLS-1$
+ model = new NewInstancePageModel(defaultKeyname, image, cloud); //$NON-NLS-1$
setDescription(WizardMessages.getString(DESCRIPTION));
setTitle(WizardMessages.getString(TITLE));
setImageDescriptor(SWTImagesFactory.DESC_DELTA_LARGE);
@@ -180,14 +177,14 @@
nameLabel.setText(WizardMessages.getString(NAME_LABEL));
GridDataFactory.fillDefaults().align(SWT.LEFT, SWT.CENTER).applyTo(nameLabel);
this.nameText = new Text(container, SWT.BORDER | SWT.SINGLE);
- UIUtils.createPreferencesProposalAdapter(nameText, NAME_PROPOSAL_KEY);
+ UIUtils.createPreferencesProposalAdapter(nameText,
IDeltaCloudPreferenceConstants.INSTANCE_NAME_PROPOSAL_KEY);
GridDataFactory.fillDefaults().span(2, 1).grab(true, false).applyTo(nameText);
Label imageLabel = new Label(container, SWT.NULL);
imageLabel.setText(WizardMessages.getString(IMAGE_LABEL));
GridDataFactory.fillDefaults().align(SWT.LEFT, SWT.CENTER).applyTo(imageLabel);
this.imageText = new Text(container, SWT.BORDER | SWT.SINGLE);
- UIUtils.createPreferencesProposalAdapter(imageText, IMAGE_PROPOSAL_KEY);
+ UIUtils.createPreferencesProposalAdapter(imageText,
IDeltaCloudPreferenceConstants.INSTANCE_IMAGE_PROPOSAL_KEY);
GridDataFactory.fillDefaults().grab(true, false).align(SWT.FILL,
SWT.CENTER).applyTo(imageText);
Button findImageButton = new Button(container, SWT.NULL);
findImageButton.setText(WizardMessages.getString(FIND_BUTTON_LABEL));
@@ -212,7 +209,7 @@
keyLabel.setText(WizardMessages.getString(KEY_LABEL));
GridDataFactory.fillDefaults().align(SWT.LEFT, SWT.CENTER).applyTo(keyLabel);
keyText = new Text(container, SWT.BORDER | SWT.SINGLE);
- UIUtils.createPreferencesProposalAdapter(keyText, KEY_PROPOSAL_KEY);
+ UIUtils.createPreferencesProposalAdapter(keyText,
IDeltaCloudPreferenceConstants.INSTANCE_KEY_PROPOSAL_KEY);
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).applyTo(keyText);
Button keyManageButton = new Button(container, SWT.NULL);
keyManageButton.setText(WizardMessages.getString(MANAGE_BUTTON_LABEL));
Modified:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/NewInstancePageModel.java
===================================================================
---
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/NewInstancePageModel.java 2011-02-18
16:42:58 UTC (rev 29245)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/NewInstancePageModel.java 2011-02-18
16:45:00 UTC (rev 29246)
@@ -14,6 +14,7 @@
import java.util.Collection;
import java.util.List;
+import org.jboss.tools.deltacloud.core.DeltaCloud;
import org.jboss.tools.deltacloud.core.DeltaCloudHardwareProfile;
import org.jboss.tools.deltacloud.core.DeltaCloudImage;
import org.jboss.tools.deltacloud.core.DeltaCloudRealm;
@@ -49,8 +50,10 @@
private String cpu;
private String storage;
private String memory;
+ private DeltaCloud cloud;
- protected NewInstancePageModel(String keyId, DeltaCloudImage image) {
+ protected NewInstancePageModel(String keyId, DeltaCloudImage image, DeltaCloud cloud) {
+ this.cloud = cloud;
this.keyId = keyId;
this.image = image;
}
@@ -74,6 +77,10 @@
setArch(image.getArchitecture());
}
+ public int getSelectedRealmIndex() {
+ return realms.indexOf(selectedRealm);
+ }
+
public void setSelectedRealmIndex(int index) {
if (realms.size() > index) {
int oldIndex = -1;
@@ -82,17 +89,34 @@
oldIndex = realms.indexOf(selectedRealm);
}
DeltaCloudRealm deltaCloudRealm = realms.get(index);
- setSelectedRealm(deltaCloudRealm);
+ selectedRealm = deltaCloudRealm;
+ cloud.setLastRealmName(selectedRealm.getName());
firePropertyChange(PROPERTY_SELECTED_REALM_INDEX, oldIndex, index);
}
}
- public int getSelectedRealmIndex() {
- return realms.indexOf(selectedRealm);
+ private void setSelectedRealm(String name) {
+ if (realms.size() > 0) {
+ int index = getRealmIndex(name);
+ if (index >= 0) {
+ setSelectedRealmIndex(index);
+ }
+ }
}
- public void setSelectedRealm(DeltaCloudRealm realm) {
- selectedRealm = realm;
+ private int getRealmIndex(String name) {
+ int index = 0;
+ if (name != null
+ && realms != null
+ && realms.size() > 0) {
+ for (int i = 0; i < realms.size(); i++) {
+ if (name.equals(realms.get(i).getName())) {
+ index = i;
+ break;
+ }
+ }
+ }
+ return index;
}
public String getRealmId() {
@@ -104,14 +128,14 @@
protected void setRealms(List<DeltaCloudRealm> realms) {
firePropertyChange(PROPERTY_REALMS, this.realms, this.realms = realms);
- setSelectedRealmIndex(0);
+ setSelectedRealm(cloud.getLastRealmName());
}
public List<DeltaCloudRealm> getRealms() {
return realms;
}
- protected void setAllProfiles(List<DeltaCloudHardwareProfile> profiles) {
+ public void setAllProfiles(List<DeltaCloudHardwareProfile> profiles) {
firePropertyChange(PROP_ALL_PROFILES, this.allProfiles, this.allProfiles = profiles);
setFilteredProfiles(filterProfiles(image, profiles));
}
@@ -122,7 +146,7 @@
private void setFilteredProfiles(List<DeltaCloudHardwareProfile> profiles) {
firePropertyChange(PROP_FILTERED_PROFILES, this.filteredProfiles, this.filteredProfiles
= profiles);
- setSelectedProfileIndex(0);
+ setSelectedProfileIndex();
}
public List<DeltaCloudHardwareProfile> getFilteredProfiles() {
@@ -143,6 +167,24 @@
return filteredProfiles;
}
+ private void setSelectedProfileIndex() {
+ setSelectedProfileIndex(getProfileIndex(cloud.getLastProfileId()));
+ }
+
+ private int getProfileIndex(String selectedProfileId) {
+ int index = 0;
+ if (selectedProfileId != null
+ && filteredProfiles != null && filteredProfiles.size() > 0) {
+ for (int i = 0; i < filteredProfiles.size(); i++) {
+ if (selectedProfileId.equals(filteredProfiles.get(i).getId())) {
+ index = i;
+ break;
+ }
+ }
+ }
+ return index;
+ }
+
public void setSelectedProfileIndex(int index) {
if (filteredProfiles.size() > index) {
int oldIndex = -1;
@@ -151,8 +193,9 @@
oldIndex = filteredProfiles.indexOf(selectedProfile);
}
DeltaCloudHardwareProfile hardwareProfile = filteredProfiles.get(index);
- setSelectedProfile(hardwareProfile);
+ selectedProfile = hardwareProfile;
firePropertyChange(PROP_SELECTED_PROFILE_INDEX, oldIndex, index);
+ cloud.setLastProfileId(hardwareProfile.getId());
}
}
@@ -164,10 +207,6 @@
return filteredProfiles.indexOf(selectedProfile);
}
- public void setSelectedProfile(DeltaCloudHardwareProfile profile) {
- selectedProfile = profile;
- }
-
public String getProfileId() {
if (selectedProfile == null) {
return null;
Modified:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/SshPrivateKeysPreferences.java
===================================================================
---
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/SshPrivateKeysPreferences.java 2011-02-18
16:42:58 UTC (rev 29245)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/SshPrivateKeysPreferences.java 2011-02-18
16:45:00 UTC (rev 29246)
@@ -16,8 +16,8 @@
import org.eclipse.core.runtime.Platform;
import org.jboss.tools.deltacloud.core.DeltaCloudException;
import org.jboss.tools.deltacloud.core.client.utils.StringUtils;
-import org.jboss.tools.internal.deltacloud.ui.preferences.StringPreferenceValue;
-import org.jboss.tools.internal.deltacloud.ui.preferences.StringsPreferenceValue;
+import org.jboss.tools.deltacloud.ui.preferences.StringPreferenceValue;
+import org.jboss.tools.deltacloud.ui.preferences.StringsPreferenceValue;
/**
* @author André Dietisheim