JBoss Tools SVN: r23966 - in workspace/rstryker/rse/as: plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/extensions/polling and 3 other directories.
by jbosstools-commits@lists.jboss.org
Author: rob.stryker(a)jboss.com
Date: 2010-08-06 06:29:45 -0400 (Fri, 06 Aug 2010)
New Revision: 23966
Added:
workspace/rstryker/rse/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/LocalJBossBehaviorDelegate.java
workspace/rstryker/rse/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/launch/LocalJBossServerStartupLaunchUtil.java
Modified:
workspace/rstryker/rse/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/extensions/polling/ProcessTerminatedPoller.java
workspace/rstryker/rse/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/DeployableServer.java
workspace/rstryker/rse/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/JBossServerBehavior.java
workspace/rstryker/rse/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/PollThread.java
workspace/rstryker/rse/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/launch/AbstractJBossLaunchConfigType.java
workspace/rstryker/rse/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/launch/JBossServerStartupLaunchConfiguration.java
workspace/rstryker/rse/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/launch/RunJarContainerWrapper.java
workspace/rstryker/rse/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/launch/StopLaunchConfiguration.java
workspace/rstryker/rse/as/plugins/org.jboss.ide.eclipse.as.core/plugin.xml
workspace/rstryker/rse/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/server/MockTests.java
workspace/rstryker/rse/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/server/StartupShutdownTest.java
Log:
JBIDE-6796 - extracting local launch behaviour into separate classes
Modified: workspace/rstryker/rse/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/extensions/polling/ProcessTerminatedPoller.java
===================================================================
--- workspace/rstryker/rse/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/extensions/polling/ProcessTerminatedPoller.java 2010-08-06 09:19:37 UTC (rev 23965)
+++ workspace/rstryker/rse/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/extensions/polling/ProcessTerminatedPoller.java 2010-08-06 10:29:45 UTC (rev 23966)
@@ -14,9 +14,11 @@
import java.util.Properties;
import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.debug.core.model.IProcess;
import org.eclipse.wst.server.core.IServer;
import org.jboss.ide.eclipse.as.core.server.IServerStatePoller;
import org.jboss.ide.eclipse.as.core.server.internal.JBossServerBehavior;
+import org.jboss.ide.eclipse.as.core.server.internal.JBossServerBehavior.JBossBehaviourDelegate;
import org.jboss.ide.eclipse.as.core.server.internal.PollThread;
import org.jboss.ide.eclipse.as.core.server.internal.ServerStatePollerType;
@@ -32,7 +34,11 @@
public class ProcessTerminatedPoller implements IServerStatePoller {
public static final String POLLER_ID = "org.jboss.ide.eclipse.as.core.runtime.server.processTerminatedPoller"; //$NON-NLS-1$
+ public static interface IProcessProvider {
+ public IProcess getProcess();
+ }
+
private ServerStatePollerType type;
private JBossServerBehavior server;
public void beginPolling(IServer server, boolean expectedState,
@@ -55,7 +61,12 @@
}
public boolean isComplete() throws PollingException {
- return server.getProcess() == null || server.getProcess().isTerminated();
+ JBossBehaviourDelegate del = server.getDelegate();
+ if( del instanceof IProcessProvider ) {
+ IProcess p = ((IProcessProvider)del).getProcess();
+ return p == null || p.isTerminated();
+ }
+ return true;
}
public void failureHandled(Properties properties) {
Modified: workspace/rstryker/rse/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/DeployableServer.java
===================================================================
--- workspace/rstryker/rse/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/DeployableServer.java 2010-08-06 09:19:37 UTC (rev 23965)
+++ workspace/rstryker/rse/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/DeployableServer.java 2010-08-06 10:29:45 UTC (rev 23966)
@@ -18,7 +18,6 @@
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Status;
-import org.eclipse.jst.server.core.IEnterpriseApplication;
import org.eclipse.wst.server.core.IModule;
import org.eclipse.wst.server.core.IRuntime;
import org.eclipse.wst.server.core.IServer;
@@ -27,9 +26,7 @@
import org.eclipse.wst.server.core.model.ServerDelegate;
import org.jboss.ide.eclipse.as.core.server.IDeployableServer;
import org.jboss.ide.eclipse.as.core.server.IJBossServerRuntime;
-import org.jboss.ide.eclipse.as.core.util.ModuleUtil;
import org.jboss.ide.eclipse.as.core.util.ServerUtil;
-import org.jboss.ide.eclipse.as.wtp.core.modules.IJBTModule;
import org.jboss.ide.eclipse.as.wtp.core.util.ServerModelUtilities;
public class DeployableServer extends ServerDelegate implements IDeployableServer {
Modified: workspace/rstryker/rse/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/JBossServerBehavior.java
===================================================================
--- workspace/rstryker/rse/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/JBossServerBehavior.java 2010-08-06 09:19:37 UTC (rev 23965)
+++ workspace/rstryker/rse/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/JBossServerBehavior.java 2010-08-06 10:29:45 UTC (rev 23966)
@@ -20,35 +20,15 @@
******************************************************************************/
package org.jboss.ide.eclipse.as.core.server.internal;
-import javax.management.MBeanServerConnection;
-import javax.management.ObjectName;
+import java.util.HashMap;
import org.eclipse.core.runtime.CoreException;
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.debug.core.DebugEvent;
-import org.eclipse.debug.core.DebugException;
-import org.eclipse.debug.core.DebugPlugin;
-import org.eclipse.debug.core.IDebugEventSetListener;
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
-import org.eclipse.debug.core.model.IProcess;
-import org.eclipse.wst.server.core.IRuntime;
-import org.eclipse.wst.server.core.IServer;
-import org.jboss.ide.eclipse.as.core.JBossServerCorePlugin;
-import org.jboss.ide.eclipse.as.core.Messages;
-import org.jboss.ide.eclipse.as.core.extensions.events.IEventCodes;
-import org.jboss.ide.eclipse.as.core.extensions.events.ServerLogger;
-import org.jboss.ide.eclipse.as.core.extensions.jmx.JBossServerConnectionProvider;
-import org.jboss.ide.eclipse.as.core.extensions.jmx.JMXClassLoaderRepository;
-import org.jboss.ide.eclipse.as.core.server.IJBossServerRuntime;
-import org.jboss.ide.eclipse.as.core.server.IServerStatePoller;
-import org.jboss.ide.eclipse.as.core.server.internal.launch.JBossServerStartupLaunchConfiguration;
-import org.jboss.ide.eclipse.as.core.server.internal.launch.StopLaunchConfiguration;
-import org.jboss.ide.eclipse.as.core.util.IJBossRuntimeConstants;
-import org.jboss.tools.jmx.core.IJMXRunnable;
-import org.jboss.tools.jmx.core.JMXException;
+import org.jboss.ide.eclipse.as.core.publishers.LocalPublishMethod;
+import org.jboss.ide.eclipse.as.core.server.IJBossServerPublishMethodType;
+import org.jboss.ide.eclipse.as.core.util.DeploymentPreferenceLoader;
/**
*
@@ -57,239 +37,82 @@
*/
public class JBossServerBehavior extends DeployableServerBehavior {
- private PollThread pollThread = null;
- protected IProcess process;
- protected boolean nextStopRequiresForce = false;
+ public static interface JBossBehaviourDelegate {
+ public void setActualBehaviour(JBossServerBehavior actualBehaviour);
+ public void stop(boolean force);
+ public void setupLaunchConfiguration(ILaunchConfigurationWorkingCopy workingCopy, IProgressMonitor monitor) throws CoreException;
+ public void publishStart(final IProgressMonitor monitor) throws CoreException;
+ public void publishFinish(final IProgressMonitor monitor) throws CoreException;
+ public void serverStarting();
+ public void serverStopping();
+ public IStatus canChangeState(String launchMode);
+ }
+
+ public static HashMap<String, Class> delegateClassMap;
+ static {
+ delegateClassMap = new HashMap<String, Class>();
+ delegateClassMap.put(LocalPublishMethod.LOCAL_PUBLISH_METHOD, LocalJBossBehaviorDelegate.class);
+ }
+ public static void addDelegateMapping(String s, Class c) {
+ delegateClassMap.put(s, c);
+ }
+
public JBossServerBehavior() {
super();
}
- public void stop(boolean force) {
- int state = getServer().getServerState();
- if( force || process == null || process.isTerminated() || state == IServer.STATE_STOPPED || nextStopRequiresForce) {
- forceStop();
- return;
- }
+ private JBossBehaviourDelegate delegate;
+ private String lastModeId;
+ public JBossBehaviourDelegate getDelegate() {
+ IJBossServerPublishMethodType type = DeploymentPreferenceLoader.getCurrentDeploymentMethodType(getServer());
+ String id = type == null ? LocalPublishMethod.LOCAL_PUBLISH_METHOD : type.getId();
+ if( id.equals(lastModeId))
+ return delegate;
- // if we're starting up or shutting down and they've tried again,
- // then force it to stop.
- if( state == IServer.STATE_STARTING || state == IServer.STATE_STOPPING ) {
- pollThread.cancel();
- forceStop();
- return;
+ Class c = delegateClassMap.get(id);
+ try {
+ JBossBehaviourDelegate o = (JBossBehaviourDelegate)c.newInstance();
+ o.setActualBehaviour(this);
+ lastModeId = id;
+ delegate = o;
+ } catch( InstantiationException ie) {
+ } catch( IllegalAccessException iae) {
}
-
- serverStopping();
- new Thread() {public void run() {
- boolean success = StopLaunchConfiguration.stop(getServer());
- if( !success ) {
- if( process != null && !process.isTerminated() ) {
- setServerStarted();
- pollThread.cancel(Messages.STOP_FAILED_MESSAGE);
- nextStopRequiresForce = true;
- }
- }
- }}.start();
+ return delegate;
}
- public synchronized void forceStop() {
- // just terminate the process.
- if( process != null && !process.isTerminated()) {
- try {
- process.terminate();
- addForceStopEvent();
- } catch( DebugException e ) {
- addForceStopFailedEvent(e);
- }
- }
- process = null;
- setServerStopped();
+ public void stop(boolean force) {
+ getDelegate().stop(force);
}
- protected void addForceStopFailedEvent(DebugException e) {
- IStatus status = new Status(IStatus.ERROR,
- JBossServerCorePlugin.PLUGIN_ID, IEventCodes.BEHAVIOR_FORCE_STOP_FAILED,
- Messages.FORCE_TERMINATE_FAILED, e);
- ServerLogger.getDefault().log(getServer(), status);
- }
- protected void addForceStopEvent() {
- IStatus status = new Status(IStatus.ERROR,
- JBossServerCorePlugin.PLUGIN_ID, IEventCodes.BEHAVIOR_FORCE_STOP,
- Messages.FORCE_TERMINATED, null);
- ServerLogger.getDefault().log(getServer(), status);
- }
-
- protected void addProcessTerminatedEvent() {
- IStatus status = new Status(IStatus.INFO,
- JBossServerCorePlugin.PLUGIN_ID, IEventCodes.BEHAVIOR_PROCESS_TERMINATED,
- Messages.TERMINATED, null);
- ServerLogger.getDefault().log(getServer(), status);
- }
-
public void setupLaunchConfiguration(ILaunchConfigurationWorkingCopy workingCopy, IProgressMonitor monitor) throws CoreException {
- JBossServerStartupLaunchConfiguration.setupLaunchConfiguration(workingCopy, getServer());
+ getDelegate().setupLaunchConfiguration(workingCopy, monitor);
}
-
- protected transient IDebugEventSetListener processListener;
- public synchronized void setProcess(final IProcess newProcess) {
- if (process != null) {
- return;
- }
- process = newProcess;
- if (processListener != null)
- DebugPlugin.getDefault().removeDebugEventListener(processListener);
- if (newProcess == null)
- return;
-
- processListener = new IDebugEventSetListener() {
- public void handleDebugEvents(DebugEvent[] events) {
- if (events != null) {
- int size = events.length;
- for (int i = 0; i < size; i++) {
- if (process != null && process.equals(events[i].getSource()) && events[i].getKind() == DebugEvent.TERMINATE) {
- DebugPlugin.getDefault().removeDebugEventListener(this);
- forceStop();
- addProcessTerminatedEvent();
- }
- }
- }
- }
- };
- DebugPlugin.getDefault().addDebugEventListener(processListener);
- }
-
-
public void setRunMode(String mode) {
setMode(mode);
}
public void serverStarting() {
- nextStopRequiresForce = false;
setServerStarting();
- pollServer(IServerStatePoller.SERVER_UP);
+ getDelegate().serverStarting();
}
public void serverStopping() {
setServerStopping();
- pollServer(IServerStatePoller.SERVER_DOWN);
+ getDelegate().serverStopping();
}
- public synchronized IProcess getProcess() {
- return process;
- }
-
- protected void pollServer(final boolean expectedState) {
- if( this.pollThread != null ) {
- pollThread.cancel();
- }
- this.pollThread = new PollThread(Messages.ServerPollerThreadName, expectedState, this);
- pollThread.start();
- }
-
-
protected void publishStart(final IProgressMonitor monitor) throws CoreException {
super.publishStart(monitor);
- if( shouldSuspendScanner()) {
- JMXClassLoaderRepository.getDefault().addConcerned(getServer(), this);
- IJMXRunnable r = new IJMXRunnable() {
- public void run(MBeanServerConnection connection) throws Exception {
- suspendDeployment(connection, monitor);
- }
- };
- try {
- JBossServerConnectionProvider.run(getServer(), r);
- } catch( JMXException jmxe ) {
- IStatus status = new Status(IStatus.WARNING, JBossServerCorePlugin.PLUGIN_ID, IEventCodes.SUSPEND_DEPLOYMENT_SCANNER, Messages.JMXPauseScannerError, jmxe);
- ServerLogger.getDefault().log(getServer(), status);
- }
- }
+ getDelegate().publishStart(monitor);
}
protected void publishFinish(final IProgressMonitor monitor) throws CoreException {
- if( shouldSuspendScanner()) {
- IJMXRunnable r = new IJMXRunnable() {
- public void run(MBeanServerConnection connection) throws Exception {
- resumeDeployment(connection, monitor);
- }
- };
- try {
- JBossServerConnectionProvider.run(getServer(), r);
- } catch( JMXException jmxe ) {
- IStatus status = new Status(IStatus.WARNING, JBossServerCorePlugin.PLUGIN_ID, IEventCodes.RESUME_DEPLOYMENT_SCANNER, Messages.JMXResumeScannerError, jmxe);
- ServerLogger.getDefault().log(getServer(), status);
- } finally {
- JMXClassLoaderRepository.getDefault().removeConcerned(getServer(), this);
- }
- }
+ getDelegate().publishFinish(monitor);
super.publishFinish(monitor);
}
- protected boolean shouldSuspendScanner() {
-// if( getServer().getServerType().getId().equals(IConstants.AS_50))
-// return false;
- if( getServer().getServerState() != IServer.STATE_STARTED)
- return false;
- return true;
- }
-
- protected void suspendDeployment(final MBeanServerConnection connection, IProgressMonitor monitor) throws Exception {
- ObjectName name = new ObjectName(IJBossRuntimeConstants.DEPLOYMENT_SCANNER_MBEAN_NAME);
- launchDeployCommand(connection, name, IJBossRuntimeConstants.STOP, monitor);
- }
-
-
-
- protected void resumeDeployment(final MBeanServerConnection connection, IProgressMonitor monitor) throws Exception {
- ObjectName name = new ObjectName(IJBossRuntimeConstants.DEPLOYMENT_SCANNER_MBEAN_NAME);
- launchDeployCommand(connection, name, IJBossRuntimeConstants.START, monitor);
- }
-
- protected void launchDeployCommand(final MBeanServerConnection connection, final ObjectName objectName,
- final String methodName, IProgressMonitor monitor) throws Exception {
- final Exception[] e = new Exception[1];
- final Object waitObject = new Object();
- final Boolean[] subtaskComplete = new Boolean[1];
- subtaskComplete[0] = new Boolean(false);
- Thread t = new Thread() {
- public void run() {
- Exception exception = null;
- try {
- executeDeploymentCommand(connection, objectName, methodName);
- } catch( Exception ex ) {
- exception = ex;
- }
- synchronized(waitObject) {
- e[0] = exception;
- subtaskComplete[0] = new Boolean(true);
- waitObject.notifyAll();
- }
- }
- };
- t.start();
- int count = 0;
- while(t.isAlive() && !monitor.isCanceled() && count <= 4000) {
- count+= 1000;
- synchronized(waitObject) {
- if( subtaskComplete[0].booleanValue() )
- break;
- waitObject.wait(1000);
- }
- }
- synchronized(waitObject) {
- if( !subtaskComplete[0].booleanValue()) {
- t.interrupt();
- IStatus status = new Status(IStatus.WARNING, JBossServerCorePlugin.PLUGIN_ID, IEventCodes.DEPLOYMENT_SCANNER_TRANSITION_CANCELED, Messages.JMXScannerCanceled, null);
- ServerLogger.getDefault().log(getServer(), status);
- }
- }
- }
-
- protected void executeDeploymentCommand(MBeanServerConnection connection, ObjectName objectName, String methodName) throws Exception {
- connection.invoke(objectName, methodName, new Object[] { }, new String[] {});
- }
-
-
// Can start / stop / restart etc
public IStatus canStart(String launchMode) {
return canChangeState(launchMode);
@@ -304,21 +127,6 @@
return canChangeState(launchMode);
}
protected IStatus canChangeState(String launchMode) {
- if( getServer() != null && getServer().getRuntime() != null &&
- getRuntime().getVM() != null )
- return Status.OK_STATUS;
- return new Status(IStatus.ERROR, JBossServerCorePlugin.PLUGIN_ID,
- "This server does not have a valid runtime environment"); //$NON-NLS-1$
+ return getDelegate().canChangeState(launchMode);
}
-
- private IJBossServerRuntime getRuntime() {
- IRuntime r = getServer().getRuntime();
- IJBossServerRuntime ajbsrt = null;
- if (r != null) {
- ajbsrt = (IJBossServerRuntime) r
- .loadAdapter(IJBossServerRuntime.class,
- new NullProgressMonitor());
- }
- return ajbsrt;
- }
}
Added: workspace/rstryker/rse/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/LocalJBossBehaviorDelegate.java
===================================================================
--- workspace/rstryker/rse/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/LocalJBossBehaviorDelegate.java (rev 0)
+++ workspace/rstryker/rse/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/LocalJBossBehaviorDelegate.java 2010-08-06 10:29:45 UTC (rev 23966)
@@ -0,0 +1,327 @@
+/*******************************************************************************
+ * Copyright (c) 2007 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
+ ******************************************************************************/
+/*******************************************************************************
+ * Copyright (c) 2007 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.core.server.internal;
+
+import javax.management.MBeanServerConnection;
+import javax.management.ObjectName;
+
+import org.eclipse.core.runtime.CoreException;
+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.debug.core.DebugEvent;
+import org.eclipse.debug.core.DebugException;
+import org.eclipse.debug.core.DebugPlugin;
+import org.eclipse.debug.core.IDebugEventSetListener;
+import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
+import org.eclipse.debug.core.model.IProcess;
+import org.eclipse.wst.server.core.IRuntime;
+import org.eclipse.wst.server.core.IServer;
+import org.jboss.ide.eclipse.as.core.JBossServerCorePlugin;
+import org.jboss.ide.eclipse.as.core.Messages;
+import org.jboss.ide.eclipse.as.core.extensions.events.IEventCodes;
+import org.jboss.ide.eclipse.as.core.extensions.events.ServerLogger;
+import org.jboss.ide.eclipse.as.core.extensions.jmx.JBossServerConnectionProvider;
+import org.jboss.ide.eclipse.as.core.extensions.jmx.JMXClassLoaderRepository;
+import org.jboss.ide.eclipse.as.core.extensions.polling.ProcessTerminatedPoller.IProcessProvider;
+import org.jboss.ide.eclipse.as.core.server.IJBossServerRuntime;
+import org.jboss.ide.eclipse.as.core.server.IServerStatePoller;
+import org.jboss.ide.eclipse.as.core.server.internal.JBossServerBehavior.JBossBehaviourDelegate;
+import org.jboss.ide.eclipse.as.core.server.internal.launch.LocalJBossServerStartupLaunchUtil;
+import org.jboss.ide.eclipse.as.core.server.internal.launch.StopLaunchConfiguration;
+import org.jboss.ide.eclipse.as.core.util.IJBossRuntimeConstants;
+import org.jboss.tools.jmx.core.IJMXRunnable;
+import org.jboss.tools.jmx.core.JMXException;
+
+/**
+ *
+ * @author Rob Stryker
+ *
+ */
+public class LocalJBossBehaviorDelegate implements JBossBehaviourDelegate, IProcessProvider {
+
+ private PollThread pollThread = null;
+ protected IProcess process;
+ protected boolean nextStopRequiresForce = false;
+ private JBossServerBehavior actualBehavior;
+ public LocalJBossBehaviorDelegate() {
+ super();
+ }
+
+ public void setActualBehaviour(JBossServerBehavior actualBehaviour) {
+ this.actualBehavior = actualBehaviour;
+ }
+
+ protected IServer getServer() {
+ return actualBehavior.getServer();
+ }
+
+ public void stop(boolean force) {
+ int state = getServer().getServerState();
+ if( force || process == null || process.isTerminated() || state == IServer.STATE_STOPPED || nextStopRequiresForce) {
+ forceStop();
+ return;
+ }
+
+ // if we're starting up or shutting down and they've tried again,
+ // then force it to stop.
+ if( state == IServer.STATE_STARTING || state == IServer.STATE_STOPPING ) {
+ pollThread.cancel();
+ forceStop();
+ return;
+ }
+
+ serverStopping();
+ new Thread() {public void run() {
+ boolean success = StopLaunchConfiguration.stop(getServer());
+ if( !success ) {
+ if( process != null && !process.isTerminated() ) {
+ actualBehavior.setServerStarted();
+ pollThread.cancel(Messages.STOP_FAILED_MESSAGE);
+ nextStopRequiresForce = true;
+ }
+ }
+ }}.start();
+ }
+
+ public synchronized void forceStop() {
+ // just terminate the process.
+ if( process != null && !process.isTerminated()) {
+ try {
+ process.terminate();
+ addForceStopEvent();
+ } catch( DebugException e ) {
+ addForceStopFailedEvent(e);
+ }
+ }
+ process = null;
+ actualBehavior.setServerStopped();
+ }
+
+ protected void addForceStopFailedEvent(DebugException e) {
+ IStatus status = new Status(IStatus.ERROR,
+ JBossServerCorePlugin.PLUGIN_ID, IEventCodes.BEHAVIOR_FORCE_STOP_FAILED,
+ Messages.FORCE_TERMINATE_FAILED, e);
+ ServerLogger.getDefault().log(getServer(), status);
+ }
+ protected void addForceStopEvent() {
+ IStatus status = new Status(IStatus.ERROR,
+ JBossServerCorePlugin.PLUGIN_ID, IEventCodes.BEHAVIOR_FORCE_STOP,
+ Messages.FORCE_TERMINATED, null);
+ ServerLogger.getDefault().log(getServer(), status);
+ }
+
+ protected void addProcessTerminatedEvent() {
+ IStatus status = new Status(IStatus.INFO,
+ JBossServerCorePlugin.PLUGIN_ID, IEventCodes.BEHAVIOR_PROCESS_TERMINATED,
+ Messages.TERMINATED, null);
+ ServerLogger.getDefault().log(getServer(), status);
+ }
+
+ public void setupLaunchConfiguration(ILaunchConfigurationWorkingCopy workingCopy, IProgressMonitor monitor) throws CoreException {
+ LocalJBossServerStartupLaunchUtil.setupLaunchConfiguration(workingCopy, getServer());
+ }
+
+
+ protected transient IDebugEventSetListener processListener;
+ public synchronized void setProcess(final IProcess newProcess) {
+ if (process != null) {
+ return;
+ }
+ process = newProcess;
+ if (processListener != null)
+ DebugPlugin.getDefault().removeDebugEventListener(processListener);
+ if (newProcess == null)
+ return;
+
+ processListener = new IDebugEventSetListener() {
+ public void handleDebugEvents(DebugEvent[] events) {
+ if (events != null) {
+ int size = events.length;
+ for (int i = 0; i < size; i++) {
+ if (process != null && process.equals(events[i].getSource()) && events[i].getKind() == DebugEvent.TERMINATE) {
+ DebugPlugin.getDefault().removeDebugEventListener(this);
+ forceStop();
+ addProcessTerminatedEvent();
+ }
+ }
+ }
+ }
+ };
+ DebugPlugin.getDefault().addDebugEventListener(processListener);
+ }
+
+
+ public void serverStarting() {
+ nextStopRequiresForce = false;
+ pollServer(IServerStatePoller.SERVER_UP);
+ }
+
+ public void serverStopping() {
+ actualBehavior.setServerStopping();
+ pollServer(IServerStatePoller.SERVER_DOWN);
+ }
+
+ public synchronized IProcess getProcess() {
+ return process;
+ }
+
+ protected void pollServer(final boolean expectedState) {
+ if( this.pollThread != null ) {
+ pollThread.cancel();
+ }
+ this.pollThread = new PollThread(Messages.ServerPollerThreadName, expectedState, actualBehavior);
+ pollThread.start();
+ }
+
+
+ public void publishStart(final IProgressMonitor monitor) throws CoreException {
+ if( shouldSuspendScanner()) {
+ JMXClassLoaderRepository.getDefault().addConcerned(getServer(), this);
+ IJMXRunnable r = new IJMXRunnable() {
+ public void run(MBeanServerConnection connection) throws Exception {
+ suspendDeployment(connection, monitor);
+ }
+ };
+ try {
+ JBossServerConnectionProvider.run(getServer(), r);
+ } catch( JMXException jmxe ) {
+ IStatus status = new Status(IStatus.WARNING, JBossServerCorePlugin.PLUGIN_ID, IEventCodes.SUSPEND_DEPLOYMENT_SCANNER, Messages.JMXPauseScannerError, jmxe);
+ ServerLogger.getDefault().log(getServer(), status);
+ }
+ }
+ }
+
+ public void publishFinish(final IProgressMonitor monitor) throws CoreException {
+ if( shouldSuspendScanner()) {
+ IJMXRunnable r = new IJMXRunnable() {
+ public void run(MBeanServerConnection connection) throws Exception {
+ resumeDeployment(connection, monitor);
+ }
+ };
+ try {
+ JBossServerConnectionProvider.run(getServer(), r);
+ } catch( JMXException jmxe ) {
+ IStatus status = new Status(IStatus.WARNING, JBossServerCorePlugin.PLUGIN_ID, IEventCodes.RESUME_DEPLOYMENT_SCANNER, Messages.JMXResumeScannerError, jmxe);
+ ServerLogger.getDefault().log(getServer(), status);
+ } finally {
+ JMXClassLoaderRepository.getDefault().removeConcerned(getServer(), this);
+ }
+ }
+ }
+
+ protected boolean shouldSuspendScanner() {
+ if( getServer().getServerState() != IServer.STATE_STARTED)
+ return false;
+ return true;
+ }
+
+ protected void suspendDeployment(final MBeanServerConnection connection, IProgressMonitor monitor) throws Exception {
+ ObjectName name = new ObjectName(IJBossRuntimeConstants.DEPLOYMENT_SCANNER_MBEAN_NAME);
+ launchDeployCommand(connection, name, IJBossRuntimeConstants.STOP, monitor);
+ }
+
+
+
+ protected void resumeDeployment(final MBeanServerConnection connection, IProgressMonitor monitor) throws Exception {
+ ObjectName name = new ObjectName(IJBossRuntimeConstants.DEPLOYMENT_SCANNER_MBEAN_NAME);
+ launchDeployCommand(connection, name, IJBossRuntimeConstants.START, monitor);
+ }
+
+ protected void launchDeployCommand(final MBeanServerConnection connection, final ObjectName objectName,
+ final String methodName, IProgressMonitor monitor) throws Exception {
+ final Exception[] e = new Exception[1];
+ final Object waitObject = new Object();
+ final Boolean[] subtaskComplete = new Boolean[1];
+ subtaskComplete[0] = new Boolean(false);
+ Thread t = new Thread() {
+ public void run() {
+ Exception exception = null;
+ try {
+ executeDeploymentCommand(connection, objectName, methodName);
+ } catch( Exception ex ) {
+ exception = ex;
+ }
+ synchronized(waitObject) {
+ e[0] = exception;
+ subtaskComplete[0] = new Boolean(true);
+ waitObject.notifyAll();
+ }
+ }
+ };
+ t.start();
+ int count = 0;
+ while(t.isAlive() && !monitor.isCanceled() && count <= 4000) {
+ count+= 1000;
+ synchronized(waitObject) {
+ if( subtaskComplete[0].booleanValue() )
+ break;
+ waitObject.wait(1000);
+ }
+ }
+ synchronized(waitObject) {
+ if( !subtaskComplete[0].booleanValue()) {
+ t.interrupt();
+ IStatus status = new Status(IStatus.WARNING, JBossServerCorePlugin.PLUGIN_ID, IEventCodes.DEPLOYMENT_SCANNER_TRANSITION_CANCELED, Messages.JMXScannerCanceled, null);
+ ServerLogger.getDefault().log(getServer(), status);
+ }
+ }
+ }
+
+ protected void executeDeploymentCommand(MBeanServerConnection connection, ObjectName objectName, String methodName) throws Exception {
+ connection.invoke(objectName, methodName, new Object[] { }, new String[] {});
+ }
+
+
+ // Can start / stop / restart etc
+ public IStatus canStart(String launchMode) {
+ return canChangeState(launchMode);
+ }
+ public IStatus canRestart(String launchMode) {
+ return canChangeState(launchMode);
+ }
+ public IStatus canStop() {
+ return canChangeState(null);
+ }
+ public IStatus canStop(String launchMode) {
+ return canChangeState(launchMode);
+ }
+
+ public IStatus canChangeState(String launchMode) {
+ if( getServer() != null && getServer().getRuntime() != null &&
+ getRuntime().getVM() != null )
+ return Status.OK_STATUS;
+ return new Status(IStatus.ERROR, JBossServerCorePlugin.PLUGIN_ID,
+ "This server does not have a valid runtime environment"); //$NON-NLS-1$
+ }
+
+ private IJBossServerRuntime getRuntime() {
+ IRuntime r = getServer().getRuntime();
+ IJBossServerRuntime ajbsrt = null;
+ if (r != null) {
+ ajbsrt = (IJBossServerRuntime) r
+ .loadAdapter(IJBossServerRuntime.class,
+ new NullProgressMonitor());
+ }
+ return ajbsrt;
+ }
+}
Modified: workspace/rstryker/rse/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/PollThread.java
===================================================================
--- workspace/rstryker/rse/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/PollThread.java 2010-08-06 09:19:37 UTC (rev 23965)
+++ workspace/rstryker/rse/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/PollThread.java 2010-08-06 10:29:45 UTC (rev 23966)
@@ -218,14 +218,14 @@
protected void alertBehavior(boolean currentState, boolean finalAlert) {
if (currentState != expectedState) {
// it didnt work... cancel all processes! force stop
- behavior.forceStop();
+ behavior.stop(true);
if (finalAlert)
alertEventLogFailure();
} else {
if (currentState == IServerStatePoller.SERVER_UP)
behavior.setServerStarted();
else
- behavior.forceStop();
+ behavior.stop(true);
if (finalAlert)
alertEventLogSuccess(currentState);
Modified: workspace/rstryker/rse/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/launch/AbstractJBossLaunchConfigType.java
===================================================================
--- workspace/rstryker/rse/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/launch/AbstractJBossLaunchConfigType.java 2010-08-06 09:19:37 UTC (rev 23965)
+++ workspace/rstryker/rse/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/launch/AbstractJBossLaunchConfigType.java 2010-08-06 10:29:45 UTC (rev 23966)
@@ -55,11 +55,11 @@
return true;
}
- protected void preLaunch(ILaunchConfiguration configuration,
+ public void preLaunch(ILaunchConfiguration configuration,
String mode, ILaunch launch, IProgressMonitor monitor) throws CoreException {
// override me
}
- protected void postLaunch(ILaunchConfiguration configuration,
+ public void postLaunch(ILaunchConfiguration configuration,
String mode, ILaunch launch, IProgressMonitor monitor) throws CoreException {
// override me
}
@@ -135,7 +135,7 @@
}
- protected static JBossServer findJBossServer(String serverId) throws CoreException {
+ public static JBossServer findJBossServer(String serverId) throws CoreException {
if( serverId == null )
throw new CoreException(new Status(IStatus.ERROR, JBossServerCorePlugin.PLUGIN_ID,
NLS.bind(Messages.ServerNotFound, serverId)));
@@ -153,7 +153,7 @@
return jbs;
}
- protected static IJBossServerRuntime findJBossServerRuntime(IServer server) throws CoreException {
+ public static IJBossServerRuntime findJBossServerRuntime(IServer server) throws CoreException {
IRuntime rt = server.getRuntime();
IJBossServerRuntime jbrt = null;
if( rt != null )
@@ -164,14 +164,14 @@
return jbrt;
}
- protected static void addCPEntry(ArrayList<IRuntimeClasspathEntry> list, JBossServer jbs, String relative) {
+ public static void addCPEntry(ArrayList<IRuntimeClasspathEntry> list, JBossServer jbs, String relative) {
addCPEntry(list, new Path(getServerHome(jbs)).append(relative));
}
- protected static void addCPEntry(ArrayList<IRuntimeClasspathEntry> list, IPath path) {
+ public static void addCPEntry(ArrayList<IRuntimeClasspathEntry> list, IPath path) {
list.add(JavaRuntime.newArchiveRuntimeClasspathEntry(path));
}
- protected static void addJREEntry(ArrayList<IRuntimeClasspathEntry> cp, IVMInstall vmInstall) {
+ public static void addJREEntry(ArrayList<IRuntimeClasspathEntry> cp, IVMInstall vmInstall) {
if (vmInstall != null) {
try {
cp.add(JavaRuntime.newRuntimeContainerClasspathEntry(
@@ -186,7 +186,7 @@
}
}
- protected static void addToolsJar(ArrayList<IRuntimeClasspathEntry> cp, IVMInstall vmInstall) {
+ public static void addToolsJar(ArrayList<IRuntimeClasspathEntry> cp, IVMInstall vmInstall) {
File f = vmInstall.getInstallLocation();
File c1 = new File(f, IConstants.LIB);
File c2 = new File(c1, IConstants.TOOLS_JAR);
@@ -195,7 +195,7 @@
}
- protected static ArrayList<String> convertClasspath(ArrayList<IRuntimeClasspathEntry> cp) {
+ public static ArrayList<String> convertClasspath(ArrayList<IRuntimeClasspathEntry> cp) {
Iterator<IRuntimeClasspathEntry> cpi = cp.iterator();
ArrayList<String> list = new ArrayList<String>();
while (cpi.hasNext()) {
@@ -211,7 +211,7 @@
return list;
}
- protected static void addDirectory(String serverHome, ArrayList<IRuntimeClasspathEntry> classpath,
+ public static void addDirectory(String serverHome, ArrayList<IRuntimeClasspathEntry> classpath,
String dirName) {
String libPath = serverHome + File.separator + dirName;
File libDir = new File(libPath);
Modified: workspace/rstryker/rse/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/launch/JBossServerStartupLaunchConfiguration.java
===================================================================
--- workspace/rstryker/rse/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/launch/JBossServerStartupLaunchConfiguration.java 2010-08-06 09:19:37 UTC (rev 23965)
+++ workspace/rstryker/rse/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/launch/JBossServerStartupLaunchConfiguration.java 2010-08-06 10:29:45 UTC (rev 23966)
@@ -10,384 +10,69 @@
******************************************************************************/
package org.jboss.ide.eclipse.as.core.server.internal.launch;
-import java.io.File;
-import java.net.MalformedURLException;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-
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;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.debug.core.DebugPlugin;
import org.eclipse.debug.core.ILaunch;
import org.eclipse.debug.core.ILaunchConfiguration;
-import org.eclipse.debug.core.ILaunchConfigurationType;
-import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
-import org.eclipse.debug.core.ILaunchManager;
-import org.eclipse.debug.core.model.IProcess;
-import org.eclipse.jdt.launching.IJavaLaunchConfigurationConstants;
-import org.eclipse.jdt.launching.IRuntimeClasspathEntry;
-import org.eclipse.jdt.launching.IVMInstall;
-import org.eclipse.jdt.launching.JavaRuntime;
-import org.eclipse.jdt.launching.StandardClasspathProvider;
-import org.eclipse.osgi.util.NLS;
-import org.eclipse.wst.server.core.IRuntime;
import org.eclipse.wst.server.core.IServer;
-import org.eclipse.wst.server.core.ServerCore;
import org.eclipse.wst.server.core.ServerUtil;
-import org.jboss.ide.eclipse.as.core.JBossServerCorePlugin;
-import org.jboss.ide.eclipse.as.core.Messages;
-import org.jboss.ide.eclipse.as.core.server.IJBossServerConstants;
-import org.jboss.ide.eclipse.as.core.server.IJBossServerRuntime;
-import org.jboss.ide.eclipse.as.core.server.internal.JBossServer;
-import org.jboss.ide.eclipse.as.core.server.internal.JBossServerBehavior;
-import org.jboss.ide.eclipse.as.core.util.ArgsUtil;
-import org.jboss.ide.eclipse.as.core.util.IConstants;
-import org.jboss.ide.eclipse.as.core.util.IJBossRuntimeConstants;
-import org.jboss.ide.eclipse.as.core.util.IJBossRuntimeResourceConstants;
-import org.jboss.ide.eclipse.as.core.util.IJBossToolingConstants;
+import org.jboss.ide.eclipse.as.core.publishers.LocalPublishMethod;
+import org.jboss.ide.eclipse.as.core.server.IJBossServerPublishMethodType;
+import org.jboss.ide.eclipse.as.core.server.internal.DeployableServerBehavior;
+import org.jboss.ide.eclipse.as.core.util.DeploymentPreferenceLoader;
+import org.jboss.ide.eclipse.as.core.util.ServerConverter;
public class JBossServerStartupLaunchConfiguration extends AbstractJBossLaunchConfigType {
-
- static final char[] INVALID_CHARS = new char[] {'\\', '/', ':', '*', '?', '"', '<', '>', '|', '\0', '@', '&'};
- static final String LAUNCH_TYPE = "org.jboss.ide.eclipse.as.core.server.startupConfiguration"; //$NON-NLS-1$
- static final String DEFAULTS_SET = "jboss.defaults.been.set"; //$NON-NLS-1$
- static final String START_JAR_LOC = IJBossRuntimeResourceConstants.BIN + Path.SEPARATOR + IJBossRuntimeResourceConstants.START_JAR;
- static final String START_MAIN_TYPE = IJBossRuntimeConstants.START_MAIN_TYPE;
-
- public static ILaunchConfigurationWorkingCopy setupLaunchConfiguration(IServer server, String action) throws CoreException {
- ILaunchConfigurationWorkingCopy config = createLaunchConfiguration(server);
- setupLaunchConfiguration(config, server);
- return config;
- }
-
- public static void setupLaunchConfiguration(
- ILaunchConfigurationWorkingCopy workingCopy, IServer server) throws CoreException {
- if(!workingCopy.getAttributes().containsKey(DEFAULTS_SET)) {
- forceDefaultsSet(workingCopy, server);
- }
+ public static interface StartLaunchDelegate {
+ public void actualLaunch(JBossServerStartupLaunchConfiguration launchConfig,
+ ILaunchConfiguration configuration,
+ String mode, ILaunch launch, IProgressMonitor monitor) throws CoreException;
- // Upgrade old launch configs
- JBossServer jbs = findJBossServer(server.getId());
- if( jbs == null )
- throw new CoreException(new Status(IStatus.ERROR, JBossServerCorePlugin.PLUGIN_ID,
- NLS.bind(Messages.CannotSetUpImproperServer, server.getName())));
-
- String cpProvider = workingCopy.getAttribute(IJavaLaunchConfigurationConstants.ATTR_CLASSPATH_PROVIDER, (String)null);
- if( !DEFAULT_CP_PROVIDER_ID.equals(cpProvider)) {
- workingCopy.setAttribute(IJavaLaunchConfigurationConstants.ATTR_CLASSPATH_PROVIDER, DEFAULT_CP_PROVIDER_ID);
- workingCopy.setAttribute(IJavaLaunchConfigurationConstants.ATTR_CLASSPATH, getClasspath(jbs));
- workingCopy.setAttribute(IJavaLaunchConfigurationConstants.ATTR_DEFAULT_CLASSPATH, false);
- }
+ public boolean preLaunchCheck(ILaunchConfiguration configuration, String mode, IProgressMonitor monitor) throws CoreException;
+ public void preLaunch(ILaunchConfiguration configuration,
+ String mode, ILaunch launch, IProgressMonitor monitor) throws CoreException;
+ public void postLaunch(ILaunchConfiguration configuration, String mode,
+ ILaunch launch, IProgressMonitor monitor) throws CoreException;
- // Force the launch to get certain fields from the runtime
- updateMandatedFields(workingCopy, jbs);
}
-
- /*
- * Ensures that the working directory and classpath are 100% accurate.
- * Merges proper required params into args and vm args
- */
- protected static void updateMandatedFields(ILaunchConfigurationWorkingCopy wc, JBossServer jbs) throws CoreException{
- String serverHome = getServerHome(jbs);
- if( serverHome == null )
- throw new CoreException(new Status(IStatus.ERROR, JBossServerCorePlugin.PLUGIN_ID,
- NLS.bind(Messages.CannotLocateServerHome, jbs.getServer().getName())));
-
- IRuntime rt = jbs.getServer().getRuntime();
- IJBossServerRuntime jbrt = null;
- if( rt != null )
- jbrt = (IJBossServerRuntime)rt.getAdapter(IJBossServerRuntime.class);
-
- if( jbrt == null )
- throw new CoreException(new Status(IStatus.ERROR, JBossServerCorePlugin.PLUGIN_ID,
- NLS.bind(Messages.ServerRuntimeNotFound, jbs.getServer().getName())));
-
- /* Args and vm args */
-
- String args = wc.getAttribute(IJavaLaunchConfigurationConstants.ATTR_PROGRAM_ARGUMENTS, ""); //$NON-NLS-1$
- String vmArgs = wc.getAttribute(IJavaLaunchConfigurationConstants.ATTR_VM_ARGUMENTS, ""); //$NON-NLS-1$
- String host = jbs.getServer().getHost();
- String host2 = ArgsUtil.getValue(args,
- IJBossRuntimeConstants.STARTUP_ARG_HOST_SHORT,
- IJBossRuntimeConstants.STARTUP_ARG_HOST_LONG);
- if( !host.equals(host2))
- args = ArgsUtil.setArg(args,
- IJBossRuntimeConstants.STARTUP_ARG_HOST_SHORT,
- IJBossRuntimeConstants.STARTUP_ARG_HOST_LONG, host);
-
- IJBossServerRuntime runtime = (IJBossServerRuntime)
- jbs.getServer().getRuntime().loadAdapter(IJBossServerRuntime.class, null);
- String config = runtime.getJBossConfiguration();
- args = ArgsUtil.setArg(args,
- IJBossRuntimeConstants.STARTUP_ARG_CONFIG_SHORT,
- IJBossRuntimeConstants.STARTUP_ARG_CONFIG_LONG, config);
-
- try {
- if( !runtime.getConfigLocation().equals(IConstants.SERVER)) {
- args = ArgsUtil.setArg(args, null,
- IJBossRuntimeConstants.SYSPROP + IJBossRuntimeConstants.JBOSS_SERVER_HOME_URL,
- runtime.getConfigLocationFullPath().toFile().toURL().toString());
- }
- } catch( MalformedURLException murle) {}
-
-
- vmArgs= ArgsUtil.setArg(vmArgs, null,
- IJBossRuntimeConstants.SYSPROP + IJBossRuntimeConstants.ENDORSED_DIRS,
- runtime.getRuntime().getLocation().append(
- IJBossRuntimeResourceConstants.LIB).append(
- IJBossRuntimeResourceConstants.ENDORSED).toOSString(), true);
-
- if( runtime.getRuntime().getLocation().append(
- IJBossRuntimeResourceConstants.BIN).append(
- IJBossRuntimeResourceConstants.NATIVE).toFile().exists() ) {
- String argVal = ArgsUtil.getValue(vmArgs, null,
- IJBossRuntimeConstants.SYSPROP + IJBossRuntimeConstants.JAVA_LIB_PATH);
-
- String libPath =
- runtime.getRuntime().getLocation()
- .append(IJBossRuntimeResourceConstants.BIN)
- .append(IJBossRuntimeResourceConstants.NATIVE).toOSString();
- if( argVal != null ) {
- if( argVal.startsWith("\"")) //$NON-NLS-1$
- argVal = argVal.substring(1);
- if( argVal.endsWith("\"")) //$NON-NLS-1$
- argVal = argVal.substring(0, argVal.length()-1);
- if( argVal.startsWith(":")) //$NON-NLS-1$
- argVal = argVal.substring(1);
-
- String[] asArr = argVal.split(File.pathSeparator);
- asArr[0] = libPath;
- String implode = ""; //$NON-NLS-1$
- for( int i = 0; i < asArr.length; i++ )
- implode += asArr[i] + File.pathSeparator;
- libPath = implode;
- }
- vmArgs = ArgsUtil.setArg(vmArgs, null,
- IJBossRuntimeConstants.SYSPROP + IJBossRuntimeConstants.JAVA_LIB_PATH,
- libPath, true);
+ private StartLaunchDelegate del = null;
+ protected StartLaunchDelegate getDelegate(ILaunchConfiguration configuration) throws CoreException {
+ if( del != null )
+ return del;
+ IServer server = ServerUtil.getServer(configuration);
+ DeployableServerBehavior beh = ServerConverter.getDeployableServerBehavior(server);
+ IJBossServerPublishMethodType type = beh.createPublishMethod().getPublishMethodType();
+ if( type.getId().equals(LocalPublishMethod.LOCAL_PUBLISH_METHOD)) {
+ del = new LocalJBossServerStartupLaunchUtil();
}
-
- /* Claspath */
- List<String> cp = wc.getAttribute(IJavaLaunchConfigurationConstants.ATTR_CLASSPATH, new ArrayList<String>());
- List<String> newCP = fixCP(cp, jbs);
-
- IVMInstall vmInstall = runtime.getVM();
- if( vmInstall != null )
- wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_JRE_CONTAINER_PATH, JavaRuntime.newJREContainerPath(vmInstall).toPortableString());
- wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_WORKING_DIRECTORY, serverHome + Path.SEPARATOR + IJBossRuntimeResourceConstants.BIN);
- wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_PROGRAM_ARGUMENTS, args.trim());
- wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_VM_ARGUMENTS, vmArgs.trim());
- wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_CLASSPATH, newCP);
- wc.setAttribute(SERVER_ID,jbs.getServer().getId());
-
+ return del;
}
-
- protected static List<String> fixCP(List<String> list, JBossServer jbs) {
- try {
- boolean found = false;
- String[] asString = (String[]) list.toArray(new String[list.size()]);
- for( int i = 0; i < asString.length; i++ ) {
- if( asString[i].contains(RunJarContainerWrapper.ID)) {
- found = true;
- asString[i] = getRunJarRuntimeCPEntry(jbs).getMemento();
- }
- }
- ArrayList<String> result = new ArrayList<String>();
- result.addAll(Arrays.asList(asString));
- if( !found )
- result.add(getRunJarRuntimeCPEntry(jbs).getMemento());
- return result;
- } catch( CoreException ce) {
- return list;
- }
+ public void actualLaunch(ILaunchConfiguration configuration,
+ String mode, ILaunch launch, IProgressMonitor monitor) throws CoreException {
+ getDelegate(configuration).actualLaunch(this, configuration, mode, launch, monitor);
}
- protected static void forceDefaultsSet(ILaunchConfigurationWorkingCopy wc, IServer server) throws CoreException {
- JBossServer jbs = findJBossServer(server.getId());
- if( jbs == null )
- throw new CoreException(new Status(IStatus.ERROR, JBossServerCorePlugin.PLUGIN_ID,
- NLS.bind(Messages.CannotSetUpImproperServer, server.getName())));
-
- String serverHome = getServerHome(jbs);
- if( serverHome == null )
- throw new CoreException(new Status(IStatus.ERROR, JBossServerCorePlugin.PLUGIN_ID,
- NLS.bind(Messages.CannotLocateServerHome, server.getName())));
-
- IRuntime rt = jbs.getServer().getRuntime();
- IJBossServerRuntime jbrt = null;
- if( rt != null ) {
- jbrt = (IJBossServerRuntime)rt.getAdapter(IJBossServerRuntime.class);
- }
-
- if( jbrt == null )
- throw new CoreException(new Status(IStatus.ERROR, JBossServerCorePlugin.PLUGIN_ID,
- NLS.bind(Messages.ServerRuntimeNotFound, jbs.getServer().getName())));
-
- IVMInstall vmInstall = jbrt.getVM();
- if( vmInstall != null )
- wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_JRE_CONTAINER_PATH, JavaRuntime.newJREContainerPath(vmInstall).toPortableString());
- wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_PROGRAM_ARGUMENTS, getDefaultArgs(jbs));
- wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_VM_ARGUMENTS, jbrt.getDefaultRunVMArgs());
- wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_MAIN_TYPE_NAME, START_MAIN_TYPE);
- wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_WORKING_DIRECTORY, serverHome + Path.SEPARATOR + IJBossRuntimeResourceConstants.BIN);
- wc.setAttribute(ILaunchManager.ATTR_ENVIRONMENT_VARIABLES, jbrt.getDefaultRunEnvVars());
- wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_CLASSPATH, getClasspath(jbs));
- wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_CLASSPATH_PROVIDER, DEFAULT_CP_PROVIDER_ID);
- wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_DEFAULT_CLASSPATH, false);
-
- wc.setAttribute(DEFAULTS_SET, true);
- }
-
- protected static ArrayList<String> getClasspath(JBossServer jbs) throws CoreException {
- IJBossServerRuntime jbrt = findJBossServerRuntime(jbs.getServer());
- ArrayList<IRuntimeClasspathEntry> classpath = new ArrayList<IRuntimeClasspathEntry>();
- classpath.add(getRunJarRuntimeCPEntry(jbs));
- addJREEntry(classpath, jbrt.getVM());
-
- String version = jbs.getServer().getRuntime().getRuntimeType().getVersion();
- if( version.equals(IJBossToolingConstants.AS_40))
- addToolsJar(classpath, jbrt.getVM());
-
- ArrayList<String> runtimeClassPaths = convertClasspath(classpath);
- return runtimeClassPaths;
-
- }
+ public void superActualLaunch(ILaunchConfiguration configuration,
+ String mode, ILaunch launch, IProgressMonitor monitor) throws CoreException {
+ super.actualLaunch(configuration, mode, launch, monitor);
+ }
+ /*
+ * Ensures that the working directory and classpath are 100% accurate.
+ * Merges proper required params into args and vm args
+ */
- protected static IRuntimeClasspathEntry getRunJarRuntimeCPEntry(JBossServer jbs) throws CoreException {
- IPath containerPath = new Path(RunJarContainerWrapper.ID).append(jbs.getServer().getName());
- return JavaRuntime.newRuntimeContainerClasspathEntry(containerPath, IRuntimeClasspathEntry.USER_CLASSES);
- }
-
- protected static String getDefaultArgs(JBossServer jbs) throws CoreException {
- IJBossServerRuntime rt = findJBossServerRuntime(jbs.getServer());
- if (rt != null) {
- return rt.getDefaultRunArgs() +
- IJBossRuntimeConstants.SPACE + IJBossRuntimeConstants.STARTUP_ARG_HOST_SHORT +
- IJBossRuntimeConstants.SPACE + jbs.getServer().getHost();
- }
- return null;
- }
-
public boolean preLaunchCheck(ILaunchConfiguration configuration, String mode, IProgressMonitor monitor) throws CoreException {
- JBossServerBehavior jbsBehavior = getServerBehavior(configuration);
- if( !jbsBehavior.canStart(mode).isOK())
- throw new CoreException(jbsBehavior.canStart(mode));
- return true;
+ return getDelegate(configuration).preLaunchCheck(configuration, mode, monitor);
}
- protected void preLaunch(ILaunchConfiguration configuration,
+ public void preLaunch(ILaunchConfiguration configuration,
String mode, ILaunch launch, IProgressMonitor monitor) throws CoreException {
- try {
- JBossServerBehavior jbsBehavior = getServerBehavior(configuration);
- jbsBehavior.setRunMode(mode);
- jbsBehavior.serverStarting();
- } catch( CoreException ce ) {
- // report it
- }
+ getDelegate(configuration).preLaunch(configuration, mode, launch, monitor);
}
public void postLaunch(ILaunchConfiguration configuration, String mode,
ILaunch launch, IProgressMonitor monitor) throws CoreException {
- try {
- IProcess[] processes = launch.getProcesses();
- JBossServerBehavior jbsBehavior = getServerBehavior(configuration);
- jbsBehavior.setProcess(processes[0]);
- } catch( CoreException ce ) {
- // report
- }
+ getDelegate(configuration).postLaunch(configuration, mode, launch, monitor);
}
-
- public static JBossServerBehavior getServerBehavior(ILaunchConfiguration configuration) throws CoreException {
- IServer server = ServerUtil.getServer(configuration);
- JBossServerBehavior jbossServerBehavior = (JBossServerBehavior) server.getAdapter(JBossServerBehavior.class);
- return jbossServerBehavior;
- }
-
- protected static String getValidLaunchConfigurationName(String s) {
- if (s == null || s.length() == 0)
- return "1"; //$NON-NLS-1$
- int size = INVALID_CHARS.length;
- for (int i = 0; i < size; i++) {
- s = s.replace(INVALID_CHARS[i], '_');
- }
- return s;
- }
-
- /**
- * Will create a launch configuration for the server
- * if one does not already exist.
- */
- public static ILaunchConfigurationWorkingCopy createLaunchConfiguration(IServer server) throws CoreException {
- ILaunchConfigurationType launchConfigType = DebugPlugin.getDefault().getLaunchManager().getLaunchConfigurationType(LAUNCH_TYPE);
- if (launchConfigType == null)
- return null;
-
- ILaunchManager launchManager = DebugPlugin.getDefault().getLaunchManager();
- ILaunchConfiguration[] launchConfigs = null;
- try {
- launchConfigs = launchManager.getLaunchConfigurations(launchConfigType);
- } catch (CoreException e) {
- // ignore
- }
-
- if (launchConfigs != null) {
- int size = launchConfigs.length;
- for (int i = 0; i < size; i++) {
- try {
- String serverId = launchConfigs[i].getAttribute(SERVER_ID, (String) null);
- if (server.getId().equals(serverId)) {
- ILaunchConfigurationWorkingCopy wc = launchConfigs[i].getWorkingCopy();
- return wc;
- }
- } catch (CoreException e) {
- }
- }
- }
-
- // create a new launch configuration
- String launchName = getValidLaunchConfigurationName(server.getName());
- launchName = launchManager.generateUniqueLaunchConfigurationNameFrom(launchName);
- ILaunchConfigurationWorkingCopy wc = launchConfigType.newInstance(null, launchName);
- wc.setAttribute(SERVER_ID, server.getId());
- return wc;
- }
-
- /* For "restore defaults" functionality */
- private static final String DEFAULT_CP_PROVIDER_ID = "org.jboss.ide.eclipse.as.core.server.internal.launch.serverClasspathProvider"; //$NON-NLS-1$
- public static class JBossServerDefaultClasspathProvider extends StandardClasspathProvider {
- public IRuntimeClasspathEntry[] computeUnresolvedClasspath(ILaunchConfiguration configuration) throws CoreException {
- boolean useDefault = configuration.getAttribute(IJavaLaunchConfigurationConstants.ATTR_DEFAULT_CLASSPATH, true);
- if (useDefault) {
- return defaultEntries(configuration);
- }
- return super.computeUnresolvedClasspath(configuration);
- }
-
- protected IRuntimeClasspathEntry[] defaultEntries(ILaunchConfiguration config) {
- try {
- String server = config.getAttribute(SERVER_ID, (String)null);
- IServer s = ServerCore.findServer(server);
- IJBossServerRuntime ibjsrt = (IJBossServerRuntime)s.getRuntime().loadAdapter(IJBossServerRuntime.class, new NullProgressMonitor());
- JBossServer jbs = (JBossServer)s.loadAdapter(JBossServer.class, new NullProgressMonitor());
- IVMInstall install = ibjsrt.getVM();
- ArrayList<IRuntimeClasspathEntry> list = new ArrayList<IRuntimeClasspathEntry>();
- addJREEntry(list, install);
- list.add(getRunJarRuntimeCPEntry(jbs));
- return (IRuntimeClasspathEntry[]) list
- .toArray(new IRuntimeClasspathEntry[list.size()]);
- } catch( CoreException ce) {
- }
- try {
- return super.computeUnresolvedClasspath(config);
- } catch( CoreException ce ) {}
- return new IRuntimeClasspathEntry[]{};
- }
- }
}
Added: workspace/rstryker/rse/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/launch/LocalJBossServerStartupLaunchUtil.java
===================================================================
--- workspace/rstryker/rse/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/launch/LocalJBossServerStartupLaunchUtil.java (rev 0)
+++ workspace/rstryker/rse/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/launch/LocalJBossServerStartupLaunchUtil.java 2010-08-06 10:29:45 UTC (rev 23966)
@@ -0,0 +1,408 @@
+/*******************************************************************************
+ * Copyright (c) 2007 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.core.server.internal.launch;
+
+import java.io.File;
+import java.net.MalformedURLException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+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;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.debug.core.DebugPlugin;
+import org.eclipse.debug.core.ILaunch;
+import org.eclipse.debug.core.ILaunchConfiguration;
+import org.eclipse.debug.core.ILaunchConfigurationType;
+import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
+import org.eclipse.debug.core.ILaunchManager;
+import org.eclipse.debug.core.model.IProcess;
+import org.eclipse.jdt.launching.IJavaLaunchConfigurationConstants;
+import org.eclipse.jdt.launching.IRuntimeClasspathEntry;
+import org.eclipse.jdt.launching.IVMInstall;
+import org.eclipse.jdt.launching.JavaRuntime;
+import org.eclipse.jdt.launching.StandardClasspathProvider;
+import org.eclipse.osgi.util.NLS;
+import org.eclipse.wst.server.core.IRuntime;
+import org.eclipse.wst.server.core.IServer;
+import org.eclipse.wst.server.core.ServerCore;
+import org.eclipse.wst.server.core.ServerUtil;
+import org.jboss.ide.eclipse.as.core.JBossServerCorePlugin;
+import org.jboss.ide.eclipse.as.core.Messages;
+import org.jboss.ide.eclipse.as.core.server.IJBossServerRuntime;
+import org.jboss.ide.eclipse.as.core.server.internal.JBossServer;
+import org.jboss.ide.eclipse.as.core.server.internal.JBossServerBehavior;
+import org.jboss.ide.eclipse.as.core.server.internal.LocalJBossBehaviorDelegate;
+import org.jboss.ide.eclipse.as.core.server.internal.launch.JBossServerStartupLaunchConfiguration.StartLaunchDelegate;
+import org.jboss.ide.eclipse.as.core.util.ArgsUtil;
+import org.jboss.ide.eclipse.as.core.util.IConstants;
+import org.jboss.ide.eclipse.as.core.util.IJBossRuntimeConstants;
+import org.jboss.ide.eclipse.as.core.util.IJBossRuntimeResourceConstants;
+import org.jboss.ide.eclipse.as.core.util.IJBossToolingConstants;
+
+public class LocalJBossServerStartupLaunchUtil implements StartLaunchDelegate {
+
+ static final char[] INVALID_CHARS = new char[] {'\\', '/', ':', '*', '?', '"', '<', '>', '|', '\0', '@', '&'};
+ static final String LAUNCH_TYPE = "org.jboss.ide.eclipse.as.core.server.startupConfiguration"; //$NON-NLS-1$
+ static final String DEFAULTS_SET = "jboss.defaults.been.set"; //$NON-NLS-1$
+ static final String START_JAR_LOC = IJBossRuntimeResourceConstants.BIN + Path.SEPARATOR + IJBossRuntimeResourceConstants.START_JAR;
+ static final String START_MAIN_TYPE = IJBossRuntimeConstants.START_MAIN_TYPE;
+
+ public static ILaunchConfigurationWorkingCopy setupLaunchConfiguration(IServer server, String action) throws CoreException {
+ ILaunchConfigurationWorkingCopy config = createLaunchConfiguration(server);
+ setupLaunchConfiguration(config, server);
+ return config;
+ }
+
+ public static void setupLaunchConfiguration(
+ ILaunchConfigurationWorkingCopy workingCopy, IServer server) throws CoreException {
+ if(!workingCopy.getAttributes().containsKey(DEFAULTS_SET)) {
+ forceDefaultsSet(workingCopy, server);
+ }
+
+ // Upgrade old launch configs
+ JBossServer jbs = AbstractJBossLaunchConfigType.findJBossServer(server.getId());
+ if( jbs == null )
+ throw new CoreException(new Status(IStatus.ERROR, JBossServerCorePlugin.PLUGIN_ID,
+ NLS.bind(Messages.CannotSetUpImproperServer, server.getName())));
+
+ String cpProvider = workingCopy.getAttribute(IJavaLaunchConfigurationConstants.ATTR_CLASSPATH_PROVIDER, (String)null);
+ if( !DEFAULT_CP_PROVIDER_ID.equals(cpProvider)) {
+ workingCopy.setAttribute(IJavaLaunchConfigurationConstants.ATTR_CLASSPATH_PROVIDER, DEFAULT_CP_PROVIDER_ID);
+ workingCopy.setAttribute(IJavaLaunchConfigurationConstants.ATTR_CLASSPATH, getClasspath(jbs));
+ workingCopy.setAttribute(IJavaLaunchConfigurationConstants.ATTR_DEFAULT_CLASSPATH, false);
+ }
+
+ // Force the launch to get certain fields from the runtime
+ updateMandatedFields(workingCopy, jbs);
+ }
+
+ /*
+ * Ensures that the working directory and classpath are 100% accurate.
+ * Merges proper required params into args and vm args
+ */
+
+ protected static void updateMandatedFields(ILaunchConfigurationWorkingCopy wc, JBossServer jbs) throws CoreException{
+ String serverHome = AbstractJBossLaunchConfigType.getServerHome(jbs);
+ if( serverHome == null )
+ throw new CoreException(new Status(IStatus.ERROR, JBossServerCorePlugin.PLUGIN_ID,
+ NLS.bind(Messages.CannotLocateServerHome, jbs.getServer().getName())));
+
+ IRuntime rt = jbs.getServer().getRuntime();
+ IJBossServerRuntime jbrt = null;
+ if( rt != null )
+ jbrt = (IJBossServerRuntime)rt.getAdapter(IJBossServerRuntime.class);
+
+ if( jbrt == null )
+ throw new CoreException(new Status(IStatus.ERROR, JBossServerCorePlugin.PLUGIN_ID,
+ NLS.bind(Messages.ServerRuntimeNotFound, jbs.getServer().getName())));
+
+ /* Args and vm args */
+
+ String args = wc.getAttribute(IJavaLaunchConfigurationConstants.ATTR_PROGRAM_ARGUMENTS, ""); //$NON-NLS-1$
+ String vmArgs = wc.getAttribute(IJavaLaunchConfigurationConstants.ATTR_VM_ARGUMENTS, ""); //$NON-NLS-1$
+ String host = jbs.getServer().getHost();
+ String host2 = ArgsUtil.getValue(args,
+ IJBossRuntimeConstants.STARTUP_ARG_HOST_SHORT,
+ IJBossRuntimeConstants.STARTUP_ARG_HOST_LONG);
+ if( !host.equals(host2))
+ args = ArgsUtil.setArg(args,
+ IJBossRuntimeConstants.STARTUP_ARG_HOST_SHORT,
+ IJBossRuntimeConstants.STARTUP_ARG_HOST_LONG, host);
+
+ IJBossServerRuntime runtime = (IJBossServerRuntime)
+ jbs.getServer().getRuntime().loadAdapter(IJBossServerRuntime.class, null);
+ String config = runtime.getJBossConfiguration();
+ args = ArgsUtil.setArg(args,
+ IJBossRuntimeConstants.STARTUP_ARG_CONFIG_SHORT,
+ IJBossRuntimeConstants.STARTUP_ARG_CONFIG_LONG, config);
+
+ try {
+ if( !runtime.getConfigLocation().equals(IConstants.SERVER)) {
+ args = ArgsUtil.setArg(args, null,
+ IJBossRuntimeConstants.SYSPROP + IJBossRuntimeConstants.JBOSS_SERVER_HOME_URL,
+ runtime.getConfigLocationFullPath().toFile().toURL().toString());
+ }
+ } catch( MalformedURLException murle) {}
+
+
+ vmArgs= ArgsUtil.setArg(vmArgs, null,
+ IJBossRuntimeConstants.SYSPROP + IJBossRuntimeConstants.ENDORSED_DIRS,
+ runtime.getRuntime().getLocation().append(
+ IJBossRuntimeResourceConstants.LIB).append(
+ IJBossRuntimeResourceConstants.ENDORSED).toOSString(), true);
+
+ if( runtime.getRuntime().getLocation().append(
+ IJBossRuntimeResourceConstants.BIN).append(
+ IJBossRuntimeResourceConstants.NATIVE).toFile().exists() ) {
+ String argVal = ArgsUtil.getValue(vmArgs, null,
+ IJBossRuntimeConstants.SYSPROP + IJBossRuntimeConstants.JAVA_LIB_PATH);
+
+ String libPath =
+ runtime.getRuntime().getLocation()
+ .append(IJBossRuntimeResourceConstants.BIN)
+ .append(IJBossRuntimeResourceConstants.NATIVE).toOSString();
+ if( argVal != null ) {
+ if( argVal.startsWith("\"")) //$NON-NLS-1$
+ argVal = argVal.substring(1);
+ if( argVal.endsWith("\"")) //$NON-NLS-1$
+ argVal = argVal.substring(0, argVal.length()-1);
+ if( argVal.startsWith(":")) //$NON-NLS-1$
+ argVal = argVal.substring(1);
+
+ String[] asArr = argVal.split(File.pathSeparator);
+ asArr[0] = libPath;
+ String implode = ""; //$NON-NLS-1$
+ for( int i = 0; i < asArr.length; i++ )
+ implode += asArr[i] + File.pathSeparator;
+ libPath = implode;
+ }
+ vmArgs = ArgsUtil.setArg(vmArgs, null,
+ IJBossRuntimeConstants.SYSPROP + IJBossRuntimeConstants.JAVA_LIB_PATH,
+ libPath, true);
+ }
+
+ /* Claspath */
+ List<String> cp = wc.getAttribute(IJavaLaunchConfigurationConstants.ATTR_CLASSPATH, new ArrayList<String>());
+ List<String> newCP = fixCP(cp, jbs);
+
+ IVMInstall vmInstall = runtime.getVM();
+ if( vmInstall != null )
+ wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_JRE_CONTAINER_PATH, JavaRuntime.newJREContainerPath(vmInstall).toPortableString());
+ wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_WORKING_DIRECTORY, serverHome + Path.SEPARATOR + IJBossRuntimeResourceConstants.BIN);
+ wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_PROGRAM_ARGUMENTS, args.trim());
+ wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_VM_ARGUMENTS, vmArgs.trim());
+ wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_CLASSPATH, newCP);
+ wc.setAttribute(AbstractJBossLaunchConfigType.SERVER_ID,jbs.getServer().getId());
+
+ }
+
+ protected static List<String> fixCP(List<String> list, JBossServer jbs) {
+ try {
+ boolean found = false;
+ String[] asString = (String[]) list.toArray(new String[list.size()]);
+ for( int i = 0; i < asString.length; i++ ) {
+ if( asString[i].contains(RunJarContainerWrapper.ID)) {
+ found = true;
+ asString[i] = getRunJarRuntimeCPEntry(jbs).getMemento();
+ }
+ }
+ ArrayList<String> result = new ArrayList<String>();
+ result.addAll(Arrays.asList(asString));
+ if( !found )
+ result.add(getRunJarRuntimeCPEntry(jbs).getMemento());
+ return result;
+ } catch( CoreException ce) {
+ return list;
+ }
+ }
+
+ protected static void forceDefaultsSet(ILaunchConfigurationWorkingCopy wc, IServer server) throws CoreException {
+ JBossServer jbs = AbstractJBossLaunchConfigType.findJBossServer(server.getId());
+ if( jbs == null )
+ throw new CoreException(new Status(IStatus.ERROR, JBossServerCorePlugin.PLUGIN_ID,
+ NLS.bind(Messages.CannotSetUpImproperServer, server.getName())));
+
+ String serverHome = AbstractJBossLaunchConfigType.getServerHome(jbs);
+ if( serverHome == null )
+ throw new CoreException(new Status(IStatus.ERROR, JBossServerCorePlugin.PLUGIN_ID,
+ NLS.bind(Messages.CannotLocateServerHome, server.getName())));
+
+ IRuntime rt = jbs.getServer().getRuntime();
+ IJBossServerRuntime jbrt = null;
+ if( rt != null ) {
+ jbrt = (IJBossServerRuntime)rt.getAdapter(IJBossServerRuntime.class);
+ }
+
+ if( jbrt == null )
+ throw new CoreException(new Status(IStatus.ERROR, JBossServerCorePlugin.PLUGIN_ID,
+ NLS.bind(Messages.ServerRuntimeNotFound, jbs.getServer().getName())));
+
+ IVMInstall vmInstall = jbrt.getVM();
+ if( vmInstall != null )
+ wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_JRE_CONTAINER_PATH, JavaRuntime.newJREContainerPath(vmInstall).toPortableString());
+ wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_PROGRAM_ARGUMENTS, getDefaultArgs(jbs));
+ wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_VM_ARGUMENTS, jbrt.getDefaultRunVMArgs());
+ wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_MAIN_TYPE_NAME, START_MAIN_TYPE);
+ wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_WORKING_DIRECTORY, serverHome + Path.SEPARATOR + IJBossRuntimeResourceConstants.BIN);
+ wc.setAttribute(ILaunchManager.ATTR_ENVIRONMENT_VARIABLES, jbrt.getDefaultRunEnvVars());
+ wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_CLASSPATH, getClasspath(jbs));
+ wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_CLASSPATH_PROVIDER, DEFAULT_CP_PROVIDER_ID);
+ wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_DEFAULT_CLASSPATH, false);
+
+ wc.setAttribute(DEFAULTS_SET, true);
+ }
+
+ protected static ArrayList<String> getClasspath(JBossServer jbs) throws CoreException {
+ IJBossServerRuntime jbrt = AbstractJBossLaunchConfigType.findJBossServerRuntime(jbs.getServer());
+ ArrayList<IRuntimeClasspathEntry> classpath = new ArrayList<IRuntimeClasspathEntry>();
+ classpath.add(getRunJarRuntimeCPEntry(jbs));
+ AbstractJBossLaunchConfigType.addJREEntry(classpath, jbrt.getVM());
+
+ String version = jbs.getServer().getRuntime().getRuntimeType().getVersion();
+ if( version.equals(IJBossToolingConstants.AS_40))
+ AbstractJBossLaunchConfigType.addToolsJar(classpath, jbrt.getVM());
+
+ ArrayList<String> runtimeClassPaths = AbstractJBossLaunchConfigType.convertClasspath(classpath);
+ return runtimeClassPaths;
+
+ }
+
+ protected static IRuntimeClasspathEntry getRunJarRuntimeCPEntry(JBossServer jbs) throws CoreException {
+ IPath containerPath = new Path(RunJarContainerWrapper.ID).append(jbs.getServer().getName());
+ return JavaRuntime.newRuntimeContainerClasspathEntry(containerPath, IRuntimeClasspathEntry.USER_CLASSES);
+ }
+
+ protected static String getDefaultArgs(JBossServer jbs) throws CoreException {
+ IJBossServerRuntime rt = AbstractJBossLaunchConfigType.findJBossServerRuntime(jbs.getServer());
+ if (rt != null) {
+ return rt.getDefaultRunArgs() +
+ IJBossRuntimeConstants.SPACE + IJBossRuntimeConstants.STARTUP_ARG_HOST_SHORT +
+ IJBossRuntimeConstants.SPACE + jbs.getServer().getHost();
+ }
+ return null;
+ }
+
+
+ public static JBossServerBehavior getServerBehavior(ILaunchConfiguration configuration) throws CoreException {
+ IServer server = ServerUtil.getServer(configuration);
+ JBossServerBehavior jbossServerBehavior = (JBossServerBehavior) server.getAdapter(JBossServerBehavior.class);
+ return jbossServerBehavior;
+ }
+
+ protected static String getValidLaunchConfigurationName(String s) {
+ if (s == null || s.length() == 0)
+ return "1"; //$NON-NLS-1$
+ int size = INVALID_CHARS.length;
+ for (int i = 0; i < size; i++) {
+ s = s.replace(INVALID_CHARS[i], '_');
+ }
+ return s;
+ }
+
+ /**
+ * Will create a launch configuration for the server
+ * if one does not already exist.
+ */
+ public static ILaunchConfigurationWorkingCopy createLaunchConfiguration(IServer server) throws CoreException {
+ ILaunchConfigurationType launchConfigType = DebugPlugin.getDefault().getLaunchManager().getLaunchConfigurationType(LAUNCH_TYPE);
+ if (launchConfigType == null)
+ return null;
+
+ ILaunchManager launchManager = DebugPlugin.getDefault().getLaunchManager();
+ ILaunchConfiguration[] launchConfigs = null;
+ try {
+ launchConfigs = launchManager.getLaunchConfigurations(launchConfigType);
+ } catch (CoreException e) {
+ // ignore
+ }
+
+ if (launchConfigs != null) {
+ int size = launchConfigs.length;
+ for (int i = 0; i < size; i++) {
+ try {
+ String serverId = launchConfigs[i].getAttribute(AbstractJBossLaunchConfigType.SERVER_ID, (String) null);
+ if (server.getId().equals(serverId)) {
+ ILaunchConfigurationWorkingCopy wc = launchConfigs[i].getWorkingCopy();
+ return wc;
+ }
+ } catch (CoreException e) {
+ }
+ }
+ }
+
+ // create a new launch configuration
+ String launchName = getValidLaunchConfigurationName(server.getName());
+ launchName = launchManager.generateUniqueLaunchConfigurationNameFrom(launchName);
+ ILaunchConfigurationWorkingCopy wc = launchConfigType.newInstance(null, launchName);
+ wc.setAttribute(AbstractJBossLaunchConfigType.SERVER_ID, server.getId());
+ return wc;
+ }
+
+ /* For "restore defaults" functionality */
+ private static final String DEFAULT_CP_PROVIDER_ID = "org.jboss.ide.eclipse.as.core.server.internal.launch.serverClasspathProvider"; //$NON-NLS-1$
+ public static class JBossServerDefaultClasspathProvider extends StandardClasspathProvider {
+ public IRuntimeClasspathEntry[] computeUnresolvedClasspath(ILaunchConfiguration configuration) throws CoreException {
+ boolean useDefault = configuration.getAttribute(IJavaLaunchConfigurationConstants.ATTR_DEFAULT_CLASSPATH, true);
+ if (useDefault) {
+ return defaultEntries(configuration);
+ }
+ return super.computeUnresolvedClasspath(configuration);
+ }
+
+ protected IRuntimeClasspathEntry[] defaultEntries(ILaunchConfiguration config) {
+ try {
+ String server = config.getAttribute(AbstractJBossLaunchConfigType.SERVER_ID, (String)null);
+ IServer s = ServerCore.findServer(server);
+ IJBossServerRuntime ibjsrt = (IJBossServerRuntime)s.getRuntime().loadAdapter(IJBossServerRuntime.class, new NullProgressMonitor());
+ JBossServer jbs = (JBossServer)s.loadAdapter(JBossServer.class, new NullProgressMonitor());
+ IVMInstall install = ibjsrt.getVM();
+ ArrayList<IRuntimeClasspathEntry> list = new ArrayList<IRuntimeClasspathEntry>();
+ AbstractJBossLaunchConfigType.addJREEntry(list, install);
+ list.add(getRunJarRuntimeCPEntry(jbs));
+ return (IRuntimeClasspathEntry[]) list
+ .toArray(new IRuntimeClasspathEntry[list.size()]);
+ } catch( CoreException ce) {
+ }
+ try {
+ return super.computeUnresolvedClasspath(config);
+ } catch( CoreException ce ) {}
+ return new IRuntimeClasspathEntry[]{};
+ }
+ }
+
+
+
+ /*
+ * Actual instance methods
+ */
+ public void actualLaunch(
+ JBossServerStartupLaunchConfiguration launchConfig,
+ ILaunchConfiguration configuration, String mode, ILaunch launch,
+ IProgressMonitor monitor) throws CoreException {
+ launchConfig.superActualLaunch(configuration, mode, launch, monitor);
+ }
+
+ public boolean preLaunchCheck(ILaunchConfiguration configuration, String mode, IProgressMonitor monitor) throws CoreException {
+ JBossServerBehavior jbsBehavior = getServerBehavior(configuration);
+ if( !jbsBehavior.canStart(mode).isOK())
+ throw new CoreException(jbsBehavior.canStart(mode));
+ return true;
+ }
+
+ public void preLaunch(ILaunchConfiguration configuration,
+ String mode, ILaunch launch, IProgressMonitor monitor) throws CoreException {
+ try {
+ JBossServerBehavior jbsBehavior = getServerBehavior(configuration);
+ jbsBehavior.setRunMode(mode);
+ jbsBehavior.serverStarting();
+ } catch( CoreException ce ) {
+ // report it
+ }
+ }
+
+ public void postLaunch(ILaunchConfiguration configuration, String mode,
+ ILaunch launch, IProgressMonitor monitor) throws CoreException {
+ try {
+ IProcess[] processes = launch.getProcesses();
+ JBossServerBehavior jbsBehavior = getServerBehavior(configuration);
+ ((LocalJBossBehaviorDelegate)(jbsBehavior.getDelegate())).setProcess(processes[0]);
+ } catch( CoreException ce ) {
+ // report
+ }
+ }
+
+}
Modified: workspace/rstryker/rse/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/launch/RunJarContainerWrapper.java
===================================================================
--- workspace/rstryker/rse/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/launch/RunJarContainerWrapper.java 2010-08-06 09:19:37 UTC (rev 23965)
+++ workspace/rstryker/rse/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/launch/RunJarContainerWrapper.java 2010-08-06 10:29:45 UTC (rev 23966)
@@ -82,7 +82,7 @@
if( s != null ) {
IRuntime rt = s.getRuntime();
IPath home = rt.getLocation();
- IPath runJar = home.append(JBossServerStartupLaunchConfiguration.START_JAR_LOC);
+ IPath runJar = home.append(LocalJBossServerStartupLaunchUtil.START_JAR_LOC);
return new IClasspathEntry[] {
JavaRuntime.newArchiveRuntimeClasspathEntry(
Modified: workspace/rstryker/rse/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/launch/StopLaunchConfiguration.java
===================================================================
--- workspace/rstryker/rse/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/launch/StopLaunchConfiguration.java 2010-08-06 09:19:37 UTC (rev 23965)
+++ workspace/rstryker/rse/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/launch/StopLaunchConfiguration.java 2010-08-06 10:29:45 UTC (rev 23966)
@@ -68,7 +68,7 @@
}
}
- protected void preLaunch(ILaunchConfiguration configuration,
+ public void preLaunch(ILaunchConfiguration configuration,
String mode, ILaunch launch, IProgressMonitor monitor) {
}
Modified: workspace/rstryker/rse/as/plugins/org.jboss.ide.eclipse.as.core/plugin.xml
===================================================================
--- workspace/rstryker/rse/as/plugins/org.jboss.ide.eclipse.as.core/plugin.xml 2010-08-06 09:19:37 UTC (rev 23965)
+++ workspace/rstryker/rse/as/plugins/org.jboss.ide.eclipse.as.core/plugin.xml 2010-08-06 10:29:45 UTC (rev 23966)
@@ -1019,7 +1019,7 @@
<extension
point="org.eclipse.jdt.launching.classpathProviders">
<classpathProvider
- class="org.jboss.ide.eclipse.as.core.server.internal.launch.JBossServerStartupLaunchConfiguration$JBossServerDefaultClasspathProvider"
+ class="org.jboss.ide.eclipse.as.core.server.internal.launch.LocalJBossServerStartupLaunchUtil$JBossServerDefaultClasspathProvider"
id="org.jboss.ide.eclipse.as.core.server.internal.launch.serverClasspathProvider">
</classpathProvider>
</extension>
Modified: workspace/rstryker/rse/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/server/MockTests.java
===================================================================
--- workspace/rstryker/rse/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/server/MockTests.java 2010-08-06 09:19:37 UTC (rev 23965)
+++ workspace/rstryker/rse/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/server/MockTests.java 2010-08-06 10:29:45 UTC (rev 23966)
@@ -4,13 +4,13 @@
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.debug.core.ILaunch;
import org.eclipse.debug.core.ILaunchConfiguration;
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
import org.eclipse.debug.core.model.IProcess;
import org.eclipse.jdt.launching.IJavaLaunchConfigurationConstants;
import org.eclipse.wst.server.core.IServer;
import org.eclipse.wst.server.core.IServerWorkingCopy;
+import org.jboss.ide.eclipse.as.core.extensions.polling.ProcessTerminatedPoller.IProcessProvider;
import org.jboss.ide.eclipse.as.core.server.internal.JBossServerBehavior;
import org.jboss.ide.eclipse.as.core.server.internal.LocalJBossServerRuntime;
import org.jboss.ide.eclipse.as.core.server.internal.ServerAttributeHelper;
@@ -90,10 +90,10 @@
int loops = 0;
JBossServerBehavior behavior = (JBossServerBehavior)server.loadAdapter(JBossServerBehavior.class, null);
-
+
while(loops < 50) {
- if( behavior.getProcess() != null ) {
- return behavior.getProcess();
+ if( ((IProcessProvider)behavior.getDelegate()).getProcess() != null ) {
+ return ((IProcessProvider)behavior.getDelegate()).getProcess();
}
try {
loops++;
Modified: workspace/rstryker/rse/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/server/StartupShutdownTest.java
===================================================================
--- workspace/rstryker/rse/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/server/StartupShutdownTest.java 2010-08-06 09:19:37 UTC (rev 23965)
+++ workspace/rstryker/rse/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/server/StartupShutdownTest.java 2010-08-06 10:29:45 UTC (rev 23966)
@@ -34,9 +34,10 @@
import org.eclipse.swt.SWTException;
import org.eclipse.swt.widgets.Display;
import org.eclipse.wst.server.core.IServer;
+import org.eclipse.wst.server.core.IServer.IOperationListener;
import org.eclipse.wst.server.core.IServerListener;
import org.eclipse.wst.server.core.ServerEvent;
-import org.eclipse.wst.server.core.IServer.IOperationListener;
+import org.jboss.ide.eclipse.as.core.extensions.polling.ProcessTerminatedPoller.IProcessProvider;
import org.jboss.ide.eclipse.as.core.server.internal.JBossServerBehavior;
import org.jboss.ide.eclipse.as.core.util.IJBossToolingConstants;
import org.jboss.ide.eclipse.as.test.ASTest;
@@ -259,8 +260,8 @@
JBossServerBehavior behavior =
(JBossServerBehavior)currentServer.loadAdapter(JBossServerBehavior.class, null);
if( behavior != null ) {
- if( behavior.getProcess() != null ) {
- return behavior.getProcess().getStreamsProxy().getOutputStreamMonitor();
+ if( ((IProcessProvider)behavior.getDelegate()).getProcess() != null ) {
+ return ((IProcessProvider)behavior.getDelegate()).getProcess().getStreamsProxy().getOutputStreamMonitor();
}
}
return null;
15 years, 4 months
JBoss Tools SVN: r23965 - trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/drop/treeviewer/model.
by jbosstools-commits@lists.jboss.org
Author: scabanovich
Date: 2010-08-06 05:19:37 -0400 (Fri, 06 Aug 2010)
New Revision: 23965
Modified:
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/drop/treeviewer/model/ManagedBeanForMdElement.java
Log:
https://jira.jboss.org/browse/JBIDE-6303
Modified: trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/drop/treeviewer/model/ManagedBeanForMdElement.java
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/drop/treeviewer/model/ManagedBeanForMdElement.java 2010-08-06 09:18:48 UTC (rev 23964)
+++ trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/drop/treeviewer/model/ManagedBeanForMdElement.java 2010-08-06 09:19:37 UTC (rev 23965)
@@ -60,7 +60,7 @@
if(returnTypes.length>0) {
types.put(IWebPromptingProvider.RETURN_TYPE, returnTypes[0]);
} else {
- types.put(IWebPromptingProvider.RETURN_TYPE, "void"); //$NON-NLS-1$
+ types.put(IWebPromptingProvider.RETURN_TYPE, "any"); //$NON-NLS-1$
}
List properties = parentResource.getProvider().getList(parentResource.getXModel(), SUPPORTED_ID, getFullName(), types);
15 years, 4 months
JBoss Tools SVN: r23964 - trunk/jst/plugins/org.jboss.tools.jst.web.kb/taglibs.
by jbosstools-commits@lists.jboss.org
Author: scabanovich
Date: 2010-08-06 05:18:48 -0400 (Fri, 06 Aug 2010)
New Revision: 23964
Modified:
trunk/jst/plugins/org.jboss.tools.jst.web.kb/taglibs/JsfHtmlBasic.xml
Log:
https://jira.jboss.org/browse/JBIDE-6303
last change is reverted, because the other solution stated in issue comments is implemented
Modified: trunk/jst/plugins/org.jboss.tools.jst.web.kb/taglibs/JsfHtmlBasic.xml
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.web.kb/taglibs/JsfHtmlBasic.xml 2010-08-06 08:16:24 UTC (rev 23963)
+++ trunk/jst/plugins/org.jboss.tools.jst.web.kb/taglibs/JsfHtmlBasic.xml 2010-08-06 09:18:48 UTC (rev 23964)
@@ -2,11 +2,7 @@
<!DOCTYPE tag-lib PUBLIC "-//Red Hat, Inc//DTD Knowledge Base 2.0//EN" "http://anonsvn.jboss.org/repos/jbosstools/trunk/jst/plugins/org.jboss.too...">
<tag-lib defaultPrefix="h">
<component closeTag="true" name="commandButton">
- <attribute name="action" required="true">
- <proposal type="beanMethodBySignature">
- <param name="returnType" value="java.lang.String" />
- </proposal>
- </attribute>
+ <attribute name="action" required="true"/>
<attribute name="value" required="true" />
<attribute name="image">
<proposal type="file">
15 years, 4 months
jbosstools-commits@lists.jboss.org 97% OFF on Pfizer!
by jbosstools-commits@lists.jboss.org
http://groups.yahoo.com/group/kwemsemmu/message
ig; denn erstens sind die bisherigen Wirtschaftsrezepte dem
deutschen Volke sehr schlecht bekommen, die Stellungnahmen zu den Fragen der nationalen
Selbstbehauptung erinnern uns sehr stark an die Gutachten ahnlicher Sachverstandiger in fruheren
Zeiten, zum Beispiel des bayerischen Medizinalkollegiums anla.lich der Frage der Einfuhrung der
Eisenbahn. Alle Befurchtungen dieser erlauchten Korporation von damals sind spater bekanntlich nicht
eingetroffen; die Reisenden in den Zugen des neuen "Dampfrosses" wurden nicht schwindlig, die
Zuschauer auch nicht krank, und auf die Bretterzaune, um die
Eisenbahn. Alle Befurchtungen dieser erlauchten Korporation von damals sind spater bekanntlich nicht
eingetroffen; die Reisenden in den Zugen des neuen "Dampfrosses" wurden nicht schwindlig, die
Zuschauer auch nicht krank, und auf die Bretterzaune, um die
neue Einric
15 years, 4 months
JBoss Tools SVN: r23963 - trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/dialog.
by jbosstools-commits@lists.jboss.org
Author: dmaliarevich
Date: 2010-08-06 04:16:24 -0400 (Fri, 06 Aug 2010)
New Revision: 23963
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/dialog/ExternalizeStringsWizardPage.java
Log:
https://jira.jboss.org/browse/JBIDE-6794 , tables items removed.
Modified: trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/dialog/ExternalizeStringsWizardPage.java
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/dialog/ExternalizeStringsWizardPage.java 2010-08-06 08:15:08 UTC (rev 23962)
+++ trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/dialog/ExternalizeStringsWizardPage.java 2010-08-06 08:16:24 UTC (rev 23963)
@@ -431,7 +431,7 @@
/*
* Clear the table
*/
- tagsTable.clearAll();
+ tagsTable.removeAll();
/*
* Fill in new values
*/
15 years, 4 months
JBoss Tools SVN: r23962 - in trunk/vpe/tests/org.jboss.tools.vpe.spring.test: resources/SpringTest/src/main/java/org/jboss/tools/vpe/spring/test/springtest/bean and 6 other directories.
by jbosstools-commits@lists.jboss.org
Author: dvinnichek
Date: 2010-08-06 04:15:08 -0400 (Fri, 06 Aug 2010)
New Revision: 23962
Added:
trunk/vpe/tests/org.jboss.tools.vpe.spring.test/resources/SpringTest/src/main/java/org/jboss/tools/vpe/spring/test/springtest/bean/
trunk/vpe/tests/org.jboss.tools.vpe.spring.test/resources/SpringTest/src/main/java/org/jboss/tools/vpe/spring/test/springtest/bean/DayOfWeekForm.java
trunk/vpe/tests/org.jboss.tools.vpe.spring.test/resources/SpringTest/src/main/java/org/jboss/tools/vpe/spring/test/springtest/controller/DayOfWeekFormController.java
trunk/vpe/tests/org.jboss.tools.vpe.spring.test/resources/SpringTest/src/main/java/org/jboss/tools/vpe/spring/test/springtest/editor/
trunk/vpe/tests/org.jboss.tools.vpe.spring.test/resources/SpringTest/src/main/java/org/jboss/tools/vpe/spring/test/springtest/editor/DayOfWeekPropertyEditor.java
trunk/vpe/tests/org.jboss.tools.vpe.spring.test/resources/SpringTest/src/main/webapp/WEB-INF/jsp/transform.jsp
trunk/vpe/tests/org.jboss.tools.vpe.spring.test/resources/SpringTest/src/main/webapp/WEB-INF/jsp/transform.jsp.xml
Modified:
trunk/vpe/tests/org.jboss.tools.vpe.spring.test/resources/SpringTest/src/main/webapp/WEB-INF/springapp-servlet.xml
trunk/vpe/tests/org.jboss.tools.vpe.spring.test/resources/SpringTest/src/main/webapp/index.jsp
trunk/vpe/tests/org.jboss.tools.vpe.spring.test/src/org/jboss/tools/vpe/spring/test/SpringComponentContentTest.java
Log:
add tests for spring:transform (https://jira.jboss.org/browse/JBIDE-6711)
Added: trunk/vpe/tests/org.jboss.tools.vpe.spring.test/resources/SpringTest/src/main/java/org/jboss/tools/vpe/spring/test/springtest/bean/DayOfWeekForm.java
===================================================================
--- trunk/vpe/tests/org.jboss.tools.vpe.spring.test/resources/SpringTest/src/main/java/org/jboss/tools/vpe/spring/test/springtest/bean/DayOfWeekForm.java (rev 0)
+++ trunk/vpe/tests/org.jboss.tools.vpe.spring.test/resources/SpringTest/src/main/java/org/jboss/tools/vpe/spring/test/springtest/bean/DayOfWeekForm.java 2010-08-06 08:15:08 UTC (rev 23962)
@@ -0,0 +1,14 @@
+package org.jboss.tools.vpe.spring.test.springtest.bean;
+
+public class DayOfWeekForm {
+
+ private String dayOfWeekNumber = "3";
+
+ public String getDayOfWeekNumber() {
+ return dayOfWeekNumber;
+ }
+
+ public void setDayOfWeekNumber(String dayOfWeekNumber) {
+ this.dayOfWeekNumber = dayOfWeekNumber;
+ }
+}
Property changes on: trunk/vpe/tests/org.jboss.tools.vpe.spring.test/resources/SpringTest/src/main/java/org/jboss/tools/vpe/spring/test/springtest/bean/DayOfWeekForm.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Author Id Revision Date
Name: svn:eol-style
+ native
Added: trunk/vpe/tests/org.jboss.tools.vpe.spring.test/resources/SpringTest/src/main/java/org/jboss/tools/vpe/spring/test/springtest/controller/DayOfWeekFormController.java
===================================================================
--- trunk/vpe/tests/org.jboss.tools.vpe.spring.test/resources/SpringTest/src/main/java/org/jboss/tools/vpe/spring/test/springtest/controller/DayOfWeekFormController.java (rev 0)
+++ trunk/vpe/tests/org.jboss.tools.vpe.spring.test/resources/SpringTest/src/main/java/org/jboss/tools/vpe/spring/test/springtest/controller/DayOfWeekFormController.java 2010-08-06 08:15:08 UTC (rev 23962)
@@ -0,0 +1,44 @@
+package org.jboss.tools.vpe.spring.test.springtest.controller;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.servlet.http.HttpServletRequest;
+
+import org.jboss.tools.vpe.spring.test.springtest.bean.DayOfWeekForm;
+import org.jboss.tools.vpe.spring.test.springtest.editor.DayOfWeekPropertyEditor;
+import org.springframework.validation.BindException;
+import org.springframework.web.bind.ServletRequestDataBinder;
+import org.springframework.web.servlet.ModelAndView;
+import org.springframework.web.servlet.mvc.SimpleFormController;
+
+public class DayOfWeekFormController extends SimpleFormController {
+
+ private Map refData;
+
+ public DayOfWeekFormController() {
+
+ setCommandClass(DayOfWeekForm.class);
+
+ refData = new HashMap();
+
+ List list = new ArrayList();
+ for (int i = 0; i < 7; i++) {
+ list.add(String.valueOf(i));
+ }
+
+ refData.put("dayOfWeekNumbers", list);
+ }
+
+ protected Map referenceData(HttpServletRequest request) throws Exception {
+ return refData;
+ }
+
+ protected void initBinder(HttpServletRequest request,
+ ServletRequestDataBinder binder) throws Exception {
+ super.initBinder(request, binder);
+ binder.registerCustomEditor(String.class, new DayOfWeekPropertyEditor());
+ }
+}
Property changes on: trunk/vpe/tests/org.jboss.tools.vpe.spring.test/resources/SpringTest/src/main/java/org/jboss/tools/vpe/spring/test/springtest/controller/DayOfWeekFormController.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Author Id Revision Date
Name: svn:eol-style
+ native
Added: trunk/vpe/tests/org.jboss.tools.vpe.spring.test/resources/SpringTest/src/main/java/org/jboss/tools/vpe/spring/test/springtest/editor/DayOfWeekPropertyEditor.java
===================================================================
--- trunk/vpe/tests/org.jboss.tools.vpe.spring.test/resources/SpringTest/src/main/java/org/jboss/tools/vpe/spring/test/springtest/editor/DayOfWeekPropertyEditor.java (rev 0)
+++ trunk/vpe/tests/org.jboss.tools.vpe.spring.test/resources/SpringTest/src/main/java/org/jboss/tools/vpe/spring/test/springtest/editor/DayOfWeekPropertyEditor.java 2010-08-06 08:15:08 UTC (rev 23962)
@@ -0,0 +1,67 @@
+package org.jboss.tools.vpe.spring.test.springtest.editor;
+
+import java.beans.PropertyEditorSupport;
+
+public class DayOfWeekPropertyEditor extends PropertyEditorSupport {
+
+ public void setAsText(String text) {
+ if("MON".equals(text)) {
+ setValue("1");
+ }
+ else if("TUE".equals(text)) {
+ setValue("2");
+ }
+ else if("WED".equals(text)) {
+ setValue("3");
+ }
+ else if("THU".equals(text)) {
+ setValue("4");
+ }
+ else if("FRI".equals(text)) {
+ setValue("5");
+ }
+ else if("SAT".equals(text)) {
+ setValue("6");
+ }
+ else if("SUN".equals(text)) {
+ setValue("0");
+ }
+ else {
+ setValue("");
+ }
+ }
+
+ public String getAsText() {
+ if(this.getValue() != null
+ && !(this.getValue() instanceof String)) {
+ return "";
+ }
+
+ String text = (String) this.getValue();
+
+ if("1".equals(text)) {
+ return "MON";
+ }
+ else if("2".equals(text)) {
+ return "TUE";
+ }
+ else if("3".equals(text)) {
+ return "WED";
+ }
+ else if("4".equals(text)) {
+ return "THU";
+ }
+ else if("5".equals(text)) {
+ return "FRI";
+ }
+ else if("6".equals(text)) {
+ return "SAT";
+ }
+ else if("0".equals(text)) {
+ return "SUN";
+ }
+ else {
+ return text;
+ }
+ }
+}
Property changes on: trunk/vpe/tests/org.jboss.tools.vpe.spring.test/resources/SpringTest/src/main/java/org/jboss/tools/vpe/spring/test/springtest/editor/DayOfWeekPropertyEditor.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Author Id Revision Date
Name: svn:eol-style
+ native
Added: trunk/vpe/tests/org.jboss.tools.vpe.spring.test/resources/SpringTest/src/main/webapp/WEB-INF/jsp/transform.jsp
===================================================================
--- trunk/vpe/tests/org.jboss.tools.vpe.spring.test/resources/SpringTest/src/main/webapp/WEB-INF/jsp/transform.jsp (rev 0)
+++ trunk/vpe/tests/org.jboss.tools.vpe.spring.test/resources/SpringTest/src/main/webapp/WEB-INF/jsp/transform.jsp 2010-08-06 08:15:08 UTC (rev 23962)
@@ -0,0 +1,36 @@
+<%@page contentType="text/html"%>
+<%@page pageEncoding="UTF-8"%>
+<%@taglib prefix="c"
+ uri="http://java.sun.com/jsp/jstl/core"%>
+<%@taglib prefix="spring"
+ uri="http://www.springframework.org/tags"%>
+
+<html>
+ <body>
+ <h1>Test of spring:transform</h1>
+ <form name="dayOfWeekForm"
+ action="/transform.htm"
+ method="POST">
+ <spring:bind path="command.dayOfWeekNumber">
+ <select id="dayOfWeekSelector" name="${status.expression}">
+ <c:forEach var="dayOfWeekNumber" items="${dayOfWeekNumbers}" >
+ <span id="dayOfWeekTransformer">
+ <spring:transform value="${dayOfWeekNumber}" var="dayOfWeekName"/>
+ </span>
+ <c:choose>
+ <c:when test="${status.value == dayOfWeekName}">
+ <option value="<c:out value="${dayOfWeekName}"/>"
+ selected="selected">
+ </c:when>
+ <c:otherwise>
+ <option value="<c:out value="${dayOfWeekName}"/>">
+ </c:otherwise>
+ </c:choose>
+ <c:out value="${dayOfWeekName}"/>
+ </option>
+ </c:forEach>
+ </select>
+ </spring:bind>
+ </form>
+ </body>
+</html>
\ No newline at end of file
Property changes on: trunk/vpe/tests/org.jboss.tools.vpe.spring.test/resources/SpringTest/src/main/webapp/WEB-INF/jsp/transform.jsp
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:eol-style
+ native
Added: trunk/vpe/tests/org.jboss.tools.vpe.spring.test/resources/SpringTest/src/main/webapp/WEB-INF/jsp/transform.jsp.xml
===================================================================
--- trunk/vpe/tests/org.jboss.tools.vpe.spring.test/resources/SpringTest/src/main/webapp/WEB-INF/jsp/transform.jsp.xml (rev 0)
+++ trunk/vpe/tests/org.jboss.tools.vpe.spring.test/resources/SpringTest/src/main/webapp/WEB-INF/jsp/transform.jsp.xml 2010-08-06 08:15:08 UTC (rev 23962)
@@ -0,0 +1,6 @@
+<tests>
+ <test id="dayOfWeekTransformer">
+ <SPAN ID="dayOfWeekTransformer">
+ </SPAN>
+ </test>
+</tests>
\ No newline at end of file
Property changes on: trunk/vpe/tests/org.jboss.tools.vpe.spring.test/resources/SpringTest/src/main/webapp/WEB-INF/jsp/transform.jsp.xml
___________________________________________________________________
Name: svn:mime-type
+ text/xml
Name: svn:eol-style
+ native
Modified: trunk/vpe/tests/org.jboss.tools.vpe.spring.test/resources/SpringTest/src/main/webapp/WEB-INF/springapp-servlet.xml
===================================================================
--- trunk/vpe/tests/org.jboss.tools.vpe.spring.test/resources/SpringTest/src/main/webapp/WEB-INF/springapp-servlet.xml 2010-08-06 06:36:56 UTC (rev 23961)
+++ trunk/vpe/tests/org.jboss.tools.vpe.spring.test/resources/SpringTest/src/main/webapp/WEB-INF/springapp-servlet.xml 2010-08-06 08:15:08 UTC (rev 23962)
@@ -17,16 +17,21 @@
<bean name="/eval.htm" class="org.jboss.tools.vpe.spring.test.springtest.FormController"/>
<bean name="/errors.htm" class="org.jboss.tools.vpe.spring.test.springtest.controller.ErrorsController">
<property name="validator" ref="userValidator"/>
+ <property name="successView" value="errors"/>
</bean>
<bean name="/bind.htm" class="org.jboss.tools.vpe.spring.test.springtest.controller.ErrorsController">
<property name="validator" ref="userValidator"/>
+ <property name="successView" value="bind"/>
</bean>
<bean name="/hasBindErrors.htm" class="org.jboss.tools.vpe.spring.test.springtest.controller.ErrorsController">
<property name="validator" ref="beanValidator"/>
+ <property name="successView" value="hasBindErrors"/>
</bean>
<bean name="/nestedPath.htm" class="org.jboss.tools.vpe.spring.test.springtest.controller.ErrorsController">
<property name="validator" ref="userValidator"/>
+ <property name="successView" value="nestedPath"/>
</bean>
+ <bean name="/transform.htm" class="org.jboss.tools.vpe.spring.test.springtest.controller.DayOfWeekFormController"/>
<bean name="/select.htm" class="org.jboss.tools.vpe.spring.test.springtest.FormController"/>
<bean name="/escapeBody.htm" class="org.jboss.tools.vpe.spring.test.springtest.FormController"/>
<bean name="/url.htm" class="org.jboss.tools.vpe.spring.test.springtest.FormController"/>
@@ -34,6 +39,7 @@
<bean id="beanValidator" class="org.jboss.tools.vpe.spring.test.springtest.validator.BeanValidator"/>
<bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
+ <property name="viewClass" value="org.springframework.web.servlet.view.JstlView"></property>
<property name="prefix" value="/WEB-INF/jsp/"></property>
<property name="suffix" value=".jsp"></property>
</bean>
Modified: trunk/vpe/tests/org.jboss.tools.vpe.spring.test/resources/SpringTest/src/main/webapp/index.jsp
===================================================================
--- trunk/vpe/tests/org.jboss.tools.vpe.spring.test/resources/SpringTest/src/main/webapp/index.jsp 2010-08-06 06:36:56 UTC (rev 23961)
+++ trunk/vpe/tests/org.jboss.tools.vpe.spring.test/resources/SpringTest/src/main/webapp/index.jsp 2010-08-06 08:15:08 UTC (rev 23962)
@@ -24,4 +24,6 @@
<br/>
<a href="eval.htm">eval.htm</a>
<br/>
+<a href="transform.htm">transform.htm</a>
+<br/>
Modified: trunk/vpe/tests/org.jboss.tools.vpe.spring.test/src/org/jboss/tools/vpe/spring/test/SpringComponentContentTest.java
===================================================================
--- trunk/vpe/tests/org.jboss.tools.vpe.spring.test/src/org/jboss/tools/vpe/spring/test/SpringComponentContentTest.java 2010-08-06 06:36:56 UTC (rev 23961)
+++ trunk/vpe/tests/org.jboss.tools.vpe.spring.test/src/org/jboss/tools/vpe/spring/test/SpringComponentContentTest.java 2010-08-06 08:15:08 UTC (rev 23962)
@@ -117,6 +117,10 @@
performContentTestByFullPath("src/main/webapp/WEB-INF/jsp/url.jsp"); //$NON-NLS-1$
}
+ public void testTransform() throws Throwable {
+ performContentTestByFullPath("src/main/webapp/WEB-INF/jsp/transform.jsp"); //$NON-NLS-1$
+ }
+
@Override
protected String getTestProjectName() {
return SpringAllTests.IMPORT_PROJECT_NAME;
15 years, 4 months
JBoss Tools SVN: r23961 - in trunk: jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/parts and 4 other directories.
by jbosstools-commits@lists.jboss.org
Author: vpakan(a)redhat.com
Date: 2010-08-06 02:36:56 -0400 (Fri, 06 Aug 2010)
New Revision: 23961
Added:
trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/helper/ReflectionsHelper.java
trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/parts/SWTBotTableExt.java
Modified:
trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/helper/KeyboardHelper.java
trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/types/IDELabel.java
trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/types/ViewType.java
trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/META-INF/MANIFEST.MF
trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/src/org/jboss/tools/vpe/ui/bot/test/editor/JspFileEditingTest.java
trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/src/org/jboss/tools/vpe/ui/bot/test/tools/SWTBotWebBrowser.java
Log:
Extend Jsp File Editing SWTBot Test
Modified: trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/helper/KeyboardHelper.java
===================================================================
--- trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/helper/KeyboardHelper.java 2010-08-06 06:34:01 UTC (rev 23960)
+++ trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/helper/KeyboardHelper.java 2010-08-06 06:36:56 UTC (rev 23961)
@@ -2,11 +2,14 @@
import java.awt.AWTException;
import java.awt.Robot;
+import java.awt.event.KeyEvent;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Event;
import org.eclipse.swtbot.swt.finder.utils.SWTBotPreferences;
+import org.eclipse.swtbot.swt.finder.utils.SWTUtils;
+import org.jboss.tools.ui.bot.ext.Timing;
public class KeyboardHelper {
private static Robot robot = null;
@@ -28,6 +31,17 @@
}
/**
+ * Simulate pressing of keys with keyCodes via SWT
+ * @param display
+ * @param keyCodes
+ */
+ public static void pressKeyCodes (Display display , byte[] keyCodes){
+ for (byte keyCode : keyCodes){
+ KeyboardHelper.pressKeyCode(display,keyCode);
+ SWTUtils.sleep(Timing.time1S());
+ }
+ }
+ /**
* Simulate pressing of key with keyCode via AWT
* @param awtKeyCode
*/
@@ -57,4 +71,46 @@
throw new RuntimeException(e);
}
}
+ /**
+ * Simulate typing of key with keyCode via AWT
+ * @param awtKeyCode
+ */
+ public static void typeKeyCodeUsingAWT (int awtKeyCode){
+ KeyboardHelper.pressKeyCodeUsingAWT(awtKeyCode);
+ KeyboardHelper.releaseKeyCodeUsingAWT(awtKeyCode);
+ }
+ /**
+ * Simulate typing of basic string via AWT
+ * @param textkeyCodes - string which can contain only basic characters 0..9, A..Z, a..z
+ */
+ public static void typeBasicStringUsingAWT (String textKeyCodes){
+ for (int index = 0 ; index < textKeyCodes.length() ; index++){
+ char ch = textKeyCodes.charAt(index);
+ int keyCode = getAWTKeyCode (ch);
+ boolean pressShift = (ch >= 'A' && ch <= 'Z');
+ if (pressShift){
+ KeyboardHelper.pressKeyCodeUsingAWT(KeyEvent.VK_SHIFT);
+ }
+ KeyboardHelper.typeKeyCodeUsingAWT(keyCode);
+ if (pressShift){
+ KeyboardHelper.releaseKeyCodeUsingAWT(KeyEvent.VK_SHIFT);
+ }
+ KeyboardHelper.robot.delay(Timing.time1S());
+ }
+ }
+
+ public static int getAWTKeyCode (char ch){
+ int result = KeyEvent.VK_UNDEFINED;
+ try {
+ result = ReflectionsHelper.getPrivateFieldValue(KeyEvent.class,
+ "VK_" + String.valueOf(ch).toUpperCase(),
+ null,
+ Integer.class);
+ } catch (SecurityException e) {
+ } catch (IllegalArgumentException e) {
+ } catch (NoSuchFieldException e) {
+ } catch (IllegalAccessException e) {
+ }
+ return result;
+ }
}
Added: trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/helper/ReflectionsHelper.java
===================================================================
--- trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/helper/ReflectionsHelper.java (rev 0)
+++ trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/helper/ReflectionsHelper.java 2010-08-06 06:36:56 UTC (rev 23961)
@@ -0,0 +1,39 @@
+ /*******************************************************************************
+ * Copyright (c) 2007-2009 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
+ *
+ * Contributor:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+
+package org.jboss.tools.ui.bot.ext.helper;
+
+import java.lang.reflect.Field;
+
+import org.apache.log4j.Logger;
+/**
+ * Helper to use Reflections functionality
+ * @author Vladimir Pakan
+ *
+ */
+public class ReflectionsHelper {
+ protected static final Logger log = Logger.getLogger(ReflectionsHelper.class);
+
+ @SuppressWarnings("unchecked")
+ public static <T> T getPrivateFieldValue (Class<?> clazz , String fieldName ,
+ Object instance, Class<T> resultClazz) throws SecurityException, NoSuchFieldException, IllegalArgumentException, IllegalAccessException{
+ Field field = clazz.getDeclaredField(fieldName);
+ field.setAccessible(true);
+ Object value = field.get(instance);
+ if (value != null){
+ return (T)value;
+ }
+ else{
+ return null;
+ }
+ }
+
+}
Property changes on: trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/helper/ReflectionsHelper.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/parts/SWTBotTableExt.java
===================================================================
--- trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/parts/SWTBotTableExt.java (rev 0)
+++ trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/parts/SWTBotTableExt.java 2010-08-06 06:36:56 UTC (rev 23961)
@@ -0,0 +1,57 @@
+/*******************************************************************************
+
+ * Copyright (c) 2007-2010 Exadel, Inc. and 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:
+ * Exadel, Inc. and Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.ui.bot.ext.parts;
+
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.swtbot.swt.finder.SWTBot;
+import org.eclipse.swtbot.swt.finder.exceptions.WidgetNotFoundException;
+import org.eclipse.swtbot.swt.finder.widgets.AbstractSWTBotControl;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotTable;
+import org.jboss.tools.ui.bot.ext.Timing;
+
+/**
+ * Extends Table Component
+ * @author vlado pakan
+ *
+ */
+public class SWTBotTableExt extends AbstractSWTBotControl<Table> {
+
+ private SWTBotTable swtBotTable = null;
+
+ private SWTBotTableExt(Table table) throws WidgetNotFoundException {
+ super(table);
+ }
+
+ public SWTBotTableExt(SWTBotTable swtBotTable) throws WidgetNotFoundException {
+ this(swtBotTable.widget);
+ this.swtBotTable = swtBotTable;
+ }
+ /**
+ * Sets value of table cell editable via Text Cell Editor on position specified by row and column
+ * @param newValue - new value of the cell
+ * @param row - zero based row index
+ * @param column - zero based column index
+ * @param oldValue - old value of the cell
+ * @param bot - bot containing table
+ */
+ public void setTableCellWithTextEditorText(String newValue,
+ int row , int column,
+ String oldValue,
+ SWTBot bot){
+
+ swtBotTable.click(row, column);
+ bot.sleep(Timing.time1S());
+ bot.text(oldValue, 0).setText(newValue);
+
+ }
+
+}
Property changes on: trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/parts/SWTBotTableExt.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/types/IDELabel.java
===================================================================
--- trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/types/IDELabel.java 2010-08-06 06:34:01 UTC (rev 23960)
+++ trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/types/IDELabel.java 2010-08-06 06:36:56 UTC (rev 23961)
@@ -98,6 +98,7 @@
public static final String EDIT = "Edit...";
public static final String ADD_WITHOUT_DOTS = "Add";
public static final String DROOLS_WORKBENCH = "Drools workbench";
+ public static final String REFRESH = "Refresh";
}
public class Shell {
@@ -137,6 +138,7 @@
public static final String SHOW_VIEW = "Show View";
public static final String PROPERTIES_FOR = "Properties for";
public static final String COPY_FILE_FROM_GUVNOR_TO_PACKAGE_EXPLORER = "File Operation";
+ public static final String INSERT_TAG = "Insert Tag";
}
public class EntityGroup {
@@ -196,6 +198,7 @@
public static final String GUVNOR_REPOSITORIES = "Guvnor Repositories";
public static final String GUVNOR_RESOURCE_HISTORY = "Guvnor Resource History";
public static final String PROPERTIES = "Properties";
+ public static final String JBOSS_TOOLS_PALETTE = "JBoss Tools Palette";
}
public class ViewGroup {
Modified: trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/types/ViewType.java
===================================================================
--- trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/types/ViewType.java 2010-08-06 06:34:01 UTC (rev 23960)
+++ trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/types/ViewType.java 2010-08-06 06:36:56 UTC (rev 23961)
@@ -20,7 +20,7 @@
public enum ViewType {
PACKAGE_EXPLORER, PROJECT_EXPLORER, WELCOME, DATA_SOURCE_EXPLORER,
SERVERS,WEB_PROJECTS,PROBLEMS,DEBUG,GUVNOR_REPOSITORIES,PROPERTIES,
- GUVNOR_RESOURCE_HISTORY;
+ GUVNOR_RESOURCE_HISTORY,JBOSS_TOOLS_PALETTE;
public String getGroupLabel() {
@@ -36,6 +36,7 @@
case GUVNOR_REPOSITORIES: viewLabel = IDELabel.ViewGroup.GUVNOR; break;
case PROPERTIES: viewLabel = IDELabel.ViewGroup.GENERAL; break;
case GUVNOR_RESOURCE_HISTORY: viewLabel = IDELabel.ViewGroup.GUVNOR; break;
+ case JBOSS_TOOLS_PALETTE: viewLabel = IDELabel.ViewGroup.JBOSS_TOOLS_WEB; break;
default: fail("Unknown View Type");
}
return viewLabel;
@@ -54,6 +55,7 @@
case GUVNOR_REPOSITORIES: viewLabel = IDELabel.View.GUVNOR_REPOSITORIES; break;
case PROPERTIES: viewLabel = IDELabel.View.PROPERTIES; break;
case GUVNOR_RESOURCE_HISTORY: viewLabel = IDELabel.View.GUVNOR_RESOURCE_HISTORY; break;
+ case JBOSS_TOOLS_PALETTE: viewLabel = IDELabel.View.JBOSS_TOOLS_PALETTE; break;
default: fail("Unknown View Type");
}
return viewLabel;
Modified: trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/META-INF/MANIFEST.MF
===================================================================
--- trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/META-INF/MANIFEST.MF 2010-08-06 06:34:01 UTC (rev 23960)
+++ trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/META-INF/MANIFEST.MF 2010-08-06 06:36:56 UTC (rev 23961)
@@ -28,7 +28,10 @@
org.jboss.tools.vpe.html,
org.jboss.tools.vpe.jsp,
org.jboss.tools.vpe.resref,
- org.jboss.tools.vpe.ui.palette
+ org.jboss.tools.vpe.ui.palette,
+ org.eclipse.swtbot.eclipse.gef.finder;bundle-version="2.0.0",
+ org.eclipse.gef;bundle-version="3.6.0",
+ org.jboss.tools.common.model.ui;bundle-version="3.2.0"
Eclipse-RegisterBuddy: org.apache.log4j
Bundle-ActivationPolicy: lazy
Bundle-RequiredExecutionEnvironment: J2SE-1.5
Modified: trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/src/org/jboss/tools/vpe/ui/bot/test/editor/JspFileEditingTest.java
===================================================================
--- trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/src/org/jboss/tools/vpe/ui/bot/test/editor/JspFileEditingTest.java 2010-08-06 06:34:01 UTC (rev 23960)
+++ trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/src/org/jboss/tools/vpe/ui/bot/test/editor/JspFileEditingTest.java 2010-08-06 06:36:56 UTC (rev 23961)
@@ -11,61 +11,112 @@
******************************************************************************/
package org.jboss.tools.vpe.ui.bot.test.editor;
-
-import java.io.File;
-import java.io.IOException;
import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotEclipseEditor;
+import org.eclipse.swtbot.swt.finder.SWTBot;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotTable;
+import org.jboss.tools.ui.bot.ext.SWTBotExt;
import org.jboss.tools.ui.bot.ext.Timing;
-import org.jboss.tools.ui.bot.ext.helper.FileHelper;
+import org.jboss.tools.ui.bot.ext.helper.KeyboardHelper;
+import org.jboss.tools.ui.bot.ext.parts.SWTBotTableExt;
import org.jboss.tools.ui.bot.ext.types.IDELabel;
import org.jboss.tools.vpe.ui.bot.test.tools.SWTBotWebBrowser;
import org.mozilla.interfaces.nsIDOMNode;
/**
- * Tests large XHTML file editing
+ * Tests JSP file editing and synchronization between Source Editor and Visual Editor
* @author vlado pakan
*
*/
public class JspFileEditingTest extends VPEEditorTestCase {
+ private SWTBotExt botExt = null;
+
public JspFileEditingTest() {
super();
+ botExt = new SWTBotExt();
}
public void testJspFileEditing(){
- try{
- String resourceWebContentLocation = getPathToResources("WebContent");
- FileHelper.copyFilesBinaryRecursively(new File(resourceWebContentLocation),
- new File(FileHelper.getProjectLocation(JBT_TEST_PROJECT_NAME, bot),"WebContent"),
- null);
- }catch (IOException ioe){
- throw new RuntimeException("Unable to copy necessary files from plugin's resources directory",ioe);
- }
- bot.menu(IDELabel.Menu.FILE).menu(IDELabel.Menu.REFRESH).click();
- bot.sleep(Timing.time1S());
eclipse.maximizeActiveShell();
- openPage();
- openPalette();
- SWTBotWebBrowser swtBotWebBrowser = new SWTBotWebBrowser(TEST_PAGE,bot);
+
+ insertTagUsingContextMenu();
+ insertTagUsingPalette();
- nsIDOMNode node = swtBotWebBrowser.getDomNodeByTagName("INPUT",1);
-
- swtBotWebBrowser.selectDomNode(node,0);
- bot.sleep(Timing.time1S());
- swtBotWebBrowser.clickContextMenu(node, SWTBotWebBrowser.INSERT_AFTER_MENU_LABEL,
- SWTBotWebBrowser.JSF_MENU_LABEL,
- SWTBotWebBrowser.HTML_MENU_LABEL,
- SWTBotWebBrowser.H_OUTPUT_TEXT_TAG_MENU_LABEL);
-
- final SWTBotEclipseEditor jspTextEditor = bot.editorByTitle(TEST_PAGE).toTextEditor();
+ }
+ /**
+ * Inserts tag to html page using Context Menu of Visual Editor
+ */
+ private void insertTagUsingContextMenu() {
+
+ openPage();
+ SWTBotWebBrowser swtBotWebBrowser = new SWTBotWebBrowser(TEST_PAGE, botExt);
+ nsIDOMNode node = swtBotWebBrowser.getDomNodeByTagName("INPUT", 1);
+ swtBotWebBrowser.selectDomNode(node, 0);
+ botExt.sleep(Timing.time1S());
+
+ swtBotWebBrowser.clickContextMenu(node,
+ SWTBotWebBrowser.INSERT_AFTER_MENU_LABEL,
+ SWTBotWebBrowser.JSF_MENU_LABEL, SWTBotWebBrowser.HTML_MENU_LABEL,
+ SWTBotWebBrowser.H_OUTPUT_TEXT_TAG_MENU_LABEL);
+
+ final SWTBotEclipseEditor jspTextEditor = botExt.editorByTitle(TEST_PAGE)
+ .toTextEditor();
jspTextEditor.save();
// Check if tag h:outputText was properly added
String editorText = jspTextEditor.getText();
- assertTrue("File " + TEST_PAGE + " has to contain string '<h:outputText/>' but it doesn't",
- editorText.contains("<h:outputText/>"));
- }
+ assertTrue("File " + TEST_PAGE
+ + " has to contain string '<h:outputText/>' but it doesn't",
+ editorText.contains("<h:outputText/>"));
+ }
+ /**
+ * Inserts tag to html page using JBoss Tools Palette
+ */
+ private void insertTagUsingPalette(){
+
+ openPage();
+ openPalette();
+
+ SWTBotWebBrowser swtBotWebBrowser = new SWTBotWebBrowser(TEST_PAGE, botExt);
+ nsIDOMNode node = swtBotWebBrowser.getDomNodeByTagName("INPUT", 1);
+ swtBotWebBrowser.selectDomNode(node, 0);
+ botExt.sleep(Timing.time1S());
+
+ swtBotWebBrowser.activatePaletteTool("outputText");
+ SWTBot dialogBot = botExt.shell(IDELabel.Shell.INSERT_TAG).activate().bot();
+ SWTBotTable swtBotTable = dialogBot.table();
+ String outputTextValue = "123 !! Test value !! 321";
+ new SWTBotTableExt(swtBotTable).setTableCellWithTextEditorText(
+ outputTextValue, swtBotTable.indexOf("value"), 1, "", dialogBot);
+ dialogBot.button(IDELabel.Button.FINISH).click();
+ final SWTBotEclipseEditor jspTextEditor = botExt.editorByTitle(TEST_PAGE)
+ .toTextEditor();
+ jspTextEditor.save();
+ botExt.toolbarButtonWithTooltip(IDELabel.Button.REFRESH).click();
+ botExt.sleep(Timing.time1S());
+ String editorText = jspTextEditor.getText();
+ String testText = "<h:outputText value=\"" + outputTextValue + "\"/>";
+ assertTrue("File " + TEST_PAGE + " has to contain string '" + testText
+ + "' but it doesn't", editorText.contains(testText));
+ // Insert text via Visual Editor to inserted h:outputText tag
+ node = swtBotWebBrowser.getDomNodeByTagName(
+ swtBotWebBrowser.getNsIDOMDocument(), "#text", 6);
+ botExt.sleep(Timing.time2S());
+ swtBotWebBrowser.selectDomNode(node, 5);
+ String insertString = "ab9876CD";
+ KeyboardHelper.typeBasicStringUsingAWT(insertString);
+ botExt.sleep(Timing.time2S());
+ jspTextEditor.save();
+ editorText = jspTextEditor.getText();
+ outputTextValue = outputTextValue.substring(0, 5) + insertString
+ + outputTextValue.substring(5);
+ testText = "<h:outputText value=\"" + outputTextValue + "\"/>";
+ assertTrue("File " + TEST_PAGE + " has to contain string '" + testText
+ + "' but it doesn't", editorText.contains(testText));
+ jspTextEditor.close();
+ }
+
@Override
protected void closeUnuseDialogs() {
Modified: trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/src/org/jboss/tools/vpe/ui/bot/test/tools/SWTBotWebBrowser.java
===================================================================
--- trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/src/org/jboss/tools/vpe/ui/bot/test/tools/SWTBotWebBrowser.java 2010-08-06 06:34:01 UTC (rev 23960)
+++ trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/src/org/jboss/tools/vpe/ui/bot/test/tools/SWTBotWebBrowser.java 2010-08-06 06:36:56 UTC (rev 23961)
@@ -13,28 +13,44 @@
import static org.junit.Assert.assertNotNull;
-import java.lang.reflect.Field;
import java.util.Arrays;
+import java.util.LinkedList;
+import java.util.List;
+import org.eclipse.gef.EditDomain;
+import org.eclipse.gef.palette.PaletteEntry;
+import org.eclipse.gef.palette.ToolEntry;
+import org.eclipse.gef.ui.palette.PaletteViewer;
import org.eclipse.swt.browser.Browser;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Decorations;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Menu;
import org.eclipse.swt.widgets.MenuItem;
-import org.eclipse.swtbot.swt.finder.SWTBot;
+import org.eclipse.swtbot.eclipse.gef.finder.finders.PaletteFinder;
+import org.eclipse.swtbot.eclipse.gef.finder.matchers.ToolEntryLabelMatcher;
import org.eclipse.swtbot.swt.finder.exceptions.WidgetNotFoundException;
import org.eclipse.swtbot.swt.finder.finders.UIThreadRunnable;
+import org.eclipse.swtbot.swt.finder.results.Result;
import org.eclipse.swtbot.swt.finder.results.WidgetResult;
import org.eclipse.ui.IEditorReference;
+import org.eclipse.ui.IViewReference;
+import org.eclipse.ui.PlatformUI;
+import org.jboss.tools.common.model.ui.views.palette.PaletteCreator;
+import org.jboss.tools.common.model.ui.views.palette.PaletteViewPart;
import org.jboss.tools.jst.jsp.editor.IVisualEditor;
import org.jboss.tools.jst.jsp.jspeditor.JSPMultiPageEditor;
+import org.jboss.tools.ui.bot.ext.SWTBotExt;
+import org.jboss.tools.ui.bot.ext.SWTEclipseExt;
import org.jboss.tools.ui.bot.ext.Timing;
import org.jboss.tools.ui.bot.ext.helper.ContextMenuHelper;
+import org.jboss.tools.ui.bot.ext.helper.ReflectionsHelper;
import org.jboss.tools.ui.bot.ext.parts.ObjectMultiPageEditorBot;
+import org.jboss.tools.ui.bot.ext.types.ViewType;
import org.jboss.tools.vpe.editor.VpeEditorPart;
import org.jboss.tools.vpe.editor.mozilla.MozillaEditor;
import org.jboss.tools.vpe.editor.mozilla.MozillaEventAdapter;
+import org.jboss.tools.vpe.ui.palette.PaletteAdapter;
import org.jboss.tools.vpe.xulrunner.util.XPCOM;
import org.mozilla.interfaces.nsIDOMDocument;
import org.mozilla.interfaces.nsIDOMEvent;
@@ -69,9 +85,9 @@
private Display display;
private IVisualEditor visualEditor;
private MozillaEditor mozillaEditor;
- private SWTBot bot;
+ private SWTBotExt bot;
- public SWTBotWebBrowser (String title, SWTBot bot){
+ public SWTBotWebBrowser (String title, SWTBotExt bot){
ObjectMultiPageEditorBot objectMultiPageEditorBot = new ObjectMultiPageEditorBot(title);
IEditorReference ref = objectMultiPageEditorBot.getEditorReference();
JSPMultiPageEditor multiPageEditor = null;
@@ -81,7 +97,7 @@
assertNotNull(multiPageEditor);
this.bot = bot;
this.visualEditor = multiPageEditor.getVisualEditor();
- this.mozillaEditor = ((VpeEditorPart)multiPageEditor.getVisualEditor()).getVisualEditor();
+ this.mozillaEditor = ((VpeEditorPart)visualEditor).getVisualEditor();
this.display = getBrowser().getDisplay();
}
@@ -90,7 +106,6 @@
* @param node
* @param depth
*/
- @SuppressWarnings("unused")
private static void displayNsIDOMNode(nsIDOMNode node , int depth) {
System.out.println("");
System.out.print(fillString(' ', depth) + "<" + node.getNodeName() + " ");
@@ -330,11 +345,11 @@
parent = parent.getParent();
}
try {
- Field menusField = Decorations.class.getDeclaredField("menus");
- menusField.setAccessible(true);
- Object menusObject = menusField.get(parent);
- if (menusObject != null){
- Menu[] menus = (Menu[])menusObject;
+ Menu[] menus = ReflectionsHelper.getPrivateFieldValue(Decorations.class,
+ "menus",
+ parent,
+ Menu[].class);
+ if (menus != null){
MenuItem topMenuItem = null;
int index = menus.length - 1;
while (topMenuItem == null && index >= 0){
@@ -372,5 +387,102 @@
ContextMenuHelper.clickContextMenu(topMenu, menuLabels);
}
+ /**
+ * Returns node corresponding to specified tagName
+ * @param parentNode
+ * @param tagName
+ * @param order - index of tagName tag in DOM model from all tagName nodes contained in model
+ * @return
+ */
+ public nsIDOMNode getDomNodeByTagName(nsIDOMNode parentNode , String tagName, Integer order){
+ List<nsIDOMNode> nodes = getDomNodesByTagName(parentNode,tagName);
+ nsIDOMNode result = null;
+ if (nodes != null && nodes.size() > order){
+ result = nodes.get(order);
+ }
+ return result;
+ }
+ /**
+ * Recursively search for node with specified tagName
+ * @param parentNode
+ * @param tagName
+ * @return
+ */
+ public List<nsIDOMNode> getDomNodesByTagName(nsIDOMNode parentNode , String tagName){
+ LinkedList<nsIDOMNode> result = new LinkedList<nsIDOMNode>();
+ if (parentNode.getNodeName().equals(tagName)){
+ result.add(parentNode);
+ }
+ nsIDOMNodeList children = parentNode.getChildNodes();
+ for (int i = 0; i < children.getLength(); i++) {
+ nsIDOMNode child = children.item(i);
+ // leave out empty text nodes in test dom model
+ if ((child.getNodeType() == Node.TEXT_NODE)
+ && ((child.getNodeValue() == null) || (child.getNodeValue().trim()
+ .length() == 0)))
+ continue;
+ result.addAll(getDomNodesByTagName(child, tagName));
+
+ }
+ return result;
+
+ }
+ /**
+ * Activate JBoss Tools Palette Tool with specified Label
+ * @param toolLabel
+ */
+ public void activatePaletteTool (String toolLabel){
+
+ SWTEclipseExt.showView(bot, ViewType.JBOSS_TOOLS_PALETTE);
+
+ IViewReference ref = UIThreadRunnable.syncExec(new Result<IViewReference>() {
+ public IViewReference run() {
+ IViewReference ref = null;
+ IViewReference[] viewReferences = null;
+ viewReferences = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getViewReferences();
+ for (IViewReference reference : viewReferences) {
+ if (reference.getTitle().equals("JBoss Tools Palette")){
+ return reference;
+ }
+ }
+ return ref;
+ }
+ });
+ // Find Palette Viewer dirty way
+ PaletteViewPart pvp = (PaletteViewPart)ref.getPart(true);
+ try {
+ PaletteCreator pc = ReflectionsHelper.getPrivateFieldValue(PaletteViewPart.class,
+ "paletteCreator",
+ pvp,
+ PaletteCreator.class);
+ PaletteAdapter pa = ReflectionsHelper.getPrivateFieldValue(PaletteCreator.class,
+ "paletteAdapter",
+ pc,
+ PaletteAdapter.class);
+ PaletteViewer paletteViewer = ReflectionsHelper.getPrivateFieldValue(PaletteAdapter.class,
+ "viewer",
+ pa,
+ PaletteViewer.class);
+
+ EditDomain ed = new EditDomain();
+ ed.setPaletteViewer(paletteViewer);
+ ed.setPaletteRoot(paletteViewer.getPaletteRoot());
+ PaletteFinder pf = new PaletteFinder(ed);
+ ToolEntryLabelMatcher telm = new ToolEntryLabelMatcher(toolLabel);
+ PaletteEntry peJsfHtml = pf.findEntries(telm).get(0);
+ // Activate outputText Tool from Palette
+ paletteViewer.setActiveTool((ToolEntry)peJsfHtml);
+ } catch (SecurityException e) {
+ throw new RuntimeException(e);
+ } catch (IllegalArgumentException e) {
+ throw new RuntimeException(e);
+ } catch (NoSuchFieldException e) {
+ throw new RuntimeException(e);
+ } catch (IllegalAccessException e) {
+ throw new RuntimeException(e);
+ }
+
+ }
+
}
15 years, 4 months
JBoss Tools SVN: r23960 - trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/src/org/jboss/tools/vpe/ui/bot/test/wizard.
by jbosstools-commits@lists.jboss.org
Author: vpakan(a)redhat.com
Date: 2010-08-06 02:34:01 -0400 (Fri, 06 Aug 2010)
New Revision: 23960
Modified:
trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/src/org/jboss/tools/vpe/ui/bot/test/wizard/NewXHTMLPageWizardTest.java
Log:
Remove unused import.
Modified: trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/src/org/jboss/tools/vpe/ui/bot/test/wizard/NewXHTMLPageWizardTest.java
===================================================================
--- trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/src/org/jboss/tools/vpe/ui/bot/test/wizard/NewXHTMLPageWizardTest.java 2010-08-06 03:23:27 UTC (rev 23959)
+++ trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/src/org/jboss/tools/vpe/ui/bot/test/wizard/NewXHTMLPageWizardTest.java 2010-08-06 06:34:01 UTC (rev 23960)
@@ -10,10 +10,8 @@
******************************************************************************/
package org.jboss.tools.vpe.ui.bot.test.wizard;
-import org.eclipse.swtbot.swt.finder.widgets.SWTBotTree;
import org.jboss.tools.ui.bot.ext.gen.ActionItem;
import org.jboss.tools.ui.bot.ext.types.IDELabel;
-import org.jboss.tools.ui.bot.test.WidgetVariables;
import org.jboss.tools.vpe.ui.bot.test.VPEAutoTestCase;
/**
15 years, 4 months
JBoss Tools SVN: r23959 - workspace/rstryker/rse/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal.
by jbosstools-commits@lists.jboss.org
Author: rob.stryker(a)jboss.com
Date: 2010-08-05 23:23:27 -0400 (Thu, 05 Aug 2010)
New Revision: 23959
Modified:
workspace/rstryker/rse/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/JBossServer.java
Log:
Cleanup of ugly legacy code which was meant to respond to changes in the launch config. However for the past year, the launch config has instead updated itself based on the server attributes so the launch config no longer needs to be updated manually
Modified: workspace/rstryker/rse/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/JBossServer.java
===================================================================
--- workspace/rstryker/rse/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/JBossServer.java 2010-08-06 02:52:49 UTC (rev 23958)
+++ workspace/rstryker/rse/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/JBossServer.java 2010-08-06 03:23:27 UTC (rev 23959)
@@ -10,37 +10,23 @@
******************************************************************************/
package org.jboss.ide.eclipse.as.core.server.internal;
-import java.io.File;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.Date;
-import java.util.Map;
-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;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.debug.core.ILaunchConfiguration;
-import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
-import org.eclipse.jdt.launching.IJavaLaunchConfigurationConstants;
import org.eclipse.jst.server.core.IWebModule;
-import org.eclipse.osgi.util.NLS;
import org.eclipse.wst.server.core.IModule;
import org.eclipse.wst.server.core.IServer;
-import org.eclipse.wst.server.core.internal.Server;
import org.eclipse.wst.server.core.model.IURLProvider;
import org.jboss.ide.eclipse.as.core.JBossServerCorePlugin;
-import org.jboss.ide.eclipse.as.core.Messages;
import org.jboss.ide.eclipse.as.core.extensions.descriptors.XPathModel;
import org.jboss.ide.eclipse.as.core.extensions.descriptors.XPathQuery;
import org.jboss.ide.eclipse.as.core.server.IDeployableServer;
import org.jboss.ide.eclipse.as.core.server.IJBossServerConstants;
import org.jboss.ide.eclipse.as.core.server.IJBossServerRuntime;
-import org.jboss.ide.eclipse.as.core.util.ArgsUtil;
-import org.jboss.ide.eclipse.as.core.util.IJBossRuntimeConstants;
import org.jboss.ide.eclipse.as.core.util.ServerUtil;
/**
@@ -59,85 +45,16 @@
setAttribute("auto-publish-time", 1); //$NON-NLS-1$
setAttribute("id", getAttribute("id", (String)"") + new Date().getTime()); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
}
-
- public void saveConfiguration(IProgressMonitor monitor) throws CoreException {
- // here we update the launch configuration with any details that might have changed.
- try {
- Server s = (Server)getServer();
- ILaunchConfiguration lc = s.getLaunchConfiguration(false, new NullProgressMonitor());
- if( lc != null ) {
- String startArgs = lc.getAttribute(IJavaLaunchConfigurationConstants.ATTR_PROGRAM_ARGUMENTS, (String)null);
- String originalArgs = startArgs;
- if( !getServer().getHost().equals(getHost(true)))
- startArgs = ArgsUtil.setArg(startArgs,
- IJBossRuntimeConstants.STARTUP_ARG_HOST_SHORT,
- IJBossRuntimeConstants.STARTUP_ARG_HOST_LONG,
- getServer().getHost());
-
- IJBossServerRuntime runtime = (IJBossServerRuntime)
- getServer().getRuntime().loadAdapter(IJBossServerRuntime.class, null);
- String config = runtime.getJBossConfiguration();
- startArgs = ArgsUtil.setArg(startArgs,
- IJBossRuntimeConstants.STARTUP_ARG_CONFIG_SHORT,
- IJBossRuntimeConstants.STARTUP_ARG_CONFIG_LONG, config);
-
- if( startArgs != null && !startArgs.trim().equals(originalArgs)) {
- ILaunchConfigurationWorkingCopy wc = lc.getWorkingCopy();
- wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_PROGRAM_ARGUMENTS, startArgs);
- wc.doSave();
- }
- }
- } catch( CoreException ce ) {
- IStatus s = new Status(IStatus.ERROR, JBossServerCorePlugin.PLUGIN_ID,
- NLS.bind(Messages.CannotSaveServersStartArgs, getServer().getName()), ce);
- JBossServerCorePlugin.getDefault().getLog().log(s);
- }
- }
public String getHost() {
- String host = getHost(true);
- return host == null ? getServer().getHost() : host;
+ return getServer().getHost();
}
-
- public String getHost(boolean checkLaunchConfig) {
- String host = null;
- if( checkLaunchConfig ) {
- try {
- Server s = (Server)getServer();
- ILaunchConfiguration lc = s.getLaunchConfiguration(true, new NullProgressMonitor());
- if(lc!=null) {
- String startArgs = lc.getAttribute(IJavaLaunchConfigurationConstants.ATTR_PROGRAM_ARGUMENTS, (String)null);
- String val = ArgsUtil.getValue(startArgs,
- IJBossRuntimeConstants.STARTUP_ARG_HOST_SHORT,
- IJBossRuntimeConstants.STARTUP_ARG_HOST_LONG);
- if( val != null ) {
- host = val;
- }
- }
- } catch( CoreException ce ) {}
- }
- return host;
- }
-
+
public String getConfigDirectory() {
- return getConfigDirectory(true);
+ IJBossServerRuntime runtime = (IJBossServerRuntime)getServer().getRuntime().loadAdapter(IJBossServerRuntime.class, null);
+ return runtime.getConfigLocationFullPath().toOSString();
}
- public String getConfigDirectory(boolean checkLaunchConfig) {
- if( !checkLaunchConfig )
- return getRuntimeConfigDirectory();
-
- String configDir = getLaunchConfigConfigurationDirectory();
- if( configDir == null )
- return getRuntimeConfigDirectory();
-
- File f = new File(configDir);
- if( !f.exists() || !f.canRead() || !f.isDirectory())
- return getRuntimeConfigDirectory();
-
- return new Path(configDir).toOSString();
- }
-
public String getDeployFolder() {
return getDeployFolder(this, getDeployLocationType());
}
@@ -167,11 +84,6 @@
return null;
}
- protected String getDeployFolder(boolean checkLaunchConfig) {
- return new Path(getConfigDirectory(checkLaunchConfig) + Path.SEPARATOR + DEPLOY).toOSString();
- }
-
-
public String getTempDeployFolder() {
IJBossServerRuntime jbsrt = getRuntime();
String type = getDeployLocationType();
@@ -190,41 +102,7 @@
}
return null;
}
-
- protected String getLaunchConfigConfigurationDirectory() {
- try {
- Server s = (Server)getServer();
- ILaunchConfiguration lc = s.getLaunchConfiguration(true, new NullProgressMonitor());
- String startArgs = lc.getAttribute(IJavaLaunchConfigurationConstants.ATTR_PROGRAM_ARGUMENTS, (String)null);
- Map map = ArgsUtil.getSystemProperties(startArgs);
-
- if( map.get(JBOSS_SERVER_HOME_DIR) != null )
- return (String)map.get(JBOSS_SERVER_HOME_DIR);
-
- if( map.get(JBOSS_SERVER_BASE_DIR) != null ) {
- String name = map.get(JBOSS_SERVER_NAME) != null ?
- (String)map.get(JBOSS_SERVER_NAME) : DEFAULT_CONFIGURATION;
- return (String)map.get(JBOSS_SERVER_BASE_DIR) + Path.SEPARATOR + name;
- }
-
- if( map.get(JBOSS_HOME_DIR) != null ) {
- return (String)map.get(JBOSS_HOME_DIR) + Path.SEPARATOR + SERVER
- + Path.SEPARATOR + DEFAULT_CONFIGURATION;
- }
- } catch( CoreException ce ) {
- }
- return null;
- }
-
- protected String getRuntimeConfigDirectory() {
- IJBossServerRuntime runtime = (IJBossServerRuntime)
- getServer().getRuntime().loadAdapter(IJBossServerRuntime.class, null);
- String p = getServer().getRuntime().getLocation().toOSString() + Path.SEPARATOR + SERVER +
- Path.SEPARATOR + runtime.getJBossConfiguration();
- return new Path(p).toOSString();
- }
-
public int getJNDIPort() {
return findPort(JNDI_PORT, JNDI_PORT_DETECT, JNDI_PORT_DETECT_XPATH,
JNDI_PORT_DEFAULT_XPATH, JNDI_DEFAULT_PORT);
@@ -258,8 +136,6 @@
return defaultValue;
}
-
-
public URL getModuleRootURL(IModule module) {
if (module == null || module.loadAdapter(IWebModule.class,null)==null )
15 years, 4 months
JBoss Tools SVN: r23958 - workspace/rstryker/rse/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/tools/as/rse/ui.
by jbosstools-commits@lists.jboss.org
Author: rob.stryker(a)jboss.com
Date: 2010-08-05 22:52:49 -0400 (Thu, 05 Aug 2010)
New Revision: 23958
Modified:
workspace/rstryker/rse/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/tools/as/rse/ui/RSEDeploymentPreferenceUI.java
Log:
JBIDE-6792 - undo to reset combo
Modified: workspace/rstryker/rse/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/tools/as/rse/ui/RSEDeploymentPreferenceUI.java
===================================================================
--- workspace/rstryker/rse/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/tools/as/rse/ui/RSEDeploymentPreferenceUI.java 2010-08-06 02:26:56 UTC (rev 23957)
+++ workspace/rstryker/rse/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/tools/as/rse/ui/RSEDeploymentPreferenceUI.java 2010-08-06 02:52:49 UTC (rev 23958)
@@ -10,6 +10,9 @@
******************************************************************************/
package org.jboss.tools.as.rse.ui;
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+
import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.rse.core.RSECorePlugin;
import org.eclipse.rse.core.events.ISystemModelChangeEvent;
@@ -46,13 +49,12 @@
}
@Override
- public void fillComposite(Composite parent,
- ServerModeSection modeSection) {
+ public void fillComposite(Composite parent, ServerModeSection modeSection) {
parent.setLayout(new FillLayout());
new RSEDeploymentPreferenceComposite(parent, SWT.NONE, modeSection);
}
- public static class RSEDeploymentPreferenceComposite extends Composite {
+ public static class RSEDeploymentPreferenceComposite extends Composite implements PropertyChangeListener {
private ServerModeSection modeSection;
private CustomSystemHostCombo combo;
private Text rseServerHome,rseServerConfig;
@@ -109,9 +111,28 @@
public void modifyText(ModifyEvent e) {
serverConfigChanged();
}});
+ modeSection.getServer().addPropertyChangeListener(this);
}
+ @Override
+ public void dispose () {
+ super.dispose();
+ modeSection.getServer().removePropertyChangeListener(this);
+ }
+ private boolean updatingFromModelChange = false;
+ public void propertyChange(PropertyChangeEvent evt) {
+ updatingFromModelChange = true;
+ if( evt.getPropertyName().equals(RSEUtils.RSE_SERVER_HOME_DIR)) {
+ rseServerHome.setText(evt.getNewValue().toString());
+ } else if( evt.getPropertyName().equals(RSEUtils.RSE_SERVER_CONFIG)) {
+ rseServerConfig.setText(evt.getNewValue().toString());
+ } else if( evt.getPropertyName().equals(RSEUtils.RSE_SERVER_HOST)) {
+ combo.setHostName(evt.getNewValue().toString());
+ }
+ updatingFromModelChange = false;
+ }
+
protected void browseClicked() {
SystemRemoteFileDialog d = new SystemRemoteFileDialog(
rseBrowse.getShell(), "Browse remote system", combo.getHost());
@@ -130,28 +151,34 @@
}
protected void rseHostChanged() {
- String hostName = combo.getHost() == null ? null : combo.getHost().getAliasName();
- String oldVal = modeSection.getServer().getAttribute(RSEUtils.RSE_SERVER_HOST, (String)null);
- if( !hostName.equals(oldVal)) {
- modeSection.getCommandManager().execute(new ChangeServerPropertyCommand(
- modeSection.getServer(), RSEUtils.RSE_SERVER_HOST, hostName,
- "Change RSE Host"));
- modeSection.getCommandManager().execute(new ChangeServerPropertyCommand(
- modeSection.getServer(), "hostname", combo.getHost().getHostName(),
- "Change Hostname"));
+ if( !updatingFromModelChange ) {
+ String hostName = combo.getHost() == null ? null : combo.getHost().getAliasName();
+ String oldVal = modeSection.getServer().getAttribute(RSEUtils.RSE_SERVER_HOST, (String)null);
+ if( !hostName.equals(oldVal) && !updatingFromModelChange) {
+ modeSection.getCommandManager().execute(new ChangeServerPropertyCommand(
+ modeSection.getServer(), RSEUtils.RSE_SERVER_HOST, hostName,
+ "Change RSE Host"));
+ modeSection.getCommandManager().execute(new ChangeServerPropertyCommand(
+ modeSection.getServer(), "hostname", combo.getHost().getHostName(),
+ "Change Hostname"));
+ }
}
}
protected void serverHomeChanged() {
- modeSection.getCommandManager().execute(new ChangeServerPropertyCommand(
- modeSection.getServer(), RSEUtils.RSE_SERVER_HOME_DIR, rseServerHome.getText(),
- "Change RSE Server's Home Directory"));
+ if( !updatingFromModelChange) {
+ modeSection.getCommandManager().execute(new ChangeServerPropertyCommand(
+ modeSection.getServer(), RSEUtils.RSE_SERVER_HOME_DIR, rseServerHome.getText(),
+ "Change RSE Server's Home Directory"));
+ }
}
protected void serverConfigChanged() {
- modeSection.getCommandManager().execute(new ChangeServerPropertyCommand(
- modeSection.getServer(), RSEUtils.RSE_SERVER_CONFIG, rseServerConfig.getText(),
- "Change RSE Server's Configuration"));
+ if( !updatingFromModelChange ) {
+ modeSection.getCommandManager().execute(new ChangeServerPropertyCommand(
+ modeSection.getServer(), RSEUtils.RSE_SERVER_CONFIG, rseServerConfig.getText(),
+ "Change RSE Server's Configuration"));
+ }
}
public class CustomSystemHostCombo extends Composite implements ModifyListener, ISystemModelChangeListener {
@@ -211,6 +238,22 @@
return currentHostName;
}
+ public void setHostName(String name) {
+ this.currentHostName = name;
+ this.currentHost = findHost(currentHostName);
+ if( currentHost == null )
+ combo.clearSelection();
+ else {
+ String[] items = combo.getItems();
+ for( int i = 0; i < items.length; i++ ) {
+ if( items[i].equals(currentHost.getAliasName())) {
+ combo.select(i);
+ return;
+ }
+ }
+ }
+ }
+
public void refreshConnections() {
hosts = RSECorePlugin.getTheSystemRegistry().getHostsBySubSystemConfigurationCategory(fileSubSystem);
hostsAsStrings = new String[hosts.length];
@@ -263,4 +306,5 @@
}
}
}
+
}
15 years, 4 months