JBoss Tools SVN: r38539 - 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 05:30:57 -0500 (Thu, 09 Feb 2012)
New Revision: 38539
Added:
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/core/console/UserModel.java
Log:
An initial usermodel class (trying to avoid a clash / merge issue)
Added: 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 (rev 0)
+++ trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/core/console/UserModel.java 2012-02-09 10:30:57 UTC (rev 38539)
@@ -0,0 +1,92 @@
+/*******************************************************************************
+ * 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.io.IOException;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.HashMap;
+
+import org.jboss.tools.openshift.express.internal.ui.OpenShiftUIActivator;
+
+import com.openshift.express.client.IUser;
+import com.openshift.express.client.OpenShiftException;
+import com.openshift.express.client.User;
+
+public class UserModel {
+ private static UserModel model;
+ public static UserModel getDefault() {
+ if( model == null )
+ model = new UserModel();
+ return model;
+ }
+
+
+ /** The most recent user connected on OpenShift. */
+ private IUser recentUser = null;
+ private HashMap<String, IUser> allUsers = new HashMap<String,IUser>();
+
+ /**
+ * Create a user for temporary external use
+ *
+ * @param username
+ * @param password
+ * @return
+ * @throws OpenShiftException
+ * @throws IOException
+ */
+ public IUser createUser(String username, String password) throws OpenShiftException, IOException {
+ IUser u = new User(username, password, OpenShiftUIActivator.PLUGIN_ID + " " +
+ OpenShiftUIActivator.getDefault().getBundle().getVersion());
+ return u;
+ }
+
+ public void addUser(IUser user) {
+ try {
+ allUsers.put(user.getRhlogin(), recentUser);
+ this.recentUser = user;
+ } catch(OpenShiftException ose ) {
+ // TODO
+ }
+ }
+
+ public IUser getRecentUser() {
+ return recentUser;
+ }
+
+ public IUser findUser(String username) {
+ try {
+ for( int i = 0; i < allUsers.size(); i++ ) {
+ if( allUsers.get(i).getUUID().equals(username))
+ return allUsers.get(i);
+ }
+ } catch(OpenShiftException ose) {
+
+ }
+ return null;
+ }
+
+ public IUser[] getUsers() {
+ Collection<IUser> c = allUsers.values();
+ IUser[] rets = (IUser[]) c.toArray(new IUser[c.size()]);
+ return rets;
+ }
+
+ public void load() {
+ // TODO
+ }
+
+ public void save() {
+ // TODO
+ // save the passwords in secure storage, save the username list somewhere else
+ }
+
+}
14 years, 2 months
JBoss Tools SVN: r38538 - in trunk/openshift/plugins/org.jboss.tools.openshift.express.ui: META-INF and 5 other directories.
by jbosstools-commits@lists.jboss.org
Author: xcoulon
Date: 2012-02-09 05:29:54 -0500 (Thu, 09 Feb 2012)
New Revision: 38538
Added:
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/util/
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
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ApplicationSelectionDialog.java
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ApplicationSelectionDialogModel.java
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/OpenShiftExpressApplicationWizardModel.java
Removed:
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/AbstractOpenShiftApplicationWizardModel.java
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ImportExistingApplicationWizard.java
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ImportExistingApplicationWizardModel.java
Modified:
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/META-INF/MANIFEST.MF
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/action/ImportApplicationAction.java
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/ApplicationConfigurationWizardPageModel.java
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ApplicationSelectionWizardPage.java
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ApplicationSelectionWizardPageModel.java
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ApplicationWizardPage.java
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/CreateNewApplicationWizard.java
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/CreateNewApplicationWizardModel.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
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/GitCloningSettingsWizardPage.java
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/GitCloningSettingsWizardPageModel.java
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/IOpenShiftWizardModel.java
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ProjectAndServerAdapterSettingsWizardPage.java
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/appimport/ImportProjectWizard.java
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/appimport/ImportProjectWizardModel.java
Log:
OPEN - issue JBIDE-10528: Improve OpenShift UI
https://issues.jboss.org/browse/JBIDE-10528
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/META-INF/MANIFEST.MF
===================================================================
--- trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/META-INF/MANIFEST.MF 2012-02-09 10:03:21 UTC (rev 38537)
+++ trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/META-INF/MANIFEST.MF 2012-02-09 10:29:54 UTC (rev 38538)
@@ -40,7 +40,8 @@
org.eclipse.ui.forms;bundle-version="3.5.100",
org.eclipse.jface.text;bundle-version="3.7.0",
org.eclipse.ui.views.properties.tabbed;bundle-version="3.5.200",
- org.jboss.ide.eclipse.archives.webtools;bundle-version="2.3.0"
+ org.jboss.ide.eclipse.archives.webtools;bundle-version="2.3.0",
+ org.eclipse.equinox.security;bundle-version="1.1.1"
Bundle-ActivationPolicy: lazy
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Import-Package: org.jboss.tools.common.databinding,
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:03:21 UTC (rev 38537)
+++ trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/plugin.xml 2012-02-09 10:29:54 UTC (rev 38538)
@@ -28,7 +28,7 @@
</category>
<wizard
category="org.jboss.tools.openshift.express.ui.wizard.importCategory"
- class="org.jboss.tools.openshift.express.internal.ui.wizard.ImportExistingApplicationWizard"
+ class="org.jboss.tools.openshift.express.internal.ui.wizard.OpenShiftExpressApplicationWizard"
icon="icons/openshift-logo-white-icon.png"
id="org.jboss.tools.openshift.express.ui.importExistingApplicationWizard"
name="Existing OpenShift Express Application">
Modified: trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/action/ImportApplicationAction.java
===================================================================
--- trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/action/ImportApplicationAction.java 2012-02-09 10:03:21 UTC (rev 38537)
+++ trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/action/ImportApplicationAction.java 2012-02-09 10:29:54 UTC (rev 38538)
@@ -1,15 +1,15 @@
package org.jboss.tools.openshift.express.internal.ui.action;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.jface.viewers.ITreeSelection;
import org.eclipse.jface.wizard.WizardDialog;
import org.eclipse.swt.widgets.Display;
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.EmbedCartridgeWizard;
-import org.jboss.tools.openshift.express.internal.ui.wizard.ImportExistingApplicationWizard;
+import org.jboss.tools.openshift.express.internal.ui.wizard.OpenShiftExpressApplicationWizard;
import com.openshift.express.client.IApplication;
-import com.openshift.express.client.IUser;
public class ImportApplicationAction extends AbstractAction {
@@ -23,8 +23,13 @@
final ITreeSelection treeSelection = (ITreeSelection)selection;
if (selection != null && selection instanceof ITreeSelection && treeSelection.getFirstElement() instanceof IApplication) {
final IApplication application = (IApplication) treeSelection.getFirstElement();
- final IUser user = OpenShiftUIActivator.getDefault().getUser();
- ImportExistingApplicationWizard wizard = new ImportExistingApplicationWizard();
+ //final IUser user = OpenShiftUIActivator.getDefault().getUser();
+ OpenShiftExpressApplicationWizard wizard = new OpenShiftExpressApplicationWizard();
+ wizard.setSelectedApplication(application);
+ final IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(application.getName());
+ if(project.exists()) {
+ wizard.setSelectedProject(project);
+ }
WizardDialog dialog = new WizardDialog(Display.getCurrent().getActiveShell(), wizard);
dialog.create();
dialog.open();
Added: 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 (rev 0)
+++ trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/util/OpenShiftPasswordStorageKey.java 2012-02-09 10:29:54 UTC (rev 38538)
@@ -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.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);
+ }
+}
Property changes on: trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/util/OpenShiftPasswordStorageKey.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/util/SecurePasswordStore.java
===================================================================
--- trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/util/SecurePasswordStore.java (rev 0)
+++ trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/util/SecurePasswordStore.java 2012-02-09 10:29:54 UTC (rev 38538)
@@ -0,0 +1,98 @@
+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);
+ }
+}
Property changes on: trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/util/SecurePasswordStore.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/util/SecurePasswordStoreException.java
===================================================================
--- trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/util/SecurePasswordStoreException.java (rev 0)
+++ trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/util/SecurePasswordStoreException.java 2012-02-09 10:29:54 UTC (rev 38538)
@@ -0,0 +1,33 @@
+/**
+ *
+ */
+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);
+ }
+
+
+}
Property changes on: trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/util/SecurePasswordStoreException.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Deleted: trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/AbstractOpenShiftApplicationWizardModel.java
===================================================================
--- trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/AbstractOpenShiftApplicationWizardModel.java 2012-02-09 10:03:21 UTC (rev 38537)
+++ trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/AbstractOpenShiftApplicationWizardModel.java 2012-02-09 10:29:54 UTC (rev 38538)
@@ -1,327 +0,0 @@
-package org.jboss.tools.openshift.express.internal.ui.wizard;
-
-import java.io.File;
-import java.io.IOException;
-import java.lang.reflect.InvocationTargetException;
-import java.net.URISyntaxException;
-import java.util.HashMap;
-import java.util.List;
-
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.wst.server.core.IRuntime;
-import org.eclipse.wst.server.core.IServerType;
-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.ui.OpenShiftUIActivator;
-import org.jboss.tools.openshift.express.internal.ui.wizard.appimport.ConfigureGitSharedProject;
-import org.jboss.tools.openshift.express.internal.ui.wizard.appimport.ConfigureUnsharedProject;
-import org.jboss.tools.openshift.express.internal.ui.wizard.appimport.ImportNewProject;
-import org.jboss.tools.openshift.express.internal.ui.wizard.appimport.ServerAdapterFactory;
-
-import com.openshift.express.client.IApplication;
-import com.openshift.express.client.ICartridge;
-import com.openshift.express.client.OpenShiftException;
-
-public class AbstractOpenShiftApplicationWizardModel extends ObservableUIPojo implements IOpenShiftWizardModel {
-
- protected HashMap<String, Object> dataModel = new HashMap<String, Object>();
- public AbstractOpenShiftApplicationWizardModel() {
- super();
- // default value(s)
- setNewProject(true);
- setCreateServerAdapter(true);
- setRepositoryPath(DEFAULT_REPOSITORY_PATH);
- setRemoteName(NEW_PROJECT_REMOTE_NAME_DEFAULT);
- setServerType(ServerCore.findServerType("org.jboss.tools.openshift.express.openshift.server.type"));
- setPublicationMode(PUBLISH_SOURCE);
- }
-
-
- /**
- * Imports the project that the user has chosen into the workspace.
- *
- * @param monitor
- * the monitor to report progress to
- * @throws OpenShiftException
- * @throws CoreException
- * @throws InterruptedException
- * @throws URISyntaxException
- * @throws InvocationTargetException
- */
- @Override
- public void importProject(IProgressMonitor monitor) throws OpenShiftException, CoreException, InterruptedException,
- URISyntaxException, InvocationTargetException {
- List<IProject> importedProjects = new ImportNewProject(getProjectName(), getApplication(), getRemoteName(),
- getRepositoryFile()).execute(monitor);
- createServerAdapter(monitor, importedProjects);
- }
-
- /**
- * Enables the user chosen, unshared project to be used on the chosen
- * OpenShift application. Clones the application git repository, copies the
- * configuration files to the user project (in the workspace), shares the
- * user project with git and creates the server adapter.
- *
- * @param monitor
- * the monitor to report progress to
- * @throws URISyntaxException
- * The OpenShift application repository could not be cloned,
- * because the uri it is located at is not a valid git uri
- * @throws OpenShiftException
- *
- * @throws InvocationTargetException
- * The OpenShift application repository could not be cloned, the
- * clone operation failed.
- * @throws InterruptedException
- * The OpenShift application repository could not be cloned, the
- * clone operation was interrupted.
- * @throws IOException
- * The configuration files could not be copied from the git
- * clone to the user project
- * @throws CoreException
- * The user project could not be shared with the git
- */
- @Override
- public void configureUnsharedProject(IProgressMonitor monitor)
- throws OpenShiftException, InvocationTargetException, InterruptedException, IOException, CoreException,
- URISyntaxException {
- List<IProject> importedProjects = new ConfigureUnsharedProject(
- getProjectName()
- , getApplication()
- , getRemoteName()
- , OpenShiftUIActivator.getDefault().getUser())
- .execute(monitor);
- createServerAdapter(monitor, importedProjects);
- }
-
- /**
- * Enables the user chosen, unshared project to be used on the chosen
- * OpenShift application. Clones the application git repository, copies the
- * configuration files to the user project (in the workspace), adds the
- * appication git repo as remote and creates the server adapter.
- *
- * @param monitor
- * the monitor to report progress to
- * @throws URISyntaxException
- * The OpenShift application repository could not be cloned,
- * because the uri it is located at is not a valid git uri
- * @throws OpenShiftException
- *
- * @throws InvocationTargetException
- * The OpenShift application repository could not be cloned, the
- * clone operation failed.
- * @throws InterruptedException
- * The OpenShift application repository could not be cloned, the
- * clone operation was interrupted.
- * @throws IOException
- * The configuration files could not be copied from the git
- * clone to the user project
- * @throws CoreException
- * The user project could not be shared with the git
- */
- @Override
- public void configureGitSharedProject(IProgressMonitor monitor)
- throws OpenShiftException, InvocationTargetException, InterruptedException, IOException, CoreException,
- URISyntaxException {
- List<IProject> importedProjects = new ConfigureGitSharedProject(
- getProjectName()
- , getApplication()
- , getRemoteName()
-// , getUser())
- , OpenShiftUIActivator.getDefault().getUser())
- .execute(monitor);
- createServerAdapter(monitor, importedProjects);
- }
-
- private void createServerAdapter(IProgressMonitor monitor, List<IProject> importedProjects)
- throws OpenShiftException {
- Assert.isTrue(importedProjects.size() > 0);
- IProject project = importedProjects.get(0);
- new ServerAdapterFactory().create(project, this, monitor);
- }
-
- @Override
- public File getRepositoryFile() {
- String repositoryPath = getRepositoryPath();
- if (repositoryPath == null || repositoryPath.length() == 0) {
- return null;
- }
- return new File(repositoryPath, getApplicationName());
- }
-
- @Override
- public Object setProperty(String key, Object value) {
- Object oldVal = dataModel.get(key);
- dataModel.put(key, value);
- firePropertyChange(key, oldVal, value);
- return value;
- }
-
- @Override
- public Object getProperty(String key) {
- return dataModel.get(key);
- }
-
-// @Override
-// public void setUser(IUser user) {
-// setProperty(USER, user);
-// OpenShiftUIActivator.getDefault().setUser(user);
-// }
-
-// @Override
-// public IUser getUser() {
-// return (IUser) getProperty(USER);
-// return OpenShiftUIActivator.getDefault().getUser();
-// }
-
- @Override
- public IApplication getApplication() {
- return (IApplication) getProperty(APPLICATION);
- }
-
- @Override
- public String getApplicationName() {
- String applicationName = null;
- IApplication application = getApplication();
- if (application != null) {
- applicationName = application.getName();
- }
- return applicationName;
- }
-
- @Override
- public ICartridge getApplicationCartridge() {
- ICartridge cartridge = null;
- IApplication application = getApplication();
- if (application != null) {
- cartridge = application.getCartridge();
- }
- return cartridge;
- }
-
- @Override
- public String getApplicationCartridgeName() {
- String cartridgeName = null;
- ICartridge cartridge = getApplicationCartridge();
- if (cartridge != null) {
- cartridgeName = cartridge.getName();
- }
- return cartridgeName;
- }
-
- @Override
- public void setApplication(IApplication application) {
- setProperty(APPLICATION, application);
- }
-
- @Override
- public String setRemoteName(String remoteName) {
- setProperty(REMOTE_NAME, remoteName);
- return remoteName;
- }
-
- @Override
- public String getRemoteName() {
- return (String) getProperty(REMOTE_NAME);
- }
-
- @Override
- public String setRepositoryPath(String repositoryPath) {
- return (String) setProperty(REPOSITORY_PATH, repositoryPath);
- }
-
- @Override
- public String getRepositoryPath() {
- return (String) getProperty(REPOSITORY_PATH);
- }
-
- @Override
- public boolean isNewProject() {
- return (Boolean) getProperty(NEW_PROJECT);
- }
-
- @Override
- public boolean isExistingProject() {
- return !((Boolean) getProperty(NEW_PROJECT));
- }
-
- @Override
- public Boolean setNewProject(boolean newProject) {
- return (Boolean) setProperty(NEW_PROJECT, newProject);
- }
-
- @Override
- public Boolean setExistingProject(boolean existingProject) {
- return (Boolean) setProperty(NEW_PROJECT, !existingProject);
- }
-
- @Override
- public String setProjectName(String projectName) {
- return (String) setProperty(PROJECT_NAME, projectName);
- }
-
- @Override
- public boolean isGitSharedProject() {
- return EGitUtils.isSharedWithGit(getProject());
- }
-
- private IProject getProject() {
- return ResourcesPlugin.getWorkspace().getRoot().getProject(getProjectName());
- }
- @Override
- public Boolean setCreateServerAdapter(Boolean createServerAdapter) {
- return (Boolean) setProperty(CREATE_SERVER_ADAPTER, createServerAdapter);
- }
-
- @Override
- public String getProjectName() {
- return (String) getProperty(PROJECT_NAME);
- }
-
- @Override
- public String setMergeUri(String mergeUri) {
- return (String) setProperty(MERGE_URI, mergeUri);
- }
-
- @Override
- public String getMergeUri() {
- return (String) getProperty(MERGE_URI);
- }
-
- @Override
- public IRuntime getRuntime() {
- return (IRuntime) getProperty(RUNTIME_DELEGATE);
- }
-
- @Override
- public String getMode() {
- return (String) getProperty(PUBLICATION_MODE);
- }
-
- @Override
- public boolean isCreateServerAdapter() {
- Boolean isCreateServer = (Boolean) getProperty(CREATE_SERVER_ADAPTER);
- return isCreateServer != null && isCreateServer.booleanValue();
- }
-
- @Override
- public IServerType getServerType() {
- return (IServerType) getProperty(SERVER_TYPE);
- }
-
- @Override
- public void setServerType(IServerType serverType) {
- setProperty(SERVER_TYPE, serverType);
- }
-
- private void setPublicationMode(String mode) {
- setProperty(PUBLICATION_MODE, mode);
- }
-
-
-}
\ No newline at end of file
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:03:21 UTC (rev 38537)
+++ trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ApplicationConfigurationWizardPage.java 2012-02-09 10:29:54 UTC (rev 38538)
@@ -31,9 +31,15 @@
import org.eclipse.jface.databinding.swt.ISWTObservableValue;
import org.eclipse.jface.databinding.swt.WidgetProperties;
import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.jface.dialogs.IInputValidator;
import org.eclipse.jface.dialogs.InputDialog;
import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.fieldassist.AutoCompleteField;
+import org.eclipse.jface.fieldassist.ControlDecoration;
+import org.eclipse.jface.fieldassist.FieldDecoration;
+import org.eclipse.jface.fieldassist.FieldDecorationRegistry;
+import org.eclipse.jface.fieldassist.TextContentAdapter;
import org.eclipse.jface.layout.GridDataFactory;
import org.eclipse.jface.layout.GridLayoutFactory;
import org.eclipse.jface.layout.TableColumnLayout;
@@ -62,7 +68,10 @@
import org.eclipse.swt.widgets.Table;
import org.eclipse.swt.widgets.Text;
import org.jboss.tools.common.ui.WizardUtils;
+import org.jboss.tools.common.ui.databinding.InvertingBooleanConverter;
+import org.jboss.tools.common.ui.databinding.ValueBindingBuilder;
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.StringUtils;
import org.jboss.tools.openshift.express.internal.ui.utils.UIUtils;
import org.jboss.tools.openshift.express.internal.ui.wizard.CreationLogDialog.LogEntry;
@@ -82,8 +91,9 @@
private CheckboxTableViewer viewer;
private ApplicationConfigurationWizardPageModel pageModel;
+ private Button useExistingAppBtn = null;
- public ApplicationConfigurationWizardPage(IWizard wizard, CreateNewApplicationWizardModel wizardModel) {
+ public ApplicationConfigurationWizardPage(IWizard wizard, OpenShiftExpressApplicationWizardModel wizardModel) {
super("Application Configuration", "Configure the application you want to create.",
"Application configuration", wizard);
this.pageModel = new ApplicationConfigurationWizardPageModel(wizardModel);
@@ -93,11 +103,127 @@
protected void doCreateControls(Composite container, DataBindingContext dbc) {
GridLayoutFactory.fillDefaults().applyTo(container);
GridDataFactory.fillDefaults().grab(true, true).align(SWT.FILL, SWT.FILL).applyTo(container);
+ createApplicationSelectionGroup(container, dbc);
createApplicationConfigurationGroup(container, dbc);
}
+ private Composite createApplicationSelectionGroup(Composite container, DataBindingContext dbc) {
+ Composite existingAppSelectionGroup = new Composite(container, SWT.NONE);
+ // projectGroup.setText("Project");
+ GridDataFactory.fillDefaults().align(SWT.LEFT, SWT.CENTER).align(SWT.FILL, SWT.CENTER).grab(true, false)
+ .applyTo(existingAppSelectionGroup);
+ GridLayoutFactory.fillDefaults().numColumns(3).margins(6, 6).applyTo(existingAppSelectionGroup);
+
+ // existing app checkbox
+ useExistingAppBtn = new Button(existingAppSelectionGroup, SWT.CHECK);
+ useExistingAppBtn.setText("Use the existing application");
+ useExistingAppBtn.setToolTipText("Select an existing application or uncheck to create a new one.");
+ useExistingAppBtn.setFocus();
+ GridDataFactory.fillDefaults().span(1, 1).align(SWT.FILL, SWT.CENTER).grab(false, false)
+ .applyTo(useExistingAppBtn);
+ final IObservableValue useExistingAppObservable = BeanProperties.value(
+ ApplicationConfigurationWizardPageModel.PROPERTY_USE_EXISTING_APPLICATION).observe(pageModel);
+ final ISWTObservableValue useExistingAppBtnSelection = WidgetProperties.selection().observe(useExistingAppBtn);
+ dbc.bindValue(useExistingAppBtnSelection, useExistingAppObservable);
+
+ // existing app name
+ final Text existingAppNameText = new Text(existingAppSelectionGroup, SWT.BORDER);
+ GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).span(1, 1).grab(true, false)
+ .applyTo(existingAppNameText);
+ final IObservableValue existingAppNameModelObservable = BeanProperties.value(
+ ApplicationConfigurationWizardPageModel.PROPERTY_EXISTING_APPLICATION_NAME).observe(pageModel);
+ // observe text changes
+ final ISWTObservableValue existingAppNameTextObservable = WidgetProperties.text(SWT.Modify).observe(
+ existingAppNameText);
+ ValueBindingBuilder.bind(existingAppNameTextObservable).to(existingAppNameModelObservable).in(dbc);
+ 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);
+ // move focus to the project name text control when choosing the 'Use an existing project' option.
+ useExistingAppBtn.addSelectionListener(new SelectionListener() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ existingAppNameText.setFocus();
+ existingAppNameText.selectAll();
+ }
+
+ @Override
+ public void widgetDefaultSelected(SelectionEvent e) {
+ }
+ });
+ // let's provide content assist on the existing project name
+ ControlDecoration dec = new ControlDecoration(existingAppNameText, SWT.TOP | SWT.LEFT);
+ FieldDecoration contentProposalFieldIndicator = FieldDecorationRegistry.getDefault().getFieldDecoration(
+ FieldDecorationRegistry.DEC_CONTENT_PROPOSAL);
+ dec.setImage(contentProposalFieldIndicator.getImage());
+ dec.setDescriptionText("Auto-completion is enabled when you start typing a project name.");
+ dec.setShowOnlyOnFocus(true);
+
+ AutoCompleteField adapter = new AutoCompleteField(existingAppNameText, new TextContentAdapter(),
+ new String[] {});
+
+ adapter.setProposals(getApplicationNames());
+
+ Button browseAppsButton = new Button(existingAppSelectionGroup, SWT.NONE);
+ browseAppsButton.setText("Browse");
+ browseAppsButton.addSelectionListener(onBrowseApps());
+ GridDataFactory.fillDefaults().align(SWT.LEFT, SWT.CENTER).hint(100, SWT.DEFAULT).span(1, 1).grab(false, false)
+ .applyTo(browseAppsButton);
+ ValueBindingBuilder.bind(WidgetProperties.enabled().observe(browseAppsButton))
+ .notUpdating(useExistingAppObservable).in(dbc);
+ 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;
+ }
+
+ private String[] getApplicationNames() {
+ try {
+ List<IApplication> applications;
+ applications = pageModel.getApplications();
+ String[] names = new String[applications.size()];
+ for (int i = 0; i < applications.size(); i++) {
+ names[i] = applications.get(i).getName();
+ }
+ return names;
+ } catch (OpenShiftException e) {
+ Logger.error("Failed to retrieve list of OpenShift applications", e);
+ }
+ return new String[0];
+ }
+
+ private SelectionListener onBrowseApps() {
+ return new SelectionListener() {
+
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ final ApplicationSelectionDialog appSelectionDialog = new ApplicationSelectionDialog(
+ (OpenShiftExpressApplicationWizard) getWizard(), null, getShell());
+ final int result = appSelectionDialog.open();
+ if (result == IDialogConstants.OK_ID) {
+ final IApplication selectedApplication = appSelectionDialog.getSelectedApplication();
+ if (selectedApplication != null) {
+ pageModel.setExistingApplicationName(selectedApplication.getName());
+ }
+ }
+ }
+
+ @Override
+ public void widgetDefaultSelected(SelectionEvent e) {
+ }
+ };
+ }
+
private void createApplicationConfigurationGroup(Composite parent, DataBindingContext dbc) {
- Composite container = new Composite(parent, SWT.NONE);
+ Group container = new Group(parent, SWT.NONE);
+ container.setText("Application creation");
GridLayoutFactory.fillDefaults().numColumns(2).margins(6, 6).applyTo(container);
GridDataFactory.fillDefaults().grab(true, true).align(SWT.FILL, SWT.FILL).applyTo(container);
@@ -119,8 +245,8 @@
applicationTypeLabel.setText("Type:");
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).span(1, 1).applyTo(applicationTypeLabel);
Combo cartridgesCombo = new Combo(container, SWT.BORDER | SWT.READ_ONLY);
- GridDataFactory.fillDefaults()
- .align(SWT.FILL, SWT.CENTER).span(1, 1).grab(true, false).applyTo(cartridgesCombo);
+ GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).span(1, 1).grab(true, false)
+ .applyTo(cartridgesCombo);
fillCartridgesCombo(dbc, cartridgesCombo);
final ISWTObservableValue cartridgesComboObservable = WidgetProperties.selection().observe(cartridgesCombo);
final IObservableValue selectedCartridgeModelObservable = BeanProperties.value(
@@ -128,14 +254,14 @@
dbc.bindValue(cartridgesComboObservable, selectedCartridgeModelObservable,
new UpdateValueStrategy().setConverter(new StringToCartridgeConverter()),
new UpdateValueStrategy().setConverter(new CartridgeToStringConverter()));
- final ApplicationInputValidator applicationInputValidator =
- new ApplicationInputValidator(applicationNameTextObservable, cartridgesComboObservable);
+ final ApplicationToCreateInputValidator applicationInputValidator = new ApplicationToCreateInputValidator(
+ applicationNameTextObservable, cartridgesComboObservable);
dbc.addValidationStatusProvider(applicationInputValidator);
- final ApplicationNameValidator applicationNameValidator = new ApplicationNameValidator(
+ /*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");
@@ -143,25 +269,34 @@
GridLayoutFactory.fillDefaults().numColumns(2).margins(6, 6).applyTo(cartridgesGroup);
Composite tableContainer = new Composite(cartridgesGroup, SWT.NONE);
- GridDataFactory.fillDefaults()
- .align(SWT.FILL, SWT.FILL).grab(true, true).span(1, 2).hint(SWT.DEFAULT, 250).applyTo(tableContainer);
+ GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).grab(true, true).span(1, 2).hint(400, 250)
+ .applyTo(tableContainer);
this.viewer = createTable(tableContainer);
Button checkAllButton = new Button(cartridgesGroup, SWT.PUSH);
checkAllButton.setText("&Select All");
- GridDataFactory.fillDefaults()
- .hint(110, SWT.DEFAULT).grab(false, false).align(SWT.FILL, SWT.TOP).applyTo(checkAllButton);
+ GridDataFactory.fillDefaults().hint(110, SWT.DEFAULT).grab(false, false).align(SWT.FILL, SWT.TOP)
+ .applyTo(checkAllButton);
checkAllButton.addSelectionListener(onCheckAll());
Button uncheckAllButton = new Button(cartridgesGroup, SWT.PUSH);
uncheckAllButton.setText("&Deselect All");
- GridDataFactory.fillDefaults().
- hint(110, SWT.DEFAULT).grab(false, true).align(SWT.FILL, SWT.TOP).applyTo(uncheckAllButton);
+ GridDataFactory.fillDefaults().hint(110, SWT.DEFAULT).grab(false, true).align(SWT.FILL, SWT.TOP)
+ .applyTo(uncheckAllButton);
uncheckAllButton.addSelectionListener(onUncheckAll());
// bottom filler
Composite spacer = new Composite(container, SWT.NONE);
- GridDataFactory.fillDefaults()
- .span(2, 1).align(SWT.FILL, SWT.FILL).grab(true, true).applyTo(spacer);
+ GridDataFactory.fillDefaults().span(2, 1).align(SWT.FILL, SWT.FILL).grab(true, true).applyTo(spacer);
+ // enabling the group if the 'use existing application' checkbox state is 'false' (unchecked)
+ final ISWTObservableValue useExistinAppBtnObservable = WidgetProperties.selection().observe(
+ this.useExistingAppBtn);
+
+ final ISWTObservableValue createApplicationGroupEnabled = WidgetProperties.enabled().observe(container);
+ ValueBindingBuilder.bind(createApplicationGroupEnabled).notUpdatingParticipant().to(useExistinAppBtnObservable)
+ .converting(new InvertingBooleanConverter()).in(dbc);
+
+ // dbc.bindValue(useExistinAppBtnObservable, createApplicationGroupEnabled);
+
}
private void fillCartridgesCombo(DataBindingContext dbc, Combo cartridgesCombo) {
@@ -342,7 +477,9 @@
getShell().getDisplay().syncExec(new Runnable() {
@Override
public void run() {
- viewer.setInput(cartridges);
+ if (viewer != null) {
+ viewer.setInput(cartridges);
+ }
}
});
}
@@ -407,12 +544,11 @@
}
/**
- * Viewer element comparer based on #equals(). The default implementation in
- * CheckboxTableViewer compares elements based on instance identity.
+ * Viewer element comparer based on #equals(). The default implementation in CheckboxTableViewer compares elements
+ * based on instance identity.
* <p>
- * We need this since the available cartridges (item listed in the viewer)
- * are not the same instance as the ones in the embedded application (items
- * to check in the viewer).
+ * We need this since the available cartridges (item listed in the viewer) are not the same instance as the ones in
+ * the embedded application (items to check in the viewer).
*/
private static class EqualityComparer implements IElementComparer {
@@ -488,32 +624,30 @@
}
}
- class ApplicationNameValidator extends MultiValidator {
+ class ApplicationToSelectNameValidator extends MultiValidator {
private final IObservableValue applicationNameStatusObservable;
private final ISWTObservableValue applicationNameTextObservable;
- public ApplicationNameValidator(IObservableValue applicationNameStatusObservable,
- ISWTObservableValue applicationNameTextObservable) {
+ public ApplicationToSelectNameValidator(IObservableValue applicationNameStatusObservable,
+ ISWTObservableValue applicationNameTextObservable, IObservableValue existingAppNameModelObservable) {
this.applicationNameStatusObservable = applicationNameStatusObservable;
this.applicationNameTextObservable = applicationNameTextObservable;
}
@Override
protected IStatus validate() {
- final IStatus applicationNameStatus = (IStatus) applicationNameStatusObservable.getValue();
- if (applicationNameStatus != null) {
- return applicationNameStatus;
- }
+ /*
+ * final IStatus applicationNameStatus = (IStatus) applicationNameStatusObservable.getValue(); if
+ * (applicationNameStatus != null) { return applicationNameStatus; }
+ */
return ValidationStatus.ok();
}
/*
* (non-Javadoc)
- *
- * @see
- * org.eclipse.core.databinding.validation.MultiValidator#getTargets()
+ * @see org.eclipse.core.databinding.validation.MultiValidator#getTargets()
*/
@Override
public IObservableList getTargets() {
@@ -524,11 +658,11 @@
}
- class ApplicationInputValidator extends MultiValidator {
+ class ApplicationToCreateInputValidator extends MultiValidator {
private final ISWTObservableValue applicationNameTextObservable, cartridgesComboObservable;
- public ApplicationInputValidator(ISWTObservableValue applicationNameTextObservable,
+ public ApplicationToCreateInputValidator(ISWTObservableValue applicationNameTextObservable,
ISWTObservableValue cartridgesComboObservable) {
this.applicationNameTextObservable = applicationNameTextObservable;
this.cartridgesComboObservable = cartridgesComboObservable;
@@ -536,21 +670,21 @@
@Override
protected IStatus validate() {
- final String applicationName = (String) applicationNameTextObservable.getValue();
- final String applicationType = (String) cartridgesComboObservable.getValue();
- if (applicationName == null || applicationName.isEmpty() || applicationType == null
- || applicationType.isEmpty()) {
- return ValidationStatus
- .cancel("Please enter a name and select a type for the OpenShift application you want to create.");
+ if (!pageModel.getUseExistingApplication()) {
+ final String applicationName = (String) applicationNameTextObservable.getValue();
+ final String applicationType = (String) cartridgesComboObservable.getValue();
+ if (applicationName == null || applicationName.isEmpty() || applicationType == null
+ || applicationType.isEmpty()) {
+ return ValidationStatus
+ .cancel("Please enter a name and select a type for the OpenShift application you want to create.");
+ }
}
return ValidationStatus.ok();
}
/*
* (non-Javadoc)
- *
- * @see
- * org.eclipse.core.databinding.validation.MultiValidator#getTargets()
+ * @see org.eclipse.core.databinding.validation.MultiValidator#getTargets()
*/
@Override
public IObservableList getTargets() {
Modified: trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ApplicationConfigurationWizardPageModel.java
===================================================================
--- trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ApplicationConfigurationWizardPageModel.java 2012-02-09 10:03:21 UTC (rev 38537)
+++ trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ApplicationConfigurationWizardPageModel.java 2012-02-09 10:29:54 UTC (rev 38538)
@@ -11,6 +11,7 @@
package org.jboss.tools.openshift.express.internal.ui.wizard;
import java.util.ArrayList;
+import java.util.Collections;
import java.util.List;
import org.eclipse.core.runtime.IProgressMonitor;
@@ -32,13 +33,16 @@
*/
public class ApplicationConfigurationWizardPageModel extends ObservableUIPojo {
+ public static final String PROPERTY_USE_EXISTING_APPLICATION = "useExistingApplication";
+ public static final String PROPERTY_EXISTING_APPLICATION_NAME = "existingApplication";
public static final String PROPERTY_CARTRIDGES = "cartridges";
public static final String PROPERTY_EMBEDDABLE_CARTRIDGES = "embeddableCartridges";
public static final String PROPERTY_SELECTED_CARTRIDGE = "selectedCartridge";
public static final String PROPERTY_APPLICATION_NAME = "applicationName";
public static final String PROPERTY_APPLICATION_NAME_STATUS = "applicationNameStatus";
- private CreateNewApplicationWizardModel wizardModel;
+
+ private final OpenShiftExpressApplicationWizardModel wizardModel;
private List<IApplication> existingApplications = new ArrayList<IApplication>();
private List<ICartridge> cartridges = new ArrayList<ICartridge>();
@@ -46,16 +50,59 @@
private String applicationName;
private IStatus applicationNameStatus;
private ICartridge selectedCartridge;
+ private String selectedApplicationName;
+ private boolean useExistingApplication;
- public ApplicationConfigurationWizardPageModel(CreateNewApplicationWizardModel wizardModel) {
+ public ApplicationConfigurationWizardPageModel(OpenShiftExpressApplicationWizardModel wizardModel) {
this.wizardModel = wizardModel;
+ setUseExistingApplication(wizardModel.isExistingApplication());
+ setExistingApplicationName(wizardModel.getApplication() != null ? wizardModel.getApplication().getName() : null);
}
+ /**
+ * @return the wizardModel
+ */
+ public final OpenShiftExpressApplicationWizardModel getWizardModel() {
+ return wizardModel;
+ }
+
public IUser getUser() {
// return wizardModel.getUser();
return OpenShiftUIActivator.getDefault().getUser();
}
+
+ public List<IApplication> getApplications() throws OpenShiftException {
+ IUser user = getUser();
+ if (user == null) {
+ return Collections.emptyList();
+ }
+ return user.getApplications();
+ }
+
+ public boolean getUseExistingApplication() {
+ return this.useExistingApplication;
+ }
+
+ public void setUseExistingApplication(boolean useExistingApplication) {
+ wizardModel.setUseExistingApplication(useExistingApplication);
+ firePropertyChange(PROPERTY_USE_EXISTING_APPLICATION, this.useExistingApplication, this.useExistingApplication = useExistingApplication);
+ }
+
+ public String getExistingApplicationName() {
+ return selectedApplicationName;
+ }
+
+ public void setExistingApplicationName(String applicationName) {
+ for(IApplication application : getExistingApplications()) {
+ if(application.getName().equals(applicationName)) {
+ wizardModel.setApplication(application);
+ }
+ }
+ firePropertyChange(PROPERTY_EXISTING_APPLICATION_NAME, this.selectedApplicationName, this.selectedApplicationName = applicationName);
+ }
+
+
public void loadExistingApplications() throws OpenShiftException {
IUser user = getUser();
if (user != null) {
@@ -97,7 +144,7 @@
public void setSelectedCartridge(ICartridge cartridge) {
wizardModel.setApplicationCartridge(cartridge);
firePropertyChange(PROPERTY_SELECTED_CARTRIDGE, selectedCartridge, this.selectedCartridge = cartridge);
- validateApplicationName();
+ //validateApplicationName();
}
public List<IEmbeddableCartridge> loadEmbeddableCartridges() throws OpenShiftException {
Added: trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ApplicationSelectionDialog.java
===================================================================
--- trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ApplicationSelectionDialog.java (rev 0)
+++ trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ApplicationSelectionDialog.java 2012-02-09 10:29:54 UTC (rev 38538)
@@ -0,0 +1,266 @@
+package org.jboss.tools.openshift.express.internal.ui.wizard;
+
+/*******************************************************************************
+ * Copyright (c) 2011 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+
+import java.util.Collection;
+
+import org.eclipse.core.databinding.Binding;
+import org.eclipse.core.databinding.DataBindingContext;
+import org.eclipse.core.databinding.UpdateValueStrategy;
+import org.eclipse.core.databinding.beans.BeanProperties;
+import org.eclipse.core.databinding.validation.IValidator;
+import org.eclipse.core.databinding.validation.ValidationStatus;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.jface.databinding.viewers.ViewerProperties;
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.jface.dialogs.TitleAreaDialog;
+import org.eclipse.jface.layout.GridDataFactory;
+import org.eclipse.jface.layout.GridLayoutFactory;
+import org.eclipse.jface.layout.TableColumnLayout;
+import org.eclipse.jface.viewers.ArrayContentProvider;
+import org.eclipse.jface.viewers.CellLabelProvider;
+import org.eclipse.jface.viewers.ColumnWeightData;
+import org.eclipse.jface.viewers.DoubleClickEvent;
+import org.eclipse.jface.viewers.IDoubleClickListener;
+import org.eclipse.jface.viewers.TableViewer;
+import org.eclipse.jface.viewers.TableViewerColumn;
+import org.eclipse.jface.viewers.ViewerCell;
+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.Control;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Table;
+import org.jboss.tools.common.ui.WizardUtils;
+import org.jboss.tools.common.ui.databinding.DataBindingUtils;
+import org.jboss.tools.openshift.express.internal.ui.OpenShiftImages;
+import org.jboss.tools.openshift.express.internal.ui.utils.Logger;
+
+import com.openshift.express.client.IApplication;
+import com.openshift.express.client.OpenShiftException;
+
+/**
+ * @author Andre Dietisheim
+ * @author Xavier Coulon
+ */
+public class ApplicationSelectionDialog extends TitleAreaDialog {
+
+ private final ApplicationSelectionDialogModel dialogModel;
+ private final DataBindingContext dbc;
+ private TableViewer tableViewer;
+
+ public ApplicationSelectionDialog(OpenShiftExpressApplicationWizard wizard, IApplication selectedApplication,
+ Shell parentShell) {
+ super(parentShell);
+ this.dialogModel = new ApplicationSelectionDialogModel(wizard.getWizardModel());
+ this.dialogModel.setSelectedApplication(selectedApplication);
+ this.dbc = new DataBindingContext();
+ }
+
+ @Override
+ protected Control createContents(Composite parent) {
+ Control control = super.createContents(parent);
+ setupDialog(parent);
+ return control;
+ }
+
+ private void setupDialog(Composite parent) {
+ parent.getShell().setText("Application selection");
+ setTitle("Select an application in the list");
+ setTitleImage(OpenShiftImages.OPENSHIFT_LOGO_WHITE_MEDIUM_IMG);
+ setDialogHelpAvailable(false);
+ }
+
+ @Override
+ protected void createButtonsForButtonBar(Composite parent) {
+ createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, true);
+ createButton(parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false);
+ }
+
+ /**
+ * Creates the SWT Group in which a table which will display the existing applications with their corresponding
+ * type. Before each application, a radio button will let the user choose which application to import in his
+ * workspace.
+ *
+ * @param container
+ * @param dbc
+ */
+ @Override
+ protected Control createDialogArea(Composite parent) {
+ Label titleSeparator = new Label(parent, SWT.HORIZONTAL | SWT.SEPARATOR);
+ GridDataFactory.fillDefaults().align(SWT.FILL, SWT.TOP).grab(true, false).applyTo(titleSeparator);
+
+ Composite dialogArea = new Composite(parent, SWT.NONE);
+ GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).grab(true, true).applyTo(dialogArea);
+ GridLayoutFactory.fillDefaults().margins(10, 10).applyTo(dialogArea);
+
+ Label applicationLabel = new Label(dialogArea, SWT.NONE);
+ applicationLabel.setText("Existing Applications on OpenShift");
+ GridDataFactory.fillDefaults().grab(true, false).align(SWT.FILL, SWT.FILL).span(5, 1).applyTo(applicationLabel);
+ GridLayoutFactory.fillDefaults().numColumns(2).margins(6, 6).applyTo(dialogArea);
+
+ Composite tableContainer = new Composite(dialogArea, SWT.NONE);
+ tableViewer = createTable(tableContainer);
+ tableViewer.setInput(dialogModel.getApplications());
+ GridDataFactory.fillDefaults().span(1, 2).align(SWT.FILL, SWT.FILL).grab(true, false).hint(SWT.DEFAULT, 200)
+ .applyTo(tableContainer);
+ tableViewer.addDoubleClickListener(onApplicationDoubleClick());
+ Binding selectedApplicationBinding = dbc.bindValue(ViewerProperties.singleSelection().observe(tableViewer),
+ BeanProperties.value(ApplicationSelectionDialogModel.PROPERTY_SELECTED_APPLICATION)
+ .observe(dialogModel), new UpdateValueStrategy().setAfterGetValidator(new IValidator() {
+ @Override
+ public IStatus validate(Object value) {
+ if (value != null) {
+ return ValidationStatus.ok();
+ } else {
+ return ValidationStatus.cancel("Select an application in the list below.");
+ }
+ }
+ }), null);
+
+ 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)
+ .applyTo(detailsButton);
+ DataBindingUtils.bindEnablementToValidationStatus(detailsButton, IStatus.OK, dbc, selectedApplicationBinding);
+ detailsButton.addSelectionListener(onDetails(dbc));
+ // bottom filler
+ Composite spacer = new Composite(dialogArea, SWT.NONE);
+ GridDataFactory.fillDefaults().span(2, 1).align(SWT.FILL, SWT.FILL).grab(true, true).applyTo(spacer);
+ // horizontal line to separate content from buttons
+ Label buttonsSeparator = new Label(parent, SWT.HORIZONTAL | SWT.SEPARATOR);
+ GridDataFactory.fillDefaults().align(SWT.FILL, SWT.TOP).grab(true, false).applyTo(buttonsSeparator);
+
+ return dialogArea;
+ }
+
+ private IDoubleClickListener onApplicationDoubleClick() {
+ return new IDoubleClickListener() {
+ @Override
+ public void doubleClick(DoubleClickEvent event) {
+ openDetailsDialog();
+ }
+ };
+ }
+
+ protected TableViewer createTable(Composite tableContainer) {
+ Table table = new Table(tableContainer, SWT.BORDER | SWT.FULL_SELECTION | SWT.V_SCROLL | SWT.H_SCROLL);
+ int desiredHeight = table.getItemHeight() * 10 + table.getHeaderHeight();
+ GridDataFactory.fillDefaults().grab(true, false).hint(SWT.DEFAULT, desiredHeight).applyTo(table);
+ table.setLinesVisible(true);
+ table.setHeaderVisible(true);
+ TableColumnLayout tableLayout = new TableColumnLayout();
+ tableContainer.setLayout(tableLayout);
+ TableViewer viewer = new TableViewer(table);
+ viewer.setContentProvider(new ArrayContentProvider());
+ createTableColumn("Name", 1, new CellLabelProvider() {
+ @Override
+ public void update(ViewerCell cell) {
+ IApplication application = (IApplication) cell.getElement();
+ cell.setText(application.getName());
+ }
+ }, viewer, tableLayout);
+
+ createTableColumn("Type", 1, new CellLabelProvider() {
+ @Override
+ public void update(ViewerCell cell) {
+ IApplication application = (IApplication) cell.getElement();
+ cell.setText(application.getCartridge().getName());
+ }
+ }, viewer, tableLayout);
+
+ createTableColumn("URL", 3, new CellLabelProvider() {
+ @Override
+ public void update(ViewerCell cell) {
+ IApplication application = (IApplication) cell.getElement();
+ try {
+ cell.setText(application.getApplicationUrl());
+ } catch (OpenShiftException e) {
+ }
+ }
+ }, viewer, tableLayout);
+
+ return viewer;
+ }
+
+ private void createTableColumn(String name, int weight, CellLabelProvider cellLabelProvider, TableViewer viewer,
+ TableColumnLayout layout) {
+ TableViewerColumn column = new TableViewerColumn(viewer, SWT.LEFT);
+ column.getColumn().setText(name);
+ column.getColumn().setResizable(true);
+ column.setLabelProvider(cellLabelProvider);
+ layout.setColumnData(column.getColumn(), new ColumnWeightData(weight, true));
+ }
+
+ private SelectionAdapter onRefresh(final DataBindingContext dbc) {
+ return new SelectionAdapter() {
+
+ @Override
+ public void widgetSelected(SelectionEvent event) {
+ try {
+ WizardUtils.runInWizard(new Job("Loading applications...") {
+ @Override
+ protected IStatus run(IProgressMonitor monitor) {
+ final Collection<IApplication> applications = dialogModel.getApplications();
+ setViewerInput(applications);
+ return Status.OK_STATUS;
+ }
+
+ }, null, dbc);
+ } catch (Exception e) {
+ // ignore
+ }
+ }
+ };
+ }
+
+ private SelectionAdapter onDetails(DataBindingContext dbc) {
+ return new SelectionAdapter() {
+
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ openDetailsDialog();
+ }
+ };
+ }
+
+ private void openDetailsDialog() {
+ new ApplicationDetailsDialog(dialogModel.getSelectedApplication(), getShell()).open();
+ }
+
+ private void setViewerInput(final Collection<IApplication> applications) {
+ getShell().getDisplay().syncExec(new Runnable() {
+
+ @Override
+ public void run() {
+ Logger.debug("Setting {} application(s) in the viewer", applications.size());
+ tableViewer.setInput(applications);
+ }
+ });
+ }
+
+ public IApplication getSelectedApplication() {
+ return dialogModel.getSelectedApplication();
+ }
+}
Property changes on: trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ApplicationSelectionDialog.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ApplicationSelectionDialogModel.java
===================================================================
--- trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ApplicationSelectionDialogModel.java (rev 0)
+++ trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ApplicationSelectionDialogModel.java 2012-02-09 10:29:54 UTC (rev 38538)
@@ -0,0 +1,65 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.openshift.express.internal.ui.wizard;
+
+import java.util.Collections;
+import java.util.List;
+
+import org.jboss.tools.common.ui.databinding.ObservableUIPojo;
+import org.jboss.tools.openshift.express.internal.ui.OpenShiftUIActivator;
+import org.jboss.tools.openshift.express.internal.ui.utils.Logger;
+
+import com.openshift.express.client.IApplication;
+import com.openshift.express.client.IUser;
+import com.openshift.express.client.OpenShiftException;
+
+/**
+ * @author Andre Dietisheim
+ * @author Xavier Coulon
+ *
+ */
+public class ApplicationSelectionDialogModel extends ObservableUIPojo {
+
+ public static final String PROPERTY_SELECTED_APPLICATION = "selectedApplication";
+
+ private IApplication selectedApplication;
+
+ public ApplicationSelectionDialogModel(IOpenShiftWizardModel wizardModel) {
+ this.selectedApplication = wizardModel.getApplication();
+ }
+
+ public List<IApplication> getApplications() {
+ try {
+ IUser user = getUser();
+ if (user == null) {
+ return Collections.emptyList();
+ }
+ return user.getApplications();
+ } catch (OpenShiftException e) {
+ Logger.error("Failed to retrieve User's applications", e);
+ }
+ return Collections.emptyList();
+ }
+
+ public IApplication getSelectedApplication() {
+ return selectedApplication;
+ }
+
+ public void setSelectedApplication(IApplication application) {
+ firePropertyChange(PROPERTY_SELECTED_APPLICATION, this.selectedApplication,
+ this.selectedApplication = application);
+ }
+
+ public IUser getUser() {
+ return OpenShiftUIActivator.getDefault().getUser();
+ }
+
+}
Property changes on: trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ApplicationSelectionDialogModel.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/ApplicationSelectionWizardPage.java
===================================================================
--- trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ApplicationSelectionWizardPage.java 2012-02-09 10:03:21 UTC (rev 38537)
+++ trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ApplicationSelectionWizardPage.java 2012-02-09 10:29:54 UTC (rev 38538)
@@ -10,57 +10,66 @@
******************************************************************************/
package org.jboss.tools.openshift.express.internal.ui.wizard;
-import java.util.ArrayList;
import java.util.Collection;
import org.eclipse.core.databinding.Binding;
import org.eclipse.core.databinding.DataBindingContext;
+import org.eclipse.core.databinding.UpdateListStrategy;
import org.eclipse.core.databinding.UpdateValueStrategy;
import org.eclipse.core.databinding.beans.BeanProperties;
+import org.eclipse.core.databinding.conversion.Converter;
+import org.eclipse.core.databinding.observable.value.IObservableValue;
import org.eclipse.core.databinding.validation.IValidator;
+import org.eclipse.core.databinding.validation.MultiValidator;
import org.eclipse.core.databinding.validation.ValidationStatus;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.jobs.Job;
-import org.eclipse.jface.databinding.viewers.ViewerProperties;
+import org.eclipse.jface.databinding.fieldassist.ControlDecorationSupport;
+import org.eclipse.jface.databinding.swt.ISWTObservableValue;
+import org.eclipse.jface.databinding.swt.WidgetProperties;
+import org.eclipse.jface.fieldassist.AutoCompleteField;
+import org.eclipse.jface.fieldassist.ControlDecoration;
+import org.eclipse.jface.fieldassist.FieldDecoration;
+import org.eclipse.jface.fieldassist.FieldDecorationRegistry;
+import org.eclipse.jface.fieldassist.TextContentAdapter;
import org.eclipse.jface.layout.GridDataFactory;
import org.eclipse.jface.layout.GridLayoutFactory;
-import org.eclipse.jface.layout.TableColumnLayout;
-import org.eclipse.jface.viewers.ArrayContentProvider;
-import org.eclipse.jface.viewers.CellLabelProvider;
-import org.eclipse.jface.viewers.ColumnWeightData;
-import org.eclipse.jface.viewers.DoubleClickEvent;
-import org.eclipse.jface.viewers.IDoubleClickListener;
import org.eclipse.jface.viewers.TableViewer;
-import org.eclipse.jface.viewers.TableViewerColumn;
-import org.eclipse.jface.viewers.ViewerCell;
import org.eclipse.jface.wizard.IWizard;
+import org.eclipse.osgi.util.NLS;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Combo;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Table;
+import org.eclipse.swt.widgets.Text;
import org.jboss.tools.common.ui.WizardUtils;
-import org.jboss.tools.common.ui.databinding.DataBindingUtils;
+import org.jboss.tools.common.ui.databinding.InvertingBooleanConverter;
+import org.jboss.tools.common.ui.databinding.ValueBindingBuilder;
import org.jboss.tools.openshift.express.internal.ui.OpenShiftUIActivator;
-import org.jboss.tools.openshift.express.internal.ui.utils.Logger;
+import com.openshift.express.client.Cartridge;
import com.openshift.express.client.IApplication;
+import com.openshift.express.client.ICartridge;
import com.openshift.express.client.NotFoundOpenShiftException;
-import com.openshift.express.client.OpenShiftException;
/**
* @author Andre Dietisheim
* @author Xavier Coulon
*/
+@Deprecated
public class ApplicationSelectionWizardPage extends AbstractOpenShiftWizardPage {
private TableViewer tableViewer;
private final ApplicationSelectionWizardPageModel pageModel;
+ private Text existingAppNameText = null;
+
public ApplicationSelectionWizardPage(IWizard wizard, IOpenShiftWizardModel wizardModel) {
super("Application selection", "Click 'next' or select another application to import.",
"Application selection", wizard);
@@ -70,9 +79,94 @@
@Override
protected void doCreateControls(Composite container, DataBindingContext dbc) {
GridLayoutFactory.fillDefaults().numColumns(2).applyTo(container);
- createApplicationsGroup(container, dbc);
+ createExistingAppSelectionGroup(container, dbc);
+ //createApplicationCreationGroup(container, dbc);
}
+ private Composite createExistingAppSelectionGroup(Composite container, DataBindingContext dbc) {
+ Composite existingAppSelectionGroup = new Composite(container, SWT.NONE);
+ // projectGroup.setText("Project");
+ GridDataFactory.fillDefaults().align(SWT.LEFT, SWT.CENTER).align(SWT.FILL, SWT.CENTER).grab(true, false)
+ .applyTo(existingAppSelectionGroup);
+ GridLayoutFactory.fillDefaults().numColumns(3).margins(6, 6).applyTo(existingAppSelectionGroup);
+
+ // existing app checkbox
+ Button useExistingAppBtn = new Button(existingAppSelectionGroup, SWT.CHECK);
+ useExistingAppBtn.setText("Use the existing application");
+ useExistingAppBtn.setToolTipText("Select an existing application or uncheck to create a new one.");
+ useExistingAppBtn.setFocus();
+ GridDataFactory.fillDefaults().span(3, 1).align(SWT.FILL, SWT.CENTER).grab(false, false)
+ .applyTo(useExistingAppBtn);
+ final IObservableValue useExistingAppObservable = BeanProperties.value(
+ ApplicationSelectionWizardPageModel.PROPERTY_USE_EXISTING_APPLICATION).observe(pageModel);
+ final ISWTObservableValue useExistingAppBtnSelection = WidgetProperties.selection().observe(useExistingAppBtn);
+ dbc.bindValue(useExistingAppBtnSelection, useExistingAppObservable);
+
+ // existing project
+ Label existingProjectLabel = new Label(existingAppSelectionGroup, SWT.NONE);
+ existingProjectLabel.setText("Use the existing project");
+ GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).span(1, 1).grab(false, false).indent(10, 0)
+ .applyTo(existingProjectLabel);
+
+ existingAppNameText = new Text(existingAppSelectionGroup, SWT.BORDER);
+ GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).span(1, 1).grab(true, false)
+ .applyTo(existingAppNameText);
+ final IObservableValue appNameModelObservable = BeanProperties.value(
+ ApplicationSelectionWizardPageModel.PROPERTY_SELECTED_APPLICATION).observe(pageModel);
+ final ISWTObservableValue existingAppNameTextObservable = WidgetProperties.text(SWT.Modify).observe(
+ existingAppNameText);
+ ValueBindingBuilder.bind(existingAppNameTextObservable).to(appNameModelObservable).in(dbc);
+ // disable the project name text when the model state is set to 'new project'
+ ValueBindingBuilder.bind(WidgetProperties.enabled().observe(existingAppNameText))
+ .notUpdating(useExistingAppObservable).converting(new InvertingBooleanConverter()).in(dbc);
+ // move focus to the project name text control when choosing the 'Use an existing project' option.
+ useExistingAppBtn.addSelectionListener(new SelectionListener() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ existingAppNameText.setFocus();
+ existingAppNameText.selectAll();
+ }
+
+ @Override
+ public void widgetDefaultSelected(SelectionEvent e) {
+ }
+ });
+ // let's provide content assist on the existing project name
+ ControlDecoration dec = new ControlDecoration(existingAppNameText, SWT.TOP | SWT.LEFT);
+ FieldDecoration contentProposalFieldIndicator = FieldDecorationRegistry.getDefault().getFieldDecoration(
+ FieldDecorationRegistry.DEC_CONTENT_PROPOSAL);
+ dec.setImage(contentProposalFieldIndicator.getImage());
+ dec.setDescriptionText("Auto-completion is enabled when you start typing a project name.");
+ dec.setShowOnlyOnFocus(true);
+
+ AutoCompleteField adapter = new AutoCompleteField(existingAppNameText, new TextContentAdapter(),
+ new String[] {});
+
+ //adapter.setProposals(getOpenProjectsInWorkspace());
+
+ Button browseAppsButton = new Button(existingAppSelectionGroup, SWT.NONE);
+ browseAppsButton.setText("Browse");
+ GridDataFactory.fillDefaults().align(SWT.LEFT, SWT.CENTER).hint(100, SWT.DEFAULT).span(1, 1).grab(false, false)
+ .applyTo(browseAppsButton);
+ browseAppsButton.addSelectionListener(onBrowseApps());
+ ValueBindingBuilder.bind(WidgetProperties.enabled().observe(browseAppsButton))
+ .notUpdating(useExistingAppObservable).converting(new InvertingBooleanConverter()).in(dbc);
+
+ final IObservableValue existingProjectValidityObservable = BeanProperties.value(
+ ProjectAndServerAdapterSettingsWizardPageModel.PROPERTY_EXISTING_PROJECT_VALIDITY).observe(pageModel);
+ final UseExistingApplicationValidator existingProjectValidator = new UseExistingApplicationValidator(
+ existingProjectValidityObservable);
+ dbc.addValidationStatusProvider(existingProjectValidator);
+ ControlDecorationSupport.create(existingProjectValidator, SWT.LEFT | SWT.TOP);
+
+ return existingAppSelectionGroup;
+ }
+
+ private SelectionListener onBrowseApps() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
/**
* Creates the SWT Group in which a table which will display the existing applications with their corresponding
* type. Before each application, a radio button will let the user choose which application to import in his
@@ -81,111 +175,73 @@
* @param container
* @param dbc
*/
- private void createApplicationsGroup(Composite container, DataBindingContext dbc) {
- Label applicationLabel = new Label(container, SWT.NONE);
- applicationLabel.setText("Existing Applications on OpenShift");
- GridDataFactory.fillDefaults().grab(true, false).align(SWT.FILL, SWT.FILL).span(5, 1).applyTo(applicationLabel);
- // GridLayoutFactory.fillDefaults().numColumns(4).margins(6, 6).applyTo(applicationGroup);
+ private void createApplicationCreationGroup(Composite parent, DataBindingContext dbc) {
+ GridLayoutFactory.fillDefaults().numColumns(2).margins(10, 10).applyTo(parent);
- Composite tableContainer = new Composite(container, SWT.NONE);
- this.tableViewer = createTable(tableContainer);
-
- GridDataFactory.fillDefaults().span(1, 2).align(SWT.FILL, SWT.FILL).grab(true, false)
- //.hint(SWT.DEFAULT, desiredHeight)
- .applyTo(tableContainer);
- tableViewer.addDoubleClickListener(onApplicationDoubleClick());
- Binding selectedApplicationBinding = dbc.bindValue(ViewerProperties.singleSelection().observe(tableViewer),
- BeanProperties.value(ApplicationWizardPageModel.PROPERTY_SELECTED_APPLICATION).observe(pageModel),
- new UpdateValueStrategy().setAfterGetValidator(new IValidator() {
+ Label nameLabel = new Label(parent, SWT.NONE);
+ nameLabel.setText("Na&me");
+ GridDataFactory.fillDefaults().align(SWT.LEFT, SWT.CENTER).applyTo(nameLabel);
+ Text nameText = new Text(parent, SWT.BORDER);
+ nameText.setTextLimit(13);
+ GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false).applyTo(nameText);
+ Binding nameBinding = dbc.bindValue(WidgetProperties.text(SWT.Modify).observe(nameText),
+ BeanProperties.value(NewApplicationWizardPageModel.PROPERTY_NAME).observe(pageModel),
+ new UpdateValueStrategy().setAfterGetValidator(new ApplicationNameValidator()), null);
+ ControlDecorationSupport.create(nameBinding, SWT.LEFT | SWT.TOP);
+
+ Label cartridgeLabel = new Label(parent, SWT.WRAP);
+ cartridgeLabel.setText("&Application Type");
+ GridDataFactory.fillDefaults().align(SWT.LEFT, SWT.CENTER).applyTo(cartridgeLabel);
+ Combo cartridgesCombo = new Combo(parent, SWT.BORDER | SWT.READ_ONLY);
+ GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false).applyTo(cartridgesCombo);
+ dbc.bindList(WidgetProperties.items().observe(cartridgesCombo),
+ BeanProperties.list(NewApplicationWizardPageModel.PROPERTY_CARTRIDGES).observe(pageModel),
+ new UpdateListStrategy(UpdateListStrategy.POLICY_NEVER),
+ new UpdateListStrategy().setConverter(new Converter(Object.class, String.class) {
+
@Override
+ public Object convert(Object fromObject) {
+ if (!(fromObject instanceof ICartridge)) {
+ return null;
+ }
+ return ((ICartridge) fromObject).getName();
+ }
+ }));
+ Binding comboSelectionBinding = dbc.bindValue(WidgetProperties.selection().observe(cartridgesCombo),
+ BeanProperties.value(NewApplicationWizardPageModel.PROPERTY_SELECTED_CARTRIDGE).observe(pageModel),
+ new UpdateValueStrategy().setConverter(new Converter(String.class, ICartridge.class) {
+
+ @Override
+ public Object convert(Object fromObject) {
+ if (fromObject instanceof String && ((String) fromObject).length() > 0) {
+ return new Cartridge(((String) fromObject));
+ }
+ return null;
+ }
+ }).setAfterGetValidator(new IValidator() {
+
+ @Override
public IStatus validate(Object value) {
- if (value != null) {
+ if (!(value instanceof String) || ((String) value).length() == 0) {
+ return ValidationStatus.error("You have to select a type");
+ } else {
return ValidationStatus.ok();
- } else {
- return ValidationStatus.cancel("Select an application in the list below.");
}
}
- }), null);
+ }), new UpdateValueStrategy().setConverter(new Converter(ICartridge.class, String.class) {
- Button refreshButton = new Button(container, SWT.PUSH);
- refreshButton.setText("R&efresh");
- GridDataFactory.fillDefaults().align(SWT.RIGHT, SWT.TOP).grab(false, false).hint(80, SWT.DEFAULT)
- .applyTo(refreshButton);
- // DataBindingUtils.bindEnablementToValidationStatus(refreshButton, IStatus.OK, dbc,
- // selectedApplicationBinding);
- refreshButton.addSelectionListener(onRefresh(dbc));
+ @Override
+ public Object convert(Object fromObject) {
+ if (fromObject instanceof ICartridge) {
+ return ((ICartridge) fromObject).getName();
+ }
+ return null;
+ }
+ }));
+ ControlDecorationSupport.create(comboSelectionBinding, SWT.LEFT | SWT.TOP);
- Button detailsButton = new Button(container, SWT.PUSH);
- detailsButton.setText("De&tails");
- GridDataFactory.fillDefaults().align(SWT.RIGHT, SWT.TOP).grab(false, true).hint(80, SWT.DEFAULT)
- .applyTo(detailsButton);
- DataBindingUtils.bindEnablementToValidationStatus(detailsButton, IStatus.OK, dbc, selectedApplicationBinding);
- detailsButton.addSelectionListener(onDetails(dbc));
- // bottom filler
- Composite spacer = new Composite(container, SWT.NONE);
- GridDataFactory.fillDefaults().span(2, 1).align(SWT.FILL, SWT.FILL).grab(true, true)
- .applyTo(spacer);
-
}
- private IDoubleClickListener onApplicationDoubleClick() {
- return new IDoubleClickListener() {
- @Override
- public void doubleClick(DoubleClickEvent event) {
- openDetailsDialog();
- }
- };
- }
-
- protected TableViewer createTable(Composite tableContainer) {
- Table table = new Table(tableContainer, SWT.BORDER | SWT.FULL_SELECTION | SWT.V_SCROLL | SWT.H_SCROLL);
- int desiredHeight = table.getItemHeight() * 10 + table.getHeaderHeight();
- GridDataFactory.fillDefaults().grab(true, false).hint(SWT.DEFAULT, desiredHeight).applyTo(table);
- table.setLinesVisible(true);
- table.setHeaderVisible(true);
- TableColumnLayout tableLayout = new TableColumnLayout();
- tableContainer.setLayout(tableLayout);
- TableViewer viewer = new TableViewer(table);
- viewer.setContentProvider(new ArrayContentProvider());
- createTableColumn("Name", 1, new CellLabelProvider() {
- @Override
- public void update(ViewerCell cell) {
- IApplication application = (IApplication) cell.getElement();
- cell.setText(application.getName());
- }
- }, viewer, tableLayout);
-
- createTableColumn("Type", 1, new CellLabelProvider() {
- @Override
- public void update(ViewerCell cell) {
- IApplication application = (IApplication) cell.getElement();
- cell.setText(application.getCartridge().getName());
- }
- }, viewer, tableLayout);
-
- createTableColumn("URL", 3, new CellLabelProvider() {
- @Override
- public void update(ViewerCell cell) {
- IApplication application = (IApplication) cell.getElement();
- try {
- cell.setText(application.getApplicationUrl());
- } catch (OpenShiftException e) {
- }
- }
- }, viewer, tableLayout);
-
- return viewer;
- }
-
- private void createTableColumn(String name, int weight, CellLabelProvider cellLabelProvider, TableViewer viewer,
- TableColumnLayout layout) {
- TableViewerColumn column = new TableViewerColumn(viewer, SWT.LEFT);
- column.getColumn().setText(name);
- column.getColumn().setResizable(true);
- column.setLabelProvider(cellLabelProvider);
- layout.setColumnData(column.getColumn(), new ColumnWeightData(weight, true));
- }
-
private SelectionAdapter onRefresh(final DataBindingContext dbc) {
return new SelectionAdapter() {
@@ -196,19 +252,7 @@
@Override
protected IStatus run(IProgressMonitor monitor) {
- try {
- final Collection<IApplication> applications = pageModel.getApplications();
- setViewerInput(applications);
- return Status.OK_STATUS;
- } catch (NotFoundOpenShiftException e) {
- // no domain and therefore no applications present
- clearViewer();
- return Status.OK_STATUS;
- } catch (Exception e) {
- clearViewer();
- return new Status(IStatus.ERROR, OpenShiftUIActivator.PLUGIN_ID,
- "Could not load applications", e);
- }
+ return Status.OK_STATUS;
}
}, getContainer(), getDataBindingContext());
@@ -220,20 +264,6 @@
};
}
- private SelectionAdapter onDetails(DataBindingContext dbc) {
- return new SelectionAdapter() {
-
- @Override
- public void widgetSelected(SelectionEvent e) {
- openDetailsDialog();
- }
- };
- }
-
- private void openDetailsDialog() {
- new ApplicationDetailsDialog(pageModel.getSelectedApplication(), getShell()).open();
- }
-
@Override
protected void onPageActivated(final DataBindingContext dbc) {
try {
@@ -243,14 +273,11 @@
protected IStatus run(IProgressMonitor monitor) {
try {
final Collection<IApplication> applications = pageModel.getApplications();
- setViewerInput(applications);
return Status.OK_STATUS;
} catch (NotFoundOpenShiftException e) {
// no domain and therefore no applications present
- clearViewer();
return Status.OK_STATUS;
} catch (Exception e) {
- clearViewer();
return new Status(IStatus.ERROR, OpenShiftUIActivator.PLUGIN_ID, "Could not load applications",
e);
}
@@ -263,19 +290,40 @@
}
}
- private void clearViewer() {
- Logger.debug("Clearing applications list in viewer");
- setViewerInput(new ArrayList<IApplication>());
- }
+ class UseExistingApplicationValidator extends MultiValidator {
- private void setViewerInput(final Collection<IApplication> applications) {
- getShell().getDisplay().syncExec(new Runnable() {
+ private final IObservableValue existingProjectValidityObservable;
- @Override
- public void run() {
- Logger.debug("Setting {} application(s) in the viewer", applications.size());
- tableViewer.setInput(applications);
+ public UseExistingApplicationValidator(IObservableValue existingProjectValidityObservable) {
+ this.existingProjectValidityObservable = existingProjectValidityObservable;
+ }
+
+ @Override
+ protected IStatus validate() {
+ final IStatus existingProjectValidityStatus = (IStatus) existingProjectValidityObservable.getValue();
+
+ if (existingProjectValidityStatus != null) {
+ final IStatus existingProjectValidity = pageModel.getExistingApplicationValidity();
+ return existingProjectValidity;
}
- });
+ return ValidationStatus.ok();
+ }
+
}
+
+ private class ApplicationNameValidator implements IValidator {
+
+ @Override
+ public IStatus validate(Object value) {
+ String name = (String) value;
+ if (name.length() == 0) {
+ return ValidationStatus.error("You have to provide a name");
+ } else if (pageModel.hasApplication(name)) {
+ return ValidationStatus.error(NLS.bind(
+ "Names must be unique. You already have an application named \"{0}\"", name));
+ }
+ return ValidationStatus.ok();
+ }
+ }
+
}
Modified: trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ApplicationSelectionWizardPageModel.java
===================================================================
--- trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ApplicationSelectionWizardPageModel.java 2012-02-09 10:03:21 UTC (rev 38537)
+++ trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ApplicationSelectionWizardPageModel.java 2012-02-09 10:29:54 UTC (rev 38538)
@@ -13,6 +13,8 @@
import java.util.Collections;
import java.util.List;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
import org.jboss.tools.common.ui.databinding.ObservableUIPojo;
import org.jboss.tools.openshift.express.internal.ui.OpenShiftUIActivator;
@@ -25,17 +27,20 @@
* @author Xavier Coulon
*
*/
+@Deprecated
public class ApplicationSelectionWizardPageModel extends ObservableUIPojo {
- public static final String PROPERTY_NAMESPACE = "namespace";
- public static final String PROPERTY_DOMAIN = "domain";
+ public static final String PROPERTY_USE_EXISTING_APPLICATION = "useExistingApplication";
public static final String PROPERTY_SELECTED_APPLICATION = "selectedApplication";
+ private boolean useExistingApplication = false;
private IApplication selectedApplication;
private IOpenShiftWizardModel wizardModel;
public ApplicationSelectionWizardPageModel(IOpenShiftWizardModel wizardModel) {
this.wizardModel = wizardModel;
+ this.selectedApplication = wizardModel.getApplication();
+ this.useExistingApplication = wizardModel.isExistingApplication();
}
public List<IApplication> getApplications() throws OpenShiftException {
@@ -55,16 +60,27 @@
firePropertyChange(PROPERTY_SELECTED_APPLICATION, this.selectedApplication, this.selectedApplication = application);
}
- public void destroyCurrentApplication() throws OpenShiftException {
- if (selectedApplication == null) {
- return;
- }
+ public IUser getUser() {
+ return OpenShiftUIActivator.getDefault().getUser();
+ }
- selectedApplication.destroy();
+ public boolean getUseExistingApplication() {
+ return this.useExistingApplication;
}
- public IUser getUser() {
- return OpenShiftUIActivator.getDefault().getUser();
+ public void setUseExistingApplication(boolean useExistingApplication) {
+ wizardModel.setUseExistingApplication(useExistingApplication);
+ firePropertyChange(PROPERTY_USE_EXISTING_APPLICATION, this.useExistingApplication, this.useExistingApplication = useExistingApplication);
+
}
+ public IStatus getExistingApplicationValidity() {
+ // TODO Auto-generated method stub
+ return Status.OK_STATUS;
+ }
+ public boolean hasApplication(String name) {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
}
Modified: trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ApplicationWizardPage.java
===================================================================
--- trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ApplicationWizardPage.java 2012-02-09 10:03:21 UTC (rev 38537)
+++ trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ApplicationWizardPage.java 2012-02-09 10:29:54 UTC (rev 38538)
@@ -124,7 +124,7 @@
private void createApplicationsGroup(Composite container, DataBindingContext dbc) {
Group applicationGroup = new Group(container, SWT.BORDER);
applicationGroup.setText("Available Applications");
- GridDataFactory.fillDefaults().grab(true, true).align(SWT.FILL, SWT.FILL).hint(400, 260).span(3, 1)
+ GridDataFactory.fillDefaults().grab(true, true).align(SWT.FILL, SWT.FILL).span(3, 1)
.applyTo(applicationGroup);
GridLayoutFactory.fillDefaults().numColumns(4).margins(6, 6).applyTo(applicationGroup);
Modified: trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/CreateNewApplicationWizard.java
===================================================================
--- trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/CreateNewApplicationWizard.java 2012-02-09 10:03:21 UTC (rev 38537)
+++ trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/CreateNewApplicationWizard.java 2012-02-09 10:29:54 UTC (rev 38538)
@@ -37,11 +37,12 @@
* @author Andre Dietisheim
* @author Xavier Coulon
*/
-public class CreateNewApplicationWizard extends AbstractOpenShiftApplicationWizard<CreateNewApplicationWizardModel>
+@Deprecated
+public class CreateNewApplicationWizard extends OpenShiftExpressApplicationWizard
implements INewWizard {
public CreateNewApplicationWizard() {
- setWizardModel(new CreateNewApplicationWizardModel());
+ setWizardModel(new OpenShiftExpressApplicationWizardModel());
setNeedsProgressMonitor(true);
}
@@ -60,7 +61,7 @@
// re-connect..
addPage(new CredentialsWizardPage(this));
}
- addPage(new ApplicationConfigurationWizardPage(this, getWizardModel()));
+ //addPage(new ApplicationConfigurationWizardPage(this, getWizardModel()));
addPage(new ProjectAndServerAdapterSettingsWizardPage(this, getWizardModel()));
addPage(new GitCloningSettingsWizardPage(this, getWizardModel()));
}
Modified: trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/CreateNewApplicationWizardModel.java
===================================================================
--- trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/CreateNewApplicationWizardModel.java 2012-02-09 10:03:21 UTC (rev 38537)
+++ trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/CreateNewApplicationWizardModel.java 2012-02-09 10:29:54 UTC (rev 38538)
@@ -15,7 +15,8 @@
import com.openshift.express.client.OpenShiftApplicationNotAvailableException;
import com.openshift.express.client.OpenShiftException;
-public class CreateNewApplicationWizardModel extends AbstractOpenShiftApplicationWizardModel {
+@Deprecated
+public class CreateNewApplicationWizardModel extends OpenShiftExpressApplicationWizardModel {
/**
* Timeout in seconds when trying to contact an application after it had been created.
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:03:21 UTC (rev 38537)
+++ trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/CredentialsWizardPage.java 2012-02-09 10:29:54 UTC (rev 38538)
@@ -61,13 +61,13 @@
private Text passwordText = null;
public CredentialsWizardPage(IWizard wizard) {
- super("Server connection", "Please provide your OpenShift Express user credentials, then click 'next'.", "Server Connection",
+ super("Server connection", "Please provide your OpenShift Express credentials.", "Server Connection",
wizard);
this.pageModel = new CredentialsWizardPageModel();
}
protected void doCreateControls(Composite container, DataBindingContext dbc) {
- GridLayoutFactory.fillDefaults().numColumns(3).margins(10, 10).applyTo(container);
+ 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"
@@ -82,7 +82,7 @@
rhLoginLabel.setText("&Username");
GridDataFactory.fillDefaults().align(SWT.LEFT, SWT.CENTER).applyTo(rhLoginLabel);
rhLoginText = new Text(container, SWT.BORDER);
- GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false).span(2, 1).applyTo(rhLoginText);
+ GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false).span(1, 1).applyTo(rhLoginText);
UIUtils.selectAllOnFocus(rhLoginText);
final IObservableValue rhLoginObservable = BeanProperties.value(CredentialsWizardPageModel.PROPERTY_RHLOGIN)
.observe(pageModel);
@@ -92,7 +92,7 @@
passwordLabel.setText("&Password");
GridDataFactory.fillDefaults().align(SWT.LEFT, SWT.CENTER).applyTo(passwordLabel);
passwordText = new Text(container, SWT.BORDER | SWT.PASSWORD);
- GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false).span(2, 1).applyTo(passwordText);
+ GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false).span(1, 1).applyTo(passwordText);
UIUtils.selectAllOnFocus(passwordText);
final IObservableValue passwordModelObservable = BeanProperties.value(CredentialsWizardPageModel.PROPERTY_PASSWORD)
.observe(pageModel);
@@ -109,7 +109,7 @@
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(3, 1).hint(SWT.DEFAULT, 30).applyTo(signupLink);
+ GridDataFactory.fillDefaults().align(SWT.LEFT, SWT.CENTER).span(2, 1).hint(SWT.DEFAULT, 30).applyTo(signupLink);
signupLink.addSelectionListener(onSignupLinkClicked());
}
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:03:21 UTC (rev 38537)
+++ trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/CredentialsWizardPageModel.java 2012-02-09 10:29:54 UTC (rev 38538)
@@ -16,6 +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 com.openshift.express.client.IUser;
import com.openshift.express.client.NotFoundOpenShiftException;
@@ -39,23 +43,62 @@
private String password;
private IStatus credentialsStatus;
private StringPreferenceValue rhLoginPreferenceValue;
+ private final String libraServer;
+ private SecurePasswordStore store;
+
public CredentialsWizardPageModel() {
this.rhLoginPreferenceValue = new StringPreferenceValue(RHLOGIN_PREFS_KEY, OpenShiftUIActivator.PLUGIN_ID);
+ this.libraServer = initLibraServer();
this.rhLogin = initRhLogin();
+ initSecureStore(libraServer, rhLogin);
+ this.password = initPassword();
resetCredentialsStatus();
}
+ private String initLibraServer() {
+ try {
+ return new OpenShiftConfiguration().getLibraServer();
+ } catch (Exception e) {
+ Logger.error("Failed to load OpenShift configuration from client library", e);
+ }
+ return null;
+ }
+
+ private SecurePasswordStore initSecureStore(final String platform, final String username) {
+ final OpenShiftPasswordStorageKey key = new OpenShiftPasswordStorageKey(platform, username);
+ store = new SecurePasswordStore(key);
+ return store;
+ }
+
protected String initRhLogin() {
String rhLogin = null;
rhLogin = rhLoginPreferenceValue.get();
- if (rhLogin == null
- || rhLogin.length() == 0) {
+ if (rhLogin == null || rhLogin.length() == 0) {
rhLogin = getUserConfiguration();
}
return rhLogin;
}
+ protected String initPassword() {
+ if (libraServer != null && rhLogin != null && !rhLogin.isEmpty() && store!= null) {
+ try {
+ return store.getPassword();
+ } 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);
+ } catch (SecurePasswordStoreException e) {
+ Logger.error(e.getMessage(), e);
+ }
+ }
+
protected String getUserConfiguration() {
String configuredUsername = null;
try {
@@ -71,8 +114,7 @@
}
public void setRhLogin(String rhLogin) {
- if (rhLogin != null
- && !rhLogin.equals(this.rhLogin)) {
+ if (rhLogin != null && !rhLogin.equals(this.rhLogin)) {
rhLoginPreferenceValue.store(rhLogin);
firePropertyChange(PROPERTY_RHLOGIN, this.rhLogin, this.rhLogin = rhLogin);
resetCredentialsStatus();
@@ -84,8 +126,7 @@
}
public void setPassword(String password) {
- if (password != null
- && !password.equals(this.password)) {
+ if (password != null && !password.equals(this.password)) {
firePropertyChange(PROPERTY_PASSWORD, this.password, this.password = password);
resetCredentialsStatus();
}
@@ -96,8 +137,7 @@
}
private void setCredentialsStatus(IStatus status) {
- firePropertyChange(PROPERTY_CREDENTIALS_STATUS, this.credentialsStatus,
- this.credentialsStatus = status);
+ firePropertyChange(PROPERTY_CREDENTIALS_STATUS, this.credentialsStatus, this.credentialsStatus = status);
}
public IStatus getCredentialsStatus() {
@@ -106,8 +146,7 @@
public boolean areCredentialsValid() {
IStatus validationStatus = getCredentialsStatus();
- return validationStatus != null
- && validationStatus.isOK();
+ return validationStatus != null && validationStatus.isOK();
}
public boolean areCredentialsValidated() {
@@ -120,14 +159,16 @@
// reset without notifying
// this.credentialsValidity = null;
IUser user = OpenShiftUIActivator.getDefault().createUser(getRhLogin(), getPassword());
- user.isValid();
+ if (user.isValid()) {
+ storePassword(password);
+ }
} catch (NotFoundOpenShiftException e) {
// valid user without domain
} catch (OpenShiftException e) {
status = new Status(IStatus.ERROR, OpenShiftUIActivator.PLUGIN_ID, "Your credentails are not valid.");
} catch (Exception e) {
- status = new Status(IStatus.ERROR, OpenShiftUIActivator.PLUGIN_ID,
- NLS.bind("Could not check user credentials: {0}.", e.getMessage()));
+ status = new Status(IStatus.ERROR, OpenShiftUIActivator.PLUGIN_ID, NLS.bind(
+ "Could not check user credentials: {0}.", e.getMessage()));
}
setCredentialsStatus(status);
Modified: trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/GitCloningSettingsWizardPage.java
===================================================================
--- trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/GitCloningSettingsWizardPage.java 2012-02-09 10:03:21 UTC (rev 38537)
+++ trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/GitCloningSettingsWizardPage.java 2012-02-09 10:29:54 UTC (rev 38538)
@@ -60,7 +60,7 @@
setPageComplete(false);
}
- public GitCloningSettingsWizardPage(ImportExistingApplicationWizard wizard, IOpenShiftWizardModel model) {
+ public GitCloningSettingsWizardPage(OpenShiftExpressApplicationWizard wizard, IOpenShiftWizardModel model) {
super(
"Import an existing OpenShift application",
"Configure the cloning settings by specifying the clone destination if you create a new project, and the git remote name if you're using an existing project.",
Modified: trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/GitCloningSettingsWizardPageModel.java
===================================================================
--- trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/GitCloningSettingsWizardPageModel.java 2012-02-09 10:03:21 UTC (rev 38537)
+++ trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/GitCloningSettingsWizardPageModel.java 2012-02-09 10:29:54 UTC (rev 38538)
@@ -15,6 +15,7 @@
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.ResourcesPlugin;
+
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Path;
@@ -29,7 +30,6 @@
import com.openshift.express.client.IApplication;
import com.openshift.express.client.ICartridge;
import com.openshift.express.client.OpenShiftException;
-
/**
* @author Andre Dietisheim
* @author Rob Stryker
Modified: trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/IOpenShiftWizardModel.java
===================================================================
--- trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/IOpenShiftWizardModel.java 2012-02-09 10:03:21 UTC (rev 38537)
+++ trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/IOpenShiftWizardModel.java 2012-02-09 10:29:54 UTC (rev 38538)
@@ -34,6 +34,7 @@
public static final String NEW_PROJECT = "enableProject";
public static final String USER = "user";
public static final String APPLICATION = "application";
+ public static final String USE_EXISTING_APPLICATION = "useExistingApplication";
public static final String REMOTE_NAME = "remoteName";
public static final String REPOSITORY_PATH = "repositoryPath";
public static final String PROJECT_NAME = "projectName";
@@ -178,4 +179,8 @@
public void setServerType(IServerType serverType);
+ public boolean isExistingApplication();
+
+ public void setUseExistingApplication(boolean useExistingApplication);
+
}
\ No newline at end of file
Deleted: trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ImportExistingApplicationWizard.java
===================================================================
--- trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ImportExistingApplicationWizard.java 2012-02-09 10:03:21 UTC (rev 38537)
+++ trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ImportExistingApplicationWizard.java 2012-02-09 10:29:54 UTC (rev 38538)
@@ -1,170 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2011 Red Hat, Inc.
- * Distributed under license by Red Hat, Inc. All rights reserved.
- * This program is made available under the terms of the
- * Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Red Hat, Inc. - initial API and implementation
- ******************************************************************************/
-package org.jboss.tools.openshift.express.internal.ui.wizard;
-
-import java.io.IOException;
-import java.lang.reflect.InvocationTargetException;
-import java.net.URISyntaxException;
-
-import org.eclipse.core.resources.WorkspaceJob;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.jface.dialogs.ErrorDialog;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jgit.errors.TransportException;
-import org.eclipse.osgi.util.NLS;
-import org.eclipse.ui.IImportWizard;
-import org.eclipse.ui.IWorkbench;
-import org.jboss.tools.common.ui.DelegatingProgressMonitor;
-import org.jboss.tools.common.ui.JobUtils;
-import org.jboss.tools.common.ui.WizardUtils;
-import org.jboss.tools.openshift.express.internal.ui.ImportFailedException;
-import org.jboss.tools.openshift.express.internal.ui.OpenShiftUIActivator;
-import org.jboss.tools.openshift.express.internal.ui.WontOverwriteException;
-
-import com.openshift.express.client.IUser;
-import com.openshift.express.client.OpenShiftException;
-
-/**
- * @author Andre Dietisheim
- * @author Xavier Coulon
- */
-public class ImportExistingApplicationWizard extends AbstractOpenShiftApplicationWizard<ImportExistingApplicationWizardModel> implements IImportWizard {
-
- public ImportExistingApplicationWizard() {
- super();
- }
-
- @Override
- public void init(IWorkbench workbench, IStructuredSelection selection) {
- setWindowTitle("OpenShift application wizard");
- setNeedsProgressMonitor(true);
- }
-
- @Override
- public boolean performFinish() {
- try {
- final DelegatingProgressMonitor delegatingMonitor = new DelegatingProgressMonitor();
- IStatus jobResult =
- WizardUtils.runInWizard(
- new ImportJob(delegatingMonitor),
- delegatingMonitor, getContainer());
- return JobUtils.isOk(jobResult);
- } catch (Exception e) {
- ErrorDialog.openError(getShell(), "Error", "Could not create local git repository.",
- new Status(IStatus.ERROR, OpenShiftUIActivator.PLUGIN_ID,
- "An exception occurred while creating local git repository.", e));
- return false;
- }
- }
-
- @Override
- public void addPages() {
- setWizardModel(new ImportExistingApplicationWizardModel());
- final IUser user = OpenShiftUIActivator.getDefault().getUser();
- try {
- if(user == null || !user.isValid()) {
- addPage(new CredentialsWizardPage(this));
- }
- } catch (OpenShiftException e) {
- // if the user's validity can't be checked, we may want to re-connect..
- addPage(new CredentialsWizardPage(this));
- }
- addPage(new ApplicationSelectionWizardPage(this, getWizardModel()));
- addPage(new ProjectAndServerAdapterSettingsWizardPage(this, getWizardModel()));
- addPage(new GitCloningSettingsWizardPage(this, getWizardModel()));
- }
-
- /**
- * A workspace job that will create a new project or enable the selected
- * project to be used with OpenShift.
- */
- private class ImportJob extends WorkspaceJob {
-
- private DelegatingProgressMonitor delegatingMonitor;
-
- public ImportJob(DelegatingProgressMonitor delegatingMonitor) {
- super("Importing project to workspace...");
- this.delegatingMonitor = delegatingMonitor;
- }
-
- @Override
- public IStatus runInWorkspace(IProgressMonitor monitor) throws CoreException {
- try {
- delegatingMonitor.add(monitor);
- ImportExistingApplicationWizardModel wizardModel = getWizardModel();
- if (wizardModel.isNewProject()) {
- wizardModel.importProject(delegatingMonitor);
- } else if (!wizardModel.isGitSharedProject()) {
- if (!askForConfirmation(
- NLS.bind("OpenShift application {0} will be enabled on project {1} by " +
- "copying OpenShift configuration and enabling Git for the project.\n " +
- "This cannot be undone. Do you wish to continue ?"
- , wizardModel.getApplicationName()
- , wizardModel.getProjectName()),
- wizardModel.getApplicationName())) {
- return Status.CANCEL_STATUS;
- }
- getWizardModel().configureUnsharedProject(delegatingMonitor);
- } else {
- if (!askForConfirmation(
- NLS.bind("OpenShift application {0} will be enabled on project {1} by copying OpenShift " +
- "configuration and adding the OpenShift git repo as remote.\n " +
- "This cannot be undone. Do you wish to continue ?"
- , wizardModel.getApplicationName()
- , wizardModel.getProjectName())
- , wizardModel.getApplicationName())) {
- return Status.CANCEL_STATUS;
- }
- wizardModel.configureGitSharedProject(delegatingMonitor);
- }
- return Status.OK_STATUS;
- } catch (final WontOverwriteException e) {
- openError("Project already present", e.getMessage());
- return Status.CANCEL_STATUS;
- } catch (final ImportFailedException e) {
- return OpenShiftUIActivator.createErrorStatus(
- "Could not import maven project {0}.", e,
- getWizardModel().getProjectName());
- } catch (IOException e) {
- return OpenShiftUIActivator.createErrorStatus(
- "Could not copy openshift configuration files to project {0}", e,
- getWizardModel().getProjectName());
- } catch (OpenShiftException e) {
- return OpenShiftUIActivator.createErrorStatus(
- "Could not import project to the workspace.", e);
- } catch (URISyntaxException e) {
- return OpenShiftUIActivator.createErrorStatus(
- "The url of the remote git repository is not valid", e);
- } catch (InvocationTargetException e) {
- if (isTransportException(e)) {
- TransportException te = getTransportException(e);
- return OpenShiftUIActivator
- .createErrorStatus(
- "Could not clone the repository. Authentication failed.\n"
- + " Please make sure that you added your private key to the ssh preferences.",
- te);
- } else {
- return OpenShiftUIActivator.createErrorStatus(
- "An exception occurred while creating local git repository.", e);
- }
- } catch (Exception e) {
- return OpenShiftUIActivator.createErrorStatus(
- "Could not import project to the workspace.", e);
- } finally {
- delegatingMonitor.done();
- }
- }
- }
-
-}
Deleted: trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ImportExistingApplicationWizardModel.java
===================================================================
--- trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ImportExistingApplicationWizardModel.java 2012-02-09 10:03:21 UTC (rev 38537)
+++ trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ImportExistingApplicationWizardModel.java 2012-02-09 10:29:54 UTC (rev 38538)
@@ -1,25 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2011 Red Hat, Inc.
- * Distributed under license by Red Hat, Inc. All rights reserved.
- * This program is made available under the terms of the
- * Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Red Hat, Inc. - initial API and implementation
- ******************************************************************************/
-package org.jboss.tools.openshift.express.internal.ui.wizard;
-
-
-
-
-/**
- * @author André Dietisheim <adietish(a)redhat.com>
- */
-public class ImportExistingApplicationWizardModel extends AbstractOpenShiftApplicationWizardModel {
-
- public ImportExistingApplicationWizardModel() {
- dataModel.put(NEW_PROJECT, false);
- }
-
-}
Copied: trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/OpenShiftExpressApplicationWizard.java (from rev 38461, trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ImportExistingApplicationWizard.java)
===================================================================
--- trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/OpenShiftExpressApplicationWizard.java (rev 0)
+++ trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/OpenShiftExpressApplicationWizard.java 2012-02-09 10:29:54 UTC (rev 38538)
@@ -0,0 +1,177 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.openshift.express.internal.ui.wizard;
+
+import java.io.IOException;
+import java.lang.reflect.InvocationTargetException;
+import java.net.URISyntaxException;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.WorkspaceJob;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.jface.dialogs.ErrorDialog;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jgit.errors.TransportException;
+import org.eclipse.osgi.util.NLS;
+import org.eclipse.ui.IImportWizard;
+import org.eclipse.ui.IWorkbench;
+import org.jboss.tools.common.ui.DelegatingProgressMonitor;
+import org.jboss.tools.common.ui.JobUtils;
+import org.jboss.tools.common.ui.WizardUtils;
+import org.jboss.tools.openshift.express.internal.ui.ImportFailedException;
+import org.jboss.tools.openshift.express.internal.ui.OpenShiftUIActivator;
+import org.jboss.tools.openshift.express.internal.ui.WontOverwriteException;
+
+import com.openshift.express.client.IApplication;
+import com.openshift.express.client.IUser;
+import com.openshift.express.client.OpenShiftException;
+
+/**
+ * @author Andre Dietisheim
+ * @author Xavier Coulon
+ */
+public class OpenShiftExpressApplicationWizard extends
+ AbstractOpenShiftApplicationWizard<OpenShiftExpressApplicationWizardModel> implements IImportWizard {
+
+ public OpenShiftExpressApplicationWizard() {
+ super();
+ setWizardModel(new OpenShiftExpressApplicationWizardModel());
+ }
+
+ public void setSelectedApplication(IApplication application) {
+ getWizardModel().setApplication(application);
+ }
+
+ public void setSelectedProject(IProject project) {
+ if (project != null && project.exists()) {
+ getWizardModel().setExistingProject(false);
+ getWizardModel().setProjectName(project.getName());
+ } else {
+ getWizardModel().setExistingProject(true);
+ getWizardModel().setProjectName(null);
+ }
+ }
+
+ @Override
+ public void init(IWorkbench workbench, IStructuredSelection selection) {
+ setWindowTitle("OpenShift Application Wizard");
+ setNeedsProgressMonitor(true);
+ }
+
+
+ @Override
+ public void addPages() {
+ final IUser user = OpenShiftUIActivator.getDefault().getUser();
+ try {
+ if (user == null || !user.isValid()) {
+ addPage(new CredentialsWizardPage(this));
+ }
+ } catch (OpenShiftException e) {
+ // if the user's validity can't be checked, we may want to re-connect..
+ addPage(new CredentialsWizardPage(this));
+ }
+ addPage(new ApplicationConfigurationWizardPage(this, getWizardModel()));
+ addPage(new ProjectAndServerAdapterSettingsWizardPage(this, getWizardModel()));
+ addPage(new GitCloningSettingsWizardPage(this, getWizardModel()));
+ }
+
+ @Override
+ public boolean performFinish() {
+ try {
+ final DelegatingProgressMonitor delegatingMonitor = new DelegatingProgressMonitor();
+ IStatus jobResult = WizardUtils.runInWizard(new ImportJob(delegatingMonitor), delegatingMonitor,
+ getContainer());
+ return JobUtils.isOk(jobResult);
+ } catch (Exception e) {
+ ErrorDialog.openError(getShell(), "Error", "Could not create local git repository.", new Status(
+ IStatus.ERROR, OpenShiftUIActivator.PLUGIN_ID,
+ "An exception occurred while creating local git repository.", e));
+ return false;
+ }
+ }
+
+ /**
+ * A workspace job that will create a new project or enable the selected project to be used with OpenShift.
+ */
+ class ImportJob extends WorkspaceJob {
+
+ private DelegatingProgressMonitor delegatingMonitor;
+
+ public ImportJob(DelegatingProgressMonitor delegatingMonitor) {
+ super("Importing project to workspace...");
+ this.delegatingMonitor = delegatingMonitor;
+ }
+
+ @Override
+ public IStatus runInWorkspace(IProgressMonitor monitor) throws CoreException {
+ try {
+ delegatingMonitor.add(monitor);
+ OpenShiftExpressApplicationWizardModel wizardModel = getWizardModel();
+ if (wizardModel.isNewProject()) {
+ wizardModel.importProject(delegatingMonitor);
+ } else if (!wizardModel.isGitSharedProject()) {
+ if (!askForConfirmation(
+ NLS.bind("OpenShift application {0} will be enabled on project {1} by "
+ + "copying OpenShift configuration and enabling Git for the project.\n "
+ + "This cannot be undone. Do you wish to continue ?",
+ wizardModel.getApplicationName(), wizardModel.getProjectName()),
+ wizardModel.getApplicationName())) {
+ return Status.CANCEL_STATUS;
+ }
+ getWizardModel().configureUnsharedProject(delegatingMonitor);
+ } else {
+ if (!askForConfirmation(
+ NLS.bind("OpenShift application {0} will be enabled on project {1} by copying OpenShift "
+ + "configuration and adding the OpenShift git repo as remote.\n "
+ + "This cannot be undone. Do you wish to continue ?",
+ wizardModel.getApplicationName(), wizardModel.getProjectName()),
+ wizardModel.getApplicationName())) {
+ return Status.CANCEL_STATUS;
+ }
+ wizardModel.configureGitSharedProject(delegatingMonitor);
+ }
+ return Status.OK_STATUS;
+ } catch (final WontOverwriteException e) {
+ openError("Project already present", e.getMessage());
+ return Status.CANCEL_STATUS;
+ } catch (final ImportFailedException e) {
+ return OpenShiftUIActivator.createErrorStatus("Could not import maven project {0}.", e,
+ getWizardModel().getProjectName());
+ } catch (IOException e) {
+ return OpenShiftUIActivator.createErrorStatus(
+ "Could not copy openshift configuration files to project {0}", e, getWizardModel()
+ .getProjectName());
+ } catch (OpenShiftException e) {
+ return OpenShiftUIActivator.createErrorStatus("Could not import project to the workspace.", e);
+ } catch (URISyntaxException e) {
+ return OpenShiftUIActivator.createErrorStatus("The url of the remote git repository is not valid", e);
+ } catch (InvocationTargetException e) {
+ if (isTransportException(e)) {
+ TransportException te = getTransportException(e);
+ return OpenShiftUIActivator.createErrorStatus(
+ "Could not clone the repository. Authentication failed.\n"
+ + " Please make sure that you added your private key to the ssh preferences.", te);
+ } else {
+ return OpenShiftUIActivator.createErrorStatus(
+ "An exception occurred while creating local git repository.", e);
+ }
+ } catch (Exception e) {
+ return OpenShiftUIActivator.createErrorStatus("Could not import project to the workspace.", e);
+ } finally {
+ delegatingMonitor.done();
+ }
+ }
+ }
+
+}
Property changes on: trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/OpenShiftExpressApplicationWizard.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Copied: trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/OpenShiftExpressApplicationWizardModel.java (from rev 38461, trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/AbstractOpenShiftApplicationWizardModel.java)
===================================================================
--- trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/OpenShiftExpressApplicationWizardModel.java (rev 0)
+++ trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/OpenShiftExpressApplicationWizardModel.java 2012-02-09 10:29:54 UTC (rev 38538)
@@ -0,0 +1,404 @@
+package org.jboss.tools.openshift.express.internal.ui.wizard;
+
+import java.io.File;
+import java.io.IOException;
+import java.lang.reflect.InvocationTargetException;
+import java.net.URISyntaxException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.osgi.util.NLS;
+import org.eclipse.wst.server.core.IRuntime;
+import org.eclipse.wst.server.core.IServerType;
+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.ui.OpenShiftUIActivator;
+import org.jboss.tools.openshift.express.internal.ui.messages.OpenShiftExpressUIMessages;
+import org.jboss.tools.openshift.express.internal.ui.wizard.appimport.ConfigureGitSharedProject;
+import org.jboss.tools.openshift.express.internal.ui.wizard.appimport.ConfigureUnsharedProject;
+import org.jboss.tools.openshift.express.internal.ui.wizard.appimport.ImportNewProject;
+import org.jboss.tools.openshift.express.internal.ui.wizard.appimport.ServerAdapterFactory;
+
+import com.openshift.express.client.IApplication;
+import com.openshift.express.client.ICartridge;
+import com.openshift.express.client.IEmbeddableCartridge;
+import com.openshift.express.client.IUser;
+import com.openshift.express.client.OpenShiftApplicationNotAvailableException;
+import com.openshift.express.client.OpenShiftException;
+
+public class OpenShiftExpressApplicationWizardModel extends ObservableUIPojo implements IOpenShiftWizardModel {
+
+ 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";
+
+
+ public OpenShiftExpressApplicationWizardModel() {
+ super();
+ // default value(s)
+ setNewProject(true);
+ setCreateServerAdapter(true);
+ setRepositoryPath(DEFAULT_REPOSITORY_PATH);
+ setRemoteName(NEW_PROJECT_REMOTE_NAME_DEFAULT);
+ setServerType(ServerCore.findServerType("org.jboss.tools.openshift.express.openshift.server.type"));
+ setPublicationMode(PUBLISH_SOURCE);
+ setUseExistingApplication(false);
+ }
+
+
+ /**
+ * Imports the project that the user has chosen into the workspace.
+ *
+ * @param monitor
+ * the monitor to report progress to
+ * @throws OpenShiftException
+ * @throws CoreException
+ * @throws InterruptedException
+ * @throws URISyntaxException
+ * @throws InvocationTargetException
+ */
+ @Override
+ public void importProject(IProgressMonitor monitor) throws OpenShiftException, CoreException, InterruptedException,
+ URISyntaxException, InvocationTargetException {
+ List<IProject> importedProjects = new ImportNewProject(getProjectName(), getApplication(), getRemoteName(),
+ getRepositoryFile()).execute(monitor);
+ createServerAdapter(monitor, importedProjects);
+ }
+
+ /**
+ * Enables the user chosen, unshared project to be used on the chosen
+ * OpenShift application. Clones the application git repository, copies the
+ * configuration files to the user project (in the workspace), shares the
+ * user project with git and creates the server adapter.
+ *
+ * @param monitor
+ * the monitor to report progress to
+ * @throws URISyntaxException
+ * The OpenShift application repository could not be cloned,
+ * because the uri it is located at is not a valid git uri
+ * @throws OpenShiftException
+ *
+ * @throws InvocationTargetException
+ * The OpenShift application repository could not be cloned, the
+ * clone operation failed.
+ * @throws InterruptedException
+ * The OpenShift application repository could not be cloned, the
+ * clone operation was interrupted.
+ * @throws IOException
+ * The configuration files could not be copied from the git
+ * clone to the user project
+ * @throws CoreException
+ * The user project could not be shared with the git
+ */
+ @Override
+ public void configureUnsharedProject(IProgressMonitor monitor)
+ throws OpenShiftException, InvocationTargetException, InterruptedException, IOException, CoreException,
+ URISyntaxException {
+ List<IProject> importedProjects = new ConfigureUnsharedProject(
+ getProjectName()
+ , getApplication()
+ , getRemoteName()
+ , OpenShiftUIActivator.getDefault().getUser())
+ .execute(monitor);
+ createServerAdapter(monitor, importedProjects);
+ }
+
+ /**
+ * Enables the user chosen, unshared project to be used on the chosen
+ * OpenShift application. Clones the application git repository, copies the
+ * configuration files to the user project (in the workspace), adds the
+ * appication git repo as remote and creates the server adapter.
+ *
+ * @param monitor
+ * the monitor to report progress to
+ * @throws URISyntaxException
+ * The OpenShift application repository could not be cloned,
+ * because the uri it is located at is not a valid git uri
+ * @throws OpenShiftException
+ *
+ * @throws InvocationTargetException
+ * The OpenShift application repository could not be cloned, the
+ * clone operation failed.
+ * @throws InterruptedException
+ * The OpenShift application repository could not be cloned, the
+ * clone operation was interrupted.
+ * @throws IOException
+ * The configuration files could not be copied from the git
+ * clone to the user project
+ * @throws CoreException
+ * The user project could not be shared with the git
+ */
+ @Override
+ public void configureGitSharedProject(IProgressMonitor monitor)
+ throws OpenShiftException, InvocationTargetException, InterruptedException, IOException, CoreException,
+ URISyntaxException {
+ List<IProject> importedProjects = new ConfigureGitSharedProject(
+ getProjectName()
+ , getApplication()
+ , getRemoteName()
+// , getUser())
+ , OpenShiftUIActivator.getDefault().getUser())
+ .execute(monitor);
+ createServerAdapter(monitor, importedProjects);
+ }
+
+ private void createServerAdapter(IProgressMonitor monitor, List<IProject> importedProjects)
+ throws OpenShiftException {
+ Assert.isTrue(importedProjects.size() > 0);
+ IProject project = importedProjects.get(0);
+ new ServerAdapterFactory().create(project, this, monitor);
+ }
+
+ @Override
+ public File getRepositoryFile() {
+ String repositoryPath = getRepositoryPath();
+ if (repositoryPath == null || repositoryPath.length() == 0) {
+ return null;
+ }
+ return new File(repositoryPath, getApplicationName());
+ }
+
+ @Override
+ public Object setProperty(String key, Object value) {
+ Object oldVal = dataModel.get(key);
+ dataModel.put(key, value);
+ firePropertyChange(key, oldVal, value);
+ return value;
+ }
+
+ @Override
+ public Object getProperty(String key) {
+ return dataModel.get(key);
+ }
+
+// @Override
+// public void setUser(IUser user) {
+// setProperty(USER, user);
+// OpenShiftUIActivator.getDefault().setUser(user);
+// }
+
+// @Override
+// public IUser getUser() {
+// return (IUser) getProperty(USER);
+// return OpenShiftUIActivator.getDefault().getUser();
+// }
+
+ @Override
+ public IApplication getApplication() {
+ return (IApplication) getProperty(APPLICATION);
+ }
+
+ @Override
+ public String getApplicationName() {
+ String applicationName = null;
+ IApplication application = getApplication();
+ if (application != null) {
+ applicationName = application.getName();
+ }
+ return applicationName;
+ }
+
+ @Override
+ public ICartridge getApplicationCartridge() {
+ ICartridge cartridge = null;
+ IApplication application = getApplication();
+ if (application != null) {
+ cartridge = application.getCartridge();
+ }
+ return cartridge;
+ }
+
+ @Override
+ public String getApplicationCartridgeName() {
+ String cartridgeName = null;
+ ICartridge cartridge = getApplicationCartridge();
+ if (cartridge != null) {
+ cartridgeName = cartridge.getName();
+ }
+ return cartridgeName;
+ }
+
+ @Override
+ public void setApplication(IApplication application) {
+ setProperty(APPLICATION, application);
+ if(application == null) {
+ setUseExistingApplication(false);
+ } else {
+ setUseExistingApplication(true);
+ }
+ }
+
+ @Override
+ public String setRemoteName(String remoteName) {
+ setProperty(REMOTE_NAME, remoteName);
+ return remoteName;
+ }
+
+ @Override
+ public String getRemoteName() {
+ return (String) getProperty(REMOTE_NAME);
+ }
+
+ @Override
+ public String setRepositoryPath(String repositoryPath) {
+ return (String) setProperty(REPOSITORY_PATH, repositoryPath);
+ }
+
+ @Override
+ public String getRepositoryPath() {
+ return (String) getProperty(REPOSITORY_PATH);
+ }
+
+ @Override
+ public boolean isNewProject() {
+ return (Boolean) getProperty(NEW_PROJECT);
+ }
+
+ @Override
+ public boolean isExistingProject() {
+ return !((Boolean) getProperty(NEW_PROJECT));
+ }
+
+ @Override
+ public Boolean setNewProject(boolean newProject) {
+ return (Boolean) setProperty(NEW_PROJECT, newProject);
+ }
+
+ @Override
+ public Boolean setExistingProject(boolean existingProject) {
+ return (Boolean) setProperty(NEW_PROJECT, !existingProject);
+ }
+
+ @Override
+ public String setProjectName(String projectName) {
+ return (String) setProperty(PROJECT_NAME, projectName);
+ }
+
+ @Override
+ public boolean isGitSharedProject() {
+ return EGitUtils.isSharedWithGit(getProject());
+ }
+
+ private IProject getProject() {
+ return ResourcesPlugin.getWorkspace().getRoot().getProject(getProjectName());
+ }
+ @Override
+ public Boolean setCreateServerAdapter(Boolean createServerAdapter) {
+ return (Boolean) setProperty(CREATE_SERVER_ADAPTER, createServerAdapter);
+ }
+
+ @Override
+ public String getProjectName() {
+ return (String) getProperty(PROJECT_NAME);
+ }
+
+ @Override
+ public String setMergeUri(String mergeUri) {
+ return (String) setProperty(MERGE_URI, mergeUri);
+ }
+
+ @Override
+ public String getMergeUri() {
+ return (String) getProperty(MERGE_URI);
+ }
+
+ @Override
+ public IRuntime getRuntime() {
+ return (IRuntime) getProperty(RUNTIME_DELEGATE);
+ }
+
+ @Override
+ public String getMode() {
+ return (String) getProperty(PUBLICATION_MODE);
+ }
+
+ @Override
+ public boolean isCreateServerAdapter() {
+ Boolean isCreateServer = (Boolean) getProperty(CREATE_SERVER_ADAPTER);
+ return isCreateServer != null && isCreateServer.booleanValue();
+ }
+
+ @Override
+ public IServerType getServerType() {
+ return (IServerType) getProperty(SERVER_TYPE);
+ }
+
+ @Override
+ public void setServerType(IServerType serverType) {
+ setProperty(SERVER_TYPE, serverType);
+ }
+
+ private void setPublicationMode(String mode) {
+ setProperty(PUBLICATION_MODE, mode);
+ }
+
+
+ @Override
+ public boolean isExistingApplication() {
+ return (Boolean) getProperty(USE_EXISTING_APPLICATION);
+ }
+
+
+ @Override
+ public void setUseExistingApplication(boolean useExistingApplication) {
+ setProperty(USE_EXISTING_APPLICATION, useExistingApplication);
+ }
+
+
+ private void waitForAccessible(IApplication application, IProgressMonitor monitor)
+ throws OpenShiftApplicationNotAvailableException, OpenShiftException {
+ // monitor.subTask("waiting for application to become accessible...");
+ if (!application.waitForAccessible(APP_CREATION_TIMEOUT * 1000)) {
+ throw new OpenShiftApplicationNotAvailableException(NLS.bind(
+ OpenShiftExpressUIMessages.HOSTNAME_NOT_ANSWERING, application.getApplicationUrl()));
+ }
+ }
+
+ IApplication createApplication(String name, ICartridge cartridge, IProgressMonitor monitor) throws OpenShiftApplicationNotAvailableException, OpenShiftException {
+ IUser user = OpenShiftUIActivator.getDefault().getUser();
+ if (user == null) {
+ throw new OpenShiftException("Could not create application, have no valid user credentials");
+ }
+ IApplication application = user.createApplication(name, cartridge);
+ waitForAccessible(application, monitor);
+ return application;
+ }
+
+ public void createApplication(IProgressMonitor monitor) throws OpenShiftApplicationNotAvailableException, OpenShiftException {
+ IApplication application = createApplication(getApplicationName(), getApplicationCartridge(), monitor);
+ setApplication(application);
+
+ }
+
+
+ public List<IEmbeddableCartridge> getSelectedEmbeddableCartridges() {
+ @SuppressWarnings("unchecked")
+ List<IEmbeddableCartridge> selectedEmbeddableCartridges = (List<IEmbeddableCartridge>) dataModel.get(SELECTED_EMBEDDABLE_CARTRIDGES);
+ if(selectedEmbeddableCartridges == null) {
+ selectedEmbeddableCartridges = new ArrayList<IEmbeddableCartridge>();
+ dataModel.put(SELECTED_EMBEDDABLE_CARTRIDGES, selectedEmbeddableCartridges);
+ }
+ return selectedEmbeddableCartridges;
+ }
+
+
+ public void setApplicationCartridge(ICartridge cartridge) {
+ // TODO Auto-generated method stub
+
+ }
+
+
+ public void setApplicationName(String applicationName) {
+ // TODO Auto-generated method stub
+
+ }
+
+}
\ No newline at end of file
Property changes on: trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/OpenShiftExpressApplicationWizardModel.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/ProjectAndServerAdapterSettingsWizardPage.java
===================================================================
--- trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ProjectAndServerAdapterSettingsWizardPage.java 2012-02-09 10:03:21 UTC (rev 38537)
+++ trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ProjectAndServerAdapterSettingsWizardPage.java 2012-02-09 10:29:54 UTC (rev 38538)
@@ -40,6 +40,7 @@
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Group;
+import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Text;
import org.eclipse.ui.dialogs.WorkingSetGroup;
import org.jboss.tools.common.ui.databinding.InvertingBooleanConverter;
@@ -77,12 +78,13 @@
// projectGroup.setText("Project");
GridDataFactory.fillDefaults().align(SWT.LEFT, SWT.CENTER).align(SWT.FILL, SWT.CENTER).grab(true, false)
.applyTo(projectGroup);
- GridLayoutFactory.fillDefaults().numColumns(5).margins(6, 6).applyTo(projectGroup);
+ GridLayoutFactory.fillDefaults().numColumns(3).margins(6, 6).applyTo(projectGroup);
- // new project radio button
- Button newProjectRadioBtn = new Button(projectGroup, SWT.RADIO);
+ // new project checkbox
+ Button newProjectRadioBtn = new Button(projectGroup, SWT.CHECK);
newProjectRadioBtn.setText("Create a new project");
- newProjectRadioBtn.setToolTipText("The project will have the name of the OpenShift application");
+ newProjectRadioBtn
+ .setToolTipText("The OpenShift application code will be pulled into the newly created project or merged into the selected one.");
newProjectRadioBtn.setFocus();
GridDataFactory.fillDefaults().span(3, 1).align(SWT.FILL, SWT.CENTER).grab(false, false)
.applyTo(newProjectRadioBtn);
@@ -93,16 +95,11 @@
dbc.bindValue(newProjectRadioBtnSelection, newProjectObservable);
// existing project
- Button existingProjectRadioBtn = new Button(projectGroup, SWT.RADIO);
- existingProjectRadioBtn.setText("Use an existing project");
- existingProjectRadioBtn
- .setToolTipText("The OpenShift application code will be merged into the existing project");
- GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).span(3, 1).grab(false, false)
- .applyTo(existingProjectRadioBtn);
- final ISWTObservableValue existingProjectRadioBtnSelection = WidgetProperties.selection().observe(
- existingProjectRadioBtn);
- ValueBindingBuilder.bind(existingProjectRadioBtnSelection).notUpdating(newProjectObservable)
- .converting(new InvertingBooleanConverter()).in(dbc);
+ Label existingProjectLabel = new Label(projectGroup, SWT.NONE);
+ existingProjectLabel.setText("Use the existing project");
+ GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).span(1, 1).grab(false, false)
+ .indent(10, 0).applyTo(existingProjectLabel);
+
existingProjectNameText = new Text(projectGroup, SWT.BORDER);
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).span(1, 1).grab(true, false)
.applyTo(existingProjectNameText);
@@ -115,7 +112,7 @@
ValueBindingBuilder.bind(WidgetProperties.enabled().observe(existingProjectNameText))
.notUpdating(newProjectObservable).converting(new InvertingBooleanConverter()).in(dbc);
// move focus to the project name text control when choosing the 'Use an existing project' option.
- existingProjectRadioBtn.addSelectionListener(new SelectionListener() {
+ newProjectRadioBtn.addSelectionListener(new SelectionListener() {
@Override
public void widgetSelected(SelectionEvent e) {
existingProjectNameText.setFocus();
Modified: trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/appimport/ImportProjectWizard.java
===================================================================
--- trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/appimport/ImportProjectWizard.java 2012-02-09 10:03:21 UTC (rev 38537)
+++ trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/appimport/ImportProjectWizard.java 2012-02-09 10:29:54 UTC (rev 38538)
@@ -37,13 +37,13 @@
import org.jboss.tools.openshift.express.internal.ui.wizard.AdapterWizardPage;
import org.jboss.tools.openshift.express.internal.ui.wizard.ApplicationWizardPage;
import org.jboss.tools.openshift.express.internal.ui.wizard.CreateNewApplicationWizard;
-import org.jboss.tools.openshift.express.internal.ui.wizard.ImportExistingApplicationWizard;
+import org.jboss.tools.openshift.express.internal.ui.wizard.OpenShiftExpressApplicationWizard;
import com.openshift.express.client.OpenShiftException;
/**
* @author André Dietisheim
- * @Deprecated: see the {@link CreateNewApplicationWizard} and the {@link ImportExistingApplicationWizard}
+ * @Deprecated: see the {@link CreateNewApplicationWizard} and the {@link OpenShiftExpressApplicationWizard}
*/
@Deprecated
public class ImportProjectWizard extends Wizard implements INewWizard {
Modified: trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/appimport/ImportProjectWizardModel.java
===================================================================
--- trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/appimport/ImportProjectWizardModel.java 2012-02-09 10:03:21 UTC (rev 38537)
+++ trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/appimport/ImportProjectWizardModel.java 2012-02-09 10:29:54 UTC (rev 38538)
@@ -28,7 +28,7 @@
import org.jboss.tools.openshift.egit.core.EGitUtils;
import org.jboss.tools.openshift.express.internal.ui.wizard.AdapterWizardPageModel;
import org.jboss.tools.openshift.express.internal.ui.wizard.CreateNewApplicationWizardModel;
-import org.jboss.tools.openshift.express.internal.ui.wizard.ImportExistingApplicationWizardModel;
+import org.jboss.tools.openshift.express.internal.ui.wizard.OpenShiftExpressApplicationWizardModel;
import com.openshift.express.client.IApplication;
import com.openshift.express.client.ICartridge;
@@ -37,7 +37,7 @@
/**
* @author André Dietisheim <adietish(a)redhat.com>
- * @Deprecated: see the {@link CreateNewApplicationWizardModel} and the {@link ImportExistingApplicationWizardModel}
+ * @Deprecated: see the {@link CreateNewApplicationWizardModel} and the {@link OpenShiftExpressApplicationWizardModel}
*/
@Deprecated
public class ImportProjectWizardModel extends ObservableUIPojo {
14 years, 2 months
JBoss Tools SVN: r38537 - in trunk/build/aggregate/bottests-site/tests/org.jboss.tools.drools.ui.bot.test/src/org/jboss/tools/drools/ui/bot/test: smoke and 1 other directory.
by jbosstools-commits@lists.jboss.org
Author: jgargula
Date: 2012-02-09 05:03:21 -0500 (Thu, 09 Feb 2012)
New Revision: 38537
Modified:
trunk/build/aggregate/bottests-site/tests/org.jboss.tools.drools.ui.bot.test/src/org/jboss/tools/drools/ui/bot/test/DroolsAllBotTests.java
trunk/build/aggregate/bottests-site/tests/org.jboss.tools.drools.ui.bot.test/src/org/jboss/tools/drools/ui/bot/test/smoke/DroolsViewsTest.java
trunk/build/aggregate/bottests-site/tests/org.jboss.tools.drools.ui.bot.test/src/org/jboss/tools/drools/ui/bot/test/smoke/GuvnorRepositoriesTest.java
trunk/build/aggregate/bottests-site/tests/org.jboss.tools.drools.ui.bot.test/src/org/jboss/tools/drools/ui/bot/test/smoke/RuleFlowTest.java
Log:
Added workingMemoryTest to DroolsViewsTest and added support for deleting legacy guvnor repository files
Modified: trunk/build/aggregate/bottests-site/tests/org.jboss.tools.drools.ui.bot.test/src/org/jboss/tools/drools/ui/bot/test/DroolsAllBotTests.java
===================================================================
--- trunk/build/aggregate/bottests-site/tests/org.jboss.tools.drools.ui.bot.test/src/org/jboss/tools/drools/ui/bot/test/DroolsAllBotTests.java 2012-02-09 09:54:13 UTC (rev 38536)
+++ trunk/build/aggregate/bottests-site/tests/org.jboss.tools.drools.ui.bot.test/src/org/jboss/tools/drools/ui/bot/test/DroolsAllBotTests.java 2012-02-09 10:03:21 UTC (rev 38537)
@@ -28,6 +28,7 @@
import org.jboss.tools.ui.bot.ext.RequirementAwareSuite;
import org.jboss.tools.ui.bot.ext.SWTTestExt;
import org.jboss.tools.ui.bot.ext.SWTUtilExt;
+import org.jboss.tools.ui.bot.ext.config.TestConfigurator;
import org.jboss.tools.ui.bot.ext.types.IDELabel;
import org.jboss.tools.ui.bot.ext.types.PerspectiveType;
import org.junit.AfterClass;
@@ -160,8 +161,31 @@
}
eclipse.openPerspective(PerspectiveType.JAVA);
eclipse.maximizeActiveShell();
+
+ // Removes legacy files after previous run
+ final String serverHome = TestConfigurator.currentConfig.getServer().runtimeHome;
+ if (serverHome != null) {
+ deleteGuvnorRepositoryIfExists(serverHome + "/bin/");
+ }
}
+ private static void deleteGuvnorRepositoryIfExists(final String pathToDirectoryWithRepository) {
+ delete(new File(pathToDirectoryWithRepository + "repository.xml"));
+ delete(new File(pathToDirectoryWithRepository + "repository"));
+ }
+
+ private static boolean delete(final File file) {
+ if (!file.exists()) {
+ return false;
+ }
+ if (file.isDirectory()) {
+ for (final String s : file.list()) {
+ delete(new File(file, s));
+ }
+ }
+ return file.delete();
+ }
+
public static boolean useExternalDroolsRuntime() {
return USE_EXTERNAL_DROOLS_RUNTIME;
}
Modified: trunk/build/aggregate/bottests-site/tests/org.jboss.tools.drools.ui.bot.test/src/org/jboss/tools/drools/ui/bot/test/smoke/DroolsViewsTest.java
===================================================================
--- trunk/build/aggregate/bottests-site/tests/org.jboss.tools.drools.ui.bot.test/src/org/jboss/tools/drools/ui/bot/test/smoke/DroolsViewsTest.java 2012-02-09 09:54:13 UTC (rev 38536)
+++ trunk/build/aggregate/bottests-site/tests/org.jboss.tools.drools.ui.bot.test/src/org/jboss/tools/drools/ui/bot/test/smoke/DroolsViewsTest.java 2012-02-09 10:03:21 UTC (rev 38537)
@@ -5,11 +5,14 @@
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
+import java.util.Set;
import org.eclipse.swt.widgets.Widget;
import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotEclipseEditor;
import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotView;
import org.eclipse.swtbot.swt.finder.exceptions.WidgetNotFoundException;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotMenu;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotTree;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem;
import org.jboss.tools.ui.bot.ext.SWTOpenExt;
import org.jboss.tools.ui.bot.ext.SWTTestExt;
@@ -19,6 +22,7 @@
import org.jboss.tools.ui.bot.ext.types.IDELabel;
import org.junit.After;
import org.junit.Before;
+import org.junit.Ignore;
import org.junit.Test;
/**
@@ -28,7 +32,7 @@
*/
public class DroolsViewsTest extends SWTTestExt {
- private static final String PROJECT_NAME = "droolsTest";
+ private static final String PROJECT_NAME = "droolsViewsTest";
private static final String RULES_FILE = "Sample.drl";
private static final String RULES_FILE_PATH = "src/main/rules";
private static final String JAVA_FILE = "DroolsTest.java";
@@ -45,18 +49,20 @@
@Before
public void setUp() {
if (isFirstTimeRun) {
- eclipse.closeAllEditors();
+ eclipse.closeAllEditors();
manageProject();
setUpOnce();
}
SWTBotTreeItem javaTreeItem = packageExplorer.selectTreeItem(JAVA_FILE, new String[] {PROJECT_NAME, JAVA_FILE_PATH, SAMPLE_TREE_NODE});
eclipse.debugTreeItemAsDroolsApplication(javaTreeItem);
- while (bot.waitForShell(IDELabel.Shell.PROGRESS_INFORMATION, 0) != null) {
- bot.sleep(Timing.time2S());
- }
+
if (isFirstTimeRun) {
eclipse.closeConfirmPerspectiveSwitchShellIfOpened(false, true);
+ } else {
+ while (bot.waitForShell(IDELabel.Shell.PROGRESS_INFORMATION, 0) != null) {
+ bot.sleep(Timing.time2S());
+ }
}
bot.sleep(Timing.time2S());
@@ -77,7 +83,7 @@
* and creates brand new project.
*/
private void manageProject() {
- packageExplorer.deleteAllProjects();
+ //packageExplorer.deleteAllProjects();
ManageDroolsProject.createDroolsProject(PROJECT_NAME);
Widget openingProjectWidget = null;
try {
@@ -102,6 +108,8 @@
public void tearDown() {
eclipse.closeView(IDELabel.View.AGENDA);
eclipse.closeView(IDELabel.View.GLOBAL_DATA);
+ eclipse.closeView(IDELabel.View.AUDIT);
+ eclipse.closeView(IDELabel.View.WORKING_MEMORY);
eclipse.finishDebug();
}
@@ -138,6 +146,7 @@
* Tests refreshing of Agenda view.
*/
@Test
+ @Ignore
public void refreshAgendaTest() {
openView(IDELabel.View.AGENDA);
eclipse.stepOver();
@@ -178,6 +187,99 @@
}
/**
+ * Test of Working Memory view
+ */
+ @Test
+ public void workingMemoryTest() {
+ openView(IDELabel.View.WORKING_MEMORY);
+
+ SWTBotTree workingMemoryTree = bot.tree();
+ assertEquals("Working memory tree was expected to have exactly 1 root item, but it had "
+ + workingMemoryTree.getAllItems().length + " root items.", 1, workingMemoryTree.getAllItems().length);
+
+ String rootItemText = workingMemoryTree.getAllItems()[0].getText();
+ assertNotNull(rootItemText);
+ assertTrue("Root item of working memory tree had unexpected text: " + rootItemText,
+ rootItemText.contains("DroolsTest$Message"));
+
+ List<String> treeItemsStrings = workingMemoryTree.expandNode(rootItemText).getNodes();
+ final int EXPECTED_ITEMS = 6;
+ assertEquals("There should be " + EXPECTED_ITEMS + " items but was " + treeItemsStrings.size(),
+ EXPECTED_ITEMS, treeItemsStrings.size());
+
+ String messageString = "message= \"Goodbye cruel world\"";
+ String statusString = "status= 1";
+ String[] itemsStrings = new String[] {"BYE= 2", "FINISH= 3","GOODBYE= 1", "HELLO= 0", messageString, statusString};
+ Set<String> expectedWorkingMemorySet = new HashSet<String>(EXPECTED_ITEMS);
+ for (int i = 0; i < itemsStrings.length; i++) {
+ expectedWorkingMemorySet.add(itemsStrings[i]);
+ }
+ assertEquals(expectedWorkingMemorySet, getWorkingMemoryItems(rootItemText));
+
+ eclipse.resumeDebug();
+ expectedWorkingMemorySet.remove(messageString);
+ expectedWorkingMemorySet.remove(statusString);
+ messageString = "message= \"JustBye rule\"";
+ statusString = "status= 3";
+ expectedWorkingMemorySet.add(messageString);
+ expectedWorkingMemorySet.add(statusString);
+ assertEquals(expectedWorkingMemorySet, getWorkingMemoryItems(rootItemText));
+
+ eclipse.resumeDebug();
+ expectedWorkingMemorySet.clear();
+ showView(IDELabel.View.CONSOLE);
+ showView(IDELabel.View.WORKING_MEMORY);
+ assertEquals("Working memory view should be empty. Maybe it was not refreshed.",
+ expectedWorkingMemorySet, getWorkingMemoryItems(rootItemText));
+ }
+
+ /**
+ * Gets working memory items from Working Memory view.
+ *
+ * @param rootNode Root node name
+ * @return Set of strings representing working memory items.
+ */
+ private Set<String> getWorkingMemoryItems(final String rootNode) {
+ waitForStoppingDebugging();
+ showView(IDELabel.View.WORKING_MEMORY);
+ Set<String> stringSet = new HashSet<String>();
+
+ List<String> nodesStrings = null;
+ try {
+ nodesStrings = bot.tree().expandNode(rootNode).getNodes();
+ } catch (WidgetNotFoundException wnfe) {
+ return stringSet;
+ }
+
+ for (String s : nodesStrings) {
+ final int index = s.indexOf('(');
+ if (index > 0) {
+ s = s.substring(0, index);
+ }
+ stringSet.add(s.trim());
+ }
+
+ return stringSet;
+ }
+
+ /**
+ * Waits while debugging is stopped at breakpoint or finished.
+ */
+ private void waitForStoppingDebugging() {
+ for (int i = 0; i < 20; i++) {
+ SWTBotMenu resumeMenu = bot.menu(IDELabel.Menu.RUN).menu(IDELabel.Menu.RESUME);
+ if (resumeMenu.isEnabled()) {
+ return;
+ }
+ SWTBotMenu terminateMenu = bot.menu(IDELabel.Menu.RUN).menu(IDELabel.Menu.TERMINATE);
+ if (!resumeMenu.isEnabled() && !terminateMenu.isEnabled()) {
+ return;
+ }
+ bot.sleep(Timing.time1S());
+ }
+ }
+
+ /**
* Adds some pieces of code to DroolsTest.java
*/
private void adjustDroolsTestFile() {
@@ -252,10 +354,14 @@
private void showView(final String viewTitle) {
checkViewTitleNull(viewTitle);
boolean isViewOpened = false;
- for (SWTBotView view : bot.views()) {
+ for (final SWTBotView view : bot.views()) {
if (viewTitle.equals(view.getTitle())) {
- view.show();
- view.setFocus();
+ view.getWidget().getDisplay().syncExec(new Runnable() {
+ public void run() {
+ view.show();
+ view.setFocus();
+ }
+ });
isViewOpened = true;
break;
}
Modified: trunk/build/aggregate/bottests-site/tests/org.jboss.tools.drools.ui.bot.test/src/org/jboss/tools/drools/ui/bot/test/smoke/GuvnorRepositoriesTest.java
===================================================================
--- trunk/build/aggregate/bottests-site/tests/org.jboss.tools.drools.ui.bot.test/src/org/jboss/tools/drools/ui/bot/test/smoke/GuvnorRepositoriesTest.java 2012-02-09 09:54:13 UTC (rev 38536)
+++ trunk/build/aggregate/bottests-site/tests/org.jboss.tools.drools.ui.bot.test/src/org/jboss/tools/drools/ui/bot/test/smoke/GuvnorRepositoriesTest.java 2012-02-09 10:03:21 UTC (rev 38537)
@@ -31,6 +31,10 @@
import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem;
import org.hamcrest.Matcher;
import org.jboss.tools.drools.ui.bot.test.DroolsAllBotTests;
+import org.jboss.tools.ui.bot.ext.SWTEclipseExt;
+import org.jboss.tools.ui.bot.ext.SWTTestExt;
+import org.jboss.tools.ui.bot.ext.SWTUtilExt;
+import org.jboss.tools.ui.bot.ext.Timing;
import org.jboss.tools.ui.bot.ext.config.Annotations.Require;
import org.jboss.tools.ui.bot.ext.config.Annotations.Server;
import org.jboss.tools.ui.bot.ext.config.Annotations.ServerState;
@@ -48,10 +52,6 @@
import org.jboss.tools.ui.bot.ext.types.JobName;
import org.jboss.tools.ui.bot.ext.types.PerspectiveType;
import org.jboss.tools.ui.bot.ext.view.GuvnorRepositories;
-import org.jboss.tools.ui.bot.ext.SWTEclipseExt;
-import org.jboss.tools.ui.bot.ext.SWTTestExt;
-import org.jboss.tools.ui.bot.ext.SWTUtilExt;
-import org.jboss.tools.ui.bot.ext.Timing;
import org.junit.Test;
/**
* Tests Guvnor Repositories
@@ -131,6 +131,7 @@
assertTrue("Guvnor repository was not deleted properly",
guvnorRepositoriesBot.tree().rowCount() == 0);
}
+
/**
* Opens Guvnor Console
*/
Modified: trunk/build/aggregate/bottests-site/tests/org.jboss.tools.drools.ui.bot.test/src/org/jboss/tools/drools/ui/bot/test/smoke/RuleFlowTest.java
===================================================================
--- trunk/build/aggregate/bottests-site/tests/org.jboss.tools.drools.ui.bot.test/src/org/jboss/tools/drools/ui/bot/test/smoke/RuleFlowTest.java 2012-02-09 09:54:13 UTC (rev 38536)
+++ trunk/build/aggregate/bottests-site/tests/org.jboss.tools.drools.ui.bot.test/src/org/jboss/tools/drools/ui/bot/test/smoke/RuleFlowTest.java 2012-02-09 10:03:21 UTC (rev 38537)
@@ -31,13 +31,16 @@
import org.eclipse.swtbot.eclipse.gef.finder.SWTGefBot;
import org.eclipse.swtbot.eclipse.gef.finder.widgets.SWTBotGefEditor;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotCheckBox;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotTree;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem;
import org.jboss.tools.drools.ui.bot.test.DroolsAllBotTests;
import org.jboss.tools.ui.bot.ext.SWTEclipseExt;
+import org.jboss.tools.ui.bot.ext.SWTOpenExt;
import org.jboss.tools.ui.bot.ext.SWTTestExt;
import org.jboss.tools.ui.bot.ext.SWTUtilExt;
import org.jboss.tools.ui.bot.ext.Timing;
+import org.jboss.tools.ui.bot.ext.gen.ActionItem;
import org.jboss.tools.ui.bot.ext.helper.KeyboardHelper;
import org.jboss.tools.ui.bot.ext.types.IDELabel;
import org.jboss.tools.ui.bot.ext.types.ViewType;
@@ -68,15 +71,32 @@
private boolean isEditorMaximized = false;
- /**
- * Tests Rule Flow
- */
- @Test
- public void testRuleFlow() {
- runRuleFlowCheck(DroolsAllBotTests.RULE_FLOW_JAVA_TEST_FILE_NAME);
- ruleFlowEditorCheck(DroolsAllBotTests.RULE_FLOW_FILE_NAME);
- }
+ /**
+ * Tests Rule Flow
+ */
+ @Test
+ public void testRuleFlow() {
+ runRuleFlowCheck(DroolsAllBotTests.RULE_FLOW_JAVA_TEST_FILE_NAME);
+ ruleFlowEditorCheck(DroolsAllBotTests.RULE_FLOW_FILE_NAME);
+ }
+ /**
+ * Sets all drools flow nodes.
+ */
+ @SuppressWarnings("unused")
+ private void setAllDroolsFlowNodes() {
+ new SWTOpenExt(bot).preferenceOpen(ActionItem.Preference.DroolsDroolsFlownodes.LABEL);
+ bot.waitForShell(IDELabel.Shell.PREFERENCES);
+ for (SWTBotCheckBox checkBox : bot.checkBoxes()) {
+ if (checkBox.isEnabled()) {
+ checkBox.select();
+ }
+ }
+ bot.button(IDELabel.Button.OK).click();
+ bot.waitForShell(IDELabel.Shell.WARNING);
+ bot.button(IDELabel.Button.OK).click();
+ }
+
/**
* Runs newly created Drools project and check result
* @param droolsProjectName
14 years, 2 months
JBoss Tools SVN: r38536 - trunk/ws/plugins/org.jboss.tools.ws.jaxrs.ui.
by jbosstools-commits@lists.jboss.org
Author: xcoulon
Date: 2012-02-09 04:54:13 -0500 (Thu, 09 Feb 2012)
New Revision: 38536
Modified:
trunk/ws/plugins/org.jboss.tools.ws.jaxrs.ui/plugin.xml
Log:
patch applied - https://issues.jboss.org/browse/JBIDE-10285 (was missing a piece of code)
Modified: trunk/ws/plugins/org.jboss.tools.ws.jaxrs.ui/plugin.xml
===================================================================
--- trunk/ws/plugins/org.jboss.tools.ws.jaxrs.ui/plugin.xml 2012-02-09 09:51:39 UTC (rev 38535)
+++ trunk/ws/plugins/org.jboss.tools.ws.jaxrs.ui/plugin.xml 2012-02-09 09:54:13 UTC (rev 38536)
@@ -317,4 +317,15 @@
</extension-->
<!-- see https://bugs.eclipse.org/bugs/show_bug.cgi?id=338898 -->
+ <extension point="org.eclipse.wst.server.core.moduleArtifactAdapters">
+ <moduleArtifactAdapter
+ id="org.jboss.tools.ws.jaxrs.ui.jaxrsartifactadapter"
+ class="org.jboss.tools.ws.jaxrs.ui.internal.utils.JaxrsPathModuleArtifactAdapter">
+ <enablement>
+ <with variable="selection">
+ <adapt type="org.jboss.tools.ws.jaxrs.ui.cnf.UriPathTemplateElement"/>
+ </with>
+ </enablement>
+ </moduleArtifactAdapter>
+ </extension>
</plugin>
14 years, 2 months
JBoss Tools SVN: r38535 - trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test.
by jbosstools-commits@lists.jboss.org
Author: ljelinko
Date: 2012-02-09 04:51:39 -0500 (Thu, 09 Feb 2012)
New Revision: 38535
Modified:
trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/pom.xml
Log:
Add the possibility to parametrize test class from outside
Modified: trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/pom.xml
===================================================================
--- trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/pom.xml 2012-02-09 09:49:51 UTC (rev 38534)
+++ trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/pom.xml 2012-02-09 09:51:39 UTC (rev 38535)
@@ -17,6 +17,7 @@
<jbosstools.test.jboss-seam.home>${requirement.build.root}/jboss-seam-2.2.1.CR2</jbosstools.test.jboss-seam.home> <!--TODO setup default path -->
<configurations.dir>resources/project_config_files</configurations.dir>
<systemProperties>-Djbosstools.test.jboss-gatein.home=${jbosstools.test.jboss-gatein.home} -Djbosstools.test.jboss-seam.home=${jbosstools.test.jboss-seam.home} -Dtest.configurations.dir=${configurations.dir} -Dorg.eclipse.swtbot.screenshots.dir=${project.build.outputDirectory}/screenshots</systemProperties>
+ <test.class>org.jboss.tools.portlet.ui.bot.test.AllTestsSuite</test.class>
</properties>
<build>
@@ -27,7 +28,7 @@
<configuration>
<useUIThread>false</useUIThread>
<testSuite>org.jboss.tools.portlet.ui.bot.test</testSuite>
- <testClass>org.jboss.tools.portlet.ui.bot.test.AllTestsSuite</testClass>
+ <testClass>${test.class}</testClass>
<skip>${swtbot.test.skip}</skip>
<dependencies combine.children="append">
<dependency>
14 years, 2 months
JBoss Tools SVN: r38534 - 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 04:49:51 -0500 (Thu, 09 Feb 2012)
New Revision: 38534
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/MavenAllBotTests.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 08:54:27 UTC (rev 38533)
+++ trunk/maven/tests/org.jboss.tools.maven.ui.bot.test/src/org/jboss/tools/maven/ui/bot/test/Configurators.java 2012-02-09 09:49:51 UTC (rev 38534)
@@ -72,6 +72,7 @@
addDependencies(PROJECT_NAME_JSF, "com.sun.faces", "mojarra-jsf-api", "2.0.0-b04");
assertTrue("Project "+PROJECT_NAME_JSF+" doesn't have "+JSF_NATURE+" nature",Utils.hasNature(PROJECT_NAME_JSF, JSF_NATURE));
clean();
+ /*
createMavenizedDynamicWebProject(PROJECT_NAME_JSF, false);
addFacesConf(PROJECT_NAME_JSF);
assertTrue("Project "+PROJECT_NAME_JSF+" doesn't have "+JSF_NATURE+" nature",Utils.hasNature(PROJECT_NAME_JSF, JSF_NATURE));
@@ -84,9 +85,9 @@
clean();
createMavenizedDynamicWebProject(PROJECT_NAME_JSF, true);
assertTrue("Project "+PROJECT_NAME_JSF+" doesn't have "+JSF_NATURE+" nature",Utils.hasNature(PROJECT_NAME_JSF, JSF_NATURE));
+ */
-
}
@@ -193,11 +194,11 @@
}
private void addDependencies(String projectName, String groupId, String artifactId, String version) throws Exception{
- IMavenProjectFacade facade = MavenPlugin.getMavenProjectRegistry().getMavenProject("org.jboss.tools", projectName,"0.0.1-SNAPSHOT");
+ IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
DocumentBuilder docBuilder = factory.newDocumentBuilder();
- Document docPom = docBuilder.parse(facade.getProject().getFile("pom.xml").getContents());
+ Document docPom = docBuilder.parse(project.getProject().getFile("pom.xml").getContents());
Element dependenciesElement = docPom.createElement("dependencies");
Element dependencyElement = docPom.createElement("dependency");
Element groupIdElement = docPom.createElement("groupId");
@@ -220,7 +221,7 @@
StreamResult result = new StreamResult(xmlAsWriter);
DOMSource source = new DOMSource(docPom);
trans.transform(source, result);
- facade.getProject().getFile("pom.xml").setContents(new ByteArrayInputStream(xmlAsWriter.toString().getBytes("UTF-8")), 0, null);
+ project.getProject().getFile("pom.xml").setContents(new ByteArrayInputStream(xmlAsWriter.toString().getBytes("UTF-8")), 0, null);
botUtil.waitForAll();
updateConf(projectName);
}
@@ -262,11 +263,11 @@
}
private void addServlet(String projectName, String servletName, String servletClass, String load) throws Exception{
- IMavenProjectFacade facade = MavenPlugin.getMavenProjectRegistry().getMavenProject("org.jboss.tools", projectName,"0.0.1-SNAPSHOT");
+ IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
DocumentBuilder docBuilder = factory.newDocumentBuilder();
- Document docPom = docBuilder.parse(facade.getProject().getFile("web.xml").getContents());
+ Document docPom = docBuilder.parse(project.getProject().getFile("web.xml").getContents());
Element servletElement = docPom.createElement("servlet");
Element servletNameElement = docPom.createElement("servlet-name");
Element servletClassElement = docPom.createElement("servlet-class");
@@ -287,7 +288,7 @@
StreamResult result = new StreamResult(xmlAsWriter);
DOMSource source = new DOMSource(docPom);
trans.transform(source, result);
- facade.getProject().getFile("pom.xml").setContents(new ByteArrayInputStream(xmlAsWriter.toString().getBytes("UTF-8")), 0, null);
+ project.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/MavenAllBotTests.java
===================================================================
--- trunk/maven/tests/org.jboss.tools.maven.ui.bot.test/src/org/jboss/tools/maven/ui/bot/test/MavenAllBotTests.java 2012-02-09 08:54:27 UTC (rev 38533)
+++ trunk/maven/tests/org.jboss.tools.maven.ui.bot.test/src/org/jboss/tools/maven/ui/bot/test/MavenAllBotTests.java 2012-02-09 09:49:51 UTC (rev 38534)
@@ -24,9 +24,9 @@
CreateMavenizedSeamProjectTest.class,
CreateMavenizedEARProjectTest.class,
CreateMavenizedJSFProjectTest.class,
- MavenProfileSelectionTest.class, //failures
+ //MavenProfileSelectionTest.class, //failures
MaterializeLibraryTest.class,
- CreateMavenProjectsTest.class,
+ //CreateMavenProjectsTest.class,
Configurators.class
})
public class MavenAllBotTests {
14 years, 2 months
JBoss Tools SVN: r38533 - trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/test.
by jbosstools-commits@lists.jboss.org
Author: ljelinko
Date: 2012-02-09 03:54:27 -0500 (Thu, 09 Feb 2012)
New Revision: 38533
Added:
trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/test/StopServer.java
Modified:
trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/test/AllTestsSuite.java
Log:
Added temporary test to debug jenkins
Modified: trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/test/AllTestsSuite.java
===================================================================
--- trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/test/AllTestsSuite.java 2012-02-09 08:50:31 UTC (rev 38532)
+++ trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/test/AllTestsSuite.java 2012-02-09 08:54:27 UTC (rev 38533)
@@ -44,7 +44,8 @@
SeamPortletExampleRuntime4x.class,
JSFPortletExampleRuntime5x.class,
RichFacesPortletExampleRuntime5x.class,
- SeamPortletExampleRuntime5x.class
+ SeamPortletExampleRuntime5x.class,
+ StopServer.class
})
public class AllTestsSuite {
Added: trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/test/StopServer.java
===================================================================
--- trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/test/StopServer.java (rev 0)
+++ trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/test/StopServer.java 2012-02-09 08:54:27 UTC (rev 38533)
@@ -0,0 +1,17 @@
+package org.jboss.tools.portlet.ui.bot.test;
+
+import org.jboss.tools.portlet.ui.bot.test.testcase.SWTTaskBasedTestCase;
+import org.jboss.tools.ui.bot.ext.config.Annotations.Require;
+import org.jboss.tools.ui.bot.ext.config.Annotations.Seam;
+import org.jboss.tools.ui.bot.ext.config.Annotations.Server;
+import org.jboss.tools.ui.bot.ext.config.Annotations.ServerState;
+import org.junit.Test;
+
+@Require(server=@Server(version="5.1.0", state=ServerState.NotRunning), seam=@Seam)
+public class StopServer extends SWTTaskBasedTestCase {
+
+ @Test
+ public void testStop(){
+ System.out.println("Stopping ++++++++++++++++");
+ }
+}
14 years, 2 months
JBoss Tools SVN: r38532 - trunk/maven/plugins/org.jboss.tools.maven.jsf/src/org/jboss/tools/maven/jsf/configurators.
by jbosstools-commits@lists.jboss.org
Author: fbricon
Date: 2012-02-09 03:50:31 -0500 (Thu, 09 Feb 2012)
New Revision: 38532
Modified:
trunk/maven/plugins/org.jboss.tools.maven.jsf/src/org/jboss/tools/maven/jsf/configurators/JSFProjectConfigurator.java
trunk/maven/plugins/org.jboss.tools.maven.jsf/src/org/jboss/tools/maven/jsf/configurators/JSFUtils.java
Log:
JBIDE-10785 : refresh parent to prevent o.o.s.p.BackingStoreException: Resource '/parent/web/.settings' does not exist.
Modified: trunk/maven/plugins/org.jboss.tools.maven.jsf/src/org/jboss/tools/maven/jsf/configurators/JSFProjectConfigurator.java
===================================================================
--- trunk/maven/plugins/org.jboss.tools.maven.jsf/src/org/jboss/tools/maven/jsf/configurators/JSFProjectConfigurator.java 2012-02-09 07:02:27 UTC (rev 38531)
+++ trunk/maven/plugins/org.jboss.tools.maven.jsf/src/org/jboss/tools/maven/jsf/configurators/JSFProjectConfigurator.java 2012-02-09 08:50:31 UTC (rev 38532)
@@ -44,6 +44,7 @@
import org.eclipse.wst.common.project.facet.core.IProjectFacetVersion;
import org.eclipse.wst.common.project.facet.core.ProjectFacetsManager;
import org.jboss.tools.maven.core.IJBossMavenConstants;
+import org.jboss.tools.maven.core.MavenUtil;
import org.jboss.tools.maven.core.ProjectUtil;
import org.jboss.tools.maven.core.internal.project.facet.MavenFacetInstallDataModelProvider;
import org.jboss.tools.maven.jsf.MavenJSFActivator;
@@ -171,6 +172,11 @@
markerManager.deleteMarkers(fproj.getProject(), MavenJSFConstants.JSF_CONFIGURATION_ERROR_MARKER_ID);
if (!fproj.hasProjectFacet(JSF_FACET)) {
+
+ //JBIDE-10785 : refresh parent to prevent
+ // org.osgi.service.prefs.BackingStoreException: Resource '/parent/web/.settings' does not exist.
+ MavenUtil.refreshParent(mavenProject);
+
String warSourceDir = getWarSourceDirectory(mavenProject,fproj.getProject());
String facesConfigPath = "WEB-INF/faces-config.xml";
IFile facesConfig = fproj.getProject().getFolder(warSourceDir).getFile(facesConfigPath);
Modified: trunk/maven/plugins/org.jboss.tools.maven.jsf/src/org/jboss/tools/maven/jsf/configurators/JSFUtils.java
===================================================================
--- trunk/maven/plugins/org.jboss.tools.maven.jsf/src/org/jboss/tools/maven/jsf/configurators/JSFUtils.java 2012-02-09 07:02:27 UTC (rev 38531)
+++ trunk/maven/plugins/org.jboss.tools.maven.jsf/src/org/jboss/tools/maven/jsf/configurators/JSFUtils.java 2012-02-09 08:50:31 UTC (rev 38532)
@@ -36,7 +36,9 @@
public class JSFUtils {
public static final String FACES_SERVLET = "javax.faces.webapp.FacesServlet";
-
+
+ private static final String FACES_SERVLET_XPATH = "//servlet[servlet-class=\"" + FACES_SERVLET + "\"]";
+
public static final String JSF_VERSION_2_0 = "2.0";
public static final String JSF_VERSION_1_2 = "1.2";
@@ -108,8 +110,7 @@
Document doc = builder.parse(input);
XPath xpath = XPathFactory.newInstance().newXPath();
- String expression = "//servlet[servlet-class=\"" + FACES_SERVLET + "\"]";
- XPathExpression expr = xpath.compile(expression);
+ XPathExpression expr = xpath.compile(FACES_SERVLET_XPATH);
hasFacesServlet = null != expr.evaluate(doc, XPathConstants.NODE);
} catch (Exception e) {
Activator.log("An error occured trying to find to "+FACES_SERVLET+" :"+e.getMessage());
14 years, 2 months
JBoss Tools SVN: r38531 - trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/types.
by jbosstools-commits@lists.jboss.org
Author: jgargula
Date: 2012-02-09 02:02:27 -0500 (Thu, 09 Feb 2012)
New Revision: 38531
Modified:
trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/types/IDELabel.java
Log:
Added string for Console view
Modified: trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/types/IDELabel.java
===================================================================
--- trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/types/IDELabel.java 2012-02-09 03:22:51 UTC (rev 38530)
+++ trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/types/IDELabel.java 2012-02-09 07:02:27 UTC (rev 38531)
@@ -273,6 +273,7 @@
public static final String DATA_SOURCE_EXPLORER = "Data Source Explorer";
public static final String SERVERS = "Servers";
public static final String WEB_PROJECTS = "Web Projects";
+ public static final String CONSOLE = "Console";
public static final String PROBLEMS = "Problems";
public static final String DEBUG = "Debug";
public static final String GUVNOR_REPOSITORIES = "Guvnor Repositories";
14 years, 2 months
JBoss Tools SVN: r38530 - in trunk/documentation/guides/GettingStartedGuide/en-US: images/getting_started and 1 other directory.
by jbosstools-commits@lists.jboss.org
Author: irooskov(a)redhat.com
Date: 2012-02-08 22:22:51 -0500 (Wed, 08 Feb 2012)
New Revision: 38530
Added:
trunk/documentation/guides/GettingStartedGuide/en-US/images/getting_started/jboss_central_13.png
trunk/documentation/guides/GettingStartedGuide/en-US/images/getting_started/jboss_central_14.png
trunk/documentation/guides/GettingStartedGuide/en-US/images/getting_started/jboss_central_15.png
trunk/documentation/guides/GettingStartedGuide/en-US/images/getting_started/jboss_central_icon_07.png
Modified:
trunk/documentation/guides/GettingStartedGuide/en-US/getting_started.xml
Log:
updated with new information for jboss central
Modified: trunk/documentation/guides/GettingStartedGuide/en-US/getting_started.xml
===================================================================
--- trunk/documentation/guides/GettingStartedGuide/en-US/getting_started.xml 2012-02-09 02:06:21 UTC (rev 38529)
+++ trunk/documentation/guides/GettingStartedGuide/en-US/getting_started.xml 2012-02-09 03:22:51 UTC (rev 38530)
@@ -130,6 +130,11 @@
</imageobject>
</mediaobject>
</figure>
+ <section>
+ <title>Getting Started with JBoss Central</title>
+ <para>
+ The <guilabel>Getting Started</guilabel> tab of JBoss Central is the first you will see upon launching the JBoss Developer Studio and is setup as a functional starting point for developers.
+ </para>
<para>
At the top of the tab is a search box. By clicking the down arrow to the left you can select to perform a search on either the <guimenuitem>Red Hat Customer Portal</guimenuitem> or the <guimenuitem>JBoss Community</guimenuitem>.
</para>
@@ -281,6 +286,55 @@
</mediaobject>
</figure>
</section>
+ <section>
+ <title>Software installation and updates from within JBoss Central</title>
+ <para>
+ The <guilabel>Software/Update</guilabel> tab at the bottom of JBoss Central switches to a screen where you can install and update your software.
+ </para>
+ <figure>
+ <title>Software/Update tab</title>
+ <mediaobject>
+ <imageobject>
+ <imagedata fileref="images/getting_started/jboss_central_13.png" scale="90"/>
+ </imageobject>
+ </mediaobject>
+ </figure>
+ <warning>
+ <para>
+ Some software available through this tab is third-party community software that Red Hat has no control over. Installing third-party software may impact the level of support that Red Hat can provide.
+ </para>
+ </warning>
+ <para>
+ To install or update software, select the checkbox beside one or more components.
+ </para>
+ <figure>
+ <title>Software/Update tab</title>
+ <mediaobject>
+ <imageobject>
+ <imagedata fileref="images/getting_started/jboss_central_14.png" scale="90"/>
+ </imageobject>
+ </mediaobject>
+ </figure>
+ <para>
+ Once you have selected all the components to update or install, click the <inlinemediaobject>
+ <imageobject>
+ <imagedata fileref="images/getting_started/jboss_central_icon_07.png"/>
+ </imageobject>
+ <textobject>
+ <phrase>Install</phrase>
+ </textobject>
+</inlinemediaobject> button at the bottom left of the tab window. A screen will then appear offering you the option of deselecting a part of the component if you wish.
+ </para>
+ <figure>
+ <title>Software/Update tab</title>
+ <mediaobject>
+ <imageobject>
+ <imagedata fileref="images/getting_started/jboss_central_15.png" scale="90"/>
+ </imageobject>
+ </mediaobject>
+ </figure>
+ </section>
+ </section>
<section id="JBoss_Perspective">
<title>JBoss Perspective</title>
<para>
Added: trunk/documentation/guides/GettingStartedGuide/en-US/images/getting_started/jboss_central_13.png
===================================================================
(Binary files differ)
Property changes on: trunk/documentation/guides/GettingStartedGuide/en-US/images/getting_started/jboss_central_13.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: trunk/documentation/guides/GettingStartedGuide/en-US/images/getting_started/jboss_central_14.png
===================================================================
(Binary files differ)
Property changes on: trunk/documentation/guides/GettingStartedGuide/en-US/images/getting_started/jboss_central_14.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: trunk/documentation/guides/GettingStartedGuide/en-US/images/getting_started/jboss_central_15.png
===================================================================
(Binary files differ)
Property changes on: trunk/documentation/guides/GettingStartedGuide/en-US/images/getting_started/jboss_central_15.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: trunk/documentation/guides/GettingStartedGuide/en-US/images/getting_started/jboss_central_icon_07.png
===================================================================
(Binary files differ)
Property changes on: trunk/documentation/guides/GettingStartedGuide/en-US/images/getting_started/jboss_central_icon_07.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
14 years, 2 months