JBoss Tools SVN: r38549 - trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/viewer.
by jbosstools-commits@lists.jboss.org
Author: rob.stryker(a)jboss.com
Date: 2012-02-09 08:10:55 -0500 (Thu, 09 Feb 2012)
New Revision: 38549
Modified:
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/viewer/OpenShiftExpressConsoleContentProvider.java
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/viewer/OpenShiftExpressConsoleLabelProvider.java
Log:
Adds a loading... child in the viewer to prevent workspace freezes.
Modified: trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/viewer/OpenShiftExpressConsoleContentProvider.java
===================================================================
--- trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/viewer/OpenShiftExpressConsoleContentProvider.java 2012-02-09 12:38:39 UTC (rev 38548)
+++ trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/viewer/OpenShiftExpressConsoleContentProvider.java 2012-02-09 13:10:55 UTC (rev 38549)
@@ -1,7 +1,6 @@
package org.jboss.tools.openshift.express.internal.ui.viewer;
-import java.util.concurrent.ArrayBlockingQueue;
-import java.util.concurrent.TimeUnit;
+import java.util.ArrayList;
import org.eclipse.core.resources.IWorkspaceRoot;
import org.eclipse.core.runtime.IProgressMonitor;
@@ -9,7 +8,9 @@
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.jface.viewers.ITreeContentProvider;
+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.UserModel;
import org.jboss.tools.openshift.express.internal.ui.utils.Logger;
@@ -19,6 +20,8 @@
public class OpenShiftExpressConsoleContentProvider implements ITreeContentProvider {
+ private StructuredViewer viewer;
+
@Override
public void dispose() {
// TODO Auto-generated method stub
@@ -27,56 +30,110 @@
@Override
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+ this.viewer = (StructuredViewer)viewer;
}
+
+ public static class LoadingStub {
+ public LoadingStub() {
+ }
+ }
+ // Keep track of what's loading and what's finished
+ private ArrayList<IUser> loadedUsers = new ArrayList<IUser>();
+ private ArrayList<IUser> loadingUsers = new ArrayList<IUser>();
+
@Override
public Object[] getElements(final Object parentElement) {
if(parentElement instanceof IWorkspaceRoot) {
return UserModel.getDefault().getUsers();
}
if( parentElement instanceof UserModel ) {
- return ((UserModel)parentElement).getUsers();
+ IUser[] users = ((UserModel)parentElement).getUsers();
+ return users;
}
- final ArrayBlockingQueue<Object[]> queue = new ArrayBlockingQueue<Object[]>(1);
- try {
- Job job = new Job("Loading OpenShift Express User information...") {
-
- @Override
- protected IStatus run(IProgressMonitor monitor) {
- // TODO Auto-generated method stub
- monitor.beginTask("Loading OpenShift Express information...", IProgressMonitor.UNKNOWN);
- monitor.worked(1);
- try {
- if (parentElement instanceof OpenShiftExpressConsoleContentCategory) {
- queue.offer(new Object[] { ((OpenShiftExpressConsoleContentCategory) parentElement).getUser() });
- }
- if (parentElement instanceof IUser) {
- queue.offer(((IUser) parentElement).getApplications().toArray());
- }
- if (parentElement instanceof IApplication) {
- queue.offer(((IApplication) parentElement).getEmbeddedCartridges().toArray());
- }
- // .... the actual work is done here...
- } catch (OpenShiftException e) {
- Logger.error("Unable to retrieve OpenShift Express information", e);
- } finally {
- monitor.done();
- }
- return Status.OK_STATUS;
+ if( parentElement instanceof IUser ) {
+ if( !loadedUsers.contains(parentElement)) {
+ if( !loadingUsers.contains(parentElement)) {
+ // Load the data
+ launchLoadingUserJob((IUser)parentElement);
}
- };
- job.setPriority(Job.LONG);
- job.schedule();
- //job.join();
- return queue.poll(10, TimeUnit.SECONDS);
- } catch (Exception e) {
- Logger.error("Failed to load OpenShit Express account information", e);
+ // return a stub object that says loading...
+ return new Object[]{new LoadingStub()};
+ }
}
+ return getChildrenFor(parentElement, false);
+ }
- return null;
+ // Force the children to load completely
+ private void getChildrenFor(Object[] parentElements) {
+ for( int i = 0; i < parentElements.length; i++ ) {
+ getChildrenFor(parentElements[i], true);
+ }
}
-
+
+ // Get the children without the protection of a "loading..." situation
+ private Object[] getChildrenFor(Object parentElement, boolean recurse) {
+ // .... the actual work is done here...
+ Object[] children = new Object[0];
+ try {
+ if (parentElement instanceof OpenShiftExpressConsoleContentCategory) {
+ IUser user = ((OpenShiftExpressConsoleContentCategory) parentElement).getUser();
+ children = new Object[] { user };
+ }
+ if (parentElement instanceof IUser) {
+ children = ((IUser) parentElement).getApplications().toArray();
+ }
+ if (parentElement instanceof IApplication) {
+ children = ((IApplication) parentElement).getEmbeddedCartridges().toArray();
+ }
+
+ if( recurse ) {
+ getChildrenFor(children);
+ }
+ } catch (OpenShiftException e) {
+ Logger.error("Unable to retrieve OpenShift Express information", e);
+ }
+ return children;
+ }
+
+ private void launchLoadingUserJob(final IUser user) {
+ Job job = new Job("Loading OpenShift Express User information...") {
+
+ @Override
+ protected IStatus run(IProgressMonitor monitor) {
+ monitor.beginTask("Loading OpenShift Express information...", IProgressMonitor.UNKNOWN);
+ monitor.worked(1);
+ // Get the actual children, with the delay
+ loadingUsers.add(user);
+ getChildrenFor(user, true);
+
+ loadedUsers.add(user);
+ loadingUsers.remove(user);
+
+ // refresh the parent object in the viewer when finished
+ try {
+ Thread.sleep(10000);
+ } catch(InterruptedException ie) {
+
+ }
+ refreshViewerObject(user);
+ monitor.done();
+ return Status.OK_STATUS;
+ }
+ };
+ job.setPriority(Job.LONG);
+ job.schedule();
+ }
+
+ private void refreshViewerObject(final Object object) {
+ Display.getDefault().asyncExec(new Runnable() {
+ public void run() {
+ viewer.refresh(object);
+ }
+ });
+ }
+
@Override
public Object[] getChildren(Object parentElement) {
return getElements(parentElement);
Modified: trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/viewer/OpenShiftExpressConsoleLabelProvider.java
===================================================================
--- trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/viewer/OpenShiftExpressConsoleLabelProvider.java 2012-02-09 12:38:39 UTC (rev 38548)
+++ trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/viewer/OpenShiftExpressConsoleLabelProvider.java 2012-02-09 13:10:55 UTC (rev 38549)
@@ -1,12 +1,13 @@
package org.jboss.tools.openshift.express.internal.ui.viewer;
+import org.eclipse.jface.viewers.DelegatingStyledCellLabelProvider.IStyledLabelProvider;
import org.eclipse.jface.viewers.ILabelProvider;
import org.eclipse.jface.viewers.ILabelProviderListener;
-import org.eclipse.jface.viewers.DelegatingStyledCellLabelProvider.IStyledLabelProvider;
import org.eclipse.jface.viewers.StyledString;
import org.eclipse.swt.graphics.Image;
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.viewer.OpenShiftExpressConsoleContentProvider.LoadingStub;
import com.openshift.express.client.IApplication;
import com.openshift.express.client.IEmbeddableCartridge;
@@ -88,6 +89,10 @@
styledString.setStyle(0, message.length(), StyledString.DECORATIONS_STYLER);
return new StyledString(message);
}
+
+ if( element instanceof LoadingStub) {
+ return new StyledString("Loading...");
+ }
return null;
}
14 years, 2 months
JBoss Tools SVN: r38548 - trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/jspeditor.
by jbosstools-commits@lists.jboss.org
Author: vrubezhny
Date: 2012-02-09 07:38:39 -0500 (Thu, 09 Feb 2012)
New Revision: 38548
Modified:
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/jspeditor/JSPMultiPageEditor.java
Log:
JBIDE-10835
"assertion failed" error clicking on JSP Error Marker
Fix for the issue.
Modified: trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/jspeditor/JSPMultiPageEditor.java
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/jspeditor/JSPMultiPageEditor.java 2012-02-09 12:30:16 UTC (rev 38547)
+++ trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/jspeditor/JSPMultiPageEditor.java 2012-02-09 12:38:39 UTC (rev 38548)
@@ -1,12 +1,12 @@
/*******************************************************************************
- * Copyright (c) 2007 Exadel, Inc. and Red Hat, Inc.
+ * Copyright (c) 2007-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:
- * Exadel, Inc. and Red Hat, Inc. - initial API and implementation
+ * Red Hat, Inc. - initial API and implementation
******************************************************************************/
package org.jboss.tools.jst.jsp.jspeditor;
@@ -539,8 +539,15 @@
public void gotoMarker(final IMarker marker) {
// setActivePage(IVisualEditor.VISUALSOURCE_MODE);
// pageChange(IVisualEditor.VISUALSOURCE_MODE);
- setActivePage(IVisualEditor.SOURCE_MODE);
- pageChange(IVisualEditor.SOURCE_MODE);
+
+ // Fix for JBIDE-10835: In some environments we have no working XulRunner,
+ // so, as result, there is only Source Tab is in editor
+ // (and its index is not IVisualEditor.SOURCE_MODE == 1, but 0)
+ //
+ int pageToActivate = (IVisualEditor.SOURCE_MODE < getPageCount() ? IVisualEditor.SOURCE_MODE : 0);
+
+ setActivePage(pageToActivate);
+ pageChange(pageToActivate);
IGotoMarker adapter = (IGotoMarker) sourceEditor
.getAdapter(IGotoMarker.class);
if (adapter != null) {
14 years, 2 months
JBoss Tools SVN: r38547 - trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard.
by jbosstools-commits@lists.jboss.org
Author: adietish
Date: 2012-02-09 07:30:16 -0500 (Thu, 09 Feb 2012)
New Revision: 38547
Modified:
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/OpenShiftExpressApplicationWizard.java
Log:
added INewWizard so that the wizard may be launched from central again
Modified: trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/OpenShiftExpressApplicationWizard.java
===================================================================
--- trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/OpenShiftExpressApplicationWizard.java 2012-02-09 12:06:19 UTC (rev 38546)
+++ trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/OpenShiftExpressApplicationWizard.java 2012-02-09 12:30:16 UTC (rev 38547)
@@ -25,6 +25,7 @@
import org.eclipse.jgit.errors.TransportException;
import org.eclipse.osgi.util.NLS;
import org.eclipse.ui.IImportWizard;
+import org.eclipse.ui.INewWizard;
import org.eclipse.ui.IWorkbench;
import org.jboss.tools.common.ui.DelegatingProgressMonitor;
import org.jboss.tools.common.ui.JobUtils;
@@ -42,7 +43,7 @@
* @author Xavier Coulon
*/
public class OpenShiftExpressApplicationWizard extends
- AbstractOpenShiftApplicationWizard<OpenShiftExpressApplicationWizardModel> implements IImportWizard {
+ AbstractOpenShiftApplicationWizard<OpenShiftExpressApplicationWizardModel> implements IImportWizard, INewWizard {
public OpenShiftExpressApplicationWizard() {
super();
14 years, 2 months
JBoss Tools SVN: r38546 - trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/core/console.
by jbosstools-commits@lists.jboss.org
Author: rob.stryker(a)jboss.com
Date: 2012-02-09 07:06:19 -0500 (Thu, 09 Feb 2012)
New Revision: 38546
Modified:
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/core/console/UserModel.java
Log:
stupid typo... added a null value. ugh.
Modified: trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/core/console/UserModel.java
===================================================================
--- trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/core/console/UserModel.java 2012-02-09 12:04:37 UTC (rev 38545)
+++ trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/core/console/UserModel.java 2012-02-09 12:06:19 UTC (rev 38546)
@@ -56,7 +56,7 @@
public void addUser(IUser user) {
try {
- allUsers.put(user.getRhlogin(), recentUser);
+ allUsers.put(user.getRhlogin(), user);
this.recentUser = user;
} catch(OpenShiftException ose ) {
// TODO
14 years, 2 months
JBoss Tools SVN: r38545 - trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard.
by jbosstools-commits@lists.jboss.org
Author: adietish
Date: 2012-02-09 07:04:37 -0500 (Thu, 09 Feb 2012)
New Revision: 38545
Modified:
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/OpenShiftExpressApplicationWizardModel.java
Log:
minor cleanup
Modified: trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/OpenShiftExpressApplicationWizardModel.java
===================================================================
--- trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/OpenShiftExpressApplicationWizardModel.java 2012-02-09 11:59:04 UTC (rev 38544)
+++ trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/OpenShiftExpressApplicationWizardModel.java 2012-02-09 12:04:37 UTC (rev 38545)
@@ -19,6 +19,7 @@
import org.eclipse.wst.server.core.ServerCore;
import org.jboss.tools.common.ui.databinding.ObservableUIPojo;
import org.jboss.tools.openshift.egit.core.EGitUtils;
+import org.jboss.tools.openshift.express.internal.core.behaviour.ExpressServerUtils;
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.wizard.appimport.ConfigureGitSharedProject;
@@ -37,8 +38,8 @@
protected HashMap<String, Object> dataModel = new HashMap<String, Object>();
- private static final int APP_CREATION_TIMEOUT = 30;
- private static final String SELECTED_EMBEDDABLE_CARTRIDGES = "selectedEmbeddableCartridges";
+ private static final int APP_CREATION_TIMEOUT = 40;
+ private static final String KEY_SELECTED_EMBEDDABLE_CARTRIDGES = "selectedEmbeddableCartridges";
public OpenShiftExpressApplicationWizardModel() {
@@ -48,7 +49,7 @@
setCreateServerAdapter(true);
setRepositoryPath(DEFAULT_REPOSITORY_PATH);
setRemoteName(NEW_PROJECT_REMOTE_NAME_DEFAULT);
- setServerType(ServerCore.findServerType("org.jboss.tools.openshift.express.openshift.server.type"));
+ setServerType(ServerCore.findServerType(ExpressServerUtils.OPENSHIFT_SERVER_TYPE));
setPublicationMode(PUBLISH_SOURCE);
setUseExistingApplication(false);
}
@@ -381,10 +382,10 @@
public List<IEmbeddableCartridge> getSelectedEmbeddableCartridges() {
@SuppressWarnings("unchecked")
- List<IEmbeddableCartridge> selectedEmbeddableCartridges = (List<IEmbeddableCartridge>) dataModel.get(SELECTED_EMBEDDABLE_CARTRIDGES);
+ List<IEmbeddableCartridge> selectedEmbeddableCartridges = (List<IEmbeddableCartridge>) dataModel.get(KEY_SELECTED_EMBEDDABLE_CARTRIDGES);
if(selectedEmbeddableCartridges == null) {
selectedEmbeddableCartridges = new ArrayList<IEmbeddableCartridge>();
- dataModel.put(SELECTED_EMBEDDABLE_CARTRIDGES, selectedEmbeddableCartridges);
+ dataModel.put(KEY_SELECTED_EMBEDDABLE_CARTRIDGES, selectedEmbeddableCartridges);
}
return selectedEmbeddableCartridges;
}
14 years, 2 months
JBoss Tools SVN: r38544 - in trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal: ui and 1 other directories.
by jbosstools-commits@lists.jboss.org
Author: rob.stryker(a)jboss.com
Date: 2012-02-09 06:59:04 -0500 (Thu, 09 Feb 2012)
New Revision: 38544
Modified:
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/core/console/UserModel.java
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/OpenShiftUIActivator.java
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/viewer/OpenShiftExpressConsoleContentProvider.java
Log:
Additions to usermodel class to organize stuff in a nice api
Modified: trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/core/console/UserModel.java
===================================================================
--- trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/core/console/UserModel.java 2012-02-09 11:54:01 UTC (rev 38543)
+++ trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/core/console/UserModel.java 2012-02-09 11:59:04 UTC (rev 38544)
@@ -11,15 +11,20 @@
package org.jboss.tools.openshift.express.internal.core.console;
import java.io.IOException;
-import java.util.Arrays;
import java.util.Collection;
import java.util.HashMap;
+import org.jboss.tools.common.ui.preferencevalue.StringPreferenceValue;
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;
+import org.jboss.tools.openshift.express.internal.ui.utils.SecurePasswordStore;
+import org.jboss.tools.openshift.express.internal.ui.utils.SecurePasswordStoreException;
import com.openshift.express.client.IUser;
import com.openshift.express.client.OpenShiftException;
import com.openshift.express.client.User;
+import com.openshift.express.client.configuration.OpenShiftConfiguration;
public class UserModel {
private static UserModel model;
@@ -62,6 +67,10 @@
return recentUser;
}
+ public void setRecentUser(IUser user) {
+ this.recentUser = user;
+ }
+
public IUser findUser(String username) {
try {
for( int i = 0; i < allUsers.size(); i++ ) {
@@ -80,13 +89,107 @@
return rets;
}
+ /**
+ * Load the user list from preferences and secure storage
+ */
public void load() {
// TODO
}
+ /**
+ * Save the user list to preferences and secure storage
+ */
public void save() {
// TODO
// save the passwords in secure storage, save the username list somewhere else
}
+ private static final String RHLOGIN_PREFS_KEY = "org.jboss.tools.openshift.express.internal.ui.wizard.CredentialsWizardModel_RHLOGIN";
+
+ /**
+ * Get the username stored in preferences as most recently used
+ * @return
+ */
+ public String getDefaultUsername() {
+ StringPreferenceValue pref = new StringPreferenceValue(RHLOGIN_PREFS_KEY, OpenShiftUIActivator.PLUGIN_ID);
+ String rhLogin = null;
+ rhLogin = pref.get();
+ if (rhLogin == null || rhLogin.length() == 0) {
+ String configuredUsername = null;
+ try {
+ configuredUsername = new OpenShiftConfiguration().getRhlogin();
+ } catch (Exception e) {
+ // do nothing
+ }
+ rhLogin = configuredUsername;
+ }
+ return rhLogin;
+ }
+
+ /*
+ * Return true if the value is updated, false otherwise
+ */
+ public boolean setDefaultUsername(String rhLogin) {
+ String prev = getDefaultUsername();
+ StringPreferenceValue preference = new StringPreferenceValue(RHLOGIN_PREFS_KEY, OpenShiftUIActivator.PLUGIN_ID);
+ if (rhLogin != null && !rhLogin.equals(prev)) {
+ preference.store(rhLogin);
+ return true;
+ }
+ return false;
+ }
+
+ /*
+ * Return a password from secure storage, or
+ * null if platform not found, or password not stored
+ */
+ public String getPasswordFromSecureStorage(final String rhLogin) {
+ SecurePasswordStore store = getSecureStore(rhLogin);
+ if( store != null && rhLogin != null && !rhLogin.isEmpty() ) {
+ try {
+ return store.getPassword();
+ } catch (SecurePasswordStoreException e) {
+ Logger.error("Failed to retrieve OpenShift user's password from Secured Store", e);
+ }
+ }
+ return null;
+ }
+
+ public void setPasswordInSecureStorage(final String rhLogin, String password) {
+ SecurePasswordStore store = getSecureStore(rhLogin);
+ if( store != null && rhLogin != null && !rhLogin.isEmpty() ) {
+ try {
+ store.setPassword(password);
+ } catch (SecurePasswordStoreException e) {
+ Logger.error(e.getMessage(), e);
+ }
+ }
+ }
+
+
+ private SecurePasswordStore getSecureStore(final String rhLogin) {
+ return getSecureStore(initLibraServer(), rhLogin);
+ }
+
+ /*
+ * Return a secure store or null if platform is not found
+ */
+ private SecurePasswordStore getSecureStore(final String platform, final String username) {
+ if( platform == null )
+ return null;
+ final OpenShiftPasswordStorageKey key = new OpenShiftPasswordStorageKey(platform, username);
+ SecurePasswordStore store = new SecurePasswordStore(key);
+ return store;
+ }
+
+ private String initLibraServer() {
+ try {
+ return new OpenShiftConfiguration().getLibraServer();
+ } catch (Exception e) {
+ Logger.error("Failed to load OpenShift configuration from client library", e);
+ }
+ return null;
+ }
+
+
}
Modified: trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/OpenShiftUIActivator.java
===================================================================
--- trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/OpenShiftUIActivator.java 2012-02-09 11:54:01 UTC (rev 38543)
+++ trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/OpenShiftUIActivator.java 2012-02-09 11:59:04 UTC (rev 38544)
@@ -12,6 +12,7 @@
import org.eclipse.osgi.util.NLS;
import org.eclipse.swt.graphics.Image;
import org.eclipse.ui.plugin.AbstractUIPlugin;
+import org.jboss.tools.openshift.express.internal.core.console.UserModel;
import org.osgi.framework.BundleContext;
import com.openshift.express.client.IUser;
@@ -29,9 +30,6 @@
// The shared instance
private static OpenShiftUIActivator plugin;
- /** The user connected on OpenShift. */
- private IUser user = null;
-
/**
* The constructor
*/
@@ -96,16 +94,27 @@
}
+ /**
+ * Create a new user and add it to the model
+ * @param username
+ * @param password
+ * @return
+ * @throws OpenShiftException
+ * @throws IOException
+ */
public IUser createUser(String username, String password) throws OpenShiftException, IOException {
- this.user = new User(username, password, PLUGIN_ID + " " + getBundle().getVersion());
- return user;
+ IUser u = UserModel.getDefault().createUser(username, password);
+ UserModel.getDefault().addUser(u);
+ return u;
}
/**
+ * Get the most recently created or used user
+ *
* @return the user
*/
public final IUser getUser() {
- return user;
+ return UserModel.getDefault().getRecentUser();
}
/**
Modified: trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/viewer/OpenShiftExpressConsoleContentProvider.java
===================================================================
--- trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/viewer/OpenShiftExpressConsoleContentProvider.java 2012-02-09 11:54:01 UTC (rev 38543)
+++ trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/viewer/OpenShiftExpressConsoleContentProvider.java 2012-02-09 11:59:04 UTC (rev 38544)
@@ -10,6 +10,7 @@
import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.jface.viewers.ITreeContentProvider;
import org.eclipse.jface.viewers.Viewer;
+import org.jboss.tools.openshift.express.internal.core.console.UserModel;
import org.jboss.tools.openshift.express.internal.ui.utils.Logger;
import com.openshift.express.client.IApplication;
@@ -31,8 +32,12 @@
@Override
public Object[] getElements(final Object parentElement) {
if(parentElement instanceof IWorkspaceRoot) {
- return new Object[0];
+ return UserModel.getDefault().getUsers();
}
+ if( parentElement instanceof UserModel ) {
+ return ((UserModel)parentElement).getUsers();
+ }
+
final ArrayBlockingQueue<Object[]> queue = new ArrayBlockingQueue<Object[]>(1);
try {
Job job = new Job("Loading OpenShift Express User information...") {
14 years, 2 months
JBoss Tools SVN: r38543 - trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard.
by jbosstools-commits@lists.jboss.org
Author: xcoulon
Date: 2012-02-09 06:54:01 -0500 (Thu, 09 Feb 2012)
New Revision: 38543
Modified:
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/CredentialsWizardPage.java
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/CredentialsWizardPageModel.java
Log:
FIXED - openshift should provide a "remember password" option
https://issues.jboss.org/browse/JBIDE-10693
Modified: trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/CredentialsWizardPage.java
===================================================================
--- trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/CredentialsWizardPage.java 2012-02-09 11:11:41 UTC (rev 38542)
+++ trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/CredentialsWizardPage.java 2012-02-09 11:54:01 UTC (rev 38543)
@@ -100,10 +100,16 @@
ControlDecorationSupport.create(credentialsStatusValidator, SWT.LEFT | SWT.TOP);
new Label(container, SWT.NONE); // filler to align the checkbox under the text fields
- Button rememberMeCheckBox = new Button(container, SWT.CHECK);
- rememberMeCheckBox.setText("Save password (could trigger secure storage login)");
- GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false).applyTo(rememberMeCheckBox);
+ Button rememberPasswordCheckBox = new Button(container, SWT.CHECK);
+ rememberPasswordCheckBox.setText("Save password (could trigger secure storage login)");
+ GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false).applyTo(rememberPasswordCheckBox);
+ final IObservableValue rememberPasswordModelObservable = BeanProperties.value(CredentialsWizardPageModel.PROPERTY_REMEMBER_PASSWORD)
+ .observe(pageModel);
+ final ISWTObservableValue rememberPasswordCheckBoxObservable = WidgetProperties.selection().observe(rememberPasswordCheckBox);
+ dbc.bindValue(rememberPasswordCheckBoxObservable, rememberPasswordModelObservable);
+
+
Link signupLink = new Link(container, SWT.WRAP);
signupLink.setText("If you don't have an account on OpenShift, please sign up <a>here</a>.");
GridDataFactory.fillDefaults().align(SWT.LEFT, SWT.CENTER).span(2, 1).hint(SWT.DEFAULT, 30).applyTo(signupLink);
Modified: trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/CredentialsWizardPageModel.java
===================================================================
--- trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/CredentialsWizardPageModel.java 2012-02-09 11:11:41 UTC (rev 38542)
+++ trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/CredentialsWizardPageModel.java 2012-02-09 11:54:01 UTC (rev 38543)
@@ -38,9 +38,11 @@
public static final String PROPERTY_RHLOGIN = "rhLogin";
public static final String PROPERTY_PASSWORD = "password";
public static final String PROPERTY_CREDENTIALS_STATUS = "credentialsStatus";
+ public static final String PROPERTY_REMEMBER_PASSWORD = "rememberPassword";
private String rhLogin;
private String password;
+ private boolean rememberPassword;
private IStatus credentialsStatus;
private StringPreferenceValue rhLoginPreferenceValue;
private final String libraServer;
@@ -52,7 +54,7 @@
this.libraServer = initLibraServer();
this.rhLogin = initRhLogin();
initSecureStore(libraServer, rhLogin);
- this.password = initPassword();
+ initPassword();
resetCredentialsStatus();
}
@@ -65,12 +67,13 @@
return null;
}
- private SecurePasswordStore initSecureStore(final String platform, final String username) {
+ private void initSecureStore(final String platform, final String username) {
final OpenShiftPasswordStorageKey key = new OpenShiftPasswordStorageKey(platform, username);
- store = new SecurePasswordStore(key);
- return store;
+ if (key != null) {
+ this.store = new SecurePasswordStore(key);
+ }
}
-
+
protected String initRhLogin() {
String rhLogin = null;
rhLogin = rhLoginPreferenceValue.get();
@@ -80,24 +83,36 @@
return rhLogin;
}
- protected String initPassword() {
- if (libraServer != null && rhLogin != null && !rhLogin.isEmpty() && store!= null) {
+ protected void initPassword() {
+ if (libraServer != null && rhLogin != null && !rhLogin.isEmpty() && store != null) {
try {
- return store.getPassword();
+ this.password = store.getPassword();
+ setRememberPassword(this.password != null && !this.password.isEmpty());
} catch (SecurePasswordStoreException e) {
Logger.error("Failed to retrieve OpenShift user's password from Secured Store", e);
}
}
- return null;
}
private void storePassword(String password) {
try {
- store.setPassword(password);
+ if (store != null) {
+ store.setPassword(password);
+ }
} catch (SecurePasswordStoreException e) {
Logger.error(e.getMessage(), e);
}
}
+
+ private void erasePasswordStore() {
+ try {
+ if (store != null) {
+ store.remove();
+ }
+ } catch (SecurePasswordStoreException e) {
+ Logger.error(e.getMessage(), e);
+ }
+ }
protected String getUserConfiguration() {
String configuredUsername = null;
@@ -132,6 +147,21 @@
}
}
+ /**
+ * @return the rememberPassword
+ */
+ public boolean isRememberPassword() {
+ return rememberPassword;
+ }
+
+ /**
+ * @param rememberPassword
+ * the rememberPassword to set
+ */
+ public void setRememberPassword(boolean rememberPassword) {
+ firePropertyChange(PROPERTY_REMEMBER_PASSWORD, this.rememberPassword, this.rememberPassword = rememberPassword);
+ }
+
private void resetCredentialsStatus() {
setCredentialsStatus(null);
}
@@ -159,8 +189,10 @@
// reset without notifying
// this.credentialsValidity = null;
IUser user = OpenShiftUIActivator.getDefault().createUser(getRhLogin(), getPassword());
- if (user.isValid()) {
+ if (user.isValid() && rememberPassword) {
storePassword(password);
+ } else if(user.isValid() && !rememberPassword) {
+ erasePasswordStore();
}
} catch (NotFoundOpenShiftException e) {
// valid user without domain
@@ -174,4 +206,5 @@
setCredentialsStatus(status);
return status;
}
+
}
14 years, 2 months
JBoss Tools SVN: r38542 - in trunk/openshift/plugins/org.jboss.tools.openshift.express.ui: src/org/jboss/tools/openshift/express/internal/ui/util and 2 other directories.
by jbosstools-commits@lists.jboss.org
Author: xcoulon
Date: 2012-02-09 06:11:41 -0500 (Thu, 09 Feb 2012)
New Revision: 38542
Added:
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/utils/OpenShiftPasswordStorageKey.java
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/utils/SecurePasswordStore.java
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/utils/SecurePasswordStoreException.java
Removed:
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/util/OpenShiftPasswordStorageKey.java
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/util/SecurePasswordStore.java
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/util/SecurePasswordStoreException.java
Modified:
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/plugin.xml
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ApplicationConfigurationWizardPage.java
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/CredentialsWizardPage.java
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/CredentialsWizardPageModel.java
Log:
OPEN - issue JBIDE-10528: Improve OpenShift UI
https://issues.jboss.org/browse/JBIDE-10528
Modified: trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/plugin.xml
===================================================================
--- trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/plugin.xml 2012-02-09 10:35:29 UTC (rev 38541)
+++ trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/plugin.xml 2012-02-09 11:11:41 UTC (rev 38542)
@@ -14,7 +14,7 @@
</category>
<wizard
category="org.jboss.ide.eclipse.as.openshift.express.ui.wizard.category"
- class="org.jboss.tools.openshift.express.internal.ui.wizard.CreateNewApplicationWizard"
+ class="org.jboss.tools.openshift.express.internal.ui.wizard.OpenShiftExpressApplicationWizard"
icon="icons/openshift-logo-white-icon.png"
id="org.jboss.ide.eclipse.as.openshift.express.ui.wizard.createNewApplicationWizard"
name="OpenShift Express Application">
Deleted: trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/util/OpenShiftPasswordStorageKey.java
===================================================================
--- trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/util/OpenShiftPasswordStorageKey.java 2012-02-09 10:35:29 UTC (rev 38541)
+++ trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/util/OpenShiftPasswordStorageKey.java 2012-02-09 11:11:41 UTC (rev 38542)
@@ -1,54 +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.openshift.express.internal.ui.util;
-
-import org.jboss.tools.openshift.express.internal.ui.OpenShiftUIActivator;
-import org.jboss.tools.openshift.express.internal.ui.util.SecurePasswordStore.IStorageKey;
-
-
-/**
- * Implements a key to be used to store values in the preferences store.
- *
- * @author Andre Dietisheim
- *
- */
-public class OpenShiftPasswordStorageKey implements IStorageKey {
-
- private static final char SEPARATOR = '/';
-
- private static final String PREFERNCES_BASEKEY = OpenShiftUIActivator.PLUGIN_ID.replace('.', SEPARATOR);
- private String platform;
- private String userName;
-
- public OpenShiftPasswordStorageKey(String platform, String userName) {
- this.userName = userName;
- this.platform = userName;
- }
-
- @Override
- public String getKey() {
- return new StringBuilder(PREFERNCES_BASEKEY)
- .append(platform)
- .append(SEPARATOR)
- .append(userName)
- .toString();
- }
-
- @Override
- public boolean equals(IStorageKey key) {
- if (!key.getClass().isAssignableFrom(OpenShiftPasswordStorageKey.class)) {
- return false;
- }
- OpenShiftPasswordStorageKey deltaCloudKey = (OpenShiftPasswordStorageKey) key;
- return userName.equals(deltaCloudKey.userName)
- && platform.equals(deltaCloudKey.platform);
- }
-}
Deleted: trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/util/SecurePasswordStore.java
===================================================================
--- trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/util/SecurePasswordStore.java 2012-02-09 10:35:29 UTC (rev 38541)
+++ trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/util/SecurePasswordStore.java 2012-02-09 11:11:41 UTC (rev 38542)
@@ -1,98 +0,0 @@
-package org.jboss.tools.openshift.express.internal.ui.util;
-
-import java.io.UnsupportedEncodingException;
-import java.net.URLEncoder;
-
-import org.eclipse.equinox.security.storage.EncodingUtils;
-import org.eclipse.equinox.security.storage.ISecurePreferences;
-import org.eclipse.equinox.security.storage.SecurePreferencesFactory;
-import org.eclipse.equinox.security.storage.StorageException;
-
-/**
- * @author Andre Dietisheim
- *
- */
-public class SecurePasswordStore {
-
- private static final String ENCODING = "UTF-8";
-
- public static interface IStorageKey {
- public String getKey();
-
- public boolean equals(IStorageKey key);
- }
-
- private String password;
- private IStorageKey storageKey;
-
- public SecurePasswordStore(IStorageKey key) {
- this.storageKey = key;
- }
-
- public String getPassword() throws SecurePasswordStoreException {
- try {
- return this.password = getFromPreferences(storageKey);
- } catch (Exception e) {
- throw new SecurePasswordStoreException("Could get password", e);
- }
- }
-
- public void setPassword(String password) throws SecurePasswordStoreException {
- update(storageKey, password);
- }
-
- private void update(IStorageKey key, String password) throws SecurePasswordStoreException {
- if (!storageKey.equals(key) || isPasswordChanged(password)) {
- storeInPreferences(this.password = password, this.storageKey = key);
- }
- }
-
- private boolean isPasswordChanged(String password) {
- if (this.password == null && password == null) {
- return false;
- } else {
- return (this.password == null && password != null) || (this.password != null && password == null)
- || !password.equals(this.password);
- }
- }
-
- public void remove() throws SecurePasswordStoreException {
- try {
- ISecurePreferences node = getNode(storageKey);
- if (node == null) {
- throw new SecurePasswordStoreException("Could not remove password");
- }
- node.clear();
- } catch (Exception e) {
- throw new SecurePasswordStoreException("Could not remove password", e);
- }
- }
-
- private String getFromPreferences(IStorageKey key) throws StorageException, UnsupportedEncodingException {
- ISecurePreferences node = getNode(key);
- String password = node.get("password", null); //$NON-NLS-1$
- if (password == null) {
- return null;
- }
- return new String(EncodingUtils.decodeBase64(password));
- }
-
- private void storeInPreferences(String password, IStorageKey key) throws SecurePasswordStoreException {
- try {
- ISecurePreferences node = getNode(key);
- node.put("password", EncodingUtils.encodeBase64(password.getBytes()), true /* encrypt */); //$NON-NLS-1$
- } catch (Exception e) {
- throw new SecurePasswordStoreException("Could not store password", e);
- }
- }
-
- private ISecurePreferences getNode(IStorageKey key) throws UnsupportedEncodingException {
- if (key == null) {
- return null;
- }
-
- ISecurePreferences root = SecurePreferencesFactory.getDefault();
- String keyString = URLEncoder.encode(key.getKey(), ENCODING);
- return root.node(keyString);
- }
-}
Deleted: trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/util/SecurePasswordStoreException.java
===================================================================
--- trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/util/SecurePasswordStoreException.java 2012-02-09 10:35:29 UTC (rev 38541)
+++ trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/util/SecurePasswordStoreException.java 2012-02-09 11:11:41 UTC (rev 38542)
@@ -1,33 +0,0 @@
-/**
- *
- */
-package org.jboss.tools.openshift.express.internal.ui.util;
-
-/**
- * @author Xavier Coulon
- *
- */
-public class SecurePasswordStoreException extends Exception {
-
- /** generated serialVersionUID. */
- private static final long serialVersionUID = -1732042851833545771L;
-
- /**
- * Full constructor
- * @param message the message to print
- * @param cause the underlying cause
- */
- public SecurePasswordStoreException(String message, Throwable cause) {
- super(message, cause);
- }
-
- /**
- * Full constructor
- * @param message the message to print
- */
- public SecurePasswordStoreException(String message) {
- super(message);
- }
-
-
-}
Copied: trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/utils/OpenShiftPasswordStorageKey.java (from rev 38538, trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/util/OpenShiftPasswordStorageKey.java)
===================================================================
--- trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/utils/OpenShiftPasswordStorageKey.java (rev 0)
+++ trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/utils/OpenShiftPasswordStorageKey.java 2012-02-09 11:11:41 UTC (rev 38542)
@@ -0,0 +1,54 @@
+/*******************************************************************************
+ * 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.openshift.express.internal.ui.utils;
+
+import org.jboss.tools.openshift.express.internal.ui.OpenShiftUIActivator;
+import org.jboss.tools.openshift.express.internal.ui.utils.SecurePasswordStore.IStorageKey;
+
+
+/**
+ * Implements a key to be used to store values in the preferences store.
+ *
+ * @author Andre Dietisheim
+ *
+ */
+public class OpenShiftPasswordStorageKey implements IStorageKey {
+
+ private static final char SEPARATOR = '/';
+
+ private static final String PREFERNCES_BASEKEY = OpenShiftUIActivator.PLUGIN_ID.replace('.', SEPARATOR);
+ private String platform;
+ private String userName;
+
+ public OpenShiftPasswordStorageKey(String platform, String userName) {
+ this.userName = userName;
+ this.platform = userName;
+ }
+
+ @Override
+ public String getKey() {
+ return new StringBuilder(PREFERNCES_BASEKEY)
+ .append(platform)
+ .append(SEPARATOR)
+ .append(userName)
+ .toString();
+ }
+
+ @Override
+ public boolean equals(IStorageKey key) {
+ if (!key.getClass().isAssignableFrom(OpenShiftPasswordStorageKey.class)) {
+ return false;
+ }
+ OpenShiftPasswordStorageKey deltaCloudKey = (OpenShiftPasswordStorageKey) key;
+ return userName.equals(deltaCloudKey.userName)
+ && platform.equals(deltaCloudKey.platform);
+ }
+}
Property changes on: trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/utils/OpenShiftPasswordStorageKey.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/utils/SecurePasswordStore.java (from rev 38538, trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/util/SecurePasswordStore.java)
===================================================================
--- trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/utils/SecurePasswordStore.java (rev 0)
+++ trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/utils/SecurePasswordStore.java 2012-02-09 11:11:41 UTC (rev 38542)
@@ -0,0 +1,98 @@
+package org.jboss.tools.openshift.express.internal.ui.utils;
+
+import java.io.UnsupportedEncodingException;
+import java.net.URLEncoder;
+
+import org.eclipse.equinox.security.storage.EncodingUtils;
+import org.eclipse.equinox.security.storage.ISecurePreferences;
+import org.eclipse.equinox.security.storage.SecurePreferencesFactory;
+import org.eclipse.equinox.security.storage.StorageException;
+
+/**
+ * @author Andre Dietisheim
+ *
+ */
+public class SecurePasswordStore {
+
+ private static final String ENCODING = "UTF-8";
+
+ public static interface IStorageKey {
+ public String getKey();
+
+ public boolean equals(IStorageKey key);
+ }
+
+ private String password;
+ private IStorageKey storageKey;
+
+ public SecurePasswordStore(IStorageKey key) {
+ this.storageKey = key;
+ }
+
+ public String getPassword() throws SecurePasswordStoreException {
+ try {
+ return this.password = getFromPreferences(storageKey);
+ } catch (Exception e) {
+ throw new SecurePasswordStoreException("Could get password", e);
+ }
+ }
+
+ public void setPassword(String password) throws SecurePasswordStoreException {
+ update(storageKey, password);
+ }
+
+ private void update(IStorageKey key, String password) throws SecurePasswordStoreException {
+ if (!storageKey.equals(key) || isPasswordChanged(password)) {
+ storeInPreferences(this.password = password, this.storageKey = key);
+ }
+ }
+
+ private boolean isPasswordChanged(String password) {
+ if (this.password == null && password == null) {
+ return false;
+ } else {
+ return (this.password == null && password != null) || (this.password != null && password == null)
+ || !password.equals(this.password);
+ }
+ }
+
+ public void remove() throws SecurePasswordStoreException {
+ try {
+ ISecurePreferences node = getNode(storageKey);
+ if (node == null) {
+ throw new SecurePasswordStoreException("Could not remove password");
+ }
+ node.clear();
+ } catch (Exception e) {
+ throw new SecurePasswordStoreException("Could not remove password", e);
+ }
+ }
+
+ private String getFromPreferences(IStorageKey key) throws StorageException, UnsupportedEncodingException {
+ ISecurePreferences node = getNode(key);
+ String password = node.get("password", null); //$NON-NLS-1$
+ if (password == null) {
+ return null;
+ }
+ return new String(EncodingUtils.decodeBase64(password));
+ }
+
+ private void storeInPreferences(String password, IStorageKey key) throws SecurePasswordStoreException {
+ try {
+ ISecurePreferences node = getNode(key);
+ node.put("password", EncodingUtils.encodeBase64(password.getBytes()), true /* encrypt */); //$NON-NLS-1$
+ } catch (Exception e) {
+ throw new SecurePasswordStoreException("Could not store password", e);
+ }
+ }
+
+ private ISecurePreferences getNode(IStorageKey key) throws UnsupportedEncodingException {
+ if (key == null) {
+ return null;
+ }
+
+ ISecurePreferences root = SecurePreferencesFactory.getDefault();
+ String keyString = URLEncoder.encode(key.getKey(), ENCODING);
+ return root.node(keyString);
+ }
+}
Property changes on: trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/utils/SecurePasswordStore.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/utils/SecurePasswordStoreException.java (from rev 38538, trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/util/SecurePasswordStoreException.java)
===================================================================
--- trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/utils/SecurePasswordStoreException.java (rev 0)
+++ trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/utils/SecurePasswordStoreException.java 2012-02-09 11:11:41 UTC (rev 38542)
@@ -0,0 +1,33 @@
+/**
+ *
+ */
+package org.jboss.tools.openshift.express.internal.ui.utils;
+
+/**
+ * @author Xavier Coulon
+ *
+ */
+public class SecurePasswordStoreException extends Exception {
+
+ /** generated serialVersionUID. */
+ private static final long serialVersionUID = -1732042851833545771L;
+
+ /**
+ * Full constructor
+ * @param message the message to print
+ * @param cause the underlying cause
+ */
+ public SecurePasswordStoreException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ /**
+ * Full constructor
+ * @param message the message to print
+ */
+ public SecurePasswordStoreException(String message) {
+ super(message);
+ }
+
+
+}
Property changes on: trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/utils/SecurePasswordStoreException.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Modified: trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ApplicationConfigurationWizardPage.java
===================================================================
--- trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ApplicationConfigurationWizardPage.java 2012-02-09 10:35:29 UTC (rev 38541)
+++ trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ApplicationConfigurationWizardPage.java 2012-02-09 11:11:41 UTC (rev 38542)
@@ -136,7 +136,9 @@
final ISWTObservableValue existingAppNameTextObservable = WidgetProperties.text(SWT.Modify).observe(
existingAppNameText);
ValueBindingBuilder.bind(existingAppNameTextObservable).to(existingAppNameModelObservable).in(dbc);
- existingAppNameText.setText(pageModel.getExistingApplicationName());
+ if (pageModel.getExistingApplicationName() != null) {
+ existingAppNameText.setText(pageModel.getExistingApplicationName());
+ }
// enable the app name text when the model state is set to 'use existing app'
ValueBindingBuilder.bind(WidgetProperties.enabled().observe(existingAppNameText))
.notUpdating(useExistingAppObservable).in(dbc);
@@ -175,12 +177,11 @@
final IObservableValue existingAppValidityObservable = BeanProperties.value(
ApplicationConfigurationWizardPageModel.PROPERTY_EXISTING_APPLICATION_NAME).observe(pageModel);
-
final ApplicationToSelectNameValidator existingProjectValidator = new ApplicationToSelectNameValidator(
existingAppValidityObservable, existingAppNameTextObservable, existingAppNameModelObservable);
dbc.addValidationStatusProvider(existingProjectValidator);
ControlDecorationSupport.create(existingProjectValidator, SWT.LEFT | SWT.TOP);
-
+
return existingAppSelectionGroup;
}
@@ -257,11 +258,12 @@
final ApplicationToCreateInputValidator applicationInputValidator = new ApplicationToCreateInputValidator(
applicationNameTextObservable, cartridgesComboObservable);
dbc.addValidationStatusProvider(applicationInputValidator);
- /*final ApplicationToSelectNameValidator applicationNameValidator = new ApplicationToSelectNameValidator(us
- applicationNameStatusObservable, applicationNameTextObservable);
- dbc.addValidationStatusProvider(applicationNameValidator);
- ControlDecorationSupport.create(applicationNameValidator, SWT.LEFT | SWT.TOP);
- */
+ /*
+ * final ApplicationToSelectNameValidator applicationNameValidator = new ApplicationToSelectNameValidator(us
+ * applicationNameStatusObservable, applicationNameTextObservable);
+ * dbc.addValidationStatusProvider(applicationNameValidator);
+ * ControlDecorationSupport.create(applicationNameValidator, SWT.LEFT | SWT.TOP);
+ */
// embeddable cartridges
Group cartridgesGroup = new Group(container, SWT.NONE);
cartridgesGroup.setText("Embeddable Cartridges");
@@ -626,14 +628,15 @@
class ApplicationToSelectNameValidator extends MultiValidator {
- private final IObservableValue applicationNameStatusObservable;
+ private final IObservableValue existingAppValidityObservable;
+ private final ISWTObservableValue existingAppNameTextObservable;
+ private final IObservableValue existingAppNameModelObservable;
- private final ISWTObservableValue applicationNameTextObservable;
-
- public ApplicationToSelectNameValidator(IObservableValue applicationNameStatusObservable,
- ISWTObservableValue applicationNameTextObservable, IObservableValue existingAppNameModelObservable) {
- this.applicationNameStatusObservable = applicationNameStatusObservable;
- this.applicationNameTextObservable = applicationNameTextObservable;
+ public ApplicationToSelectNameValidator(IObservableValue existingAppValidityObservable,
+ ISWTObservableValue existingAppNameTextObservable, IObservableValue existingAppNameModelObservable) {
+ this.existingAppValidityObservable = existingAppValidityObservable;
+ this.existingAppNameTextObservable = existingAppNameTextObservable;
+ this.existingAppNameModelObservable = existingAppNameModelObservable;
}
@Override
@@ -652,7 +655,7 @@
@Override
public IObservableList getTargets() {
WritableList targets = new WritableList();
- targets.add(applicationNameTextObservable);
+ targets.add(existingAppNameTextObservable);
return targets;
}
Modified: trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/CredentialsWizardPage.java
===================================================================
--- trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/CredentialsWizardPage.java 2012-02-09 10:35:29 UTC (rev 38541)
+++ trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/CredentialsWizardPage.java 2012-02-09 11:11:41 UTC (rev 38542)
@@ -35,6 +35,7 @@
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Link;
@@ -69,15 +70,6 @@
protected void doCreateControls(Composite container, DataBindingContext dbc) {
GridLayoutFactory.fillDefaults().numColumns(2).margins(10, 10).applyTo(container);
- // This wizard page status and navigation controls are bound to the credentials validity status:
- // 1 - No error message is displayed if the credentials validity status is "OK"
- // 2 - when the user changes the 'rhLogin' or 'password' field values, the credentials validity status is set to
- // "Cancel", thus no error message should appear on the wizard page
- // 3 - when the 'rhLogin' and the 'password' fields are not null/empty, the 'next' control button is enabled
- // 4 - if the credentials validation fails (ie, invalid credentials), the 'next' button is disabled and an error
- // message is displayed at the top of the wizard page until the 'rhLogin' and/or the 'password' field values
- // have been changed. Then back to step 2.
-
Label rhLoginLabel = new Label(container, SWT.NONE);
rhLoginLabel.setText("&Username");
GridDataFactory.fillDefaults().align(SWT.LEFT, SWT.CENTER).applyTo(rhLoginLabel);
@@ -107,6 +99,11 @@
dbc.addValidationStatusProvider(credentialsStatusValidator);
ControlDecorationSupport.create(credentialsStatusValidator, SWT.LEFT | SWT.TOP);
+ new Label(container, SWT.NONE); // filler to align the checkbox under the text fields
+ Button rememberMeCheckBox = new Button(container, SWT.CHECK);
+ rememberMeCheckBox.setText("Save password (could trigger secure storage login)");
+ GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false).applyTo(rememberMeCheckBox);
+
Link signupLink = new Link(container, SWT.WRAP);
signupLink.setText("If you don't have an account on OpenShift, please sign up <a>here</a>.");
GridDataFactory.fillDefaults().align(SWT.LEFT, SWT.CENTER).span(2, 1).hint(SWT.DEFAULT, 30).applyTo(signupLink);
Modified: trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/CredentialsWizardPageModel.java
===================================================================
--- trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/CredentialsWizardPageModel.java 2012-02-09 10:35:29 UTC (rev 38541)
+++ trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/CredentialsWizardPageModel.java 2012-02-09 11:11:41 UTC (rev 38542)
@@ -16,10 +16,10 @@
import org.jboss.tools.common.ui.databinding.ObservableUIPojo;
import org.jboss.tools.common.ui.preferencevalue.StringPreferenceValue;
import org.jboss.tools.openshift.express.internal.ui.OpenShiftUIActivator;
-import org.jboss.tools.openshift.express.internal.ui.util.OpenShiftPasswordStorageKey;
-import org.jboss.tools.openshift.express.internal.ui.util.SecurePasswordStore;
-import org.jboss.tools.openshift.express.internal.ui.util.SecurePasswordStoreException;
import org.jboss.tools.openshift.express.internal.ui.utils.Logger;
+import org.jboss.tools.openshift.express.internal.ui.utils.OpenShiftPasswordStorageKey;
+import org.jboss.tools.openshift.express.internal.ui.utils.SecurePasswordStore;
+import org.jboss.tools.openshift.express.internal.ui.utils.SecurePasswordStoreException;
import com.openshift.express.client.IUser;
import com.openshift.express.client.NotFoundOpenShiftException;
14 years, 2 months
JBoss Tools SVN: r38541 - trunk/maven/tests/org.jboss.tools.maven.ui.bot.test/src/org/jboss/tools/maven/ui/bot/test.
by jbosstools-commits@lists.jboss.org
Author: rawagner
Date: 2012-02-09 05:35:29 -0500 (Thu, 09 Feb 2012)
New Revision: 38541
Modified:
trunk/maven/tests/org.jboss.tools.maven.ui.bot.test/src/org/jboss/tools/maven/ui/bot/test/Configurators.java
trunk/maven/tests/org.jboss.tools.maven.ui.bot.test/src/org/jboss/tools/maven/ui/bot/test/MavenProfileSelectionTest.java
Log:
-
Modified: trunk/maven/tests/org.jboss.tools.maven.ui.bot.test/src/org/jboss/tools/maven/ui/bot/test/Configurators.java
===================================================================
--- trunk/maven/tests/org.jboss.tools.maven.ui.bot.test/src/org/jboss/tools/maven/ui/bot/test/Configurators.java 2012-02-09 10:32:18 UTC (rev 38540)
+++ trunk/maven/tests/org.jboss.tools.maven.ui.bot.test/src/org/jboss/tools/maven/ui/bot/test/Configurators.java 2012-02-09 10:35:29 UTC (rev 38541)
@@ -153,9 +153,15 @@
botUtil.waitForAll();
assertTrue("Web project doesn't have maven nature",Utils.isMavenProject(projectName));
updateConf(projectName);
- assertFalse("Project "+projectName+" have "+JSF_NATURE+" nature.",Utils.hasNature(projectName, JSF_NATURE));
- assertFalse("Project "+projectName+" have "+JAXRS_NATURE+" nature.",Utils.hasNature(projectName, JAXRS_NATURE));
- assertFalse("Project "+projectName+" have "+CDI_NATURE+" nature.",Utils.hasNature(projectName, CDI_NATURE));
+ if(runtime){
+ assertTrue("Project "+projectName+" doesn't have "+JSF_NATURE+" nature.",Utils.hasNature(projectName, JSF_NATURE));
+ assertTrue("Project "+projectName+" doesn't have "+JAXRS_NATURE+" nature.",Utils.hasNature(projectName, JAXRS_NATURE));
+ assertTrue("Project "+projectName+" doesn't have "+CDI_NATURE+" nature.",Utils.hasNature(projectName, CDI_NATURE));
+ } else {
+ assertFalse("Project "+projectName+" have "+JSF_NATURE+" nature.",Utils.hasNature(projectName, JSF_NATURE));
+ assertFalse("Project "+projectName+" have "+JAXRS_NATURE+" nature.",Utils.hasNature(projectName, JAXRS_NATURE));
+ assertFalse("Project "+projectName+" have "+CDI_NATURE+" nature.",Utils.hasNature(projectName, CDI_NATURE));
+ }
}
private void createMavenizedEJBProject(String projectName, boolean runtime)throws Exception{
Modified: trunk/maven/tests/org.jboss.tools.maven.ui.bot.test/src/org/jboss/tools/maven/ui/bot/test/MavenProfileSelectionTest.java
===================================================================
--- trunk/maven/tests/org.jboss.tools.maven.ui.bot.test/src/org/jboss/tools/maven/ui/bot/test/MavenProfileSelectionTest.java 2012-02-09 10:32:18 UTC (rev 38540)
+++ trunk/maven/tests/org.jboss.tools.maven.ui.bot.test/src/org/jboss/tools/maven/ui/bot/test/MavenProfileSelectionTest.java 2012-02-09 10:35:29 UTC (rev 38541)
@@ -60,7 +60,6 @@
SWTBot shell = bot.shell("Select Maven profiles").activate().bot();
shell.button("Select All").click();
String selectedProfiles = shell.textWithLabel("Active profiles for simple-jar :").getText();
- System.out.println("+++++++++++++++++++++"+selectedProfiles);
shell.button("OK").click();
testActivatedProfiles(project.getName(), selectedProfiles, false);
14 years, 2 months
JBoss Tools SVN: r38540 - trunk/maven/tests/org.jboss.tools.maven.ui.bot.test/src/org/jboss/tools/maven/ui/bot/test.
by jbosstools-commits@lists.jboss.org
Author: rawagner
Date: 2012-02-09 05:32:18 -0500 (Thu, 09 Feb 2012)
New Revision: 38540
Modified:
trunk/maven/tests/org.jboss.tools.maven.ui.bot.test/src/org/jboss/tools/maven/ui/bot/test/Configurators.java
trunk/maven/tests/org.jboss.tools.maven.ui.bot.test/src/org/jboss/tools/maven/ui/bot/test/CreateMavenizedJSFProjectTest.java
Log:
longer timeout for JSF project
Modified: trunk/maven/tests/org.jboss.tools.maven.ui.bot.test/src/org/jboss/tools/maven/ui/bot/test/Configurators.java
===================================================================
--- trunk/maven/tests/org.jboss.tools.maven.ui.bot.test/src/org/jboss/tools/maven/ui/bot/test/Configurators.java 2012-02-09 10:30:57 UTC (rev 38539)
+++ trunk/maven/tests/org.jboss.tools.maven.ui.bot.test/src/org/jboss/tools/maven/ui/bot/test/Configurators.java 2012-02-09 10:32:18 UTC (rev 38540)
@@ -263,11 +263,11 @@
}
private void addServlet(String projectName, String servletName, String servletClass, String load) throws Exception{
- IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);
+ IProject facade = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
DocumentBuilder docBuilder = factory.newDocumentBuilder();
- Document docPom = docBuilder.parse(project.getProject().getFile("web.xml").getContents());
+ Document docPom = docBuilder.parse(facade.getProject().getFile("web.xml").getContents());
Element servletElement = docPom.createElement("servlet");
Element servletNameElement = docPom.createElement("servlet-name");
Element servletClassElement = docPom.createElement("servlet-class");
@@ -288,7 +288,7 @@
StreamResult result = new StreamResult(xmlAsWriter);
DOMSource source = new DOMSource(docPom);
trans.transform(source, result);
- project.getProject().getFile("web.xml").setContents(new ByteArrayInputStream(xmlAsWriter.toString().getBytes("UTF-8")), 0, null);
+ facade.getProject().getFile("web.xml").setContents(new ByteArrayInputStream(xmlAsWriter.toString().getBytes("UTF-8")), 0, null);
botUtil.waitForAll();
updateConf(projectName);
}
Modified: trunk/maven/tests/org.jboss.tools.maven.ui.bot.test/src/org/jboss/tools/maven/ui/bot/test/CreateMavenizedJSFProjectTest.java
===================================================================
--- trunk/maven/tests/org.jboss.tools.maven.ui.bot.test/src/org/jboss/tools/maven/ui/bot/test/CreateMavenizedJSFProjectTest.java 2012-02-09 10:30:57 UTC (rev 38539)
+++ trunk/maven/tests/org.jboss.tools.maven.ui.bot.test/src/org/jboss/tools/maven/ui/bot/test/CreateMavenizedJSFProjectTest.java 2012-02-09 10:32:18 UTC (rev 38540)
@@ -29,6 +29,7 @@
import org.eclipse.swtbot.swt.finder.keyboard.Keystrokes;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem;
import org.jboss.tools.ui.bot.ext.SWTBotExt;
+import org.jboss.tools.ui.bot.ext.SWTUtilExt;
import org.jboss.tools.ui.bot.ext.config.Annotations.Require;
import org.junit.BeforeClass;
import org.junit.Test;
@@ -58,6 +59,7 @@
public static final String JSF_VERSION_2 ="2.0";
protected static SWTWorkbenchBot bot;
+ private SWTUtilExt botUtil = new SWTUtilExt(bot);
@BeforeClass
@@ -134,9 +136,9 @@
shellRuntime = bot.shell("New Server").activate().bot();
shellRuntime.tree().expandNode("JBoss Community").select(server);
shellRuntime.button("Finish").click();
- waitForIdle();
+ botUtil.waitForAll(Long.MAX_VALUE);
shell.button("Finish").click();;
- waitForIdle();
+ botUtil.waitForAll(Long.MAX_VALUE);
}
14 years, 2 months