com.intellij.ui.AnActionButton Java Examples

The following examples show how to use com.intellij.ui.AnActionButton. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: RoutingSettingsForm.java    From idea-php-symfony2-plugin with MIT License 6 votes vote down vote up
private void addWebDeploymentButton(ToolbarDecorator tablePanel) {
    tablePanel.addExtraAction(new AnActionButton("Remote", AllIcons.Actions.Download) {
        @Override
        public void actionPerformed(AnActionEvent anActionEvent) {
            UiSettingsUtil.openFileDialogForDefaultWebServerConnection(project, new WebServerFileDialogExtensionCallback("php") {
                @Override
                public void success(@NotNull WebServerConfig server, @NotNull WebServerConfig.RemotePath remotePath) {
                    RoutingSettingsForm.this.tableView.getListTableModel().addRow(
                        new RoutingFile("remote://" + org.apache.commons.lang.StringUtils.stripStart(remotePath.path, "/"))
                    );

                    RoutingSettingsForm.this.changed = true;
                }
            });
        }
    });
}
 
Example #2
Source File: ContainerSettingsForm.java    From idea-php-symfony2-plugin with MIT License 6 votes vote down vote up
private void addWebDeploymentButton(ToolbarDecorator tablePanel) {
    tablePanel.addExtraAction(new AnActionButton("Remote", AllIcons.Actions.Download) {
        @Override
        public void actionPerformed(AnActionEvent anActionEvent) {
            UiSettingsUtil.openFileDialogForDefaultWebServerConnection(project, new WebServerFileDialogExtensionCallback("xml") {
                @Override
                public void success(@NotNull WebServerConfig server, @NotNull WebServerConfig.RemotePath remotePath) {
                    ContainerSettingsForm.this.tableView.getListTableModel().addRow(
                        new ContainerFile("remote://" + org.apache.commons.lang.StringUtils.stripStart(remotePath.path, "/"))
                    );

                    ContainerSettingsForm.this.changed = true;
                }
            });
        }
    });
}
 
Example #3
Source File: VariablesPanel.java    From intellij-xquery with Apache License 2.0 6 votes vote down vote up
private AnActionButtonRunnable getRemoveAction(final TableView<XQueryRunVariable> variablesTable) {
    return new AnActionButtonRunnable() {
        @Override
        public void run(AnActionButton button) {
            TableUtil.stopEditing(variablesTable);
            final int[] selected = variablesTable.getSelectedRows();
            if (selected == null || selected.length == 0) return;
            for (int i = selected.length - 1; i >= 0; i--) {
                variablesModel.removeRow(selected[i]);
            }
            for (int i = selected.length - 1; i >= 0; i--) {
                int idx = selected[i];
                variablesModel.fireTableRowsDeleted(idx, idx);
            }
            int selection = selected[0];
            if (selection >= variablesModel.getRowCount()) {
                selection = variablesModel.getRowCount() - 1;
            }
            if (selection >= 0) {
                variablesTable.setRowSelectionInterval(selection, selection);
            }
            variablesTable.requestFocus();
        }
    };
}
 
Example #4
Source File: VariablesPanel.java    From intellij-xquery with Apache License 2.0 6 votes vote down vote up
private AnActionButtonRunnable getAddAction(final TableView<XQueryRunVariable> variablesTable) {
    return new AnActionButtonRunnable() {
        @Override
        public void run(AnActionButton button) {
            XQueryRunVariable newVariable = new XQueryRunVariable();
            if (showEditorDialog(newVariable)) {
                ArrayList<XQueryRunVariable> newList = new ArrayList<XQueryRunVariable>(variablesModel
                        .getItems());
                newList.add(newVariable);
                variablesModel.setItems(newList);
                int index = variablesModel.getRowCount() - 1;
                variablesModel.fireTableRowsInserted(index, index);
                variablesTable.setRowSelectionInterval(index, index);
            }
        }
    };
}
 
Example #5
Source File: DataSourceListPanelGuiTest.java    From intellij-xquery with Apache License 2.0 6 votes vote down vote up
@Test
public void shouldRemoveEntryAfterRemoveButtonClicked() {
    panel.populateWithConfigurations(asList(defaultDataSource));
    final AnActionButton action = getAnActionButton(REMOVE);
    final AnActionEvent event = new TestActionEvent(action);

    execute(new GuiTask() {
        @Override
        protected void executeInEDT() throws Throwable {
            action.actionPerformed(event);
        }
    });

    window.list().requireNoSelection();
    assertThat(window.list().contents().length, is(0));
}
 
