Search in sources :

Example 6 with ActionButton

use of com.intellij.openapi.actionSystem.impl.ActionButton in project android by JetBrains.

the class EditMultipleSourcesAction method actionPerformed.

@Override
public void actionPerformed(AnActionEvent e) {
    Project project = e.getData(CommonDataKeys.PROJECT);
    assert project != null;
    final Navigatable[] files = e.getData(CommonDataKeys.NAVIGATABLE_ARRAY);
    assert files != null && files.length > 0;
    if (files.length > 1) {
        DefaultListModel listModel = new DefaultListModel();
        for (int i = 0; i < files.length; ++i) {
            assert files[i] instanceof PsiClassNavigation;
            //noinspection unchecked
            listModel.add(i, ((PsiClassNavigation) files[i]).getPsiFile());
        }
        final JBList list = new JBList(listModel);
        int width = WindowManager.getInstance().getFrame(project).getSize().width;
        list.setCellRenderer(new GotoFileCellRenderer(width));
        JBPopup popup = JBPopupFactory.getInstance().createListPopupBuilder(list).setTitle("Choose Target File").setItemChoosenCallback(new Runnable() {

            @Override
            public void run() {
                Object selectedValue = list.getSelectedValue();
                PsiClassNavigation navigationWrapper = null;
                for (Navigatable file : files) {
                    if (selectedValue == ((PsiClassNavigation) file).getPsiFile()) {
                        navigationWrapper = (PsiClassNavigation) file;
                        break;
                    }
                }
                assert navigationWrapper != null;
                if (navigationWrapper.canNavigate()) {
                    navigationWrapper.navigate(true);
                }
            }
        }).createPopup();
        if (e.getInputEvent().getSource() instanceof ActionButton) {
            popup.showUnderneathOf((ActionButton) e.getInputEvent().getSource());
        } else {
            popup.showInBestPositionFor(e.getDataContext());
        }
    } else {
        assert files[0] instanceof PsiClassNavigation;
        PsiClassNavigation file = (PsiClassNavigation) files[0];
        if (file.canNavigate()) {
            file.navigate(true);
        }
    }
}
Also used : Project(com.intellij.openapi.project.Project) GotoFileCellRenderer(com.intellij.ide.util.gotoByName.GotoFileCellRenderer) ActionButton(com.intellij.openapi.actionSystem.impl.ActionButton) JBList(com.intellij.ui.components.JBList) JBPopup(com.intellij.openapi.ui.popup.JBPopup) Navigatable(com.intellij.pom.Navigatable)

Example 7 with ActionButton

use of com.intellij.openapi.actionSystem.impl.ActionButton in project android by JetBrains.

the class AttachedToolWindowTest method testHideFromButtonInHeader.

@Test
public void testHideFromButtonInHeader() {
    myToolWindow.setFloating(false);
    ActionButton button = findButtonByName(myToolWindow.getComponent(), "Hide");
    assertThat(button).isNotNull();
    button.click();
    assertThat(myToolWindow.isMinimized()).isTrue();
    verify(myModel).update(eq(myToolWindow), eq(PropertyType.MINIMIZED));
}
Also used : ActionButton(com.intellij.openapi.actionSystem.impl.ActionButton) Test(org.junit.Test)

Example 8 with ActionButton

use of com.intellij.openapi.actionSystem.impl.ActionButton in project android by JetBrains.

the class AttachedToolWindowTest method testAdditionalActionFromButtonInHeader.

@Test
public void testAdditionalActionFromButtonInHeader() {
    PalettePanelToolContent panel = (PalettePanelToolContent) myToolWindow.getContent();
    assert panel != null;
    ActionButton button = findButtonByName(myToolWindow.getComponent(), "AdditionalAction");
    assertThat(button).isNotNull();
    button.click();
    assertThat(panel.isAdditionalActionPerformed()).isTrue();
}
Also used : ActionButton(com.intellij.openapi.actionSystem.impl.ActionButton) Test(org.junit.Test)

Example 9 with ActionButton

use of com.intellij.openapi.actionSystem.impl.ActionButton in project android by JetBrains.

the class AttachedToolWindowTest method testSearchButtonInHeader.

@Test
public void testSearchButtonInHeader() {
    JLabel header = findHeaderLabel(myToolWindow.getComponent());
    assertThat(header.isVisible()).isTrue();
    SearchTextField searchField = findHeaderSearchField(myToolWindow.getComponent());
    assertThat(searchField.isVisible()).isFalse();
    ActionButton button = findButtonByName(myToolWindow.getComponent(), "Search");
    assertThat(button).isNotNull();
    button.click();
    assertThat(header.isVisible()).isFalse();
    assertThat(searchField.isVisible()).isTrue();
    fireFocusLost(searchField.getTextEditor());
    assertThat(header.isVisible()).isTrue();
    assertThat(searchField.isVisible()).isFalse();
}
Also used : ActionButton(com.intellij.openapi.actionSystem.impl.ActionButton) SearchTextField(com.intellij.ui.SearchTextField) Test(org.junit.Test)

Example 10 with ActionButton

use of com.intellij.openapi.actionSystem.impl.ActionButton in project android by JetBrains.

the class ProjectStructureDialogFixture method clickAddButtonImpl.

protected void clickAddButtonImpl() {
    ActionButton addButton = robot().finder().find(target(), new GenericTypeMatcher<ActionButton>(ActionButton.class) {

        @Override
        protected boolean isMatching(@NotNull ActionButton button) {
            String toolTipText = button.getToolTipText();
            return button.isShowing() && toolTipText != null && toolTipText.startsWith("Add");
        }
    });
    robot().click(addButton);
}
Also used : ActionButton(com.intellij.openapi.actionSystem.impl.ActionButton)

Aggregations

ActionButton (com.intellij.openapi.actionSystem.impl.ActionButton)23 NotNull (org.jetbrains.annotations.NotNull)6 AnAction (com.intellij.openapi.actionSystem.AnAction)3 Test (org.junit.Test)3 ActionButtonFixture (com.android.tools.idea.tests.gui.framework.fixture.ActionButtonFixture)2 PresentationFactory (com.intellij.openapi.actionSystem.impl.PresentationFactory)2 Ref (com.intellij.openapi.util.Ref)2 VirtualFile (com.intellij.openapi.vfs.VirtualFile)2 ComponentLookupException (org.fest.swing.exception.ComponentLookupException)2 PropertiesComponent (com.intellij.ide.util.PropertiesComponent)1 GotoFileCellRenderer (com.intellij.ide.util.gotoByName.GotoFileCellRenderer)1 ActionButtonLook (com.intellij.openapi.actionSystem.ex.ActionButtonLook)1 InplaceActionButtonLook (com.intellij.openapi.actionSystem.impl.InplaceActionButtonLook)1 Project (com.intellij.openapi.project.Project)1 ExistingLibraryEditor (com.intellij.openapi.roots.ui.configuration.libraryEditor.ExistingLibraryEditor)1 LibraryEditor (com.intellij.openapi.roots.ui.configuration.libraryEditor.LibraryEditor)1 LibraryRootsComponent (com.intellij.openapi.roots.ui.configuration.libraryEditor.LibraryRootsComponent)1 ValidationInfo (com.intellij.openapi.ui.ValidationInfo)1 MultiLineLabel (com.intellij.openapi.ui.ex.MultiLineLabel)1 JBPopup (com.intellij.openapi.ui.popup.JBPopup)1