Search in sources :

Example 1 with TableSpeedSearch

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

the class SubscriptionsDialog method createUIComponents.

private void createUIComponents() {
    contentPane = new JPanel();
    contentPane.setPreferredSize(new Dimension(350, 200));
    DefaultTableModel model = new SubscriptionTableModel();
    // Set the text read by JAWS
    model.addColumn("Selected");
    model.addColumn("Subscription name");
    model.addColumn("Subscription ID");
    table = new JBTable();
    table.setModel(model);
    TableColumn column = table.getColumnModel().getColumn(CHECKBOX_COLUMN);
    // Don't show title text
    column.setHeaderValue("");
    column.setMinWidth(23);
    column.setMaxWidth(23);
    JTableUtils.enableBatchSelection(table, CHECKBOX_COLUMN);
    table.getTableHeader().setReorderingAllowed(false);
    new TableSpeedSearch(table);
    AnActionButton refreshAction = new AnActionButton("Refresh", AllIcons.Actions.Refresh) {

        @Override
        public void actionPerformed(AnActionEvent anActionEvent) {
            this.setEnabled(false);
            model.setRowCount(0);
            model.fireTableDataChanged();
            table.getEmptyText().setText("Refreshing");
            AppInsightsClient.createByType(AppInsightsClient.EventType.Subscription, "", "Refresh", null);
            final AzureString title = AzureOperationBundle.title("account|subscription.refresh");
            final AzureTask task = new AzureTask(project, title, true, () -> {
                try {
                    SubscriptionsDialog.this.refreshSubscriptions();
                } finally {
                    this.setEnabled(true);
                }
            }, AzureTask.Modality.ANY);
            AzureTaskManager.getInstance().runInBackground(task);
        }
    };
    refreshAction.registerCustomShortcutSet(KeyEvent.VK_R, InputEvent.ALT_DOWN_MASK, contentPane);
    ToolbarDecorator tableToolbarDecorator = ToolbarDecorator.createDecorator(table).disableUpDownActions().addExtraActions(refreshAction);
    panelTable = tableToolbarDecorator.createPanel();
}
Also used : TableSpeedSearch(com.intellij.ui.TableSpeedSearch) DefaultTableModel(javax.swing.table.DefaultTableModel) ToolbarDecorator(com.intellij.ui.ToolbarDecorator) JBTable(com.intellij.ui.table.JBTable) AnActionEvent(com.intellij.openapi.actionSystem.AnActionEvent) AzureTask(com.microsoft.azure.toolkit.lib.common.task.AzureTask) TableColumn(javax.swing.table.TableColumn) AnActionButton(com.intellij.ui.AnActionButton) AzureString(com.microsoft.azure.toolkit.lib.common.bundle.AzureString)

Aggregations

AnActionEvent (com.intellij.openapi.actionSystem.AnActionEvent)1 AnActionButton (com.intellij.ui.AnActionButton)1 TableSpeedSearch (com.intellij.ui.TableSpeedSearch)1 ToolbarDecorator (com.intellij.ui.ToolbarDecorator)1 JBTable (com.intellij.ui.table.JBTable)1 AzureString (com.microsoft.azure.toolkit.lib.common.bundle.AzureString)1 AzureTask (com.microsoft.azure.toolkit.lib.common.task.AzureTask)1 DefaultTableModel (javax.swing.table.DefaultTableModel)1 TableColumn (javax.swing.table.TableColumn)1