Author: rob.stryker(a)jboss.com
Date: 2012-04-27 05:14:20 -0400 (Fri, 27 Apr 2012)
New Revision: 40553
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/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/OpenShiftExpressApplicationWizardModel.java
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/appimport/ServerAdapterFactory.java
Log:
JBIDE-11487 clean up of settings
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-04-27
08:09:18 UTC (rev 40552)
+++
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/core/behaviour/ExpressServerUtils.java 2012-04-27
09:14:20 UTC (rev 40553)
@@ -16,9 +16,12 @@
import java.util.List;
import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.ProjectScope;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.preferences.IEclipsePreferences;
+import org.eclipse.core.runtime.preferences.IScopeContext;
import org.eclipse.jgit.transport.URIish;
import org.eclipse.osgi.util.NLS;
import org.eclipse.wst.server.core.IRuntime;
@@ -38,11 +41,12 @@
import org.jboss.tools.openshift.egit.core.EGitUtils;
import org.jboss.tools.openshift.express.internal.core.console.UserDelegate;
import org.jboss.tools.openshift.express.internal.core.console.UserModel;
+import org.jboss.tools.openshift.express.internal.ui.OpenShiftUIActivator;
import org.jboss.tools.openshift.express.internal.ui.utils.Logger;
import
org.jboss.tools.openshift.express.internal.ui.wizard.IOpenShiftExpressWizardModel;
+import org.osgi.service.prefs.BackingStoreException;
import com.openshift.client.IApplication;
-import com.openshift.client.IDomain;
import com.openshift.client.OpenShiftException;
/**
@@ -54,19 +58,31 @@
*/
@SuppressWarnings("restriction")
public class ExpressServerUtils {
+ /* Server Settings */
public static final String ATTRIBUTE_EXPRESS_MODE =
"org.jboss.tools.openshift.express.internal.core.behaviour.ExpressMode";
public static final String EXPRESS_BINARY_MODE = "publishBinary";
public static final String EXPRESS_SOURCE_MODE = "publishSource";
+ public static final String ATTRIBUTE_DEPLOY_PROJECT =
"org.jboss.tools.openshift.binary.deployProject";
+
+ /* Legacy Server Settings: Please usage scan before removal */
+ public static final String ATTRIBUTE_DEPLOY_PROJECT_LEGACY =
"org.jboss.tools.openshift.express.internal.core.behaviour.binary.deployProject";
+ public static final String ATTRIBUTE_REMOTE_NAME =
"org.jboss.tools.openshift.express.internal.core.behaviour.RemoteName";
public static final String ATTRIBUTE_APPLICATION_NAME =
"org.jboss.tools.openshift.express.internal.core.behaviour.ApplicationName";
public static final String ATTRIBUTE_APPLICATION_ID =
"org.jboss.tools.openshift.express.internal.core.behaviour.ApplicationId";
- 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";
-
+
+ /* New Settings inside the project */
+ public static final String SETTING_REMOTE_NAME =
"org.jboss.tools.openshift.RemoteName";
+ public static final String SETTING_APPLICATION_NAME =
"org.jboss.tools.openshift.ApplicationName";
+ public static final String SETTING_APPLICATION_ID =
"org.jboss.tools.openshift.ApplicationId";
+ public static final String SETTING_DOMAIN =
"org.jboss.tools.openshift.Domain";
+ public static final String SETTING_USERNAME =
"org.jboss.tools.openshift.Username";
+ public static final String SETTING_DEPLOY_FOLDER_NAME =
"org.jboss.tools.openshift.DeployFolder";
+
// 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";
@@ -81,81 +97,55 @@
public static final String TASK_WIZARD_ATTR_APP_LIST = "appList";
public static final String TASK_WIZARD_ATTR_SELECTED_APP = "application";
-
- public static String getExpressMode(IServerAttributes attributes ) {
- return attributes.getAttribute(ATTRIBUTE_EXPRESS_MODE, EXPRESS_SOURCE_MODE);
+ public static String getExpressDeployProject(IServerAttributes attributes ) {
+ return attributes.getAttribute(ATTRIBUTE_DEPLOY_PROJECT,
+ attributes.getAttribute(ATTRIBUTE_DEPLOY_PROJECT_LEGACY, (String)null));
}
-
- public static String getExpressModeAsString(IServerAttributes attributes) {
- String mode = getExpressMode(attributes);
- if( mode.equals(EXPRESS_SOURCE_MODE))
- return "Source";
- return "Binary";
+
+ private static IProject getExpressDeployProject2(IServerAttributes attributes) {
+ String name = getExpressDeployProject(attributes);
+ return name == null ? null :
ResourcesPlugin.getWorkspace().getRoot().getProject(name);
}
- public static IServer setExpressMode(IServer server, String val) throws CoreException {
- IServerWorkingCopy wc = server.createWorkingCopy();
- wc.setAttribute(ATTRIBUTE_EXPRESS_MODE, val);
- return wc.save(false, new NullProgressMonitor());
+ public static String getProjectAttribute(IProject project, String attributeName, String
defaultVal) {
+ if( project == null )
+ return defaultVal;
+ String qualifier = OpenShiftUIActivator.getDefault().getBundle().getSymbolicName();
+ IScopeContext context = new ProjectScope(project);
+ IEclipsePreferences node = context.getNode(qualifier);
+ return node.get(attributeName, defaultVal);
}
-
+
public static String getExpressApplicationName(IServerAttributes attributes ) {
- return attributes.getAttribute(ATTRIBUTE_APPLICATION_NAME, (String)null);
+ return getProjectAttribute(getExpressDeployProject2(attributes),
SETTING_APPLICATION_NAME,
+ attributes.getAttribute(ATTRIBUTE_APPLICATION_NAME, (String)null));
}
- public static IServer setExpressApplication(IServer server, String val) throws
CoreException {
- IServerWorkingCopy wc = server.createWorkingCopy();
- wc.setAttribute(ATTRIBUTE_APPLICATION_NAME, val);
- return wc.save(false, new NullProgressMonitor());
- }
-
- public static String getExpressDeployProject(IServerAttributes attributes ) {
- return attributes.getAttribute(ATTRIBUTE_DEPLOY_PROJECT, (String)null);
- }
- public static IServer setExpressDeployProject(IServer server, String val) throws
CoreException {
- IServerWorkingCopy wc = server.createWorkingCopy();
- wc.setAttribute(ATTRIBUTE_DEPLOY_PROJECT, val);
- return wc.save(false, new NullProgressMonitor());
- }
-
public static String getExpressApplicationId(IServerAttributes attributes ) {
- return attributes.getAttribute(ATTRIBUTE_APPLICATION_ID, (String)null);
+ return getProjectAttribute(getExpressDeployProject2(attributes),
SETTING_APPLICATION_ID,
+ attributes.getAttribute(ATTRIBUTE_APPLICATION_ID, (String)null));
}
public static String getExpressDomain(IServerAttributes attributes ) {
- return attributes.getAttribute(ATTRIBUTE_DOMAIN, (String)null);
+ return getProjectAttribute(getExpressDeployProject2(attributes), SETTING_DOMAIN,
+ attributes.getAttribute(ATTRIBUTE_DOMAIN, (String)null));
}
- public static IServer setExpressDomain(IServer server, String val) throws CoreException
{
- IServerWorkingCopy wc = server.createWorkingCopy();
- wc.setAttribute(ATTRIBUTE_DOMAIN, val);
- return wc.save(false, new NullProgressMonitor());
- }
-
public static String getExpressDeployFolder(IServerAttributes attributes ) {
- return attributes.getAttribute(ATTRIBUTE_DEPLOY_FOLDER_NAME,
ExpressServerUtils.ATTRIBUTE_DEPLOY_FOLDER_DEFAULT);
+ return getProjectAttribute(getExpressDeployProject2(attributes),
SETTING_DEPLOY_FOLDER_NAME,
+ attributes.getAttribute(ATTRIBUTE_DEPLOY_FOLDER_NAME, (String)null));
}
public static String getExpressRemoteName(IServerAttributes attributes ) {
- return attributes.getAttribute(ATTRIBUTE_REMOTE_NAME,
IOpenShiftExpressWizardModel.NEW_PROJECT_REMOTE_NAME_DEFAULT);
+ return getProjectAttribute(getExpressDeployProject2(attributes), SETTING_REMOTE_NAME,
+ attributes.getAttribute(ATTRIBUTE_REMOTE_NAME,(String)null));
}
- public static IServer setExpressRemoteName(IServer server, String val) throws
CoreException {
- IServerWorkingCopy wc = server.createWorkingCopy();
- wc.setAttribute(ATTRIBUTE_REMOTE_NAME, val);
- return wc.save(false, new NullProgressMonitor());
- }
-
public static String getExpressUsername(IServerAttributes attributes ) {
- return attributes.getAttribute(ATTRIBUTE_USERNAME, (String)null);
+ return getProjectAttribute(getExpressDeployProject2(attributes), SETTING_USERNAME,
+ attributes.getAttribute(ATTRIBUTE_USERNAME, (String)null));
}
- public static IServer setExpressUsername(IServer server, String val) throws
CoreException {
- IServerWorkingCopy wc = server.createWorkingCopy();
- wc.setAttribute(ATTRIBUTE_USERNAME, val);
- return wc.save(false, new NullProgressMonitor());
- }
-
public static boolean getIgnoresContextRoot(IServerAttributes server) {
return server.getAttribute(PREFERENCE_IGNORE_CONTEXT_ROOT, true);
}
@@ -165,27 +155,6 @@
wc.setAttribute(ATTRIBUTE_REMOTE_NAME, val);
return wc.save(false, new NullProgressMonitor());
}
-
- /*
- public static IServer fillServerWithOpenShiftDetails(IServer server, IApplication
application,
- 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(), deployProject, projectRelativeFolder,
mode, remoteName);
- }*/
-
- public static void fillServerWithOpenShiftDetails(IServerWorkingCopy wc, IApplication
application,
- UserDelegate user, IDomain domain, String mode, String deployProject,
- String projectRelativeFolder, String remoteName) throws OpenShiftException {
- fillServerWithOpenShiftDetails(wc,
- application == null ? null : application.getApplicationUrl(),
- user == null ? null : user.getRhlogin(),
- domain == null ? null : domain.getId(),
- application == null ? null : application.getName(),
- application == null ? null : application.getUUID(),
- deployProject, projectRelativeFolder, mode, remoteName);
- }
/**
* Fills an already-created server with the proper openshift details.
@@ -202,20 +171,16 @@
*/
@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 {
+ String deployProject) throws CoreException {
ServerWorkingCopy wc = (ServerWorkingCopy)server.createWorkingCopy();
- fillServerWithOpenShiftDetails(wc, host, username, domain, appName, appId,
- deployProject, projectRelativeFolder, mode, remoteName);
+ fillServerWithOpenShiftDetails((IServerWorkingCopy)wc, host, deployProject);
IServer saved = wc.save(true, new NullProgressMonitor());
return saved;
}
public static void fillServerWithOpenShiftDetails(IServerWorkingCopy wc, String host,
- String username, String domain, String appName, String appId,
- String deployProject, String projectRelativeFolder,
- String mode, String remoteName) {
+ String deployProject) {
+
if( host != null ) {
if( host.indexOf("://") != -1)
host = host.substring(host.indexOf("://") + 3);
@@ -224,14 +189,14 @@
}
wc.setHost(host);
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_DEPLOY_FOLDER_NAME, projectRelativeFolder);
- wc.setAttribute(ATTRIBUTE_EXPRESS_MODE, mode);
- wc.setAttribute(ATTRIBUTE_REMOTE_NAME, remoteName);
+// 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_FOLDER_NAME, projectRelativeFolder);
+// 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);
@@ -352,4 +317,67 @@
return null;
}
}
+
+ public static void updateOpenshiftProjectSettings(IProject project, IApplication app,
UserDelegate user,
+ String remoteName, String deployFolder) {
+ String qualifier = OpenShiftUIActivator.getDefault().getBundle().getSymbolicName();
+ IScopeContext context = new ProjectScope(project);
+ IEclipsePreferences node = context.getNode(qualifier);
+ node.put(ExpressServerUtils.SETTING_APPLICATION_ID, app.getUUID());
+ node.put(ExpressServerUtils.SETTING_APPLICATION_NAME, app.getName());
+ node.put(ExpressServerUtils.SETTING_USERNAME, user.getRhlogin());
+ node.put(ExpressServerUtils.SETTING_DOMAIN, app.getDomain().getId());
+ node.put(ExpressServerUtils.SETTING_REMOTE_NAME, remoteName);
+ node.put(ExpressServerUtils.SETTING_DEPLOY_FOLDER_NAME, deployFolder);
+ try {
+ node.flush();
+ } catch (BackingStoreException e) {
+ OpenShiftUIActivator.log(e);
+ }
+ }
+
+
+ /* Deprecated */
+ public static IServer setExpressMode(IServer server, String val) throws CoreException {
+ IServerWorkingCopy wc = server.createWorkingCopy();
+ wc.setAttribute(ATTRIBUTE_EXPRESS_MODE, val);
+ return wc.save(false, new NullProgressMonitor());
+ }
+ public static IServer setExpressApplication(IServer server, String val) throws
CoreException {
+ IServerWorkingCopy wc = server.createWorkingCopy();
+ wc.setAttribute(ATTRIBUTE_APPLICATION_NAME, val);
+ return wc.save(false, new NullProgressMonitor());
+ }
+ public static IServer setExpressDeployProject(IServer server, String val) throws
CoreException {
+ IServerWorkingCopy wc = server.createWorkingCopy();
+ wc.setAttribute(ATTRIBUTE_DEPLOY_PROJECT, val);
+ return wc.save(false, new NullProgressMonitor());
+ }
+ public static IServer setExpressDomain(IServer server, String val) throws CoreException
{
+ IServerWorkingCopy wc = server.createWorkingCopy();
+ wc.setAttribute(ATTRIBUTE_DOMAIN, val);
+ return wc.save(false, new NullProgressMonitor());
+ }
+ public static IServer setExpressUsername(IServer server, String val) throws
CoreException {
+ IServerWorkingCopy wc = server.createWorkingCopy();
+ wc.setAttribute(ATTRIBUTE_USERNAME, val);
+ return wc.save(false, new NullProgressMonitor());
+ }
+
+ public static IServer setExpressRemoteName(IServer server, String val) throws
CoreException {
+ IServerWorkingCopy wc = server.createWorkingCopy();
+ wc.setAttribute(ATTRIBUTE_REMOTE_NAME, val);
+ return wc.save(false, new NullProgressMonitor());
+ }
+ public static String getExpressMode(IServerAttributes attributes ) {
+ return attributes.getAttribute(ATTRIBUTE_EXPRESS_MODE, EXPRESS_SOURCE_MODE);
+ }
+
+ public static String getExpressModeAsString(IServerAttributes attributes) {
+ String mode = getExpressMode(attributes);
+ if( mode.equals(EXPRESS_SOURCE_MODE))
+ return "Source";
+ return "Binary";
+ }
+
}
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-04-27
08:09:18 UTC (rev 40552)
+++
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/behaviour/ExpressDetailsComposite.java 2012-04-27
09:14:20 UTC (rev 40553)
@@ -46,6 +46,7 @@
import org.eclipse.swt.widgets.Combo;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Group;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Link;
import org.eclipse.swt.widgets.Text;
@@ -114,11 +115,16 @@
this.composite = fill;
this.showVerify = showVerify;
this.showImportLink = showVerify;
- initModel();
- createWidgets(fill);
- fillWidgets();
- addListeners();
- quickValidate();
+ try {
+ initModel();
+ createWidgets(fill);
+ fillWidgets();
+ addListeners();
+ quickValidate();
+ } catch(RuntimeException e) {
+ e.printStackTrace();
+ throw e;
+ }
}
public Composite getComposite() {
@@ -168,7 +174,9 @@
this.pass = this.user == null ? null :
UserModel.getDefault().getPasswordFromSecureStorage(this.user);
this.deployFolder = ExpressServerUtils.getExpressDeployFolder(server);
+ this.deployFolder = this.deployFolder == null ?
ExpressServerUtils.ATTRIBUTE_DEPLOY_FOLDER_DEFAULT : this.deployFolder;
this.remote = ExpressServerUtils.getExpressRemoteName(server);
+ this.remote = this.remote == null ? ExpressServerUtils.ATTRIBUTE_REMOTE_NAME_DEFAULT :
this.remote;
}
/* Set widgets initial values */
@@ -268,10 +276,16 @@
GridData gd = GridDataFactory.fillDefaults().span(2, 1).create();
importLink.setLayoutData(gd);
}
- Label zipDestLabel = new Label(composite, SWT.NONE);
+
+
+ Group projectSettings = new Group(composite, SWT.NONE);
+ GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).grab(true,
false).span(2,1).applyTo(projectSettings);
+ projectSettings.setLayout(new GridLayout(2, false));
+
+ Label zipDestLabel = new Label(projectSettings, SWT.NONE);
zipDestLabel.setText("Output Directory: ");
- Composite zipDestComposite = new Composite(composite, SWT.NONE);
+ Composite zipDestComposite = new Composite(projectSettings, SWT.NONE);
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).grab(true,
false).applyTo(zipDestComposite);
zipDestComposite.setLayout(new FormLayout());
browseDestButton = new Button(zipDestComposite, SWT.PUSH);
@@ -282,12 +296,13 @@
- Label remoteLabel = new Label(composite, SWT.NONE);
+ Label remoteLabel = new Label(projectSettings, SWT.NONE);
GridDataFactory.fillDefaults().align(SWT.LEFT, SWT.CENTER).applyTo(remoteLabel);
- remoteText = new Text(composite, SWT.SINGLE | SWT.BORDER);
+ remoteText = new Text(projectSettings, SWT.SINGLE | SWT.BORDER);
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).grab(true,
false).applyTo(remoteText);
// Text
+ projectSettings.setText("Project Settings");
userLabel.setText("Username: ");
if( passLabel != null ) passLabel.setText("Password: ");
remoteLabel.setText("Remote: ");
@@ -392,8 +407,40 @@
}
});
}
+
+ deployProjectCombo.addModifyListener(new ModifyListener() {
+ public void modifyText(ModifyEvent e) {
+ deployProjectChanged();
+ }
+ });
}
+ private void deployProjectChanged() {
+ System.out.println("HEEEEEEEEEEY!");
+ int i = deployProjectCombo.getSelectionIndex();
+ if( i != -1 ) {
+ IProject depProj =
ResourcesPlugin.getWorkspace().getRoot().getProject(deployProject);
+ if( depProj != null && depProj.isAccessible() ) {
+ String remote = ExpressServerUtils.getProjectAttribute(depProj,
+ ExpressServerUtils.SETTING_REMOTE_NAME, null);
+ //ExpressServerUtils.ATTRIBUTE_REMOTE_NAME_DEFAULT);
+ String depFolder = ExpressServerUtils.getProjectAttribute(depProj,
+ ExpressServerUtils.SETTING_DEPLOY_FOLDER_NAME, null);
+ //ExpressServerUtils.ATTRIBUTE_DEPLOY_FOLDER_DEFAULT);
+ if( remote == null ) {
+ remoteText.setText(ExpressServerUtils.ATTRIBUTE_REMOTE_NAME_DEFAULT);
+ }
+ if( depFolder == null )
+ deployFolderText.setText(ExpressServerUtils.ATTRIBUTE_DEPLOY_FOLDER_DEFAULT);
+
+ boolean enabled = remote == null && depFolder == null;
+ remoteText.setEnabled(enabled);
+ deployFolderText.setEnabled(enabled);
+ browseDestButton.setEnabled(enabled);
+ }
+ }
+ }
+
private void browsePressed() {
IFolder f = chooseFolder();
if( f != null ) {
@@ -569,6 +616,7 @@
UserModel.getDefault().clearPasswordInSecureStorage(fuser.getRhlogin());
}
fillServerWithDetails();
+ updateProjectSettings();
} catch(OpenShiftException ose) {
throw new CoreException(new Status(IStatus.ERROR, OpenShiftUIActivator.PLUGIN_ID,
ose.getMessage(), ose));
}
@@ -577,10 +625,23 @@
// Fill the server working copy
// update the values
IServerWorkingCopy wc = callback.getServer();
- ExpressServerUtils.fillServerWithOpenShiftDetails(wc, fapplication,
- fuser, fdomain, mode, deployProject, deployFolder, remote);
+ String host = fapplication == null ? null : fapplication.getApplicationUrl();
+ ExpressServerUtils.fillServerWithOpenShiftDetails(wc, host, deployProject);
}
+
+ private void updateProjectSettings() {
+ IProject depProj = ResourcesPlugin.getWorkspace().getRoot().getProject(deployProject);
+ String projRemote = ExpressServerUtils.getProjectAttribute(depProj,
+ ExpressServerUtils.SETTING_REMOTE_NAME, null);
+ String projDepFolder = ExpressServerUtils.getProjectAttribute(depProj,
+ ExpressServerUtils.SETTING_DEPLOY_FOLDER_NAME, null);
+ if( projRemote == null && projDepFolder == null ) {
+ ExpressServerUtils.updateOpenshiftProjectSettings(
+ depProj, fapplication, fuser, remote, deployFolder);
+ }
+ }
+
private String[] getAppNamesAsStrings(List<IApplication> allApps) {
String[] appNames = new String[allApps.size()];
for (int i = 0; i < allApps.size(); i++) {
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-04-27
08:09:18 UTC (rev 40552)
+++
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/behaviour/ExpressDetailsSection.java 2012-04-27
09:14:20 UTC (rev 40553)
@@ -10,42 +10,22 @@
*******************************************************************************/
package org.jboss.tools.openshift.express.internal.ui.behaviour;
-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.Path;
import org.eclipse.jface.layout.GridDataFactory;
-import org.eclipse.jface.viewers.ILabelProvider;
-import org.eclipse.jface.viewers.ITreeContentProvider;
-import org.eclipse.jface.window.Window;
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.layout.FormLayout;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Text;
import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.IEditorSite;
-import org.eclipse.ui.dialogs.ElementTreeSelectionDialog;
import org.eclipse.ui.forms.widgets.ExpandableComposite;
import org.eclipse.ui.forms.widgets.FormToolkit;
import org.eclipse.ui.forms.widgets.Section;
-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.eclipse.wst.server.ui.editor.ServerEditorSection;
-import org.eclipse.wst.server.ui.internal.editor.ServerEditorPartInput;
import org.jboss.ide.eclipse.as.ui.UIUtil;
-import org.jboss.ide.eclipse.as.ui.editor.ServerWorkingCopyPropertyCommand;
import org.jboss.tools.openshift.express.internal.core.behaviour.ExpressServerUtils;
public class ExpressDetailsSection extends ServerEditorSection {
@@ -53,7 +33,7 @@
protected Text userText, remoteText;
protected Text deployFolderText;
protected Text appNameText, deployProjectText;
- protected Button verifyButton, browseDestButton;
+ protected Button verifyButton; // browseDestButton;
public void init(IEditorSite site, IEditorInput input) {
super.init(site, input);
@@ -75,7 +55,7 @@
section.setClient(c);
initWidgets();
- addListeners();
+// addListeners();
}
protected void initWidgets() {
@@ -94,7 +74,8 @@
String remote = ExpressServerUtils.getExpressRemoteName(server);
deployFolderText.setText(outDir == null ? "" : outDir);
remoteText.setText(remote == null ? "" : remote);
-
+ remoteText.setEnabled(false);
+ deployFolderText.setEnabled(false);
}
protected Composite createComposite(Section section) {
@@ -104,6 +85,12 @@
private void createWidgets(Composite composite) {
composite.setLayout(new GridLayout(2, false));
+
+ Label deployLocationLabel = new Label(composite, SWT.NONE);
+ deployProjectText = new Text(composite, SWT.SINGLE | SWT.BORDER);
+ GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).grab(true,
false).applyTo(deployProjectText);
+
+
Label userLabel = new Label(composite, SWT.NONE);
GridDataFactory.fillDefaults().align(SWT.LEFT, SWT.CENTER).applyTo(userLabel);
userText = new Text(composite, SWT.SINGLE | SWT.BORDER);
@@ -114,19 +101,16 @@
appNameText = new Text(composite, SWT.SINGLE | SWT.BORDER);
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).grab(true,
false).applyTo(appNameText);
- Label deployLocationLabel = new Label(composite, SWT.NONE);
- deployProjectText = new Text(composite, SWT.SINGLE | SWT.BORDER);
- GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).grab(true,
false).applyTo(deployProjectText);
-
Label zipDestLabel = new Label(composite, SWT.NONE);
- 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.PUSH);
- browseDestButton.setLayoutData(UIUtil.createFormData2(0,5,100,-5,null,0,100,0));
- deployFolderText = new Text(zipDestComposite, SWT.SINGLE | SWT.BORDER);
- deployFolderText.setLayoutData(UIUtil.createFormData2(0,5,100,-5,0,0,browseDestButton,-5));
+// 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.PUSH);
+// browseDestButton.setLayoutData(UIUtil.createFormData2(0,5,100,-5,null,0,100,0));
+ deployFolderText = new Text(composite, SWT.SINGLE | SWT.BORDER);
+ //deployFolderText.setLayoutData(UIUtil.createFormData2(0,5,100,-5,0,0,100,0));
+ GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).grab(true,
false).applyTo(deployFolderText);
Label remoteLabel = new Label(composite, SWT.NONE);
GridDataFactory.fillDefaults().align(SWT.LEFT, SWT.CENTER).applyTo(remoteLabel);
@@ -139,76 +123,76 @@
zipDestLabel.setText("Output Directory: ");
userLabel.setText("Username: ");
remoteLabel.setText("Remote: ");
- browseDestButton.setText("Browse...");
+// browseDestButton.setText("Browse...");
}
- ModifyListener remoteModifyListener, deployDestinationModifyListener;
- protected void addListeners() {
- remoteModifyListener = new ModifyListener() {
- public void modifyText(ModifyEvent e) {
- ((ServerEditorPartInput) input).getServerCommandManager().execute(new
SetRemoteCommand(server));
- }
- };
- remoteText.addModifyListener(remoteModifyListener);
- deployDestinationModifyListener = new ModifyListener() {
- public void modifyText(ModifyEvent e) {
- ((ServerEditorPartInput) input).getServerCommandManager().execute(new
SetDeployFolderCommand(server));
- }
- };
- deployFolderText.addModifyListener(deployDestinationModifyListener);
-
- browseDestButton.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- browsePressed();
- }
- });
+// ModifyListener remoteModifyListener, deployDestinationModifyListener;
+// protected void addListeners() {
+// remoteModifyListener = new ModifyListener() {
+// public void modifyText(ModifyEvent e) {
+// ((ServerEditorPartInput) input).getServerCommandManager().execute(new
SetRemoteCommand(server));
+// }
+// };
+// remoteText.addModifyListener(remoteModifyListener);
+// deployDestinationModifyListener = new ModifyListener() {
+// public void modifyText(ModifyEvent e) {
+// ((ServerEditorPartInput) input).getServerCommandManager().execute(new
SetDeployFolderCommand(server));
+// }
+// };
+// deployFolderText.addModifyListener(deployDestinationModifyListener);
+//
+// browseDestButton.addSelectionListener(new SelectionAdapter() {
+// public void widgetSelected(SelectionEvent e) {
+// browsePressed();
+// }
+// });
- }
+// }
+//
+// private void browsePressed() {
+// IFolder f = chooseFolder();
+// if( f != null ) {
+// deployFolderText.setText(f.getFullPath().removeFirstSegments(1).makeRelative().toOSString());
+// }
+// }
- private void browsePressed() {
- IFolder f = chooseFolder();
- if( f != null ) {
- deployFolderText.setText(f.getFullPath().removeFirstSegments(1).makeRelative().toOSString());
- }
- }
-
- private IFolder chooseFolder() {
- String depProject = ExpressServerUtils.getExpressDeployProject(server);
- String depFolder = ExpressServerUtils.getExpressDeployFolder(server);
-
- IProject p = ResourcesPlugin.getWorkspace().getRoot().getProject(depProject);
-
- 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(depFolder));
- if (res != null)
- dialog.setInitialSelection(res);
-
- if (dialog.open() == Window.OK)
- return (IFolder) dialog.getFirstResult();
- return null;
- }
-
- public class SetRemoteCommand extends ServerWorkingCopyPropertyCommand {
- public SetRemoteCommand(IServerWorkingCopy server) {
- super(server, "Change Remote Name", remoteText, remoteText.getText(),
- ExpressServerUtils.ATTRIBUTE_REMOTE_NAME, remoteModifyListener,
- ExpressServerUtils.ATTRIBUTE_REMOTE_NAME_DEFAULT);
- }
- }
-
- public class SetDeployFolderCommand extends ServerWorkingCopyPropertyCommand {
- public SetDeployFolderCommand(IServerWorkingCopy server) {
- super(server, "Change Deployment Folder", deployFolderText,
deployFolderText.getText(),
- ExpressServerUtils.ATTRIBUTE_DEPLOY_FOLDER_NAME, deployDestinationModifyListener,
- ExpressServerUtils.ATTRIBUTE_DEPLOY_FOLDER_DEFAULT);
- }
- }
+// private IFolder chooseFolder() {
+// String depProject = ExpressServerUtils.getExpressDeployProject(server);
+// String depFolder = ExpressServerUtils.getExpressDeployFolder(server);
+//
+// IProject p = ResourcesPlugin.getWorkspace().getRoot().getProject(depProject);
+//
+// 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(depFolder));
+// if (res != null)
+// dialog.setInitialSelection(res);
+//
+// if (dialog.open() == Window.OK)
+// return (IFolder) dialog.getFirstResult();
+// return null;
+// }
+//
+// public class SetRemoteCommand extends ServerWorkingCopyPropertyCommand {
+// public SetRemoteCommand(IServerWorkingCopy server) {
+// super(server, "Change Remote Name", remoteText, remoteText.getText(),
+// ExpressServerUtils.ATTRIBUTE_REMOTE_NAME, remoteModifyListener,
+// ExpressServerUtils.ATTRIBUTE_REMOTE_NAME_DEFAULT);
+// }
+// }
+//
+// public class SetDeployFolderCommand extends ServerWorkingCopyPropertyCommand {
+// public SetDeployFolderCommand(IServerWorkingCopy server) {
+// super(server, "Change Deployment Folder", deployFolderText,
deployFolderText.getText(),
+// ExpressServerUtils.ATTRIBUTE_DEPLOY_FOLDER_NAME, deployDestinationModifyListener,
+// ExpressServerUtils.ATTRIBUTE_DEPLOY_FOLDER_DEFAULT);
+// }
+// }
}
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-04-27
08:09:18 UTC (rev 40552)
+++
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/OpenShiftExpressApplicationWizard.java 2012-04-27
09:14:20 UTC (rev 40553)
@@ -15,10 +15,14 @@
import java.net.SocketTimeoutException;
import java.net.URISyntaxException;
import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Iterator;
import java.util.List;
import java.util.Set;
+import org.eclipse.core.resources.IContainer;
import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.resources.WorkspaceJob;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
@@ -150,11 +154,10 @@
if (success) {
success = importProject();
}
-
wizardModel.addUserToModel();
return success;
}
-
+
private boolean importProject() {
try {
final DelegatingProgressMonitor delegatingMonitor = new DelegatingProgressMonitor();
Modified:
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/OpenShiftExpressApplicationWizardModel.java
===================================================================
---
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/OpenShiftExpressApplicationWizardModel.java 2012-04-27
08:09:18 UTC (rev 40552)
+++
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/OpenShiftExpressApplicationWizardModel.java 2012-04-27
09:14:20 UTC (rev 40553)
@@ -6,6 +6,7 @@
import java.net.URISyntaxException;
import java.util.HashMap;
import java.util.HashSet;
+import java.util.Iterator;
import java.util.List;
import java.util.Set;
import java.util.concurrent.Callable;
@@ -14,25 +15,31 @@
import java.util.concurrent.FutureTask;
import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.ProjectScope;
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.core.runtime.preferences.IEclipsePreferences;
+import org.eclipse.core.runtime.preferences.IScopeContext;
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.ide.eclipse.as.core.JBossServerCorePlugin;
import org.jboss.tools.common.ui.databinding.ObservableUIPojo;
import org.jboss.tools.openshift.egit.core.EGitUtils;
import org.jboss.tools.openshift.express.internal.core.behaviour.ExpressServerUtils;
import org.jboss.tools.openshift.express.internal.core.console.UserDelegate;
import org.jboss.tools.openshift.express.internal.core.console.UserModel;
+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.utils.Logger;
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 org.osgi.service.prefs.BackingStoreException;
import com.openshift.client.IApplication;
import com.openshift.client.ICartridge;
@@ -87,9 +94,27 @@
, getRemoteName()
, getRepositoryFile())
.execute(monitor);
+ addSettingsFiles(importedProjects);
createServerAdapter(monitor, importedProjects);
}
+ private void addSettingsFiles(List<IProject> imported) {
+ Iterator<IProject> i = imported.iterator();
+ while(i.hasNext()) {
+ IProject p = i.next();
+ if( p.getFolder(".git").exists()) {
+ // This is our project
+ IApplication app = getApplication();
+ IProject project = p;
+ // Add the settings here!
+ ExpressServerUtils.updateOpenshiftProjectSettings(project, app,
+ getUser(), getRemoteName(),
+ ExpressServerUtils.ATTRIBUTE_DEPLOY_FOLDER_DEFAULT);
+ return;
+ }
+ }
+ }
+
/**
* Enables the user chosen, unshared project to be used on the chosen
* OpenShift application. Clones the application git repository, copies the
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-04-27
08:09:18 UTC (rev 40552)
+++
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/appimport/ServerAdapterFactory.java 2012-04-27
09:14:20 UTC (rev 40553)
@@ -114,10 +114,8 @@
String serverName =
org.jboss.ide.eclipse.as.core.util.ServerUtil.getDefaultServerName(serverNameBase);
IServer server = ExpressServerUtils.createServer(rt, serverType, serverName);
- ExpressServerUtils.fillServerWithOpenShiftDetails(server,
application.getApplicationUrl(),
- user.getRhlogin(), user.getPassword(), user.getDefaultDomain().getId(),
- application.getName(), application.getUUID(), deployProject,
- ExpressServerUtils.ATTRIBUTE_DEPLOY_FOLDER_DEFAULT, mode, remoteName);
+ ExpressServerUtils.fillServerWithOpenShiftDetails(server,
+ application.getApplicationUrl(), deployProject);
return server;
}