Example #6
Source File: UserDefinedLibraryPanelGuiTest.java    From intellij-xquery with Apache License 2.0 5 votes vote down vote up
@Test
public void shouldRemoveSelectedPositionAfterActioningRemoveButton() {
    cfg.USER_DEFINED_LIBRARY_PATHS = asList(PATH_JAR);
    setUpPanelWithUserLibrary(ENABLED);
    final AnActionButton action = getAnActionButton(REMOVE);
    final AnActionEvent event = new TestActionEvent(action);
    panel.getPathList().setSelectedIndex(0);

    simulateAction(action, event);

    assertThat(window.list(PATH_LIST_NAME).contents().length, is(0));
}
 
Example #7
Source File: DocumentationOrderRootTypeUIFactory.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
protected void addToolbarButtons(ToolbarDecorator toolbarDecorator) {
  AnActionButton specifyUrlButton = new AnActionButton(ProjectBundle.message("sdk.paths.specify.url.button"), IconUtil.getAddLinkIcon()) {
    @RequiredUIAccess
    @Override
    public void actionPerformed(@Nonnull AnActionEvent e) {
      onSpecifyUrlButtonClicked();
    }
  };
  specifyUrlButton.setShortcut(CustomShortcutSet.fromString("alt S"));
  specifyUrlButton.addCustomUpdater(e -> myEnabled);
  toolbarDecorator.addExtraAction(specifyUrlButton);
}
 
Example #8
Source File: VariablesPanelGuiTest.java    From intellij-xquery with Apache License 2.0 5 votes vote down vote up
private void clickButton(CommonActionsPanel.Buttons button) {
    final AnActionButton action = getAnActionButton(button);
    final AnActionEvent event = new TestActionEvent(action);

    execute(new GuiTask() {
        @Override
        protected void executeInEDT() throws Throwable {
            action.actionPerformed(event);
        }
    });
}
 
Example #9
Source File: UserDefinedLibraryPanelGuiTest.java    From intellij-xquery with Apache License 2.0 5 votes vote down vote up
private void simulateAction(final AnActionButton action, final AnActionEvent event) {
    execute(new GuiTask() {
        @Override
        protected void executeInEDT() throws Throwable {
            action.actionPerformed(event);
        }
    });
}
 
Example #10
Source File: UserDefinedLibraryPanelGuiTest.java    From intellij-xquery with Apache License 2.0 5 votes vote down vote up
@Test
public void shouldInvokeChangeListenerAfterChangeOfPathListContents() {
    cfg.USER_DEFINED_LIBRARY_PATHS = asList(PATH_JAR);
    setUpPanelWithUserLibrary(ENABLED);
    panel.setUpChangeListeners(aggregatingPanel, listener);
    final AnActionButton action = getAnActionButton(REMOVE);
    final AnActionEvent event = new TestActionEvent(action);
    panel.getPathList().setSelectedIndex(0);

    simulateAction(action, event);

    verifyChangeListenerInvokedForCurrentConfigurationState();
}
 
Example #11
Source File: PluginSettingForm.java    From ycy-intellij-plugin with GNU General Public License v3.0 5 votes vote down vote up
private void createUIComponents() {
    // place custom component creation code here
    this.remindTypeOptions = new ComboBox<>();
    for (ConfigState.RemindTypeEnum remindType : ConfigState.RemindTypeEnum.values()) {
        this.remindTypeOptions.addItem(remindType.description);
    }

    ConfigState configState = ConfigService.getInstance().getState();
    List<String> remindImages = configState.getRemindImages();
    this.pluginSettingTable = new PluginSettingTable(remindImages);
    this.imageUrlList = ToolbarDecorator.createDecorator(pluginSettingTable)
        /*
         * at version 1.5 fix a bug: 2020.1 版本 AllIcons.Actions.Reset_to_default 过时问题
         * see https://github.com/fantasticmao/ycy-intellij-plugin/issues/27
         */
        .addExtraAction(new AnActionButton("Reset", AllIcons.Actions.Rollback) {
            @Override
            public void actionPerformed(AnActionEvent e) {
                pluginSettingTable.resetTableList();
            }

            @Override
            public boolean isDumbAware() {
                return true; // 使用「后台更新」模式
            }
        })
        .createPanel();
}
 
