Author: vpakan(a)redhat.com
Date: 2010-08-25 04:18:54 -0400 (Wed, 25 Aug 2010)
New Revision: 24409
Added:
trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/src/org/jboss/tools/vpe/ui/bot/test/editor/MenuItemEntity.java
trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/src/org/jboss/tools/vpe/ui/bot/test/editor/VisualEditorContextMenuTest.java
Modified:
trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/helper/ContextMenuHelper.java
trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/helper/KeyboardHelper.java
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/ViewType.java
trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/src/org/jboss/tools/vpe/ui/bot/test/VPEAllBotTests.java
trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/src/org/jboss/tools/vpe/ui/bot/test/tools/SWTBotWebBrowser.java
Log:
Added VisualEditorContextMenuTest test.
Modified:
trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/helper/ContextMenuHelper.java
===================================================================
---
trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/helper/ContextMenuHelper.java 2010-08-25
08:06:59 UTC (rev 24408)
+++
trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/helper/ContextMenuHelper.java 2010-08-25
08:18:54 UTC (rev 24409)
@@ -49,7 +49,7 @@
public class ContextMenuHelper {
protected static final Logger log = Logger.getLogger(ContextMenuHelper.class);
/**
- * Clicks the context menu matching the text.
+ * Returns the context menu item matching the text.
*
* @param bot bot containing context menu.
* @param text the text on the context menu.
@@ -58,19 +58,42 @@
*/
public static MenuItem getContextMenu(final AbstractSWTBot<?> bot,
final String text, final boolean hideAfterwards) {
- final List<String> foundMenuItems = new Vector<String>();
+ final Menu menu = UIThreadRunnable.syncExec(new WidgetResult<Menu>() {
+ public Menu run() {
+ return getWidgetMenu(bot.widget);
+ }
+ });
+ if (menu == null) {
+ throw new WidgetNotFoundException("Could not find menu of active bot: " +
bot);
+ }
+ else{
+ return ContextMenuHelper.getContextMenu(menu, text, hideAfterwards);
+ }
+
+ }
+ /**
+ * Returns the context menu item matching the text.
+ *
+ * @param menu top parent menu containing menu item.
+ * @param text the text on the context menu.
+ * @param hideAfterwards hide menu when method is finished.
+ * @throws WidgetNotFoundException if the widget is not found.
+ */
+ public static MenuItem getContextMenu(final Menu menu,
+ final String text, final boolean hideAfterwards) {
+ final List<String> foundMenuItems = new Vector<String>();
final MenuItem menuItem = UIThreadRunnable
.syncExec(new WidgetResult<MenuItem>() {
@SuppressWarnings("unchecked")
- public MenuItem run() {
+ public MenuItem run() {
MenuItem menuItem = null;
- Menu menu = getWidgetMenu(bot.widget);
Matcher<?> matcher =
allOf(instanceOf(MenuItem.class),withMnemonic(text));
menuItem = show(menu, matcher, hideAfterwards, foundMenuItems);
+ Menu currentMenu = menu;
if (menuItem != null) {
- menu = menuItem.getMenu();
+ currentMenu = menuItem.getMenu();
} else {
- hide(menu);
+ hide(currentMenu);
}
return menuItem;
}
@@ -91,6 +114,7 @@
return menuItem;
}
}
+
/**
* Simulate Show event to menu and returns MenuItem matching to matcher
* @param menu
@@ -118,16 +142,26 @@
return null;
}
/**
- * Recursively hide menus
+ * Hides menus recursively dependent on hideRecursively parameter
* @param menu bottom menu to start hiding from
+ * @param hideRecursively
*/
- private static void hide(final Menu menu) {
- menu.notifyListeners(SWT.Hide, new Event());
- if (menu.getParentMenu() != null) {
- hide(menu.getParentMenu());
+ private static void hide(final Menu menu , boolean hideRecursively) {
+ if (menu != null){
+ menu.notifyListeners(SWT.Hide, new Event());
+ if (menu.getParentMenu() != null && hideRecursively) {
+ hide(menu.getParentMenu(),hideRecursively);
+ }
}
}
/**
+ * Hides menus recursively dependent on hideRecursively parameter
+ * @param menu bottom menu to start hiding from
+ */
+ private static void hide(final Menu menu) {
+ ContextMenuHelper.hide (menu,true);
+ }
+ /**
* Returns menu of input widget
* @param widget
* @return
@@ -270,204 +304,314 @@
}
private static void click(final MenuItem menuItem) {
- final Event event = new Event();
- event.time = (int) System.currentTimeMillis();
- event.widget = menuItem;
- event.display = menuItem.getDisplay();
- event.type = SWT.Selection;
+ final Event event = new Event();
+ event.time = (int) System.currentTimeMillis();
+ event.widget = menuItem;
+ event.display = menuItem.getDisplay();
+ event.type = SWT.Selection;
- UIThreadRunnable.asyncExec(menuItem.getDisplay(), new VoidResult() {
- public void run() {
- log.info("Click on menu item: " + menuItem.getText());
- menuItem.notifyListeners(SWT.Selection, event);
- }
- });
- }
- /**
- * Returns tree menu which contains menuLabel
- * @param tree
- * @param menuLabel
- * @return
- */
- public static Menu getTreeMenuViaReflections (final Tree tree, final String
menuLabel){
- // Menu has to be already created
- return UIThreadRunnable.syncExec(new WidgetResult<Menu>() {
- public Menu run() {
- Menu result = null;
- Composite parent = tree.getParent();
- while (!(parent instanceof Decorations)){
- parent = parent.getParent();
- }
- try {
- 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){
- if (menus[index] != null){
- MenuItem[] menuItems = menus[index].getItems();
- int menuItemIndex = 0;
- while (topMenuItem == null && menuItemIndex <
menuItems.length){
- if (menuItems[menuItemIndex].getText().equals(menuLabel)){
- topMenuItem = menuItems[menuItemIndex];
- }
- menuItemIndex++;
+ UIThreadRunnable.asyncExec(menuItem.getDisplay(), new VoidResult() {
+ public void run() {
+ log.info("Click on menu item: " + menuItem.getText());
+ menuItem.notifyListeners(SWT.Selection, event);
+ }
+ });
+ }
+
+ /**
+ * Returns tree menu which contains menuLabel
+ *
+ * @param tree
+ * @param menuLabel
+ * @return
+ */
+ public static Menu getTreeMenuViaReflections(final Tree tree,
+ final String menuLabel) {
+ // Menu has to be already created
+ return UIThreadRunnable.syncExec(new WidgetResult<Menu>() {
+ public Menu run() {
+ Menu result = null;
+ Composite parent = tree.getParent();
+ while (!(parent instanceof Decorations)) {
+ parent = parent.getParent();
+ }
+ try {
+ 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) {
+ if (menus[index] != null) {
+ MenuItem[] menuItems = menus[index].getItems();
+ int menuItemIndex = 0;
+ while (topMenuItem == null && menuItemIndex <
menuItems.length) {
+ if (menuItems[menuItemIndex].getText().equals(menuLabel)) {
+ topMenuItem = menuItems[menuItemIndex];
}
+ menuItemIndex++;
}
- index--;
}
- if (topMenuItem != null){
- result = topMenuItem.getParent();
- }
+ index--;
}
- else{
- throw new WidgetNotFoundException("Unable to find MenuItem with label
" + menuLabel);
+ if (topMenuItem != null) {
+ result = topMenuItem.getParent();
}
- } catch (SecurityException se) {
- throw new WidgetNotFoundException("Unable to find MenuItem with label
" + menuLabel,se);
- } catch (NoSuchFieldException nsfe) {
- throw new WidgetNotFoundException("Unable to find MenuItem with label
" + menuLabel,nsfe);
- } catch (IllegalArgumentException iae) {
- throw new WidgetNotFoundException("Unable to find MenuItem with label
" + menuLabel,iae);
- } catch (IllegalAccessException iace) {
- throw new WidgetNotFoundException("Unable to find MenuItem with label
" + menuLabel,iace);
+ } else {
+ throw new WidgetNotFoundException(
+ "Unable to find MenuItem with label " + menuLabel);
}
- return result;
- }});
- }
- /**
- * Simulate Right Click on treeItem
- * @param tree
- * @param treeItem
- */
- public static void treeRightClick(final Tree tree , final TreeItem treeItem) {
- Rectangle cellBounds = UIThreadRunnable.syncExec(new Result<Rectangle>() {
- public Rectangle run() {
- return treeItem.getBounds();
+ } catch (SecurityException se) {
+ throw new WidgetNotFoundException(
+ "Unable to find MenuItem with label " + menuLabel, se);
+ } catch (NoSuchFieldException nsfe) {
+ throw new WidgetNotFoundException(
+ "Unable to find MenuItem with label " + menuLabel, nsfe);
+ } catch (IllegalArgumentException iae) {
+ throw new WidgetNotFoundException(
+ "Unable to find MenuItem with label " + menuLabel, iae);
+ } catch (IllegalAccessException iace) {
+ throw new WidgetNotFoundException(
+ "Unable to find MenuItem with label " + menuLabel, iace);
}
- });
- clickXY(cellBounds.x + (cellBounds.width / 2), cellBounds.y + (cellBounds.height /
2), tree , treeItem);
- }
- /**
- * Simulate Right Click on treeItem on specified position
- * @param x
- * @param y
- * @param tree
- * @param treeItem
- */
- protected static void clickXY(int x, int y,final Tree tree , final TreeItem treeItem)
{
- notifyTree(SWT.MouseEnter,tree,treeItem);
- notifyTree(SWT.MouseMove,tree,treeItem);
- notifyTree(SWT.Activate,tree,treeItem);
- notifyTree(SWT.FocusIn,tree,treeItem);
- notifyTree(SWT.MouseDown, createMouseEvent(x, y, 3, SWT.BUTTON3, 1, tree,
treeItem),tree);
- notifyTree(SWT.MouseUp,createMouseEvent(x, y, 3, SWT.BUTTON3, 1, tree,
treeItem),tree);
- notifyTree(SWT.Selection, createEvent(tree,treeItem),tree);
- notifyTree(SWT.MouseHover,tree,treeItem);
- notifyTree(SWT.MouseMove,tree,treeItem);
- notifyTree(SWT.MouseExit,tree,treeItem);
- notifyTree(SWT.Deactivate,tree,treeItem);
- notifyTree(SWT.FocusOut,tree,treeItem);
- }
- /**
- * Notify tree with Event of specified eventType
- * @param eventType
- * @param tree
- * @param treeItem
- */
- private static void notifyTree(int eventType , Tree tree , TreeItem treeItem) {
- Event event = new Event();
- event.time = (int) System.currentTimeMillis();
- event.widget = tree;
- event.display = tree.getDisplay();
- event.item = treeItem;
+ return result;
+ }
+ });
+ }
- notify(eventType, event, tree);
- }
- /**
- * Notify tree with Event of specified eventType
- * @param eventType
- * @param event
- * @param tree
- */
- private static void notifyTree(int eventType , Event event , Tree tree) {
- notify(eventType, event, tree);
- }
- /**
- * Sends a non-blocking notification of the specified type to the widget.
- *
- * @param eventType the type of event.
- * @param createEvent the event to be sent to the {@link #widget}.
- * @param widget the widget to send the event to.
- */
- protected static void notify(final int eventType, final Event createEvent, final
Widget widget) {
- createEvent.type = eventType;
- widget.getDisplay().asyncExec(new Runnable() {
- public void run() {
- if ((widget == null) || widget.isDisposed()) {
- return;
- }
- widget.notifyListeners(eventType, createEvent);
+ /**
+ * Simulate Right Click on treeItem
+ *
+ * @param tree
+ * @param treeItem
+ */
+ public static void treeRightClick(final Tree tree, final TreeItem treeItem) {
+ Rectangle cellBounds = UIThreadRunnable.syncExec(new Result<Rectangle>() {
+ public Rectangle run() {
+ return treeItem.getBounds();
+ }
+ });
+ clickXY(cellBounds.x + (cellBounds.width / 2), cellBounds.y
+ + (cellBounds.height / 2), tree, treeItem);
+ }
+
+ /**
+ * Simulate Right Click on treeItem on specified position
+ *
+ * @param x
+ * @param y
+ * @param tree
+ * @param treeItem
+ */
+ protected static void clickXY(int x, int y, final Tree tree,
+ final TreeItem treeItem) {
+ notifyTree(SWT.MouseEnter, tree, treeItem);
+ notifyTree(SWT.MouseMove, tree, treeItem);
+ notifyTree(SWT.Activate, tree, treeItem);
+ notifyTree(SWT.FocusIn, tree, treeItem);
+ notifyTree(SWT.MouseDown,
+ createMouseEvent(x, y, 3, SWT.BUTTON3, 1, tree, treeItem), tree);
+ notifyTree(SWT.MouseUp,
+ createMouseEvent(x, y, 3, SWT.BUTTON3, 1, tree, treeItem), tree);
+ notifyTree(SWT.Selection, createEvent(tree, treeItem), tree);
+ notifyTree(SWT.MouseHover, tree, treeItem);
+ notifyTree(SWT.MouseMove, tree, treeItem);
+ notifyTree(SWT.MouseExit, tree, treeItem);
+ notifyTree(SWT.Deactivate, tree, treeItem);
+ notifyTree(SWT.FocusOut, tree, treeItem);
+ }
+
+ /**
+ * Notify tree with Event of specified eventType
+ *
+ * @param eventType
+ * @param tree
+ * @param treeItem
+ */
+ private static void notifyTree(int eventType, Tree tree, TreeItem treeItem) {
+ Event event = new Event();
+ event.time = (int) System.currentTimeMillis();
+ event.widget = tree;
+ event.display = tree.getDisplay();
+ event.item = treeItem;
+
+ notify(eventType, event, tree);
+ }
+
+ /**
+ * Notify tree with Event of specified eventType
+ *
+ * @param eventType
+ * @param event
+ * @param tree
+ */
+ private static void notifyTree(int eventType, Event event, Tree tree) {
+ notify(eventType, event, tree);
+ }
+
+ /**
+ * Sends a non-blocking notification of the specified type to the widget.
+ *
+ * @param eventType
+ * the type of event.
+ * @param createEvent
+ * the event to be sent to the {@link #widget}.
+ * @param widget
+ * the widget to send the event to.
+ */
+ protected static void notify(final int eventType, final Event createEvent,
+ final Widget widget) {
+ createEvent.type = eventType;
+ widget.getDisplay().asyncExec(new Runnable() {
+ public void run() {
+ if ((widget == null) || widget.isDisposed()) {
+ return;
}
- });
+ widget.notifyListeners(eventType, createEvent);
+ }
+ });
- widget.getDisplay().syncExec(new Runnable() {
- public void run() {
- // do nothing, just wait for sync.
+ widget.getDisplay().syncExec(new Runnable() {
+ public void run() {
+ // do nothing, just wait for sync.
+ }
+ });
+ }
+
+ /**
+ * Create a mouse event
+ *
+ * @param x
+ * the x co-ordinate of the mouse event.
+ * @param y
+ * the y co-ordinate of the mouse event.
+ * @param button
+ * the mouse button that was clicked.
+ * @param stateMask
+ * the state of the keyboard modifier keys.
+ * @param count
+ * the number of times the mouse was clicked.
+ * @return an event that encapsulates {@link #widget} and {@link #display}
+ * @since 1.2
+ */
+ protected static Event createMouseEvent(int x, int y, int button,
+ int stateMask, int count, Tree tree, TreeItem treeItem) {
+ Event event = new Event();
+ event.time = (int) System.currentTimeMillis();
+ event.widget = tree;
+ event.display = tree.getDisplay();
+ event.x = x;
+ event.y = y;
+ event.button = button;
+ event.stateMask = stateMask;
+ event.count = count;
+ event.item = treeItem;
+ return event;
+ }
+
+ /**
+ * Create default Event for tree and treeItem
+ *
+ * @param tree
+ * @param treeItem
+ * @return
+ */
+ protected static Event createEvent(Tree tree, TreeItem treeItem) {
+ Event event = new Event();
+ event.time = (int) System.currentTimeMillis();
+ event.widget = tree;
+ event.display = tree.getDisplay();
+ event.item = treeItem;
+ return event;
+ }
+
+ /**
+ * Hide menu and all his parent menus and explicitly call
+ * menu.setVisible(false)
+ *
+ * @param menu
+ */
+ public static void hideMenuRecursively(final Menu menu) {
+ menu.getDisplay().syncExec(new Runnable() {
+ public void run() {
+ ContextMenuHelper.hide(menu, true);
+ menu.setVisible(false);
+ }
+ });
+ }
+
+ /**
+ * Hides one particular menu and explicitly call menu.setVisible(false)
+ *
+ * @param menu
+ */
+ public static void hideMenuNonRecursively(final Menu menu) {
+ menu.getDisplay().syncExec(new Runnable() {
+ public void run() {
+ ContextMenuHelper.hide(menu, false);
+ menu.setVisible(false);
+ }
+ });
+ }
+
+ /**
+ * Returns Menu Items Labels of menu
+ *
+ * @param menu
+ * @return
+ */
+ public static String[] getMenuItemLabels(final Menu menu) {
+
+ String[] result = null;
+
+ result = UIThreadRunnable.syncExec(new Result<String[]>() {
+ public String[] run() {
+ MenuItem[] items = menu.getItems();
+ String[] itemsLabels = new String[items.length];
+ for (int index = 0; index < items.length; index++) {
+ itemsLabels[index] = items[index].getText();
}
- });
- }
- /**
- * Create a mouse event
- *
- * @param x the x co-ordinate of the mouse event.
- * @param y the y co-ordinate of the mouse event.
- * @param button the mouse button that was clicked.
- * @param stateMask the state of the keyboard modifier keys.
- * @param count the number of times the mouse was clicked.
- * @return an event that encapsulates {@link #widget} and {@link #display}
- * @since 1.2
- */
- protected static Event createMouseEvent(int x, int y, int button, int stateMask, int
count, Tree tree , TreeItem treeItem) {
- Event event = new Event();
- event.time = (int) System.currentTimeMillis();
- event.widget = tree;
- event.display = tree.getDisplay();
- event.x = x;
- event.y = y;
- event.button = button;
- event.stateMask = stateMask;
- event.count = count;
- event.item = treeItem;
- return event;
- }
- /**
- * Create default Event for tree and treeItem
- * @param tree
- * @param treeItem
- * @return
- */
- protected static Event createEvent(Tree tree, TreeItem treeItem) {
- Event event = new Event();
- event.time = (int) System.currentTimeMillis();
- event.widget = tree;
- event.display = tree.getDisplay();
- event.item = treeItem;
- return event;
- }
- /**
- * Hide menu and all his parent menus
- * @param menu
- */
- public static void hideMenuRecursively(final Menu menu){
- menu.getDisplay().syncExec(new Runnable() {
- public void run() {
- ContextMenuHelper.hide(menu);
- menu.setVisible(false);
+ return itemsLabels;
+ }
+ });
+
+ ContextMenuHelper.hideMenuRecursively(menu);
+
+ return result;
+
+ }
+
+ /**
+ * Shows menu of menuItem
+ *
+ * @param menuItem
+ * @return
+ */
+ public static Menu showMenuOfMenuItem(final MenuItem menuItem) {
+ Menu result = null;
+
+ result = UIThreadRunnable.syncExec(new Result<Menu>() {
+ public Menu run() {
+ Menu menu = menuItem.getMenu();
+ if (menu != null) {
+ menu.notifyListeners(SWT.Show, new Event());
+ menu.setVisible(true);
}
- });
- }
+ return menu;
+ }
+ });
+
+ return result;
+ }
+ /**
+ * Trim special characters from menu item label used before comparing menu item label
+ * @param menuItemLabel
+ * @return
+ */
+ public static String trimMenuItemLabel (String menuItemLabel){
+ String result = menuItemLabel.trim().replaceAll("\\&",
"").split("\t")[0];
+
+ return result;
+
+ }
}
Modified:
trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/helper/KeyboardHelper.java
===================================================================
---
trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/helper/KeyboardHelper.java 2010-08-25
08:06:59 UTC (rev 24408)
+++
trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/helper/KeyboardHelper.java 2010-08-25
08:18:54 UTC (rev 24409)
@@ -74,10 +74,21 @@
/**
* Simulate typing of key with keyCode via AWT
* @param awtKeyCode
+ * @param modifiers keyboard modifiers such CTRL, ALT, SHIFT ...
*/
- public static void typeKeyCodeUsingAWT (int awtKeyCode){
+ public static void typeKeyCodeUsingAWT (int awtKeyCode , int... modifiers){
+ if (modifiers != null){
+ for (int modifierCode : modifiers){
+ KeyboardHelper.pressKeyCodeUsingAWT(modifierCode);
+ }
+ }
KeyboardHelper.pressKeyCodeUsingAWT(awtKeyCode);
KeyboardHelper.releaseKeyCodeUsingAWT(awtKeyCode);
+ if (modifiers != null){
+ for (int modifierCode : modifiers){
+ KeyboardHelper.releaseKeyCodeUsingAWT(modifierCode);
+ }
+ }
}
/**
* Simulate typing of basic string via AWT
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-08-25
08:06:59 UTC (rev 24408)
+++
trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/types/IDELabel.java 2010-08-25
08:18:54 UTC (rev 24409)
@@ -78,6 +78,9 @@
public static final String NAVIGATION = "Navigation";
public static final String MAXIMIZE_ACTIVE_VIEW_OR_EDITOR = "Maximize Active
View or Editor";
public static final String REFRESH = "Refresh";
+ public static final String CUT = "Cut";
+ public static final String COPY = "Copy";
+ public static final String PASTE = "Paste";
}
public class Button {
@@ -205,6 +208,7 @@
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 static final String PALETTE = "Palette";
}
public class ViewGroup {
Modified:
trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/types/ViewType.java
===================================================================
---
trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/types/ViewType.java 2010-08-25
08:06:59 UTC (rev 24408)
+++
trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/types/ViewType.java 2010-08-25
08:18:54 UTC (rev 24409)
@@ -20,9 +20,8 @@
public enum ViewType {
PACKAGE_EXPLORER, PROJECT_EXPLORER, WELCOME, DATA_SOURCE_EXPLORER,
SERVERS,WEB_PROJECTS,PROBLEMS,DEBUG,GUVNOR_REPOSITORIES,PROPERTIES,
- GUVNOR_RESOURCE_HISTORY,JBOSS_TOOLS_PALETTE;
+ GUVNOR_RESOURCE_HISTORY,JBOSS_TOOLS_PALETTE, PALETTE;
-
public String getGroupLabel() {
String viewLabel = "";
switch (this) {
@@ -37,6 +36,7 @@
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;
+ case PALETTE: viewLabel = IDELabel.ViewGroup.GENERAL; break;
default: fail("Unknown View Type");
}
return viewLabel;
@@ -56,6 +56,7 @@
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;
+ case PALETTE: viewLabel = IDELabel.View.PALETTE; break;
default: fail("Unknown View Type");
}
return viewLabel;
Modified:
trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/src/org/jboss/tools/vpe/ui/bot/test/VPEAllBotTests.java
===================================================================
---
trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/src/org/jboss/tools/vpe/ui/bot/test/VPEAllBotTests.java 2010-08-25
08:06:59 UTC (rev 24408)
+++
trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/src/org/jboss/tools/vpe/ui/bot/test/VPEAllBotTests.java 2010-08-25
08:18:54 UTC (rev 24409)
@@ -8,6 +8,7 @@
import org.jboss.tools.vpe.ui.bot.test.editor.ToggleCommentTest;
import org.jboss.tools.vpe.ui.bot.test.editor.VerificationOfNameSpacesTest;
import org.jboss.tools.vpe.ui.bot.test.editor.JspFileEditingTest;
+import org.jboss.tools.vpe.ui.bot.test.editor.VisualEditorContextMenuTest;
import org.jboss.tools.vpe.ui.bot.test.editor.XhtmlFilePerformanceTest;
import
org.jboss.tools.vpe.ui.bot.test.editor.pagedesign.AddSubstitutedELExpressionFolderScopeTest;
import org.jboss.tools.vpe.ui.bot.test.editor.pagedesign.ToolbarTextFormattingTest;
@@ -65,6 +66,7 @@
suite.addTestSuite(ManagePaletteGroupsTest.class);
suite.addTestSuite(PaletteEditorTest.class);
suite.addTestSuite(ToolbarTextFormattingTest.class);
+ suite.addTestSuite(VisualEditorContextMenuTest.class);
return new TestSetup(suite);
}
Added:
trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/src/org/jboss/tools/vpe/ui/bot/test/editor/MenuItemEntity.java
===================================================================
---
trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/src/org/jboss/tools/vpe/ui/bot/test/editor/MenuItemEntity.java
(rev 0)
+++
trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/src/org/jboss/tools/vpe/ui/bot/test/editor/MenuItemEntity.java 2010-08-25
08:18:54 UTC (rev 24409)
@@ -0,0 +1,115 @@
+/*******************************************************************************
+ * 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.vpe.ui.bot.test.editor;
+
+import java.util.Arrays;
+import java.util.Iterator;
+import java.util.List;
+
+/**
+ * Data Representation for Menu Entity
+ * @author vlado pakan
+ *
+ */
+public class MenuItemEntity {
+ private String label = null;
+ private List<MenuItemEntity> children = null;
+
+ public MenuItemEntity(String label) {
+ super();
+ this.label = label;
+ this.children = null;
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((children == null) ? 0 : children.hashCode());
+ result = prime * result + ((label == null) ? 0 : label.hashCode());
+ return result;
+ }
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ MenuItemEntity other = (MenuItemEntity) obj;
+ if (children == null) {
+ if (other.children != null)
+ return false;
+ } else if(other.children == null){
+ return false;
+ }
+ else {
+ if (children.size() == other.children.size()){
+ Iterator<MenuItemEntity> it = children.iterator();
+ Iterator<MenuItemEntity> itOther = other.children.iterator();
+ while (it.hasNext()){
+ if (!it.next().equals(itOther.next())){
+ return false;
+ }
+ }
+ }
+ else {
+ return false;
+ }
+ }
+ if (label == null) {
+ if (other.label != null)
+ return false;
+ } else if (!label.equals(other.label))
+ return false;
+ return true;
+ }
+
+ public String getLabel() {
+ return label;
+ }
+
+ public void setLabel(String label) {
+ this.label = label;
+ }
+
+ public List<MenuItemEntity> getChildren() {
+ return children;
+ }
+
+ public void setChildren(List<MenuItemEntity> children) {
+ this.children = children;
+ }
+
+ @Override
+ public String toString() {
+ return "MenuItemEntity [label=" + label + "]\nChildren:" +
childrenToString(0);
+ }
+
+ public String childrenToString (int level){
+ char[] fill = new char[level];
+ Arrays.fill(fill, ' ');
+ StringBuffer sb = new StringBuffer(new String(fill));
+ sb.append(getLabel());
+ sb.append("\n");
+ if (children != null){
+ level +=2;
+ for (MenuItemEntity child : children){
+ sb.append(child.childrenToString(level));
+ }
+ }
+
+ return sb.toString();
+
+ }
+
+}
Property changes on:
trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/src/org/jboss/tools/vpe/ui/bot/test/editor/MenuItemEntity.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/src/org/jboss/tools/vpe/ui/bot/test/editor/VisualEditorContextMenuTest.java
===================================================================
---
trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/src/org/jboss/tools/vpe/ui/bot/test/editor/VisualEditorContextMenuTest.java
(rev 0)
+++
trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/src/org/jboss/tools/vpe/ui/bot/test/editor/VisualEditorContextMenuTest.java 2010-08-25
08:18:54 UTC (rev 24409)
@@ -0,0 +1,502 @@
+/*******************************************************************************
+
+ * 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.vpe.ui.bot.test.editor;
+
+import java.awt.event.KeyEvent;
+import java.util.LinkedList;
+import java.util.List;
+
+import org.eclipse.gef.palette.PaletteContainer;
+import org.eclipse.gef.palette.PaletteEntry;
+import org.eclipse.swt.widgets.Menu;
+import org.eclipse.swt.widgets.MenuItem;
+import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotEclipseEditor;
+import org.eclipse.swtbot.swt.finder.finders.UIThreadRunnable;
+import org.eclipse.swtbot.swt.finder.results.VoidResult;
+import org.jboss.tools.ui.bot.ext.SWTBotExt;
+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.KeyboardHelper;
+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 Visual Editor Context Menu
+ * @author vlado pakan
+ *
+ */
+public class VisualEditorContextMenuTest extends VPEEditorTestCase {
+
+ private static final String PAGE_TEXT = "<%@ taglib
uri=\"http://java.sun.com/jsf/html\" prefix=\"h\" %>\n" +
+ "<%@ taglib
uri=\"http://richfaces.org/rich\"
prefix=\"rich\"%>\n" +
+ "<html>\n" +
+ " <body>\n" +
+ " plain text \n" +
+ " <h:outputText value=\"Studio\" />\n" +
+ " <rich:calendar></rich:calendar>\n" +
+ " <h:inputText/>\n" +
+ " <h:inputText/>\n" +
+ " </body>\n" +
+ "</html>";
+
+ private static final String TEST_PAGE_NAME =
"VisualEditorContextMenuTest.jsp";
+
+ private SWTBotExt botExt = null;
+
+ public VisualEditorContextMenuTest() {
+ super();
+ botExt = new SWTBotExt();
+ }
+
+ public void testVisualEditorContextMenu(){
+ eclipse.maximizeActiveShell();
+ createJspPage(VisualEditorContextMenuTest.TEST_PAGE_NAME);
+ final SWTBotEclipseEditor jspTextEditor =
botExt.editorByTitle(VisualEditorContextMenuTest.TEST_PAGE_NAME)
+ .toTextEditor();
+ final SWTBotWebBrowser webBrowser = new
SWTBotWebBrowser(VisualEditorContextMenuTest.TEST_PAGE_NAME,botExt);
+ checkContextMenuOfEmptyPage(webBrowser, jspTextEditor);
+ checkContextMenuOfPlainText(webBrowser, jspTextEditor);
+ checkContextMenuOfComponent(webBrowser, jspTextEditor);
+ checkInsertMenuContent(webBrowser);
+ checkEditMenuFunctionality(webBrowser, jspTextEditor);
+ checkInsertMenuFunctionality(webBrowser, jspTextEditor);
+ jspTextEditor.close();
+ }
+ /**
+ * Checks Context Menu of Empty JSP Page
+ * @param webBrowser
+ * @param jspTextEditor
+ */
+ private void checkContextMenuOfEmptyPage(SWTBotWebBrowser webBrowser ,
SWTBotEclipseEditor jspTextEditor){
+ jspTextEditor.setText("");
+ jspTextEditor.save();
+ jspTextEditor.setFocus();
+ jspTextEditor.selectRange(0, 0, 0);
+ // Test Context menu for empty page
+ checkMenuContent(webBrowser,new String[] {"",
+ SWTBotWebBrowser.INSERT_AROUND_MENU_LABEL,
+ SWTBotWebBrowser.INSERT_BEFORE_MENU_LABEL,
+ SWTBotWebBrowser.INSERT_AFTER_MENU_LABEL,
+ SWTBotWebBrowser.INSERT_INTO_MENU_LABEL,
+ SWTBotWebBrowser.REPLACE_WITH_MENU_LABEL,
+ "",
+ SWTBotWebBrowser.ZOOM_MENU_LABEL,
+ "",
+ SWTBotWebBrowser.PASTE_MENU_LABEL});
+
+ }
+ /**
+ * Checks Context Menu of Plain Text selected within Visual Editor
+ * @param webBrowser
+ * @param jspTextEditor
+ */
+ private void checkContextMenuOfPlainText(SWTBotWebBrowser webBrowser ,
SWTBotEclipseEditor jspTextEditor){
+ jspTextEditor.setText(VisualEditorContextMenuTest.PAGE_TEXT);
+ jspTextEditor.save();
+ jspTextEditor.setFocus();
+ jspTextEditor.selectRange(4, 5, 0);
+ checkMenuContent(webBrowser,new String[] {SWTBotWebBrowser.PARENT_TAG_MENU_LABEL +
" (body)",
+ "",
+ SWTBotWebBrowser.INSERT_AROUND_MENU_LABEL,
+ SWTBotWebBrowser.INSERT_BEFORE_MENU_LABEL,
+ SWTBotWebBrowser.INSERT_AFTER_MENU_LABEL,
+ SWTBotWebBrowser.INSERT_INTO_MENU_LABEL,
+ SWTBotWebBrowser.REPLACE_WITH_MENU_LABEL,
+ "",
+ SWTBotWebBrowser.ZOOM_MENU_LABEL,
+ "",
+ SWTBotWebBrowser.CUT_MENU_LABEL,
+ SWTBotWebBrowser.COPY_MENU_LABEL,
+ SWTBotWebBrowser.PASTE_MENU_LABEL});
+ }
+ /**
+ * Checks Context Menu of Component selected within Visual Editor
+ * @param webBrowser
+ * @param jspTextEditor
+ */
+ private void checkContextMenuOfComponent(SWTBotWebBrowser webBrowser ,
SWTBotEclipseEditor jspTextEditor){
+ jspTextEditor.setFocus();
+ jspTextEditor.selectRange(5, 23, 0);
+ checkMenuContent(webBrowser,new String[] {"<h:outputText>
Attributes",
+ SWTBotWebBrowser.PARENT_TAG_MENU_LABEL + " (body)",
+ "",
+ SWTBotWebBrowser.INSERT_AROUND_MENU_LABEL,
+ SWTBotWebBrowser.INSERT_BEFORE_MENU_LABEL,
+ SWTBotWebBrowser.INSERT_AFTER_MENU_LABEL,
+ SWTBotWebBrowser.INSERT_INTO_MENU_LABEL,
+ SWTBotWebBrowser.REPLACE_WITH_MENU_LABEL,
+ SWTBotWebBrowser.STRIP_TAG_MENU_LABEL,
+ "",
+ SWTBotWebBrowser.ZOOM_MENU_LABEL,
+ "",
+ SWTBotWebBrowser.CUT_MENU_LABEL,
+ SWTBotWebBrowser.COPY_MENU_LABEL,
+ SWTBotWebBrowser.PASTE_MENU_LABEL});
+ }
+ @Override
+ protected void closeUnuseDialogs() {
+
+ }
+
+ @Override
+ protected boolean isUnuseDialogOpened() {
+ return false;
+ }
+ /**
+ * Check content of Visual Editor Context Menu
+ * @param jspTextEditor
+ * @param expectedMenuLabels
+ */
+ private void checkMenuContent(SWTBotWebBrowser webBrowser , String[]
expectedMenuLabels){
+
+ webBrowser.setFocus();
+ bot.sleep(Timing.time1S());
+ String[] menuLabels =
ContextMenuHelper.getMenuItemLabels(webBrowser.getTopMenu(webBrowser.getSelectedDomNode(),
+ SWTBotWebBrowser.INSERT_AROUND_MENU_LABEL));
+ assertMenuContent(menuLabels , expectedMenuLabels);
+ }
+ /**
+ * Asserts equality of arrays containing menu items labels and expected menu items
labels
+ * @param menuItems
+ * @param expectedMenuItems
+ */
+ private void assertMenuContent (String[] menuItems , String[] expectedMenuItems){
+ assertTrue("Visual Editor Context Menu has wrong content:\n" +
+ "It has items:\n" +
+ VisualEditorContextMenuTest.displayFormattedArrayContent(menuItems) +
+ "Expected items are:\n" +
+ VisualEditorContextMenuTest.displayFormattedArrayContent(expectedMenuItems)
+ ,VisualEditorContextMenuTest.menuItemsLabelsEquals(menuItems, expectedMenuItems));
+ }
+ /**
+ * Returns formatted interpretation of stringArray used for displaying strinArray
content
+ * @param stringArray
+ * @return
+ */
+ private static String displayFormattedArrayContent (String[] stringArray){
+ StringBuffer sb = new StringBuffer("");
+
+ if (stringArray != null){
+ if (stringArray.length > 0){
+ for (String item : stringArray){
+ sb.append(item);
+ sb.append("\n");
+ }
+ }
+ else{
+ sb.append("<empty>\n");
+ }
+ }
+ else{
+ sb.append("<null>\n");
+ }
+
+ return sb.toString();
+ }
+ /**
+ * Compare menu items labels stored in string arrays
+ * @param menuLabels1
+ * @param menuLabels2
+ * @return
+ */
+ private static boolean menuItemsLabelsEquals (String[] menuLabels1 , String[]
menuLabels2){
+
+ boolean areEqual = false;
+
+ if (menuLabels1 == null && menuLabels2 == null){
+ areEqual = true;
+ }
+ else if (menuLabels1 != null
+ && menuLabels2 != null
+ && menuLabels1.length == menuLabels2.length){
+ boolean areEqualYet = true;
+ int index = 0;
+ while (areEqualYet && (index < menuLabels1.length)){
+ if (!ContextMenuHelper.trimMenuItemLabel(menuLabels1[index])
+ .equals(menuLabels2[index])){
+ areEqualYet = false;
+ }
+ index++;
+ }
+ if (areEqualYet){
+ areEqual = true;
+ }
+ }
+
+ return areEqual;
+
+ }
+
+ /**
+ * Checks Context Menu Content for Insert* Menus and synchronization of these
+ * menus with JBoss Tools Palette Menus
+ * @param webBrowser
+ */
+ private void checkInsertMenuContent(final SWTBotWebBrowser webBrowser){
+ // Gets Complete Palette Actions Structure
+ MenuItemEntity paletteRootEntity = new MenuItemEntity("root");
+ paletteRootEntity.setChildren(getPaletteActionsStructure());
+ MenuItemEntity contextMenuRootEntity = new MenuItemEntity("root");
+ // Gets Complete Context Menu Structure
+
contextMenuRootEntity.setChildren(getContextMenuStructure(SWTBotWebBrowser.INSERT_AROUND_MENU_LABEL,webBrowser));
+ MenuItemEntity filteredPaleteRootEntity =
filterPaletteMenuForInsertAroundAction(paletteRootEntity);
+ assertTrue("Palette content is different than Context Menu Items for
inserting\n" +
+ "Palette content:\n" + filteredPaleteRootEntity +
+ "\n Context Menu Content:\n" + contextMenuRootEntity,
+ filteredPaleteRootEntity.equals(contextMenuRootEntity));
+ // Gets Complete Context Menu Structure
+
contextMenuRootEntity.setChildren(getContextMenuStructure(SWTBotWebBrowser.INSERT_BEFORE_MENU_LABEL,webBrowser));
+ assertTrue("Palette content is different than Context Menu Items for
inserting\n" +
+ "Palette content:\n" + paletteRootEntity +
+ "\n Context Menu Content:\n" + contextMenuRootEntity,
+ paletteRootEntity.equals(contextMenuRootEntity));
+ // Gets Complete Context Menu Structure
+
contextMenuRootEntity.setChildren(getContextMenuStructure(SWTBotWebBrowser.INSERT_AFTER_MENU_LABEL,webBrowser));
+ assertTrue("Palette content is different than Context Menu Items for
inserting\n" +
+ "Palette content:\n" + paletteRootEntity +
+ "\n Context Menu Content:\n" + contextMenuRootEntity,
+ paletteRootEntity.equals(contextMenuRootEntity));
+ // Gets Complete Context Menu Structure
+
contextMenuRootEntity.setChildren(getContextMenuStructure(SWTBotWebBrowser.INSERT_INTO_MENU_LABEL,webBrowser));
+ assertTrue("Palette content is different than Context Menu Items for
inserting\n" +
+ "Palette content:\n" + paletteRootEntity +
+ "\n Context Menu Content:\n" + contextMenuRootEntity,
+ paletteRootEntity.equals(contextMenuRootEntity));
+ // Gets Complete Context Menu Structure
+
contextMenuRootEntity.setChildren(getContextMenuStructure(SWTBotWebBrowser.REPLACE_WITH_MENU_LABEL,webBrowser));
+ assertTrue("Palette content is different than Context Menu Items for
inserting\n" +
+ "Palette content:\n" + paletteRootEntity +
+ "\n Context Menu Content:\n" + contextMenuRootEntity,
+ paletteRootEntity.equals(contextMenuRootEntity));
+ }
+ /**
+ * Returns complete Palette Actions Structure in data structure
+ * which can be used for comparing with Context Menu Structure
+ * @return
+ */
+ private List<MenuItemEntity> getPaletteActionsStructure(){
+ LinkedList<MenuItemEntity> result = new LinkedList<MenuItemEntity>();
+ List<PaletteContainer> paletteContainers =
SWTBotWebBrowser.getPaletteRootContainers(botExt);
+ MenuItemEntity mainGroup = null;
+ for (PaletteContainer pc : paletteContainers){
+ String[] containerLabelParts = pc.getLabel().split(" ");
+ if (mainGroup == null || !mainGroup.getLabel().equals(containerLabelParts[0])){
+ mainGroup = new MenuItemEntity(containerLabelParts[0]);
+ mainGroup.setChildren(new LinkedList<MenuItemEntity>());
+ result.add(mainGroup);
+ }
+ MenuItemEntity technologyGroup = new MenuItemEntity(containerLabelParts[1]);
+ mainGroup.getChildren().add(technologyGroup);
+ List<PaletteEntry> pes = SWTBotWebBrowser.getPaletteContainerItems(pc);
+ LinkedList<MenuItemEntity> paletteContainerEntries = new
LinkedList<MenuItemEntity>();
+ for (PaletteEntry pe : pes){
+ paletteContainerEntries.add(new MenuItemEntity(pe.getLabel()));
+ }
+ technologyGroup.setChildren(paletteContainerEntries);
+ }
+ return result;
+ }
+ /**
+ * Returns complete Menu Items Structure in data structure
+ * which can be used for comparing with Context Menu Structure
+ * @param topMenuLabel
+ * @param webBrowser
+ * @return
+ */
+ private List<MenuItemEntity> getContextMenuStructure(final String topMenuLabel ,
SWTBotWebBrowser webBrowser){
+ final LinkedList<MenuItemEntity> result = new
LinkedList<MenuItemEntity>();
+ final Menu topMenu = webBrowser.getTopMenu(webBrowser.getSelectedDomNode(),
topMenuLabel);
+
+ UIThreadRunnable.syncExec(new VoidResult() {
+ public void run() {
+ ContextMenuHelper.clickContextMenu(topMenu, topMenuLabel);
+ MenuItem useMenuItem = ContextMenuHelper.getContextMenu(topMenu, topMenuLabel,
false);
+ Menu useMenu = ContextMenuHelper.showMenuOfMenuItem(useMenuItem);
+ for (String firstLevelMenuItemLabel :
ContextMenuHelper.getMenuItemLabels(useMenu)){
+ ContextMenuHelper.clickContextMenu(useMenu, firstLevelMenuItemLabel);
+ MenuItem firstLevelMenuItem = ContextMenuHelper.getContextMenu(useMenu,
firstLevelMenuItemLabel, false);
+ MenuItemEntity firstLevelMenuItemEntity = new
MenuItemEntity(firstLevelMenuItem.getText());
+ result.add(firstLevelMenuItemEntity);
+ Menu firstLevelMenu =
ContextMenuHelper.showMenuOfMenuItem(firstLevelMenuItem);
+ LinkedList<MenuItemEntity> firstMenuItemEntities = new
LinkedList<MenuItemEntity>();
+ firstLevelMenuItemEntity.setChildren(firstMenuItemEntities);
+ for (String secondLevelMenuItemLabel :
ContextMenuHelper.getMenuItemLabels(firstLevelMenu)){
+ ContextMenuHelper.clickContextMenu(firstLevelMenu,
secondLevelMenuItemLabel);
+ MenuItem secondLevelMenuItem =
ContextMenuHelper.getContextMenu(firstLevelMenu, secondLevelMenuItemLabel, false);
+ MenuItemEntity secondLevelMenuItemEntity = new
MenuItemEntity(secondLevelMenuItem.getText());
+ firstMenuItemEntities.add(secondLevelMenuItemEntity);
+ Menu secondLevelMenu =
ContextMenuHelper.showMenuOfMenuItem(secondLevelMenuItem);
+ LinkedList<MenuItemEntity> secondMenuItemEntities = new
LinkedList<MenuItemEntity>();
+ secondLevelMenuItemEntity.setChildren(secondMenuItemEntities);
+ for (String thirdLevelMenuItemLabel :
ContextMenuHelper.getMenuItemLabels(secondLevelMenu)){
+ // trim name space and <,> characters
+ String trimedLabel =
thirdLevelMenuItemLabel.split(":")[1].replaceFirst(">",
"");
+ secondMenuItemEntities.add(new MenuItemEntity(trimedLabel));
+ }
+ }
+ }
+ ContextMenuHelper.hideMenuNonRecursively(useMenu);
+ ContextMenuHelper.hideMenuRecursively(topMenu);
+ }
+ });
+ return result;
+ }
+ /**
+ * Filter Menu Item Entities which are not added to Insert Around Context Menu Action
+ * @param rootMenuItemEntity
+ * @return
+ */
+ private MenuItemEntity filterPaletteMenuForInsertAroundAction(MenuItemEntity
rootMenuItemEntity){
+ MenuItemEntity result = new MenuItemEntity(rootMenuItemEntity.getLabel());
+ LinkedList<MenuItemEntity> newRootChildren = new
LinkedList<MenuItemEntity>();
+ result.setChildren(newRootChildren);
+ for (MenuItemEntity mieFirstLevel : rootMenuItemEntity.getChildren()){
+ String firstLevelMenuItemLabel = mieFirstLevel.getLabel();
+ MenuItemEntity mieNewFirstLevel = new MenuItemEntity(firstLevelMenuItemLabel);
+ newRootChildren.add(mieNewFirstLevel);
+ LinkedList<MenuItemEntity> newFirstLevelChildren = new
LinkedList<MenuItemEntity>();
+ mieNewFirstLevel.setChildren(newFirstLevelChildren);
+ for (MenuItemEntity mieSecondLevel : mieFirstLevel.getChildren()){
+ String secondLevelMenuItemLabel = mieSecondLevel.getLabel();
+ MenuItemEntity mieNewSecondLevel = new MenuItemEntity(secondLevelMenuItemLabel);
+ newFirstLevelChildren.add(mieNewSecondLevel);
+ LinkedList<MenuItemEntity> newSecondLevelChildren = new
LinkedList<MenuItemEntity>();
+ mieNewSecondLevel.setChildren(newSecondLevelChildren);
+ for (MenuItemEntity mieThirdLevel : mieSecondLevel.getChildren()){
+ String thirdLevelMenuItemLabel = mieThirdLevel.getLabel();
+ if (thirdLevelMenuItemLabel.endsWith(" taglib") ||
+ (firstLevelMenuItemLabel.equals("JBoss") &&
secondLevelMenuItemLabel.equals("Ajax4Jsf") &&
thirdLevelMenuItemLabel.equals("queue")) ||
+ (firstLevelMenuItemLabel.equals("JBoss") &&
secondLevelMenuItemLabel.equals("RichFaces") &&
thirdLevelMenuItemLabel.equals("menuSeparator")) ||
+ (firstLevelMenuItemLabel.equals("JBoss") &&
secondLevelMenuItemLabel.equals("Seam") &&
thirdLevelMenuItemLabel.equals("convertEnum")) ||
+ (firstLevelMenuItemLabel.equals("JBoss") &&
secondLevelMenuItemLabel.equals("Seam") &&
thirdLevelMenuItemLabel.equals("convertDateTime")) ||
+ (firstLevelMenuItemLabel.equals("JBoss") &&
secondLevelMenuItemLabel.equals("Seam") &&
thirdLevelMenuItemLabel.equals("enumItem")) ||
+ (firstLevelMenuItemLabel.equals("JBoss") &&
secondLevelMenuItemLabel.equals("Seam") &&
thirdLevelMenuItemLabel.equals("fileUpload")) ||
+ (firstLevelMenuItemLabel.equals("JBoss") &&
secondLevelMenuItemLabel.equals("Seam") &&
thirdLevelMenuItemLabel.equals("validate")) ||
+ (firstLevelMenuItemLabel.equals("JSF") &&
secondLevelMenuItemLabel.equals("HTML") &&
thirdLevelMenuItemLabel.equals("commandButton")) ||
+ (firstLevelMenuItemLabel.equals("JSF") &&
secondLevelMenuItemLabel.equals("HTML") &&
thirdLevelMenuItemLabel.equals("graphicImage")) ||
+ (firstLevelMenuItemLabel.equals("JSF") &&
secondLevelMenuItemLabel.equals("HTML") &&
thirdLevelMenuItemLabel.equals("inputHidden")) ||
+ (firstLevelMenuItemLabel.equals("JSF") &&
secondLevelMenuItemLabel.equals("HTML") &&
thirdLevelMenuItemLabel.equals("inputSecret")) ||
+ (firstLevelMenuItemLabel.equals("JSF") &&
secondLevelMenuItemLabel.equals("HTML") &&
thirdLevelMenuItemLabel.equals("inputText")) ||
+ (firstLevelMenuItemLabel.equals("JSF") &&
secondLevelMenuItemLabel.equals("HTML") &&
thirdLevelMenuItemLabel.equals("message")) ||
+ (firstLevelMenuItemLabel.equals("JSF") &&
secondLevelMenuItemLabel.equals("HTML") &&
thirdLevelMenuItemLabel.equals("messages")) ||
+ (firstLevelMenuItemLabel.equals("JSF") &&
secondLevelMenuItemLabel.equals("HTML") &&
thirdLevelMenuItemLabel.equals("outputText")) ||
+ (firstLevelMenuItemLabel.equals("JSF") &&
secondLevelMenuItemLabel.equals("HTML") &&
thirdLevelMenuItemLabel.equals("selectBooleanCheckbox"))){
+ // Skip these Menu Items
+ }
+ else{
+ MenuItemEntity mieNewThirdLevel = new
MenuItemEntity(thirdLevelMenuItemLabel);
+ newSecondLevelChildren.add(mieNewThirdLevel);
+ }
+ }
+ }
+ }
+
+ return result;
+ }
+ /**
+ * Checks Edit Menu functionality i.e. Cut, Copy and Paste Actions
+ * @param webBrowser
+ * @param jspTextEditor
+ */
+ private void checkEditMenuFunctionality(SWTBotWebBrowser webBrowser ,
SWTBotEclipseEditor jspTextEditor){
+ jspTextEditor.setFocus();
+ jspTextEditor.selectRange(6, 9, 0);
+ webBrowser.setFocus();
+ // Test Cut
+ nsIDOMNode calendarNode = webBrowser.getDomNodeByTagName("INPUT",0);
+ webBrowser.selectDomNode(calendarNode,0);
+ botExt.sleep(Timing.time1S());
+ webBrowser.clickContextMenu(calendarNode, IDELabel.Menu.CUT);
+ botExt.sleep(Timing.time1S());
+ String sourceEditorText = jspTextEditor.getText();
+ assertTrue ("Source Editor should not contain text
'<rich:calendar></rich:calendar>'\nSource Editor Text: " +
+ sourceEditorText,
+
!sourceEditorText.contains("<rich:calendar></rich:calendar>"));
+ // Test Paste
+ webBrowser.setFocus();
+ nsIDOMNode inputTextNode = webBrowser.getDomNodeByTagName("INPUT",0);
+ webBrowser.selectDomNode(inputTextNode,0);
+ webBrowser.clickContextMenu(inputTextNode, IDELabel.Menu.PASTE);
+ botExt.sleep(Timing.time1S());
+ sourceEditorText = jspTextEditor.getText();
+ assertTrue ("Source Editor should contain text
'<rich:calendar></rich:calendar>'\nSource Editor Text: " +
+ sourceEditorText,
+
sourceEditorText.contains("<rich:calendar></rich:calendar>"));
+ // Test Copy
+ calendarNode = webBrowser.getDomNodeByTagName("INPUT",0);
+ webBrowser.setFocus();
+ calendarNode = webBrowser.getDomNodeByTagName("INPUT",0);
+ webBrowser.selectDomNode(calendarNode,0);
+ webBrowser.clickContextMenu(calendarNode, IDELabel.Menu.COPY);
+ inputTextNode = webBrowser.getDomNodeByTagName("INPUT",1);
+ webBrowser.selectDomNode(inputTextNode,0);
+ botExt.sleep(Timing.time1S());
+ webBrowser.clickContextMenu(inputTextNode, IDELabel.Menu.PASTE);
+ botExt.sleep(Timing.time1S());
+ sourceEditorText = jspTextEditor.getText();
+ assertTrue ("Source Editor should not contain text
'<h:inputText/>'\nSource Editor Text: " +
+ sourceEditorText,
+ !sourceEditorText.contains("<h:inputText/>"));
+ // Test editing using keyboard shortcuts
+ jspTextEditor.setFocus();
+ jspTextEditor.setText(VisualEditorContextMenuTest.PAGE_TEXT);
+ jspTextEditor.save();
+ jspTextEditor.selectRange(6, 9, 0);
+ bot.sleep(Timing.time1S());
+ webBrowser.setFocus();
+ // Test Cut
+ calendarNode = webBrowser.getDomNodeByTagName("INPUT",0);
+ webBrowser.selectDomNode(calendarNode,0);
+ botExt.sleep(Timing.time1S());
+ webBrowser.setFocus();
+ KeyboardHelper.typeKeyCodeUsingAWT(KeyEvent.VK_X,KeyEvent.VK_CONTROL);
+ botExt.sleep(Timing.time1S());
+ sourceEditorText = jspTextEditor.getText();
+ assertTrue ("Source Editor should not contain text
'<rich:calendar></rich:calendar>'\nSource Editor Text: " +
+ sourceEditorText,
+
!sourceEditorText.contains("<rich:calendar></rich:calendar>"));
+ // Test Paste
+ webBrowser.setFocus();
+ inputTextNode = webBrowser.getDomNodeByTagName("INPUT",0);
+ webBrowser.selectDomNode(inputTextNode,0);
+ KeyboardHelper.typeKeyCodeUsingAWT(KeyEvent.VK_V,KeyEvent.VK_CONTROL);
+ botExt.sleep(Timing.time1S());
+ sourceEditorText = jspTextEditor.getText();
+ assertTrue ("Source Editor should contain text
'<rich:calendar></rich:calendar>'\nSource Editor Text: " +
+ sourceEditorText,
+
sourceEditorText.contains("<rich:calendar></rich:calendar>"));
+ // Test Copy
+ calendarNode = webBrowser.getDomNodeByTagName("INPUT",0);
+ webBrowser.setFocus();
+ calendarNode = webBrowser.getDomNodeByTagName("INPUT",0);
+ webBrowser.selectDomNode(calendarNode,0);
+ KeyboardHelper.typeKeyCodeUsingAWT(KeyEvent.VK_C,KeyEvent.VK_CONTROL);
+ inputTextNode = webBrowser.getDomNodeByTagName("INPUT",1);
+ webBrowser.selectDomNode(inputTextNode,0);
+ botExt.sleep(Timing.time1S());
+ KeyboardHelper.typeKeyCodeUsingAWT(KeyEvent.VK_V,KeyEvent.VK_CONTROL);
+ botExt.sleep(Timing.time1S());
+ sourceEditorText = jspTextEditor.getText();
+ assertTrue ("Source Editor should not contain text
'<h:inputText/>'\nSource Editor Text: " +
+ sourceEditorText,
+ !sourceEditorText.contains("<h:inputText/>"));
+
+ }
+ /**
+ * Checks Insert Menu Functionality
+ * @param webBrowser
+ * @param jspTextEditor
+ */
+ private void checkInsertMenuFunctionality(SWTBotWebBrowser webBrowser ,
SWTBotEclipseEditor jspTextEditor){
+
+ }
+}
Property changes on:
trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/src/org/jboss/tools/vpe/ui/bot/test/editor/VisualEditorContextMenuTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
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-25
08:06:59 UTC (rev 24408)
+++
trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/src/org/jboss/tools/vpe/ui/bot/test/tools/SWTBotWebBrowser.java 2010-08-25
08:18:54 UTC (rev 24409)
@@ -18,9 +18,11 @@
import java.util.List;
import org.eclipse.gef.EditDomain;
+import org.eclipse.gef.palette.PaletteContainer;
import org.eclipse.gef.palette.PaletteEntry;
import org.eclipse.gef.palette.ToolEntry;
import org.eclipse.gef.ui.palette.PaletteViewer;
+import org.eclipse.gef.ui.views.palette.PaletteView;
import org.eclipse.swt.browser.Browser;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Decorations;
@@ -37,9 +39,9 @@
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.jst.jsp.jspeditor.PalettePageImpl;
import org.jboss.tools.ui.bot.ext.SWTBotExt;
import org.jboss.tools.ui.bot.ext.SWTEclipseExt;
import org.jboss.tools.ui.bot.ext.Timing;
@@ -72,12 +74,18 @@
*
*/
public class SWTBotWebBrowser {
+ public static final String PARENT_TAG_MENU_LABEL = "Parent Tag";
public static final String INSERT_AROUND_MENU_LABEL = "Insert around";
public static final String INSERT_BEFORE_MENU_LABEL = "Insert before";
public static final String INSERT_AFTER_MENU_LABEL = "Insert after";
public static final String INSERT_INTO_MENU_LABEL = "Insert into";
public static final String REPLACE_WITH_MENU_LABEL = "Replace with";
public static final String STRIP_TAG_MENU_LABEL = "Strip Tag";
+ public static final String ZOOM_MENU_LABEL = "Zoom";
+ public static final String CUT_MENU_LABEL = "Cut";
+ public static final String COPY_MENU_LABEL = "Copy";
+ public static final String PASTE_MENU_LABEL = "Paste";
+
public static final String JSF_MENU_LABEL = "JSF";
public static final String HTML_MENU_LABEL = "HTML";
public static final String H_OUTPUT_TEXT_TAG_MENU_LABEL =
"<h:outputText>";
@@ -295,97 +303,8 @@
* @param menus
*/
public void clickContextMenu(final nsIDOMNode node , final String... menuLabels){
- // Create Context Menu Event
- final nsIDOMEvent domEvent = new nsIDOMEvent() {
-
- public nsISupports queryInterface(String arg0) {
- return XPCOM.queryInterface(node,nsISupports.class);
- }
- public void stopPropagation() {
- }
- public void preventDefault() {
- }
- public void initEvent(String arg0, boolean arg1, boolean arg2) {
- }
- public String getType() {
- return "contextmenu";
- }
- public double getTimeStamp() {
- return 0;
- }
- public nsIDOMEventTarget getTarget() {
- return XPCOM.queryInterface(node,nsIDOMEventTarget.class);
- }
- public int getEventPhase() {
- return 0;
- }
-
- public nsIDOMEventTarget getCurrentTarget() {
- return XPCOM.queryInterface(node,nsIDOMEventTarget.class);
- }
- public boolean getCancelable() {
- return false;
- }
- public boolean getBubbles() {
- return false;
- }
- };
- // Simulate Context Menu Event
- display.syncExec(new Runnable() {
- public void run() {
- getMozillaEventAdapter().handleEvent(domEvent);
- }
- });
- // Get Top Menu
- Menu topMenu = UIThreadRunnable.syncExec(new WidgetResult<Menu>() {
- public Menu run() {
- Menu result = null;
- Composite parent = mozillaEditor.getControl().getParent();
- while (!(parent instanceof Decorations)){
- parent = parent.getParent();
- }
- try {
- 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){
- if (menus[index] != null){
- MenuItem[] menuItems = menus[index].getItems();
- int menuItemIndex = 0;
- while (topMenuItem == null && menuItemIndex <
menuItems.length){
- if (menuItems[menuItemIndex].getText().equals(menuLabels[0])){
- topMenuItem = menuItems[menuItemIndex];
- }
- menuItemIndex++;
- }
- }
- index--;
- }
- if (topMenuItem != null){
- result = topMenuItem.getParent();
- }
- }
- else{
- throw new WidgetNotFoundException("Unable to find MenuItem with label
" + menuLabels[0]);
- }
- } catch (SecurityException se) {
- throw new WidgetNotFoundException("Unable to find MenuItem with label
" + menuLabels[0],se);
- } catch (NoSuchFieldException nsfe) {
- throw new WidgetNotFoundException("Unable to find MenuItem with label
" + menuLabels[0],nsfe);
- } catch (IllegalArgumentException iae) {
- throw new WidgetNotFoundException("Unable to find MenuItem with label
" + menuLabels[0],iae);
- } catch (IllegalAccessException iace) {
- throw new WidgetNotFoundException("Unable to find MenuItem with label
" + menuLabels[0],iace);
- }
- return result;
- }});
-
+ Menu topMenu = getTopMenu(node, menuLabels[0]);
ContextMenuHelper.clickContextMenu(topMenu, menuLabels);
-
}
/**
* Returns node corresponding to specified tagName
@@ -488,7 +407,7 @@
* @return
*/
private static PaletteViewer getPaletteViewer (SWTBotExt bot){
- SWTEclipseExt.showView(bot, ViewType.JBOSS_TOOLS_PALETTE);
+ SWTEclipseExt.showView(bot, ViewType.PALETTE);
IViewReference ref = UIThreadRunnable
.syncExec(new Result<IViewReference>() {
@@ -498,7 +417,7 @@
viewReferences = PlatformUI.getWorkbench()
.getActiveWorkbenchWindow().getActivePage().getViewReferences();
for (IViewReference reference : viewReferences) {
- if (reference.getTitle().equals("JBoss Tools Palette")) {
+ if (reference.getTitle().equals(ViewType.PALETTE.getViewLabel())) {
return reference;
}
}
@@ -506,15 +425,15 @@
}
});
// Find Palette Viewer dirty way
- PaletteViewPart pvp = (PaletteViewPart) ref.getPart(true);
+ PaletteView pv = (PaletteView)ref.getPart(true);
+ PalettePageImpl ppi = (PalettePageImpl)pv.getCurrentPage();
try {
PaletteCreator pc = ReflectionsHelper.getPrivateFieldValue(
- PaletteViewPart.class, "paletteCreator", pvp, PaletteCreator.class);
+ PalettePageImpl.class, "paletteCreator", ppi, PaletteCreator.class);
PaletteAdapter pa = ReflectionsHelper.getPrivateFieldValue(
PaletteCreator.class, "paletteAdapter", pc, PaletteAdapter.class);
PaletteViewer paletteViewer = ReflectionsHelper.getPrivateFieldValue(
PaletteAdapter.class, "viewer", pa, PaletteViewer.class);
-
return paletteViewer;
} catch (SecurityException e) {
throw new RuntimeException(e);
@@ -583,4 +502,145 @@
result =
getSelectionController().getSelection(nsISelectionController.SELECTION_NORMAL);
return result;
}
+ /**
+ * Returns top context menu of Visual Editor
+ * @param node
+ * @param topMenuItemLabel
+ * @return
+ */
+ public Menu getTopMenu(final nsIDOMNode node , final String topMenuItemLabel){
+ // Create Context Menu Event
+ final nsIDOMEvent domEvent = new nsIDOMEvent() {
+
+ public nsISupports queryInterface(String arg0) {
+ return node != null ? XPCOM.queryInterface(node,nsISupports.class) : null;
+ }
+ public void stopPropagation() {
+ }
+ public void preventDefault() {
+ }
+ public void initEvent(String arg0, boolean arg1, boolean arg2) {
+ }
+ public String getType() {
+ return "contextmenu";
+ }
+ public double getTimeStamp() {
+ return 0;
+ }
+ public nsIDOMEventTarget getTarget() {
+ return node != null ? XPCOM.queryInterface(node,nsIDOMEventTarget.class) : null;
+ }
+ public int getEventPhase() {
+ return 0;
+ }
+
+ public nsIDOMEventTarget getCurrentTarget() {
+ return node != null ? XPCOM.queryInterface(node,nsIDOMEventTarget.class) : null;
+ }
+ public boolean getCancelable() {
+ return false;
+ }
+ public boolean getBubbles() {
+ return false;
+ }
+ };
+ // Simulate Context Menu Event
+ display.syncExec(new Runnable() {
+ public void run() {
+ getMozillaEventAdapter().handleEvent(domEvent);
+ }
+ });
+ // Get Top Menu
+ return UIThreadRunnable.syncExec(new WidgetResult<Menu>() {
+ public Menu run() {
+ Menu result = null;
+ Composite parent = mozillaEditor.getControl().getParent();
+ while (!(parent instanceof Decorations)){
+ parent = parent.getParent();
+ }
+ try {
+ 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){
+ if (menus[index] != null){
+ MenuItem[] menuItems = menus[index].getItems();
+ int menuItemIndex = 0;
+ while (topMenuItem == null && menuItemIndex <
menuItems.length){
+ if
(ContextMenuHelper.trimMenuItemLabel(menuItems[menuItemIndex].getText())
+ .equals(topMenuItemLabel)){
+ topMenuItem = menuItems[menuItemIndex];
+ }
+ menuItemIndex++;
+ }
+ }
+ index--;
+ }
+ if (topMenuItem != null){
+ result = topMenuItem.getParent();
+ }
+ }
+ else{
+ throw new WidgetNotFoundException("Unable to find MenuItem with label
" + topMenuItemLabel);
+ }
+ } catch (SecurityException se) {
+ throw new WidgetNotFoundException("Unable to find MenuItem with label
" + topMenuItemLabel,se);
+ } catch (NoSuchFieldException nsfe) {
+ throw new WidgetNotFoundException("Unable to find MenuItem with label
" + topMenuItemLabel,nsfe);
+ } catch (IllegalArgumentException iae) {
+ throw new WidgetNotFoundException("Unable to find MenuItem with label
" + topMenuItemLabel,iae);
+ } catch (IllegalAccessException iace) {
+ throw new WidgetNotFoundException("Unable to find MenuItem with label
" + topMenuItemLabel,iace);
+ }
+ return result;
+ }});
+
+ }
+ /**
+ * Returns Palette Containers
+ * @param bot
+ * @return
+ */
+ public static final List<PaletteContainer> getPaletteRootContainers (SWTBotExt
bot) {
+ List<PaletteContainer> result = null;
+ final PaletteViewer paletteViewer = SWTBotWebBrowser.getPaletteViewer(bot);
+ result = UIThreadRunnable.syncExec(new
Result<LinkedList<PaletteContainer>> (){
+ public LinkedList<PaletteContainer> run() {
+ LinkedList<PaletteContainer> paletteContainers = new
LinkedList<PaletteContainer>();
+ for (Object o : paletteViewer.getPaletteRoot().getChildren()){
+ if (o instanceof PaletteContainer){
+ paletteContainers.add((PaletteContainer)o);
+ }
+ }
+ return paletteContainers;
+ }
+ });
+
+ return result;
+ }
+ /**
+ * Returns Palette Entries of paletteContainer
+ * @param paletteContainer
+ * @return
+ */
+ public static final List<PaletteEntry> getPaletteContainerItems (final
PaletteContainer paletteContainer) {
+ List<PaletteEntry> result = null;
+ result = UIThreadRunnable.syncExec(new Result<LinkedList<PaletteEntry>>
(){
+ public LinkedList<PaletteEntry> run() {
+ LinkedList<PaletteEntry> paletteEntries = new
LinkedList<PaletteEntry>();
+ for (Object o : paletteContainer.getChildren()){
+ if (o instanceof PaletteEntry && !(o instanceof PaletteContainer)){
+ paletteEntries.add((PaletteEntry)o);
+ }
+ }
+ return paletteEntries;
+ }
+ });
+ return result;
+ }
+
}