Search in sources :

Example 11 with AnActionEvent

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

the class MorphAction method actionPerformed.

protected void actionPerformed(final GuiEditor editor, final List<RadComponent> selection, final AnActionEvent e) {
    Processor<ComponentItem> processor = selectedValue -> {
        Runnable runnable = () -> {
            for (RadComponent c : selection) {
                if (!morphComponent(editor, c, selectedValue))
                    break;
            }
            editor.refreshAndSave(true);
        };
        CommandProcessor.getInstance().executeCommand(editor.getProject(), runnable, UIDesignerBundle.message("morph.component.command"), null);
        IdeFocusManager.getGlobalInstance().doWhenFocusSettlesDown(() -> {
            IdeFocusManager.getGlobalInstance().requestFocus(editor.getGlassLayer(), true);
        });
        return true;
    };
    PaletteListPopupStep step = new PaletteListPopupStep(editor, myLastMorphComponent, processor, UIDesignerBundle.message("morph.component.title"));
    step.hideNonAtomic();
    if (selection.size() == 1) {
        step.hideComponentClass(selection.get(0).getComponentClassName());
    }
    final ListPopup listPopup = JBPopupFactory.getInstance().createListPopup(step);
    FormEditingUtil.showPopupUnderComponent(listPopup, selection.get(0));
}
Also used : PsiType(com.intellij.psi.PsiType) UIDesignerBundle(com.intellij.uiDesigner.UIDesignerBundle) RadAtomicComponent(com.intellij.uiDesigner.radComponents.RadAtomicComponent) JavaPsiFacade(com.intellij.psi.JavaPsiFacade) ChangeFieldTypeFix(com.intellij.uiDesigner.quickFixes.ChangeFieldTypeFix) ArrayList(java.util.ArrayList) GuiEditor(com.intellij.uiDesigner.designSurface.GuiEditor) Palette(com.intellij.uiDesigner.palette.Palette) PsiElementFactory(com.intellij.psi.PsiElementFactory) IProperty(com.intellij.uiDesigner.lw.IProperty) Logger(com.intellij.openapi.diagnostic.Logger) IntroComponentProperty(com.intellij.uiDesigner.propertyInspector.properties.IntroComponentProperty) IncorrectOperationException(com.intellij.util.IncorrectOperationException) ComponentItem(com.intellij.uiDesigner.palette.ComponentItem) BindingProperty(com.intellij.uiDesigner.propertyInspector.properties.BindingProperty) RadComponent(com.intellij.uiDesigner.radComponents.RadComponent) FormEditingUtil(com.intellij.uiDesigner.FormEditingUtil) CommandProcessor(com.intellij.openapi.command.CommandProcessor) ListPopup(com.intellij.openapi.ui.popup.ListPopup) List(java.util.List) IComponent(com.intellij.uiDesigner.lw.IComponent) IdeFocusManager(com.intellij.openapi.wm.IdeFocusManager) JBPopupFactory(com.intellij.openapi.ui.popup.JBPopupFactory) Processor(com.intellij.util.Processor) AnActionEvent(com.intellij.openapi.actionSystem.AnActionEvent) PsiField(com.intellij.psi.PsiField) RadContainer(com.intellij.uiDesigner.radComponents.RadContainer) NotNull(org.jetbrains.annotations.NotNull) InsertComponentProcessor(com.intellij.uiDesigner.designSurface.InsertComponentProcessor) FormInspectionUtil(com.intellij.uiDesigner.inspections.FormInspectionUtil) IntrospectedProperty(com.intellij.uiDesigner.propertyInspector.IntrospectedProperty) ComponentItem(com.intellij.uiDesigner.palette.ComponentItem) RadComponent(com.intellij.uiDesigner.radComponents.RadComponent) ListPopup(com.intellij.openapi.ui.popup.ListPopup)

Example 12 with AnActionEvent

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

the class BoundIconRenderer method getClickAction.

