[jbosstools-commits] JBoss Tools SVN: r43749 - in trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui: utils and 2 other directories.

jbosstools-commits at lists.jboss.org jbosstools-commits at lists.jboss.org
Mon Sep 17 10:56:03 EDT 2012


Author: adietish
Date: 2012-09-17 10:56:03 -0400 (Mon, 17 Sep 2012)
New Revision: 43749

Added:
   trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/utils/JobScheduler.java
   trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/utils/UIUpdatingJob.java
   trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ssh/
   trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ssh/AddSSHKeyWizard.java
   trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ssh/AddSSHKeyWizardPage.java
   trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ssh/ManageSSHKeysWizard.java
   trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ssh/ManageSSHKeysWizardPage.java
   trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ssh/ManageSSHKeysWizardPageModel.java
Removed:
   trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ManageSSHKeysWizard.java
   trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ManageSSHKeysWizardPage.java
   trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ManageSSHKeysWizardPageModel.java
Modified:
   trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/command/ManageSSHKeysHandler.java
Log:
[JBIDE-11912] added "Add existing SSH Key" dialog

Modified: trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/command/ManageSSHKeysHandler.java
===================================================================
--- trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/command/ManageSSHKeysHandler.java	2012-09-17 14:40:42 UTC (rev 43748)
+++ trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/command/ManageSSHKeysHandler.java	2012-09-17 14:56:03 UTC (rev 43749)
@@ -18,7 +18,7 @@
 import org.eclipse.ui.handlers.HandlerUtil;
 import org.jboss.tools.common.ui.WizardUtils;
 import org.jboss.tools.openshift.express.internal.core.console.UserDelegate;
-import org.jboss.tools.openshift.express.internal.ui.wizard.ManageSSHKeysWizard;
+import org.jboss.tools.openshift.express.internal.ui.wizard.ssh.ManageSSHKeysWizard;
 
 /**
  * @author Andre Dietisheim

Added: trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/utils/JobScheduler.java
===================================================================
--- trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/utils/JobScheduler.java	                        (rev 0)
+++ trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/utils/JobScheduler.java	2012-09-17 14:56:03 UTC (rev 43749)
@@ -0,0 +1,45 @@
+/******************************************************************************* 
+ * Copyright (c) 2012 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 Incorporated - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.openshift.express.internal.ui.utils;
+
+import org.eclipse.core.runtime.jobs.IJobChangeEvent;
+import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.core.runtime.jobs.JobChangeAdapter;
+
+/**
+ * @author Andre Dietisheim
+ */
+public class JobScheduler {
+
+	private Job job;
+
+	public JobScheduler(Job job) {
+		this.job = job;
+	}
+
+	public class ChainedJob {
+		private Job job;
+
+		private ChainedJob(Job job) {
+			this.job = job;
+		}
+
+		public ChainedJob andWhenDone(final Job constrainedJob) {
+			job.addJobChangeListener(new JobChangeAdapter() {
+
+				@Override
+				public void done(IJobChangeEvent event) {
+					constrainedJob.schedule();
+				}});
+			return new ChainedJob(constrainedJob);
+		}
+	}
+}


Property changes on: trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/utils/JobScheduler.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Added: trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/utils/UIUpdatingJob.java
===================================================================
--- trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/utils/UIUpdatingJob.java	                        (rev 0)
+++ trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/utils/UIUpdatingJob.java	2012-09-17 14:56:03 UTC (rev 43749)
@@ -0,0 +1,36 @@
+package org.jboss.tools.openshift.express.internal.ui.utils;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.jobs.IJobChangeEvent;
+import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.core.runtime.jobs.JobChangeAdapter;
+import org.eclipse.ui.progress.UIJob;
+
+public abstract class UIUpdatingJob extends Job {
+
+	public UIUpdatingJob(String name) {
+		super(name);
+		addJobChangeListener(new JobChangeAdapter() {
+
+			@Override
+			public void done(IJobChangeEvent event) {
+				new UIJob(getName()) {
+					
+					@Override
+					public IStatus runInUIThread(IProgressMonitor monitor) {
+						return updateUI(monitor);
+					}
+				}.schedule();
+			}});
+	}
+	
+	@Override
+	protected abstract IStatus run(IProgressMonitor monitor);
+
+	protected IStatus updateUI(IProgressMonitor monitor) {
+		return Status.OK_STATUS;
+	}
+	
+}


