Search in sources :

Example 1 with ComponentLookupException

use of org.fest.swing.exception.ComponentLookupException in project intellij-community by JetBrains.

the class GuiTestUtil method findComboBox.

public static JComboBoxFixture findComboBox(@NotNull Robot robot, @NotNull Container container, @NotNull String labelText) {
    JLabel label = (JLabel) robot.finder().find(container, new ComponentMatcher() {

        @Override
        public boolean matches(Component p0) {
            return (p0 instanceof JLabel && ((JLabel) p0).getText() != null && ((JLabel) p0).getText().equals(labelText));
        }
    });
    if (label == null)
        throw new ComponentLookupException("Unable to find label with text \" + labelText+\"");
    Container boundedCmp = (Container) label.getLabelFor();
    if (boundedCmp == null)
        throw new ComponentLookupException("Unable to find bounded component for label \" + labelText+\"");
    JComboBox cb = robot.finder().findByType(boundedCmp, JComboBox.class);
    if (cb == null)
        throw new ComponentLookupException("Unable to find JComboBox near label \" + labelText+\"");
    return new JComboBoxFixture(robot, cb);
}
Also used : ComponentLookupException(org.fest.swing.exception.ComponentLookupException) JTextComponent(javax.swing.text.JTextComponent)

Example 2 with ComponentLookupException

use of org.fest.swing.exception.ComponentLookupException in project intellij-community by JetBrains.

the class ActionLinkFixture method findByActionId.

@NotNull
public static ActionLinkFixture findByActionId(@NotNull final String actionId, @NotNull final Robot robot, @NotNull final Container container) {
    final Ref<ActionLink> actionLinkRef = new Ref<ActionLink>();
    pause(new Condition("Find ActionLink with ID '" + actionId + "'") {

        @Override
        public boolean test() {
            Collection<ActionLink> found = robot.finder().findAll(container, new GenericTypeMatcher<ActionLink>(ActionLink.class) {

                @Override
                protected boolean isMatching(@NotNull ActionLink actionLink) {
                    if (actionLink.isVisible()) {
                        AnAction action = actionLink.getAction();
                        String id = ActionManager.getInstance().getId(action);
                        return actionId.equals(id);
                    }
                    return false;
                }
            });
            if (found.size() == 1) {
                actionLinkRef.set(getFirstItem(found));
                return true;
            }
            return false;
        }
    }, SHORT_TIMEOUT);
    ActionLink actionLink = actionLinkRef.get();
    if (actionLink == null) {
        throw new ComponentLookupException("Failed to find ActionLink with ID '" + actionId + "'");
    }
    return new ActionLinkFixture(robot, actionLink);
}
Also used : Condition(org.fest.swing.timing.Condition) Ref(com.intellij.openapi.util.Ref) Collection(java.util.Collection) ComponentLookupException(org.fest.swing.exception.ComponentLookupException) GenericTypeMatcher(org.fest.swing.core.GenericTypeMatcher) NotNull(org.jetbrains.annotations.NotNull) AnAction(com.intellij.openapi.actionSystem.AnAction) ActionLink(com.intellij.ui.components.labels.ActionLink) NotNull(org.jetbrains.annotations.NotNull)

Example 3 with ComponentLookupException

use of org.fest.swing.exception.ComponentLookupException in project intellij-community by JetBrains.

the class ActionLinkFixture method findActionLinkByName.

@NotNull
public static ActionLinkFixture findActionLinkByName(@NotNull final String actionName, @NotNull final Robot robot, @NotNull final Container container, @NotNull final Timeout timeout) {
    final Ref<ActionLink> actionLinkRef = new Ref<ActionLink>();
    pause(new Condition("Find ActionLink with name '" + actionName + "'") {

        @Override
        public boolean test() {
            Collection<ActionLink> found = robot.finder().findAll(container, new GenericTypeMatcher<ActionLink>(ActionLink.class) {

                @Override
                protected boolean isMatching(@NotNull ActionLink actionLink) {
                    if (actionLink.isVisible()) {
                        return actionLink.getText().equals(actionName);
                    }
                    return false;
                }
            });
            if (found.size() == 1) {
                actionLinkRef.set(getFirstItem(found));
                return true;
            }
            return false;
        }
    }, timeout);
    ActionLink actionLink = actionLinkRef.get();
    if (actionLink == null) {
        throw new ComponentLookupException("Failed to find ActionLink with name '" + actionName + "'");
    }
    return new ActionLinkFixture(robot, actionLink);
}
Also used : Condition(org.fest.swing.timing.Condition) Ref(com.intellij.openapi.util.Ref) Collection(java.util.Collection) ComponentLookupException(org.fest.swing.exception.ComponentLookupException) GenericTypeMatcher(org.fest.swing.core.GenericTypeMatcher) NotNull(org.jetbrains.annotations.NotNull) ActionLink(com.intellij.ui.components.labels.ActionLink) NotNull(org.jetbrains.annotations.NotNull)

