Author: adietish
Date: 2011-01-17 04:47:42 -0500 (Mon, 17 Jan 2011)
New Revision: 28287
Added:
branches/jbosstools-3.2.0.CR1/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/common/databinding/validator/ObjectNotNullToBoolean.java
branches/jbosstools-3.2.0.CR1/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/common/databinding/validator/StringNotEmptyToBoolean.java
branches/jbosstools-3.2.0.CR1/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/common/databinding/validator/ValidWritableFilePathValidator.java
Removed:
branches/jbosstools-3.2.0.CR1/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/common/databinding/validator/BoundObjectPresentConverter.java
Modified:
branches/jbosstools-3.2.0.CR1/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/client/DeltaCloudClientImpl.java
branches/jbosstools-3.2.0.CR1/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/preferences/StringEntriesPreferenceValue.java
branches/jbosstools-3.2.0.CR1/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/ManageKeysPage.java
branches/jbosstools-3.2.0.CR1/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/ManageKeysPageModel.java
branches/jbosstools-3.2.0.CR1/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/NewInstanceWizard.java
branches/jbosstools-3.2.0.CR1/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/PemFileManager.java
branches/jbosstools-3.2.0.CR1/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/SshPrivateKeysPreferences.java
branches/jbosstools-3.2.0.CR1/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/WizardMessages.properties
Log:
[JBIDE-8096]
Modified:
branches/jbosstools-3.2.0.CR1/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/client/DeltaCloudClientImpl.java
===================================================================
---
branches/jbosstools-3.2.0.CR1/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/client/DeltaCloudClientImpl.java 2011-01-17
09:46:55 UTC (rev 28286)
+++
branches/jbosstools-3.2.0.CR1/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/client/DeltaCloudClientImpl.java 2011-01-17
09:47:42 UTC (rev 28287)
@@ -396,7 +396,7 @@
}
public void deleteKey(String keyname) throws DeltaCloudClientException {
- requestStringResponse(new DeleteKeyRequest(baseUrl, keyname));
+ request(new DeleteKeyRequest(baseUrl, keyname));
}
public List<Key> listKeys() throws DeltaCloudClientException {
Deleted:
branches/jbosstools-3.2.0.CR1/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/common/databinding/validator/BoundObjectPresentConverter.java
===================================================================
---
branches/jbosstools-3.2.0.CR1/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/common/databinding/validator/BoundObjectPresentConverter.java 2011-01-17
09:46:55 UTC (rev 28286)
+++
branches/jbosstools-3.2.0.CR1/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/common/databinding/validator/BoundObjectPresentConverter.java 2011-01-17
09:47:42 UTC (rev 28287)
@@ -1,28 +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.common.databinding.validator;
-
-import org.eclipse.core.databinding.conversion.Converter;
-
-/**
- * @author André Dietisheim
- */
-public class BoundObjectPresentConverter extends Converter {
-
- public BoundObjectPresentConverter() {
- super(Object.class, Boolean.class);
- }
-
- @Override
- public Object convert(Object fromObject) {
- return fromObject != null;
- }
-}
Copied:
branches/jbosstools-3.2.0.CR1/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/common/databinding/validator/ObjectNotNullToBoolean.java
(from rev 28147,
branches/jbosstools-3.2.0.CR1/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/common/databinding/validator/BoundObjectPresentConverter.java)
===================================================================
---
branches/jbosstools-3.2.0.CR1/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/common/databinding/validator/ObjectNotNullToBoolean.java
(rev 0)
+++
branches/jbosstools-3.2.0.CR1/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/common/databinding/validator/ObjectNotNullToBoolean.java 2011-01-17
09:47:42 UTC (rev 28287)
@@ -0,0 +1,28 @@
+/*******************************************************************************
+ * 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.common.databinding.validator;
+
+import org.eclipse.core.databinding.conversion.Converter;
+
+/**
+ * @author André Dietisheim
+ */
+public class ObjectNotNullToBoolean extends Converter {
+
+ public ObjectNotNullToBoolean() {
+ super(Object.class, Boolean.class);
+ }
+
+ @Override
+ public Object convert(Object fromObject) {
+ return fromObject != null;
+ }
+}
Property changes on:
branches/jbosstools-3.2.0.CR1/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/common/databinding/validator/ObjectNotNullToBoolean.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
branches/jbosstools-3.2.0.CR1/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/common/databinding/validator/StringNotEmptyToBoolean.java
===================================================================
---
branches/jbosstools-3.2.0.CR1/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/common/databinding/validator/StringNotEmptyToBoolean.java
(rev 0)
+++
branches/jbosstools-3.2.0.CR1/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/common/databinding/validator/StringNotEmptyToBoolean.java 2011-01-17
09:47:42 UTC (rev 28287)
@@ -0,0 +1,29 @@
+/*******************************************************************************
+ * 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.common.databinding.validator;
+
+import org.eclipse.core.databinding.conversion.Converter;
+
+/**
+ * @author André Dietisheim
+ */
+public class StringNotEmptyToBoolean extends Converter {
+
+ public StringNotEmptyToBoolean() {
+ super(String.class, Boolean.class);
+ }
+
+ @Override
+ public Object convert(Object fromObject) {
+ return fromObject != null
+ && !((String) fromObject).isEmpty();
+ }
+}
Property changes on:
branches/jbosstools-3.2.0.CR1/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/common/databinding/validator/StringNotEmptyToBoolean.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
branches/jbosstools-3.2.0.CR1/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/common/databinding/validator/ValidWritableFilePathValidator.java
===================================================================
---
branches/jbosstools-3.2.0.CR1/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/common/databinding/validator/ValidWritableFilePathValidator.java
(rev 0)
+++
branches/jbosstools-3.2.0.CR1/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/common/databinding/validator/ValidWritableFilePathValidator.java 2011-01-17
09:47:42 UTC (rev 28287)
@@ -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.internal.deltacloud.ui.common.databinding.validator;
+
+import java.io.File;
+
+import org.eclipse.core.databinding.validation.IValidator;
+import org.eclipse.core.databinding.validation.ValidationStatus;
+import org.eclipse.core.runtime.IStatus;
+
+/**
+ * @author André Dietisheim
+ */
+public class ValidWritableFilePathValidator implements IValidator {
+
+ @Override
+ public IStatus validate(Object value) {
+ if (value instanceof String) {
+ File file = new File((String) value);
+ if (file.exists() &&
+ file.canWrite()) {
+ return ValidationStatus.ok();
+ }
+ }
+ return ValidationStatus.error("You must choose a valid and writable
location");
+ }
+}
Property changes on:
branches/jbosstools-3.2.0.CR1/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/common/databinding/validator/ValidWritableFilePathValidator.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified:
branches/jbosstools-3.2.0.CR1/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/preferences/StringEntriesPreferenceValue.java
===================================================================
---
branches/jbosstools-3.2.0.CR1/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/preferences/StringEntriesPreferenceValue.java 2011-01-17
09:46:55 UTC (rev 28286)
+++
branches/jbosstools-3.2.0.CR1/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/preferences/StringEntriesPreferenceValue.java 2011-01-17
09:47:42 UTC (rev 28287)
@@ -85,17 +85,21 @@
* 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;
}
}
}
}
- store(currentValues);
+ if (removed) {
+ store(currentValues);
+ }
}
/**
Modified:
branches/jbosstools-3.2.0.CR1/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/ManageKeysPage.java
===================================================================
---
branches/jbosstools-3.2.0.CR1/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/ManageKeysPage.java 2011-01-17
09:46:55 UTC (rev 28286)
+++
branches/jbosstools-3.2.0.CR1/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/ManageKeysPage.java 2011-01-17
09:47:42 UTC (rev 28287)
@@ -12,14 +12,21 @@
import java.text.MessageFormat;
+import org.eclipse.core.databinding.Binding;
import org.eclipse.core.databinding.DataBindingContext;
import org.eclipse.core.databinding.UpdateListStrategy;
import org.eclipse.core.databinding.UpdateSetStrategy;
import org.eclipse.core.databinding.UpdateValueStrategy;
import org.eclipse.core.databinding.beans.BeanProperties;
import org.eclipse.core.databinding.conversion.Converter;
+import org.eclipse.core.databinding.observable.value.IObservableValue;
+import org.eclipse.core.databinding.observable.value.WritableValue;
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.databinding.fieldassist.ControlDecorationSupport;
import org.eclipse.jface.databinding.swt.WidgetProperties;
import org.eclipse.jface.dialogs.IInputValidator;
import org.eclipse.jface.dialogs.InputDialog;
@@ -33,15 +40,24 @@
import org.eclipse.swt.events.SelectionListener;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.DirectoryDialog;
import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Group;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.List;
import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Text;
+import org.jboss.tools.common.log.StatusFactory;
import org.jboss.tools.deltacloud.core.DeltaCloud;
+import org.jboss.tools.deltacloud.core.DeltaCloudException;
import org.jboss.tools.deltacloud.core.DeltaCloudKey;
+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.ErrorUtils;
import org.jboss.tools.deltacloud.ui.SWTImagesFactory;
-import
org.jboss.tools.internal.deltacloud.ui.common.databinding.validator.BoundObjectPresentConverter;
+import
org.jboss.tools.internal.deltacloud.ui.common.databinding.validator.ObjectNotNullToBoolean;
+import
org.jboss.tools.internal.deltacloud.ui.common.databinding.validator.ValidWritableFilePathValidator;
import org.jboss.tools.internal.deltacloud.ui.utils.WizardUtils;
/**
@@ -60,7 +76,6 @@
private final static String CONFIRM_KEY_DELETE_TITLE =
"ConfirmKeyDelete.title"; //$NON-NLS-1$
private final static String CONFIRM_KEY_DELETE_MSG = "ConfirmKeyDelete.msg";
//$NON-NLS-1$
- private List keyList;
private ManageKeysPageModel model;
private class Key2IdConverter extends Converter {
@@ -123,33 +138,25 @@
setPageComplete(false);
}
- private void refreshKeys() {
- try {
- Job job = model.refreshKeys();
- WizardUtils.runInWizard(job, getContainer());
- } catch (Exception e) {
- // ignore since the job will report its failure
- }
- }
-
- public DeltaCloudKey getKey() {
- return model.getSelectedKey();
- }
-
@Override
public void createControl(Composite parent) {
DataBindingContext dbc = new DataBindingContext();
// WizardPageSupport.create(this, dbc);
+ bindWizardComplete(dbc);
- bindWizardComplete(dbc);
Composite container = new Composite(parent, SWT.NULL);
- GridLayoutFactory.fillDefaults().numColumns(4).equalWidth(false).applyTo(container);
+ GridLayoutFactory.fillDefaults()
+ .numColumns(4).equalWidth(false).applyTo(container);
- this.keyList = createKeyList(dbc, container);
- GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).grab(true, true).span(4,
5).applyTo(keyList);
+ Label keyListLabel = new Label(container, SWT.NULL);
+ keyListLabel.setText("Keys available on the server:");
+ GridDataFactory.fillDefaults().span(4, 1).applyTo(keyListLabel);
+ List keyList = createKeyList(dbc, container);
+ GridDataFactory.fillDefaults()
+ .align(SWT.FILL, SWT.FILL).grab(true, true).span(4, 8).hint(100,
200).applyTo(keyList);
+
Button refreshButton = new Button(container, SWT.NULL);
- // TODO: Internationalize strings
refreshButton.setText("Refresh keys");
refreshButton.addSelectionListener(onRefreshPressed());
GridDataFactory.fillDefaults().applyTo(refreshButton);
@@ -157,19 +164,73 @@
Label dummyLabel = new Label(container, SWT.NULL);
GridDataFactory.fillDefaults().grab(true, false).applyTo(dummyLabel);
- Button createButton = new Button(container, SWT.NULL);
- createButton.setText(WizardMessages.getString(NEW));
- createButton.addSelectionListener(onNewPressed());
+ Button createButton = createNewButton(container, dbc);
GridDataFactory.fillDefaults().applyTo(createButton);
Button deleteButton = createDeleteButton(container, dbc);
GridDataFactory.fillDefaults().applyTo(deleteButton);
+ Group localStorageGroup = new Group(container, SWT.BORDER);
+ localStorageGroup.setText("Local Keystore");
+ GridDataFactory.fillDefaults().span(4, 1).applyTo(localStorageGroup);
+ GridLayoutFactory.fillDefaults()
+ .numColumns(2).extendedMargins(10, 10, 10, 14).applyTo(localStorageGroup);
+
+ Text keyStoreText = new Text(localStorageGroup, SWT.BORDER);
+ bindKeyStoreText(keyStoreText, dbc);
+ GridDataFactory.fillDefaults()
+ .grab(true, false).align(SWT.FILL, SWT.CENTER).applyTo(keyStoreText);
+ addKeyStoreLocationDecoration(keyStoreText, dbc);
+
+ Button keyStoreBrowseButton = new Button(localStorageGroup, SWT.None);
+ keyStoreBrowseButton.addSelectionListener(onKeyStoreLocationBrowse());
+ keyStoreBrowseButton.setText("Choose...");
+ GridDataFactory.fillDefaults().align(SWT.CENTER, SWT.CENTER);
+
setControl(container);
refreshKeys();
}
+ private void addKeyStoreLocationDecoration(Text keyStoreText, DataBindingContext dbc) {
+ IObservableValue observable = new WritableValue();
+ Binding binding = dbc.bindValue(
+ WidgetProperties.text(SWT.Modify).observe(keyStoreText),
+ observable,
+ new UpdateValueStrategy().setBeforeSetValidator(new
ValidWritableFilePathValidator()),
+ new UpdateValueStrategy().setBeforeSetValidator(new
ValidWritableFilePathValidator()));
+ ControlDecorationSupport.create(binding, SWT.LEFT | SWT.TOP);
+ }
+
+ private Button createNewButton(Composite container, DataBindingContext dbc) {
+ Button newButton = new Button(container, SWT.NULL);
+ newButton.setText(WizardMessages.getString(NEW));
+ newButton.addSelectionListener(onNewPressed());
+ return newButton;
+ }
+
+ private void bindKeyStoreText(Text keyStoreText, DataBindingContext dbc) {
+ dbc.bindValue(
+ WidgetProperties.text(SWT.Modify).observe(keyStoreText),
+ BeanProperties.value(ManageKeysPageModel.PROP_KEY_STORE_PATH).observe(model));
+ }
+
+ private SelectionListener onKeyStoreLocationBrowse() {
+ return new SelectionAdapter() {
+
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ DirectoryDialog dialog = new DirectoryDialog(getShell(), SWT.NONE);
+ dialog.setFilterPath(model.getKeyStorePath());
+ dialog.setText("Choose a directory to store new keys");
+ String keyStorePath = dialog.open();
+ if (keyStorePath != null && keyStorePath.length() > 0) {
+ model.setKeyStorePath(keyStorePath);
+ }
+ }
+ };
+ }
+
private Button createDeleteButton(Composite container, DataBindingContext dbc) {
Button deleteButton = new Button(container, SWT.NULL);
deleteButton.setText(WizardMessages.getString(DELETE));
@@ -179,7 +240,7 @@
WidgetProperties.enabled().observe(deleteButton),
BeanProperties.value(ManageKeysPageModel.PROP_SELECTED_KEY).observe(model),
new UpdateValueStrategy(UpdateSetStrategy.POLICY_NEVER),
- new UpdateValueStrategy().setConverter(new BoundObjectPresentConverter()));
+ new UpdateValueStrategy().setConverter(new ObjectNotNullToBoolean()));
return deleteButton;
}
@@ -188,7 +249,7 @@
BeanProperties.value("pageComplete").observe(this),
BeanProperties.value(ManageKeysPageModel.PROP_SELECTED_KEY).observe(model),
new UpdateValueStrategy(UpdateSetStrategy.POLICY_NEVER),
- new UpdateValueStrategy().setConverter(new BoundObjectPresentConverter()));
+ new UpdateValueStrategy().setConverter(new ObjectNotNullToBoolean()));
}
private List createKeyList(DataBindingContext dbc, Composite container) {
@@ -200,7 +261,8 @@
new UpdateListStrategy(UpdateSetStrategy.POLICY_NEVER),
new UpdateListStrategy().setConverter(new Key2IdConverter()));
// bind selected key
- dbc.bindValue(WidgetProperties.selection().observe(keyList),
+ dbc.bindValue(
+ WidgetProperties.selection().observe(keyList),
BeanProperties.value(ManageKeysPageModel.PROP_SELECTED_KEY).observe(model),
new UpdateValueStrategy().setConverter(new Id2KeyConverter()),
new UpdateValueStrategy().setConverter(new Key2IdConverter()));
@@ -231,11 +293,31 @@
};
}
+ private void refreshKeys() {
+ Job job = new AbstractCloudElementJob("Get keys", model.getCloud(),
CLOUDELEMENT.KEYS) {
+
+ protected IStatus doRun(IProgressMonitor monitor) throws Exception {
+ try {
+ model.refreshKeys();
+ return Status.OK_STATUS;
+ } catch (DeltaCloudException e) {
+ return StatusFactory.getInstance(IStatus.ERROR, Activator.PLUGIN_ID,
+ MessageFormat.format("Could not get keys from cloud {0}",
getCloud().getName()), e);
+ }
+ }
+ };
+ try {
+ WizardUtils.runInWizard(job, getContainer());
+ } catch (Exception e) {
+ // ignore since the job will report its failure
+ }
+ }
+
private SelectionListener onNewPressed() {
return new SelectionAdapter() {
@Override
- public void widgetSelected(SelectionEvent e) {
+ public void widgetSelected(SelectionEvent event) {
Display display = Display.getDefault();
Shell shell = new Shell(display);
// String directoryText = directory.getText();
@@ -245,33 +327,92 @@
d.create();
if (d.open() == InputDialog.OK) {
String keyId = d.getValue();
- createKey(keyId);
+ DeltaCloudKey key = createKey(keyId);
+ storeKeyLocally(key);
}
}
+
};
}
- private void createKey(final String keyId) {
+ private DeltaCloudKey createKey(final String keyId) {
+ final DeltaCloudKey[] keyHolder = new DeltaCloudKey[1];
try {
- model.createKey(keyId);
+ Job job = new AbstractCloudElementJob("Create key", model.getCloud(),
CLOUDELEMENT.KEYS) {
+
+ protected IStatus doRun(IProgressMonitor monitor) throws Exception {
+ try {
+ keyHolder[0] = model.createKey(keyId);
+ return Status.OK_STATUS;
+ } catch (DeltaCloudException e) {
+ return StatusFactory.getInstance(IStatus.ERROR, Activator.PLUGIN_ID,
+ MessageFormat.format("Could not create key \"{0}\"", keyId),
e);
+ }
+ }
+ };
+ WizardUtils.runInWizard(job, getContainer());
} catch (Exception e) {
- // TODO: internationalize strings
- ErrorUtils.handleError(
- "Error",
- MessageFormat.format("Error", "Could not create key
\"{0}\"", keyId), e,
- getShell());
+ // ignore
}
+ return keyHolder[0];
}
+ private void storeKeyLocally(DeltaCloudKey key) {
+ try {
+ if (key != null) {
+ boolean store = MessageDialog.openConfirm(getShell(),
+ "Confirm to store the new key",
+ "Do you want to store the key locally and add it to the private keys?");
+ if (store) {
+ model.storeKeyLocally(key);
+ }
+ }
+ } catch (Exception e) {
+ ErrorUtils.handleError("Error", MessageFormat.format(
+ "Could not store key \"{0}\" locally and add it to the ssh private
keys", key.getName()),
+ e, getShell());
+ }
+ }
+
private void deleteKey() {
try {
- model.deleteSelectedKey();
+ Job job = new AbstractCloudElementJob("Delete key", model.getCloud(),
CLOUDELEMENT.KEYS) {
+
+ protected IStatus doRun(IProgressMonitor monitor) throws Exception {
+ try {
+ final DeltaCloudKey key = model.deleteSelectedKey();
+ final boolean[] isConfirmDelete = new boolean[] { false };
+ if (PemFileManager.exists(key.getName(),
SshPrivateKeysPreferences.getSshKeyDirectory())) {
+ getShell().getDisplay().syncExec(new Runnable() {
+
+ @Override
+ public void run() {
+ isConfirmDelete[0] = MessageDialog.openConfirm(
+ getShell(),
+ "Delete key locally?",
+ MessageFormat.format(
+ "Shall the key \"{0}\" be deleted from local key
store?",
+ key.getName()));
+ }
+ });
+ if (isConfirmDelete[0]) {
+ model.removeKeyLocally(key);
+ }
+ }
+ return Status.OK_STATUS;
+ } catch (DeltaCloudException e) {
+ return StatusFactory.getInstance(IStatus.ERROR, Activator.PLUGIN_ID,
+ MessageFormat.format("Could not delete key",
model.getSelectedKey().getId()), e);
+ }
+ }
+ };
+ WizardUtils.runInWizard(job, getContainer());
} catch (Exception e) {
- // TODO: internationalize strings
- ErrorUtils.handleError(
- "Error",
- MessageFormat.format("Error", "Could not create key
\"{0}\"", model.getSelectedKey().getId()), e,
- getShell());
+ // ignore
}
}
+
+ public DeltaCloudKey getKey() {
+ return model.getSelectedKey();
+ }
}
Modified:
branches/jbosstools-3.2.0.CR1/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/ManageKeysPageModel.java
===================================================================
---
branches/jbosstools-3.2.0.CR1/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/ManageKeysPageModel.java 2011-01-17
09:46:55 UTC (rev 28286)
+++
branches/jbosstools-3.2.0.CR1/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/ManageKeysPageModel.java 2011-01-17
09:47:42 UTC (rev 28287)
@@ -10,22 +10,15 @@
******************************************************************************/
package org.jboss.tools.internal.deltacloud.ui.wizards;
-import java.text.MessageFormat;
+import java.io.File;
+import java.io.FileNotFoundException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
-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.jboss.tools.common.log.StatusFactory;
import org.jboss.tools.deltacloud.core.DeltaCloud;
import org.jboss.tools.deltacloud.core.DeltaCloudException;
import org.jboss.tools.deltacloud.core.DeltaCloudKey;
-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.internal.deltacloud.ui.common.databinding.validator.ObservableUIPojo;
/**
@@ -37,41 +30,71 @@
public static final String PROP_KEYS = "keys";
public static final String PROP_KEYS_ADDED = "keyAdded";
public static final String PROP_KEYS_REMOVED = "keyRemoved";
+ public static final String PROP_KEY_STORE_PATH = "keyStorePath";
private List<DeltaCloudKey> keys = new ArrayList<DeltaCloudKey>();
private DeltaCloud cloud;
private DeltaCloudKey selectedKey;
+ private String keyStorePath;
public ManageKeysPageModel(DeltaCloud cloud) {
this.cloud = cloud;
- // asyncGetKeys(cloud);
+ this.keyStorePath = initKeyStorePath();
}
- public void deleteSelectedKey() throws DeltaCloudException {
+ private String initKeyStorePath() {
+ try {
+ return SshPrivateKeysPreferences.getSshKeyDirectory();
+ } catch (FileNotFoundException e) {
+ return null;
+ }
+ }
+
+ public DeltaCloudKey deleteSelectedKey() throws DeltaCloudException {
if (selectedKey == null) {
- return;
+ return null;
}
cloud.deleteKey(selectedKey.getId());
int index = keys.indexOf(selectedKey);
keys.remove(selectedKey);
fireIndexedPropertyChange(PROP_KEYS, index, selectedKey, null);
- PemFileManager.delete(selectedKey, SshPrivateKeysPreferences.getKeyStorePath());
+ DeltaCloudKey key = selectedKey;
setSelectedKey(index - 1);
+ return key;
}
- public void createKey(String keyId) throws DeltaCloudException {
+ public void removeKeyLocally(DeltaCloudKey key) throws DeltaCloudException,
FileNotFoundException {
+ if (key == null) {
+ return;
+ }
+
+ String keyStorePath = getKeyStorePath();
+ if (keyStorePath != null && keyStorePath.length() > 0) {
+ File pemFile = PemFileManager.delete(key, keyStorePath);
+ SshPrivateKeysPreferences.remove(pemFile.getAbsolutePath());
+ }
+ }
+
+ public DeltaCloudKey createKey(String keyId) throws DeltaCloudException {
DeltaCloudKey key = cloud.createKey(keyId);
keys.add(key);
int index = keys.indexOf(key);
fireIndexedPropertyChange(PROP_KEYS, index, null, key);
setSelectedKey(key);
- PemFileManager.create(key, SshPrivateKeysPreferences.getKeyStorePath());
+ return key;
}
- public Job refreshKeys() {
- return asyncGetKeys();
+ public void storeKeyLocally(DeltaCloudKey key) throws DeltaCloudException,
FileNotFoundException {
+ File pemFile = PemFileManager.create(key, getKeyStorePath());
+ SshPrivateKeysPreferences.add(pemFile.getAbsolutePath());
}
+ public void refreshKeys() throws DeltaCloudException {
+ java.util.List<DeltaCloudKey> newKeys = new ArrayList<DeltaCloudKey>();
+ newKeys.addAll(Arrays.asList(cloud.getKeys()));
+ setKeys(newKeys);
+ }
+
public DeltaCloudKey getSelectedKey() {
return selectedKey;
}
@@ -119,7 +142,13 @@
public void setKeys(List<DeltaCloudKey> newKeys) {
firePropertyChange(PROP_KEYS, this.keys, this.keys = newKeys);
- setSelectedKey();
+ /*
+ * need to reset selection since widget looses selection (when items are
+ * set) and property may not fire if no change in selection
+ */
+ DeltaCloudKey key = getSelectedKey();
+ setSelectedKey(null);
+ setSelectedKey(key);
}
public DeltaCloudKey getKey(String keyId) {
@@ -137,24 +166,17 @@
return matchingKey;
}
- private Job asyncGetKeys() {
- Job job = new AbstractCloudElementJob("Get keys", cloud, CLOUDELEMENT.KEYS)
{
+ public String getKeyStorePath() {
+ return keyStorePath;
+ }
- protected IStatus doRun(IProgressMonitor monitor) throws Exception {
- try {
- java.util.List<DeltaCloudKey> newKeys = new ArrayList<DeltaCloudKey>();
- newKeys.addAll(Arrays.asList(getCloud().getKeys()));
- setKeys(newKeys);
- return Status.OK_STATUS;
- } catch (DeltaCloudException e) {
- // TODO: internationalize strings
- return StatusFactory.getInstance(IStatus.ERROR, Activator.PLUGIN_ID,
- MessageFormat.format("Could not get keys from cloud {0}",
getCloud().getName()), e);
- }
- }
+ public void setKeyStorePath(String keyStorePath) {
+ System.err.println(keyStorePath);
+ firePropertyChange(PROP_KEY_STORE_PATH, this.keyStorePath, this.keyStorePath =
keyStorePath);
+ }
- };
- job.schedule();
- return job;
+ public DeltaCloud getCloud() {
+ return cloud;
}
+
}
Modified:
branches/jbosstools-3.2.0.CR1/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/NewInstanceWizard.java
===================================================================
---
branches/jbosstools-3.2.0.CR1/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/NewInstanceWizard.java 2011-01-17
09:46:55 UTC (rev 28286)
+++
branches/jbosstools-3.2.0.CR1/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/NewInstanceWizard.java 2011-01-17
09:47:42 UTC (rev 28287)
@@ -11,13 +11,12 @@
package org.jboss.tools.internal.deltacloud.ui.wizards;
import java.io.File;
-import java.io.UnsupportedEncodingException;
-import java.net.URLEncoder;
-import java.text.MessageFormat;
+import java.io.FileNotFoundException;
import org.eclipse.core.runtime.Assert;
import org.eclipse.core.runtime.preferences.InstanceScope;
import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.dialogs.MessageDialogWithToggle;
import org.eclipse.jface.wizard.Wizard;
import org.jboss.tools.common.jobs.ChainedJob;
@@ -98,59 +97,23 @@
String memory = model.getMemory();
String storage = model.getStorage();
String keyId = model.getKeyId();
- String name = utf8Encode(model.getName());
+ String name = model.getName();
// Save persistent settings for this particular cloud
cloud.setLastImageId(imageId);
cloud.setLastKeyname(keyId);
- Preferences prefs = new InstanceScope().getNode(Activator.PLUGIN_ID);
-
boolean result = false;
Exception e = null;
try {
- 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);
- 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 (toggleState) {
- prefs.putBoolean(IDeltaCloudPreferenceConstants.DONT_CONFIRM_CREATE_INSTANCE,
true);
- }
- }
- instance = cloud.createInstance(name, imageId, realmId, profileId, keyId, memory,
storage);
- if (instance != null) {
- result = true;
- if (instance.getState().equals(DeltaCloudInstance.State.PENDING)) {
- // TODO use chained job? Maybe. But chainedJob needs to be
- // moved
- ChainedJob first =
- new InstanceStateJob(
- WizardMessages.getFormattedString(STARTING_INSTANCE_TITLE, instance.getName()),
- instance,
- DeltaCloudInstance.State.RUNNING);
- first.setUser(true);
- ChainedJob last = first;
- ChainedJob temp;
- for (int i = 0; i < additionalPages.length; i++) {
- temp = additionalPages[i].getPerformFinishJob(instance);
- if (temp != null) {
- last.setNextJob(temp);
- last = temp;
- }
+ if (isProceed()) {
+ warnSshPrivateKey(keyId);
+ instance = cloud.createInstance(name, imageId, realmId, profileId, keyId, memory,
storage);
+ if (instance != null) {
+ result = true;
+ if (instance.getState().equals(DeltaCloudInstance.State.PENDING)) {
+ scheduleJobs();
}
- first.schedule();
}
}
} catch (DeltaCloudException ex) {
@@ -162,32 +125,67 @@
WizardMessages.getFormattedString(CREATE_INSTANCE_FAILURE_MSG,
new String[] { name, imageId, realmId, profileId }),
e, getShell());
- } else {
- addToSshPrefs(keyId);
}
return result;
}
- private void addToSshPrefs(String keyId) {
+ private void warnSshPrivateKey(String keyId) {
try {
- File pemFile = PemFileManager.getFile(keyId,
SshPrivateKeysPreferences.getKeyStorePath());
- if (pemFile != null) {
- SshPrivateKeysPreferences.add(pemFile.getName());
+ File file = PemFileManager.getFile(keyId,
SshPrivateKeysPreferences.getSshKeyDirectory());
+ boolean isKnowPrivateKey =
SshPrivateKeysPreferences.contains(file.getAbsolutePath());
+
+ if (!isKnowPrivateKey) {
+ MessageDialog
+ .openWarning(
+ getShell(),
+ "Instance key is not private key",
+ "The instance key is not a key that's know as private key to the
ssh-subsystem. If the instance key is what you need to connect to you instance, you'll
have to download it and add it to the private keys in the SSH preferences.");
}
- } catch (DeltaCloudException e) {
- ErrorUtils.handleError("Error",
- MessageFormat.format("Could not add key \"{0}\" to ssh
preferences", keyId), e, getShell());
+ } catch (FileNotFoundException e) {
+
}
}
- private String utf8Encode(String string) {
- try {
- return URLEncoder.encode(string, "UTF-8");
- } catch (UnsupportedEncodingException e) {
- // TODO: implement proper handling
- return "";
- } //$NON-NLS-1$
+ private void scheduleJobs() {
+ ChainedJob first =
+ new InstanceStateJob(
+ WizardMessages.getFormattedString(STARTING_INSTANCE_TITLE, instance.getName()),
+ instance,
+ DeltaCloudInstance.State.RUNNING);
+ first.setUser(true);
+ ChainedJob last = first;
+ ChainedJob temp;
+ for (int i = 0; i < additionalPages.length; i++) {
+ temp = additionalPages[i].getPerformFinishJob(instance);
+ if (temp != null) {
+ last.setNextJob(temp);
+ last = temp;
+ }
+ }
+ first.schedule();
}
+ private boolean isProceed() {
+ boolean proceed = true;
+ Preferences prefs = new InstanceScope().getNode(Activator.PLUGIN_ID);
+ 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);
+ proceed = dialog.getReturnCode() == Dialog.OK;
+ boolean toggleState = dialog.getToggleState();
+ // If warning turned off by user, set the preference for future
+ // usage
+ if (toggleState) {
+ prefs.putBoolean(IDeltaCloudPreferenceConstants.DONT_CONFIRM_CREATE_INSTANCE, true);
+ }
+ }
+ return proceed;
+ }
}
Modified:
branches/jbosstools-3.2.0.CR1/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/PemFileManager.java
===================================================================
---
branches/jbosstools-3.2.0.CR1/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/PemFileManager.java 2011-01-17
09:46:55 UTC (rev 28286)
+++
branches/jbosstools-3.2.0.CR1/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/PemFileManager.java 2011-01-17
09:47:42 UTC (rev 28287)
@@ -27,13 +27,14 @@
private static final String PEM_FILE_SUFFIX = "pem";
- public static void delete(DeltaCloudKey key, String keyStorePath) throws
DeltaCloudException {
+ public static File delete(DeltaCloudKey key, String keyStorePath) throws
DeltaCloudException {
try {
Assert.isLegal(key != null);
Assert.isLegal(keyStorePath != null && keyStorePath.length() > 0);
File file = getFile(key.getId(), keyStorePath);
delete(file);
+ return file;
} catch (DeltaCloudException e) {
throw e;
} catch (Exception e) {
@@ -44,8 +45,8 @@
public static File create(DeltaCloudKey key, String keyStorePath) throws
DeltaCloudException {
try {
Assert.isLegal(key != null);
- Assert.isLegal(keyStorePath != null && keyStorePath.length() > 0);
- File keyFile = create(getFile(key.getId(), keyStorePath), keyStorePath);
+ Assert.isLegal(keyStorePath != null && keyStorePath.length() > 0, "key
store path is not set.");
+ File keyFile = create(getFile(key.getId(), keyStorePath));
save(key.getPem(), keyFile);
keyFile.setWritable(false, false);
return keyFile;
@@ -62,11 +63,12 @@
}
}
- private static File create(File file, String keyStoreLocation)
- throws IOException {
- if (!file.exists()) {
- file.createNewFile();
+ private static File create(File file) throws IOException {
+ if (file.exists()) {
+ throw new IllegalStateException(
+ MessageFormat.format("File \"{0}\" already exists.",
file.getAbsolutePath()));
}
+ file.createNewFile();
file.setReadable(false, false);
file.setWritable(true, true);
file.setReadable(true, true);
@@ -77,11 +79,16 @@
File keyFile =
Path.fromOSString(keyStoreLocation)
.append(keyId)
- .addFileExtension(PEM_FILE_SUFFIX) //$NON-NLS-1$
+ .addFileExtension(PEM_FILE_SUFFIX)
.toFile();
return keyFile;
}
+ public static boolean exists(String keyId, String keyStoreLocation) {
+ File file = getFile(keyId, keyStoreLocation);
+ return file != null && file.exists();
+ }
+
private static void delete(File file) throws DeltaCloudException {
try {
if (file == null
Modified:
branches/jbosstools-3.2.0.CR1/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/SshPrivateKeysPreferences.java
===================================================================
---
branches/jbosstools-3.2.0.CR1/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/SshPrivateKeysPreferences.java 2011-01-17
09:46:55 UTC (rev 28286)
+++
branches/jbosstools-3.2.0.CR1/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/SshPrivateKeysPreferences.java 2011-01-17
09:47:42 UTC (rev 28287)
@@ -10,7 +10,12 @@
******************************************************************************/
package org.jboss.tools.internal.deltacloud.ui.wizards;
+import java.io.File;
+import java.io.FileNotFoundException;
+
+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.StringEntriesPreferenceValue;
import org.jboss.tools.internal.deltacloud.ui.preferences.StringPreferenceValue;
@@ -23,11 +28,14 @@
/**
* Preference keys defined by org.eclipse.jsch.
*
- * these keys are replicates from org.eclipse.jsch.internal.core.IConstants
+ * these keys are replicates from org.eclipse.jsch.internal.core.IConstants
*/
private static final String PRIVATEKEY = "PRIVATEKEY";
private static final String SSH2HOME = "SSH2HOME";
+ private static final String SSH_USERHOME = ".ssh";
+ private static final String SSH_USERHOME_WIN32 = "ssh";
+
private static StringEntriesPreferenceValue sshPrivateKeyPreference =
new StringEntriesPreferenceValue(",", PRIVATEKEY, PLUGIN_ID);
private static StringPreferenceValue sshHome = new StringPreferenceValue(SSH2HOME,
PLUGIN_ID);
@@ -43,6 +51,21 @@
}
/**
+ * Adds the given keyName to the ssh-preferences
+ *
+ * @param keyName
+ * the name of the key to add
+ */
+ public static boolean contains(String keyName) {
+ for (String privateKey : sshPrivateKeyPreference.get()) {
+ if (privateKey.equals(keyName)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ /**
* Removes the given keyName from the ssh-preferences
*
* @param keyName
@@ -52,17 +75,37 @@
sshPrivateKeyPreference.remove(keyName);
}
- public static String getKeyStorePath() throws DeltaCloudException {
- // TODO: replace by code that queries the RSE preferences for its key
- // location setting
-// String userHomePath = System.getProperty("user.home");
-// if (userHomePath == null) {
-// throw new DeltaCloudException("Could not determine path to save pem file
to");
-// }
-// return new StringBuilder(userHomePath)
-// .append(File.separatorChar).append(".ssh").append(File.separatorChar)
-// .toString();
- return sshHome.get();
+ /**
+ * Returns the path to the folder that ssh keys get stored to. It either
+ * gets the preferences value from org.eclipse.jsch or uses a ssh folder in
+ * the user home. This code was built according to what
+ * org.eclipse.jsch.internal.core.PreferenceInitializer is doing.
+ *
+ * @return the directory to store or load the ssh keys from
+ * @throws DeltaCloudException
+ * if the directory could not be determined
+ */
+ public static String getSshKeyDirectory() throws FileNotFoundException {
+ String sshHomePath = sshHome.get();
+ if (StringUtils.isEmpty(sshHomePath)) {
+ sshHomePath = getSshSystemHome();
+ }
+
+ if (StringUtils.isEmpty(sshHomePath)) {
+ throw new FileNotFoundException("Could not determine path to ssh keys
directory.");
+ }
+ return sshHomePath;
}
+ private static String getSshSystemHome() {
+ String userHomePath = System.getProperty("user.home");
+ StringBuilder builder = new StringBuilder(userHomePath);
+ builder.append(File.separatorChar);
+ if (Platform.getOS().equals(Platform.OS_WIN32)) {
+ builder.append(SSH_USERHOME_WIN32); //$NON-NLS-1$
+ } else {
+ builder.append(SSH_USERHOME);
+ }
+ return builder.toString();
+ }
}
Modified:
branches/jbosstools-3.2.0.CR1/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/WizardMessages.properties
===================================================================
---
branches/jbosstools-3.2.0.CR1/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/WizardMessages.properties 2011-01-17
09:46:55 UTC (rev 28286)
+++
branches/jbosstools-3.2.0.CR1/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/WizardMessages.properties 2011-01-17
09:47:42 UTC (rev 28287)
@@ -88,7 +88,7 @@
NewInstance.title=Launch Instance
NewInstance.name=Launch Instance
-ManageKeys.desc=Select a key to use when creating an instance so that it may be accessed
remotely.
+ManageKeys.desc=Select a key to use when creating an instance.
ManageKeys.title=Manage Keys
ManageKeys.name=Manage Keys