Author: jpeterka
Date: 2010-09-17 08:45:15 -0400 (Fri, 17 Sep 2010)
New Revision: 24983
Added:
trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/widgets/SWTBotTreeExt.java
Modified:
trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/SWTEclipseExt.java
trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/parts/ObjectMultiPageEditorBot.java
trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/types/IDELabel.java
Log:
SWTBotTreeExt added
IDELabel consts added
ObjectMultipageEditor issue fixed
EclipseExt closeView updated
Modified:
trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/SWTEclipseExt.java
===================================================================
---
trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/SWTEclipseExt.java 2010-09-17
12:32:40 UTC (rev 24982)
+++
trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/SWTEclipseExt.java 2010-09-17
12:45:15 UTC (rev 24983)
@@ -96,7 +96,11 @@
* Close view by text
*/
public void closeView(String view) {
- bot.viewByTitle(view).close();
+ try {
+ bot.viewByTitle(view).close();
+ } catch (WidgetNotFoundException ex) {
+ log.info("WARN - Can't close the view \"" + view +
"\"");
+ }
}
/**
Modified:
trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/parts/ObjectMultiPageEditorBot.java
===================================================================
---
trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/parts/ObjectMultiPageEditorBot.java 2010-09-17
12:32:40 UTC (rev 24982)
+++
trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/parts/ObjectMultiPageEditorBot.java 2010-09-17
12:45:15 UTC (rev 24983)
@@ -6,6 +6,10 @@
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.log4j.Logger;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotEditor;
import org.eclipse.swtbot.swt.finder.finders.UIThreadRunnable;
@@ -15,33 +19,38 @@
import org.eclipse.ui.PartInitException;
import org.eclipse.ui.PlatformUI;
+
/**
- *
+ *
* @author jpeterka
*
*/
public class ObjectMultiPageEditorBot {
-
+
+ private Logger log = Logger.getLogger(ObjectMultiPageEditorBot.class);
private final IEditorReference ref;
-
+
public ObjectMultiPageEditorBot(String title) {
ref = getEditorReferenceByTitle(title);
}
public ObjectMultiPageEditorBot(SWTBotEditor editor) {
ref = editor.getReference();
}
-
+
public IEditorReference getEditorReference() {
return ref;
}
- private IEditorReference getEditorReferenceByTitle(final String title) {
+ private IEditorReference getEditorReferenceByTitle(final String title) {
// Search for editor
IEditorReference ref = UIThreadRunnable.syncExec(new Result<IEditorReference>()
{
public IEditorReference run() {
+
+
+
IEditorReference ref = null;
IEditorReference[] editorReferences = null;
editorReferences =
PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getEditorReferences();
-
+
try {
for (IEditorReference reference: editorReferences) {
IEditorInput input = reference.getEditorInput();
@@ -53,33 +62,59 @@
} catch (PartInitException ex) {
fail(ex.toString());
}
- return ref;
+ return ref;
}
});
-
+
assertNotNull(ref);
return ref;
}
-
- public void selectPage(final String pageName) {
-
+
+
+
+ /**
+ * Returns list of classes which are super classes of the given class
+ * @param list - empty list of classes
+ * @param clazz - first class
+ */
+ private void getSuperclassesList(List<Class<? extends Object>> list,
Class<? extends Object> clazz) {
+
+ Class<? extends Object> superClass = clazz.getSuperclass();
+
+ if (!superClass.getCanonicalName().equalsIgnoreCase("java.lang.Object")) {
+ list.add(superClass);
+ getSuperclassesList(list, superClass);
+ }
+ return;
+ }
+
+
+ public void selectPage(final String pageName) {
+
final Object editor = ref.getPart(true);
boolean found = false;
- for (Class<?> cl : editor.getClass().getDeclaredClasses()) {
- System.out.println(cl.getName());
- if
(cl.getName().equals("org.jboss.tools.common.editor.ObjectMultiPageEditor")) {
- found=true;break;
+
+ //ObjectMultiPageEditor editor = new ObjectMultiPageEditor();
+ List<Class<? extends Object>> cl = new ArrayList<Class<? extends
Object>>();
+ getSuperclassesList(cl, editor.getClass());
+ for (Class<? extends Object> c : cl) {
+ log.info(c.getCanonicalName());
+ if
(c.getCanonicalName().equals("org.jboss.tools.common.editor.ObjectMultiPageEditor"))
{
+ found = true;
+ break;
}
}
- assertTrue("Editor is not instance of ObjectMultiPageEditor",found);
+
+ assertTrue("Editor is not instance of ObjectMultiPageEditor, rep.
HibConfig3CompoundEditor",found);
+
try {
final Method m = editor.getClass().getMethod("selectPageByName",
String.class);
// Select page
- Display.getDefault().syncExec(new Runnable() {
-
+ Display.getDefault().asyncExec(new Runnable() {
+
public void run() {
try {
- m.invoke(editor, pageName);
+ m.invoke(editor, pageName);
} catch (IllegalArgumentException e) {
// TODO Auto-generated catch block
e.printStackTrace();
@@ -99,8 +134,7 @@
// TODO Auto-generated catch block
e.printStackTrace();
}
-
+
}
}
-
\ No newline at end of file
Modified:
trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/types/IDELabel.java
===================================================================
---
trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/types/IDELabel.java 2010-09-17
12:32:40 UTC (rev 24982)
+++
trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/types/IDELabel.java 2010-09-17
12:45:15 UTC (rev 24983)
@@ -164,7 +164,7 @@
public class EntityLabel {
public static final String HIBERNATE_MAPPING_FILE = "Hibernate XML Mapping file
(hbm.xml)";
- public static final String HIBERNATE_REVERSE_FILE = "Hibernate Reverse Engineering
File(reveng.xml)";
+ public static final String HIBERNATE_REVERSE_FILE = "Hibernate Reverse Engineering
File (reveng.xml)";
public static final String HIBERNATE_CONSOLE = "Hibernate Console
Configuration";
public static final String JAVA_CLASS = "Class";
public static final String JAVA_PROJECT = "Java Project";
Added:
trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/widgets/SWTBotTreeExt.java
===================================================================
---
trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/widgets/SWTBotTreeExt.java
(rev 0)
+++
trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/widgets/SWTBotTreeExt.java 2010-09-17
12:45:15 UTC (rev 24983)
@@ -0,0 +1,27 @@
+package org.jboss.tools.ui.bot.ext.widgets;
+
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotTree;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem;
+
+public class SWTBotTreeExt {
+ SWTBotTree tree;
+
+ /**
+ * SWTBotTreeExt contstructor
+ * @param tree
+ */
+ public SWTBotTreeExt(SWTBotTree tree) {
+ this.tree = tree;
+ }
+
+ /**
+ * Expands whole tree
+ */
+ public void expandAll() {
+ SWTBotTreeItem[] items = tree.getAllItems();
+ for (SWTBotTreeItem i : items ) {
+ if (!i.isExpanded())
+ i.expand();
+ }
+ }
+}
Property changes on:
trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/widgets/SWTBotTreeExt.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Show replies by date