@Override
@Nullable
public AnAction getClickAction() {
    return new AnAction() {

        @Override
        public void actionPerformed(AnActionEvent e) {
            List<PsiFile> formFiles = getBoundFormFiles();
            if (formFiles.size() > 0) {
                final VirtualFile virtualFile = formFiles.get(0).getVirtualFile();
                if (virtualFile == null) {
                    return;
                }
                Project project = myElement.getProject();
                FileEditor[] editors = FileEditorManager.getInstance(project).openFile(virtualFile, true);
                if (myElement instanceof PsiField) {
                    for (FileEditor editor : editors) {
                        if (editor instanceof UIFormEditor) {
                            ((UIFormEditor) editor).selectComponent(((PsiField) myElement).getName());
                        }
                    }
                }
            }
        }
    };
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) Project(com.intellij.openapi.project.Project) FileEditor(com.intellij.openapi.fileEditor.FileEditor) UIFormEditor(com.intellij.uiDesigner.editor.UIFormEditor) AnActionEvent(com.intellij.openapi.actionSystem.AnActionEvent) AnAction(com.intellij.openapi.actionSystem.AnAction) Nullable(org.jetbrains.annotations.Nullable)

Example 13 with AnActionEvent

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

the class TestNGConfigurationEditor method createView.

private void createView() {
    commonParametersPanel.add(commonJavaParameters, BorderLayout.CENTER);
    classField.setComponent(new EditorTextFieldWithBrowseButton(project, true, new JavaCodeFragment.VisibilityChecker() {

        @Override
        public Visibility isDeclarationVisible(PsiElement declaration, PsiElement place) {
            if (declaration instanceof PsiClass && place.getParent() instanceof PsiJavaCodeReferenceElement) {
                return Visibility.VISIBLE;
            }
            try {
                if (declaration instanceof PsiClass && new TestClassBrowser(project, TestNGConfigurationEditor.this).getFilter().isAccepted((PsiClass) declaration)) {
                    return Visibility.VISIBLE;
                }
            } catch (MessageInfoException e) {
                return Visibility.NOT_VISIBLE;
            }
            return Visibility.NOT_VISIBLE;
        }
    }));
    final EditorTextFieldWithBrowseButton methodEditorTextField = new EditorTextFieldWithBrowseButton(project, true, JavaCodeFragment.VisibilityChecker.EVERYTHING_VISIBLE, PlainTextLanguage.INSTANCE.getAssociatedFileType());
    methodField.setComponent(methodEditorTextField);
    groupField.setComponent(new TextFieldWithBrowseButton.NoPathCompletion());
    suiteField.setComponent(new TextFieldWithBrowseButton());
    packageField.setVisible(true);
    packageField.setEnabled(true);
    packageField.setComponent(new EditorTextFieldWithBrowseButton(project, false));
    TextFieldWithBrowseButton outputDirectoryButton = new TextFieldWithBrowseButton();
    outputDirectory.setComponent(outputDirectoryButton);
    outputDirectoryButton.addBrowseFolderListener("TestNG", "Select test output directory", project, FileChooserDescriptorFactory.createSingleFolderDescriptor());
    moduleClasspath.setEnabled(true);
    moduleClasspath.setComponent(new ModulesComboBox());
    propertiesTableModel = new TestNGParametersTableModel();
    listenerModel = new TestNGListenersTableModel();
    TextFieldWithBrowseButton textFieldWithBrowseButton = new TextFieldWithBrowseButton();
    propertiesFile.setComponent(textFieldWithBrowseButton);
    FileChooserDescriptor propertiesFileDescriptor = new FileChooserDescriptor(true, false, false, false, false, false) {

        @Override
        public boolean isFileVisible(VirtualFile virtualFile, boolean showHidden) {
            if (!showHidden && virtualFile.getName().charAt(0) == '.')
                return false;
            return virtualFile.isDirectory() || "properties".equals(virtualFile.getExtension());
        }
    };
    textFieldWithBrowseButton.addBrowseFolderListener("TestNG", "Select .properties file for test properties", project, propertiesFileDescriptor);
    propertiesTableView = new TableView(propertiesTableModel);
    myPropertiesPanel.add(ToolbarDecorator.createDecorator(propertiesTableView).setAddAction(new AnActionButtonRunnable() {

        @Override
        public void run(AnActionButton button) {
            propertiesTableModel.addParameter();
            int index = propertiesTableModel.getRowCount() - 1;
            propertiesTableView.setRowSelectionInterval(index, index);
        }
    }).setRemoveAction(new AnActionButtonRunnable() {

        @Override
        public void run(AnActionButton button) {
            int idx = propertiesTableView.getSelectedRow() - 1;
            for (int row : propertiesTableView.getSelectedRows()) {
                propertiesTableModel.removeProperty(row);
            }
            if (idx > -1)
                propertiesTableView.setRowSelectionInterval(idx, idx);
        }
    }).disableUpDownActions().createPanel(), BorderLayout.CENTER);
    myListenersList = new JBList(listenerModel);
    myListenersPanel.add(ToolbarDecorator.createDecorator(myListenersList).setAddAction(new AddActionButtonRunnable()).setRemoveAction(new AnActionButtonRunnable() {

        @Override
        public void run(AnActionButton button) {
            int idx = myListenersList.getSelectedIndex() - 1;
            for (int row : myListenersList.getSelectedIndices()) {
                listenerModel.removeListener(row);
            }
            if (idx > -1)
                myListenersList.setSelectedIndex(idx);
        }
    }).setAddActionUpdater(new AnActionButtonUpdater() {

        @Override
        public boolean isEnabled(AnActionEvent e) {
            return !project.isDefault();
        }
    }).disableUpDownActions().createPanel(), BorderLayout.CENTER);
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) FileChooserDescriptor(com.intellij.openapi.fileChooser.FileChooserDescriptor) AnActionEvent(com.intellij.openapi.actionSystem.AnActionEvent) MessageInfoException(com.theoryinpractice.testng.MessageInfoException) ModulesComboBox(com.intellij.application.options.ModulesComboBox) TestClassBrowser(com.theoryinpractice.testng.configuration.browser.TestClassBrowser) JBList(com.intellij.ui.components.JBList) TableView(com.intellij.ui.table.TableView)

