Search in sources :

Example 1 with AnActionButtonRunnable

use of com.intellij.ui.AnActionButtonRunnable 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 2 with AnActionButtonRunnable

use of com.intellij.ui.AnActionButtonRunnable in project intellij-community by JetBrains.

the class CheckBoxListModelEditor method editAction.

@NotNull
public CheckBoxListModelEditor<T> editAction(@NotNull final Function<T, T> consumer) {
    final Runnable action = () -> {
        T item = getSelectedItem();
        if (item != null) {
            T newItem = consumer.fun(item);
            if (newItem != null) {
                list.updateItem(item, newItem, StringUtil.notNullize(toNameConverter.fun(newItem)));
            }
            IdeFocusManager.getGlobalInstance().doWhenFocusSettlesDown(() -> {
                IdeFocusManager.getGlobalInstance().requestFocus(list, true);
            });
        }
    };
    toolbarDecorator.setEditAction(new AnActionButtonRunnable() {

        @Override
        public void run(AnActionButton button) {
            action.run();
        }
    });
    EditSourceOnDoubleClickHandler.install(list, action);
    return this;
}
Also used : AnActionButtonRunnable(com.intellij.ui.AnActionButtonRunnable) AnActionButtonRunnable(com.intellij.ui.AnActionButtonRunnable) AnActionButton(com.intellij.ui.AnActionButton) NotNull(org.jetbrains.annotations.NotNull)

Example 3 with AnActionButtonRunnable

use of com.intellij.ui.AnActionButtonRunnable in project intellij-plugins by JetBrains.

the class AddRemoveTableRowsDialog method initButtons.

private void initButtons() {
    ToolbarDecorator d = ToolbarDecorator.createDecorator(myTable);
    d.setAddAction(new AnActionButtonRunnable() {

        public void run(AnActionButton button) {
            if (addObject()) {
                ((AbstractTableModel) myTable.getModel()).fireTableDataChanged();
                if (myEditAddedRow) {
                    myTable.editCellAt(myTable.getRowCount() - 1, 0);
                }
            }
        }
    });
    d.setRemoveAction(new AnActionButtonRunnable() {

        public void run(AnActionButton anActionButton) {
            TableUtil.stopEditing(myTable);
            final int[] selectedRows = myTable.getSelectedRows();
            Arrays.sort(selectedRows);
            for (int i = selectedRows.length - 1; i >= 0; i--) {
                myList.remove(selectedRows[i]);
            }
            ((AbstractTableModel) myTable.getModel()).fireTableDataChanged();
        }
    });
    myMainPanel.add(d.createPanel(), BorderLayout.CENTER);
}
Also used : AnActionButtonRunnable(com.intellij.ui.AnActionButtonRunnable) ToolbarDecorator(com.intellij.ui.ToolbarDecorator) AnActionButton(com.intellij.ui.AnActionButton)

Example 4 with AnActionButtonRunnable

use of com.intellij.ui.AnActionButtonRunnable in project azure-tools-for-java by Microsoft.

the class WebAppDeployDialog method createUIComponents.

private void createUIComponents() {
    DefaultTableModel tableModel = new DefaultTableModel() {

        @Override
        public boolean isCellEditable(int row, int column) {
            return false;
        }
    };
    tableModel.addColumn("Name");
    tableModel.addColumn("JDK");
    tableModel.addColumn("Web container");
    tableModel.addColumn("Resource group");
    table = new JBTable(tableModel);
    table.setRowSelectionAllowed(true);
    table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    table.getSelectionModel().addListSelectionListener(new ListSelectionListener() {

        public void valueChanged(ListSelectionEvent event) {
            if (event.getValueIsAdjusting())
                return;
            //System.out.println("row : " + table.getValueAt(table.getSelectedRow(), 0).toString());
            fillAppServiceDetails();
        }
    });
    AnActionButton refreshAction = new AnActionButton("Refresh", AllIcons.Actions.Refresh) {

        @Override
        public void actionPerformed(AnActionEvent anActionEvent) {
            refreshAppServices();
        }
    };
    ToolbarDecorator tableToolbarDecorator = ToolbarDecorator.createDecorator(table).setAddAction(new AnActionButtonRunnable() {

        @Override
        public void run(AnActionButton button) {
            createAppService();
        }
    }).setRemoveAction(new AnActionButtonRunnable() {

        @Override
        public void run(AnActionButton button) {
            deleteAppService();
        }
    }).setRemoveActionUpdater(new AnActionButtonUpdater() {

        @Override
        public boolean isEnabled(AnActionEvent e) {
            return table.getSelectedRow() != -1;
        }
    }).disableUpDownActions().addExtraActions(refreshAction);
    panelTable = tableToolbarDecorator.createPanel();
}
Also used : AnActionButtonRunnable(com.intellij.ui.AnActionButtonRunnable) AnActionButtonUpdater(com.intellij.ui.AnActionButtonUpdater) DefaultTableModel(javax.swing.table.DefaultTableModel) ListSelectionEvent(javax.swing.event.ListSelectionEvent) ToolbarDecorator(com.intellij.ui.ToolbarDecorator) JBTable(com.intellij.ui.table.JBTable) AnActionEvent(com.intellij.openapi.actionSystem.AnActionEvent) AnActionButton(com.intellij.ui.AnActionButton) ListSelectionListener(javax.swing.event.ListSelectionListener)