Example 4 with ComponentLookupException

use of org.fest.swing.exception.ComponentLookupException in project android by JetBrains.

the class ActionButtonFixture method findByActionId.

@NotNull
public static ActionButtonFixture findByActionId(@NotNull final String actionId, @NotNull final Robot robot, @NotNull final Container container) {
    final Ref<ActionButton> actionButtonRef = new Ref<>();
    Wait.seconds(1).expecting("ActionButton with ID '" + actionId + "' to be visible").until(() -> {
        Collection<ActionButton> found = robot.finder().findAll(container, new GenericTypeMatcher<ActionButton>(ActionButton.class) {

            @Override
            protected boolean isMatching(@NotNull ActionButton button) {
                if (button.isVisible()) {
                    AnAction action = button.getAction();
                    if (action != null) {
                        String id = ActionManager.getInstance().getId(action);
                        return actionId.equals(id);
                    }
                }
                return false;
            }
        });
        if (found.size() == 1) {
            actionButtonRef.set(getFirstItem(found));
            return true;
        }
        return false;
    });
    ActionButton button = actionButtonRef.get();
    if (button == null) {
        throw new ComponentLookupException("Failed to find ActionButton with ID '" + actionId + "'");
    }
    return new ActionButtonFixture(robot, button);
}
Also used : Ref(com.intellij.openapi.util.Ref) ActionButton(com.intellij.openapi.actionSystem.impl.ActionButton) ComponentLookupException(org.fest.swing.exception.ComponentLookupException) AnAction(com.intellij.openapi.actionSystem.AnAction) NotNull(org.jetbrains.annotations.NotNull)

Example 5 with ComponentLookupException

use of org.fest.swing.exception.ComponentLookupException in project android by JetBrains.

the class ActionLinkFixture method findByActionId.

@NotNull
public static ActionLinkFixture findByActionId(@NotNull final String actionId, @NotNull final Robot robot, @NotNull final Container container) {
    final Ref<ActionLink> actionLinkRef = new Ref<>();
    Wait.seconds(1).expecting("ActionLink with ID '" + actionId + "' to be visible").until(() -> {
        Collection<ActionLink> found = robot.finder().findAll(container, new GenericTypeMatcher<ActionLink>(ActionLink.class) {

            @Override
            protected boolean isMatching(@NotNull ActionLink actionLink) {
                if (actionLink.isVisible()) {
                    AnAction action = actionLink.getAction();
                    String id = ActionManager.getInstance().getId(action);
                    return actionId.equals(id);
                }
                return false;
            }
        });
        if (found.size() == 1) {
            actionLinkRef.set(getFirstItem(found));
            return true;
        }
        return false;
    });
    ActionLink actionLink = actionLinkRef.get();
    if (actionLink == null) {
        throw new ComponentLookupException("Failed to find ActionLink with ID '" + actionId + "'");
    }
    return new ActionLinkFixture(robot, actionLink);
}
Also used : Ref(com.intellij.openapi.util.Ref) ComponentLookupException(org.fest.swing.exception.ComponentLookupException) AnAction(com.intellij.openapi.actionSystem.AnAction) ActionLink(com.intellij.ui.components.labels.ActionLink) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

ComponentLookupException (org.fest.swing.exception.ComponentLookupException)10 NotNull (org.jetbrains.annotations.NotNull)7 Ref (com.intellij.openapi.util.Ref)5 AnAction (com.intellij.openapi.actionSystem.AnAction)4 Condition (org.fest.swing.timing.Condition)4 ActionLink (com.intellij.ui.components.labels.ActionLink)3 Collection (java.util.Collection)3 GenericTypeMatcher (org.fest.swing.core.GenericTypeMatcher)3 ElementNotFoundException (com.axway.ats.uiengine.exceptions.ElementNotFoundException)2 SwingDriverInternal (com.axway.ats.uiengine.internal.driver.SwingDriverInternal)2 ActionButton (com.intellij.openapi.actionSystem.impl.ActionButton)2 JTextComponent (javax.swing.text.JTextComponent)2 JTextComponentFixture (org.fest.swing.fixture.JTextComponentFixture)2 HprofEditor (com.android.tools.idea.editors.hprof.HprofEditor)1 MoreThanOneSuchElementException (com.axway.ats.uiengine.exceptions.MoreThanOneSuchElementException)1 FileEditor (com.intellij.openapi.fileEditor.FileEditor)1 EditorWindow (com.intellij.openapi.fileEditor.impl.EditorWindow)1 EditorWithProviderComposite (com.intellij.openapi.fileEditor.impl.EditorWithProviderComposite)1 EditorsSplitters (com.intellij.openapi.fileEditor.impl.EditorsSplitters)1 FileEditorManagerImpl (com.intellij.openapi.fileEditor.impl.FileEditorManagerImpl)1