Search in sources :

Example 11 with GuiTask

use of org.fest.swing.edt.GuiTask in project android by JetBrains.

the class ThemeEditorTableCellWriter method startCellEditing.

/** {@inheritDoc} */
@Override
public void startCellEditing(@NotNull final JTable table, final int row, final int column) {
    final JTableLocation location = location();
    execute(new GuiTask() {

        @Override
        protected void executeInEDT() throws Throwable {
            scrollToCell(table, row, column, location);
        }
    });
    Rectangle cellBounds = location.cellBounds(table, row, column);
    robot.click(table, cellBounds.getLocation());
}
Also used : GuiTask(org.fest.swing.edt.GuiTask) JTableLocation(org.fest.swing.driver.JTableLocation)

Example 12 with GuiTask

use of org.fest.swing.edt.GuiTask in project android by JetBrains.

the class IdeFrameFixture method requestFocusIfLost.

/**
   * Gets the focus back to Android Studio if it was lost
   */
public void requestFocusIfLost() {
    KeyboardFocusManager keyboardFocusManager = KeyboardFocusManager.getCurrentKeyboardFocusManager();
    Wait.seconds(1).expecting("a component to have the focus").until(() -> {
        // keep asking until it is. This problem has appeared at least when not using a window manager when running tests.
        if (keyboardFocusManager.getFocusOwner() == null) {
            execute(new GuiTask() {

                @Override
                protected void executeInEDT() throws Throwable {
                    target().requestFocus();
                }
            });
            return false;
        }
        return true;
    });
}
Also used : GuiTask(org.fest.swing.edt.GuiTask)

Example 13 with GuiTask

use of org.fest.swing.edt.GuiTask in project android by JetBrains.

the class IdeFrameFixture method getSourceFolderRelativePaths.

/**
   * Returns a list of system independent paths
   */
@NotNull
public Collection<String> getSourceFolderRelativePaths(@NotNull String moduleName, @NotNull JpsModuleSourceRootType<?> sourceType) {
    Set<String> paths = Sets.newHashSet();
    Module module = getModule(moduleName);
    ModuleRootManager moduleRootManager = ModuleRootManager.getInstance(module);
    execute(new GuiTask() {

        @Override
        protected void executeInEDT() throws Throwable {
            ModifiableRootModel rootModel = moduleRootManager.getModifiableModel();
            try {
                for (ContentEntry contentEntry : rootModel.getContentEntries()) {
                    for (SourceFolder folder : contentEntry.getSourceFolders()) {
                        JpsModuleSourceRootType<?> rootType = folder.getRootType();
                        if (rootType.equals(sourceType)) {
                            String path = urlToPath(folder.getUrl());
                            String relativePath = getRelativePath(myProjectPath, new File(toSystemDependentName(path)));
                            paths.add(PathUtil.toSystemIndependentName(relativePath));
                        }
                    }
                }
            } finally {
                rootModel.dispose();
            }
        }
    });
    return paths;
}
Also used : GuiTask(org.fest.swing.edt.GuiTask) ModifiableRootModel(com.intellij.openapi.roots.ModifiableRootModel) SourceFolder(com.intellij.openapi.roots.SourceFolder) JpsModuleSourceRootType(org.jetbrains.jps.model.module.JpsModuleSourceRootType) ContentEntry(com.intellij.openapi.roots.ContentEntry) ModuleRootManager(com.intellij.openapi.roots.ModuleRootManager) Module(com.intellij.openapi.module.Module) VirtualFile(com.intellij.openapi.vfs.VirtualFile) File(java.io.File) GradleUtil.getGradleBuildFile(com.android.tools.idea.gradle.util.GradleUtil.getGradleBuildFile) Assert.assertNotNull(junit.framework.Assert.assertNotNull) NotNull(org.jetbrains.annotations.NotNull)

Example 14 with GuiTask

use of org.fest.swing.edt.GuiTask in project android by JetBrains.

the class SelectPathFixture method clickOK.

@NotNull
public IdeFrameFixture clickOK() {
    JButton button = GuiTests.waitUntilShowingAndEnabled(myRobot, myDialog, Matchers.byText(JButton.class, "OK"));
    // Click the "OK" button pragmatically to eliminate the flakiness due to a possible click miss.
    GuiActionRunner.execute(new GuiTask() {

        @Override
        protected void executeInEDT() throws Throwable {
            button.doClick();
        }
    });
    Wait.seconds(5).expecting("dialog to disappear").until(() -> !target().isShowing());
    return myIdeFrameFixture;
}
Also used : GuiTask(org.fest.swing.edt.GuiTask) NotNull(org.jetbrains.annotations.NotNull)

Example 15 with GuiTask

use of org.fest.swing.edt.GuiTask in project android by JetBrains.

the class SelectSdkDialogFixture method setJdkPath.

@NotNull
public SelectSdkDialogFixture setJdkPath(@NotNull final File path) {
    final JLabel label = robot().finder().find(target(), JLabelMatcher.withText("Select Java JDK:").andShowing());
    execute(new GuiTask() {

        @Override
        protected void executeInEDT() throws Throwable {
            Component textField = label.getLabelFor();
            assertThat(textField).isInstanceOf(JTextField.class);
            ((JTextField) textField).setText(path.getPath());
        }
    });
    return this;
}
Also used : GuiTask(org.fest.swing.edt.GuiTask) NotNull(org.jetbrains.annotations.NotNull)

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