Property changes on: trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/utils/UIUpdatingJob.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Deleted: trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ManageSSHKeysWizard.java
===================================================================
--- trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ManageSSHKeysWizard.java	2012-09-17 14:40:42 UTC (rev 43748)
+++ trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ManageSSHKeysWizard.java	2012-09-17 14:56:03 UTC (rev 43749)
@@ -1,37 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2011 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.openshift.express.internal.ui.wizard;
-
-import org.eclipse.jface.wizard.Wizard;
-import org.jboss.tools.openshift.express.internal.core.console.UserDelegate;
-
-/**
- * @author André Dietisheim
- */
-public class ManageSSHKeysWizard extends Wizard {
-
-	private UserDelegate user;
-
-	public ManageSSHKeysWizard(UserDelegate user) {
-		this.user = user;
-		setNeedsProgressMonitor(true);
-	}
-
-	@Override
-	public boolean performFinish() {
-		return true;
-	}
-
-	@Override
-	public void addPages() {
-		addPage(new ManageSSHKeysWizardPage(user, this));
-	}
-}

Deleted: trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ManageSSHKeysWizardPage.java
===================================================================
--- trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ManageSSHKeysWizardPage.java	2012-09-17 14:40:42 UTC (rev 43748)
+++ trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ManageSSHKeysWizardPage.java	2012-09-17 14:56:03 UTC (rev 43749)
@@ -1,168 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2012 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.openshift.express.internal.ui.wizard;
-
-import java.util.ArrayList;
-import java.util.Collection;
-
-import org.eclipse.core.databinding.DataBindingContext;
-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.layout.GridDataFactory;
-import org.eclipse.jface.layout.GridLayoutFactory;
-import org.eclipse.jface.viewers.ArrayContentProvider;
-import org.eclipse.jface.viewers.IElementComparer;
-import org.eclipse.jface.viewers.TableViewer;
-import org.eclipse.jface.wizard.IWizard;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Group;
-import org.eclipse.swt.widgets.Table;
-import org.jboss.tools.common.ui.WizardUtils;
-import org.jboss.tools.openshift.express.internal.core.console.UserDelegate;
-import org.jboss.tools.openshift.express.internal.ui.OpenShiftUIActivator;
-import org.jboss.tools.openshift.express.internal.ui.utils.StringUtils;
-import org.jboss.tools.openshift.express.internal.ui.utils.TableViewerBuilder;
-import org.jboss.tools.openshift.express.internal.ui.utils.TableViewerBuilder.IColumnLabelProvider;
-
-import com.openshift.client.IOpenShiftSSHKey;
-
-/**
- * @author André Dietisheim
- */
-public class ManageSSHKeysWizardPage extends AbstractOpenShiftWizardPage {
-
-	private ManageSSHKeysWizardPageModel pageModel;
-	private TableViewer viewer;
-
-	public ManageSSHKeysWizardPage(UserDelegate user, IWizard wizard) {
-		super("Manage SSH Keys", "Manage the SSH keys that are available to your OpenShift account",
-				"ManageSSHKeysPage", wizard);
-		this.pageModel = new ManageSSHKeysWizardPageModel(user);
-	}
-
-	@Override
-	protected void doCreateControls(Composite parent, DataBindingContext dbc) {
-		GridLayoutFactory.fillDefaults().margins(10, 10).applyTo(parent);
-
-		Group sshKeysGroup = new Group(parent, SWT.NONE);
-		sshKeysGroup.setText("SSH Public Keys");
-		GridDataFactory.fillDefaults()
-				.align(SWT.FILL, SWT.FILL).grab(true, true).applyTo(sshKeysGroup);
-		GridLayoutFactory.fillDefaults()
-				.numColumns(2).margins(6, 6).applyTo(sshKeysGroup);
-
-		Composite tableContainer = new Composite(sshKeysGroup, SWT.NONE);
-		this.viewer = createTable(tableContainer);
-		GridDataFactory.fillDefaults()
-				.span(1, 5).align(SWT.FILL, SWT.FILL).grab(true, true).applyTo(tableContainer);
-
-		Button addButton = new Button(sshKeysGroup, SWT.PUSH);
-		GridDataFactory.fillDefaults()
-				.align(SWT.FILL, SWT.FILL).applyTo(addButton);
-		addButton.setText("Add Existing...");
-
-		Button newButton = new Button(sshKeysGroup, SWT.PUSH);
-		GridDataFactory.fillDefaults()
-				.align(SWT.FILL, SWT.FILL).applyTo(newButton);
-		newButton.setText("New...");
-
-		Button removeButton = new Button(sshKeysGroup, SWT.PUSH);
-		GridDataFactory.fillDefaults()
-				.align(SWT.FILL, SWT.FILL).applyTo(removeButton);
-		removeButton.setText("Remove...");
-
-		Composite filler = new Composite(sshKeysGroup, SWT.None);
-		GridDataFactory.fillDefaults()
-				.align(SWT.FILL, SWT.FILL).applyTo(filler);
-
-		Button refreshButton = new Button(sshKeysGroup, SWT.PUSH);
-		GridDataFactory.fillDefaults()
-				.align(SWT.FILL, SWT.END).applyTo(refreshButton);
-		refreshButton.setText("Refresh...");
-}
-
-	protected TableViewer createTable(Composite tableContainer) {
-		Table table =
-				new Table(tableContainer, SWT.BORDER | SWT.FULL_SELECTION | SWT.V_SCROLL | SWT.H_SCROLL);
-		table.setLinesVisible(true);
-		table.setHeaderVisible(true);
-		this.viewer = new TableViewerBuilder(table, tableContainer)
-				.contentProvider(new ArrayContentProvider())
-				.column(new IColumnLabelProvider<IOpenShiftSSHKey>() {
-
-					@Override
-					public String getValue(IOpenShiftSSHKey key) {
-						return key.getName();
-					}
-				})
-				.name("Name").align(SWT.LEFT).weight(2).minWidth(200).buildColumn()
-				.column(new IColumnLabelProvider<IOpenShiftSSHKey>() {
-
-					@Override
-					public String getValue(IOpenShiftSSHKey key) {
-						return key.getKeyType().getTypeId();
-					}
-				})
-				.name("Type").align(SWT.LEFT).weight(1).minWidth(50).buildColumn()
-				.column(new IColumnLabelProvider<IOpenShiftSSHKey>() {
-
-					@Override
-					public String getValue(IOpenShiftSSHKey key) {
-						return StringUtils.shorten(key.getPublicKey(), 24);
-					}
-				})
-				.name("Type").align(SWT.LEFT).weight(4).minWidth(100).buildColumn()
-				.buildViewer();
-
-		return viewer;
-	}
-
-	@Override
-	protected void onPageActivated(DataBindingContext dbc) {
-		try {
-			WizardUtils.runInWizard(new Job("Loading ssh keys...") {
-
-				@Override
-				protected IStatus run(IProgressMonitor monitor) {
-					try {
-						setViewerInput(pageModel.loadSSHKeys());
-						pageModel.loadSSHKeys();
-						return Status.OK_STATUS;
-					} catch (Exception e) {
-						clearViewer();
-						return OpenShiftUIActivator.createErrorStatus("Could not load ssh keys.", e);
-					}
-				}
-
-			}, getContainer(), getDataBindingContext());
-		} catch (Exception e) {
-			// ignore
-		}
-	}
-
-	private void clearViewer() {
-		setViewerInput(new ArrayList<IOpenShiftSSHKey>());
-	}
-
-	private void setViewerInput(final Collection<IOpenShiftSSHKey> keys) {
-		getShell().getDisplay().syncExec(new Runnable() {
-
-			@Override
-			public void run() {
-				viewer.setInput(keys);
-			}
-		});
-	}
-}
\ No newline at end of file

