Search in sources :

Example 76 with AnActionEvent

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

the class PathEditor method createComponent.

public JComponent createComponent() {
    myList = new JBList(getListModel());
    myList.setCellRenderer(createListCellRenderer(myList));
    TreeUIHelper.getInstance().installListSpeedSearch(myList, new Convertor<Object, String>() {

        @Override
        public String convert(Object file) {
            return ((VirtualFile) file).getPresentableUrl();
        }
    });
    ToolbarDecorator toolbarDecorator = ToolbarDecorator.createDecorator(myList).disableUpDownActions().setAddActionUpdater(new AnActionButtonUpdater() {

        @Override
        public boolean isEnabled(AnActionEvent e) {
            return myEnabled;
        }
    }).setRemoveActionUpdater(new AnActionButtonUpdater() {

        @Override
        public boolean isEnabled(AnActionEvent e) {
            return isRemoveActionEnabled(PathEditor.this.getSelectedRoots());
        }
    }).setAddAction(new AnActionButtonRunnable() {

        @Override
        public void run(AnActionButton button) {
            final VirtualFile[] added = doAddItems();
            if (added.length > 0) {
                setModified(true);
            }
            requestDefaultFocus();
            setSelectedRoots(added);
        }
    }).setRemoveAction(new AnActionButtonRunnable() {

        @Override
        public void run(AnActionButton button) {
            int[] indices = myList.getSelectedIndices();
            doRemoveItems(indices, myList);
        }
    });
    addToolbarButtons(toolbarDecorator);
    myPanel = toolbarDecorator.createPanel();
    myPanel.setBorder(null);
    return myPanel;
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) JBList(com.intellij.ui.components.JBList) AnActionEvent(com.intellij.openapi.actionSystem.AnActionEvent)

Example 77 with AnActionEvent

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

the class UnifiedDiffChange method createIconRenderer.

@Nullable
private GutterIconRenderer createIconRenderer(@NotNull final Side sourceSide, @NotNull final String tooltipText, @NotNull final Icon icon) {
    return new DiffGutterRenderer(icon, tooltipText) {

        @Override
        protected void performAction(AnActionEvent e) {
            if (myViewer.isStateIsOutOfDate())
                return;
            if (!myViewer.isEditable(sourceSide.other(), true))
                return;
            final Project project = e.getProject();
            final Document document = myViewer.getDocument(sourceSide.other());
            DiffUtil.executeWriteCommand(document, project, "Replace change", () -> {
                myViewer.replaceChange(UnifiedDiffChange.this, sourceSide);
                myViewer.scheduleRediff();
            });
            // applyChange() will schedule rediff, but we want to try to do it in sync
            // and we can't do it inside write action
            myViewer.rediff();
        }
    };
}
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 78 with AnActionEvent

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

the class ProjectStartupConfigurable method createComponent.

@Nullable
@Override
public JComponent createComponent() {
    myModel = new ProjectStartupTasksTableModel(RunManagerEx.getInstanceEx(myProject));
    myTable = new JBTable(myModel);
    myTable.getEmptyText().setText("Add run configurations with the + button");
    new TableSpeedSearch(myTable);
    DefaultCellEditor defaultEditor = (DefaultCellEditor) myTable.getDefaultEditor(Object.class);
    defaultEditor.setClickCountToStart(1);
    myTable.getSelectionModel().setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    new DumbAwareAction() {

        @Override
        public void actionPerformed(AnActionEvent e) {
            final int row = myTable.getSelectedRow();
            if (row >= 0 && myModel.isCellEditable(row, ProjectStartupTasksTableModel.IS_SHARED_COLUMN)) {
                myModel.setValueAt(!Boolean.TRUE.equals(myTable.getValueAt(row, ProjectStartupTasksTableModel.IS_SHARED_COLUMN)), row, ProjectStartupTasksTableModel.IS_SHARED_COLUMN);
            }
        }
    }.registerCustomShortcutSet(new CustomShortcutSet(KeyEvent.VK_SPACE), myTable);
    myTable.addMouseListener(new MouseAdapter() {

        @Override
        public void mouseClicked(MouseEvent e) {
            if (e.getClickCount() >= 2) {
                editRunConfiguration();
            }
        }
    });
    installRenderers();
    myDecorator = ToolbarDecorator.createDecorator(myTable).setAddAction(new AnActionButtonRunnable() {

        @Override
        public void run(AnActionButton button) {
            selectAndAddConfiguration(button);
        }
    }).setEditAction(new AnActionButtonRunnable() {

        @Override
        public void run(AnActionButton button) {
            editRunConfiguration();
        }
    }).setEditActionUpdater(new AnActionButtonUpdater() {

        @Override
        public boolean isEnabled(AnActionEvent e) {
            return myTable.getSelectedRow() >= 0;
        }
    }).disableUpAction().disableDownAction();
    final JPanel tasksPanel = myDecorator.createPanel();
    final JLabel label = new JLabel("Run tasks and tools via run configurations");
    label.setForeground(UIUtil.getInactiveTextColor());
    label.setHorizontalAlignment(SwingConstants.RIGHT);
    final JPanel wrapper = new JPanel(new BorderLayout());
    wrapper.add(new JLabel("To be started on project opening:"), BorderLayout.WEST);
    wrapper.add(label, BorderLayout.EAST);
    wrapper.setBorder(BorderFactory.createEmptyBorder(0, 0, UIUtil.DEFAULT_VGAP, 0));
    final JPanel main = new JPanel(new BorderLayout());
    main.add(wrapper, BorderLayout.NORTH);
    main.add(tasksPanel, BorderLayout.CENTER);
    return main;
}
Also used : MouseEvent(java.awt.event.MouseEvent) MouseAdapter(java.awt.event.MouseAdapter) JBTable(com.intellij.ui.table.JBTable) AnActionEvent(com.intellij.openapi.actionSystem.AnActionEvent) DumbAwareAction(com.intellij.openapi.project.DumbAwareAction) CustomShortcutSet(com.intellij.openapi.actionSystem.CustomShortcutSet) Nullable(org.jetbrains.annotations.Nullable)

