Author: jlukas(a)redhat.com
Date: 2010-11-09 11:05:11 -0500 (Tue, 09 Nov 2010)
New Revision: 26381
Modified:
trunk/struts/tests/org.jboss.tools.struts.ui.bot.test/META-INF/MANIFEST.MF
trunk/struts/tests/org.jboss.tools.struts.ui.bot.test/src/org/jboss/tools/struts/ui/bot/test/utils/StrutsUIEditorBot.java
Log:
updated test and deps to swtbot 2.0.1
Modified: trunk/struts/tests/org.jboss.tools.struts.ui.bot.test/META-INF/MANIFEST.MF
===================================================================
--- trunk/struts/tests/org.jboss.tools.struts.ui.bot.test/META-INF/MANIFEST.MF 2010-11-09
16:04:02 UTC (rev 26380)
+++ trunk/struts/tests/org.jboss.tools.struts.ui.bot.test/META-INF/MANIFEST.MF 2010-11-09
16:05:11 UTC (rev 26381)
@@ -7,19 +7,20 @@
Require-Bundle: org.apache.log4j;bundle-version="1.2.13",
org.eclipse.core.runtime,
org.eclipse.gef;bundle-version="3.5.1",
- org.eclipse.swtbot.eclipse.core;bundle-version="2.0.0",
- org.eclipse.swtbot.eclipse.finder;bundle-version="2.0.0",
- org.eclipse.swtbot.eclipse.gef.finder;bundle-version="2.0.0",
- org.eclipse.swtbot.eclipse.ui;bundle-version="2.0.0",
- org.eclipse.swtbot.junit4_x;bundle-version="2.0.0",
- org.eclipse.swtbot.swt.finder;bundle-version="2.0.0",
+ org.eclipse.swtbot.eclipse.core;bundle-version="2.0.1",
+ org.eclipse.swtbot.eclipse.finder;bundle-version="2.0.1",
+ org.eclipse.swtbot.eclipse.gef.finder;bundle-version="2.0.1",
+ org.eclipse.swtbot.eclipse.ui;bundle-version="2.0.1",
+ org.eclipse.swtbot.junit4_x;bundle-version="2.0.1",
+ org.eclipse.swtbot.swt.finder;bundle-version="2.0.1",
org.eclipse.ui,
org.eclipse.ui.ide;bundle-version="3.5.2",
org.jboss.tools.common.model.ui;bundle-version="3.1.0",
org.jboss.tools.struts.ui;bundle-version="3.1.0",
org.jboss.tools.jst.ui.bot.test;bundle-version="1.0.0",
org.jboss.tools.ui.bot.ext;bundle-version="1.0.0",
- org.junit4;bundle-version="4.5.0"
+ org.junit4;bundle-version="4.5.0",
+ org.eclipse.ui.browser;bundle-version="3.3.0"
Bundle-ActivationPolicy: lazy
Bundle-RequiredExecutionEnvironment: J2SE-1.5
Bundle-Vendor: JBoss by Red Hat
Modified:
trunk/struts/tests/org.jboss.tools.struts.ui.bot.test/src/org/jboss/tools/struts/ui/bot/test/utils/StrutsUIEditorBot.java
===================================================================
---
trunk/struts/tests/org.jboss.tools.struts.ui.bot.test/src/org/jboss/tools/struts/ui/bot/test/utils/StrutsUIEditorBot.java 2010-11-09
16:04:02 UTC (rev 26380)
+++
trunk/struts/tests/org.jboss.tools.struts.ui.bot.test/src/org/jboss/tools/struts/ui/bot/test/utils/StrutsUIEditorBot.java 2010-11-09
16:05:11 UTC (rev 26381)
@@ -1,13 +1,3 @@
-/*******************************************************************************
- * Copyright (c) 2010 Red Hat, Inc.
- * Distributed under license by Red Hat, Inc. All rights reserved.
- * This program is made available under the terms of the
- * Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at
http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Red Hat, Inc. - initial API and implementation
- ******************************************************************************/
package org.jboss.tools.struts.ui.bot.test.utils;
import java.lang.reflect.Field;
@@ -16,17 +6,16 @@
import java.util.logging.Level;
import java.util.logging.Logger;
-import org.eclipse.draw2d.FigureCanvas;
import org.eclipse.gef.GraphicalViewer;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot;
-import org.eclipse.swtbot.eclipse.gef.finder.widgets.SWTBotGefEditor;
-import org.eclipse.swtbot.eclipse.gef.finder.widgets.SWTBotGefFigureCanvas;
+import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotEditor;
+import org.eclipse.swtbot.eclipse.gef.finder.widgets.SWTBotGefEditPart;
+import org.eclipse.swtbot.eclipse.gef.finder.widgets.SWTBotGefViewer;
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.VoidResult;
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.IEditorReference;
import org.eclipse.ui.IWorkbenchPart;
@@ -34,79 +23,98 @@
import org.jboss.tools.common.editor.ObjectMultiPageEditor;
import org.jboss.tools.common.model.ui.editor.EditorPartWrapper;
-public class StrutsUIEditorBot extends SWTBotGefEditor {
+/**
+ * modified copy of SWTBotGefEditor class to get it working with Struts UI editor
+ *
+ * @author jlukas
+ */
+public class StrutsUIEditorBot extends SWTBotEditor {
+ private final StrutsUIEditorViewer viewer;
private static final Logger L = Logger.getLogger(StrutsUIEditorBot.class.getName());
- public StrutsUIEditorBot(IEditorReference reference) throws WidgetNotFoundException
{
- super(reference, new SWTWorkbenchBot());
- }
+ public StrutsUIEditorBot(final IEditorReference editorReference)
+ throws WidgetNotFoundException {
+ super(editorReference, new SWTWorkbenchBot());
+ GraphicalViewer graphicalViewer = UIThreadRunnable.syncExec(new
Result<GraphicalViewer>() {
+ public GraphicalViewer run() {
+ final IEditorPart/*EditorPartWrapper*/ editor = partReference.getEditor(true);
+ EditorPart/*StrutsEditor*/ ep = null;
+ try {
+ Field f = editor.getClass().getDeclaredField("editor");
+ f.setAccessible(true);
+ Object/*StrutsConfigEditor*/ o = f.get(editor);
+ f.setAccessible(false);
+ f = o.getClass().getDeclaredField("guiEditor");
+ f.setAccessible(true);
+ Object/*StrutsConfigGuiEditor*/ o2 = f.get(o);
+ f.setAccessible(false);
+ Method m = o2.getClass().getMethod("getGUI");
+ ep = (EditorPart) m.invoke(o2);
+ } catch (SecurityException e) {
+ L.log(Level.WARNING, e.getMessage(), e);
+ } catch (NoSuchFieldException e) {
+ L.log(Level.WARNING, e.getMessage(), e);
+ } catch (IllegalArgumentException e) {
+ L.log(Level.WARNING, e.getMessage(), e);
+ } catch (IllegalAccessException e) {
+ L.log(Level.WARNING, e.getMessage(), e);
+ } catch (NoSuchMethodException e) {
+ L.log(Level.WARNING, e.getMessage(), e);
+ } catch (InvocationTargetException e) {
+ L.log(Level.WARNING, e.getMessage(), e);
+ }
+ return (GraphicalViewer) ep.getAdapter(GraphicalViewer.class);
+ }
+ });
+ viewer = new StrutsUIEditorViewer(graphicalViewer);
+ }
+
+ public StrutsUIEditorBot activateTool(final String label) throws WidgetNotFoundException
{
+ viewer.activateTool(label);
+ return this;
+ }
-// @Override
-// protected void init() throws WidgetNotFoundException {
-// UIThreadRunnable.syncExec(new VoidResult() {
-//
-// public void run() {
-// final IEditorPart/*EditorPartWrapper*/ editor =
partReference.getEditor(true);
-// EditorPart/*StrutsEditor*/ ep = null;
-// try {
-// Field f = editor.getClass().getDeclaredField("editor");
-// f.setAccessible(true);
-// Object/*StrutsConfigEditor*/ o = f.get(editor);
-// f.setAccessible(false);
-// f = o.getClass().getDeclaredField("guiEditor");
-// f.setAccessible(true);
-// Object/*StrutsConfigGuiEditor*/ o2 = f.get(o);
-// f.setAccessible(false);
-// Method m = o2.getClass().getMethod("getGUI");
-// ep = (EditorPart) m.invoke(o2);
-// } catch (SecurityException e) {
-// L.log(Level.WARNING, e.getMessage(), e);
-// } catch (NoSuchFieldException e) {
-// L.log(Level.WARNING, e.getMessage(), e);
-// } catch (IllegalArgumentException e) {
-// L.log(Level.WARNING, e.getMessage(), e);
-// } catch (IllegalAccessException e) {
-// L.log(Level.WARNING, e.getMessage(), e);
-// } catch (NoSuchMethodException e) {
-// L.log(Level.WARNING, e.getMessage(), e);
-// } catch (InvocationTargetException e) {
-// L.log(Level.WARNING, e.getMessage(), e);
-// }
-// graphicalViewer = (GraphicalViewer)
ep.getAdapter(GraphicalViewer.class);
-// final Control control = graphicalViewer.getControl();
-// if (control instanceof FigureCanvas) {
-// canvas = new SWTBotGefFigureCanvas((FigureCanvas) control);
-// }
-// editDomain = graphicalViewer.getEditDomain();
-// }
-// });
-//
-// if (graphicalViewer == null) {
-// throw new WidgetNotFoundException("Editor does not adapt to a
GraphicalViewer");
-// }
-// }
+ public StrutsUIEditorBot activateTool(final String label, int index) throws
WidgetNotFoundException {
+ viewer.activateTool(label, index);
+ return this;
+ }
+
+ public SWTBotGefEditPart mainEditPart() throws WidgetNotFoundException {
+ return viewer.mainEditPart();
+ }
+
+ public Control getControl() {
+ return viewer.getControl();
+ }
- public void selectPage(final String page) {
- IWorkbenchPart p = ((EditorPartWrapper)
(getReference().getPart(true))).getEditor();
- assert p instanceof ObjectMultiPageEditor;
- final ObjectMultiPageEditor editor = (ObjectMultiPageEditor) p;
- // Select page
- Display.getDefault().syncExec(new Runnable() {
+ public StrutsUIEditorBot clickContextMenu(String text) throws WidgetNotFoundException {
+ viewer.clickContextMenu(text);
+ return this;
+ }
+
+ public void selectPage(final String page) {
+ IWorkbenchPart p = ((EditorPartWrapper) (getReference().getPart(true))).getEditor();
+ assert p instanceof ObjectMultiPageEditor;
+ final ObjectMultiPageEditor editor = (ObjectMultiPageEditor) p;
+ // Select page
+ Display.getDefault().syncExec(new Runnable() {
+ public void run() {
+ editor.selectPageByName(page);
+ }
+ });
+ }
- public void run() {
- editor.selectPageByName(page);
- }
- });
- }
+ private static class StrutsUIEditorViewer extends SWTBotGefViewer {
- public Control/*FigureCanvas*/ getControl() {
- return null;
-// return UIThreadRunnable.syncExec(new Result<Control>() {
-//
-// public Control run() {
-// return graphicalViewer.getControl();
-// }
-// });
- }
+ public StrutsUIEditorViewer(GraphicalViewer graphicalViewer)
+ throws WidgetNotFoundException {
+ super(graphicalViewer);
+ }
+
+ public Control getControl() {
+ return super.getControl();
+ }
+
+ }
}