Exemplo n.º 1
0
  private static String formatWidgetPath(Widget widget) {
    StringBuilder b = new StringBuilder();
    while (widget != null) {
      if (b.length() > 0) b.append(" <- ");
      b.append(widget.getClass().getSimpleName());

      try {
        Method getText = widget.getClass().getMethod("getText");
        if (getText.getReturnType() == String.class) {
          String text = (String) getText.invoke(widget);
          if (text != null && text.length() > 0) {
            if (text.length() > 32) text = text.substring(0, 32) + " ...";
            b.append('(').append(text).append(')');
          }
        }
      } catch (SecurityException e) {
      } catch (NoSuchMethodException e) {
      } catch (IllegalArgumentException e) {
      } catch (IllegalAccessException e) {
      } catch (InvocationTargetException e) {
      }

      widget = widget instanceof Control ? ((Control) widget).getParent() : null;
    }
    return b.toString();
  }
Exemplo n.º 2
0
 public ThemeAdapter getThemeAdapter(Widget widget) {
   Class widgetClass = widget.getClass();
   ThemeAdapter result;
   synchronized (themeAdapters) {
     result = themeAdapters.get(widgetClass);
     if (result == null) {
       ThemeAdapter adapter = findThemeAdapter(widgetClass);
       themeAdapters.put(widgetClass, adapter);
       result = adapter;
     }
   }
   ensureThemeAdapterWasFound(widgetClass, result);
   return result;
 }
Exemplo n.º 3
0
 protected Rectangle getControlBounds() {
   Widget widget = (Widget) getControl();
   if (widget instanceof Control) {
     Control control = (Control) widget;
     return control.getBounds();
   }
   Method drawMethod = findBoundsMethod(widget.getClass());
   if (drawMethod != null) {
     try {
       drawMethod.setAccessible(true);
       return (Rectangle) drawMethod.invoke(widget);
     } catch (Exception e) {
       throw new XWTException(e);
     }
   }
   Control control = findHostControl();
   return control.getBounds();
 }
Exemplo n.º 4
0
  /* (non-Javadoc)
   * @see com.windowtester.runtime.IUIContext#close(com.windowtester.runtime.locator.IWidgetLocator)
   */
  public void close(IWidgetLocator locator) throws WidgetSearchException {

    ICloseableLocator closeable = getCloseable(locator);

    if (closeable != null) {
      closeable.doClose(this);
      return;
    }

    // conditions handled in the close
    // handleConditions();
    Widget widget = findWidget(locator);
    if (widget == null) throw new WidgetSearchException("target of a close call must not be null");
    if (!(widget instanceof Shell))
      throw new WidgetSearchException(
          "target of a close call must be a Shell, got a: " + widget.getClass() + " instead");

    close((Shell) widget);
  }
Exemplo n.º 5
0
 public static void printPossibleWidgets(final SWTGefBot bot) {
   final List<? extends Widget> widgets = bot.widgets(WidgetMatcherFactory.withRegex(".*"));
   for (final Widget widget : widgets) {
     System.out.println(widget.getClass());
   }
 }
Exemplo n.º 6
0
 public void doPaint(HighlightingDriver driver) {
   String desc = (_widget == null) ? null : _widget.getClass().toString();
   TraceHandler.trace(
       IRuntimePluginTraceOptions.WIDGET_SELECTION,
       "<highlight doPaint called on a no-op highlighter -- typed: " + desc + ">");
 }