Search in sources :

Example 16 with GuiTask

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);
}
Also used : GuiTask(org.fest.swing.edt.GuiTask)

Example 17 with GuiTask

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;
}
Also used : GuiTask(org.fest.swing.edt.GuiTask) EditorTextField(com.intellij.ui.EditorTextField) NotNull(org.jetbrains.annotations.NotNull)

Example 18 with GuiTask

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;
}
Also used : GuiTask(org.fest.swing.edt.GuiTask) NotNull(org.jetbrains.annotations.NotNull)

Example 19 with GuiTask

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);
}
Also used : GuiTask(org.fest.swing.edt.GuiTask) RunsInEDT(org.fest.swing.annotation.RunsInEDT)

Example 20 with GuiTask

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;
}
Also used : GuiTask(org.fest.swing.edt.GuiTask) VirtualFile(com.intellij.openapi.vfs.VirtualFile) FileEditorManager(com.intellij.openapi.fileEditor.FileEditorManager) FileEditor(com.intellij.openapi.fileEditor.FileEditor) List(java.util.List) JBList(com.intellij.ui.components.JBList)

Aggregations

GuiTask (org.fest.swing.edt.GuiTask)38 NotNull (org.jetbrains.annotations.NotNull)16 Condition (org.fest.swing.timing.Condition)9 VirtualFile (com.intellij.openapi.vfs.VirtualFile)8 Project (com.intellij.openapi.project.Project)7 FileEditor (com.intellij.openapi.fileEditor.FileEditor)5 FileEditorManager (com.intellij.openapi.fileEditor.FileEditorManager)5 Module (com.intellij.openapi.module.Module)5 File (java.io.File)4 Test (org.junit.Test)4 GradleUtil.getGradleBuildFile (com.android.tools.idea.gradle.util.GradleUtil.getGradleBuildFile)3 OpenFileDescriptor (com.intellij.openapi.fileEditor.OpenFileDescriptor)3 JBList (com.intellij.ui.components.JBList)3 Assert.assertNotNull (junit.framework.Assert.assertNotNull)3 Assert.assertNotNull (org.junit.Assert.assertNotNull)3 GradleBuildModel (com.android.tools.idea.gradle.dsl.model.GradleBuildModel)2 GradleBuildFile (com.android.tools.idea.gradle.parser.GradleBuildFile)2 ProjectView (com.intellij.ide.projectView.ProjectView)2 ContentEntry (com.intellij.openapi.roots.ContentEntry)2 ModifiableRootModel (com.intellij.openapi.roots.ModifiableRootModel)2