Example 5 with AnActionButtonRunnable

use of com.intellij.ui.AnActionButtonRunnable in project intellij-plugins by JetBrains.

the class FilesToPackageForm method initTableButtons.

private void initTableButtons() {
    ToolbarDecorator d = ToolbarDecorator.createDecorator(myFilesToPackageTable);
    d.setAddAction(new AnActionButtonRunnable() {

        public void run(AnActionButton button) {
            final FileChooserDescriptor descriptor = new FileChooserDescriptor(true, true, false, true, false, true);
            final VirtualFile[] files = FileChooser.chooseFiles(descriptor, myProject, null);
            final ProjectFileIndex fileIndex = ProjectRootManager.getInstance(myProject).getFileIndex();
            for (final VirtualFile file : files) {
                final VirtualFile sourceRoot = fileIndex.getSourceRootForFile(file);
                String relativePath = sourceRoot == null ? null : sourceRoot.equals(file) ? "." : VfsUtilCore.getRelativePath(file, sourceRoot, '/');
                myFilesToPackage.add(new FilePathAndPathInPackage(file.getPath(), StringUtil.notNullize(relativePath, file.getName())));
            }
            if (files.length > 0) {
                fireDataChanged();
                IdeFocusManager.getInstance(myProject).requestFocus(myFilesToPackageTable, true);
                final int rowCount = myFilesToPackageTable.getRowCount();
                myFilesToPackageTable.setRowSelectionInterval(rowCount - files.length, rowCount - 1);
            }
        }
    });
    d.setRemoveAction(new AnActionButtonRunnable() {

        public void run(AnActionButton anActionButton) {
            TableUtil.stopEditing(myFilesToPackageTable);
            final int[] selectedRows = myFilesToPackageTable.getSelectedRows();
            Arrays.sort(selectedRows);
            for (int i = selectedRows.length - 1; i >= 0; i--) {
                myFilesToPackage.remove(selectedRows[i]);
            }
            fireDataChanged();
        }
    });
    myMainPanel.add(d.createPanel(), BorderLayout.CENTER);
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) FilePathAndPathInPackage(com.intellij.lang.javascript.flex.projectStructure.model.AirPackagingOptions.FilePathAndPathInPackage) AnActionButtonRunnable(com.intellij.ui.AnActionButtonRunnable) ProjectFileIndex(com.intellij.openapi.roots.ProjectFileIndex) FileChooserDescriptor(com.intellij.openapi.fileChooser.FileChooserDescriptor) ToolbarDecorator(com.intellij.ui.ToolbarDecorator) AnActionButton(com.intellij.ui.AnActionButton)

Aggregations

AnActionButton (com.intellij.ui.AnActionButton)10 AnActionButtonRunnable (com.intellij.ui.AnActionButtonRunnable)10 ToolbarDecorator (com.intellij.ui.ToolbarDecorator)8 AnActionEvent (com.intellij.openapi.actionSystem.AnActionEvent)3 ArrayList (java.util.ArrayList)3 VirtualFile (com.intellij.openapi.vfs.VirtualFile)2 CustomLineBorder (com.intellij.ui.border.CustomLineBorder)2 Tree (com.intellij.ui.treeStructure.Tree)2 List (java.util.List)2 CloudLineBreakpointType (com.google.cloud.tools.intellij.debugger.CloudLineBreakpointType)1 Breakpoint (com.intellij.debugger.ui.breakpoints.Breakpoint)1 JsonBundle (com.intellij.json.JsonBundle)1 FilePathAndPathInPackage (com.intellij.lang.javascript.flex.projectStructure.model.AirPackagingOptions.FilePathAndPathInPackage)1 Disposable (com.intellij.openapi.Disposable)1 CommonShortcuts (com.intellij.openapi.actionSystem.CommonShortcuts)1 CustomShortcutSet (com.intellij.openapi.actionSystem.CustomShortcutSet)1 ModalityState (com.intellij.openapi.application.ModalityState)1 DocumentImpl (com.intellij.openapi.editor.impl.DocumentImpl)1 FileChooserDescriptor (com.intellij.openapi.fileChooser.FileChooserDescriptor)1 FileChooserDescriptorFactory (com.intellij.openapi.fileChooser.FileChooserDescriptorFactory)1