Author: rob.stryker(a)jboss.com
Date: 2012-02-16 04:09:11 -0500 (Thu, 16 Feb 2012)
New Revision: 38806
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/editor/DeploymentTypeUIUtil.java
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/editor/IDeploymentTypeUI.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/action/CreateServerAdapterAction.java
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/behaviour/ExpressBinaryUI.java
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/behaviour/ExpressDetailsComposite.java
Log:
JBIDE-10900 - express console needs to create server
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/editor/DeploymentTypeUIUtil.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/editor/DeploymentTypeUIUtil.java 2012-02-16
07:57:07 UTC (rev 38805)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/editor/DeploymentTypeUIUtil.java 2012-02-16
09:09:11 UTC (rev 38806)
@@ -96,6 +96,9 @@
handle.setMessage(msg, IMessageProvider.ERROR);
handle.update();
}
+ public Object getAttribute(String key) {
+ return tm.getObject(key);
+ }
}
@@ -135,6 +138,9 @@
else
section.setErrorMessage(msg);
}
+ public Object getAttribute(String key) {
+ return null;
+ }
}
}
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/editor/IDeploymentTypeUI.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/editor/IDeploymentTypeUI.java 2012-02-16
07:57:07 UTC (rev 38805)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/editor/IDeploymentTypeUI.java 2012-02-16
09:09:11 UTC (rev 38806)
@@ -26,6 +26,7 @@
public void execute(IUndoableOperation operation);
public void executeLongRunning(Job j);
public void setErrorMessage(String msg);
+ public Object getAttribute(String key);
}
/**
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-16
07:57:07 UTC (rev 38805)
+++
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/core/behaviour/ExpressServerUtils.java 2012-02-16
09:09:11 UTC (rev 38806)
@@ -65,6 +65,12 @@
/** the OpensHift Server Type as defined in the plugin.xml.*/
public static final String OPENSHIFT_SERVER_TYPE =
"org.jboss.tools.openshift.express.openshift.server.type";
+ /* For use inside express wizard fragment */
+ public static final String TASK_WIZARD_ATTR_USER = "user";
+ 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);
}
Modified:
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/action/CreateServerAdapterAction.java
===================================================================
---
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/action/CreateServerAdapterAction.java 2012-02-16
07:57:07 UTC (rev 38805)
+++
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/action/CreateServerAdapterAction.java 2012-02-16
09:09:11 UTC (rev 38806)
@@ -1,11 +1,27 @@
package org.jboss.tools.openshift.express.internal.ui.action;
+import java.util.List;
+
+import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.ITreeSelection;
-import org.eclipse.wst.server.core.ServerCore;
+import org.eclipse.jface.wizard.WizardDialog;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.ui.INewWizard;
+import org.eclipse.ui.IWorkbench;
+import org.eclipse.wst.server.ui.internal.Messages;
+import org.eclipse.wst.server.ui.internal.wizard.TaskWizard;
+import org.eclipse.wst.server.ui.internal.wizard.WizardTaskUtil;
+import org.eclipse.wst.server.ui.internal.wizard.fragment.ModifyModulesWizardFragment;
+import org.eclipse.wst.server.ui.internal.wizard.fragment.NewServerWizardFragment;
+import org.eclipse.wst.server.ui.internal.wizard.fragment.TasksWizardFragment;
+import org.eclipse.wst.server.ui.wizard.WizardFragment;
+import org.jboss.tools.openshift.express.internal.core.behaviour.ExpressServerUtils;
import org.jboss.tools.openshift.express.internal.ui.OpenShiftUIActivator;
import
org.jboss.tools.openshift.express.internal.ui.messages.OpenShiftExpressUIMessages;
import com.openshift.express.client.IApplication;
+import com.openshift.express.client.IUser;
+import com.openshift.express.client.OpenShiftException;
public class CreateServerAdapterAction extends AbstractAction {
@@ -20,12 +36,36 @@
if (selection != null && selection instanceof ITreeSelection
&& treeSelection.getFirstElement() instanceof IApplication) {
final IApplication application = (IApplication) treeSelection.getFirstElement();
- ServerCore.getServers();
- /*
- * EmbedCartridgeWizard wizard = new EmbedCartridgeWizard(user, user); WizardDialog
dialog = new
- * WizardDialog(Display.getCurrent().getActiveShell(), wizard); dialog.create();
dialog.open();
- */
+ IUser user = application.getUser();
+ NewServerWizard w = new NewServerWizard(ExpressServerUtils.OPENSHIFT_SERVER_TYPE);
+ w.getTaskModel().putObject(ExpressServerUtils.TASK_WIZARD_ATTR_USER, user);
+ w.getTaskModel().putObject(ExpressServerUtils.TASK_WIZARD_ATTR_SELECTED_APP,
application);
+ WizardDialog dialog = new WizardDialog(Display.getCurrent().getActiveShell(), w);
+ dialog.open();
+ }
+ }
+
+ public class NewServerWizard extends TaskWizard implements INewWizard {
+ public NewServerWizard(final String serverType) {
+ super(Messages.wizNewServerWizardTitle, new WizardFragment() {
+ protected void createChildFragments(List<WizardFragment> list) {
+ list.add(new NewServerWizardFragment(null, serverType));
+
+ list.add(WizardTaskUtil.TempSaveRuntimeFragment);
+ list.add(WizardTaskUtil.TempSaveServerFragment);
+
+ list.add(new ModifyModulesWizardFragment());
+ list.add(new TasksWizardFragment());
+
+ list.add(WizardTaskUtil.SaveRuntimeFragment);
+ list.add(WizardTaskUtil.SaveServerFragment);
+ list.add(WizardTaskUtil.SaveHostnameFragment);
+ }
+ });
+ }
+ public void init(IWorkbench newWorkbench, IStructuredSelection newSelection) {
+ // do nothing
}
}
}
Modified:
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/behaviour/ExpressBinaryUI.java
===================================================================
---
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/behaviour/ExpressBinaryUI.java 2012-02-16
07:57:07 UTC (rev 38805)
+++
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/behaviour/ExpressBinaryUI.java 2012-02-16
09:09:11 UTC (rev 38806)
@@ -70,6 +70,9 @@
public void setErrorMessage(String msg) {
inner.setErrorMessage(msg);
}
+ public Object getAttribute(String key) {
+ return null;
+ }
};
}
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-16
07:57:07 UTC (rev 38805)
+++
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/behaviour/ExpressDetailsComposite.java 2012-02-16
09:09:11 UTC (rev 38806)
@@ -10,11 +10,9 @@
*******************************************************************************/
package org.jboss.tools.openshift.express.internal.ui.behaviour;
-import java.util.ArrayList;
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.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
@@ -88,7 +86,9 @@
this.mode = mode;
this.composite = fill;
this.showVerify = showVerify;
- fillSection(fill);
+ initModel();
+ createWidgets(fill);
+ fillWidgets();
addListeners();
}
@@ -96,7 +96,57 @@
return composite;
}
- private void fillSection(Composite composite) {
+ 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);
+ if( tmpUser == null ) {
+ // If not, use recent user
+ tmpUser = UserModel.getDefault().getRecentUser();
+ }
+ if( tmpUser == null && UserModel.getDefault().getUsers().length > 0 ) {
+ tmpUser = UserModel.getDefault().getUsers()[0];
+ }
+ if( tmpUser != null ) {
+ try {
+ this.fuser = tmpUser;
+ this.user = tmpUser.getRhlogin();
+ List<IApplication> allApps = tmpUser.getApplications();
+ this.appListNames = getAppNamesAsStrings(allApps);
+ } catch(Exception e) { /* ignore */ }
+ }
+ } else {
+ this.user = nameFromExistingServer;
+ }
+ IApplication app =
(IApplication)callback.getAttribute(ExpressServerUtils.TASK_WIZARD_ATTR_SELECTED_APP);
+ if( app != null ) {
+ this.fapplication = app;
+ this.app = app.getName();
+ }
+
+ this.pass = UserModel.getDefault().getPasswordFromSecureStorage(this.user);
+ 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 ) userText.setText(user);
+ if( pass != null ) passText.setText(pass);
+ if( remote != null ) remoteText.setText(remote);
+ if( appListNames != null ) appNameCombo.setItems(appListNames);
+ if( app != null ) {
+ int ind = appNameCombo.indexOf(app);
+ if( ind != -1 ) {
+ appNameCombo.select(ind);
+ }
+ }
+ remoteText.setText(remote);
+ }
+
+ private void createWidgets(Composite composite) {
composite.setLayout(new GridLayout(2, false));
Label userLabel = new Label(composite, SWT.NONE);
userText = new Text(composite, SWT.SINGLE | SWT.BORDER);
@@ -112,16 +162,17 @@
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);
- }
+ }
+// 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);
+// }
Label remoteLabel = new Label(composite, SWT.NONE);
remoteText = new Text(composite, SWT.SINGLE | SWT.BORDER);
@@ -132,34 +183,7 @@
userLabel.setText("Username: ");
passLabel.setText("Password: ");
remoteLabel.setText("Remote: ");
- remoteText.setText(IOpenShiftExpressWizardModel.NEW_PROJECT_REMOTE_NAME_DEFAULT);
- String n = ExpressServerUtils.getExpressUsername(server);
- String[] appNames = null;
- if( n == null ) {
- // We're in a new server wizard
- IUser user = UserModel.getDefault().getRecentUser();
- if( user == null && UserModel.getDefault().getUsers().length > 0 ) {
- user = UserModel.getDefault().getUsers()[0];
- }
- if( user != null )
- try {
- n = user.getRhlogin();
- List<IApplication> allApps = user.getApplications();
- appNames = getAppNamesAsStrings(allApps);
- } catch(Exception e) { /* ignore */ }
- }
- String p = UserModel.getDefault().getPasswordFromSecureStorage(n);
- String remote = ExpressServerUtils.getExpressRemoteName(server);
- if( n != null ) userText.setText(n);
- if( p != null ) passText.setText(p);
- if( remote != null ) remoteText.setText(remote);
-
- if( appNames != null ) {
- appListNames = appNames;
- appNameCombo.setItems(appListNames);
- }
-
if( showVerify ) {
importLink = new Link(composite, SWT.DEFAULT);
importLink.setText("<a>Import this application</a>");
//$NON-NLS-1$
@@ -170,27 +194,7 @@
verifyButton.setText("Verify...");
}
}
-
- private String[] discoverOpenshiftProjects() {
- IProject[] projects = ResourcesPlugin.getWorkspace().getRoot().getProjects();
- ArrayList<String> names = new ArrayList<String>();
- for( int i = 0; i < projects.length; i++ ) {
- if( isOpenshiftProjectWithDeploymentsFolder(projects[i])) {
- names.add(projects[i].getName());
- }
- }
- return (String[]) names.toArray(new String[names.size()]);
- }
-
- private boolean isOpenshiftProjectWithDeploymentsFolder(IProject p) {
- // TODO add other criteria?
- IFolder f = p.getFolder(".openshift");
- if( f != null && f.exists()) {
- return true;
- }
- return false;
- }
-
+
private void addListeners() {
nameModifyListener = new ModifyListener() {
public void modifyText(ModifyEvent e) {
@@ -422,8 +426,10 @@
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());
+ if( p != null ) {
+ wc.setAttribute(IDeployableServer.DEPLOY_DIRECTORY,
p.getFolder("deployments").getLocation().toString());
+ wc.setAttribute(IDeployableServer.TEMP_DEPLOY_DIRECTORY,
p.getFolder("deployments").getLocation().toString());
+ }
} catch(CoreException ce) {
// TODO FIX HANDLE
}