Author: ljelinko
Date: 2012-02-07 10:58:30 -0500 (Tue, 07 Feb 2012)
New Revision: 38474
Added:
trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/logging/
trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/logging/BasicWidgetsVisitor.java
trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/logging/LogWidgetsVisitor.java
trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/logging/VisitableWidget.java
trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/logging/WidgetVisitor.java
trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/logging/WidgetsFinder.java
trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/logging/WidgetsLogger.java
Removed:
trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/task/debug/
trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/task/finder/
Modified:
trunk/tests/plugins/org.jboss.tools.ui.bot.ext/META-INF/MANIFEST.MF
trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/log4j.xml
Log:
Moved logging functionality from portlet to swtbotext
Modified: trunk/tests/plugins/org.jboss.tools.ui.bot.ext/META-INF/MANIFEST.MF
===================================================================
--- trunk/tests/plugins/org.jboss.tools.ui.bot.ext/META-INF/MANIFEST.MF 2012-02-07
15:49:35 UTC (rev 38473)
+++ trunk/tests/plugins/org.jboss.tools.ui.bot.ext/META-INF/MANIFEST.MF 2012-02-07
15:58:30 UTC (rev 38474)
@@ -16,6 +16,7 @@
org.jboss.tools.ui.bot.ext.gen,
org.jboss.tools.ui.bot.ext.generator,
org.jboss.tools.ui.bot.ext.helper,
+ org.jboss.tools.ui.bot.ext.logging,
org.jboss.tools.ui.bot.ext.matcher,
org.jboss.tools.ui.bot.ext.parts,
org.jboss.tools.ui.bot.ext.types,
Modified: trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/log4j.xml
===================================================================
--- trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/log4j.xml 2012-02-07 15:49:35 UTC
(rev 38473)
+++ trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/log4j.xml 2012-02-07 15:58:30 UTC
(rev 38474)
@@ -50,6 +50,10 @@
<!-- set to a value higher than debug to turn on. -->
<priority value="DEBUG" />
</category>
+
+ <category name="org.jboss.tools.ui.bot.ext.logging">
+ <priority value="ALL" />
+ </category>
<category name="org.eclipse.swtbot">
<priority value="ALL" />
Copied:
trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/logging/BasicWidgetsVisitor.java
(from rev 38107,
trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/task/finder/BasicWidgetsVisitor.java)
===================================================================
---
trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/logging/BasicWidgetsVisitor.java
(rev 0)
+++
trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/logging/BasicWidgetsVisitor.java 2012-02-07
15:58:30 UTC (rev 38474)
@@ -0,0 +1,170 @@
+package org.jboss.tools.ui.bot.ext.logging;
+
+import javax.swing.table.TableColumn;
+
+import org.eclipse.swt.browser.Browser;
+import org.eclipse.swt.custom.CCombo;
+import org.eclipse.swt.custom.CLabel;
+import org.eclipse.swt.custom.CTabItem;
+import org.eclipse.swt.custom.StyledText;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Combo;
+import org.eclipse.swt.widgets.DateTime;
+import org.eclipse.swt.widgets.ExpandBar;
+import org.eclipse.swt.widgets.ExpandItem;
+import org.eclipse.swt.widgets.Group;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Link;
+import org.eclipse.swt.widgets.List;
+import org.eclipse.swt.widgets.Menu;
+import org.eclipse.swt.widgets.Scale;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Slider;
+import org.eclipse.swt.widgets.Spinner;
+import org.eclipse.swt.widgets.TabItem;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.swt.widgets.TableItem;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.swt.widgets.ToolBar;
+import org.eclipse.swt.widgets.ToolItem;
+import org.eclipse.swt.widgets.Tray;
+import org.eclipse.swt.widgets.Tree;
+import org.eclipse.swt.widgets.TreeItem;
+import org.eclipse.swt.widgets.Widget;
+import org.eclipse.ui.forms.widgets.Hyperlink;
+
+/**
+ * Distinguishes basic types that are known for SWTBot.
+ *
+ * @author Lucia Jelinkova
+ *
+ */
+public abstract class BasicWidgetsVisitor implements WidgetVisitor {
+
+ @Override
+ public void visit(Widget widget) {
+ if (widget instanceof Button){
+ visitButton((Button) widget);
+ } else if (widget instanceof Browser){
+ visitBrowser((Browser) widget);
+ } else if (widget instanceof CCombo){
+ visitCCombo((CCombo) widget);
+ } else if (widget instanceof CLabel){
+ visitCLabel((CLabel) widget);
+ } else if (widget instanceof Combo){
+ visitCombo((Combo) widget);
+ } else if (widget instanceof CTabItem){
+ visitCTabItem((CTabItem) widget);
+ } else if (widget instanceof DateTime){
+ visitDateTime((DateTime) widget);
+ } else if (widget instanceof ExpandBar){
+ visitExpandBar((ExpandBar) widget);
+ } else if (widget instanceof ExpandItem){
+ visitExpandItem((ExpandItem) widget);
+ } else if (widget instanceof Label){
+ visitLabel((Label) widget);
+ } else if (widget instanceof Link){
+ visitLink((Link) widget);
+ } else if (widget instanceof List){
+ visitList((List) widget);
+ } else if (widget instanceof Menu){
+ visitMenu((Menu) widget);
+ } else if (widget instanceof Scale){
+ visitScale((Scale) widget);
+ } else if (widget instanceof Shell){
+ visitShell((Shell) widget);
+ } else if (widget instanceof Slider){
+ visitSlider((Slider) widget);
+ } else if (widget instanceof Spinner){
+ visitSpinner((Spinner) widget);
+ } else if (widget instanceof StyledText){
+ visitStyledText((StyledText) widget);
+ } else if (widget instanceof TabItem){
+ visitTabItem((TabItem) widget);
+ } else if (widget instanceof Table){
+ visitTable((Table) widget);
+ } else if (widget instanceof TableItem){
+ visitTableItem((TableItem) widget);
+ } else if (widget instanceof Text){
+ visitText((Text) widget);
+ } else if (widget instanceof ToolBar){
+ visitToolBar((ToolBar) widget);
+ } else if (widget instanceof ToolItem){
+ visitToolItem((ToolItem) widget);
+ } else if (widget instanceof Tray){
+ visitTray((Tray) widget);
+ } else if (widget instanceof Tree){
+ visitTree((Tree) widget);
+ } else if (widget instanceof TreeItem){
+ visitTreeItem((TreeItem) widget);
+ } else if (widget instanceof Hyperlink){
+ visitHyperLink((Hyperlink) widget);
+ } else if (widget instanceof Group){
+ visitGroup((Group) widget);
+ } else {
+ visitUnkownItem(widget);
+ }
+ }
+
+ protected abstract void visitButton(Button widget);
+
+ protected abstract void visitBrowser(Browser widget);
+
+ protected abstract void visitCCombo(CCombo widget);
+
+ protected abstract void visitCLabel(CLabel widget);
+
+ protected abstract void visitCombo(Combo widget);
+
+ protected abstract void visitCTabItem(CTabItem widget);
+
+ protected abstract void visitDateTime(DateTime widget);
+
+ protected abstract void visitExpandBar(ExpandBar widget);
+
+ protected abstract void visitExpandItem(ExpandItem widget);
+
+ protected abstract void visitLabel(Label widget);
+
+ protected abstract void visitLink(Link widget);
+
+ protected abstract void visitList(List widget);
+
+ protected abstract void visitMenu(Menu widget);
+
+ protected abstract void visitScale(Scale widget);
+
+ protected abstract void visitShell(Shell widget);
+
+ protected abstract void visitSlider(Slider widget);
+
+ protected abstract void visitSpinner(Spinner widget);
+
+ protected abstract void visitStyledText(StyledText widget);
+
+ protected abstract void visitTabItem(TabItem widget);
+
+ protected abstract void visitTable(Table widget);
+
+ protected abstract void visitTableColumn(TableColumn widget);
+
+ protected abstract void visitTableItem(TableItem widget);
+
+ protected abstract void visitText(Text widget);
+
+ protected abstract void visitToolBar(ToolBar widget);
+
+ protected abstract void visitToolItem(ToolItem widget);
+
+ protected abstract void visitTray(Tray widget);
+
+ protected abstract void visitTree(Tree widget);
+
+ protected abstract void visitTreeItem(TreeItem widget);
+
+ protected abstract void visitHyperLink(Hyperlink widget);
+
+ protected abstract void visitGroup(Group widget);
+
+ protected abstract void visitUnkownItem(Widget widget);
+}
Added:
trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/logging/LogWidgetsVisitor.java
===================================================================
---
trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/logging/LogWidgetsVisitor.java
(rev 0)
+++
trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/logging/LogWidgetsVisitor.java 2012-02-07
15:58:30 UTC (rev 38474)
@@ -0,0 +1,236 @@
+package org.jboss.tools.ui.bot.ext.logging;
+
+import javax.swing.table.TableColumn;
+
+import org.apache.log4j.Logger;
+import org.eclipse.swt.browser.Browser;
+import org.eclipse.swt.custom.CCombo;
+import org.eclipse.swt.custom.CLabel;
+import org.eclipse.swt.custom.CTabItem;
+import org.eclipse.swt.custom.StyledText;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Combo;
+import org.eclipse.swt.widgets.DateTime;
+import org.eclipse.swt.widgets.ExpandBar;
+import org.eclipse.swt.widgets.ExpandItem;
+import org.eclipse.swt.widgets.Group;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Link;
+import org.eclipse.swt.widgets.List;
+import org.eclipse.swt.widgets.Menu;
+import org.eclipse.swt.widgets.Scale;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Slider;
+import org.eclipse.swt.widgets.Spinner;
+import org.eclipse.swt.widgets.TabItem;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.swt.widgets.TableItem;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.swt.widgets.ToolBar;
+import org.eclipse.swt.widgets.ToolItem;
+import org.eclipse.swt.widgets.Tray;
+import org.eclipse.swt.widgets.Tree;
+import org.eclipse.swt.widgets.TreeItem;
+import org.eclipse.swt.widgets.Widget;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotTree;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem;
+import org.eclipse.ui.forms.widgets.Hyperlink;
+
+class LogWidgetsVisitor extends BasicWidgetsVisitor {
+
+ private Logger log = Logger.getLogger(LogWidgetsVisitor.class);
+
+ @Override
+ protected void visitButton(Button widget) {
+ log.info(widget);
+ }
+
+ @Override
+ protected void visitBrowser(Browser widget) {
+ log.info(widget);
+ }
+
+ @Override
+ protected void visitCCombo(CCombo widget) {
+ log.info(widget);
+ }
+
+ @Override
+ protected void visitCLabel(CLabel widget) {
+ log.info(widget);
+ }
+
+ @Override
+ protected void visitCombo(Combo widget) {
+ StringBuilder text = new StringBuilder();
+ text.append("Combo {");
+ text.append("selected = '");
+ text.append(widget.getText());
+ text.append("', ");
+ text.append("items = {");
+ for (String item : widget.getItems()){
+ text.append(item + ", ");
+ }
+ text.append("}");
+ text.append("}");
+ log.info(text.toString());
+ }
+
+ @Override
+ protected void visitCTabItem(CTabItem widget) {
+ log.info(widget);
+ }
+
+ @Override
+ protected void visitDateTime(DateTime widget) {
+ log.info(widget);
+ }
+
+ @Override
+ protected void visitExpandBar(ExpandBar widget) {
+ log.info(widget);
+ }
+
+ @Override
+ protected void visitExpandItem(ExpandItem widget) {
+ log.info(widget);
+ }
+
+ @Override
+ protected void visitLabel(Label widget) {
+ log.info(widget);
+ }
+
+ @Override
+ protected void visitLink(Link widget) {
+ log.info(widget);
+ }
+
+ @Override
+ protected void visitList(List widget) {
+ log.info(widget);
+ }
+
+ @Override
+ protected void visitMenu(Menu widget) {
+ log.info(widget);
+ }
+
+ @Override
+ protected void visitScale(Scale widget) {
+ log.info(widget);
+ }
+
+ @Override
+ protected void visitShell(Shell widget) {
+ log.info(widget);
+ }
+
+ @Override
+ protected void visitSlider(Slider widget) {
+ log.info(widget);
+ }
+
+ @Override
+ protected void visitSpinner(Spinner widget) {
+ log.info(widget);
+ }
+
+ @Override
+ protected void visitStyledText(StyledText widget) {
+ log.info(widget);
+ }
+
+ @Override
+ protected void visitTabItem(TabItem widget) {
+ log.info(widget);
+ }
+
+ @Override
+ protected void visitTable(Table widget) {
+ log.info(widget);
+ }
+
+ @Override
+ protected void visitTableColumn(TableColumn widget) {
+ log.info(widget);
+ }
+
+ @Override
+ protected void visitTableItem(TableItem widget) {
+ log.info(widget);
+ }
+
+ @Override
+ protected void visitText(Text widget) {
+ StringBuilder text = new StringBuilder();
+ text.append("Text {");
+ text.append(widget.getText());
+ text.append("}");
+ log.info(text.toString());
+ }
+
+ @Override
+ protected void visitToolBar(ToolBar widget) {
+ StringBuilder text = new StringBuilder();
+ text.append("Toolbar {");
+ text.append(widget.getRowCount() + " row(s), ");
+ text.append(widget.getItemCount() + " item(s)");
+ text.append("}");
+ log.info(text.toString());
+ }
+
+ @Override
+ protected void visitToolItem(ToolItem widget) {
+ StringBuilder text = new StringBuilder();
+ text.append("Toolitem {");
+ text.append("text = '" + widget.getText() + "', ");
+ text.append("tooltip = '" + widget.getToolTipText() +
"'");
+ text.append("}");
+ log.info(text.toString());
+ }
+
+ @Override
+ protected void visitTray(Tray widget) {
+ log.info(widget);
+ }
+
+ @Override
+ protected void visitTree(Tree widget) {
+ StringBuilder text = new StringBuilder();
+ text.append("Tree {");
+ text.append(widget.getItemCount() + " item(s), ");
+ text.append(widget.getColumnCount() + " columns(s), ");
+ text.append("items = {");
+ for (SWTBotTreeItem item : new SWTBotTree(widget).getAllItems()){
+ text.append(item.getText() + ", ");
+ }
+ text.append("}");
+ text.append("}");
+ log.info(text.toString());
+ }
+
+ @Override
+ protected void visitTreeItem(TreeItem widget) {
+ log.info(widget);
+ }
+
+ @Override
+ protected void visitHyperLink(Hyperlink widget) {
+ StringBuilder text = new StringBuilder();
+ text.append("Hyperlink {");
+ text.append("text = '" + widget.getText() + "'");
+ text.append("}");
+ log.info(text.toString());
+ }
+
+ @Override
+ protected void visitGroup(Group widget) {
+ log.info(widget);
+ }
+
+ @Override
+ protected void visitUnkownItem(Widget widget) {
+ log.info("Unknown: " + widget);
+ }
+}
\ No newline at end of file
Copied:
trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/logging/VisitableWidget.java
(from rev 38107,
trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/task/finder/VisitableWidget.java)
===================================================================
---
trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/logging/VisitableWidget.java
(rev 0)
+++
trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/logging/VisitableWidget.java 2012-02-07
15:58:30 UTC (rev 38474)
@@ -0,0 +1,23 @@
+package org.jboss.tools.ui.bot.ext.logging;
+
+import org.eclipse.swt.widgets.Widget;
+
+/**
+ * Wraps {@link Widget} so that it can be used
+ * in Visitor pattern.
+ *
+ * @author Lucia Jelinkova
+ *
+ */
+public class VisitableWidget {
+
+ private Widget widget;
+
+ public VisitableWidget(Widget w) {
+ this.widget = w;
+ }
+
+ public void accept(WidgetVisitor visitor){
+ visitor.visit(widget);
+ }
+}
Copied:
trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/logging/WidgetVisitor.java
(from rev 38107,
trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/task/finder/WidgetVisitor.java)
===================================================================
---
trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/logging/WidgetVisitor.java
(rev 0)
+++
trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/logging/WidgetVisitor.java 2012-02-07
15:58:30 UTC (rev 38474)
@@ -0,0 +1,15 @@
+package org.jboss.tools.ui.bot.ext.logging;
+
+import org.eclipse.swt.widgets.Widget;
+
+/**
+ * Visitor for the {@link Widget} objects.
+ *
+ * @author Lucia Jelinkova
+ *
+ */
+public interface WidgetVisitor {
+
+ void visit(Widget widget);
+
+}
Copied:
trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/logging/WidgetsFinder.java
(from rev 38107,
trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/task/finder/WidgetFindingTask.java)
===================================================================
---
trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/logging/WidgetsFinder.java
(rev 0)
+++
trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/logging/WidgetsFinder.java 2012-02-07
15:58:30 UTC (rev 38474)
@@ -0,0 +1,118 @@
+package org.jboss.tools.ui.bot.ext.logging;
+
+import static org.eclipse.swtbot.swt.finder.finders.UIThreadRunnable.syncExec;
+import static org.eclipse.swtbot.swt.finder.matchers.WidgetMatcherFactory.widgetOfType;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Widget;
+import org.eclipse.swtbot.swt.finder.SWTBot;
+import org.eclipse.swtbot.swt.finder.results.VoidResult;
+import org.hamcrest.Matcher;
+
+/**
+ *
+ * Finds all widgets recursively and delegates the concrete action
+ * to be performed on the visitor (see GOF Visitor pattern)
+ *
+ * @author Lucia Jelinkova
+ *
+ */
+public class WidgetsFinder {
+
+ private Matcher<? extends Widget> matcher;
+
+ private Widget parentWidget;
+
+ private WidgetVisitor visitor;
+
+ private SWTBot bot;
+
+ /**
+ * Finds all widgets for the active shell.
+ */
+ public WidgetsFinder(WidgetVisitor visitor) {
+ this(null, visitor);
+ }
+
+ /**
+ * Finds all widgets meeting specified matcher's condition for the active shell.
+ *
+ * @param matcher
+ */
+ public WidgetsFinder(Matcher<? extends Widget> matcher, WidgetVisitor visitor) {
+ this(null, matcher, visitor);
+ }
+
+ /**
+ * Finds all widgets starting from the specified widget meeting
+ * specified matcher condition.
+ *
+ * @param widget
+ * @param matcher
+ */
+ public WidgetsFinder(Widget widget, Matcher<? extends Widget> matcher,
WidgetVisitor visitor) {
+ super();
+ this.matcher = matcher;
+ this.parentWidget = widget;
+ this.visitor = visitor;
+ }
+
+ public void find() {
+ syncExec(new VoidResult() {
+
+ @Override
+ public void run() {
+ findWidgetRecursive(getParentWidget(), new ArrayList<Widget>());
+ }
+ });
+ }
+
+ private void findWidgetRecursive(Widget widget, ArrayList<Widget> visited){
+
+ if (visited.contains(widget)){
+ return;
+ }
+
+ visited.add(widget);
+ visitWidget(widget);
+
+ if (widget instanceof Composite && ((Composite) widget).getChildren().length ==
0){
+ return;
+ }
+
+ List<? extends Widget> children = getBot().widgets(getMatcher(), widget);
+ for (Widget child : children){
+ findWidgetRecursive(child, visited);
+ }
+ }
+
+ private void visitWidget(Widget widget){
+ new VisitableWidget(widget).accept(visitor);
+ }
+
+ public Matcher<? extends Widget> getMatcher() {
+ if (matcher == null){
+ matcher = widgetOfType(Widget.class);
+ }
+ return matcher;
+ }
+
+ private Widget getParentWidget() {
+ if (parentWidget == null){
+ // get active shell from generic bot
+ parentWidget = new SWTBot().activeShell().widget;
+ }
+ return parentWidget;
+ }
+
+ private SWTBot getBot(){
+ if (bot == null){
+ // create bot for parent widget
+ bot = new SWTBot(getParentWidget());
+ }
+ return bot;
+ }
+}
Copied:
trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/logging/WidgetsLogger.java
(from rev 38107,
trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/task/debug/PrintWidgetsTask.java)
===================================================================
---
trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/logging/WidgetsLogger.java
(rev 0)
+++
trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/logging/WidgetsLogger.java 2012-02-07
15:58:30 UTC (rev 38474)
@@ -0,0 +1,34 @@
+package org.jboss.tools.ui.bot.ext.logging;
+
+import org.apache.log4j.Logger;
+import org.eclipse.swt.widgets.Widget;
+import org.hamcrest.Matcher;
+
+/**
+ * Contains methods for convenient print of widgets.
+ *
+ * @author Lucia Jelinkova
+ *
+ */
+public class WidgetsLogger {
+
+ private static final Logger log = Logger.getLogger(WidgetsLogger.class);
+
+ public static void log() {
+ log(null);
+ }
+
+ public static void log(Matcher<? extends Widget> matcher) {
+ log(matcher, null);
+ }
+
+ public static void log(Matcher<? extends Widget> matcher, Widget parentWidget) {
+ if (log.isInfoEnabled()){
+ log.info("--------------- Start of the list of widgets ---------------");
+ new WidgetsFinder(parentWidget, matcher, new LogWidgetsVisitor()).find();
+ log.info("--------------- End of the list of widgets ---------------");
+ } else {
+ System.out.println("INFO for " + WidgetsLogger.class + " is not
enabled");
+ }
+ }
+}