Search in sources :

Example 31 with AnActionEvent

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

the class AbstractVcsHelperImpl method openCommittedChangesTab.

public void openCommittedChangesTab(final CommittedChangesProvider provider, final RepositoryLocation location, final ChangeBrowserSettings settings, final int maxCount, String title) {
    DefaultActionGroup extraActions = new DefaultActionGroup();
    CommittedChangesPanel panel = new CommittedChangesPanel(myProject, provider, settings, location, extraActions);
    panel.setMaxCount(maxCount);
    panel.refreshChanges(false);
    final ContentFactory factory = ContentFactory.SERVICE.getInstance();
    if (title == null && location != null) {
        title = VcsBundle.message("browse.changes.content.title", location.toPresentableString());
    }
    final Content content = factory.createContent(panel, title, false);
    final ChangesViewContentI contentManager = ChangesViewContentManager.getInstance(myProject);
    contentManager.addContent(content);
    contentManager.setSelectedContent(content);
    extraActions.add(new CloseTabToolbarAction() {

        public void actionPerformed(final AnActionEvent e) {
            contentManager.removeContent(content);
        }
    });
    ToolWindow window = ToolWindowManager.getInstance(myProject).getToolWindow(ChangesViewContentManager.TOOLWINDOW_ID);
    if (!window.isVisible()) {
        window.activate(null);
    }
}
Also used : ToolWindow(com.intellij.openapi.wm.ToolWindow) Content(com.intellij.ui.content.Content) CloseTabToolbarAction(com.intellij.ide.actions.CloseTabToolbarAction) AnActionEvent(com.intellij.openapi.actionSystem.AnActionEvent) DefaultActionGroup(com.intellij.openapi.actionSystem.DefaultActionGroup) ContentFactory(com.intellij.ui.content.ContentFactory)

Example 32 with AnActionEvent

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

the class XDebuggerEditorBase method createLanguagePopup.

private ListPopup createLanguagePopup() {
    DefaultActionGroup actions = new DefaultActionGroup();
    for (Language language : getSupportedLanguages()) {
        //noinspection ConstantConditions
        actions.add(new AnAction(language.getDisplayName(), null, language.getAssociatedFileType().getIcon()) {

            @Override
            public void actionPerformed(@NotNull AnActionEvent e) {
                XExpression currentExpression = getExpression();
                setExpression(new XExpressionImpl(currentExpression.getExpression(), language, currentExpression.getCustomInfo()));
                requestFocusInEditor();
            }
        });
    }
    DataContext dataContext = DataManager.getInstance().getDataContext(getComponent());
    return JBPopupFactory.getInstance().createActionGroupPopup("Choose Language", actions, dataContext, JBPopupFactory.ActionSelectionAid.SPEEDSEARCH, false);
}
Also used : DataContext(com.intellij.openapi.actionSystem.DataContext) Language(com.intellij.lang.Language) XExpressionImpl(com.intellij.xdebugger.impl.breakpoints.XExpressionImpl) XExpression(com.intellij.xdebugger.XExpression) AnActionEvent(com.intellij.openapi.actionSystem.AnActionEvent) DefaultActionGroup(com.intellij.openapi.actionSystem.DefaultActionGroup) AnAction(com.intellij.openapi.actionSystem.AnAction)

Example 33 with AnActionEvent

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

the class CvsConfigurationsListEditor method createListPanel.

private JComponent createListPanel() {
    final AnActionButton duplicateButton = new DumbAwareActionButton(CvsBundle.message("action.name.copy"), PlatformIcons.COPY_ICON) {

        @Override
        public void updateButton(AnActionEvent e) {
            e.getPresentation().setEnabled(getSelectedConfiguration() != null);
        }

        @Override
        public void actionPerformed(AnActionEvent e) {
            copySelectedConfiguration();
        }
    };
    duplicateButton.setShortcut(new CustomShortcutSet(KeyStroke.getKeyStroke(KeyEvent.VK_D, SystemInfo.isMac ? KeyEvent.META_MASK : KeyEvent.CTRL_MASK)));
    final ToolbarDecorator decorator = ToolbarDecorator.createDecorator(myList).setAddAction(new AnActionButtonRunnable() {

        @Override
        public void run(AnActionButton anActionButton) {
            createNewConfiguration();
        }
    }).addExtraAction(duplicateButton);
    return decorator.createPanel();
}
Also used : DumbAwareActionButton(com.intellij.ui.DumbAwareActionButton) CustomShortcutSet(com.intellij.openapi.actionSystem.CustomShortcutSet) AnActionButtonRunnable(com.intellij.ui.AnActionButtonRunnable) ToolbarDecorator(com.intellij.ui.ToolbarDecorator) AnActionEvent(com.intellij.openapi.actionSystem.AnActionEvent) AnActionButton(com.intellij.ui.AnActionButton)

Example 34 with AnActionEvent

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

the class SimpleDiffChange method createIconRenderer.

@Nullable
private GutterIconRenderer createIconRenderer(@NotNull final Side sourceSide, @NotNull final String tooltipText, @NotNull final Icon icon, @NotNull final Runnable perform) {
    if (!DiffUtil.isEditable(myViewer.getEditor(sourceSide.other())))
        return null;
    return new DiffGutterRenderer(icon, tooltipText) {

        @Override
        protected void performAction(AnActionEvent e) {
            if (!myIsValid)
                return;
            final Project project = e.getProject();
            final Document document = myViewer.getEditor(sourceSide.other()).getDocument();
            DiffUtil.executeWriteCommand(document, project, "Replace change", perform);
        }
    };
}
Also used : Project(com.intellij.openapi.project.Project) AnActionEvent(com.intellij.openapi.actionSystem.AnActionEvent) Document(com.intellij.openapi.editor.Document) Nullable(org.jetbrains.annotations.Nullable)