Example #12
Source File: UserDefinedLibraryPanelGuiTest.java    From intellij-xquery with Apache License 2.0 5 votes vote down vote up
@Test
public void shouldShowAddPathDialogAfterActioningAddButton() {
    setUpPanelWithUserLibrary(ENABLED);
    final AnActionButton action = getAnActionButton(ADD);
    final AnActionEvent event = new TestActionEvent(action);

    simulateAction(action, event);

    assertThat(fileChooserUsedToChooseFiles, is(true));
}
 
Example #13
Source File: DataSourceListPanelGuiTest.java    From intellij-xquery with Apache License 2.0 5 votes vote down vote up
private void clickAdd() {
    final AnActionButton action = getAnActionButton(ADD);
    final AnActionEvent event = new TestActionEvent(action);

    execute(new GuiTask() {
        @Override
        protected void executeInEDT() throws Throwable {
            action.actionPerformed(event);
        }
    });
}
 
Example #14
Source File: VariablesPanel.java    From intellij-xquery with Apache License 2.0 5 votes vote down vote up
private AnActionButtonRunnable getUpdateAction(final TableView<XQueryRunVariable> variablesTable) {
    return new AnActionButtonRunnable() {
        @Override
        public void run(AnActionButton button) {
            final int selectedRow = variablesTable.getSelectedRow();
            final XQueryRunVariable selectedVariable = variablesTable.getSelectedObject();
            showEditorDialog(selectedVariable);
            variablesModel.fireTableDataChanged();
            variablesTable.setRowSelectionInterval(selectedRow, selectedRow);
        }
    };
}
 
Example #15
Source File: TemplateAddAction.java    From CodeGen with MIT License 5 votes vote down vote up
@Override
public void run(AnActionButton button) {
    // 获取选中节点
    final DefaultMutableTreeNode selectedNode = getSelectedNode();
    List<AnAction> actions = getMultipleActions(selectedNode);
    if (actions == null || actions.isEmpty()) {
        return;
    }
    // 显示新增按钮
    final DefaultActionGroup group = new DefaultActionGroup(actions);
    JBPopupFactory.getInstance()
            .createActionGroupPopup(null, group, DataManager.getInstance().getDataContext(button.getContextComponent()),
                    JBPopupFactory.ActionSelectionAid.SPEEDSEARCH, true).show(button.getPreferredPopupPoint());
}
 
Example #16
Source File: TemplateRemoveAction.java    From CodeGen with MIT License 5 votes vote down vote up
@Override
public void run(AnActionButton button) {
    DefaultMutableTreeNode selectedNode = getSelectedNode();
    if (selectedNode != null && selectedNode.getParent() != null) {
        // 删除指定节点
        DefaultTreeModel model = (DefaultTreeModel) this.templateTree.getModel();
        model.removeNodeFromParent(selectedNode);
    }
}
 
Example #17
Source File: DataSourceListPanelGuiTest.java    From intellij-xquery with Apache License 2.0 4 votes vote down vote up
private AnActionButton getAnActionButton(CommonActionsPanel.Buttons button) {
    return panel.getToolbarDecorator()
            .getActionsPanel()
            .getAnActionButton(button);
}
 
Example #18
Source File: UserDefinedLibraryPanelGuiTest.java    From intellij-xquery with Apache License 2.0 4 votes vote down vote up
private AnActionButton getAnActionButton(CommonActionsPanel.Buttons button) {
    return panel.getToolbarDecorator()
            .getActionsPanel()
            .getAnActionButton(button);
}
 
Example #19
Source File: VariablesPanelGuiTest.java    From intellij-xquery with Apache License 2.0 4 votes vote down vote up
private AnActionButton getAnActionButton(CommonActionsPanel.Buttons button) {
    return panel.getToolbarDecorator()
            .getActionsPanel()
            .getAnActionButton(button);
}
 
