Search in sources :

Example 6 with AnAction

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

the class SvnQuickListContentProvider method getVcsActions.

public List<AnAction> getVcsActions(@Nullable Project project, @Nullable AbstractVcs activeVcs, @Nullable DataContext dataContext) {
    if (activeVcs == null || !SvnVcs.VCS_NAME.equals(activeVcs.getName())) {
        return null;
    }
    final ActionManager manager = ActionManager.getInstance();
    final List<AnAction> actions = new ArrayList<>();
    add("Subversion.Copy", manager, actions);
    add("Subversion.Clenaup", manager, actions);
    return actions;
}
Also used : ActionManager(com.intellij.openapi.actionSystem.ActionManager) ArrayList(java.util.ArrayList) AnAction(com.intellij.openapi.actionSystem.AnAction)

Example 7 with AnAction

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

the class InplaceEditingLayer method startEditing.

public void startEditing(@Nullable InplaceContext inplaceContext) {
    try {
        List<RadComponent> selection = myDesigner.getSurfaceArea().getSelection();
        if (selection.size() != 1) {
            return;
        }
        myRadComponent = selection.get(0);
        myProperties = myRadComponent.getInplaceProperties();
        if (myProperties.isEmpty()) {
            myRadComponent = null;
            myProperties = null;
            return;
        }
        myInplaceComponent = new JPanel(new GridLayoutManager(myProperties.size(), 2));
        myInplaceComponent.setBorder(new LineMarginBorder(5, 5, 5, 5));
        new AnAction() {

            @Override
            public void actionPerformed(AnActionEvent e) {
                finishEditing(false);
            }
        }.registerCustomShortcutSet(CommonShortcuts.ESCAPE, myInplaceComponent);
        myEditors = new ArrayList<>();
        JComponent componentToFocus = null;
        Font font = null;
        if (inplaceContext == null) {
            inplaceContext = new InplaceContext();
        }
        int row = 0;
        for (Property property : myProperties) {
            JLabel label = new JLabel(property.getName() + ":");
            if (font == null) {
                font = label.getFont().deriveFont(Font.BOLD);
            }
            label.setFont(font);
            myInplaceComponent.add(label, new GridConstraints(row, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, 0, 0, null, null, null));
            PropertyEditor editor = property.getEditor();
            myEditors.add(editor);
            JComponent component = editor.getComponent(myRadComponent, myDesigner, property.getValue(myRadComponent), inplaceContext);
            myInplaceComponent.add(component, new GridConstraints(row++, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_GROW, 0, null, null, null));
            if (componentToFocus == null) {
                componentToFocus = editor.getPreferredFocusedComponent();
            }
        }
        for (PropertyEditor editor : myEditors) {
            editor.addPropertyEditorListener(myEditorListener);
        }
        Rectangle bounds = myRadComponent.getBounds(this);
        Dimension size = myInplaceComponent.getPreferredSize();
        myPreferredWidth = Math.max(size.width, bounds.width);
        myInplaceComponent.setBounds(bounds.x, bounds.y, myPreferredWidth, size.height);
        add(myInplaceComponent);
        myDesigner.getSurfaceArea().addSelectionListener(mySelectionListener);
        if (componentToFocus == null) {
            componentToFocus = IdeFocusTraversalPolicy.getPreferredFocusedComponent(myInplaceComponent);
        }
        if (componentToFocus == null) {
            componentToFocus = myInplaceComponent;
        }
        if (componentToFocus.requestFocusInWindow()) {
            myFocusWatcher.install(myInplaceComponent);
        } else {
            grabFocus();
            final JComponent finalComponentToFocus = componentToFocus;
            ApplicationManager.getApplication().invokeLater(() -> {
                finalComponentToFocus.requestFocusInWindow();
                myFocusWatcher.install(myInplaceComponent);
            });
        }
        enableEvents(AWTEvent.MOUSE_EVENT_MASK);
        repaint();
    } catch (Throwable e) {
        LOG.error(e);
    }
}
Also used : RadComponent(com.intellij.designer.model.RadComponent) AnActionEvent(com.intellij.openapi.actionSystem.AnActionEvent) AnAction(com.intellij.openapi.actionSystem.AnAction) GridLayoutManager(com.intellij.uiDesigner.core.GridLayoutManager) GridConstraints(com.intellij.uiDesigner.core.GridConstraints) LineMarginBorder(com.intellij.designer.designSurface.feedbacks.LineMarginBorder) PropertyEditor(com.intellij.designer.propertyTable.PropertyEditor) InplaceContext(com.intellij.designer.propertyTable.InplaceContext) Property(com.intellij.designer.model.Property)

Example 8 with AnAction

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

the class DesignerToolWindow method createActions.

