[jbosstools-commits] JBoss Tools SVN: r39347 - in branches/jbosstools-3.3.0.Beta1/openshift/plugins/org.jboss.tools.openshift.express.ui: src/org/jboss/tools/openshift/express/internal/core/console and 6 other directories.
jbosstools-commits at lists.jboss.org
jbosstools-commits at lists.jboss.org
Wed Mar 7 12:39:59 EST 2012
Author: xcoulon
Date: 2012-03-07 12:39:57 -0500 (Wed, 07 Mar 2012)
New Revision: 39347
Removed:
branches/jbosstools-3.3.0.Beta1/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/core/console/IPasswordPrompter.java
Modified:
branches/jbosstools-3.3.0.Beta1/openshift/plugins/org.jboss.tools.openshift.express.ui/plugin.xml
branches/jbosstools-3.3.0.Beta1/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/core/console/UserDelegate.java
branches/jbosstools-3.3.0.Beta1/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/core/console/UserModel.java
branches/jbosstools-3.3.0.Beta1/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/OpenShiftUIActivator.java
branches/jbosstools-3.3.0.Beta1/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/messages/OpenShiftExpressUIMessages.java
branches/jbosstools-3.3.0.Beta1/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/messages/OpenShiftExpressUIMessages.properties
branches/jbosstools-3.3.0.Beta1/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/viewer/OpenShiftExpressConsoleContentProvider.java
branches/jbosstools-3.3.0.Beta1/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/viewer/OpenShiftExpressConsoleLabelProvider.java
branches/jbosstools-3.3.0.Beta1/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/viewer/actionDelegate/OpenConnectionDialogActionDelegate.java
branches/jbosstools-3.3.0.Beta1/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/viewer/property/PropertySourceAdapterFactory.java
branches/jbosstools-3.3.0.Beta1/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/viewer/property/UserPropertySource.java
branches/jbosstools-3.3.0.Beta1/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ApplicationSelectionDialog.java
branches/jbosstools-3.3.0.Beta1/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ApplicationSelectionDialogModel.java
branches/jbosstools-3.3.0.Beta1/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/CredentialsWizardPageModel.java
Log:
Fixed - JBIDE-11184
NPE when the user is not connected (ignored the password dialog, did not input his password)
Fixed - JBIDE-10856
Application selection UI issues
Modified: branches/jbosstools-3.3.0.Beta1/openshift/plugins/org.jboss.tools.openshift.express.ui/plugin.xml
===================================================================
--- branches/jbosstools-3.3.0.Beta1/openshift/plugins/org.jboss.tools.openshift.express.ui/plugin.xml 2012-03-07 17:32:13 UTC (rev 39346)
+++ branches/jbosstools-3.3.0.Beta1/openshift/plugins/org.jboss.tools.openshift.express.ui/plugin.xml 2012-03-07 17:39:57 UTC (rev 39347)
@@ -521,14 +521,14 @@
<viewContribution
id="org.jboss.tools.openshift.express.ui.viewer.expressConsoleViewContribution"
targetID="org.jboss.tools.openshift.express.ui.viewer.expressConsoleView">
- <action
+ <!--action
class="org.jboss.tools.openshift.express.internal.ui.viewer.actionDelegate.RefreshViewerActionDelegate"
icon="icons/refresh.gif"
id="org.jboss.tools.openshift.express.ui.viewActions.refreshAction"
label="Refresh"
style="push"
toolbarPath="openshift">
- </action>
+ </action-->
<action
class="org.jboss.tools.openshift.express.internal.ui.viewer.actionDelegate.OpenConnectionDialogActionDelegate"
icon="icons/resource_obj.gif"
Deleted: branches/jbosstools-3.3.0.Beta1/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/core/console/IPasswordPrompter.java
===================================================================
--- branches/jbosstools-3.3.0.Beta1/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/core/console/IPasswordPrompter.java 2012-03-07 17:32:13 UTC (rev 39346)
+++ branches/jbosstools-3.3.0.Beta1/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/core/console/IPasswordPrompter.java 2012-03-07 17:39:57 UTC (rev 39347)
@@ -1,31 +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.core.console;
-
-import java.util.Map;
-
-import com.openshift.express.client.IUser;
-
-public interface IPasswordPrompter {
-
- public enum PromptResult {
- PASSWORD_VALUE, SAVE_PASSWORD_VALUE;
- }
- /**
- * Returns a map of the values entered by the user. The value indexed with {@link IPasswordPrompter.PromptResult.PASSWORD_VALUE} in the
- * returning array is the input password, the value indexed with indexed with {@link IPasswordPrompter.PromptResult.SAVE_PASSWORD_VALUE} is the Boolean stating
- * whether the password should be saved in the secured storage or not.
- *
- * @param user
- * @return map with password value (as String) and 'save password' (as Boolean)
- */
- public Map<PromptResult, Object> getPasswordFor(IUser user);
-}
Modified: branches/jbosstools-3.3.0.Beta1/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/core/console/UserDelegate.java
===================================================================
--- branches/jbosstools-3.3.0.Beta1/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/core/console/UserDelegate.java 2012-03-07 17:32:13 UTC (rev 39346)
+++ branches/jbosstools-3.3.0.Beta1/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/core/console/UserDelegate.java 2012-03-07 17:39:57 UTC (rev 39347)
@@ -11,10 +11,16 @@
package org.jboss.tools.openshift.express.internal.core.console;
import java.util.List;
-import java.util.Map;
-import org.jboss.tools.openshift.express.internal.core.console.IPasswordPrompter.PromptResult;
+import org.eclipse.jface.window.Window;
+import org.eclipse.jface.wizard.IWizard;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.PlatformUI;
+import org.jboss.tools.common.ui.WizardUtils;
import org.jboss.tools.openshift.express.internal.ui.utils.Logger;
+import org.jboss.tools.openshift.express.internal.ui.viewer.ConnectToOpenShiftWizard;
import com.openshift.express.client.IApplication;
import com.openshift.express.client.ICartridge;
@@ -27,12 +33,29 @@
public class UserDelegate implements IUser {
private IUser delegate;
private boolean rememberPassword;
+ private boolean connected;
+ private boolean alreadyPromptedForPassword;
- public UserDelegate(IUser user, boolean rememberPassword) {
+ public UserDelegate(IUser user, boolean rememberPassword, boolean connected) {
this.delegate = user;
this.rememberPassword = rememberPassword;
+ this.setConnected(connected);
}
+ /**
+ * @return the delegate
+ */
+ protected final IUser getDelegate() {
+ return delegate;
+ }
+
+ /**
+ * @param delegate the delegate to set
+ */
+ protected final void setDelegate(IUser delegate) {
+ this.delegate = delegate;
+ }
+
public String getRhlogin() {
return delegate.getRhlogin();
}
@@ -44,98 +67,176 @@
return rememberPassword;
}
- protected void checkForPassword() {
+ /**
+ * @param rememberPassword the rememberPassword to set
+ */
+ protected final void setRememberPassword(boolean rememberPassword) {
+ this.rememberPassword = rememberPassword;
+ }
+
+ public boolean canPromptForPassword() {
+ return this.alreadyPromptedForPassword == false;
+ }
+
+ /**
+ * Prompts user for password if it was not given or retrieved from secure storage before.
+ * @return true if user entered credentials, false otherwise.
+ */
+ public boolean checkForPassword() {
if( delegate.getPassword() == null || "".equals(delegate.getPassword())) {
try {
- Map<PromptResult, Object> passwordAndSaveValues = UserModel.promptForPassword(this);
- if(passwordAndSaveValues != null) {
- final String password = (String) passwordAndSaveValues.get(PromptResult.PASSWORD_VALUE);
- delegate = UserModel.getDefault().createUser(delegate.getRhlogin(), password);
- final Boolean save = (Boolean) passwordAndSaveValues.get(PromptResult.SAVE_PASSWORD_VALUE);
- this.rememberPassword = save;
- }
+ this.alreadyPromptedForPassword = true;
+ Display.getDefault().syncExec(new Runnable() { public void run() {
+ final IWorkbenchWindow activeWorkbenchWindow = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
+ final Shell shell = activeWorkbenchWindow != null ? activeWorkbenchWindow.getShell() : null;
+ if(shell == null) {
+ Logger.error("Could not open Credentials Wizard: no shell available");
+ return;
+ }
+ final IWizard connectToOpenShiftWizard = new ConnectToOpenShiftWizard();
+ int returnCode = WizardUtils.openWizardDialog(connectToOpenShiftWizard, shell);
+ if (returnCode == Window.OK) {
+ Logger.debug("OpenShift Auth succeeded.");
+ setDelegate(UserModel.getDefault().getRecentUser().getDelegate());
+ setConnected(true);
+ setRememberPassword(UserModel.getDefault().getRecentUser().isRememberPassword());
+ } else {
+ setConnected(false);
+ }
+ }});
} catch( Exception e ) {
Logger.error("Failed to retrieve User's password", e);
}
}
+ return (delegate.getPassword() != null && !"".equals(delegate.getPassword()));
}
public IApplication createApplication(String arg0, ICartridge arg1)
throws OpenShiftException {
- checkForPassword();
- return delegate.createApplication(arg0, arg1);
+ if(checkForPassword()) {
+ return delegate.createApplication(arg0, arg1);
+ }
+ return null;
}
public IDomain createDomain(String arg0, ISSHPublicKey arg1)
throws OpenShiftException {
- checkForPassword();
- return delegate.createDomain(arg0, arg1);
+ if(checkForPassword()) {
+ return delegate.createDomain(arg0, arg1);
+ }
+ return null;
}
public IApplication getApplicationByName(String arg0)
throws OpenShiftException {
- checkForPassword();
- return delegate.getApplicationByName(arg0);
+ if(checkForPassword()) {
+ return delegate.getApplicationByName(arg0);
+ }
+ return null;
}
public List<IApplication> getApplications() throws OpenShiftException {
- checkForPassword();
- return delegate.getApplications();
+ if(checkForPassword()) {
+ return delegate.getApplications();
+ }
+ return null;
}
public List<IApplication> getApplicationsByCartridge(ICartridge arg0)
throws OpenShiftException {
- checkForPassword();
- return delegate.getApplicationsByCartridge(arg0);
+ if(checkForPassword()) {
+ return delegate.getApplicationsByCartridge(arg0);
+ }
+ return null;
}
public String getAuthIV() {
- checkForPassword();
- return delegate.getAuthIV();
+ if(checkForPassword()) {
+ return delegate.getAuthIV();
+ }
+ return null;
}
public String getAuthKey() {
- checkForPassword();
- return delegate.getAuthKey();
+ if(checkForPassword()) {
+ return delegate.getAuthKey();
+ }
+ return null;
}
public ICartridge getCartridgeByName(String arg0) throws OpenShiftException {
- checkForPassword();
- return delegate.getCartridgeByName(arg0);
+ if(checkForPassword()) {
+ return delegate.getCartridgeByName(arg0);
+ }
+ return null;
}
public List<ICartridge> getCartridges() throws OpenShiftException {
- checkForPassword();
- return delegate.getCartridges();
+ if(checkForPassword()) {
+ return delegate.getCartridges();
+ }
+ return null;
}
public IDomain getDomain() throws OpenShiftException {
- checkForPassword();
- return delegate.getDomain();
+ if(checkForPassword()) {
+ return delegate.getDomain();
+ }
+ return null;
}
public List<IEmbeddableCartridge> getEmbeddableCartridges()
throws OpenShiftException {
- checkForPassword();
- return delegate.getEmbeddableCartridges();
+ if(checkForPassword()) {
+ return delegate.getEmbeddableCartridges();
+ }
+ return null;
}
public ISSHPublicKey getSshKey() throws OpenShiftException {
- checkForPassword();
- return delegate.getSshKey();
+ if(checkForPassword()) {
+ return delegate.getSshKey();
+ }
+ return null;
}
public String getUUID() throws OpenShiftException {
- checkForPassword();
- return delegate.getUUID();
+ if(checkForPassword()) {
+ return delegate.getUUID();
+ }
+ return null;
}
public boolean hasApplication(String arg0) throws OpenShiftException {
- checkForPassword();
- return delegate.hasApplication(arg0);
+ if(checkForPassword()) {
+ return delegate.hasApplication(arg0);
+ }
+ return false;
}
public boolean hasApplication(ICartridge arg0) throws OpenShiftException {
- checkForPassword();
- return delegate.hasApplication(arg0);
+ if(checkForPassword()) {
+ return delegate.hasApplication(arg0);
+ }
+ return false;
}
public boolean hasDomain() throws OpenShiftException {
- checkForPassword();
- return delegate.hasDomain();
+ if(checkForPassword()) {
+ return delegate.hasDomain();
+ }
+ return false;
+
}
public boolean isValid() throws OpenShiftException {
- checkForPassword();
- return delegate.isValid();
+ if(checkForPassword()) {
+ return delegate.isValid();
+ }
+ return false;
}
public void refresh() throws OpenShiftException {
- checkForPassword();
- delegate.refresh();
+ if(checkForPassword()) {
+ delegate.refresh();
+ }
}
+
+ /**
+ * @return the connected
+ */
+ public boolean isConnected() {
+ return connected;
+ }
+
+ /**
+ * @param connected the connected to set
+ */
+ public void setConnected(boolean connected) {
+ this.connected = connected;
+ }
}
Modified: branches/jbosstools-3.3.0.Beta1/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/core/console/UserModel.java
===================================================================
--- branches/jbosstools-3.3.0.Beta1/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/core/console/UserModel.java 2012-03-07 17:32:13 UTC (rev 39346)
+++ branches/jbosstools-3.3.0.Beta1/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/core/console/UserModel.java 2012-03-07 17:39:57 UTC (rev 39347)
@@ -15,13 +15,11 @@
import java.util.Collection;
import java.util.HashMap;
import java.util.Iterator;
-import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import org.jboss.tools.common.ui.preferencevalue.StringPreferenceValue;
import org.jboss.tools.common.ui.preferencevalue.StringsPreferenceValue;
-import org.jboss.tools.openshift.express.internal.core.console.IPasswordPrompter.PromptResult;
import org.jboss.tools.openshift.express.internal.ui.OpenShiftUIActivator;
import org.jboss.tools.openshift.express.internal.ui.utils.Logger;
import org.jboss.tools.openshift.express.internal.ui.utils.OpenShiftPasswordStorageKey;
@@ -44,30 +42,6 @@
return model;
}
- private static IPasswordPrompter prompter;
- public static void setPasswordPrompt(IPasswordPrompter prompt) {
- prompter =prompt;
- }
-
- public static IPasswordPrompter getPasswordPrompt() {
- return prompter;
- }
-
- /**
- * Returns a map of the values entered by the user. The value indexed with {@link IPasswordPrompter.PromptResult.PASSWORD_VALUE} in the
- * returning array is the input password, the value indexed with indexed with {@link IPasswordPrompter.PromptResult.SAVE_PASSWORD_VALUE} is the Boolean stating
- * whether the password should be saved in the secured storage or not.
- *
- * @param user
- * @return map with password value (as String) and 'save password' (as
- * Boolean), or null if the password prompter could not be
- * initialized
- */
-
- public static Map<PromptResult, Object> promptForPassword(IUser user) {
- return prompter == null ? null : prompter.getPasswordFor(user);
- }
-
/** The most recent user connected on OpenShift. */
private UserDelegate recentUser = null;
private HashMap<String, UserDelegate> allUsers = new HashMap<String, UserDelegate>();
@@ -164,7 +138,7 @@
for (int i = 0; i < users.length; i++) {
try {
String password = getPasswordFromSecureStorage(users[i]);
- UserDelegate u = new UserDelegate(createUser(users[i], password), password != null);
+ UserDelegate u = new UserDelegate(createUser(users[i], password), password != null, password != null);
addUser(u);
} catch (OpenShiftException ose) {
// TODO
Modified: branches/jbosstools-3.3.0.Beta1/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/OpenShiftUIActivator.java
===================================================================
--- branches/jbosstools-3.3.0.Beta1/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/OpenShiftUIActivator.java 2012-03-07 17:32:13 UTC (rev 39346)
+++ branches/jbosstools-3.3.0.Beta1/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/OpenShiftUIActivator.java 2012-03-07 17:39:57 UTC (rev 39347)
@@ -1,8 +1,6 @@
package org.jboss.tools.openshift.express.internal.ui;
import java.net.URL;
-import java.util.HashMap;
-import java.util.Map;
import org.eclipse.core.runtime.FileLocator;
import org.eclipse.core.runtime.IPath;
@@ -10,23 +8,16 @@
import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Status;
import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.jface.window.Window;
import org.eclipse.osgi.util.NLS;
import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.plugin.AbstractUIPlugin;
-import org.jboss.ide.eclipse.as.ui.dialogs.RequiredCredentialsDialog;
-import org.jboss.tools.openshift.express.internal.core.console.IPasswordPrompter;
import org.jboss.tools.openshift.express.internal.core.console.UserModel;
import org.osgi.framework.BundleContext;
-import com.openshift.express.client.IUser;
-
/**
* The activator class controls the plug-in life cycle
*/
-public class OpenShiftUIActivator extends AbstractUIPlugin implements IPasswordPrompter {
+public class OpenShiftUIActivator extends AbstractUIPlugin {
// The plug-in ID
public static final String PLUGIN_ID = "org.jboss.tools.openshift.express.ui"; //$NON-NLS-1$
@@ -50,7 +41,6 @@
public void start(BundleContext context) throws Exception {
super.start(context);
plugin = this;
- UserModel.setPasswordPrompt(this);
}
/*
@@ -128,20 +118,4 @@
return ImageDescriptor.createFromURL(imageFileUrl);
}
- public Map<PromptResult, Object> getPasswordFor(final IUser user) {
- final Map<PromptResult, Object> val = new HashMap<PromptResult, Object>();
- Display.getDefault().syncExec(new Runnable() {
- public void run() {
- Shell shell = Display.getDefault().getActiveShell();
- RequiredCredentialsDialog d = new RequiredCredentialsDialog(shell, user.getRhlogin(), user.getPassword());
- d.setCanModifyUser(false);
- d.setDescription("Provide enter the password for your express server");
- if( d.open() == Window.OK) {
- val.put(PromptResult.PASSWORD_VALUE, d.getPass());
- val.put(PromptResult.SAVE_PASSWORD_VALUE, d.getSave());
- }
- }
- });
- return val;
- }
}
Modified: branches/jbosstools-3.3.0.Beta1/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/messages/OpenShiftExpressUIMessages.java
===================================================================
--- branches/jbosstools-3.3.0.Beta1/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/messages/OpenShiftExpressUIMessages.java 2012-03-07 17:32:13 UTC (rev 39346)
+++ branches/jbosstools-3.3.0.Beta1/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/messages/OpenShiftExpressUIMessages.java 2012-03-07 17:39:57 UTC (rev 39347)
@@ -42,4 +42,9 @@
public static String REFRESH_VIEWER_ACTION;
public static String DELETE_CONNECTION_ACTION;
+
+ public static String USER_NOT_CONNECTED_LABEL;
+
+ public static String LOADING_USER_APPLICATIONS_LABEL;
+
}
Modified: branches/jbosstools-3.3.0.Beta1/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/messages/OpenShiftExpressUIMessages.properties
===================================================================
--- branches/jbosstools-3.3.0.Beta1/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/messages/OpenShiftExpressUIMessages.properties 2012-03-07 17:32:13 UTC (rev 39346)
+++ branches/jbosstools-3.3.0.Beta1/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/messages/OpenShiftExpressUIMessages.properties 2012-03-07 17:39:57 UTC (rev 39347)
@@ -18,4 +18,8 @@
DELETE_CONNECTION_ACTION=Delete
+USER_NOT_CONNECTED_LABEL=<User is not connected>
+LOADING_USER_APPLICATIONS_LABEL=Loading
+
+
Modified: branches/jbosstools-3.3.0.Beta1/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/viewer/OpenShiftExpressConsoleContentProvider.java
===================================================================
--- branches/jbosstools-3.3.0.Beta1/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/viewer/OpenShiftExpressConsoleContentProvider.java 2012-03-07 17:32:13 UTC (rev 39346)
+++ branches/jbosstools-3.3.0.Beta1/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/viewer/OpenShiftExpressConsoleContentProvider.java 2012-03-07 17:39:57 UTC (rev 39347)
@@ -22,6 +22,7 @@
import org.eclipse.jface.viewers.StructuredViewer;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.swt.widgets.Display;
+import org.jboss.tools.openshift.express.internal.core.console.UserDelegate;
import org.jboss.tools.openshift.express.internal.core.console.UserModel;
import org.jboss.tools.openshift.express.internal.ui.utils.Logger;
@@ -53,6 +54,11 @@
}
}
+ public static class NotConnectedUserStub {
+ public NotConnectedUserStub () {
+ }
+ }
+
// Keep track of what's loading and what's finished
private ArrayList<IUser> loadedUsers = new ArrayList<IUser>();
private ArrayList<IUser> loadingUsers = new ArrayList<IUser>();
@@ -76,7 +82,11 @@
@Override
public Object[] getChildren(Object parentElement) {
- if (parentElement instanceof IUser) {
+ if (parentElement instanceof UserDelegate) {
+ UserDelegate user = (UserDelegate) parentElement;
+ if(!user.isConnected() && !user.canPromptForPassword()) {
+ return new Object[]{new NotConnectedUserStub()};
+ }
if (!loadedUsers.contains(parentElement)) {
if (!loadingUsers.contains(parentElement)) {
// Load the data
@@ -118,8 +128,8 @@
IUser user = ((OpenShiftExpressConsoleContentCategory) parentElement).getUser();
children = new Object[] { user };
}
- if (parentElement instanceof IUser) {
- final IUser user = (IUser) parentElement;
+ if (parentElement instanceof UserDelegate) {
+ final UserDelegate user = (UserDelegate) parentElement;
if (user.hasDomain()) {
children = user.getApplications().toArray();
}
Modified: branches/jbosstools-3.3.0.Beta1/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/viewer/OpenShiftExpressConsoleLabelProvider.java
===================================================================
--- branches/jbosstools-3.3.0.Beta1/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/viewer/OpenShiftExpressConsoleLabelProvider.java 2012-03-07 17:32:13 UTC (rev 39346)
+++ branches/jbosstools-3.3.0.Beta1/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/viewer/OpenShiftExpressConsoleLabelProvider.java 2012-03-07 17:39:57 UTC (rev 39347)
@@ -18,7 +18,9 @@
import org.eclipse.ui.ISharedImages;
import org.eclipse.ui.PlatformUI;
import org.jboss.tools.openshift.express.internal.ui.OpenShiftUIActivator;
+import org.jboss.tools.openshift.express.internal.ui.messages.OpenShiftExpressUIMessages;
import org.jboss.tools.openshift.express.internal.ui.viewer.OpenShiftExpressConsoleContentProvider.LoadingStub;
+import org.jboss.tools.openshift.express.internal.ui.viewer.OpenShiftExpressConsoleContentProvider.NotConnectedUserStub;
import com.openshift.express.client.IApplication;
import com.openshift.express.client.IEmbeddableCartridge;
@@ -107,8 +109,11 @@
}
if (element instanceof LoadingStub) {
- return new StyledString("Loading...");
+ return new StyledString(OpenShiftExpressUIMessages.LOADING_USER_APPLICATIONS_LABEL);
}
+ if (element instanceof NotConnectedUserStub) {
+ return new StyledString(OpenShiftExpressUIMessages.USER_NOT_CONNECTED_LABEL);
+ }
if (element instanceof OpenShiftException ) {
return new StyledString( ((OpenShiftException)element).getMessage());
}
Modified: branches/jbosstools-3.3.0.Beta1/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/viewer/actionDelegate/OpenConnectionDialogActionDelegate.java
===================================================================
--- branches/jbosstools-3.3.0.Beta1/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/viewer/actionDelegate/OpenConnectionDialogActionDelegate.java 2012-03-07 17:32:13 UTC (rev 39346)
+++ branches/jbosstools-3.3.0.Beta1/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/viewer/actionDelegate/OpenConnectionDialogActionDelegate.java 2012-03-07 17:39:57 UTC (rev 39347)
@@ -4,10 +4,10 @@
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.window.Window;
import org.eclipse.jface.wizard.IWizard;
-import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.IViewActionDelegate;
import org.eclipse.ui.IViewPart;
+import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.navigator.CommonNavigator;
import org.jboss.tools.common.ui.WizardUtils;
import org.jboss.tools.openshift.express.internal.core.console.UserModel;
@@ -20,8 +20,7 @@
@Override
public void run(IAction action) {
- final Display display = Display.getCurrent();
- final Shell shell = new Shell(display);
+ final Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
final IWizard connectToOpenShiftWizard = new ConnectToOpenShiftWizard();
int returnCode = WizardUtils.openWizardDialog(connectToOpenShiftWizard, shell);
if (returnCode == Window.OK) {
Modified: branches/jbosstools-3.3.0.Beta1/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/viewer/property/PropertySourceAdapterFactory.java
===================================================================
--- branches/jbosstools-3.3.0.Beta1/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/viewer/property/PropertySourceAdapterFactory.java 2012-03-07 17:32:13 UTC (rev 39346)
+++ branches/jbosstools-3.3.0.Beta1/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/viewer/property/PropertySourceAdapterFactory.java 2012-03-07 17:39:57 UTC (rev 39347)
@@ -12,10 +12,10 @@
import org.eclipse.core.runtime.IAdapterFactory;
import org.eclipse.ui.views.properties.IPropertySource;
+import org.jboss.tools.openshift.express.internal.core.console.UserDelegate;
import com.openshift.express.client.IApplication;
import com.openshift.express.client.IEmbeddableCartridge;
-import com.openshift.express.client.IUser;
/**
* @author Xavier Coulon
@@ -26,8 +26,8 @@
@Override
public Object getAdapter(Object adaptableObject, @SuppressWarnings("rawtypes") Class adapterType) {
if(adapterType == IPropertySource.class) {
- if(adaptableObject instanceof IUser) {
- return new UserPropertySource((IUser)adaptableObject);
+ if(adaptableObject instanceof UserDelegate) {
+ return new UserPropertySource((UserDelegate)adaptableObject);
}
if(adaptableObject instanceof IApplication) {
return new ApplicationPropertySource((IApplication)adaptableObject);
Modified: branches/jbosstools-3.3.0.Beta1/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/viewer/property/UserPropertySource.java
===================================================================
--- branches/jbosstools-3.3.0.Beta1/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/viewer/property/UserPropertySource.java 2012-03-07 17:32:13 UTC (rev 39346)
+++ branches/jbosstools-3.3.0.Beta1/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/viewer/property/UserPropertySource.java 2012-03-07 17:39:57 UTC (rev 39347)
@@ -13,9 +13,10 @@
import org.eclipse.ui.views.properties.IPropertyDescriptor;
import org.eclipse.ui.views.properties.IPropertySource;
import org.eclipse.ui.views.properties.PropertyDescriptor;
+import org.jboss.tools.openshift.express.internal.core.console.UserDelegate;
+import org.jboss.tools.openshift.express.internal.ui.messages.OpenShiftExpressUIMessages;
import org.jboss.tools.openshift.express.internal.ui.utils.Logger;
-import com.openshift.express.client.IUser;
import com.openshift.express.client.OpenShiftException;
/**
@@ -23,9 +24,9 @@
*/
public class UserPropertySource implements IPropertySource {
- private final IUser user;
+ private final UserDelegate user;
- public UserPropertySource(IUser user) {
+ public UserPropertySource(UserDelegate user) {
this.user = user;
}
Modified: branches/jbosstools-3.3.0.Beta1/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ApplicationSelectionDialog.java
===================================================================
--- branches/jbosstools-3.3.0.Beta1/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ApplicationSelectionDialog.java 2012-03-07 17:32:13 UTC (rev 39346)
+++ branches/jbosstools-3.3.0.Beta1/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ApplicationSelectionDialog.java 2012-03-07 17:39:57 UTC (rev 39347)
@@ -138,12 +138,12 @@
}
}), null);
- Button refreshButton = new Button(dialogArea, SWT.PUSH);
+ /*Button refreshButton = new Button(dialogArea, SWT.PUSH);
refreshButton.setText("R&efresh");
GridDataFactory.fillDefaults().align(SWT.RIGHT, SWT.TOP).grab(false, false).hint(80, SWT.DEFAULT)
.applyTo(refreshButton);
refreshButton.addSelectionListener(onRefresh(dbc));
-
+ */
Button detailsButton = new Button(dialogArea, SWT.PUSH);
detailsButton.setText("De&tails...");
GridDataFactory.fillDefaults().align(SWT.RIGHT, SWT.TOP).grab(false, true).hint(80, SWT.DEFAULT)
@@ -239,6 +239,7 @@
WizardUtils.runInWizard(new Job("Loading applications...") {
@Override
protected IStatus run(IProgressMonitor monitor) {
+ dialogModel.refresh();
final Collection<IApplication> applications = dialogModel.getApplications();
setViewerInput(applications);
return Status.OK_STATUS;
Modified: branches/jbosstools-3.3.0.Beta1/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ApplicationSelectionDialogModel.java
===================================================================
--- branches/jbosstools-3.3.0.Beta1/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ApplicationSelectionDialogModel.java 2012-03-07 17:32:13 UTC (rev 39346)
+++ branches/jbosstools-3.3.0.Beta1/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ApplicationSelectionDialogModel.java 2012-03-07 17:39:57 UTC (rev 39347)
@@ -38,6 +38,14 @@
this.selectedApplication = wizardModel.getApplication();
}
+ public void refresh() {
+ try {
+ getUser().refresh();
+ } catch (OpenShiftException e) {
+ Logger.error("Failed to refresh User's account", e);
+ }
+ }
+
public List<IApplication> getApplications() {
try {
IUser user = getUser();
Modified: branches/jbosstools-3.3.0.Beta1/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/CredentialsWizardPageModel.java
===================================================================
--- branches/jbosstools-3.3.0.Beta1/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/CredentialsWizardPageModel.java 2012-03-07 17:32:13 UTC (rev 39346)
+++ branches/jbosstools-3.3.0.Beta1/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/CredentialsWizardPageModel.java 2012-03-07 17:39:57 UTC (rev 39347)
@@ -214,7 +214,7 @@
IStatus status = Status.OK_STATUS;
UserDelegate user = null;
try {
- user = new UserDelegate(UserModel.getDefault().createUser(getRhLogin(), getPassword()), rememberPassword);
+ user = new UserDelegate(UserModel.getDefault().createUser(rhLogin, password), rememberPassword, password != null);
if (user.isValid()) {
storeUser(user);
} else {
More information about the jbosstools-commits
mailing list