Search in sources :

Example 11 with ActionButton

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

the class SearchTextArea method createButton.

private static ActionButton createButton(AnAction action) {
    Presentation presentation = action.getTemplatePresentation();
    Dimension d = new JBDimension(16, 16);
    ActionButton button = new ActionButton(action, presentation, ActionPlaces.UNKNOWN, d) {

        @Override
        protected DataContext getDataContext() {
            return DataManager.getInstance().getDataContext(this);
        }
    };
    button.setLook(new InplaceActionButtonLook());
    button.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
    button.updateIcon();
    return button;
}
Also used : ActionButton(com.intellij.openapi.actionSystem.impl.ActionButton) JBDimension(com.intellij.util.ui.JBDimension) JBDimension(com.intellij.util.ui.JBDimension) InplaceActionButtonLook(com.intellij.openapi.actionSystem.impl.InplaceActionButtonLook)

Example 12 with ActionButton

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

the class SetTodoFilterAction method createCustomComponent.

@Override
public JComponent createCustomComponent(Presentation presentation) {
    ActionButton button = new ActionButton(this, presentation, ActionPlaces.TODO_VIEW_TOOLBAR, ActionToolbar.DEFAULT_MINIMUM_BUTTON_SIZE);
    presentation.putClientProperty("button", button);
    return button;
}
Also used : ActionButton(com.intellij.openapi.actionSystem.impl.ActionButton)

Example 13 with ActionButton

use of com.intellij.openapi.actionSystem.impl.ActionButton 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 14 with ActionButton

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

the class LibraryPropertiesDialog method createCenterPanel.

@Nullable
@Override
protected JComponent createCenterPanel() {
    myIconLabel.setIcon(AllIcons.Modules.Library);
    myNameLabel.setText(myLibrary.getName());
    LibraryEditor editor = new SourcesAndDocsOnlyEditor(myLibrary);
    myLibraryEditorComponent = new LibraryRootsComponent(myProject, editor) {

        @Override
        public void updatePropertiesLabel() {
            JComponent c = getComponent();
            if (c != null) {
                MultiLineLabel propertiesLabel = findComponentOfType(c, MultiLineLabel.class);
                if (propertiesLabel != null) {
                    propertiesLabel.setText("Add or remove source/Javadoc attachments");
                }
            }
        }
    };
    myLibraryEditorComponent.updatePropertiesLabel();
    JComponent c = myLibraryEditorComponent.getComponent();
    // Remove "Exclude" button. We don't support this in libraries.
    List<ActionButton> actionButtons = findComponentsOfType(c, ActionButton.class);
    for (ActionButton actionButton : actionButtons) {
        String text = actionButton.getAction().getTemplatePresentation().getText();
        if (text != null && text.startsWith("Exclude")) {
            actionButton.setVisible(false);
            break;
        }
    }
    MultiLineLabel propertiesLabel = findComponentOfType(c, MultiLineLabel.class);
    if (propertiesLabel != null) {
        propertiesLabel.setBorder(BorderFactory.createEmptyBorder(1, 1, 0, 1));
    }
    myTreePanel.add(c, BorderLayout.CENTER);
    myTreePanel.setBorder(customLine(OnePixelDivider.BACKGROUND, 1, 1, 1, 1));
    return myMainPanel;
}
Also used : ExistingLibraryEditor(com.intellij.openapi.roots.ui.configuration.libraryEditor.ExistingLibraryEditor) LibraryEditor(com.intellij.openapi.roots.ui.configuration.libraryEditor.LibraryEditor) ActionButton(com.intellij.openapi.actionSystem.impl.ActionButton) LibraryRootsComponent(com.intellij.openapi.roots.ui.configuration.libraryEditor.LibraryRootsComponent) MultiLineLabel(com.intellij.openapi.ui.ex.MultiLineLabel) Nullable(org.jetbrains.annotations.Nullable)

Example 15 with ActionButton

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

the class AttachedToolWindowTest method findButtonByName.

private static ActionButton findButtonByName(@NotNull Container container, @NotNull String name) {
    for (Component component : container.getComponents()) {
        if (component instanceof ActionButton) {
            ActionButton button = (ActionButton) component;
            AnAction action = button.getAction();
            if (action != null && name.equals(action.getTemplatePresentation().getText())) {
                return button;
            }
        }
        if (component instanceof Container) {
            ActionButton button = findButtonByName((Container) component, name);
            if (button != null) {
                return button;
            }
        }
    }
    return null;
}
Also used : ActionButton(com.intellij.openapi.actionSystem.impl.ActionButton) PropertiesComponent(com.intellij.ide.util.PropertiesComponent)

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