diff options
10 files changed, 88 insertions, 165 deletions
diff --git a/org.eclipse.jubula.rc.common/src/org/eclipse/jubula/rc/common/logger/AutServerLogger.java b/org.eclipse.jubula.rc.common/src/org/eclipse/jubula/rc/common/logger/AutServerLogger.java index 78fd52021..e9a708faf 100644 --- a/org.eclipse.jubula.rc.common/src/org/eclipse/jubula/rc/common/logger/AutServerLogger.java +++ b/org.eclipse.jubula.rc.common/src/org/eclipse/jubula/rc/common/logger/AutServerLogger.java @@ -14,18 +14,18 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; /** - * Wrapper class for org.apache.commons.logging - * This class is used in the implementation class context. - * This class will NOT be loaded by the ImplClassClassLoader but by its parent! - * The methods in this class delegate to the org.apache.commons.logging.Log. - * This is neccessary because in the ImplClassClassLoader context u can only - * use plain java code! + * Wrapper class for org.slf4j.Logger This class is used in the implementation + * class context. This class will NOT be loaded by the ImplClassClassLoader but + * by its parent! The methods in this class delegate to the + * org.apache.commons.logging.Log. This is necessary because in the + * ImplClassClassLoader context u can only use plain java code! + * * @author BREDEX GmbH * @created 10.05.2006 */ public class AutServerLogger { /** The Logger */ - private Logger m_log; + private Logger m_log; /** * Constructor @@ -159,7 +159,4 @@ public class AutServerLogger { public boolean isWarnEnabled() { return m_log.isWarnEnabled(); } - - - } diff --git a/org.eclipse.jubula.rc.rcp.e3/src/org/eclipse/jubula/rc/rcp/e3/accessor/E3Startup.java b/org.eclipse.jubula.rc.rcp.e3/src/org/eclipse/jubula/rc/rcp/e3/accessor/E3Startup.java index c535deee4..0ba53bc4a 100644 --- a/org.eclipse.jubula.rc.rcp.e3/src/org/eclipse/jubula/rc/rcp/e3/accessor/E3Startup.java +++ b/org.eclipse.jubula.rc.rcp.e3/src/org/eclipse/jubula/rc/rcp/e3/accessor/E3Startup.java @@ -13,7 +13,6 @@ package org.eclipse.jubula.rc.rcp.e3.accessor; import java.util.ArrayList; import java.util.Iterator; import java.util.List; -import java.util.Properties; import org.eclipse.core.runtime.Platform; import org.eclipse.jubula.rc.common.AUTServer; @@ -180,13 +179,11 @@ public abstract class E3Startup implements IStartup { } /** - * * {@inheritDoc} */ public void partVisible(IWorkbenchPartReference partRef) { partOpened(partRef); } - } /** @@ -206,20 +203,18 @@ public abstract class E3Startup implements IStartup { * {@inheritDoc} */ public void earlyStartup() { - final Properties envVars = - EnvironmentUtils.getProcessEnvironment(); - - if (getValue(AutConfigConstants.AUT_AGENT_HOST, envVars) != null) { + if (EnvironmentUtils.getProcessOrSystemProperty( + AutConfigConstants.AUT_AGENT_HOST) != null) { final IWorkbench workbench = PlatformUI.getWorkbench(); final Display display = workbench.getDisplay(); - initAutServer(display, envVars); + final AUTServer autServer = initAutServer(display); display.syncExec(new Runnable() { public void run() { // add GEF listeners (and listener appenders) for GEF, if available if (Platform.getBundle(E3Startup.GEF_BUNDLE_ID) != null) { m_gefListener = new GefPartListener(); - AUTServer.getInstance().addInspectorListenerAppender( + autServer.addInspectorListenerAppender( new GefInspectorListenerAppender()); } @@ -271,30 +266,30 @@ public abstract class E3Startup implements IStartup { // Registering the AdapterFactory for SWT at the registry AdapterFactoryRegistry.initRegistration(new EclipseUrlLocator()); // add listener to AUT - AUTServer.getInstance().addToolKitEventListenerToAUT(); - + autServer.addToolKitEventListenerToAUT(); } } /** * Initializes the AUT Server for the host application. - * - * @param display The Display to use for the AUT Server. - * @param envVars Environment variables to consult in configuring the - * AUT Server. + * + * @param display + * The Display to use for the AUT Server. + * @return the AUTServer instance */ - private void initAutServer(Display display, Properties envVars) { - ((SwtAUTServer)AUTServer.getInstance(CommandConstants - .AUT_SWT_SERVER)).setDisplay(display); - AUTServer.getInstance().setAutAgentHost(getValue( - AutConfigConstants.AUT_AGENT_HOST, envVars)); - AUTServer.getInstance().setAutAgentPort(getValue( - AutConfigConstants.AUT_AGENT_PORT, envVars)); - AUTServer.getInstance().setAutID(getValue( - AutConfigConstants.AUT_NAME, envVars)); - - AUTServer.getInstance().start(true); + private AUTServer initAutServer(Display display) { + AUTServer instance = AUTServer.getInstance( + CommandConstants.AUT_SWT_SERVER); + ((SwtAUTServer) instance).setDisplay(display); + instance.setAutAgentHost(EnvironmentUtils + .getProcessOrSystemProperty(AutConfigConstants.AUT_AGENT_HOST)); + instance.setAutAgentPort(EnvironmentUtils + .getProcessOrSystemProperty(AutConfigConstants.AUT_AGENT_PORT)); + instance.setAutID(EnvironmentUtils + .getProcessOrSystemProperty(AutConfigConstants.AUT_NAME)); + instance.start(true); + return instance; } /** @@ -360,15 +355,10 @@ public abstract class E3Startup implements IStartup { if (children[i] instanceof Composite) { getToolbars((Composite)children[i], toolbarList); } - try { - if (children[i] instanceof ToolBar - || children[i] instanceof CoolBar) { + if (children[i] instanceof ToolBar + || children[i] instanceof CoolBar) { - toolbarList.add(children[i]); - } - } catch (NoClassDefFoundError e) { - // we may be running in eRCP which doesn't know about - // toolbars, so we just ignore this + toolbarList.add(children[i]); } } } @@ -385,25 +375,4 @@ public abstract class E3Startup implements IStartup { window.getPartService().addPartListener(m_gefListener); } } - - /** - * Returns the value for a given property. First, <code>envVars</code> - * is checked for the given property. If this - * property cannot be found there, the - * Java System Properties will be checked. If the property is not - * found there, <code>null</code> will be returned. - * - * @param envVars The first source to check for the given property. - * @param propName The name of the property for which to find the value. - * @return The value for the given property name, or <code>null</code> if - * given property name cannot be found. - */ - private String getValue(String propName, Properties envVars) { - String value = - envVars.getProperty(propName); - if (value == null) { - value = System.getProperty(propName); - } - return value; - } } diff --git a/org.eclipse.jubula.rc.rcp.e4.swt/src/org/eclipse/jubula/rc/rcp/e4/swt/namer/E4SwtComponentNamer.java b/org.eclipse.jubula.rc.rcp.e4.swt/src/org/eclipse/jubula/rc/rcp/e4/swt/namer/E4SwtComponentNamer.java index f63553395..79a374f34 100644 --- a/org.eclipse.jubula.rc.rcp.e4.swt/src/org/eclipse/jubula/rc/rcp/e4/swt/namer/E4SwtComponentNamer.java +++ b/org.eclipse.jubula.rc.rcp.e4.swt/src/org/eclipse/jubula/rc/rcp/e4/swt/namer/E4SwtComponentNamer.java @@ -98,5 +98,4 @@ public class E4SwtComponentNamer extends RcpSwtComponentNamer protected PreferenceManager getPreferenceManager() { return null; } - } diff --git a/org.eclipse.jubula.rc.rcp.e4.swt/src/org/eclipse/jubula/rc/rcp/e4/swt/starter/SwtProcessor.java b/org.eclipse.jubula.rc.rcp.e4.swt/src/org/eclipse/jubula/rc/rcp/e4/swt/starter/SwtProcessor.java index 7fc1eef2d..983f88e38 100644 --- a/org.eclipse.jubula.rc.rcp.e4.swt/src/org/eclipse/jubula/rc/rcp/e4/swt/starter/SwtProcessor.java +++ b/org.eclipse.jubula.rc.rcp.e4.swt/src/org/eclipse/jubula/rc/rcp/e4/swt/starter/SwtProcessor.java @@ -22,7 +22,6 @@ import org.eclipse.swt.widgets.Shell; * The SWT implementation of the abstract e4 processor. */ public class SwtProcessor extends AbstractProcessor { - /** The implementation of the e4 component namer interface. */ private E4SwtComponentNamer m_componentNamer = new E4SwtComponentNamer(); @@ -38,5 +37,4 @@ public class SwtProcessor extends AbstractProcessor { ((SwtRemoteControlService) SwtRemoteControlService.getInstance()) .checkRemoteControlService(display, m_componentNamer); } - -} +}
\ No newline at end of file diff --git a/org.eclipse.jubula.rc.rcp.e4/META-INF/MANIFEST.MF b/org.eclipse.jubula.rc.rcp.e4/META-INF/MANIFEST.MF index 0ec5ad243..69d34065b 100644 --- a/org.eclipse.jubula.rc.rcp.e4/META-INF/MANIFEST.MF +++ b/org.eclipse.jubula.rc.rcp.e4/META-INF/MANIFEST.MF @@ -6,6 +6,7 @@ Bundle-Version: 2.3.0.qualifier Bundle-ClassPath: . Bundle-Vendor: Eclipse Jubula Require-Bundle: org.eclipse.osgi.services;bundle-version="[3.3.0,5.0.0)", + org.eclipse.jubula.rc.rcp.common;bundle-version="[2.0.0,3.0.0)", org.eclipse.e4.core.di;bundle-version="[1.0.0,2.0.0)", org.eclipse.e4.core.services;bundle-version="[1.0.0,2.0.0)", org.eclipse.e4.ui.workbench;bundle-version="[0.10.2,2.0.0)", diff --git a/org.eclipse.jubula.rc.rcp.e4/src/org/eclipse/jubula/rc/rcp/e4/starter/AbstractProcessor.java b/org.eclipse.jubula.rc.rcp.e4/src/org/eclipse/jubula/rc/rcp/e4/starter/AbstractProcessor.java index ad52fd751..36f64f995 100644 --- a/org.eclipse.jubula.rc.rcp.e4/src/org/eclipse/jubula/rc/rcp/e4/starter/AbstractProcessor.java +++ b/org.eclipse.jubula.rc.rcp.e4/src/org/eclipse/jubula/rc/rcp/e4/starter/AbstractProcessor.java @@ -21,8 +21,11 @@ import org.eclipse.e4.ui.model.application.ui.menu.MToolItem; import org.eclipse.e4.ui.workbench.UIEvents; import org.eclipse.e4.ui.workbench.UIEvents.EventTags; import org.eclipse.jubula.rc.rcp.e4.namer.E4ComponentNamer; +import org.eclipse.jubula.tools.constants.AUTServerExitConstants; import org.osgi.service.event.Event; import org.osgi.service.event.EventHandler; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /**us * This is an abstract e4 processor for the extension point @@ -32,7 +35,10 @@ import org.osgi.service.event.EventHandler; * which returns an {@link AbstractEventBrokerListener}. */ public abstract class AbstractProcessor implements EventHandler { - + /** the logger */ + private static final Logger LOG = LoggerFactory + .getLogger(AbstractProcessor.class); + /** * Called by processor mechanism via extension point to register at * the event broker listening on changes in the application model. @@ -43,10 +49,9 @@ public abstract class AbstractProcessor implements EventHandler { */ @Execute protected void hookListener(final IEventBroker eventBroker) { - if (!eventBroker.subscribe(UIEvents.UIElement.TOPIC_WIDGET, - this)) { - System.err.println( - "Could not subscribe to event broker TOPIC_WIDGET!"); //$NON-NLS-1$ + if (!eventBroker.subscribe(UIEvents.UIElement.TOPIC_WIDGET, this)) { + LOG.error("Could not subscribe to event broker TOPIC_WIDGET!"); //$NON-NLS-1$ + System.exit(AUTServerExitConstants.AUT_START_ERROR); } } diff --git a/org.eclipse.jubula.rc.rcp.swt/src/org/eclipse/jubula/rc/rcp/swt/aut/RcpSwtComponentNamer.java b/org.eclipse.jubula.rc.rcp.swt/src/org/eclipse/jubula/rc/rcp/swt/aut/RcpSwtComponentNamer.java index dda90b793..3f7690c34 100644 --- a/org.eclipse.jubula.rc.rcp.swt/src/org/eclipse/jubula/rc/rcp/swt/aut/RcpSwtComponentNamer.java +++ b/org.eclipse.jubula.rc.rcp.swt/src/org/eclipse/jubula/rc/rcp/swt/aut/RcpSwtComponentNamer.java @@ -186,24 +186,18 @@ public abstract class RcpSwtComponentNamer implements Listener { // component hierarchy, due to the fact that the ToolBar's // getParent() returns the CoolBar rather than the CoolItem. // To resolve this discrepancy, we use the data from the - // coresponding CoolItem to generate a name for the ToolBar. - try { - if (widget instanceof ToolBar) { - Composite toolbarParent = ((ToolBar) widget).getParent(); - if (toolbarParent instanceof CoolBar) { - CoolItem[] coolItems = ((CoolBar) toolbarParent).getItems(); - for (int i = 0; i < coolItems.length; i++) { - CoolItem item = coolItems[i]; - if (item != null && item.getControl() == widget) { - data = item.getData(); - } + // corresponding CoolItem to generate a name for the ToolBar. + if (widget instanceof ToolBar) { + Composite toolbarParent = ((ToolBar) widget).getParent(); + if (toolbarParent instanceof CoolBar) { + CoolItem[] coolItems = ((CoolBar) toolbarParent).getItems(); + for (int i = 0; i < coolItems.length; i++) { + CoolItem item = coolItems[i]; + if (item != null && item.getControl() == widget) { + data = item.getData(); } } } - } catch (NoClassDefFoundError e) { - // we may be running in eRCP which doesn't know - // about - // toolbars, so we just ignore this } return data; @@ -343,9 +337,7 @@ public abstract class RcpSwtComponentNamer implements Listener { */ public static void setToolbarComponentName(Widget partToolbar, String finalPartId) { - setComponentName( - partToolbar, - finalPartId + TOOLBAR_ID_SUFFIX); + setComponentName(partToolbar, finalPartId + TOOLBAR_ID_SUFFIX); } /** @@ -353,5 +345,4 @@ public abstract class RcpSwtComponentNamer implements Listener { * This method must be implemented depending on Eclipse RCP e3 and e4. */ protected abstract PreferenceManager getPreferenceManager(); - -} +}
\ No newline at end of file diff --git a/org.eclipse.jubula.rc.rcp.swt/src/org/eclipse/jubula/rc/rcp/swt/aut/SwtRemoteControlService.java b/org.eclipse.jubula.rc.rcp.swt/src/org/eclipse/jubula/rc/rcp/swt/aut/SwtRemoteControlService.java index 71f406768..99bafbd17 100644 --- a/org.eclipse.jubula.rc.rcp.swt/src/org/eclipse/jubula/rc/rcp/swt/aut/SwtRemoteControlService.java +++ b/org.eclipse.jubula.rc.rcp.swt/src/org/eclipse/jubula/rc/rcp/swt/aut/SwtRemoteControlService.java @@ -1,22 +1,26 @@ package org.eclipse.jubula.rc.rcp.swt.aut; -import java.util.Properties; - import org.eclipse.jubula.rc.common.AUTServer; import org.eclipse.jubula.rc.common.adaptable.AdapterFactoryRegistry; import org.eclipse.jubula.rc.rcp.common.classloader.EclipseUrlLocator; import org.eclipse.jubula.rc.swt.SwtAUTServer; +import org.eclipse.jubula.tools.constants.AUTServerExitConstants; import org.eclipse.jubula.tools.constants.AutConfigConstants; import org.eclipse.jubula.tools.utils.EnvironmentUtils; import org.eclipse.swt.SWT; import org.eclipse.swt.widgets.Display; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * This class extends the SwtAUTServer to avoid buddy class loading, * which does not work, if the SWT library is in it's own bundle. */ public class SwtRemoteControlService extends SwtAUTServer { - + /** the logger */ + private static final Logger LOG = LoggerFactory + .getLogger(SwtRemoteControlService.class); + /** An instance of this class. */ private static SwtRemoteControlService instance; @@ -65,21 +69,21 @@ public class SwtRemoteControlService extends SwtAUTServer { * @return True, if the AUTServer is already running, otherwise false. */ private boolean startRemoteControlService(final Display display) { - final Properties envVars = - EnvironmentUtils.getProcessEnvironment(); - if (getValue(AutConfigConstants.AUT_AGENT_HOST, envVars) != null) { + String autAgentHost = EnvironmentUtils + .getProcessOrSystemProperty(AutConfigConstants.AUT_AGENT_HOST); + if (autAgentHost != null) { try { - setAutAgentHost(getValue( - AutConfigConstants.AUT_AGENT_HOST, envVars)); - setAutAgentPort(getValue( - AutConfigConstants.AUT_AGENT_PORT, envVars)); - setAutID(getValue( - AutConfigConstants.AUT_NAME, envVars)); + setAutAgentHost(autAgentHost); + setAutAgentPort(EnvironmentUtils.getProcessOrSystemProperty( + AutConfigConstants.AUT_AGENT_PORT)); + setAutID(EnvironmentUtils.getProcessOrSystemProperty( + AutConfigConstants.AUT_NAME)); setDisplay(display); start(true); // true = start an RCP accessor m_hasRemoteControlServiceStarted = true; } catch (Exception e) { - e.getStackTrace(); + LOG.error(e.getLocalizedMessage(), e); + System.exit(AUTServerExitConstants.AUT_START_ERROR); } } return m_hasRemoteControlServiceStarted; @@ -101,24 +105,4 @@ public class SwtRemoteControlService extends SwtAUTServer { display.addFilter(SWT.Paint, rcpSwtComponentNamer); display.addFilter(SWT.Activate, rcpSwtComponentNamer); } - - /** - * Returns the value for a given property. First, <code>envVars</code> - * is checked for the given property. If this property cannot be found - * there, the Java System Properties will be checked. If the property - * is not found there, <code>null</code> will be returned. - * - * @param envVars The first source to check for the given property. - * @param propName The name of the property for which to find the value. - * @return The value for the given property name, or <code>null</code> if - * the given property name cannot be found. - */ - private static String getValue(String propName, Properties envVars) { - String value = envVars.getProperty(propName); - if (value == null) { - value = System.getProperty(propName); - } - return value; - } - -} +}
\ No newline at end of file diff --git a/org.eclipse.jubula.rc.swt/src/org/eclipse/jubula/rc/swt/driver/SwtRobot.java b/org.eclipse.jubula.rc.swt/src/org/eclipse/jubula/rc/swt/driver/SwtRobot.java index ef383fec1..0bf751bfe 100644 --- a/org.eclipse.jubula.rc.swt/src/org/eclipse/jubula/rc/swt/driver/SwtRobot.java +++ b/org.eclipse.jubula.rc.swt/src/org/eclipse/jubula/rc/swt/driver/SwtRobot.java @@ -17,6 +17,7 @@ import java.util.Arrays; import java.util.HashMap; import java.util.Map; +import org.eclipse.jubula.rc.common.logger.AutServerLogger; import org.eclipse.jubula.tools.utils.TimeUtil; import org.eclipse.swt.SWT; import org.eclipse.swt.SWTException; @@ -33,6 +34,9 @@ import org.eclipse.swt.widgets.Display; * @author BREDEX GmbH */ public class SwtRobot { + /** the logger */ + private static AutServerLogger log = new AutServerLogger(SwtRobot.class); + /** the # of modifiers- like SWT.CTRL, SWT.ALT, etc- that are currently defined */ private static final int MODIFIER_COUNT = 7; @@ -133,7 +137,7 @@ public class SwtRobot { * CURRENTLY THIS IS FUNCTIONALLY THE SAME AS THE NO-PARAM CONSTRUCTOR * Creates a <code>Robot</code> for the given <code>Display</code>. * @param display the <code>Display</code> associated with this robot - * @throws SWTException throwed AWT-Exception + * @throws SWTException thrown AWT-Exception */ public SwtRobot(Display display) throws SWTException { this(); @@ -254,17 +258,18 @@ public class SwtRobot { * queue, prior to calling this method, have been handled. */ public synchronized void waitForIdle() { - if (m_displayProperty.getThread() == Thread.currentThread()) { - while (m_displayProperty.readAndDispatch()) { - // FIXME Clemens: do nothing - System.out.println(); + final Display d = m_displayProperty; + if (d.getThread() == Thread.currentThread()) { + boolean continueWaiting = d.readAndDispatch(); + while (continueWaiting) { + continueWaiting = d.readAndDispatch(); } } else { - m_displayProperty.syncExec(new Runnable() { + d.syncExec(new Runnable() { public void run() { - while (m_displayProperty.readAndDispatch()) { -// FIXME Clemens: do nothing - System.out.println(); + boolean continueWaiting = d.readAndDispatch(); + while (continueWaiting) { + continueWaiting = d.readAndDispatch(); } } }); @@ -272,20 +277,6 @@ public class SwtRobot { } /** - * @param display the current display - */ - public void waitForIdle(final Display display) { - display.syncExec(new Runnable() { - public void run() { - while (display.readAndDispatch()) { -// FIXME Clemens: do nothing - System.out.println(); - } - } - }); - } - - /** * Presses all keys in a given accelerator. To type a character or digit, * just use the unicode value. For example, <code> accelerator = 'k', * accelerator = 'K', accelerator = '5' </code>. @@ -316,8 +307,7 @@ public class SwtRobot { try { m_robot.keyPress(keys[i]); } catch (IllegalArgumentException iae) { - // FIXME Clemens: log - System.err.println("IllegalArgumentException: keystroke :" //$NON-NLS-1$ + log.error("IllegalArgumentException: keystroke :" //$NON-NLS-1$ + keys[i] + "\nAccelerator:" //$NON-NLS-1$ + accelerator @@ -561,12 +551,4 @@ public class SwtRobot { public Display getDisplay() { return m_displayProperty; } - - /** - * Set the <code>Display</code> object with which this robot is synchronized. - * @param display the <code>Display</code> to associate with this <code>Robot</code> - */ - public void setDisplay(Display display) { - this.m_displayProperty = display; - } }
\ No newline at end of file diff --git a/org.eclipse.jubula.rc.swt/src/org/eclipse/jubula/rc/swt/utils/SwtUtils.java b/org.eclipse.jubula.rc.swt/src/org/eclipse/jubula/rc/swt/utils/SwtUtils.java index 517ed0cf4..8e7120cce 100644 --- a/org.eclipse.jubula.rc.swt/src/org/eclipse/jubula/rc/swt/utils/SwtUtils.java +++ b/org.eclipse.jubula.rc.swt/src/org/eclipse/jubula/rc/swt/utils/SwtUtils.java @@ -295,7 +295,6 @@ public class SwtUtils { Widget parent = null; if (widget == null) { - // FIXME Clemens log.error("Cannot get parent for null widget."); //$NON-NLS-1$ } if (widget instanceof Control) { @@ -325,9 +324,7 @@ public class SwtUtils { } else if (widget instanceof DropTarget) { parent = ((DropTarget)widget).getControl().getParent(); } else if (widget instanceof Tracker) { - // FIXME Clemens: - System.out.println(); - // Log.debug("requested the parent of a Tracker- UNFINDABLE"); + log.error("requested the parent of a Tracker- UNFINDABLE"); //$NON-NLS-1$ } return parent; } |