adapt to new SWTBot version
diff --git a/tests/org.eclipse.graphiti.bot.tests/src/org/eclipse/graphiti/bot/tests/AbstractGFTests.java b/tests/org.eclipse.graphiti.bot.tests/src/org/eclipse/graphiti/bot/tests/AbstractGFTests.java
index 232811b..e4d9eb1 100644
--- a/tests/org.eclipse.graphiti.bot.tests/src/org/eclipse/graphiti/bot/tests/AbstractGFTests.java
+++ b/tests/org.eclipse.graphiti.bot.tests/src/org/eclipse/graphiti/bot/tests/AbstractGFTests.java
@@ -38,8 +38,7 @@
import org.eclipse.emf.ecore.EEnum;
import org.eclipse.emf.ecore.EcoreFactory;
import org.eclipse.emf.transaction.TransactionalEditingDomain;
-import org.eclipse.graphiti.bot.tests.swtbot.GFSWTBotGefEditor;
-import org.eclipse.graphiti.bot.tests.swtbot.GFSWTGefBot;
+import org.eclipse.gef.GraphicalViewer;
import org.eclipse.graphiti.bot.tests.util.ITestConstants;
import org.eclipse.graphiti.examples.common.ExampleProjectNature;
import org.eclipse.graphiti.examples.common.FileService;
@@ -65,15 +64,17 @@
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.widgets.Canvas;
+import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotEditor;
import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotPerspective;
import org.eclipse.swtbot.eclipse.gef.finder.SWTBotGefTestCase;
import org.eclipse.swtbot.eclipse.gef.finder.widgets.SWTBotGefEditor;
-import org.eclipse.swtbot.eclipse.gef.finder.widgets.SWTBotGefFigureCanvas;
import org.eclipse.swtbot.swt.finder.exceptions.WidgetNotFoundException;
import org.eclipse.swtbot.swt.finder.finders.UIThreadRunnable;
import org.eclipse.swtbot.swt.finder.results.VoidResult;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.IEditorReference;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.PlatformUI;
import org.junit.Before;
@@ -81,8 +82,6 @@
abstract class AbstractGFTests extends SWTBotGefTestCase {
- protected GFSWTGefBot bot = new GFSWTGefBot();
-
private static final String PROJECT_NAME = "GraphitiTestProject";
public static final IPath SOURCE_FOLDER = new Path("src"); //$NON-NLS-1$
@@ -507,29 +506,32 @@
* @param ed
* @return
*/
- protected GFFigureCanvas getGFCanvas(final GFSWTBotGefEditor ed) {
+ protected GFFigureCanvas getGFCanvas(final SWTBotGefEditor ed) {
// get instance of GFFigureCanvas
- SWTBotGefFigureCanvas gfCanvas = ed.getGFCanvas();
- Canvas canvas = gfCanvas.widget;
- if (!(canvas instanceof GFFigureCanvas))
- return null;
- GFFigureCanvas gfFigureCanvas = (GFFigureCanvas) canvas;
+ GFFigureCanvas gfFigureCanvas = getGFCanvas();
return gfFigureCanvas;
}
- protected Canvas getCanvas(final GFSWTBotGefEditor ed) {
- // get instance of GFFigureCanvas
- SWTBotGefFigureCanvas gfCanvas = ed.getGFCanvas();
- return gfCanvas.widget;
- }
/**
* @param ed
* @return
*/
- protected Point getOrigin(final GFSWTBotGefEditor ed) {
- Canvas c = getCanvas(ed);
+ protected Point getOrigin(final SWTBotGefEditor ed) {
+ Canvas c = getGFCanvas();
Point p = c.toDisplay(0, 0);
return p;
}
+
+ protected GFFigureCanvas getGFCanvas() {
+ IEditorReference reference = getGefEditor().getReference();
+ final IEditorPart editor = reference.getEditor(true);
+ GraphicalViewer graphicalViewer = (GraphicalViewer) editor.getAdapter(GraphicalViewer.class);
+ final Control control = graphicalViewer.getControl();
+ if (control instanceof GFFigureCanvas) {
+ GFFigureCanvas c = (GFFigureCanvas) control;
+ return c;
+ }
+ return null;
+ }
}
diff --git a/tests/org.eclipse.graphiti.bot.tests/src/org/eclipse/graphiti/bot/tests/GFInteractionComponentTests.java b/tests/org.eclipse.graphiti.bot.tests/src/org/eclipse/graphiti/bot/tests/GFInteractionComponentTests.java
index 5bab4bb..b961b9e 100644
--- a/tests/org.eclipse.graphiti.bot.tests/src/org/eclipse/graphiti/bot/tests/GFInteractionComponentTests.java
+++ b/tests/org.eclipse.graphiti.bot.tests/src/org/eclipse/graphiti/bot/tests/GFInteractionComponentTests.java
@@ -32,7 +32,6 @@
import org.eclipse.gef.commands.CommandStack;
import org.eclipse.gef.palette.PaletteEntry;
import org.eclipse.gef.palette.ToolEntry;
-import org.eclipse.graphiti.bot.tests.swtbot.GFSWTBotGefEditor;
import org.eclipse.graphiti.bot.tests.util.ITestConstants;
import org.eclipse.graphiti.dt.IDiagramTypeProvider;
import org.eclipse.graphiti.features.ICreateFeature;
@@ -52,14 +51,12 @@
import org.eclipse.graphiti.ui.internal.services.GraphitiUiInternal;
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.widgets.Canvas;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Event;
import org.eclipse.swtbot.eclipse.gef.finder.finders.PaletteFinder;
import org.eclipse.swtbot.eclipse.gef.finder.matchers.AbstractToolEntryMatcher;
import org.eclipse.swtbot.eclipse.gef.finder.widgets.SWTBotGefEditPart;
import org.eclipse.swtbot.eclipse.gef.finder.widgets.SWTBotGefEditor;
-import org.eclipse.swtbot.eclipse.gef.finder.widgets.SWTBotGefFigureCanvas;
import org.eclipse.swtbot.swt.finder.results.VoidResult;
import org.hamcrest.Description;
import org.junit.Test;
@@ -130,7 +127,7 @@
final int x = 100;
final int y = 100;
final DiagramEditor diagramEditor = openDiagram(ITestConstants.DIAGRAM_TYPE_ID_ECORE);
- final GFSWTBotGefEditor ed = (GFSWTBotGefEditor) getGefEditor();
+ final SWTBotGefEditor ed = getGefEditor();
syncExec(new VoidResult() {
@Override
@@ -165,11 +162,7 @@
@Override
public void run() {
// get instance of GFFigureCanvas
- SWTBotGefFigureCanvas gfCanvas = ed.getGFCanvas();
- Canvas canvas = gfCanvas.widget;
- if (!(canvas instanceof GFFigureCanvas))
- return;
- GFFigureCanvas gfFigureCanvas = (GFFigureCanvas) canvas;
+ GFFigureCanvas gfFigureCanvas = getGFCanvas();
// do some scrolling
Event e = new Event();
@@ -241,7 +234,7 @@
final int x = 100;
final int y = 100;
final DiagramEditor diagramEditor = openDiagram(ITestConstants.DIAGRAM_TYPE_ID_ECORE);
- final GFSWTBotGefEditor ed = (GFSWTBotGefEditor) getGefEditor();
+ final SWTBotGefEditor ed = getGefEditor();
syncExec(new VoidResult() {
@Override
@@ -328,7 +321,7 @@
final int x = 100;
final int y = 100;
final DiagramEditor diagramEditor = openDiagram(ITestConstants.DIAGRAM_TYPE_ID_ECORE);
- final GFSWTBotGefEditor ed = (GFSWTBotGefEditor) getGefEditor();
+ final SWTBotGefEditor ed = getGefEditor();
syncExec(new VoidResult() {
@Override
@@ -445,7 +438,7 @@
final int DIL = 30;
final DiagramEditor diagramEditor = openDiagram(ITestConstants.DIAGRAM_TYPE_ID_SKETCH);
- final GFSWTBotGefEditor ed = (GFSWTBotGefEditor) getGefEditor();
+ final SWTBotGefEditor ed = getGefEditor();
syncExec(new VoidResult() {
@Override
@@ -534,7 +527,7 @@
final int x = 100;
final int y = 100;
final DiagramEditor diagramEditor = openDiagram(ITestConstants.DIAGRAM_TYPE_ID_SKETCH);
- final GFSWTBotGefEditor ed = (GFSWTBotGefEditor) getGefEditor();
+ final SWTBotGefEditor ed = getGefEditor();
syncExec(new VoidResult() {
@Override
@@ -590,7 +583,7 @@
final int x = 100;
final int y = 100;
final DiagramEditor diagramEditor = openDiagram(ITestConstants.DIAGRAM_TYPE_ID_SKETCH);
- final GFSWTBotGefEditor ed = (GFSWTBotGefEditor) getGefEditor();
+ final SWTBotGefEditor ed = getGefEditor();
syncExec(new VoidResult() {
@Override
@@ -649,7 +642,7 @@
final int x = 100;
final int y = 100;
final DiagramEditor diagramEditor = openDiagram(ITestConstants.DIAGRAM_TYPE_ID_SKETCH);
- final GFSWTBotGefEditor ed = (GFSWTBotGefEditor) getGefEditor();
+ final SWTBotGefEditor ed = getGefEditor();
syncExec(new VoidResult() {
@Override
@@ -702,7 +695,7 @@
final int containerSize = 100;
final int rectangleSize = 60;
final DiagramEditor diagramEditor = openDiagram(ITestConstants.DIAGRAM_TYPE_ID_SKETCH);
- final GFSWTBotGefEditor ed = (GFSWTBotGefEditor) getGefEditor();
+ final SWTBotGefEditor ed = getGefEditor();
syncExec(new VoidResult() {
@Override
@@ -804,7 +797,7 @@
final int x = 100;
final int y = 100;
final DiagramEditor diagramEditor = openDiagram(ITestConstants.DIAGRAM_TYPE_ID_SKETCH);
- final GFSWTBotGefEditor ed = (GFSWTBotGefEditor) getGefEditor();
+ final SWTBotGefEditor ed = getGefEditor();
syncExec(new VoidResult() {
@Override
@@ -903,7 +896,7 @@
final int x = 100;
final int y = 100;
final DiagramEditor diagramEditor = openDiagram(ITestConstants.DIAGRAM_TYPE_ID_ECORE);
- final GFSWTBotGefEditor ed = (GFSWTBotGefEditor) getGefEditor();
+ final SWTBotGefEditor ed = getGefEditor();
syncExec(new VoidResult() {
@Override
@@ -953,7 +946,7 @@
@Test
public void testSketchAll() throws Exception {
final DiagramEditor diagramEditor = openDiagram(ITestConstants.DIAGRAM_TYPE_ID_SKETCH);
- final GFSWTBotGefEditor ed = (GFSWTBotGefEditor) getGefEditor();
+ final SWTBotGefEditor ed = getGefEditor();
PaletteFinder paletteFinder = new PaletteFinder(diagramEditor.getEditDomain());
List<PaletteEntry> objectCreationTools = paletteFinder.findEntries(new AbstractToolEntryMatcher() {
diff --git a/tests/org.eclipse.graphiti.bot.tests/src/org/eclipse/graphiti/bot/tests/swtbot/GFSWTBotGefEditor.java b/tests/org.eclipse.graphiti.bot.tests/src/org/eclipse/graphiti/bot/tests/swtbot/GFSWTBotGefEditor.java
deleted file mode 100644
index c562426..0000000
--- a/tests/org.eclipse.graphiti.bot.tests/src/org/eclipse/graphiti/bot/tests/swtbot/GFSWTBotGefEditor.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/*******************************************************************************
- * <copyright>
- *
- * Copyright (c) 2005, 2010 SAP AG.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * SAP AG - initial API, implementation and documentation
- *
- * </copyright>
- *
- *******************************************************************************/
-package org.eclipse.graphiti.bot.tests.swtbot;
-
-import org.eclipse.draw2d.FigureCanvas;
-import org.eclipse.draw2d.LightweightSystem;
-import org.eclipse.gef.GraphicalViewer;
-import org.eclipse.graphiti.ui.internal.editor.GFFigureCanvas;
-import org.eclipse.swt.widgets.Control;
-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.swt.finder.exceptions.WidgetNotFoundException;
-import org.eclipse.swtbot.swt.finder.finders.UIThreadRunnable;
-import org.eclipse.swtbot.swt.finder.results.VoidResult;
-import org.eclipse.ui.IEditorPart;
-import org.eclipse.ui.IEditorReference;
-
-public class GFSWTBotGefEditor extends SWTBotGefEditor {
-
- /**
- * @param reference
- * @param bot
- * @throws WidgetNotFoundException
- */
- public GFSWTBotGefEditor(IEditorReference reference, SWTWorkbenchBot bot) throws WidgetNotFoundException {
- super(reference, bot);
- }
-
- protected void init() throws WidgetNotFoundException {
- UIThreadRunnable.syncExec(new VoidResult() {
- public void run() {
- final IEditorPart editor = partReference.getEditor(true);
- graphicalViewer = (GraphicalViewer) editor.getAdapter(GraphicalViewer.class);
- final Control control = graphicalViewer.getControl();
- if (control instanceof GFFigureCanvas) {
- GFFigureCanvas c = (GFFigureCanvas) control;
- LightweightSystem l = c.getLightweightSystem();
- canvas = new SWTBotGefFigureCanvas(c, l);
- } else 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 SWTBotGefFigureCanvas getGFCanvas() {
- return getCanvas();
- }
-
-}
diff --git a/tests/org.eclipse.graphiti.bot.tests/src/org/eclipse/graphiti/bot/tests/swtbot/GFSWTGefBot.java b/tests/org.eclipse.graphiti.bot.tests/src/org/eclipse/graphiti/bot/tests/swtbot/GFSWTGefBot.java
deleted file mode 100644
index c38e35d..0000000
--- a/tests/org.eclipse.graphiti.bot.tests/src/org/eclipse/graphiti/bot/tests/swtbot/GFSWTGefBot.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*******************************************************************************
- * <copyright>
- *
- * Copyright (c) 2005, 2010 SAP AG.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * SAP AG - initial API, implementation and documentation
- *
- * </copyright>
- *
- *******************************************************************************/
-package org.eclipse.graphiti.bot.tests.swtbot;
-
-import org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot;
-import org.eclipse.swtbot.eclipse.gef.finder.SWTGefBot;
-import org.eclipse.ui.IEditorReference;
-
-/**
- *
- */
-public class GFSWTGefBot extends SWTGefBot {
-
- /*
- * (non-Javadoc)
- *
- * @see
- * org.eclipse.swtbot.eclipse.gef.finder.SWTGefBot#createEditor(org.eclipse
- * .ui.IEditorReference, org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot)
- */
- @Override
- protected GFSWTBotGefEditor createEditor(IEditorReference reference, SWTWorkbenchBot bot) {
- return new GFSWTBotGefEditor(reference, bot);
- }
-
-}