AnAction[] createActions() {
    AnAction expandAll = new AnAction("Expand All", null, AllIcons.Actions.Expandall) {

        @Override
        public void actionPerformed(AnActionEvent e) {
            if (myTreeBuilder != null) {
                TreeUtil.expandAll(myComponentTree);
            }
        }
    };
    AnAction collapseAll = new AnAction("Collapse All", null, AllIcons.Actions.Collapseall) {

        @Override
        public void actionPerformed(AnActionEvent e) {
            if (myTreeBuilder != null) {
                TreeUtil.collapseAll(myComponentTree, 1);
            }
        }
    };
    return new AnAction[] { expandAll, collapseAll };
}
Also used : AnActionEvent(com.intellij.openapi.actionSystem.AnActionEvent) AnAction(com.intellij.openapi.actionSystem.AnAction)

Example 9 with AnAction

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

the class AbstractComboBoxAction method createPopupActionGroup.

@NotNull
@Override
protected DefaultActionGroup createPopupActionGroup(JComponent button) {
    DefaultActionGroup actionGroup = new DefaultActionGroup();
    for (final T item : myItems) {
        if (addSeparator(actionGroup, item)) {
            continue;
        }
        AnAction action = new AnAction() {

            @Override
            public void actionPerformed(AnActionEvent e) {
                if (mySelection != item && selectionChanged(item)) {
                    mySelection = item;
                    AbstractComboBoxAction.this.update(item, myPresentation, false);
                }
            }
        };
        actionGroup.add(action);
        Presentation presentation = action.getTemplatePresentation();
        presentation.setIcon(mySelection == item ? CHECKED : null);
        update(item, presentation, true);
    }
    return actionGroup;
}
Also used : AnActionEvent(com.intellij.openapi.actionSystem.AnActionEvent) Presentation(com.intellij.openapi.actionSystem.Presentation) DefaultActionGroup(com.intellij.openapi.actionSystem.DefaultActionGroup) AnAction(com.intellij.openapi.actionSystem.AnAction) NotNull(org.jetbrains.annotations.NotNull)

Example 10 with AnAction

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

the class PyConsoleUtil method createTabCompletionAction.

public static AnAction createTabCompletionAction(PythonConsoleView consoleView) {
    final AnAction runCompletions = new AnAction() {

        @Override
        public void actionPerformed(AnActionEvent e) {
            Editor editor = consoleView.getConsoleEditor();
            if (LookupManager.getActiveLookup(editor) != null) {
                AnAction replace = ActionManager.getInstance().getAction(IdeActions.ACTION_CHOOSE_LOOKUP_ITEM_REPLACE);
                ActionUtil.performActionDumbAware(replace, e);
                return;
            }
            AnAction completionAction = ActionManager.getInstance().getAction(IdeActions.ACTION_CODE_COMPLETION);
            if (completionAction != null) {
                ActionUtil.performActionDumbAware(completionAction, e);
            }
        }

        @Override
        public void update(AnActionEvent e) {
            Editor editor = consoleView.getConsoleEditor();
            if (LookupManager.getActiveLookup(editor) != null) {
                e.getPresentation().setEnabled(false);
            }
            int offset = editor.getCaretModel().getOffset();
            Document document = editor.getDocument();
            int lineStart = document.getLineStartOffset(document.getLineNumber(offset));
            String textToCursor = document.getText(new TextRange(lineStart, offset));
            e.getPresentation().setEnabled(!CharMatcher.WHITESPACE.matchesAllOf(textToCursor));
        }
    };
    runCompletions.registerCustomShortcutSet(KeyEvent.VK_TAB, 0, consoleView.getConsoleEditor().getComponent());
    runCompletions.getTemplatePresentation().setVisible(false);
    return runCompletions;
}
Also used : TextRange(com.intellij.openapi.util.TextRange) AnActionEvent(com.intellij.openapi.actionSystem.AnActionEvent) Editor(com.intellij.openapi.editor.Editor) Document(com.intellij.openapi.editor.Document) AnAction(com.intellij.openapi.actionSystem.AnAction)

Aggregations

AnAction (com.intellij.openapi.actionSystem.AnAction)184 AnActionEvent (com.intellij.openapi.actionSystem.AnActionEvent)62 NotNull (org.jetbrains.annotations.NotNull)31 Project (com.intellij.openapi.project.Project)24 Nullable (org.jetbrains.annotations.Nullable)22 ActionManager (com.intellij.openapi.actionSystem.ActionManager)21 DefaultActionGroup (com.intellij.openapi.actionSystem.DefaultActionGroup)21 CustomShortcutSet (com.intellij.openapi.actionSystem.CustomShortcutSet)13 ArrayList (java.util.ArrayList)13 DumbAwareAction (com.intellij.openapi.project.DumbAwareAction)8 VirtualFile (com.intellij.openapi.vfs.VirtualFile)8 ActionGroup (com.intellij.openapi.actionSystem.ActionGroup)7 Presentation (com.intellij.openapi.actionSystem.Presentation)7 PsiFile (com.intellij.psi.PsiFile)7 ReopenProjectAction (com.intellij.ide.ReopenProjectAction)6 Editor (com.intellij.openapi.editor.Editor)6 Keymap (com.intellij.openapi.keymap.Keymap)6 Ref (com.intellij.openapi.util.Ref)6 List (java.util.List)6 DataContext (com.intellij.openapi.actionSystem.DataContext)5