Deleted: trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ManageSSHKeysWizardPageModel.java
===================================================================
--- trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ManageSSHKeysWizardPageModel.java	2012-09-17 14:40:42 UTC (rev 43748)
+++ trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ManageSSHKeysWizardPageModel.java	2012-09-17 14:56:03 UTC (rev 43749)
@@ -1,53 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2012 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.openshift.express.internal.ui.wizard;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.jboss.tools.common.ui.databinding.ObservableUIPojo;
-import org.jboss.tools.openshift.express.internal.core.console.UserDelegate;
-
-import com.openshift.client.IOpenShiftSSHKey;
-
-/**
- * @author André Dietisheim
- */
-public class ManageSSHKeysWizardPageModel extends ObservableUIPojo {
-
-	public static final String PROPERTY_SSH_KEYS = "SSHKeys";
-
-	private UserDelegate user;
-	private List<IOpenShiftSSHKey> keys = new ArrayList<IOpenShiftSSHKey>();
-
-	public ManageSSHKeysWizardPageModel(UserDelegate user) {
-		this.user = user;
-	}
-
-	public List<IOpenShiftSSHKey> loadSSHKeys() {
-		return setSSHKeys(user.getSSHKeys());
-	}
-
-	public List<IOpenShiftSSHKey> getSSHKeys() {
-		return keys;
-	}
-
-	public List<IOpenShiftSSHKey> setSSHKeys(List<IOpenShiftSSHKey> keys) {
-		this.keys = keys;
-		firePropertyChange(PROPERTY_SSH_KEYS, this.keys, this.keys = keys);
-		return this.keys;
-	}
-
-	public UserDelegate getUser() {
-		return user;
-	}
-
-}