Example 79 with AnActionEvent

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

the class ShowInstancesByClassAction method perform.

@Override
protected void perform(XValueNodeImpl node, @NotNull String nodeName, AnActionEvent e) {
    final Project project = e.getProject();
    if (project != null) {
        final XDebugSession debugSession = XDebuggerManager.getInstance(project).getCurrentSession();
        final ObjectReference ref = getObjectReference(node);
        if (debugSession != null && ref != null) {
            final ReferenceType referenceType = ref.referenceType();
            new InstancesWindow(debugSession, l -> {
                final List<ObjectReference> instances = referenceType.instances(l);
                return instances == null ? Collections.emptyList() : instances;
            }, referenceType.name()).show();
        }
    }
}
Also used : List(java.util.List) XValueNodeImpl(com.intellij.xdebugger.impl.ui.tree.nodes.XValueNodeImpl) StringUtil(com.intellij.openapi.util.text.StringUtil) AnActionEvent(com.intellij.openapi.actionSystem.AnActionEvent) ReferenceType(com.sun.jdi.ReferenceType) Project(com.intellij.openapi.project.Project) XDebuggerManager(com.intellij.xdebugger.XDebuggerManager) InstancesWindow(com.intellij.debugger.memory.ui.InstancesWindow) ObjectReference(com.sun.jdi.ObjectReference) NotNull(org.jetbrains.annotations.NotNull) XDebugSession(com.intellij.xdebugger.XDebugSession) Collections(java.util.Collections) Project(com.intellij.openapi.project.Project) XDebugSession(com.intellij.xdebugger.XDebugSession) InstancesWindow(com.intellij.debugger.memory.ui.InstancesWindow) ObjectReference(com.sun.jdi.ObjectReference) List(java.util.List) ReferenceType(com.sun.jdi.ReferenceType)

Example 80 with AnActionEvent

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

the class VcsPushDialog method createForcePushInfoLabel.

@NotNull
private JComponent createForcePushInfoLabel() {
    JPanel text = new JPanel();
    text.setLayout(new BoxLayout(text, BoxLayout.X_AXIS));
    JLabel label = new JLabel("You can enable and configure Force Push in " + ShowSettingsUtil.getSettingsMenuName() + ".");
    label.setEnabled(false);
    label.setFont(JBUI.Fonts.smallFont());
    text.add(label);
    ActionLink here = new ActionLink("Configure", new AnAction() {

        @Override
        public void actionPerformed(AnActionEvent e) {
            Project project = myController.getProject();
            VcsPushDialog.this.doCancelAction(e.getInputEvent());
            ShowSettingsUtilImpl.showSettingsDialog(project, "vcs.Git", "force push");
        }
    });
    here.setFont(JBUI.Fonts.smallFont());
    text.add(here);
    return JBUI.Panels.simplePanel().addToRight(text).withBorder(JBUI.Borders.emptyBottom(4));
}
Also used : Project(com.intellij.openapi.project.Project) AnActionEvent(com.intellij.openapi.actionSystem.AnActionEvent) AnAction(com.intellij.openapi.actionSystem.AnAction) ActionLink(com.intellij.ui.components.labels.ActionLink) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

AnActionEvent (com.intellij.openapi.actionSystem.AnActionEvent)129 AnAction (com.intellij.openapi.actionSystem.AnAction)67 Project (com.intellij.openapi.project.Project)27 NotNull (org.jetbrains.annotations.NotNull)25 DumbAwareAction (com.intellij.openapi.project.DumbAwareAction)22 VirtualFile (com.intellij.openapi.vfs.VirtualFile)21 Nullable (org.jetbrains.annotations.Nullable)20 DefaultActionGroup (com.intellij.openapi.actionSystem.DefaultActionGroup)15 List (java.util.List)14 CustomShortcutSet (com.intellij.openapi.actionSystem.CustomShortcutSet)13 ArrayList (java.util.ArrayList)11 Presentation (com.intellij.openapi.actionSystem.Presentation)10 StringUtil (com.intellij.openapi.util.text.StringUtil)9 CommonDataKeys (com.intellij.openapi.actionSystem.CommonDataKeys)8 JBTable (com.intellij.ui.table.JBTable)8 DataContext (com.intellij.openapi.actionSystem.DataContext)7 Pair (com.intellij.openapi.util.Pair)7 Logger (com.intellij.openapi.diagnostic.Logger)6 Ref (com.intellij.openapi.util.Ref)6 AnActionButton (com.intellij.ui.AnActionButton)6