Author: rob.stryker(a)jboss.com
Date: 2012-02-21 03:17:58 -0500 (Tue, 21 Feb 2012)
New Revision: 38927
Modified:
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/plugin.properties
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/core/behaviour/ExpressPublishMethod.java
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/core/behaviour/ExpressServerUtils.java
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/behaviour/ExpressDetailsComposite.java
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/behaviour/ExpressDetailsSection.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/appimport/ServerAdapterFactory.java
Log:
JBIDE-10970 - express server workflow issues
Modified: trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/plugin.properties
===================================================================
---
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/plugin.properties 2012-02-21
04:27:04 UTC (rev 38926)
+++
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/plugin.properties 2012-02-21
08:17:58 UTC (rev 38927)
@@ -3,6 +3,6 @@
providerName=JBoss Community
# Version Delegates
-openshift.express.name=OpenShift Express Runtime
+openshift.express.name=OpenShift Express Server
openshift.express.description=A server adapter for use interfacing with the OpenShift
Express Framework
openshift.express.runtime.name = OpenShift Express Runtime
Modified:
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/core/behaviour/ExpressPublishMethod.java
===================================================================
---
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/core/behaviour/ExpressPublishMethod.java 2012-02-21
04:27:04 UTC (rev 38926)
+++
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/core/behaviour/ExpressPublishMethod.java 2012-02-21
08:17:58 UTC (rev 38927)
@@ -10,16 +10,21 @@
*******************************************************************************/
package org.jboss.tools.openshift.express.internal.core.behaviour;
+import org.eclipse.core.resources.IContainer;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.SubProgressMonitor;
+import org.eclipse.egit.core.op.AddToIndexOperation;
import org.eclipse.egit.core.op.PushOperationResult;
+import org.eclipse.egit.ui.Activator;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jgit.lib.Repository;
import org.eclipse.osgi.util.NLS;
@@ -56,7 +61,8 @@
@Override
public int publishFinish(DeployableServerBehavior behaviour,
IProgressMonitor monitor) throws CoreException {
- IProject destProj =
ExpressServerUtils.findProjectForServersApplication(behaviour.getServer());
+ String destProjName =
ExpressServerUtils.getExpressDeployProject(behaviour.getServer());
+ IProject destProj = ResourcesPlugin.getWorkspace().getRoot().getProject(destProjName);
if( destProj != null ) {
if( destProj.exists() ) {
refreshProject(destProj, submon(monitor, 100));
@@ -93,9 +99,18 @@
if( module.length > 1 )
return 0;
- IProject destProj =
ExpressServerUtils.findProjectForServersApplication(behaviour.getServer());
- IPath dest = destProj.getLocation().append("deployments");
+ String destProjName =
ExpressServerUtils.getExpressDeployProject(behaviour.getServer());
+ IProject destProj = ResourcesPlugin.getWorkspace().getRoot().getProject(destProjName);
+ if( destProj.equals(module[module.length-1].getProject()))
+ return 0;
+
+ String destinationFolder =
ExpressServerUtils.getExpressDeployFolder(behaviour.getServer());
+
+
+ IContainer destFolder = (IContainer)destProj.findMember(new Path(destinationFolder));
+ IPath dest = destFolder.getLocation();
+
if( module.length == 0 ) return IServer.PUBLISH_STATE_NONE;
int modulePublishState = behaviour.getServer().getModulePublishState(module);
int publishType = behaviour.getPublishType(kind, deltaKind, modulePublishState);
@@ -107,6 +122,17 @@
try {
LocalZippedPublisherUtil util = new LocalZippedPublisherUtil();
IStatus status = util.publishModule(behaviour.getServer(), dest.toString(), module,
publishType, delta, monitor);
+
+ IPath path = util.getOutputFilePath(module); // where it's deployed
+ IResource addedResource = destFolder.getFile(new Path(path.lastSegment()));
+ IResource[] resource = new IResource[]{addedResource};
+ final AddToIndexOperation operation = new AddToIndexOperation(resource);
+ try {
+ operation.execute(monitor);
+ } catch (CoreException e) {
+ // TODO
+ }
+
} catch( Exception e ) {
e.printStackTrace();
}
Modified:
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/core/behaviour/ExpressServerUtils.java
===================================================================
---
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/core/behaviour/ExpressServerUtils.java 2012-02-21
04:27:04 UTC (rev 38926)
+++
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/core/behaviour/ExpressServerUtils.java 2012-02-21
08:17:58 UTC (rev 38927)
@@ -10,6 +10,7 @@
*******************************************************************************/
package org.jboss.tools.openshift.express.internal.core.behaviour;
+import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
@@ -55,10 +56,13 @@
public static final String ATTRIBUTE_DEPLOY_PROJECT =
"org.jboss.tools.openshift.express.internal.core.behaviour.binary.deployProject";
public static final String ATTRIBUTE_DOMAIN =
"org.jboss.tools.openshift.express.internal.core.behaviour.Domain";
public static final String ATTRIBUTE_USERNAME =
"org.jboss.tools.openshift.express.internal.core.behaviour.Username";
+ public static final String ATTRIBUTE_DEPLOY_FOLDER_NAME =
"org.jboss.tools.openshift.express.internal.core.behaviour.DEPLOY_FOLDER_LOC";
+
// Legacy, not to be used
//public static final String ATTRIBUTE_PASSWORD =
"org.jboss.tools.openshift.express.internal.core.behaviour.Password";
public static final String ATTRIBUTE_REMOTE_NAME =
"org.jboss.tools.openshift.express.internal.core.behaviour.RemoteName";
public static final String ATTRIBUTE_REMOTE_NAME_DEFAULT = "origin";
+ public static final String ATTRIBUTE_DEPLOY_FOLDER_DEFAULT = "deployments";
public static final String PREFERENCE_IGNORE_CONTEXT_ROOT =
"org.jboss.tools.openshift.express.internal.core.behaviour.IgnoreContextRoot";
@@ -121,6 +125,10 @@
return wc.save(false, new NullProgressMonitor());
}
+ public static String getExpressDeployFolder(IServerAttributes attributes ) {
+ return attributes.getAttribute(ATTRIBUTE_DEPLOY_FOLDER_NAME, "deployments");
+ }
+
public static String getExpressRemoteName(IServerAttributes attributes ) {
return attributes.getAttribute(ATTRIBUTE_REMOTE_NAME, (String)null);
}
@@ -140,31 +148,7 @@
wc.setAttribute(ATTRIBUTE_USERNAME, val);
return wc.save(false, new NullProgressMonitor());
}
-
-// public static String getExpressPassword(IServerWorkingCopy server ) {
-// String username = getExpressUsername(server);
-// return UserModel.getDefault().getPasswordFromSecureStorage(username);
-// }
-//
-// public static String getExpressPassword(IServer server ) {
-// String username = getExpressUsername(server);
-// return UserModel.getDefault().getPasswordFromSecureStorage(username);
-//
-// // Can safely delete this if we have no need for backwards compat currently
-//// if( server == null )
-//// return null;
-//// String s = ServerUtil.getFromSecureStorage(server,
ExpressServerUtils.ATTRIBUTE_PASSWORD);
-//// if( s == null )
-//// return server.getAttribute(ExpressServerUtils.ATTRIBUTE_PASSWORD, (String)null);
-//// return s;
-// }
-//
-// public static void setExpressPassword(IServerAttributes server, String val) throws
CoreException {
-// String username = getExpressUsername(server);
-// UserModel.getDefault().setPasswordInSecureStorage(username, val);
-// }
-
public static boolean getIgnoresContextRoot(IServerAttributes server) {
return server.getAttribute(PREFERENCE_IGNORE_CONTEXT_ROOT, true);
}
@@ -174,68 +158,22 @@
wc.setAttribute(ATTRIBUTE_REMOTE_NAME, val);
return wc.save(false, new NullProgressMonitor());
}
-
- /**
- * To be used if you must create a local runtime adapter
- * as the user does not have one in their workspace yet
- *
- * @param host
- * @param username
- * @param password
- * @param domain
- * @param appName
- * @param sourceOrBinary
- * @param localRuntimeHomeDir
- * @return
- * @throws CoreException
- */
- public static IServer createAS7OpenShiftServer(
- String host, String username, String password,
- String domain, String appName, String appId,
- String sourceOrBinary, String remoteName,
- String localRuntimeHomeDir) throws CoreException {
- IServer server = createServerAndRuntime(IJBossToolingConstants.AS_70,
- IJBossToolingConstants.SERVER_AS_70,
- localRuntimeHomeDir, /* irrelevant */ "default");
- return fillServerWithOpenShiftDetails(server, host, username, password, domain,
appName, appId, sourceOrBinary, remoteName);
- }
-
- /**
- * To be used if a runtime is already provided, for example if a user has
- * selected the proper as7 local runtime delegate from a combo box
- *
- * @param host
- * @param username
- * @param password
- * @param domain
- * @param appName
- * @param sourceOrBinary
- * @param runtime
- * @return
- * @throws CoreException
- */
- public static IServer createAS7OpenShiftServer(
- String host, String username, String password,
- String domain, String appName, String appId, String sourceOrBinary, String
remoteName,
- IRuntime runtime) throws CoreException {
- IServer server = createServer(runtime, IJBossToolingConstants.SERVER_AS_70);
- return fillServerWithOpenShiftDetails(server, host, username, password, domain,
appName, appId, sourceOrBinary, remoteName);
- }
-
-
public static IServer fillServerWithOpenShiftDetails(IServer server, IApplication
application,
- IUser user, String mode, String remoteName) throws CoreException, OpenShiftException
{
+ IUser user, String deployProject, String projectRelativeFolder,
+ String mode, String remoteName) throws CoreException, OpenShiftException {
return fillServerWithOpenShiftDetails(server, application.getApplicationUrl(),
user.getRhlogin(), user.getPassword(), user.getDomain().getNamespace(),
- application.getName(), application.getUUID(), mode, remoteName);
+ application.getName(), application.getUUID(), deployProject, projectRelativeFolder,
mode, remoteName);
}
public static void fillServerWithOpenShiftDetails(IServerWorkingCopy wc, IApplication
application,
- IUser user, String mode, String remoteName) throws CoreException, OpenShiftException
{
+ IUser user, String mode, String deployProject,
+ String projectRelativeFolder, String remoteName) throws CoreException,
OpenShiftException {
fillServerWithOpenShiftDetails(wc, application.getApplicationUrl(),
user.getRhlogin(), user.getDomain().getNamespace(),
- application.getName(), application.getUUID(), mode, remoteName);
+ application.getName(), application.getUUID(),
+ deployProject, projectRelativeFolder, mode, remoteName);
}
/**
@@ -254,16 +192,18 @@
@SuppressWarnings("restriction")
public static IServer fillServerWithOpenShiftDetails(IServer server, String host,
String username, String password, String domain, String appName, String appId,
+ String deployProject, String projectRelativeFolder,
String mode, String remoteName) throws CoreException {
ServerWorkingCopy wc = (ServerWorkingCopy)server.createWorkingCopy();
- fillServerWithOpenShiftDetails(wc, host, username, domain, appName, appId, mode,
remoteName);
+ fillServerWithOpenShiftDetails(wc, host, username, domain, appName, appId,
+ deployProject, projectRelativeFolder, mode, remoteName);
IServer saved = wc.save(true, new NullProgressMonitor());
-// ExpressServerUtils.setExpressPassword(wc, password);
return saved;
}
public static void fillServerWithOpenShiftDetails(IServerWorkingCopy wc, String host,
- String username, String domain, String appName, String appId,
+ String username, String domain, String appName, String appId,
+ String deployProject, String projectRelativeFolder,
String mode, String remoteName) throws CoreException {
if( host.indexOf("://") != -1)
@@ -271,22 +211,20 @@
if( host.endsWith("/"))
host = host.substring(0, host.length()-1);
wc.setHost(host);
- if(mode.equals(ExpressServerUtils.EXPRESS_SOURCE_MODE)) {
- wc.setAttribute(IDeployableServer.SERVER_MODE,
ExpressBehaviourDelegate.OPENSHIFT_ID);
- } else {
- wc.setAttribute(IDeployableServer.SERVER_MODE,
ExpressBinaryBehaviourDelegate.OPENSHIFT_BINARY_ID);
-
- }
+ wc.setAttribute(IDeployableServer.SERVER_MODE, ExpressBehaviourDelegate.OPENSHIFT_ID);
wc.setAttribute(ATTRIBUTE_USERNAME, username);
wc.setAttribute(ATTRIBUTE_DOMAIN, domain);
wc.setAttribute(ATTRIBUTE_APPLICATION_NAME, appName);
wc.setAttribute(ATTRIBUTE_APPLICATION_ID, appId);
+ wc.setAttribute(ATTRIBUTE_DEPLOY_PROJECT, deployProject);
wc.setAttribute(ATTRIBUTE_EXPRESS_MODE, mode);
wc.setAttribute(ATTRIBUTE_REMOTE_NAME, remoteName);
((ServerWorkingCopy)wc).setAutoPublishSetting(Server.AUTO_PUBLISH_DISABLE);
wc.setAttribute(IJBossToolingConstants.IGNORE_LAUNCH_COMMANDS, "true");
wc.setAttribute(IJBossToolingConstants.WEB_PORT, 80);
wc.setAttribute(IJBossToolingConstants.WEB_PORT_DETECT, "false");
+ wc.setAttribute(IDeployableServer.DEPLOY_DIRECTORY_TYPE,
IDeployableServer.DEPLOY_CUSTOM);
+ wc.setAttribute(IDeployableServer.ZIP_DEPLOYMENTS_PREF, true);
}
@@ -350,7 +288,8 @@
return null;
}
- public static IProject findProjectForApplication(IApplication application) {
+ public static IProject[] findProjectsForApplication(IApplication application) {
+ ArrayList<IProject> results = new ArrayList<IProject>();
if( application ==null )
return null;
String gitUri = null;
@@ -369,14 +308,19 @@
while(it.hasNext()) {
String projURI = it.next().toPrivateString();
if( projURI.equals(gitUri))
- return projects[i];
+ results.add(projects[i]);
}
} catch(CoreException ce) {
// Log? Not 100 required, just skip this project?
}
}
- return null;
+ return results.toArray(new IProject[results.size()]);
}
+
+ public static IProject findProjectForApplication(IApplication application) {
+ IProject[] p = findProjectsForApplication(application);
+ return p == null ? null : p.length == 0 ? null : p[0];
+ }
public static IProject findProjectForServersApplication(IServer server) {
try {
Modified:
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/behaviour/ExpressDetailsComposite.java
===================================================================
---
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/behaviour/ExpressDetailsComposite.java 2012-02-21
04:27:04 UTC (rev 38926)
+++
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/behaviour/ExpressDetailsComposite.java 2012-02-21
08:17:58 UTC (rev 38927)
@@ -13,20 +13,31 @@
import java.util.Arrays;
import java.util.List;
+import org.eclipse.core.resources.IFolder;
import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.jface.layout.GridDataFactory;
+import org.eclipse.jface.viewers.ILabelProvider;
+import org.eclipse.jface.viewers.ITreeContentProvider;
+import org.eclipse.jface.viewers.ViewerFilter;
+import org.eclipse.jface.window.Window;
+import org.eclipse.jface.wizard.IWizardContainer;
import org.eclipse.jface.wizard.WizardDialog;
+import org.eclipse.jface.wizard.WizardPage;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.ModifyEvent;
import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.layout.FormLayout;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
@@ -36,9 +47,18 @@
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Link;
import org.eclipse.swt.widgets.Text;
+import org.eclipse.ui.dialogs.ElementTreeSelectionDialog;
+import org.eclipse.ui.dialogs.ISelectionStatusValidator;
+import org.eclipse.ui.internal.handlers.ResetPerspectiveHandler;
+import org.eclipse.ui.model.WorkbenchContentProvider;
+import org.eclipse.ui.model.WorkbenchLabelProvider;
+import org.eclipse.ui.views.navigator.ResourceComparator;
import org.eclipse.wst.server.core.IServerWorkingCopy;
-import org.jboss.ide.eclipse.as.core.server.IDeployableServer;
+import org.eclipse.wst.server.core.ServerCore;
+import org.eclipse.wst.server.ui.wizard.IWizardHandle;
import org.jboss.ide.eclipse.as.ui.Messages;
+import org.jboss.ide.eclipse.as.ui.UIUtil;
+import org.jboss.ide.eclipse.as.ui.editor.DeploymentTypeUIUtil;
import org.jboss.ide.eclipse.as.ui.editor.IDeploymentTypeUI.IServerModeUICallback;
import org.jboss.ide.eclipse.as.ui.editor.ServerWorkingCopyPropertyComboCommand;
import org.jboss.ide.eclipse.as.ui.editor.ServerWorkingCopyPropertyCommand;
@@ -64,16 +84,17 @@
protected IServerModeUICallback callback;
private ModifyListener nameModifyListener, remoteModifyListener,
- appModifyListener, deployProjectModifyListener;
+ appModifyListener, deployProjectModifyListener, deployDestinationModifyListener;
private ModifyListener passModifyListener;
private Link importLink;
protected Text userText, remoteText;
protected Text passText;
+ protected Text deployFolderText;
protected Combo appNameCombo, deployProjectCombo;
- protected Button verifyButton;
+ protected Button verifyButton, browseDestButton;
protected boolean showVerify;
private Composite composite;
- private String user, pass, app, remote, deployProject;
+ private String user, pass, app, remote, deployProject, deployFolder;
private IApplication fapplication;
private IUser fuser;
private String[] appListNames;
@@ -97,12 +118,16 @@
return composite;
}
+ // We already have an initial user, so username and pw can be frozen
+ private boolean createServerHasInitialUser = false;
+
private void initModel() {
String nameFromExistingServer = ExpressServerUtils.getExpressUsername(server);
if (nameFromExistingServer == null) {
// We're in a new server wizard.
// First, check if the taskmodel has data
IUser tmpUser = (IUser)
callback.getAttribute(ExpressServerUtils.TASK_WIZARD_ATTR_USER);
+ createServerHasInitialUser = tmpUser != null;
if (tmpUser == null) {
// If not, use recent user
tmpUser = UserModel.getDefault().getRecentUser();
@@ -114,9 +139,12 @@
try {
this.fuser = tmpUser;
this.user = tmpUser.getRhlogin();
- List<IApplication> allApps = tmpUser.getApplications();
- this.appListNames = getAppNamesAsStrings(allApps);
- } catch (Exception e) { /* ignore */
+ if( createServerHasInitialUser ) {
+ List<IApplication> allApps = tmpUser.getApplications();
+ this.appListNames = getAppNamesAsStrings(allApps);
+ }
+ } catch (Exception e) {
+ /* TODO */
}
}
} else {
@@ -126,82 +154,117 @@
if (app != null) {
this.fapplication = app;
this.app = app.getName();
+ } else {
+ this.app = ExpressServerUtils.getExpressApplicationName(server);
}
this.pass = UserModel.getDefault().getPasswordFromSecureStorage(this.user);
+ this.deployProject = ExpressServerUtils.getExpressDeployProject(server);
+ this.deployFolder = ExpressServerUtils.getExpressDeployFolder(server);
this.remote = ExpressServerUtils.getExpressRemoteName(server);
this.remote = this.remote == null ?
IOpenShiftExpressWizardModel.NEW_PROJECT_REMOTE_NAME_DEFAULT : this.remote;
}
/* Set widgets initial values */
private void fillWidgets() {
- if (user != null)
+ if (user != null) {
userText.setText(user);
- if (pass != null)
+ userText.setEnabled(!createServerHasInitialUser);
+ }
+ if (showVerify && pass != null) {
passText.setText(pass);
+ passText.setEnabled(!createServerHasInitialUser);
+ }
if (remote != null)
remoteText.setText(remote);
if (appListNames != null)
appNameCombo.setItems(appListNames);
+ app = ExpressServerUtils.getExpressApplicationName(server);
+ app = app != null ? app : fapplication == null ? null : fapplication.getName();
if (app != null) {
+ appNameCombo.setText(app);
+ appNameCombo.setEnabled(false);
int ind = appNameCombo.indexOf(app);
if (ind != -1) {
appNameCombo.select(ind);
}
+
+ if( fapplication != null ) {
+ resetDeployProjectCombo();
+ } else {
+ this.deployProject = ExpressServerUtils.getExpressDeployProject(server);
+ if( deployProject != null ) {
+ this.deployProjectCombo.setItems(new String[]{deployProject});
+ this.deployProjectCombo.select(0);
+ this.deployProjectCombo.setEnabled(false);
+ }
+ }
}
+
+ deployFolderText.setText(deployFolder);
remoteText.setText(remote);
}
+ private void resetDeployProjectCombo() {
+ IProject[] p = ExpressServerUtils.findProjectsForApplication(fapplication);
+ String[] names = p == null ? new String[0] : new String[p.length];
+ for( int i = 0; i < names.length; i++ ) {
+ names[i] = p[i].getName();
+ }
+ this.deployProjectCombo.setItems(names);
+ if( names.length > 0 ) {
+ deployProjectCombo.select(0);
+ this.deployProject = names[0];
+ }
+ }
+
private void createWidgets(Composite composite) {
composite.setLayout(new GridLayout(2, false));
Label userLabel = new Label(composite, SWT.NONE);
- GridDataFactory.fillDefaults()
- .align(SWT.LEFT, SWT.CENTER).applyTo(userLabel);
+ GridDataFactory.fillDefaults().align(SWT.LEFT, SWT.CENTER).applyTo(userLabel);
userText = new Text(composite, SWT.SINGLE | SWT.BORDER);
+ GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).grab(true,
false).applyTo(userText);
+ Label passLabel = null;
+ if( showVerify ) {
+ passLabel = new Label(composite, SWT.NONE);
+ GridDataFactory.fillDefaults().align(SWT.LEFT, SWT.CENTER).applyTo(passLabel);
+ passText = new Text(composite, SWT.PASSWORD | SWT.BORDER);
+ GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).grab(true,
false).applyTo(passText);
+ }
+ Label appNameLabel = new Label(composite, SWT.NONE);
GridDataFactory.fillDefaults()
- .align(SWT.FILL, SWT.FILL).grab(true, false).applyTo(userText);
- Label passLabel = new Label(composite, SWT.NONE);
- GridDataFactory.fillDefaults()
- .align(SWT.LEFT, SWT.CENTER).applyTo(passLabel);
- passText = new Text(composite, SWT.PASSWORD | SWT.BORDER);
- GridDataFactory.fillDefaults()
- .align(SWT.FILL, SWT.FILL).grab(true, false).applyTo(passText);
-
- if (mode.equals(ExpressServerUtils.EXPRESS_SOURCE_MODE)) {
- Label appNameLabel = new Label(composite, SWT.NONE);
- GridDataFactory.fillDefaults()
- .align(SWT.LEFT, SWT.CENTER).applyTo(appNameLabel);
- appNameCombo = new Combo(composite, SWT.NONE);
- GridDataFactory.fillDefaults()
- .align(SWT.FILL, SWT.FILL).grab(true, false).applyTo(appNameCombo);
- appNameLabel.setText("Application Name: ");
- String aName = ExpressServerUtils.getExpressApplicationName(server);
- if (aName != null)
- appNameCombo.setText(aName);
- if (aName != null)
- appNameCombo.setEnabled(false);
- }
- // else {
- // Label deployLocationLabel = new Label(composite, SWT.NONE);
- // deployProjectCombo = new Combo(composite, SWT.NONE);
- // deployLocationLabel.setText("Openshift Project: " );
- // String[] projectNames = discoverOpenshiftProjects();
- // deployProjectCombo.setItems(projectNames);
- // String depLoc = ExpressServerUtils.getExpressDeployProject(server);
- // if( depLoc != null ) deployProjectCombo.setText(depLoc);
- // if( depLoc != null ) deployProjectCombo.setEnabled(false);
- // }
-
+ .align(SWT.LEFT, SWT.CENTER).applyTo(appNameLabel);
+ appNameCombo = new Combo(composite, SWT.NONE);
+ GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).grab(true,
false).applyTo(appNameCombo);
+ appNameLabel.setText("Application Name: ");
+
+ Label deployLocationLabel = new Label(composite, SWT.NONE);
+ deployProjectCombo = new Combo(composite, SWT.READ_ONLY);
+ GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).grab(true,
false).applyTo(deployProjectCombo);
+ deployLocationLabel.setText("Deploy Project: " );
+
+ Label zipDestLabel = new Label(composite, SWT.NONE);
+ zipDestLabel.setText("Output Directory: ");
+
+ Composite zipDestComposite = new Composite(composite, SWT.NONE);
+ GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).grab(true,
false).applyTo(zipDestComposite);
+ zipDestComposite.setLayout(new FormLayout());
+ browseDestButton = new Button(zipDestComposite, SWT.DEFAULT);
+ browseDestButton.setText("Browse...");
+ browseDestButton.setLayoutData(UIUtil.createFormData2(0,5,100,-5,null,0,100,-5));
+ deployFolderText = new Text(zipDestComposite, SWT.SINGLE | SWT.BORDER);
+ deployFolderText.setLayoutData(UIUtil.createFormData2(0,5,100,-5,0,5,browseDestButton,-5));
+
+
+
Label remoteLabel = new Label(composite, SWT.NONE);
- GridDataFactory.fillDefaults()
- .align(SWT.LEFT, SWT.CENTER).applyTo(remoteLabel);
+ GridDataFactory.fillDefaults().align(SWT.LEFT, SWT.CENTER).applyTo(remoteLabel);
remoteText = new Text(composite, SWT.SINGLE | SWT.BORDER);
- GridDataFactory.fillDefaults()
- .align(SWT.FILL, SWT.FILL).grab(true, false).applyTo(remoteText);
+ GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).grab(true,
false).applyTo(remoteText);
// Text
userLabel.setText("Username: ");
- passLabel.setText("Password: ");
+ if( passLabel != null ) passLabel.setText("Password: ");
remoteLabel.setText("Remote: ");
if (showVerify) {
@@ -233,7 +296,7 @@
callback.execute(new SetPassCommand(server));
}
};
- passText.addModifyListener(passModifyListener);
+ if( showVerify ) passText.addModifyListener(passModifyListener);
remoteModifyListener = new ModifyListener() {
public void modifyText(ModifyEvent e) {
@@ -248,6 +311,7 @@
public void modifyText(ModifyEvent e) {
app = appNameCombo.getText();
callback.execute(new SetApplicationCommand(server));
+ resetDeployProjectCombo();
}
};
appNameCombo.addModifyListener(appModifyListener);
@@ -262,7 +326,21 @@
};
deployProjectCombo.addModifyListener(deployProjectModifyListener);
}
+ deployDestinationModifyListener = new ModifyListener() {
+ public void modifyText(ModifyEvent e) {
+ deployFolder = deployFolderText.getText();
+ callback.execute(new SetDeployFolderCommand(server));
+ }
+ };
+ deployFolderText.addModifyListener(deployDestinationModifyListener);
+
+ browseDestButton.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ browsePressed();
+ }
+ });
+
if (verifyButton != null) {
importLink.addSelectionListener(new SelectionListener() {
public void widgetSelected(SelectionEvent e) {
@@ -270,8 +348,16 @@
wizard.setInitialUser(fuser);
wizard.setSelectedApplication(fapplication);
WizardDialog dialog = new WizardDialog(Display.getCurrent().getActiveShell(),
wizard);
+ int oldServerCount = ServerCore.getServers().length;
dialog.create();
dialog.open();
+ if( ServerCore.getServers().length > oldServerCount ) {
+ // Cancel this wizard, a server has already been created
+ // This is reeeaally ugly
+ IWizardHandle handle =
((DeploymentTypeUIUtil.NewServerWizardBehaviourCallback)callback).getHandle();
+ IWizardContainer container = ((WizardPage)handle).getWizard().getContainer();
+ ((WizardDialog)container).close();
+ }
}
public void widgetDefaultSelected(SelectionEvent e) {
@@ -289,6 +375,36 @@
}
}
+ private void browsePressed() {
+ IFolder f = chooseFolder();
+ if( f != null ) {
+ deployFolderText.setText(f.getFullPath().removeFirstSegments(1).makeRelative().toOSString());
+ }
+ }
+
+ private IFolder chooseFolder() {
+ IProject p = ResourcesPlugin.getWorkspace().getRoot().getProject(this.deployProject);
+
+ ILabelProvider lp= new WorkbenchLabelProvider();
+ ITreeContentProvider cp= new WorkbenchContentProvider();
+
+ ElementTreeSelectionDialog dialog= new
ElementTreeSelectionDialog(Display.getDefault().getActiveShell(), lp, cp);
+ dialog.setTitle("Deploy Location");
+ dialog.setMessage("Please choose a location to put zipped projects");
+ dialog.setInput(p);
+ dialog.setComparator(new ResourceComparator(ResourceComparator.NAME));
+
+ IResource res= p.findMember(new Path(this.deployFolder));
+ if (res != null) {
+ dialog.setInitialSelection(res);
+ }
+
+ if (dialog.open() == Window.OK) {
+ return (IFolder) dialog.getFirstResult();
+ }
+ return null;
+ }
+
private void verifyPressed() {
final CredentialsWizardPageModel model = new CredentialsWizardPageModel(new
ConnectToOpenShiftWizardModel());
this.fapplication = null;
@@ -309,7 +425,7 @@
}
private void postLongRunningValidate() {
- importLink.setEnabled(true);
+ importLink.setEnabled(false);
if (appListNames == null) {
appListNames = new String[0];
}
@@ -320,11 +436,12 @@
appNameCombo.select(index);
}
if (error == null) {
- IProject p = ExpressServerUtils.findProjectForApplication(fapplication);
- if (p == null) {
+ IProject[] p = ExpressServerUtils.findProjectsForApplication(fapplication);
+ if (p == null || p.length == 0) {
error = "Your workspace does not have a project corresponding to " + app +
". Please import one.";
importLink.setEnabled(true);
}
+ resetDeployProjectCombo();
}
callback.setErrorMessage(error);
verifyButton.setEnabled(true);
@@ -358,6 +475,13 @@
}
}
+ public class SetDeployFolderCommand extends ServerWorkingCopyPropertyCommand {
+ public SetDeployFolderCommand(IServerWorkingCopy server) {
+ super(server, "Change Deployment Folder", deployFolderText,
deployFolderText.getText(),
+ ExpressServerUtils.ATTRIBUTE_DEPLOY_FOLDER_NAME, deployDestinationModifyListener);
+ }
+ }
+
public class SetPassCommand extends ServerWorkingCopyPropertyCommand {
public SetPassCommand(IServerWorkingCopy server) {
super(server, Messages.EditorChangePasswordCommandName, passText, passText.getText(),
@@ -384,42 +508,12 @@
if (!s.isOK()) {
ExpressDetailsComposite.this.error = "Credentials Failed";
} else {
-
- if (mode.equals(ExpressServerUtils.EXPRESS_SOURCE_MODE)) {
- verifyApplicationSourceMode(model);
- } else {
- verifyApplicationBinaryMode(model);
- }
+ verifyApplicationSourceMode(model);
}
}
};
}
- private void verifyApplicationBinaryMode(CredentialsWizardPageModel model) {
- IProject p = ResourcesPlugin.getWorkspace().getRoot().getProject(deployProject);
- try {
- fuser = UserModel.getDefault().getRecentUser();
- final List<IApplication> allApps = fuser.getApplications();
- fapplication = ExpressServerUtils.findApplicationForProject(p, allApps);
-
- if (fapplication == null) {
- error = "Application for project \"" + p.getName() + "\" not
found";
- }
- IServerWorkingCopy wc = callback.getServer();
- ExpressServerUtils.fillServerWithOpenShiftDetails(wc, fapplication, fuser,
- mode, remote);
- wc.setAttribute(IDeployableServer.DEPLOY_DIRECTORY_TYPE,
IDeployableServer.DEPLOY_CUSTOM);
- wc.setAttribute(IDeployableServer.ZIP_DEPLOYMENTS_PREF, true);
- wc.setAttribute(IDeployableServer.DEPLOY_DIRECTORY,
p.getFolder("deployments").getLocation().toString());
- wc.setAttribute(IDeployableServer.TEMP_DEPLOY_DIRECTORY,
p.getFolder("deployments").getLocation()
- .toString());
- } catch (OpenShiftException ce) {
-
- } catch (CoreException ce) {
-
- }
- }
-
private void verifyApplicationSourceMode(CredentialsWizardPageModel model) {
error = null;
// now check the app name and cartridge
@@ -432,25 +526,17 @@
IApplication application = index == -1 ? null : allApps.get(index);
ExpressDetailsComposite.this.appListNames = appNames;
if (application == null) {
- error = "Application " + app + " not found";
+ error = "Application " + app + " not found. Please select one from the
combo box.";
} else {
// Fill with new data
try {
ExpressDetailsComposite.this.fapplication = application;
ExpressDetailsComposite.this.fuser = user;
- IProject p = ExpressServerUtils.findProjectForApplication(fapplication);
-
- // update the values
- IServerWorkingCopy wc = callback.getServer();
- ExpressServerUtils.fillServerWithOpenShiftDetails(wc, application, fuser,
- mode, remote);
- wc.setAttribute(IDeployableServer.DEPLOY_DIRECTORY_TYPE,
IDeployableServer.DEPLOY_CUSTOM);
- wc.setAttribute(IDeployableServer.ZIP_DEPLOYMENTS_PREF, true);
- if (p != null) {
- wc.setAttribute(IDeployableServer.DEPLOY_DIRECTORY,
p.getFolder("deployments").getLocation()
- .toString());
- wc.setAttribute(IDeployableServer.TEMP_DEPLOY_DIRECTORY,
p.getFolder("deployments")
- .getLocation().toString());
+ if( deployProject != null && !deployProject.equals("")) {
+ // update the values
+ IServerWorkingCopy wc = callback.getServer();
+ ExpressServerUtils.fillServerWithOpenShiftDetails(wc, application,
+ fuser, mode, deployProject, deployFolder, remote);
}
} catch (CoreException ce) {
// TODO FIX HANDLE
Modified:
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/behaviour/ExpressDetailsSection.java
===================================================================
---
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/behaviour/ExpressDetailsSection.java 2012-02-21
04:27:04 UTC (rev 38926)
+++
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/behaviour/ExpressDetailsSection.java 2012-02-21
08:17:58 UTC (rev 38927)
@@ -36,7 +36,7 @@
FormToolkit toolkit = new FormToolkit(parent.getDisplay());
Section section = toolkit.createSection(parent,
ExpandableComposite.TWISTIE|ExpandableComposite.EXPANDED|ExpandableComposite.TITLE_BAR);
- section.setText("Express Server in Source Mode (Details)");
+ section.setText("Openshift Express Server");
section.setLayoutData(new GridData(GridData.FILL_HORIZONTAL |
GridData.VERTICAL_ALIGN_FILL | GridData.GRAB_HORIZONTAL| GridData.GRAB_VERTICAL));
details = ExpressDetailsComposite.createComposite(section, createCallback(),
ExpressServerUtils.EXPRESS_SOURCE_MODE, false);
Modified:
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/OpenShiftExpressApplicationWizard.java
===================================================================
---
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/OpenShiftExpressApplicationWizard.java 2012-02-21
04:27:04 UTC (rev 38926)
+++
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/OpenShiftExpressApplicationWizard.java 2012-02-21
08:17:58 UTC (rev 38927)
@@ -135,6 +135,8 @@
@Override
public void addPages() {
+ if( getWizardModel().getUser() == null)
+ getWizardModel().setUser(initialUser);
addPage(new CredentialsWizardPage(this, getWizardModel()));
addPage(new ApplicationConfigurationWizardPage(this, getWizardModel()));
addPage(new ProjectAndServerAdapterSettingsWizardPage(this, getWizardModel()));
Modified:
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/appimport/ServerAdapterFactory.java
===================================================================
---
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/appimport/ServerAdapterFactory.java 2012-02-21
04:27:04 UTC (rev 38926)
+++
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/appimport/ServerAdapterFactory.java 2012-02-21
08:17:58 UTC (rev 38927)
@@ -67,18 +67,20 @@
* @throws OpenShiftException
*/
protected void createServerAdapter(IProject project, IServerType serverType, IRuntime
runtime, String mode,
- IApplication application, IUser user, String remoteName, IProgressMonitor monitor)
throws OpenShiftException {
+ IApplication application, IUser user,
+ String remoteName, IProgressMonitor monitor) throws OpenShiftException {
String name = project.getName();
monitor.subTask(NLS.bind("Creating server adapter for project {0}", name));
createServerAdapter(Collections.singletonList(project), serverType, runtime,
- mode, application, user, remoteName, monitor);
+ mode, application, user, project.getName(), remoteName, monitor);
}
protected void createServerAdapter(List<IProject> importedProjects, IServerType
serverType,
- IRuntime runtime, String mode, IApplication application, IUser user, String
remoteName, IProgressMonitor monitor) {
+ IRuntime runtime, String mode, IApplication application, IUser user,
+ String deployProject, String remoteName, IProgressMonitor monitor) {
try {
renameWebContextRoot(importedProjects);
- IServer server = doCreateServerAdapter(serverType, runtime, mode, application, user,
remoteName);
+ IServer server = doCreateServerAdapter(serverType, runtime, mode, application, user,
deployProject, remoteName);
addModules(getModules(importedProjects), server, monitor);
} catch (CoreException ce) {
OpenShiftUIActivator.getDefault().getLog().log(ce.getStatus());
@@ -96,7 +98,7 @@
}
private IServer doCreateServerAdapter(IServerType serverType, IRuntime rt, String mode,
- IApplication application, IUser user, String remoteName) throws CoreException,
+ IApplication application, IUser user, String deployProject, String remoteName) throws
CoreException,
OpenShiftException {
Assert.isLegal(serverType != null);
Assert.isLegal(mode != null);
@@ -109,7 +111,8 @@
IServer server = ExpressServerUtils.createServer(rt, serverType, serverName);
ExpressServerUtils.fillServerWithOpenShiftDetails(server,
application.getApplicationUrl(),
user.getRhlogin(), user.getPassword(), user.getDomain().getNamespace(),
- application.getName(), application.getUUID(), mode, remoteName);
+ application.getName(), application.getUUID(), deployProject,
+ ExpressServerUtils.ATTRIBUTE_DEPLOY_FOLDER_DEFAULT, mode, remoteName);
return server;
}