Added: trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ssh/AddSSHKeyWizard.java
===================================================================
--- trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ssh/AddSSHKeyWizard.java	                        (rev 0)
+++ trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ssh/AddSSHKeyWizard.java	2012-09-17 14:56:03 UTC (rev 43749)
@@ -0,0 +1,37 @@
+/*******************************************************************************
+ * Copyright (c) 2011 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.openshift.express.internal.ui.wizard.ssh;
+
+import org.eclipse.jface.wizard.Wizard;
+import org.jboss.tools.openshift.express.internal.core.console.UserDelegate;
+
+/**
+ * @author André Dietisheim
+ */
+public class AddSSHKeyWizard extends Wizard {
+
+	private UserDelegate user;
+
+	public AddSSHKeyWizard(UserDelegate user) {
+		this.user = user;
+		setNeedsProgressMonitor(true);
+	}
+
+	@Override
+	public boolean performFinish() {
+		return true;
+	}
+
+	@Override
+	public void addPages() {
+		addPage(new AddSSHKeyWizardPage(user, this));
+	}
+}


Property changes on: trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ssh/AddSSHKeyWizard.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Added: trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ssh/AddSSHKeyWizardPage.java
===================================================================
--- trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ssh/AddSSHKeyWizardPage.java	                        (rev 0)
+++ trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ssh/AddSSHKeyWizardPage.java	2012-09-17 14:56:03 UTC (rev 43749)
@@ -0,0 +1,76 @@
+/*******************************************************************************
+ * Copyright (c) 2012 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.openshift.express.internal.ui.wizard.ssh;
+
+import org.eclipse.core.databinding.DataBindingContext;
+import org.eclipse.jface.layout.GridDataFactory;
+import org.eclipse.jface.layout.GridLayoutFactory;
+import org.eclipse.jface.wizard.IWizard;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Group;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Text;
+import org.jboss.tools.openshift.express.internal.core.console.UserDelegate;
+import org.jboss.tools.openshift.express.internal.ui.wizard.AbstractOpenShiftWizardPage;
+
+/**
+ * @author André Dietisheim
+ */
+public class AddSSHKeyWizardPage extends AbstractOpenShiftWizardPage {
+
+	private UserDelegate user;
+
+	public AddSSHKeyWizardPage(UserDelegate user, IWizard wizard) {
+		super("Add existing SSH Key", "Add an exiting SSH key to your OpenShift account",
+				"AddSSHKeysPage", wizard);
+		this.user = user;
+	}
+
+	@Override
+	protected void doCreateControls(Composite parent, DataBindingContext dbc) {
+		GridLayoutFactory.fillDefaults()
+				.margins(10, 10).applyTo(parent);
+
+		Group addSSHKeyGroup = new Group(parent, SWT.NONE);
+		addSSHKeyGroup.setText("Add existing SSH Key");
+		GridDataFactory.fillDefaults()
+				.align(SWT.FILL, SWT.FILL).grab(true, true).applyTo(addSSHKeyGroup);
+		GridLayoutFactory.fillDefaults()
+				.numColumns(3).margins(6, 6).applyTo(addSSHKeyGroup);
+
+		Label nameLabel = new Label(addSSHKeyGroup, SWT.NONE);
+		nameLabel.setText("Name:");
+		GridDataFactory.fillDefaults()
+				.align(SWT.LEFT, SWT.CENTER).applyTo(nameLabel);
+
+		Text nameText = new Text(addSSHKeyGroup, SWT.BORDER);
+		nameText.setEditable(false);
+		GridDataFactory.fillDefaults()
+				.align(SWT.FILL, SWT.CENTER).grab(true, false).span(2, 1).applyTo(nameText);
+
+		Label fileLabel = new Label(addSSHKeyGroup, SWT.NONE);
+		GridDataFactory.fillDefaults()
+				.align(SWT.LEFT, SWT.CENTER).applyTo(fileLabel);
+		fileLabel.setText("SSH Key:");
+
+		Text fileText = new Text(addSSHKeyGroup, SWT.BORDER);
+		fileText.setEditable(false);
+		GridDataFactory.fillDefaults()
+				.align(SWT.FILL, SWT.CENTER).grab(true, false).applyTo(fileText);
+
+		Button browseButton = new Button(addSSHKeyGroup, SWT.PUSH);
+		GridDataFactory.fillDefaults()
+				.align(SWT.FILL, SWT.CENTER).applyTo(browseButton);
+		browseButton.setText("Browse...");
+	}
+}
\ No newline at end of file


