summaryrefslogtreecommitdiffstats
path: root/src/com.gluster.storage.management.gui
diff options
context:
space:
mode:
authorSelvasundaram <selvam@gluster.com>2011-07-18 22:13:09 +0530
committerSelvasundaram <selvam@gluster.com>2011-07-18 22:13:09 +0530
commit9f5c58e1ad2ef2449dd17e503fc3408df18a382d (patch)
tree0a3b7399f773ff2e2642c5e7e50e417110b941e8 /src/com.gluster.storage.management.gui
parente299a61b230278a0ac625e082c39132eca469b43 (diff)
parent948ef913fae74a9b67f0901d7bbf9153c52bfffb (diff)
Merge branch 'import-keys'
Diffstat (limited to 'src/com.gluster.storage.management.gui')
-rw-r--r--src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/actions/AbstractActionDelegate.java20
-rw-r--r--src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/actions/ImportSshKeysAction.java35
2 files changed, 36 insertions, 19 deletions
diff --git a/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/actions/AbstractActionDelegate.java b/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/actions/AbstractActionDelegate.java
index 0f8121e6..ef7d0979 100644
--- a/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/actions/AbstractActionDelegate.java
+++ b/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/actions/AbstractActionDelegate.java
@@ -52,17 +52,10 @@ public abstract class AbstractActionDelegate implements IWorkbenchWindowActionDe
// Real action code must be executed using Display#asyncExec.
// Otherwise the system can hang when opening new dialog boxes on linux platform
try {
- PlatformUI.getWorkbench().getProgressService().busyCursorWhile(new IRunnableWithProgress() {
- public void run(final IProgressMonitor monitor) {
- Display.getDefault().asyncExec(new Runnable() {
- @Override
- public void run() {
- monitor.beginTask(action.getDescription(), 1);
- performAction(action);
- monitor.worked(1);
- monitor.done();
- }
- });
+ Display.getDefault().asyncExec(new Runnable() {
+ @Override
+ public void run() {
+ performAction(action);
}
});
} catch (final Exception e) {
@@ -102,10 +95,7 @@ public abstract class AbstractActionDelegate implements IWorkbenchWindowActionDe
}
protected Shell getShell() {
- if(window == null) {
- return Display.getDefault().getActiveShell();
- }
- return window.getShell();
+ return getWindow().getShell();
}
protected IWorkbenchWindow getWindow() {
diff --git a/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/actions/ImportSshKeysAction.java b/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/actions/ImportSshKeysAction.java
index 8cedc920..a166f509 100644
--- a/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/actions/ImportSshKeysAction.java
+++ b/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/actions/ImportSshKeysAction.java
@@ -1,17 +1,44 @@
package com.gluster.storage.management.gui.actions;
import org.eclipse.jface.action.IAction;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.FileDialog;
+
+import com.gluster.storage.management.client.KeysClient;
public class ImportSshKeysAction extends AbstractActionDelegate {
-
@Override
protected void performAction(IAction action) {
-
- }
+ final KeysClient client = new KeysClient();
+
+ Display.getDefault().asyncExec(new Runnable() {
+
+ @Override
+ public void run() {
+ FileDialog dialog = new FileDialog(getShell(), SWT.OPEN);
+ dialog.setText("Open");
+ dialog.setFilterNames(new String[] { "ssh-keys (*.tar)" });
+ dialog.setFilterExtensions(new String[] { "*.tar" });
+
+ String selectedFile = dialog.open();
+ if (selectedFile == null) {
+ return;
+ }
+
+ String title = "Import SSH Keys";
+ try {
+ client.importSshKeys(selectedFile);
+ showInfoDialog(title, "SSH keys imported successfully!");
+ } catch (Exception e) {
+ showErrorDialog(title, e.getMessage());
+ }
+ }
+ });
+ }
@Override
public void dispose() {
}
-
}