Author: rob.stryker(a)jboss.com
Date: 2011-10-17 06:24:51 -0400 (Mon, 17 Oct 2011)
New Revision: 35711
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/JBossServer.java
trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/core/behaviour/ExpressBehaviourDelegate.java
trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/core/behaviour/ExpressLaunchDelegate.java
trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/core/behaviour/ExpressPublishMethod.java
trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/core/behaviour/ExpressServerUtils.java
Log:
JBIDE-9793 - work for run-on server and publishing
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/JBossServer.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/JBossServer.java 2011-10-17
09:42:02 UTC (rev 35710)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/JBossServer.java 2011-10-17
10:24:51 UTC (rev 35711)
@@ -200,12 +200,17 @@
IWebModule webModule =(IWebModule)module.loadAdapter(IWebModule.class,null);
String host = getHost();
- String url = "http://"+host; //$NON-NLS-1$
+ String url = host;
+ if( !url.startsWith("http://") &&
!url.startsWith("https://") ) { //$NON-NLS-1$ //$NON-NLS-2$
+ url = "http://"+host; //$NON-NLS-1$
+ }
int port = getJBossWebPort();
if (port != 80)
url += ":" + port; //$NON-NLS-1$
- url += "/"+webModule.getContextRoot(); //$NON-NLS-1$
+ String cxRoot = webModule.getContextRoot();
+ if( !cxRoot.equals("/") && !cxRoot.equals("./"))
//$NON-NLS-1$ //$NON-NLS-2$
+ url += "/"+webModule.getContextRoot(); //$NON-NLS-1$
if (!url.endsWith("/")) //$NON-NLS-1$
url += "/"; //$NON-NLS-1$
Modified:
trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/core/behaviour/ExpressBehaviourDelegate.java
===================================================================
---
trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/core/behaviour/ExpressBehaviourDelegate.java 2011-10-17
09:42:02 UTC (rev 35710)
+++
trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/core/behaviour/ExpressBehaviourDelegate.java 2011-10-17
10:24:51 UTC (rev 35711)
@@ -8,21 +8,20 @@
import org.jboss.ide.eclipse.as.core.server.internal.IJBossBehaviourDelegate;
public class ExpressBehaviourDelegate implements IJBossBehaviourDelegate {
-
+ private DelegatingServerBehavior realBehaviour;
+
public ExpressBehaviourDelegate() {
// TODO Auto-generated constructor stub
}
@Override
public String getBehaviourTypeId() {
- // TODO Auto-generated method stub
- return null;
+ return "openshift";
}
@Override
public void setActualBehaviour(DelegatingServerBehavior actualBehaviour) {
- // TODO Auto-generated method stub
-
+ realBehaviour = actualBehaviour;
}
@Override
@@ -57,7 +56,7 @@
@Override
public IStatus canChangeState(String launchMode) {
- return Status.CANCEL_STATUS;
+ return Status.OK_STATUS;
}
@Override
Modified:
trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/core/behaviour/ExpressLaunchDelegate.java
===================================================================
---
trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/core/behaviour/ExpressLaunchDelegate.java 2011-10-17
09:42:02 UTC (rev 35710)
+++
trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/core/behaviour/ExpressLaunchDelegate.java 2011-10-17
10:24:51 UTC (rev 35711)
@@ -2,12 +2,17 @@
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
import org.eclipse.debug.core.ILaunch;
import org.eclipse.debug.core.ILaunchConfiguration;
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
import org.eclipse.wst.server.core.IServer;
+import org.jboss.ide.eclipse.as.core.Trace;
+import org.jboss.ide.eclipse.as.core.server.internal.DelegatingServerBehavior;
import
org.jboss.ide.eclipse.as.core.server.internal.launch.DelegatingStartLaunchConfiguration;
import org.jboss.ide.eclipse.as.core.server.internal.launch.IJBossLaunchDelegate;
+import org.jboss.ide.eclipse.as.core.util.JBossServerBehaviorUtils;
+import org.jboss.ide.eclipse.as.core.util.LaunchCommandPreferences;
public class ExpressLaunchDelegate implements IJBossLaunchDelegate {
@@ -26,15 +31,24 @@
@Override
public boolean preLaunchCheck(ILaunchConfiguration configuration,
String mode, IProgressMonitor monitor) throws CoreException {
- // TODO Auto-generated method stub
- return false;
+ DelegatingServerBehavior jbsBehavior =
JBossServerBehaviorUtils.getServerBehavior(configuration);
+ IStatus s = jbsBehavior.canStart(mode);
+
+ Trace.trace(Trace.STRING_FINEST, "Ensuring Server can start: " +
s.getMessage()); //$NON-NLS-1$
+ if (!s.isOK())
+ throw new CoreException(jbsBehavior.canStart(mode));
+ if (LaunchCommandPreferences.isIgnoreLaunchCommand(jbsBehavior.getServer())) {
+ Trace.trace(Trace.STRING_FINEST, "Server is marked as ignore Launch. Marking as
started."); //$NON-NLS-1$
+ jbsBehavior.setServerStarting();
+ jbsBehavior.setServerStarted();
+ return false;
+ }
+ return true;
}
@Override
public void preLaunch(ILaunchConfiguration configuration, String mode,
ILaunch launch, IProgressMonitor monitor) throws CoreException {
- // TODO Auto-generated method stub
-
}
@Override
Modified:
trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/core/behaviour/ExpressPublishMethod.java
===================================================================
---
trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/core/behaviour/ExpressPublishMethod.java 2011-10-17
09:42:02 UTC (rev 35710)
+++
trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/core/behaviour/ExpressPublishMethod.java 2011-10-17
10:24:51 UTC (rev 35711)
@@ -1,13 +1,16 @@
package org.jboss.tools.openshift.express.internal.core.behaviour;
+import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.SubProgressMonitor;
import org.eclipse.wst.server.core.IModule;
import org.eclipse.wst.server.core.IServer;
import org.jboss.ide.eclipse.as.core.server.IJBossServerPublishMethod;
import org.jboss.ide.eclipse.as.core.server.internal.DeployableServerBehavior;
import
org.jboss.ide.eclipse.as.core.server.xpl.PublishCopyUtil.IPublishCopyCallbackHandler;
+import org.jboss.ide.eclipse.as.egit.core.EGitUtils;
public class ExpressPublishMethod implements IJBossServerPublishMethod {
@@ -33,8 +36,15 @@
public int publishModule(DeployableServerBehavior behaviour, int kind,
int deltaKind, IModule[] module, IProgressMonitor monitor)
throws CoreException {
- // TODO Auto-generated method stub
- return 0;
+ int state = behaviour.getServer().getModulePublishState(module);
+ if( kind == IServer.PUBLISH_FULL || state == IServer.PUBLISH_STATE_FULL) {
+ IProject p = module[module.length-1].getProject();
+ monitor.beginTask("Publishing " + p.getName(), 200);
+ EGitUtils.commit(p, new SubProgressMonitor(monitor, 100));
+ EGitUtils.push(EGitUtils.getRepository(p), new SubProgressMonitor(monitor, 100));
+ return IServer.PUBLISH_STATE_NONE;
+ }
+ return IServer.PUBLISH_STATE_INCREMENTAL;
}
@Override
Modified:
trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/core/behaviour/ExpressServerUtils.java
===================================================================
---
trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/core/behaviour/ExpressServerUtils.java 2011-10-17
09:42:02 UTC (rev 35710)
+++
trunk/as/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/core/behaviour/ExpressServerUtils.java 2011-10-17
10:24:51 UTC (rev 35711)
@@ -7,6 +7,8 @@
import org.eclipse.wst.server.core.IServerAttributes;
import org.eclipse.wst.server.core.IServerType;
import org.eclipse.wst.server.core.IServerWorkingCopy;
+import org.eclipse.wst.server.core.internal.Server;
+import org.eclipse.wst.server.core.internal.ServerWorkingCopy;
import org.jboss.ide.eclipse.as.core.server.IDeployableServer;
import org.jboss.ide.eclipse.as.core.util.IJBossToolingConstants;
import org.jboss.ide.eclipse.as.core.util.RuntimeUtils;
@@ -150,7 +152,11 @@
public static IServer fillServerWithOpenshiftDetails(IServer server,
String host, String username, String password, String domain, String app,
String mode) throws CoreException {
- IServerWorkingCopy wc = server.createWorkingCopy();
+ if( host.indexOf("://") != -1)
+ host = host.substring(host.indexOf("://") + 3);
+ if( host.endsWith("/"))
+ host = host.substring(0, host.length()-1);
+ ServerWorkingCopy wc = (ServerWorkingCopy)server.createWorkingCopy();
wc.setHost(host);
wc.setAttribute(IDeployableServer.SERVER_MODE, "openshift");
wc.setAttribute(ATTRIBUTE_USERNAME, username);
@@ -158,6 +164,10 @@
wc.setAttribute(ATTRIBUTE_DOMAIN, domain);
wc.setAttribute(ATTRIBUTE_APPLICATION, app);
wc.setAttribute(ATTRIBUTE_EXPRESS_MODE, mode);
+ wc.setAutoPublishSetting(Server.AUTO_PUBLISH_DISABLE);
+ wc.setAttribute(IJBossToolingConstants.IGNORE_LAUNCH_COMMANDS, "true");
+ wc.setAttribute(IJBossToolingConstants.WEB_PORT, 80);
+ wc.setAttribute(IJBossToolingConstants.WEB_PORT_DETECT, "false");
return wc.save(true, new NullProgressMonitor());
}