org.eclipse.swtbot.swt.finder.utils.MessageFormat Java Examples

The following examples show how to use org.eclipse.swtbot.swt.finder.utils.MessageFormat. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SWTBotUtils.java    From tracecompass with Eclipse Public License 2.0 6 votes vote down vote up
/**
 * Close all non-main shells that are visible.
 *
 * @param bot
 *            the workbench bot
 */
public static void closeSecondaryShells(SWTWorkbenchBot bot) {
    SWTBotShell[] shells = bot.shells();
    SWTBotShell mainShell = getMainShell(shells);
    if (mainShell == null) {
        return;
    }

    // Close all non-main shell but make sure we don't close an invisible
    // shell such the special "limbo shell" that Eclipse needs to work
    Arrays.stream(shells)
            .filter(shell -> shell != mainShell)
            .filter(s -> !s.widget.isDisposed())
            .filter(SWTBotShell::isVisible)
            .peek(shell -> log.debug(MessageFormat.format("Closing lingering shell with title {0}", shell.getText())))
            .forEach(SWTBotShell::close);
}
 
Example #2
Source File: SWTBotTableCombo.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Sets the text of the combo box.
 * 
 * @param text the text to set.
 * @since 1.0
 */
public void setText(final String text) {
	log.debug(MessageFormat.format("Setting text on {0} to {1}", this, text)); //$NON-NLS-1$
	waitForEnabled();

	if (hasStyle(widget, SWT.READ_ONLY))
		throw new RuntimeException("This combo box is read-only."); //$NON-NLS-1$

	asyncExec(new VoidResult() {
		public void run() {
			widget.setText(text);
		}
	});
	notify(SWT.Modify);
	log.debug(MessageFormat.format("Set text on {0} to {1}", this, text)); //$NON-NLS-1$
}
 
Example #3
Source File: SwtBotRadio.java    From dsl-devkit with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * {@inheritDoc} A customized version to fix bug: https://bugs.eclipse.org/bugs/show_bug.cgi?id=344484.
 */
@Override
public SwtBotRadio click() {
  if (isSelected()) {
    log.debug(MessageFormat.format("Widget {0} is already selected, not clicking again.", this)); //$NON-NLS-1$
    return this;
  }
  waitForEnabled();

  log.debug(MessageFormat.format("Clicking on {0}", this)); //$NON-NLS-1$

  final SwtBotRadio otherSelectedButton = otherSelectedButton();
  if (otherSelectedButton != null) {
    otherSelectedButton.notify(SWT.Deactivate);
    asyncExec(new VoidResult() {
      public void run() {
        otherSelectedButton.widget.setSelection(false);
      }
    });
  }

  notify(SWT.Activate);
  notify(SWT.MouseDown, createMouseEvent(0, 0, 1, 0, 1));
  notify(SWT.MouseUp, createMouseEvent(0, 0, 1, SWT.BUTTON1, 1));
  asyncExec(new VoidResult() {
    public void run() {
      widget.setSelection(true);
    }
  });
  notify(SWT.Selection);

  log.debug(MessageFormat.format("Clicked on {0}", this)); //$NON-NLS-1$
  return this;
}
 
Example #4
Source File: SwtBotButton.java    From dsl-devkit with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * {@inheritDoc} A customized version with less notifications, since the button could be disabled after the {@link SWT.Selection} event.
 */
@Override
public SwtBotButton click() {
  log.debug(MessageFormat.format("Clicking on {0}", SWTUtils.getText(widget))); //$NON-NLS-1$
  waitForEnabled();
  notify(SWT.MouseEnter);
  notify(SWT.MouseMove);
  notify(SWT.Activate);
  notify(SWT.FocusIn);
  notify(SWT.MouseDown);
  notify(SWT.MouseUp);
  notify(SWT.Selection);
  log.debug(MessageFormat.format("Clicked on {0}", SWTUtils.getText(widget))); //$NON-NLS-1$
  return this;
}
 
Example #5
Source File: SWTBotTableCombo.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Unselect all selections.
 */
public void unselect() {
	waitForEnabled();
	setFocus();
	asyncExec(new VoidResult() {
		public void run() {
			log.debug(MessageFormat.format("Unselecting all in {0}", widget)); //$NON-NLS-1$
			widget.getTable().deselectAll();
		}
	});
	notifySelect();
}
 
Example #6
Source File: SWTBotTableCombo.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Selects the given index items.
 *
 * @param indices the row indices to select in the table.
 */
public void select(final int... indices) {
	waitForEnabled();
	if (indices.length > 1)
		assertMultiSelect();
	setFocus();
	log.debug(MessageFormat.format("Selecting rows {0} in table {1}", StringUtils.join(indices, ", "), this)); //$NON-NLS-1$ //$NON-NLS-2$
	unselect();
	for (int i = 0; i < indices.length; i++)
		additionalSelectAndNotify(indices[i]);
}
 
Example #7
Source File: SWTBotTableCombo.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Set the selection to the specified text.
 * 
 * @param text the text to set into the combo.
 */
public void setSelection(final String text) {
	log.debug(MessageFormat.format("Setting selection on {0} to {1}", this, text)); //$NON-NLS-1$
	waitForEnabled();
	_setSelection(text);
	notify(SWT.Selection);
	log.debug(MessageFormat.format("Set selection on {0} to {1}", this, text)); //$NON-NLS-1$
}
 
Example #8
Source File: SWTBotTableCombo.java    From bonita-studio with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Types the string in the combo box.
 *
 * @param text the text to be typed.
 * @param interval the interval between consecutive key strokes.
 * @return the same instance.
 */
public SWTBotTableCombo typeText(final String text, int interval) {
	log.debug(MessageFormat.format("Inserting text:{0} into text {1}", text, this)); //$NON-NLS-1$
	setFocus();
	keyboard().typeText(text, interval);
	return this;
}