Author: rob.stryker(a)jboss.com
Date: 2012-02-03 00:28:40 -0500 (Fri, 03 Feb 2012)
New Revision: 38406
Added:
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/ServerWorkingCopyPropertyComboCommand.java
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/core/behaviour/ExpressBinaryBehaviourDelegate.java
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/core/behaviour/ExpressBinaryPublishMethod.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
Removed:
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/behaviour/OpenShiftDeployUI.java
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/util/ServerUtil.java
trunk/as/plugins/org.jboss.ide.eclipse.as.core/plugin.xml
trunk/as/plugins/org.jboss.ide.eclipse.as.rse.core/plugin.xml
trunk/as/plugins/org.jboss.ide.eclipse.as.rse.ui/src/org/jboss/ide/eclipse/as/rse/ui/RSEDeploymentPreferenceUI.java
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/ServerModeSection.java
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/editor/ServerModeSectionComposite.java
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/editor/ServerWorkingCopyPropertyCommand.java
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/wizards/JBossServerWizardFragment.java
trunk/openshift/plugins/org.jboss.tools.openshift.egit.core/src/org/jboss/tools/openshift/egit/core/EGitUtils.java
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/META-INF/MANIFEST.MF
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/plugin.xml
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/core/behaviour/ExpressBehaviour.java
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/ExpressDetailsSection.java
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/behaviour/ExpressWizardFragment.java
Log:
JBIDE-10480 and JBIDE-10543 for binary server impl woooohoo
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/util/ServerUtil.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/util/ServerUtil.java 2012-02-03
01:09:36 UTC (rev 38405)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/util/ServerUtil.java 2012-02-03
05:28:40 UTC (rev 38406)
@@ -199,7 +199,7 @@
/**
* @since 2.3
*/
- public static void storeInSecureStorage(IServer server, String key, String val ) {
+ public static void storeInSecureStorage(IServerAttributes server, String key, String
val ) {
try {
ISecurePreferences node = getNode(server);
if( val == null )
Modified: trunk/as/plugins/org.jboss.ide.eclipse.as.core/plugin.xml
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.core/plugin.xml 2012-02-03 01:09:36 UTC (rev
38405)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.core/plugin.xml 2012-02-03 05:28:40 UTC (rev
38406)
@@ -1129,7 +1129,6 @@
point="org.jboss.ide.eclipse.as.core.behaviourExtension">
<behaviour
behaviourDelegate=""
- launchDelegate=""
name="Local"
publishMethod="org.jboss.ide.eclipse.as.core.publishers.LocalPublishMethod"
serverTypes="org.jboss.ide.eclipse.as.systemCopyServer"
Modified: trunk/as/plugins/org.jboss.ide.eclipse.as.rse.core/plugin.xml
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.rse.core/plugin.xml 2012-02-03 01:09:36 UTC
(rev 38405)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.rse.core/plugin.xml 2012-02-03 05:28:40 UTC
(rev 38406)
@@ -4,6 +4,12 @@
<extension
point="org.jboss.ide.eclipse.as.core.behaviourExtension">
<behaviour
+ name="%RSEMethodName"
+ publishMethod="org.jboss.ide.eclipse.as.rse.core.RSEPublishMethod"
+ serverTypes="org.jboss.ide.eclipse.as.systemCopyServer"
+ typeId="rse">
+ </behaviour>
+ <behaviour
behaviourDelegate="org.jboss.ide.eclipse.as.rse.core.RSEBehaviourDelegate"
launchDelegate="org.jboss.ide.eclipse.as.rse.core.RSEJBossStartLaunchDelegate"
name="%RSEMethodName"
@@ -11,9 +17,6 @@
serverTypes="%ServerTypesJBoss6OrLower"
typeId="rse">
</behaviour>
- </extension>
- <extension
- point="org.jboss.ide.eclipse.as.core.behaviourExtension">
<behaviour
behaviourDelegate="org.jboss.ide.eclipse.as.rse.core.RSEJBoss7BehaviourDelegate"
launchDelegate="org.jboss.ide.eclipse.as.rse.core.RSEJBoss7StartLaunchDelegate"
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.rse.ui/src/org/jboss/ide/eclipse/as/rse/ui/RSEDeploymentPreferenceUI.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.rse.ui/src/org/jboss/ide/eclipse/as/rse/ui/RSEDeploymentPreferenceUI.java 2012-02-03
01:09:36 UTC (rev 38405)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.rse.ui/src/org/jboss/ide/eclipse/as/rse/ui/RSEDeploymentPreferenceUI.java 2012-02-03
05:28:40 UTC (rev 38406)
@@ -13,7 +13,9 @@
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
+import org.eclipse.core.runtime.CoreException;
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;
@@ -445,4 +447,10 @@
}
return null;
}
+
+ @Override
+ public void performFinish(IProgressMonitor monitor) throws CoreException {
+ // TODO Auto-generated method stub
+
+ }
}
Added:
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
(rev 0)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/editor/DeploymentTypeUIUtil.java 2012-02-03
05:28:40 UTC (rev 38406)
@@ -0,0 +1,141 @@
+/*******************************************************************************
+ * Copyright (c) 2012 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.ide.eclipse.as.ui.editor;
+
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.commands.operations.IUndoableOperation;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.jface.dialogs.IMessageProvider;
+import org.eclipse.ui.IEditorInput;
+import org.eclipse.wst.server.core.IRuntime;
+import org.eclipse.wst.server.core.IServerWorkingCopy;
+import org.eclipse.wst.server.core.TaskModel;
+import org.eclipse.wst.server.ui.editor.ServerEditorPart;
+import org.eclipse.wst.server.ui.editor.ServerEditorSection;
+import org.eclipse.wst.server.ui.internal.editor.ServerEditorPartInput;
+import org.eclipse.wst.server.ui.internal.editor.ServerResourceCommandManager;
+import org.eclipse.wst.server.ui.wizard.IWizardHandle;
+import org.jboss.ide.eclipse.as.ui.editor.IDeploymentTypeUI.IServerModeUICallback;
+
+/**
+ * Provide utility methods to acquire a valid callback for
+ * use in either a new server wizard or inside a server editor
+ *
+ * @author rob.stryker
+ *
+ */
+public class DeploymentTypeUIUtil {
+
+ public interface ICompletable {
+ public void setComplete(boolean complete);
+ }
+
+ public static IServerModeUICallback getCallback(TaskModel tm, IWizardHandle handle,
ICompletable completable) {
+ return new NewServerWizardBehaviourCallback(tm, handle, completable);
+ }
+
+ public static IServerModeUICallback getCallback(final IServerWorkingCopy server,
IEditorInput input, ServerEditorPart part) {
+ return new ServerEditorUICallback(server, input, part);
+ }
+ public static IServerModeUICallback getCallback(final IServerWorkingCopy server,
IEditorInput input, ServerEditorSection section) {
+ return new ServerEditorUICallback(server, input, section);
+ }
+
+
+ /**
+ * For use inside a wizard fragment
+ */
+ public static class NewServerWizardBehaviourCallback implements IServerModeUICallback {
+ protected TaskModel tm;
+ protected IWizardHandle handle;
+ protected ICompletable completable;
+ public NewServerWizardBehaviourCallback(TaskModel tm,
+ IWizardHandle handle, ICompletable completable) {
+ this.tm = tm;
+ this.handle = handle;
+ this.completable = completable;
+ }
+ public IRuntime getRuntime() {
+ return (IRuntime) tm.getObject(TaskModel.TASK_RUNTIME);
+ }
+ public IServerWorkingCopy getServer() {
+ return (IServerWorkingCopy) tm.getObject(TaskModel.TASK_SERVER);
+ }
+ public IWizardHandle getHandle() {
+ return handle;
+ }
+ public void execute(IUndoableOperation operation) {
+ try {
+ operation.execute(new NullProgressMonitor(), null);
+ } catch(ExecutionException ee) {
+ // TODO
+ }
+ }
+ public void executeLongRunning(Job j) {
+ // depends on COMMON, DAMN
+// IWizardContainer container = ((WizardPage)handle).getWizard().getContainer();
+// try {
+// WizardUtils.runInWizard(j, null, container);
+// } catch(Exception e) {
+// // TODO clean
+// }
+ j.schedule();
+ }
+ @Override
+ public void setErrorMessage(String msg) {
+ if( completable != null )
+ completable.setComplete(msg == null);
+ handle.setMessage(msg, IMessageProvider.ERROR);
+ handle.update();
+ }
+ }
+
+
+ /**
+ * For use inside a server editor
+ */
+ public static class ServerEditorUICallback implements IServerModeUICallback {
+ private IServerWorkingCopy server;
+ private ServerResourceCommandManager commandManager;
+ private ServerEditorPart part;
+ private ServerEditorSection section;
+ public ServerEditorUICallback(final IServerWorkingCopy server, IEditorInput input,
ServerEditorPart part ) {
+ this.part = part;
+ this.server = server;
+ commandManager = ((ServerEditorPartInput) input).getServerCommandManager();
+ }
+ public ServerEditorUICallback(final IServerWorkingCopy server, IEditorInput input,
ServerEditorSection section) {
+ this.section = section;
+ this.server = server;
+ commandManager = ((ServerEditorPartInput) input).getServerCommandManager();
+ }
+ public IServerWorkingCopy getServer() {
+ return server;
+ }
+ public void execute(IUndoableOperation operation) {
+ commandManager.execute(operation);
+ }
+ public IRuntime getRuntime() {
+ return server.getRuntime();
+ }
+ public void executeLongRunning(Job j) {
+ j.schedule();
+ }
+ public void setErrorMessage(String msg) {
+ if( part != null )
+ part.setErrorMessage(msg);
+ else
+ section.setErrorMessage(msg);
+ }
+ }
+
+}
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-03
01:09:36 UTC (rev 38405)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/editor/IDeploymentTypeUI.java 2012-02-03
05:28:40 UTC (rev 38406)
@@ -11,6 +11,9 @@
package org.jboss.ide.eclipse.as.ui.editor;
import org.eclipse.core.commands.operations.IUndoableOperation;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.wst.server.core.IRuntime;
import org.eclipse.wst.server.core.IServerWorkingCopy;
@@ -21,6 +24,8 @@
public IServerWorkingCopy getServer();
public IRuntime getRuntime();
public void execute(IUndoableOperation operation);
+ public void executeLongRunning(Job j);
+ public void setErrorMessage(String msg);
}
/**
@@ -37,4 +42,10 @@
* @param modeSection
*/
public void fillComposite(Composite parent, IServerModeUICallback callback);
+
+ /**
+ * Allow the mode composite to take some action on finish
+ * @since 2.3
+ */
+ public void performFinish(IProgressMonitor monitor) throws CoreException;
}
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/editor/ServerModeSection.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/editor/ServerModeSection.java 2012-02-03
01:09:36 UTC (rev 38405)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/editor/ServerModeSection.java 2012-02-03
05:28:40 UTC (rev 38406)
@@ -10,7 +10,6 @@
******************************************************************************/
package org.jboss.ide.eclipse.as.ui.editor;
-import org.eclipse.core.commands.operations.IUndoableOperation;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.widgets.Composite;
@@ -20,48 +19,25 @@
import org.eclipse.ui.forms.widgets.ExpandableComposite;
import org.eclipse.ui.forms.widgets.FormToolkit;
import org.eclipse.ui.forms.widgets.Section;
-import org.eclipse.wst.server.core.IRuntime;
import org.eclipse.wst.server.core.IServerWorkingCopy;
-import org.eclipse.wst.server.ui.editor.IServerEditorPartInput;
import org.eclipse.wst.server.ui.editor.ServerEditorSection;
-import org.eclipse.wst.server.ui.internal.editor.ServerEditorPartInput;
-import org.eclipse.wst.server.ui.internal.editor.ServerResourceCommandManager;
import org.jboss.ide.eclipse.as.ui.editor.IDeploymentTypeUI.IServerModeUICallback;
public class ServerModeSection extends ServerEditorSection {
private IServerModeUICallback callback = null;
- private ServerResourceCommandManager commandManager;
-
+ private IEditorInput input;
public void init(IEditorSite site, IEditorInput input) {
super.init(site, input);
- if (input instanceof IServerEditorPartInput) {
- IServerEditorPartInput sepi = (IServerEditorPartInput) input;
- server = sepi.getServer();
- commandManager = ((ServerEditorPartInput) sepi).getServerCommandManager();
- }
+ this.input = input;
}
- public ServerResourceCommandManager getCommandManager() {
- return commandManager;
- }
-
public IServerWorkingCopy getServer() {
return server;
}
private IServerModeUICallback getUICallback() {
if( callback == null ) {
- callback = new IServerModeUICallback(){
- public IServerWorkingCopy getServer() {
- return server;
- }
- public void execute(IUndoableOperation operation) {
- getCommandManager().execute(operation);
- }
- public IRuntime getRuntime() {
- return server.getRuntime();
- }
- };
+ callback = DeploymentTypeUIUtil.getCallback(server, input, this);
}
return callback;
}
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/editor/ServerModeSectionComposite.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/editor/ServerModeSectionComposite.java 2012-02-03
01:09:36 UTC (rev 38405)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/editor/ServerModeSectionComposite.java 2012-02-03
05:28:40 UTC (rev 38406)
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2010 Red Hat, Inc.
+ * Copyright (c) 2012 Red Hat, Inc.
* Distributed under license by Red Hat, Inc. All rights reserved.
* This program is made available under the terms of the
* Eclipse Public License v1.0 which accompanies this distribution,
@@ -52,6 +52,8 @@
private Button executeShellScripts; // may be null;
private Button listenOnAllHosts; // may be null
+ private DeployUIAdditions currentUIAddition;
+
public ServerModeSectionComposite(Composite parent, int style, IServerModeUICallback
callback) {
super(parent, style);
this.callback = callback;
@@ -99,8 +101,9 @@
preferencePageBook = toolkit.createPageBook(this, SWT.FLAT|SWT.TOP);
+
preferencePageBook.setLayoutData(UIUtil.createFormData2(
- deployTypeCombo, 5, 0, 200, 0, 5, 100, -5));
+ deployTypeCombo, 5, 0, 300, 0, 5, 100, -5));
// fill widgets
String[] nameList = new String[deployAdditions.size()];
@@ -114,10 +117,10 @@
Behaviour b =
BehaviourModel.getModel().getBehaviour(callback.getServer().getOriginal().getServerType().getId());
String behaviourType = DeploymentPreferenceLoader.getCurrentDeploymentMethodTypeId(
callback.getServer().getOriginal(), getDefaultServerMode());
- current = b.getImpl(behaviourType).getName();
+ if( b.getImpl(behaviourType) != null )
+ current = b.getImpl(behaviourType).getName();
} else {
String host = callback.getServer().getHost();
-// IJBossServerPublishMethodType behType = null;
BehaviourImpl impl = null;
String serverTypeId = callback.getServer().getServerType().getId();
if( SocketUtil.isLocalhost(host)) {
@@ -143,6 +146,10 @@
deployTypeChanged(false);
}
+ public IDeploymentTypeUI getCurrentBehaviourUI() {
+ return currentUIAddition.getUI();
+ }
+
protected String getDefaultServerMode() {
return LocalPublishMethod.LOCAL_PUBLISH_METHOD;
}
@@ -184,7 +191,9 @@
this.behaviourId = id;
this.ui = ui;
}
-
+ public IDeploymentTypeUI getUI() {
+ return ui;
+ }
public boolean isRegistered() {
return registered;
}
@@ -216,6 +225,7 @@
int index = deployTypeCombo.getSelectionIndex();
if( index != -1 ) {
DeployUIAdditions ui = deployAdditions.get(index);
+ currentUIAddition = ui;
if( !ui.isRegistered()) {
Composite newRoot = preferencePageBook.createPage(ui);
ui.createComposite(newRoot);
Added:
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/editor/ServerWorkingCopyPropertyComboCommand.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/editor/ServerWorkingCopyPropertyComboCommand.java
(rev 0)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/editor/ServerWorkingCopyPropertyComboCommand.java 2012-02-03
05:28:40 UTC (rev 38406)
@@ -0,0 +1,53 @@
+/*******************************************************************************
+ * Copyright (c) 2012 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.ide.eclipse.as.ui.editor;
+
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.widgets.Combo;
+import org.eclipse.wst.server.core.IServerWorkingCopy;
+import org.eclipse.wst.server.ui.internal.command.ServerCommand;
+/**
+ * @since 2.3
+ */
+public class ServerWorkingCopyPropertyComboCommand extends ServerCommand {
+ protected String oldVal;
+ protected String newVal;
+ protected String key;
+ protected Combo combo;
+ protected ModifyListener listener;
+ protected IServerWorkingCopy wc;
+
+ public ServerWorkingCopyPropertyComboCommand(IServerWorkingCopy wc, String commandName,
+ Combo combo, String newVal, String attributeKey, ModifyListener listener) {
+ super(wc, commandName);
+ this.wc = wc;
+ this.combo = combo;
+ this.key = attributeKey;
+ this.newVal = newVal;
+ this.listener = listener;
+ if( key != null )
+ this.oldVal = wc.getAttribute(attributeKey, ""); //$NON-NLS-1$
+ }
+
+ public void execute() {
+ wc.setAttribute(key, newVal);
+ }
+
+ public void undo() {
+ if( listener != null )
+ combo.removeModifyListener(listener);
+ wc.setAttribute(key, oldVal);
+ if( combo != null && !combo.isDisposed())
+ combo.setText(oldVal);
+ if( listener != null )
+ combo.addModifyListener(listener);
+ }
+}
\ No newline at end of file
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/editor/ServerWorkingCopyPropertyCommand.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/editor/ServerWorkingCopyPropertyCommand.java 2012-02-03
01:09:36 UTC (rev 38405)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/editor/ServerWorkingCopyPropertyCommand.java 2012-02-03
05:28:40 UTC (rev 38406)
@@ -16,8 +16,7 @@
protected IServerWorkingCopy wc;
public ServerWorkingCopyPropertyCommand(IServerWorkingCopy wc, String commandName,
- Text text, String newVal, String attributeKey,
- ModifyListener listener) {
+ Text text, String newVal, String attributeKey, ModifyListener listener) {
super(wc, commandName);
this.wc = wc;
this.text = text;
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/wizards/JBossServerWizardFragment.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/wizards/JBossServerWizardFragment.java 2012-02-03
01:09:36 UTC (rev 38405)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/wizards/JBossServerWizardFragment.java 2012-02-03
05:28:40 UTC (rev 38406)
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2011 Red Hat, Inc.
+ * Copyright (c) 2012 Red Hat, Inc.
* Distributed under license by Red Hat, Inc. All rights reserved.
* This program is made available under the terms of the
* Eclipse Public License v1.0 which accompanies this distribution,
@@ -11,8 +11,6 @@
package org.jboss.ide.eclipse.as.ui.wizards;
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.core.commands.operations.IUndoableOperation;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.NullProgressMonitor;
@@ -40,7 +38,9 @@
import org.jboss.ide.eclipse.as.ui.JBossServerUISharedImages;
import org.jboss.ide.eclipse.as.ui.Messages;
import org.jboss.ide.eclipse.as.ui.UIUtil;
-import org.jboss.ide.eclipse.as.ui.editor.IDeploymentTypeUI.IServerModeUICallback;
+import org.jboss.ide.eclipse.as.ui.editor.DeploymentTypeUIUtil;
+import org.jboss.ide.eclipse.as.ui.editor.DeploymentTypeUIUtil.ICompletable;
+import org.jboss.ide.eclipse.as.ui.editor.IDeploymentTypeUI;
import org.jboss.ide.eclipse.as.ui.editor.ServerModeSectionComposite;
/**
@@ -48,7 +48,7 @@
* @author Rob Stryker <rob.stryker(a)redhat.com>
*
*/
-public class JBossServerWizardFragment extends WizardFragment {
+public class JBossServerWizardFragment extends WizardFragment implements ICompletable {
private IWizardHandle handle;
private Label serverExplanationLabel,
runtimeExplanationLabel;
@@ -56,11 +56,14 @@
private Label homeValLabel, execEnvironmentValLabel, jreValLabel, configValLabel,
configLocValLabel;
private Group runtimeGroup;
+ private ServerModeSectionComposite modeComposite;
public JBossServerWizardFragment() {
super();
}
-
+ public void setComplete(boolean complete) {
+ super.setComplete(complete);
+ }
public Composite createComposite(Composite parent, IWizardHandle handle) {
this.handle = handle;
// make modifications to parent
@@ -173,24 +176,10 @@
g.setLayoutData(groupData);
g.setLayout(new FillLayout());
- new ServerModeSectionComposite(g, SWT.NONE, new NewServerWizardBehaviourCallback());
+ modeComposite = new ServerModeSectionComposite(g, SWT.NONE,
+ DeploymentTypeUIUtil.getCallback(getTaskModel(), handle, this));
}
- private class NewServerWizardBehaviourCallback implements IServerModeUICallback {
- public IRuntime getRuntime() {
- return (IRuntime) getTaskModel().getObject(TaskModel.TASK_RUNTIME);
- }
- public IServerWorkingCopy getServer() {
- return (IServerWorkingCopy) getTaskModel().getObject(TaskModel.TASK_SERVER);
- }
- public void execute(IUndoableOperation operation) {
- try {
- operation.execute(new NullProgressMonitor(), null);
- } catch(ExecutionException ee) {
- // TODO
- }
- }
- }
private void updateErrorMessage() {
String error = getErrorString();
@@ -231,6 +220,9 @@
IServerWorkingCopy serverWC = (IServerWorkingCopy)
getTaskModel().getObject(TaskModel.TASK_SERVER);
serverWC.setRuntime((IRuntime)getTaskModel().getObject(TaskModel.TASK_RUNTIME));
serverWC.setServerConfiguration(null); // no inside jboss folder
+ IDeploymentTypeUI ui = modeComposite.getCurrentBehaviourUI();
+ if( ui != null )
+ ui.performFinish(monitor);
}
private IJBossServerRuntime getRuntime() {
@@ -246,7 +238,7 @@
}
public boolean isComplete() {
- return getErrorString() == null ? true : false;
+ return super.isComplete();
}
public boolean hasComposite() {
Modified:
trunk/openshift/plugins/org.jboss.tools.openshift.egit.core/src/org/jboss/tools/openshift/egit/core/EGitUtils.java
===================================================================
---
trunk/openshift/plugins/org.jboss.tools.openshift.egit.core/src/org/jboss/tools/openshift/egit/core/EGitUtils.java 2012-02-03
01:09:36 UTC (rev 38405)
+++
trunk/openshift/plugins/org.jboss.tools.openshift.egit.core/src/org/jboss/tools/openshift/egit/core/EGitUtils.java 2012-02-03
05:28:40 UTC (rev 38406)
@@ -361,6 +361,22 @@
return op.getCommit();
}
+ public static List<URIish> getRemoteURIs(IProject p) throws CoreException {
+ RemoteConfig rc = getRemoteConfig(p);
+ if( rc != null ) {
+ return rc.getURIs();
+ }
+ return new ArrayList<URIish>();
+ }
+
+ public static RemoteConfig getRemoteConfig(IProject project) throws CoreException {
+ Repository rep = getRepository(project);
+ if( rep != null ) {
+ return getRemoteConfig(rep);
+ }
+ return null;
+ }
+
/**
* Pushes the current branch of the given repository to the remote
* repository that it originates from.
Modified:
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/META-INF/MANIFEST.MF
===================================================================
---
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/META-INF/MANIFEST.MF 2012-02-03
01:09:36 UTC (rev 38405)
+++
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/META-INF/MANIFEST.MF 2012-02-03
05:28:40 UTC (rev 38406)
@@ -37,7 +37,8 @@
org.eclipse.core.expressions;bundle-version="3.4.300",
org.eclipse.wst.common.modulecore;bundle-version="1.2.101",
org.jboss.ide.eclipse.as.wtp.core;bundle-version="2.3.0",
- org.eclipse.ui.forms;bundle-version="3.5.100"
+ org.eclipse.ui.forms;bundle-version="3.5.100",
+ org.jboss.ide.eclipse.archives.webtools;bundle-version="2.3.0"
Bundle-ActivationPolicy: lazy
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Import-Package: org.jboss.tools.common.databinding,
Modified: trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/plugin.xml
===================================================================
--- trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/plugin.xml 2012-02-03
01:09:36 UTC (rev 38405)
+++ trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/plugin.xml 2012-02-03
05:28:40 UTC (rev 38406)
@@ -71,6 +71,14 @@
serverTypes="org.jboss.tools.openshift.express.openshift.server.type"
typeId="openshift">
</behaviour>
+ <behaviour
+
behaviourDelegate="org.jboss.tools.openshift.express.internal.core.behaviour.ExpressBinaryBehaviourDelegate"
+
launchDelegate="org.jboss.tools.openshift.express.internal.core.behaviour.ExpressLaunchDelegate"
+ name="Openshift Binary"
+
publishMethod="org.jboss.tools.openshift.express.internal.core.behaviour.ExpressBinaryPublishMethod"
+ serverTypes="org.jboss.ide.eclipse.as.70"
+ typeId="openshiftBinary">
+ </behaviour>
</extension>
<extension
@@ -271,4 +279,16 @@
typeIds="org.jboss.tools.openshift.express.openshift.server.type">
</fragment>
</extension>
+
+
+
+
+ <!-- Openshift Binary -->
+ <extension
+ point="org.jboss.ide.eclipse.as.ui.DeployMethodUI">
+ <ui
class="org.jboss.tools.openshift.express.internal.ui.behaviour.ExpressBinaryUI"
+ deployMethodId="openshiftBinary">
+ </ui>
+ </extension>
+
</plugin>
Modified:
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/core/behaviour/ExpressBehaviour.java
===================================================================
---
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/core/behaviour/ExpressBehaviour.java 2012-02-03
01:09:36 UTC (rev 38405)
+++
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/core/behaviour/ExpressBehaviour.java 2012-02-03
05:28:40 UTC (rev 38406)
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2011 Red Hat Inc..
+ * Copyright (c) 2012 Red Hat Inc..
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
Added:
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/core/behaviour/ExpressBinaryBehaviourDelegate.java
===================================================================
---
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/core/behaviour/ExpressBinaryBehaviourDelegate.java
(rev 0)
+++
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/core/behaviour/ExpressBinaryBehaviourDelegate.java 2012-02-03
05:28:40 UTC (rev 38406)
@@ -0,0 +1,49 @@
+/*******************************************************************************
+ * Copyright (c) 2012 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.openshift.express.internal.core.behaviour;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.jboss.ide.eclipse.as.core.server.internal.AbstractBehaviourDelegate;
+
+public class ExpressBinaryBehaviourDelegate extends AbstractBehaviourDelegate {
+
+ public static final String OPENSHIFT_BINARY_ID = "openshiftBinary";
+ public ExpressBinaryBehaviourDelegate() {
+ // TODO Auto-generated constructor stub
+ }
+ @Override
+ public String getBehaviourTypeId() {
+ return OPENSHIFT_BINARY_ID;
+ }
+
+ @Override
+ public void publishStart(IProgressMonitor monitor) throws CoreException {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void publishFinish(IProgressMonitor monitor) throws CoreException {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public IStatus canChangeState(String launchMode) {
+ // TODO Auto-generated method stub
+ return Status.OK_STATUS;
+ }
+
+
+}
Added:
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/core/behaviour/ExpressBinaryPublishMethod.java
===================================================================
---
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/core/behaviour/ExpressBinaryPublishMethod.java
(rev 0)
+++
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/core/behaviour/ExpressBinaryPublishMethod.java 2012-02-03
05:28:40 UTC (rev 38406)
@@ -0,0 +1,90 @@
+/*******************************************************************************
+ * Copyright (c) 2012 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.openshift.express.internal.core.behaviour;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.resources.WorkspaceJob;
+import org.eclipse.core.runtime.CoreException;
+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.Status;
+import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.wst.server.core.IModule;
+import org.eclipse.wst.server.core.IServer;
+import org.eclipse.wst.server.core.model.IModuleResourceDelta;
+import org.eclipse.wst.server.core.model.ServerBehaviourDelegate;
+import org.jboss.ide.eclipse.archives.webtools.modules.LocalZippedPublisherUtil;
+import org.jboss.ide.eclipse.as.core.publishers.PublishUtil;
+import org.jboss.ide.eclipse.as.core.server.IDeployableServer;
+import org.jboss.ide.eclipse.as.core.server.internal.DeployableServerBehavior;
+import org.jboss.ide.eclipse.as.core.util.IJBossToolingConstants;
+import org.jboss.ide.eclipse.as.core.util.ServerConverter;
+
+public class ExpressBinaryPublishMethod extends ExpressPublishMethod {
+
+ @Override
+ public int publishFinish(DeployableServerBehavior behaviour,
+ IProgressMonitor monitor) throws CoreException {
+
+ String outProject = ExpressServerUtils.getExpressDeployProject(behaviour.getServer());
+ if( outProject != null ) {
+ final IProject destProj =
ResourcesPlugin.getWorkspace().getRoot().getProject(outProject);
+ if( destProj.exists() ) {
+ refreshProject(destProj);
+ commitAndPushProject(destProj, behaviour, monitor);
+ }
+ }
+
+ return areAllPublished(behaviour) ? IServer.PUBLISH_STATE_NONE :
IServer.PUBLISH_STATE_INCREMENTAL;
+ }
+
+ private void refreshProject(final IProject project) throws CoreException {
+ // Already inside a workspace scheduling rule
+ project.refreshLocal(IResource.DEPTH_INFINITE, new NullProgressMonitor());
+ }
+
+ @Override
+ public int publishModule(DeployableServerBehavior behaviour, int kind,
+ int deltaKind, IModule[] module, IProgressMonitor monitor)
+ throws CoreException {
+ if( module.length > 1 )
+ return 0;
+
+ IDeployableServer depServ =
ServerConverter.getDeployableServer(behaviour.getServer());
+ IPath dest = PublishUtil.getDeployRootFolder(module, depServ);
+ //PublishUtil.getDeployPath(this, module, depServ);
+
+ if( module.length == 0 ) return IServer.PUBLISH_STATE_NONE;
+ int modulePublishState = behaviour.getServer().getModulePublishState(module);
+ int publishType = behaviour.getPublishType(kind, deltaKind, modulePublishState);
+
+ IModuleResourceDelta[] delta = new IModuleResourceDelta[]{};
+ if( deltaKind != ServerBehaviourDelegate.REMOVED)
+ delta = behaviour.getPublishedResourceDelta(module);
+
+
+ LocalZippedPublisherUtil util = new LocalZippedPublisherUtil();
+ IStatus status = util.publishModule(behaviour.getServer(), dest.toString(), module,
publishType, delta, monitor);
+ monitor.done();
+ return 0;
+ }
+
+ @Override
+ public String getPublishDefaultRootFolder(IServer server) {
+ IDeployableServer s = ServerConverter.getDeployableServer(server);
+ return s.getDeployFolder();
+ }
+
+}
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-03
01:09:36 UTC (rev 38405)
+++
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/core/behaviour/ExpressPublishMethod.java 2012-02-03
05:28:40 UTC (rev 38406)
@@ -27,13 +27,11 @@
import org.eclipse.swt.widgets.Shell;
import org.eclipse.team.internal.ui.wizards.ConfigureProjectWizard;
import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.internal.navigator.filters.CoreExpressionFilter;
import org.eclipse.wst.server.core.IModule;
import org.eclipse.wst.server.core.IServer;
import org.eclipse.wst.server.core.model.ServerBehaviourDelegate;
import org.jboss.ide.eclipse.as.core.server.IJBossServerPublishMethod;
import org.jboss.ide.eclipse.as.core.server.IPublishCopyCallbackHandler;
-import org.jboss.ide.eclipse.as.core.server.IServerAlreadyStartedHandler;
import org.jboss.ide.eclipse.as.core.server.internal.DeployableServerBehavior;
import org.jboss.tools.openshift.egit.core.EGitUtils;
import org.jboss.tools.openshift.express.internal.ui.console.ConsoleUtils;
@@ -61,14 +59,18 @@
shareProjects(projects);
projectsLackingGitRepo = null;
}
+ return areAllPublished(behaviour) ? IServer.PUBLISH_STATE_NONE :
IServer.PUBLISH_STATE_INCREMENTAL;
+ }
+
+ protected boolean areAllPublished(DeployableServerBehavior behaviour) {
IModule[] modules = behaviour.getServer().getModules();
boolean allpublished= true;
for (int i = 0; i < modules.length; i++) {
if(behaviour.getServer().getModulePublishState(new
IModule[]{modules[i]})!=IServer.PUBLISH_STATE_NONE)
allpublished=false;
}
- return allpublished ? IServer.PUBLISH_STATE_NONE :
IServer.PUBLISH_STATE_INCREMENTAL;
- }
+ return allpublished;
+ }
@Override
public int publishModule(DeployableServerBehavior behaviour, int kind,
@@ -98,19 +100,28 @@
return IServer.PUBLISH_STATE_UNKNOWN;
}
+ commitAndPushProject(p, behaviour, monitor);
+
+ return IServer.PUBLISH_STATE_NONE;
+ }
+
+ protected PushOperationResult commitAndPushProject(IProject p,
+ DeployableServerBehavior behaviour, IProgressMonitor monitor) throws CoreException {
+ Repository repository = EGitUtils.getRepository(p);
+
int changed = EGitUtils.countCommitableChanges(p, behaviour.getServer(), new
NullProgressMonitor() );
String remoteName =
behaviour.getServer().getAttribute(ExpressServerUtils.ATTRIBUTE_REMOTE_NAME,
ExpressServerUtils.ATTRIBUTE_REMOTE_NAME_DEFAULT);
PushOperationResult result = null;
boolean committed = false;
try {
- if( changed != 0 && requestCommitAndPushApproval(module, changed)) {
+ if( changed != 0 && requestCommitAndPushApproval(p.getName(), changed)) {
monitor.beginTask("Publishing " + p.getName(), 300);
EGitUtils.commit(p, new SubProgressMonitor(monitor, 100));
committed = true;
}
- if( committed || (changed == 0 && requestPushApproval(module))) {
+ if( committed || (changed == 0 && requestPushApproval(p.getName()))) {
if( !committed )
monitor.beginTask("Publishing " + p.getName(), 200);
result = EGitUtils.push(remoteName, EGitUtils.getRepository(p), new
SubProgressMonitor(monitor, 100));
@@ -131,10 +142,10 @@
if( result != null ) {
ConsoleUtils.appendGitPushToConsole(behaviour.getServer(), result);
}
-
- return IServer.PUBLISH_STATE_NONE;
+ return result;
}
-
+
+
private void shareProjects(final IProject[] projects) {
Display.getDefault().asyncExec(new Runnable() {
public void run() {
@@ -150,21 +161,23 @@
});
}
- private boolean requestCommitAndPushApproval(final IModule[] module, int changed) {
- String projName = module[module.length-1].getProject().getName();
+ protected String getModuleProjectName(IModule[] module) {
+ return module[module.length-1].getProject().getName();
+ }
+
+ protected boolean requestCommitAndPushApproval(String projName, int changed) {
String msg = NLS.bind(ExpressMessages.requestCommitAndPushMsg, changed, projName);
String title = NLS.bind(ExpressMessages.requestCommitAndPushTitle, projName);
return requestApproval(msg, title);
}
- private boolean requestPushApproval(final IModule[] module) {
- String projName = module[module.length-1].getProject().getName();
+ protected boolean requestPushApproval(String projName) {
String msg = NLS.bind(ExpressMessages.requestPushMsg, projName);
String title = NLS.bind(ExpressMessages.requestPushTitle, projName);
return requestApproval(msg, title);
}
- private boolean requestApproval(final String message, final String title) {
+ protected boolean requestApproval(final String message, final String title) {
final boolean[] b = new boolean[1];
Display.getDefault().syncExec(new Runnable() {
public void run() {
@@ -174,7 +187,7 @@
return b[0];
}
- private static Shell getActiveShell() {
+ protected static Shell getActiveShell() {
Display display = Display.getDefault();
final Shell[] ret = new Shell[1];
display.syncExec(new Runnable() {
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-03
01:09:36 UTC (rev 38405)
+++
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/core/behaviour/ExpressServerUtils.java 2012-02-03
05:28:40 UTC (rev 38406)
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2011 Red Hat Inc..
+ * Copyright (c) 2012 Red Hat Inc..
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -42,6 +42,7 @@
public static final String EXPRESS_SOURCE_MODE = "publishSource";
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";
// Legacy, not to be used
@@ -72,18 +73,26 @@
public static String getExpressApplicationName(IServerAttributes attributes ) {
return attributes.getAttribute(ATTRIBUTE_APPLICATION_NAME, (String)null);
}
-
- public static String getExpressApplicationId(IServerAttributes attributes ) {
- return attributes.getAttribute(ATTRIBUTE_APPLICATION_ID, (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);
+ }
+
public static String getExpressDomain(IServerAttributes attributes ) {
return attributes.getAttribute(ATTRIBUTE_DOMAIN, (String)null);
}
@@ -119,15 +128,16 @@
}
public static String getExpressPassword(IServer server ) {
+ 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 IServer setExpressPassword(IServer server, String val) throws
CoreException {
+ public static void setExpressPassword(IServerAttributes server, String val) throws
CoreException {
ServerUtil.storeInSecureStorage(server, ExpressServerUtils.ATTRIBUTE_PASSWORD, val);
- return server;
}
@@ -226,7 +236,12 @@
if( host.endsWith("/"))
host = host.substring(0, host.length()-1);
wc.setHost(host);
- wc.setAttribute(IDeployableServer.SERVER_MODE, "openshift");
+ 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(ATTRIBUTE_USERNAME, username);
wc.setAttribute(ATTRIBUTE_DOMAIN, domain);
wc.setAttribute(ATTRIBUTE_APPLICATION_NAME, appName);
Added:
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
(rev 0)
+++
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/behaviour/ExpressBinaryUI.java 2012-02-03
05:28:40 UTC (rev 38406)
@@ -0,0 +1,81 @@
+/*******************************************************************************
+ * Copyright (c) 2012 Red Hat Inc..
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ *
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat Incorporated - initial API and implementation
+ *******************************************************************************/
+package org.jboss.tools.openshift.express.internal.ui.behaviour;
+
+import org.eclipse.core.commands.operations.IUndoableOperation;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.jface.wizard.IWizardContainer;
+import org.eclipse.jface.wizard.WizardPage;
+import org.eclipse.swt.layout.FillLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.wst.server.core.IRuntime;
+import org.eclipse.wst.server.core.IServerWorkingCopy;
+import org.eclipse.wst.server.ui.wizard.IWizardHandle;
+import org.jboss.ide.eclipse.as.ui.editor.DeploymentTypeUIUtil;
+import org.jboss.ide.eclipse.as.ui.editor.IDeploymentTypeUI;
+import org.jboss.tools.common.ui.WizardUtils;
+import org.jboss.tools.openshift.express.internal.core.behaviour.ExpressServerUtils;
+
+public class ExpressBinaryUI implements IDeploymentTypeUI {
+ private ExpressDetailsComposite composite;
+ private IServerModeUICallback wrapped;
+ public ExpressBinaryUI() {
+ // TODO Auto-generated constructor stub
+ }
+
+ @Override
+ public void fillComposite(Composite parent, IServerModeUICallback callback) {
+ parent.setLayout(new FillLayout());
+ wrapped = wrapCallback(callback);
+
+ composite = ExpressDetailsComposite.createComposite(parent,wrapped,
+ ExpressServerUtils.EXPRESS_BINARY_MODE, true);
+ }
+
+ private IServerModeUICallback wrapCallback(final IServerModeUICallback inner) {
+ return new IServerModeUICallback() {
+ public IServerWorkingCopy getServer() {
+ return inner.getServer();
+ }
+ public IRuntime getRuntime() {
+ return inner.getRuntime();
+ }
+ public void execute(IUndoableOperation operation) {
+ inner.execute(operation);
+ }
+ public void executeLongRunning(Job j) {
+ if( inner instanceof DeploymentTypeUIUtil.NewServerWizardBehaviourCallback) {
+ IWizardHandle handle =
((DeploymentTypeUIUtil.NewServerWizardBehaviourCallback)inner).getHandle();
+ // depends on COMMON, DAMN
+ IWizardContainer container = ((WizardPage)handle).getWizard().getContainer();
+ try {
+ WizardUtils.runInWizard(j, null, container);
+ } catch(Exception e) {
+ // TODO clean
+ }
+ } else {
+ inner.executeLongRunning(j);
+ }
+ }
+ public void setErrorMessage(String msg) {
+ inner.setErrorMessage(msg);
+ }
+ };
+ }
+
+ @Override
+ public void performFinish(IProgressMonitor monitor) throws CoreException {
+ ExpressServerUtils.setExpressPassword(wrapped.getServer(), composite.getPassword());
+ }
+
+}
Added:
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
(rev 0)
+++
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/behaviour/ExpressDetailsComposite.java 2012-02-03
05:28:40 UTC (rev 38406)
@@ -0,0 +1,408 @@
+/*******************************************************************************
+ * Copyright (c) 2012 Red Hat Inc..
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ *
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat Incorporated - initial API and implementation
+ *******************************************************************************/
+package org.jboss.tools.openshift.express.internal.ui.behaviour;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Iterator;
+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;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.jface.layout.GridDataFactory;
+import org.eclipse.jgit.transport.URIish;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Combo;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.wst.server.core.IServerWorkingCopy;
+import org.jboss.ide.eclipse.as.core.server.IDeployableServer;
+import org.jboss.ide.eclipse.as.core.util.IJBossToolingConstants;
+import org.jboss.ide.eclipse.as.ui.Messages;
+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;
+import org.jboss.tools.openshift.egit.core.EGitUtils;
+import org.jboss.tools.openshift.express.internal.core.behaviour.ExpressServerUtils;
+import
org.jboss.tools.openshift.express.internal.ui.wizard.AbstractOpenShiftApplicationWizardModel;
+import org.jboss.tools.openshift.express.internal.ui.wizard.CredentialsWizardPageModel;
+
+import com.openshift.express.client.IApplication;
+import com.openshift.express.client.IUser;
+import com.openshift.express.client.OpenShiftException;
+
+public class ExpressDetailsComposite {
+ public static ExpressDetailsComposite createComposite(Composite parent,
+ IServerModeUICallback callback, String mode, boolean showVerify) {
+ Composite composite = new Composite(parent, SWT.NONE);
+ composite.setLayout(new GridLayout(2, false));
+ return new ExpressDetailsComposite(composite, callback, mode, showVerify);
+ }
+
+ protected IServerModeUICallback callback;
+ private ModifyListener nameModifyListener, remoteModifyListener,
+ passModifyListener, appModifyListener, deployProjectModifyListener;
+ protected Text userText, passText, remoteText;
+ protected Combo appNameCombo, deployProjectCombo;
+ protected Button verifyButton;
+ protected boolean showVerify;
+ private Composite composite;
+ private String user, pass, app, remote, deployProject;
+ private IApplication fapplication;
+ private IUser fuser;
+ private String[] appListNames;
+ private String error;
+ private IServerWorkingCopy server;
+ private String mode;
+ public ExpressDetailsComposite(Composite fill, IServerModeUICallback callback, String
mode, boolean showVerify) {
+ this.callback = callback;
+ this.server = callback.getServer();
+ this.mode = mode;
+ this.composite = fill;
+ this.showVerify = showVerify;
+ fillSection(fill);
+ addListeners();
+ }
+
+ public Composite getComposite() {
+ return composite;
+ }
+
+ public String getPassword() {
+ return pass;
+ }
+
+ private void fillSection(Composite composite) {
+ composite.setLayout(new GridLayout(2, false));
+ Label userLabel = new Label(composite, SWT.NONE);
+ userText = new Text(composite, SWT.SINGLE | SWT.BORDER);
+ GridDataFactory.fillDefaults().hint(150, SWT.DEFAULT).applyTo(userText);
+ Label passLabel = new Label(composite, SWT.NONE);
+ passText = new Text(composite, SWT.PASSWORD | SWT.BORDER);
+ GridDataFactory.fillDefaults().hint(150, SWT.DEFAULT).applyTo(passText);
+
+ if( mode.equals(ExpressServerUtils.EXPRESS_SOURCE_MODE) ) {
+ Label appNameLabel = new Label(composite, SWT.NONE);
+ appNameCombo = new Combo(composite, SWT.NONE);
+ 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);
+ }
+
+ Label remoteLabel = new Label(composite, SWT.NONE);
+ remoteText = new Text(composite, SWT.SINGLE | SWT.BORDER);
+ GridDataFactory.fillDefaults().hint(150, SWT.DEFAULT).applyTo(remoteText);
+
+
+ // Text
+ userLabel.setText("Username: ");
+ passLabel.setText("Password: ");
+ remoteLabel.setText("Remote: ");
+ remoteText.setText(AbstractOpenShiftApplicationWizardModel.NEW_PROJECT_REMOTE_NAME_DEFAULT);
+
+ String n = ExpressServerUtils.getExpressUsername(server);
+ String p = ExpressServerUtils.getExpressPassword(server.getOriginal());
+ String remote = ExpressServerUtils.getExpressRemoteName(server);
+ if( n != null ) userText.setText(n);
+ if( p != null ) passText.setText(p);
+ if( remote != null ) remoteText.setText(remote);
+
+ if( showVerify ) {
+ verifyButton = new Button(composite, SWT.PUSH);
+ 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) {
+ user = userText.getText();
+ callback.execute(new SetUserCommand(server));
+ }
+ };
+ userText.addModifyListener(nameModifyListener);
+
+ passModifyListener = new ModifyListener() {
+ public void modifyText(ModifyEvent e) {
+ //pass = passText.getText();
+ callback.execute(new SetPassCommand(server));
+ }
+ };
+ passText.addModifyListener(passModifyListener);
+
+ remoteModifyListener = new ModifyListener() {
+ public void modifyText(ModifyEvent e) {
+ remote = remoteText.getText();
+ callback.execute(new SetRemoteCommand(server));
+ }
+ };
+ remoteText.addModifyListener(remoteModifyListener);
+
+ if( appNameCombo != null ) {
+ appModifyListener = new ModifyListener() {
+ public void modifyText(ModifyEvent e) {
+ app = appNameCombo.getText();
+ callback.execute(new SetApplicationCommand(server));
+ }
+ };
+ appNameCombo.addModifyListener(appModifyListener);
+ }
+
+ if( deployProjectCombo != null ) {
+ deployProjectModifyListener = new ModifyListener() {
+ public void modifyText(ModifyEvent e) {
+ deployProject = deployProjectCombo.getText();
+ callback.execute(new SetDeployProjectCommand(server));
+ }
+ };
+ deployProjectCombo.addModifyListener(deployProjectModifyListener);
+ }
+
+ if( verifyButton != null ) {
+ verifyButton.addSelectionListener(new SelectionListener() {
+ public void widgetSelected(SelectionEvent e) {
+ verifyPressed();
+ }
+ public void widgetDefaultSelected(SelectionEvent e) {
+ }
+ });
+ }
+ }
+
+ private void verifyPressed() {
+ final CredentialsWizardPageModel model = new CredentialsWizardPageModel(null);
+ this.fapplication = null;
+ this.fuser = null;
+ this.appListNames = null;
+ model.setPassword(pass);
+ model.setRhLogin(user);
+ verifyButton.setEnabled(false);
+ final Runnable runnable = getVerifyingCredentialsJob(model);
+ Job j = new Job("Verifying Credentials and Application") {
+ protected IStatus run(IProgressMonitor monitor) {
+ runnable.run();
+ return Status.OK_STATUS;
+ }
+ };
+ callback.executeLongRunning(j);
+ postLongRunningValidate();
+ }
+
+ private void postLongRunningValidate() {
+ if( appListNames == null ) {
+ appListNames = new String[0];
+ }
+ if( appNameCombo != null ) {
+ int index = Arrays.asList(appListNames).indexOf(app);
+ appNameCombo.setItems(appListNames);
+ if( index != -1 )
+ appNameCombo.select(index);
+ }
+ callback.setErrorMessage(error);
+ verifyButton.setEnabled(true);
+ }
+
+
+ public class SetUserCommand extends ServerWorkingCopyPropertyCommand {
+ public SetUserCommand(IServerWorkingCopy server) {
+ super(server, Messages.EditorChangeUsernameCommandName, userText, userText.getText(),
+ ExpressServerUtils.ATTRIBUTE_USERNAME, nameModifyListener);
+ }
+ }
+
+ public class SetRemoteCommand extends ServerWorkingCopyPropertyCommand {
+ public SetRemoteCommand(IServerWorkingCopy server) {
+ super(server, "Change Remote Name", remoteText, remoteText.getText(),
+ ExpressServerUtils.ATTRIBUTE_REMOTE_NAME, remoteModifyListener);
+ }
+ }
+
+ public class SetApplicationCommand extends ServerWorkingCopyPropertyComboCommand {
+ public SetApplicationCommand(IServerWorkingCopy server) {
+ super(server, "Change Application Name", appNameCombo,
appNameCombo.getText(),
+ ExpressServerUtils.ATTRIBUTE_APPLICATION_NAME, appModifyListener);
+ }
+ }
+
+ public class SetDeployProjectCommand extends ServerWorkingCopyPropertyComboCommand {
+ public SetDeployProjectCommand(IServerWorkingCopy server) {
+ super(server, "Change Deployment Project", appNameCombo,
deployProjectCombo.getText(),
+ ExpressServerUtils.ATTRIBUTE_DEPLOY_PROJECT, deployProjectModifyListener);
+ }
+ }
+
+ public class SetPassCommand extends ServerWorkingCopyPropertyCommand {
+ public SetPassCommand(IServerWorkingCopy server) {
+ super(server, Messages.EditorChangePasswordCommandName, passText, passText.getText(),
+ IJBossToolingConstants.SERVER_PASSWORD, passModifyListener);
+ oldVal = passText.getText();
+ }
+
+ public void execute() {
+ pass = newVal;
+ }
+
+ public void undo() {
+ pass = oldVal;
+ text.removeModifyListener(listener);
+ text.setText(oldVal);
+ text.addModifyListener(listener);
+ }
+ }
+
+ private Runnable getVerifyingCredentialsJob(final CredentialsWizardPageModel model) {
+ return new Runnable() {
+ public void run() {
+ final IStatus s = model.validateCredentials();
+ String error = null;
+ if( !s.isOK() ) {
+ error = "Credentials Failed";
+ } else {
+
+ if( mode.equals(ExpressServerUtils.EXPRESS_SOURCE_MODE) ) {
+ verifyApplicationSourceMode(model);
+ } else {
+ verifyApplicationBinaryMode(model);
+ }
+ }
+ ExpressDetailsComposite.this.error = error;
+ }
+ };
+ }
+
+ private IApplication findApplicationForProject(IProject p, List<IApplication>
applications)
+ throws OpenShiftException, CoreException {
+ List<URIish> uris = EGitUtils.getRemoteURIs(p);
+ Iterator<IApplication> i = applications.iterator();
+ while(i.hasNext()) {
+ IApplication a = i.next();
+ String gitUri = a.getGitUri();
+ Iterator<URIish> j = uris.iterator();
+ while(j.hasNext()) {
+ String projUri = j.next().toPrivateString();
+ if( projUri.equals(gitUri)) {
+ return a;
+ }
+ }
+ }
+ return null;
+ }
+
+ private void verifyApplicationBinaryMode(CredentialsWizardPageModel model) {
+ System.out.println(deployProject);
+ IProject p = ResourcesPlugin.getWorkspace().getRoot().getProject(deployProject);
+ try {
+ final List<IApplication> allApps = model.getUser().getApplications();
+ fapplication = findApplicationForProject(p, allApps);
+ fuser = model.getUser();
+
+ 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) {
+ // now check the app name and cartridge
+ String[] appNames = new String[]{};
+ try {
+ final List<IApplication> allApps = model.getUser().getApplications();
+ appNames = getAppNamesAsStrings(allApps);
+ int index = Arrays.asList(appNames).indexOf(app);
+ IApplication application = index == -1 ? null : allApps.get(index);
+ ExpressDetailsComposite.this.appListNames = appNames;
+ if( application == null ) {
+ error = "Application " + app + " not found";
+ } else {
+ // Fill with new data
+ try {
+ ExpressDetailsComposite.this.fapplication = application;
+ ExpressDetailsComposite.this.fuser = model.getUser();
+
+ // update the values
+ IServerWorkingCopy wc = callback.getServer();
+ ExpressServerUtils.fillServerWithOpenShiftDetails(wc, application, fuser,
+ mode, remote);
+ } catch(CoreException ce) {
+ // TODO FIX HANDLE
+ }
+ }
+ } catch(OpenShiftException ose) {
+ error = "Application \"" + app + "\" not found: " +
ose.getMessage();
+ }
+ }
+
+
+
+ private String[] getAppNamesAsStrings(List<IApplication> allApps) {
+ String[] appNames = new String[allApps.size()];
+ for( int i = 0; i < allApps.size(); i++ ) {
+ appNames[i] = allApps.get(i).getName();
+ }
+ return appNames;
+ }
+
+
+}
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-03
01:09:36 UTC (rev 38405)
+++
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/behaviour/ExpressDetailsSection.java 2012-02-03
05:28:40 UTC (rev 38406)
@@ -12,30 +12,25 @@
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.swt.events.ModifyEvent;
-import org.eclipse.swt.events.ModifyListener;
import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Text;
-import org.eclipse.ui.forms.IFormColors;
+import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.IEditorSite;
import org.eclipse.ui.forms.widgets.ExpandableComposite;
import org.eclipse.ui.forms.widgets.FormToolkit;
import org.eclipse.ui.forms.widgets.Section;
-import org.eclipse.wst.server.core.IServerWorkingCopy;
import org.eclipse.wst.server.ui.editor.ServerEditorSection;
-import org.jboss.ide.eclipse.as.core.server.internal.ServerAttributeHelper;
-import org.jboss.ide.eclipse.as.ui.Messages;
-import org.jboss.ide.eclipse.as.ui.editor.ServerWorkingCopyPropertyCommand;
+import org.jboss.ide.eclipse.as.ui.editor.DeploymentTypeUIUtil;
+import org.jboss.ide.eclipse.as.ui.editor.IDeploymentTypeUI.IServerModeUICallback;
import org.jboss.tools.openshift.express.internal.core.behaviour.ExpressServerUtils;
public class ExpressDetailsSection extends ServerEditorSection {
- private ModifyListener nameModifyListener, remoteModifyListener, passModifyListener;
- private Text nameText, passText, remoteText;
- private ServerAttributeHelper helper;
-
- private String passwordString;
+ private ExpressDetailsComposite details;
+ private IEditorInput input;
+ public void init(IEditorSite site, IEditorInput input) {
+ super.init(site, input);
+ this.input = input;
+ }
public void createSection(Composite parent) {
super.createSection(parent);
@@ -44,109 +39,24 @@
Section section = toolkit.createSection(parent,
ExpandableComposite.TWISTIE|ExpandableComposite.EXPANDED|ExpandableComposite.TITLE_BAR);
section.setText("Express Server in Source Mode (Details)");
section.setLayoutData(new GridData(GridData.FILL_HORIZONTAL |
GridData.VERTICAL_ALIGN_FILL));
- Composite composite = toolkit.createComposite(section);
- composite.setLayout(new GridLayout(2, false));
- fillSection(composite, toolkit);
- addListeners();
-
- toolkit.paintBordersFor(composite);
- section.setClient(composite);
+ details = ExpressDetailsComposite.createComposite(section, createCallback(),
ExpressServerUtils.EXPRESS_SOURCE_MODE, false);
+ toolkit.paintBordersFor(details.getComposite());
+ section.setClient(details.getComposite());
+ details.appNameCombo.setEnabled(false);
}
- private void fillSection(Composite composite, FormToolkit toolkit) {
-
- GridData d = new GridData(); d.horizontalSpan = 2;
-
- Label appName = toolkit.createLabel(composite, "Application Name");
- Label appNameVal = toolkit.createLabel(composite,
ExpressServerUtils.getExpressApplicationName(server));
- Label appId = toolkit.createLabel(composite, "Application Id");
- Label appIdVal = toolkit.createLabel(composite,
ExpressServerUtils.getExpressApplicationId(server));
-
- Label username = toolkit.createLabel(composite, Messages.swf_Username);
- username.setForeground(toolkit.getColors().getColor(IFormColors.TITLE));
- String n = ExpressServerUtils.getExpressUsername(server);
- nameText = toolkit.createText(composite, n);
- String p = ExpressServerUtils.getExpressPassword(server.getOriginal());
- Label password = toolkit.createLabel(composite, Messages.swf_Password);
- password.setForeground(toolkit.getColors().getColor(IFormColors.TITLE));
- passText = toolkit.createText(composite, p);
- passwordString = p;
- String remote = ExpressServerUtils.getExpressRemoteName(server);
- Label remoteName = toolkit.createLabel(composite, "Remote Name");
- remoteName.setForeground(toolkit.getColors().getColor(IFormColors.TITLE));
- remoteText = toolkit.createText(composite, remote);
-
- d = new GridData(); d.grabExcessHorizontalSpace = true; d.widthHint = 100;
- nameText.setLayoutData(d);
- d = new GridData(); d.grabExcessHorizontalSpace = true; d.widthHint = 100;
- passText.setLayoutData(d);
-
+ private IServerModeUICallback createCallback() {
+ return DeploymentTypeUIUtil.getCallback(server, input, this);
}
-
- private void addListeners() {
- nameModifyListener = new ModifyListener() {
- public void modifyText(ModifyEvent e) {
- execute(new SetUserCommand(server));
- }
- };
- remoteModifyListener = new ModifyListener() {
- public void modifyText(ModifyEvent e) {
- execute(new SetRemoteCommand(server));
- }
- };
-
- passModifyListener = new ModifyListener() {
- public void modifyText(ModifyEvent e) {
- execute(new SetPassCommand(server));
- }
- };
- nameText.addModifyListener(nameModifyListener);
- remoteText.addModifyListener(remoteModifyListener);
- passText.addModifyListener(passModifyListener);
- }
-
- public class SetUserCommand extends ServerWorkingCopyPropertyCommand {
- public SetUserCommand(IServerWorkingCopy server) {
- super(server, Messages.EditorChangeUsernameCommandName, nameText, nameText.getText(),
- ExpressServerUtils.ATTRIBUTE_USERNAME, nameModifyListener);
- }
- }
-
- public class SetRemoteCommand extends ServerWorkingCopyPropertyCommand {
- public SetRemoteCommand(IServerWorkingCopy server) {
- super(server, "Change Remote Name", remoteText, remoteText.getText(),
- ExpressServerUtils.ATTRIBUTE_REMOTE_NAME, remoteModifyListener);
- }
- }
-
- public class SetPassCommand extends ServerWorkingCopyPropertyCommand {
- public SetPassCommand(IServerWorkingCopy server) {
- super(server, Messages.EditorChangePasswordCommandName, passText, passText.getText(),
- null, passModifyListener);
- oldVal = passText.getText();
- }
-
- public void execute() {
- passwordString = newVal;
- }
-
- public void undo() {
- passwordString = oldVal;
- text.removeModifyListener(listener);
- text.setText(oldVal);
- text.addModifyListener(listener);
- }
- }
-
/**
* Allow a section an opportunity to respond to a doSave request on the editor.
* @param monitor the progress monitor for the save operation.
*/
public void doSave(IProgressMonitor monitor) {
try {
- ExpressServerUtils.setExpressPassword(server.getOriginal(), passwordString);
+ ExpressServerUtils.setExpressPassword(server.getOriginal(), details.getPassword());
monitor.worked(100);
} catch( CoreException ce ) {
// TODO
Modified:
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/behaviour/ExpressWizardFragment.java
===================================================================
---
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/behaviour/ExpressWizardFragment.java 2012-02-03
01:09:36 UTC (rev 38405)
+++
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/behaviour/ExpressWizardFragment.java 2012-02-03
05:28:40 UTC (rev 38406)
@@ -10,50 +10,24 @@
*******************************************************************************/
package org.jboss.tools.openshift.express.internal.ui.behaviour;
-import java.util.Arrays;
-import java.util.List;
-
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.jobs.Job;
-import org.eclipse.jface.dialogs.IMessageProvider;
-import org.eclipse.jface.layout.GridDataFactory;
import org.eclipse.jface.wizard.IWizardContainer;
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.SelectionEvent;
-import org.eclipse.swt.events.SelectionListener;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Combo;
import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Text;
-import org.eclipse.wst.server.core.IServerWorkingCopy;
-import org.eclipse.wst.server.core.TaskModel;
import org.eclipse.wst.server.ui.wizard.IWizardHandle;
import org.eclipse.wst.server.ui.wizard.WizardFragment;
+import org.jboss.ide.eclipse.as.ui.editor.DeploymentTypeUIUtil.ICompletable;
+import
org.jboss.ide.eclipse.as.ui.editor.DeploymentTypeUIUtil.NewServerWizardBehaviourCallback;
import org.jboss.tools.common.ui.WizardUtils;
import org.jboss.tools.openshift.express.internal.core.behaviour.ExpressServerUtils;
-import
org.jboss.tools.openshift.express.internal.ui.wizard.AbstractOpenShiftApplicationWizardModel;
-import org.jboss.tools.openshift.express.internal.ui.wizard.CredentialsWizardPageModel;
-import com.openshift.express.client.IApplication;
-import com.openshift.express.client.IUser;
-import com.openshift.express.client.OpenShiftException;
-
-public class ExpressWizardFragment extends WizardFragment {
+public class ExpressWizardFragment extends WizardFragment implements ICompletable {
private IWizardHandle handle;
- private IApplication fapplication;
- private IUser fuser;
- private String[] appListNames;
- private String error;
+ private ExpressDetailsComposite composite;
+ private NewServerWizardBehaviourCallback callback;
- private Button verifyButton;
public ExpressWizardFragment() {
// TODO Auto-generated constructor stub
}
@@ -61,182 +35,36 @@
public boolean hasComposite() {
return true;
}
+ public void setComplete(boolean complete) {
+ super.setComplete(complete);
+ }
+
- private String user, pass, app, remote;
- private Text userText, passText, remoteText;
- private Combo appNameCombo;
public Composite createComposite(Composite parent, IWizardHandle handle) {
this.handle = handle;
handle.setTitle("Create an Openshift Server");
handle.setDescription("Create an Openshift Server adapter by typing in your
credentials and choosing an application.");
- Composite composite = createWidgets(parent);
- addListeners();
- setComplete(false);
- widgetsUpdated();
- return composite;
- }
-
- private Composite createWidgets(Composite parent) {
- Composite composite = new Composite(parent, SWT.NONE);
- composite.setLayout(new GridLayout(2, false));
- Label userLabel = new Label(composite, SWT.NONE);
- userText = new Text(composite, SWT.SINGLE | SWT.BORDER);
- GridDataFactory.fillDefaults().hint(150, SWT.DEFAULT).applyTo(userText);
- Label passLabel = new Label(composite, SWT.NONE);
- passText = new Text(composite, SWT.PASSWORD | SWT.BORDER);
- GridDataFactory.fillDefaults().hint(150, SWT.DEFAULT).applyTo(passText);
- Label appNameLabel = new Label(composite, SWT.NONE);
- appNameCombo = new Combo(composite, SWT.SINGLE);
- Label remoteLabel = new Label(composite, SWT.NONE);
- remoteText = new Text(composite, SWT.SINGLE | SWT.BORDER);
- GridDataFactory.fillDefaults().hint(150, SWT.DEFAULT).applyTo(remoteText);
- verifyButton = new Button(composite, SWT.PUSH);
-
- // Text
- userLabel.setText("Username: ");
- passLabel.setText("Password: ");
- appNameLabel.setText("Application Name: ");
- remoteLabel.setText("Remote: ");
- verifyButton.setText("Verify...");
- remoteText.setText(AbstractOpenShiftApplicationWizardModel.NEW_PROJECT_REMOTE_NAME_DEFAULT);
- return composite;
- }
-
- private void addListeners() {
- // add listeners
- ModifyListener l = new ModifyListener(){
- public void modifyText(ModifyEvent e) {
- widgetsUpdated();
+ callback = new NewServerWizardBehaviourCallback(getTaskModel(), handle, this) {
+ public void executeLongRunning(Job j) {
+ // depends on COMMON, DAMN
+ IWizardContainer container = ((WizardPage)handle).getWizard().getContainer();
+ try {
+ WizardUtils.runInWizard(j, null, container);
+ } catch(Exception e) {
+ // TODO clean
+ }
}
};
- userText.addModifyListener(l);
- passText.addModifyListener(l);
- appNameCombo.addModifyListener(l);
- remoteText.addModifyListener(l);
- appNameCombo.addSelectionListener(new SelectionListener(){
- public void widgetSelected(SelectionEvent e) {
- widgetsUpdated();
- }
- public void widgetDefaultSelected(SelectionEvent e) {
- widgetsUpdated();
- }
- });
- verifyButton.addSelectionListener(new SelectionListener() {
- public void widgetSelected(SelectionEvent e) {
- verifyPressed();
- }
- public void widgetDefaultSelected(SelectionEvent e) {
- verifyPressed();
- }
-
- });
+ composite = ExpressDetailsComposite.createComposite(parent,callback,
ExpressServerUtils.EXPRESS_SOURCE_MODE, true);
+ setComplete(false);
+ return composite.getComposite();
}
-
+
public void enter() {
// do nothing
}
-
- private void widgetsUpdated() {
- this.user = userText.getText();
- this.pass = passText.getText();
- this.app = appNameCombo.getText();
- this.remote = remoteText.getText();
- this.verifyButton.setEnabled(true);
- setComplete(false);
- handle.update();
- }
- private void verifyPressed() {
- final CredentialsWizardPageModel model = new CredentialsWizardPageModel(null);
- this.fapplication = null;
- this.fuser = null;
- this.appListNames = null;
- model.setPassword(pass);
- model.setRhLogin(user);
- verifyButton.setEnabled(false);
- setComplete(false);
- handle.update();
- final Runnable runnable = getVerifyingCredentialsJob(model);
- Job j = new Job("Verifying Credentials and Application") {
- protected IStatus run(IProgressMonitor monitor) {
- runnable.run();
- return Status.OK_STATUS;
- }
- };
- IWizardContainer container = ((WizardPage)handle).getWizard().getContainer();
- try {
- WizardUtils.runInWizard(j, null, container);
- postLongRunningValidate();
- } catch(Exception e) {
-
- }
- }
-
- private void postLongRunningValidate() {
- if( appListNames == null ) {
- appListNames = new String[0];
- }
- int index = Arrays.asList(appListNames).indexOf(app);
- appNameCombo.setItems(appListNames);
- if( index != -1 )
- appNameCombo.select(index);
- handle.setMessage(error, IMessageProvider.ERROR);
- verifyButton.setEnabled(true);
- setComplete(ExpressWizardFragment.this.fapplication != null );
- handle.update();
- }
-
- private Runnable getVerifyingCredentialsJob(final CredentialsWizardPageModel model) {
- return new Runnable() {
- public void run() {
- final IStatus s = model.validateCredentials();
- String error = null;
- String[] appNames = new String[]{};
- if( !s.isOK() ) {
- error = "Credentials Failed";
- } else {
- // now check the app name and cartridge
- try {
- final List<IApplication> allApps = model.getUser().getApplications();
- appNames = getAppNamesAsStrings(allApps);
- int index = Arrays.asList(appNames).indexOf(app);
- IApplication application = index == -1 ? null : allApps.get(index);
- appListNames = appNames;
- if( application == null ) {
- error = "Application " + app + " not found";
- } else {
- // Fill with new data
- try {
- ExpressWizardFragment.this.fapplication = application;
- ExpressWizardFragment.this.fuser = model.getUser();
-
- // update the values
- IServerWorkingCopy wc =
(IServerWorkingCopy)getTaskModel().getObject(TaskModel.TASK_SERVER);
- ExpressServerUtils.fillServerWithOpenShiftDetails(wc, application,
model.getUser(),
- ExpressServerUtils.EXPRESS_SOURCE_MODE, remote);
- } catch(CoreException ce) {
- // TODO FIX HANDLE
- }
- }
- } catch(OpenShiftException ose) {
- error = "Application \"" + app + "\" not found: " +
ose.getMessage();
- }
- }
- ExpressWizardFragment.this.error = error;
- }
- };
- }
-
- private String[] getAppNamesAsStrings(List<IApplication> allApps) {
- String[] appNames = new String[allApps.size()];
- for( int i = 0; i < allApps.size(); i++ ) {
- appNames[i] = allApps.get(i).getName();
- }
- return appNames;
- }
-
public void performFinish(IProgressMonitor monitor) throws CoreException {
- // do nothing
+ ExpressServerUtils.setExpressPassword(callback.getServer(), composite.getPassword());
}
-
}
Deleted:
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/behaviour/OpenShiftDeployUI.java
===================================================================
---
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/behaviour/OpenShiftDeployUI.java 2012-02-03
01:09:36 UTC (rev 38405)
+++
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/behaviour/OpenShiftDeployUI.java 2012-02-03
05:28:40 UTC (rev 38406)
@@ -1,91 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2011 Red Hat Inc..
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- *
http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Red Hat Incorporated - initial API and implementation
- *******************************************************************************/
-package org.jboss.tools.openshift.express.internal.ui.behaviour;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.layout.FillLayout;
-import org.eclipse.swt.layout.FormLayout;
-import org.eclipse.swt.widgets.Combo;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Text;
-import org.jboss.ide.eclipse.as.ui.UIUtil;
-import org.jboss.ide.eclipse.as.ui.editor.IDeploymentTypeUI;
-import org.jboss.tools.openshift.express.internal.core.behaviour.ExpressServerUtils;
-
-public class OpenShiftDeployUI implements IDeploymentTypeUI {
-
- public OpenShiftDeployUI() {
- // TODO Auto-generated constructor stub
- }
-
- @Override
- public void fillComposite(Composite parent, IServerModeUICallback callback) {
- createWidgets(parent, callback);
- addListeners(callback);
- }
-
- private void addListeners(IServerModeUICallback callback) {
-
- }
-
- //private Text userText, passText;
- private Text userText, passText;
- private Combo modeCombo;
-
- private String safeString(String s) {
- return s == null ? "" : s;
- }
- private void createWidgets(Composite parent, IServerModeUICallback callback) {
- // TODO Auto-generated method stub
- parent.setLayout(new FillLayout());
- Composite composite = new Composite(parent, SWT.NONE);
- composite.setLayout(new FormLayout());
-
- Label nameLabel = new Label(composite, SWT.NONE);
- nameLabel.setText("OpenShift Username:");
- userText = new Text(composite, SWT.BORDER);
- Label passLabel = new Label(composite, SWT.NONE);
- passLabel.setText("OpenShift Password:");
- passText = new Text(composite, SWT.BORDER | SWT.PASSWORD);
-
- Label domainLabel = new Label(composite, SWT.NONE);
- domainLabel.setText("Domain: " +
ExpressServerUtils.getExpressDomain(callback.getServer()));
- Label appLabel = new Label(composite, SWT.NONE);
- appLabel.setText("App: " +
ExpressServerUtils.getExpressApplicationName(callback.getServer()));
-
- Label modeLabel = new Label(composite, SWT.NONE);
- modeLabel.setText("Mode: " +
ExpressServerUtils.getExpressModeAsString(callback.getServer()));
-
- userText.setText(safeString(ExpressServerUtils.getExpressUsername(callback.getServer())));
- passText.setText(safeString(ExpressServerUtils.getExpressPassword(callback.getServer())));
- userText.setEnabled(false);
- passText.setEnabled(false);
- // Maybe just make this a label ??
-// modeCombo = new Combo(composite, SWT.READ_ONLY);
-// modeCombo.setItems(new String[]{
-// "Source", "Binary"
-// });
-// modeCombo.select(0);
-
- nameLabel.setLayoutData(UIUtil.createFormData2(0, 5,null,0,0,5,null,0));
- userText.setLayoutData(UIUtil.createFormData2(0,3,null,0,nameLabel,5,100,-5));
-
- passLabel.setLayoutData(UIUtil.createFormData2(userText, 5,null,0,0,5,null,0));
- passText.setLayoutData(UIUtil.createFormData2(userText,5,null,0,nameLabel,5,100,-5));
-
- domainLabel.setLayoutData(UIUtil.createFormData2(passText,5,null,0,0,5,null,0));
- appLabel.setLayoutData(UIUtil.createFormData2(domainLabel,5,null,0,0,5,null,0));
- modeLabel.setLayoutData(UIUtil.createFormData2(appLabel,5,null,0,0,5,null,0));
-// modeCombo.setLayoutData(UIUtil.createFormData2(appLabel,3,null,0,modeLabel,5,100,-5));
- }
-
-}