Example #20
Source File: PatternFilterEditor.java    From KodeBeagle with Apache License 2.0 4 votes vote down vote up
public PatternFilterEditor(final Project project, final String patternsHelpId) {
    super(new BorderLayout());
    myPatternsHelpId = patternsHelpId;
    myTable = new JBTable();
    myProject = project;
    final ToolbarDecorator decorator = ToolbarDecorator.createDecorator(myTable);
    decorator.addExtraAction(new AnActionButton(getAddPatternButtonText(),
            getAddPatternButtonIcon()) {
        @Override
        public void actionPerformed(final AnActionEvent e) {
            addPatternFilter();
        }
    });

    add(decorator.setRemoveAction(new AnActionButtonRunnable() {
        @Override
        public void run(final AnActionButton button) {
            TableUtil.removeSelectedItems(myTable);
        }
    }).setButtonComparator(getAddPatternButtonText(), "Remove")
            .disableUpDownActions().createPanel(), BorderLayout.CENTER);

    myTableModel = new FilterTableModel();
    myTable.setModel(myTableModel);
    myTable.setShowGrid(false);
    myTable.setShowGrid(false);
    myTable.setIntercellSpacing(new Dimension(0, 0));
    myTable.setTableHeader(null);
    myTable.setAutoResizeMode(JTable.AUTO_RESIZE_LAST_COLUMN);
    myTable.setColumnSelectionAllowed(false);
    myTable.setPreferredScrollableViewportSize(new Dimension(WIDTH,
            myTable.getRowHeight() * PREFERRED_SCROLLABLE_VIEWPORT_HEIGHT_IN_ROWS));

    TableColumnModel columnModel = myTable.getColumnModel();
    TableColumn column = columnModel.getColumn(FilterTableModel.CHECK_MARK);
    TableUtil.setupCheckboxColumn(column);
    column.setCellRenderer(new EnabledCellRenderer(myTable.getDefaultRenderer(Boolean.class)));
    columnModel.getColumn(FilterTableModel.FILTER).setCellRenderer(new FilterCellRenderer());

    getEmptyText().setText(EMPTY_PATTERNS);
}
 
Example #21
Source File: BuckSettingsUI.java    From buck with Apache License 2.0 4 votes vote down vote up
private JPanel initBuckCellSection() {
  JPanel panel = new JPanel(new BorderLayout());
  panel.setBorder(IdeBorderFactory.createTitledBorder("Cells", true));
  cellTableModel = new ListTableModel<>(CELL_NAME_COLUMN, ROOT_COLUMN, BUILD_FILENAME_COLUMN);
  cellTableModel.setItems(buckCellSettingsProvider.getCells());
  TableView<BuckCell> cellTable = new TableView<>(cellTableModel);
  cellTable.setPreferredScrollableViewportSize(
      new Dimension(
          cellTable.getPreferredScrollableViewportSize().width, 8 * cellTable.getRowHeight()));
  ToolbarDecorator decorator =
      ToolbarDecorator.createDecorator(cellTable)
          .setAddAction(
              (AnActionButton button) -> {
                final FileChooserDescriptor dirChooser =
                    FileChooserDescriptorFactory.createSingleFolderDescriptor()
                        .withTitle("Select root directory of buck cell");
                Project project = buckProjectSettingsProvider.getProject();
                FileChooser.chooseFile(
                    dirChooser,
                    project,
                    BuckSettingsUI.this,
                    project.getBaseDir(),
                    file -> {
                      BuckCell buckCell = new BuckCell();
                      buckCell.setName(file.getName());
                      buckCell.setRoot(file.getPath());
                      cellTableModel.addRow(buckCell);
                    });
              })
          .addExtraAction(
              new AnActionButton("Automatically discover cells", Actions.Find) {
                @Override
                public void actionPerformed(AnActionEvent anActionEvent) {
                  discoverCells();
                }
              });
  JBLabel label = new JBLabel("By default, commands take place in the topmost cell");
  panel.add(label, BorderLayout.NORTH);
  panel.add(decorator.createPanel(), BorderLayout.CENTER);
  return panel;
}
 
Example #22
Source File: ExcludedFilesList.java    From consulo with Apache License 2.0 4 votes vote down vote up
private void onSelectionChange() {
  int i = getSelectedIndex();
  AnActionButton removeButton = ToolbarDecorator.findRemoveButton(myFileListDecorator.getActionsPanel());
  removeButton.setEnabled(i >= 0);
}