use of org.fest.swing.edt.GuiTask in project android by JetBrains.
the class ToolWindowFixture method activate.
public void activate() {
if (isActive()) {
return;
}
execute(new GuiTask() {
@Override
protected void executeInEDT() throws Throwable {
myToolWindow.activate(null);
}
});
Wait.seconds(SECONDS_TO_WAIT).expecting("ToolWindow '" + myToolWindowId + "' to be activated").until(this::isActive);
}
use of org.fest.swing.edt.GuiTask in project android by JetBrains.
the class RenameRefactoringDialogFixture method setNewName.
@NotNull
public RenameRefactoringDialogFixture setNewName(@NotNull final String newName) {
final EditorTextField field = robot().finder().findByType(target(), EditorTextField.class);
GuiActionRunner.execute(new GuiTask() {
@Override
protected void executeInEDT() throws Throwable {
IdeFocusManager.getGlobalInstance().doWhenFocusSettlesDown(() -> {
IdeFocusManager.getGlobalInstance().requestFocus(field, true);
});
}
});
// to make sure we don't append to existing item on Linux
robot().pressAndReleaseKey(KeyEvent.VK_BACK_SPACE);
robot().enterText(newName);
Wait.seconds(1).expecting("EditorTextField to show new name").until(() -> newName.equals(field.getText()));
return this;
}
use of org.fest.swing.edt.GuiTask in project android by JetBrains.
the class CreateResourceFileDialogFixture method setFileName.
@NotNull
public CreateResourceFileDialogFixture setFileName(@NotNull final String newName) {
final Component field = robot().finder().findByLabel(getDialogWrapper().getContentPane(), "File name:");
execute(new GuiTask() {
@Override
protected void executeInEDT() throws Throwable {
IdeFocusManager.getGlobalInstance().doWhenFocusSettlesDown(() -> {
IdeFocusManager.getGlobalInstance().requestFocus(field, true);
});
}
});
// to make sure we don't append to existing item on Linux
robot().pressAndReleaseKey(KeyEvent.VK_BACK_SPACE);
robot().enterText(newName);
return this;
}
use of org.fest.swing.edt.GuiTask in project android by JetBrains.
the class SearchTextFieldDriver method deleteText.
@RunsInEDT
public void deleteText(SearchTextField textBox) {
focusAndWaitForFocusGain(textBox.getTextEditor());
execute(new GuiTask() {
@Override
protected void executeInEDT() throws Throwable {
textBox.getTextEditor().selectAll();
}
});
robot.pressAndReleaseKey(KeyEvent.VK_DELETE);
}
use of org.fest.swing.edt.GuiTask in project android by JetBrains.
the class EditorFixture method selectEditorTab.
/**
* Selects the given tab in the current editor. Used to switch between
* design mode and editor mode for example.
*
* @param tab the tab to switch to
*/
public EditorFixture selectEditorTab(@NotNull final Tab tab) {
String tabName = tab.myTabName;
execute(new GuiTask() {
@Override
protected void executeInEDT() throws Throwable {
VirtualFile currentFile = getCurrentFile();
assertNotNull("Can't switch to tab " + tabName + " when no file is open in the editor", currentFile);
FileEditorManager manager = FileEditorManager.getInstance(myFrame.getProject());
FileEditor[] editors = manager.getAllEditors(currentFile);
FileEditor target = null;
for (FileEditor editor : editors) {
if (tabName == null || tabName.equals(editor.getName())) {
target = editor;
break;
}
}
if (target != null) {
// Have to use reflection
//FileEditorManagerImpl#setSelectedEditor(final FileEditor editor)
method("setSelectedEditor").withParameterTypes(FileEditor.class).in(manager).invoke(target);
return;
}
List<String> tabNames = Lists.newArrayList();
for (FileEditor editor : editors) {
tabNames.add(editor.getName());
}
fail("Could not find editor tab \"" + (tabName != null ? tabName : "<default>") + "\": Available tabs = " + tabNames);
}
});
return this;
}
Aggregations