Example 35 with AnActionEvent

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

the class CreateClassDialog method createNorthPanel.

@Override
protected JComponent createNorthPanel() {
    JPanel panel = new JPanel(new GridBagLayout());
    GridBagConstraints gbConstraints = new GridBagConstraints();
    gbConstraints.insets = JBUI.insets(4, 8);
    gbConstraints.fill = GridBagConstraints.HORIZONTAL;
    gbConstraints.anchor = GridBagConstraints.WEST;
    if (myClassNameEditable) {
        gbConstraints.weightx = 0;
        gbConstraints.gridwidth = 1;
        panel.add(myInformationLabel, gbConstraints);
        gbConstraints.insets = JBUI.insets(4, 8);
        gbConstraints.gridx = 1;
        gbConstraints.weightx = 1;
        gbConstraints.gridwidth = 1;
        gbConstraints.fill = GridBagConstraints.HORIZONTAL;
        gbConstraints.anchor = GridBagConstraints.WEST;
        panel.add(myTfClassName, gbConstraints);
        myTfClassName.getDocument().addDocumentListener(new DocumentAdapter() {

            @Override
            protected void textChanged(DocumentEvent e) {
                getOKAction().setEnabled(PsiNameHelper.getInstance(myProject).isIdentifier(myTfClassName.getText()));
            }
        });
        getOKAction().setEnabled(StringUtil.isNotEmpty(myClassName));
    }
    gbConstraints.gridx = 0;
    gbConstraints.gridy = 2;
    gbConstraints.weightx = 0;
    gbConstraints.gridwidth = 1;
    panel.add(myPackageLabel, gbConstraints);
    gbConstraints.gridx = 1;
    gbConstraints.weightx = 1;
    new AnAction() {

        @Override
        public void actionPerformed(AnActionEvent e) {
            myPackageComponent.getButton().doClick();
        }
    }.registerCustomShortcutSet(new CustomShortcutSet(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, InputEvent.SHIFT_DOWN_MASK)), myPackageComponent.getChildComponent());
    JPanel _panel = new JPanel(new BorderLayout());
    _panel.add(myPackageComponent, BorderLayout.CENTER);
    panel.add(_panel, gbConstraints);
    gbConstraints.gridy = 3;
    gbConstraints.gridx = 0;
    gbConstraints.gridwidth = 2;
    gbConstraints.insets.top = 12;
    gbConstraints.anchor = GridBagConstraints.WEST;
    gbConstraints.fill = GridBagConstraints.NONE;
    final JBLabel label = new JBLabel(RefactoringBundle.message("target.destination.folder"));
    panel.add(label, gbConstraints);
    gbConstraints.gridy = 4;
    gbConstraints.gridx = 0;
    gbConstraints.fill = GridBagConstraints.HORIZONTAL;
    gbConstraints.insets.top = 4;
    panel.add(myDestinationCB, gbConstraints);
    final boolean isMultipleSourceRoots = JavaProjectRootsUtil.getSuitableDestinationSourceRoots(myProject).size() > 1;
    myDestinationCB.setVisible(isMultipleSourceRoots);
    label.setVisible(isMultipleSourceRoots);
    label.setLabelFor(myDestinationCB);
    return panel;
}
Also used : CustomShortcutSet(com.intellij.openapi.actionSystem.CustomShortcutSet) JBLabel(com.intellij.ui.components.JBLabel) DocumentAdapter(com.intellij.ui.DocumentAdapter) DocumentEvent(javax.swing.event.DocumentEvent) AnActionEvent(com.intellij.openapi.actionSystem.AnActionEvent) AnAction(com.intellij.openapi.actionSystem.AnAction)

Aggregations

AnActionEvent (com.intellij.openapi.actionSystem.AnActionEvent)167 AnAction (com.intellij.openapi.actionSystem.AnAction)76 Project (com.intellij.openapi.project.Project)33 NotNull (org.jetbrains.annotations.NotNull)29 VirtualFile (com.intellij.openapi.vfs.VirtualFile)28 DumbAwareAction (com.intellij.openapi.project.DumbAwareAction)27 Nullable (org.jetbrains.annotations.Nullable)21 List (java.util.List)19 DefaultActionGroup (com.intellij.openapi.actionSystem.DefaultActionGroup)18 Test (org.junit.Test)16 CustomShortcutSet (com.intellij.openapi.actionSystem.CustomShortcutSet)13 ArrayList (java.util.ArrayList)13 SonarTest (org.sonarlint.intellij.SonarTest)13 Presentation (com.intellij.openapi.actionSystem.Presentation)12 JBTable (com.intellij.ui.table.JBTable)12 AnActionButton (com.intellij.ui.AnActionButton)11 Notification (com.intellij.notification.Notification)10 CommonDataKeys (com.intellij.openapi.actionSystem.CommonDataKeys)10 StringUtil (com.intellij.openapi.util.text.StringUtil)9 ToolbarDecorator (com.intellij.ui.ToolbarDecorator)9