com.intellij.ui.AnActionButtonRunnable Java Examples

The following examples show how to use com.intellij.ui.AnActionButtonRunnable. 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: 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 #2
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 #3
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 #4
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);
}