Example 14 with AnActionEvent

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

the class JBTabbedTerminalWidget method convertActions.

public static void convertActions(@NotNull JComponent component, @NotNull List<TerminalAction> actions, @Nullable final Predicate<KeyEvent> elseAction) {
    for (final TerminalAction action : actions) {
        if (action.isHidden()) {
            continue;
        }
        AnAction a = new DumbAwareAction() {

            @Override
            public void actionPerformed(AnActionEvent e) {
                KeyEvent event = e.getInputEvent() instanceof KeyEvent ? (KeyEvent) e.getInputEvent() : null;
                if (!action.perform(event)) {
                    if (elseAction != null) {
                        elseAction.apply(event);
                    }
                }
            }
        };
        a.registerCustomShortcutSet(action.getKeyCode(), action.getModifiers(), component);
    }
}
Also used : AnActionEvent(com.intellij.openapi.actionSystem.AnActionEvent) AnAction(com.intellij.openapi.actionSystem.AnAction) DumbAwareAction(com.intellij.openapi.project.DumbAwareAction)

Example 15 with AnActionEvent

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

the class OpenUrlHyperlinkInfo method getPopupMenuGroup.

@Override
public ActionGroup getPopupMenuGroup(@NotNull MouseEvent event) {
    DefaultActionGroup group = new DefaultActionGroup();
    for (final WebBrowser browser : WebBrowserManager.getInstance().getActiveBrowsers()) {
        if (browserCondition.value(browser)) {
            group.add(new AnAction("Open in " + browser.getName(), "Open URL in " + browser.getName(), browser.getIcon()) {

                @Override
                public void actionPerformed(AnActionEvent e) {
                    BrowserLauncher.getInstance().browse(url, browser, e.getProject());
                }
            });
        }
    }
    group.add(new AnAction("Copy URL", "Copy URL to clipboard", PlatformIcons.COPY_ICON) {

        @Override
        public void actionPerformed(AnActionEvent e) {
            CopyPasteManager.getInstance().setContents(new StringSelection(url));
        }
    });
    return group;
}
Also used : AnActionEvent(com.intellij.openapi.actionSystem.AnActionEvent) DefaultActionGroup(com.intellij.openapi.actionSystem.DefaultActionGroup) AnAction(com.intellij.openapi.actionSystem.AnAction) StringSelection(java.awt.datatransfer.StringSelection)

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