Property changes on: trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ssh/AddSSHKeyWizardPage.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Copied: trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ssh/ManageSSHKeysWizard.java (from rev 43743, trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ManageSSHKeysWizard.java)
===================================================================
--- trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ssh/ManageSSHKeysWizard.java	                        (rev 0)
+++ trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ssh/ManageSSHKeysWizard.java	2012-09-17 14:56:03 UTC (rev 43749)
@@ -0,0 +1,37 @@
+/*******************************************************************************
+ * Copyright (c) 2011 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.openshift.express.internal.ui.wizard.ssh;
+
+import org.eclipse.jface.wizard.Wizard;
+import org.jboss.tools.openshift.express.internal.core.console.UserDelegate;
+
+/**
+ * @author André Dietisheim
+ */
+public class ManageSSHKeysWizard extends Wizard {
+
+	private UserDelegate user;
+
+	public ManageSSHKeysWizard(UserDelegate user) {
+		this.user = user;
+		setNeedsProgressMonitor(true);
+	}
+
+	@Override
+	public boolean performFinish() {
+		return true;
+	}
+
+	@Override
+	public void addPages() {
+		addPage(new ManageSSHKeysWizardPage(user, this));
+	}
+}


Property changes on: trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ssh/ManageSSHKeysWizard.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Copied: trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ssh/ManageSSHKeysWizardPage.java (from rev 43743, trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ManageSSHKeysWizardPage.java)
===================================================================
--- trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ssh/ManageSSHKeysWizardPage.java	                        (rev 0)
+++ trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ssh/ManageSSHKeysWizardPage.java	2012-09-17 14:56:03 UTC (rev 43749)
@@ -0,0 +1,209 @@
+/*******************************************************************************
+ * Copyright (c) 2012 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.openshift.express.internal.ui.wizard.ssh;
+
+import java.util.ArrayList;
+import java.util.Collection;
+
+import org.eclipse.core.databinding.DataBindingContext;
+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.layout.GridDataFactory;
+import org.eclipse.jface.layout.GridLayoutFactory;
+import org.eclipse.jface.viewers.ArrayContentProvider;
+import org.eclipse.jface.viewers.TableViewer;
+import org.eclipse.jface.wizard.IWizard;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Group;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.ui.statushandlers.StatusManager;
+import org.jboss.tools.common.ui.WizardUtils;
+import org.jboss.tools.openshift.express.internal.core.console.UserDelegate;
+import org.jboss.tools.openshift.express.internal.ui.OpenShiftUIActivator;
+import org.jboss.tools.openshift.express.internal.ui.utils.StringUtils;
+import org.jboss.tools.openshift.express.internal.ui.utils.TableViewerBuilder;
+import org.jboss.tools.openshift.express.internal.ui.utils.TableViewerBuilder.IColumnLabelProvider;
+import org.jboss.tools.openshift.express.internal.ui.utils.UIUpdatingJob;
+import org.jboss.tools.openshift.express.internal.ui.wizard.AbstractOpenShiftWizardPage;
+
+import com.openshift.client.IOpenShiftSSHKey;
+
+/**
+ * @author André Dietisheim
+ */
+public class ManageSSHKeysWizardPage extends AbstractOpenShiftWizardPage {
+
+	private ManageSSHKeysWizardPageModel pageModel;
+	private TableViewer viewer;
+
+	public ManageSSHKeysWizardPage(UserDelegate user, IWizard wizard) {
+		super("Manage SSH Keys", "Manage the SSH keys that are available to your OpenShift account",
+				"ManageSSHKeysPage", wizard);
+		this.pageModel = new ManageSSHKeysWizardPageModel(user);
+	}
+
+	@Override
+	protected void doCreateControls(Composite parent, DataBindingContext dbc) {
+		GridLayoutFactory.fillDefaults().margins(10, 10).applyTo(parent);
+
+		Group sshKeysGroup = new Group(parent, SWT.NONE);
+		sshKeysGroup.setText("SSH Public Keys");
+		GridDataFactory.fillDefaults()
+				.align(SWT.FILL, SWT.FILL).grab(true, true).applyTo(sshKeysGroup);
+		GridLayoutFactory.fillDefaults()
+				.numColumns(2).margins(6, 6).applyTo(sshKeysGroup);
+
+		Composite tableContainer = new Composite(sshKeysGroup, SWT.NONE);
+		this.viewer = createTable(tableContainer);
+		GridDataFactory.fillDefaults()
+				.span(1, 5).align(SWT.FILL, SWT.FILL).grab(true, true).applyTo(tableContainer);
+
+		Button addButton = new Button(sshKeysGroup, SWT.PUSH);
+		GridDataFactory.fillDefaults()
+				.align(SWT.FILL, SWT.FILL).applyTo(addButton);
+		addButton.setText("Add Existing...");
+		addButton.addSelectionListener(onAdd());
+		
+		Button newButton = new Button(sshKeysGroup, SWT.PUSH);
+		GridDataFactory.fillDefaults()
+				.align(SWT.FILL, SWT.FILL).applyTo(newButton);
+		newButton.setText("New...");
+
+		Button removeButton = new Button(sshKeysGroup, SWT.PUSH);
+		GridDataFactory.fillDefaults()
+				.align(SWT.FILL, SWT.FILL).applyTo(removeButton);
+		removeButton.setText("Remove...");
+
+		Composite filler = new Composite(sshKeysGroup, SWT.None);
+		GridDataFactory.fillDefaults()
+				.align(SWT.FILL, SWT.FILL).applyTo(filler);
+
+		Button refreshButton = new Button(sshKeysGroup, SWT.PUSH);
+		GridDataFactory.fillDefaults()
+				.align(SWT.FILL, SWT.END).applyTo(refreshButton);
+		refreshButton.setText("Refresh...");
+		refreshButton.addSelectionListener(onRefresh());
+	}
+
+	private SelectionListener onAdd() {
+		return new SelectionAdapter() {
+
+			@Override
+			public void widgetSelected(SelectionEvent e) {
+				WizardUtils.openWizardDialog(new AddSSHKeyWizard(pageModel.getUser()), getShell());
+			}
+		};
+	}
+
+	protected TableViewer createTable(Composite tableContainer) {
+		Table table =
+				new Table(tableContainer, SWT.BORDER | SWT.FULL_SELECTION | SWT.V_SCROLL | SWT.H_SCROLL);
+		table.setLinesVisible(true);
+		table.setHeaderVisible(true);
+		this.viewer = new TableViewerBuilder(table, tableContainer)
+				.contentProvider(new ArrayContentProvider())
+				.column(new IColumnLabelProvider<IOpenShiftSSHKey>() {
+
+					@Override
+					public String getValue(IOpenShiftSSHKey key) {
+						return key.getName();
+					}
+				})
+				.name("Name").align(SWT.LEFT).weight(2).minWidth(200).buildColumn()
+				.column(new IColumnLabelProvider<IOpenShiftSSHKey>() {
+
+					@Override
+					public String getValue(IOpenShiftSSHKey key) {
+						return key.getKeyType().getTypeId();
+					}
+				})
+				.name("Type").align(SWT.LEFT).weight(1).minWidth(50).buildColumn()
+				.column(new IColumnLabelProvider<IOpenShiftSSHKey>() {
+
+					@Override
+					public String getValue(IOpenShiftSSHKey key) {
+						return StringUtils.shorten(key.getPublicKey(), 24);
+					}
+				})
+				.name("Type").align(SWT.LEFT).weight(4).minWidth(100).buildColumn()
+				.buildViewer();
+
+		return viewer;
+	}
+
+	@Override
+	protected void onPageActivated(DataBindingContext dbc) {
+		try {
+			WizardUtils.runInWizard(new Job("Loading ssh keys...") {
+
+				@Override
+				protected IStatus run(IProgressMonitor monitor) {
+					try {
+						setViewerInput(pageModel.loadSSHKeys());
+						pageModel.loadSSHKeys();
+						return Status.OK_STATUS;
+					} catch (Exception e) {
+						clearViewer();
+						return OpenShiftUIActivator.createErrorStatus("Could not load ssh keys.", e);
+					}
+				}
+
+			}, getContainer(), getDataBindingContext());
+		} catch (Exception e) {
+			// ignore
+		}
+	}
+
+	private SelectionListener onRefresh() {
+		return new SelectionAdapter() {
+
+			@Override
+			public void widgetSelected(SelectionEvent e) {
+				try {
+					WizardUtils.runInWizard(new UIUpdatingJob("Refreshing keys...") {
+
+						@Override
+						protected IStatus run(IProgressMonitor monitor) {
+							pageModel.getUser().refresh();
+							setViewerInput(pageModel.getUser().getSSHKeys());
+							return Status.OK_STATUS;
+						}
+					}, getContainer());
+				} catch (Exception ex) {
+					StatusManager.getManager().handle(
+							OpenShiftUIActivator.createErrorStatus("Could not refresh keys.", ex), StatusManager.LOG);
+				}
+			}
+
+		};
+	}
+
+	private void clearViewer() {
+		setViewerInput(new ArrayList<IOpenShiftSSHKey>());
+	}
+
+	private void setViewerInput(final Collection<IOpenShiftSSHKey> keys) {
+		getShell().getDisplay().syncExec(new Runnable() {
+
+			@Override
+			public void run() {
+				viewer.setInput(keys);
+			}
+		});
+	}
+}
\ No newline at end of file


Property changes on: trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ssh/ManageSSHKeysWizardPage.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Copied: trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ssh/ManageSSHKeysWizardPageModel.java (from rev 43743, trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ManageSSHKeysWizardPageModel.java)
===================================================================
--- trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ssh/ManageSSHKeysWizardPageModel.java	                        (rev 0)
+++ trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ssh/ManageSSHKeysWizardPageModel.java	2012-09-17 14:56:03 UTC (rev 43749)
@@ -0,0 +1,53 @@
+/*******************************************************************************
+ * Copyright (c) 2012 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.openshift.express.internal.ui.wizard.ssh;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.jboss.tools.common.ui.databinding.ObservableUIPojo;
+import org.jboss.tools.openshift.express.internal.core.console.UserDelegate;
+
+import com.openshift.client.IOpenShiftSSHKey;
+
+/**
+ * @author André Dietisheim
+ */
+public class ManageSSHKeysWizardPageModel extends ObservableUIPojo {
+
+	public static final String PROPERTY_SSH_KEYS = "SSHKeys";
+
+	private UserDelegate user;
+	private List<IOpenShiftSSHKey> keys = new ArrayList<IOpenShiftSSHKey>();
+
+	public ManageSSHKeysWizardPageModel(UserDelegate user) {
+		this.user = user;
+	}
+
+	public List<IOpenShiftSSHKey> loadSSHKeys() {
+		return setSSHKeys(user.getSSHKeys());
+	}
+
+	public List<IOpenShiftSSHKey> getSSHKeys() {
+		return keys;
+	}
+
+	public List<IOpenShiftSSHKey> setSSHKeys(List<IOpenShiftSSHKey> keys) {
+		this.keys = keys;
+		firePropertyChange(PROPERTY_SSH_KEYS, this.keys, this.keys = keys);
+		return this.keys;
+	}
+
+	public UserDelegate getUser() {
+		return user;
+	}
+
+}


Property changes on: trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ssh/ManageSSHKeysWizardPageModel.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain



More information about the jbosstools-commits mailing list