Search in sources :

Example 21 with JBTable

use of com.intellij.ui.table.JBTable in project AndroidWiFiADB by pedrovgs.

the class CardLayoutDevices method createTableDevices.

private void createTableDevices() {
    AndroidDevicesTableModel model = new AndroidDevicesTableModel();
    for (Device device : devices) {
        model.add(device);
    }
    tableDevices = new JBTable(model);
    configureTableAppearance();
    panelDevices = new JPanel(new BorderLayout());
    panelDevices.add(tableDevices.getTableHeader(), BorderLayout.NORTH);
    panelDevices.add(tableDevices, BorderLayout.CENTER);
}
Also used : JPanel(javax.swing.JPanel) BorderLayout(java.awt.BorderLayout) Device(com.github.pedrovgs.androidwifiadb.Device) JBTable(com.intellij.ui.table.JBTable)

Example 22 with JBTable

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

the class AzureSelectDockerHostStep method createUIComponents.

private void createUIComponents() {
    final DefaultTableModel dockerListTableModel = new DefaultTableModel() {

        @Override
        public boolean isCellEditable(int row, int col) {
            return (col == 0);
        }

        public Class<?> getColumnClass(int colIndex) {
            return getValueAt(0, colIndex).getClass();
        }
    };
    dockerListTableModel.addColumn("");
    dockerListTableModel.addColumn("Name");
    dockerListTableModel.addColumn("State");
    dockerListTableModel.addColumn("OS");
    dockerListTableModel.addColumn("API URL");
    dockerHostsTable = new JBTable(dockerListTableModel);
    dockerHostsTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    TableColumn column = dockerHostsTable.getColumnModel().getColumn(0);
    column.setMinWidth(23);
    column.setMaxWidth(23);
    column = dockerHostsTable.getColumnModel().getColumn(1);
    column.setPreferredWidth(150);
    column = dockerHostsTable.getColumnModel().getColumn(2);
    column.setPreferredWidth(30);
    column = dockerHostsTable.getColumnModel().getColumn(3);
    column.setPreferredWidth(110);
    column = dockerHostsTable.getColumnModel().getColumn(4);
    column.setPreferredWidth(150);
    dockerListTableModel.addTableModelListener(new TableModelListener() {

        @Override
        public void tableChanged(TableModelEvent tableEvent) {
            if (tableEvent.getType() == TableModelEvent.UPDATE) {
                DockerHostsTableSelection currentSelection = new DockerHostsTableSelection();
                //          int column = dockerHostsTable.getSelectedColumn();
                int column = tableEvent.getColumn();
                currentSelection.row = tableEvent.getFirstRow();
                if (column == 0) {
                    DefaultTableModel tableModel = (DefaultTableModel) dockerHostsTable.getModel();
                    if ((Boolean) tableModel.getValueAt(currentSelection.row, 0)) {
                        if (dockerHostsTableSelection == null) {
                            dockerHostsTableSelection = currentSelection;
                            dockerHostsTableSelection.host = dockerManager.getDockerHostForURL((String) tableModel.getValueAt(currentSelection.row, 4));
                            if (dockerHostsTableSelection.host != null) {
                                model.setSubscription(dockerManager.getSubscriptionsMap().get(dockerHostsTableSelection.host.sid));
                            }
                        } else {
                            int oldRow = dockerHostsTableSelection.row;
                            dockerHostsTableSelection = null;
                            if (currentSelection.row != oldRow) {
                                // disable previous selection
                                tableModel.setValueAt(false, oldRow, 0);
                                dockerHostsTableSelection = currentSelection;
                                dockerHostsTableSelection.host = dockerManager.getDockerHostForURL((String) tableModel.getValueAt(dockerHostsTable.getSelectedRow(), 4));
                                if (dockerHostsTableSelection.host != null) {
                                    model.setSubscription(dockerManager.getSubscriptionsMap().get(dockerHostsTableSelection.host.sid));
                                }
                            }
                        }
                        setFinishButtonState(doValidate(false) == null);
                        setNextButtonState(doValidate(false) == null);
                    } else {
                        dockerHostsTableSelection = null;
                        setFinishButtonState(false);
                        setNextButtonState(false);
                    }
                }
            }
        }
    });
    AnActionButton viewDockerHostsAction = new ToolbarDecorator.ElementActionButton("Details", AllIcons.Actions.Export) {

        @Override
        public void actionPerformed(AnActionEvent anActionEvent) {
            onViewDockerHostAction();
        }
    };
    AnActionButton refreshDockerHostsAction = new AnActionButton("Refresh", AllIcons.Actions.Refresh) {

        @Override
        public void actionPerformed(AnActionEvent anActionEvent) {
            AppInsightsClient.createByType(AppInsightsClient.EventType.DockerContainer, "", "Refresh", null);
            onRefreshDockerHostAction();
        }
    };
    ToolbarDecorator tableToolbarDecorator = ToolbarDecorator.createDecorator(dockerHostsTable).setAddAction(new AnActionButtonRunnable() {

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

        @Override
        public void run(AnActionButton anActionButton) {
            onEditDockerHostAction();
        }
    }).setRemoveAction(new AnActionButtonRunnable() {

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

        @Override
        public boolean isEnabled(AnActionEvent e) {
            return dockerHostsTable.getSelectedRow() != -1;
        }
    }).setRemoveActionUpdater(new AnActionButtonUpdater() {

        @Override
        public boolean isEnabled(AnActionEvent e) {
            return dockerHostsTable.getSelectedRow() != -1;
        }
    }).disableUpDownActions().addExtraActions(viewDockerHostsAction, refreshDockerHostsAction);
    dockerHostsPanel = tableToolbarDecorator.createPanel();
}
Also used : TableModelEvent(javax.swing.event.TableModelEvent) DefaultTableModel(javax.swing.table.DefaultTableModel) JBTable(com.intellij.ui.table.JBTable) AnActionEvent(com.intellij.openapi.actionSystem.AnActionEvent) TableColumn(javax.swing.table.TableColumn) TableModelListener(javax.swing.event.TableModelListener)

Example 23 with JBTable

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

the class SrvPriCreationStatusDialog method createUIComponents.

private void createUIComponents() {
    // TODO: place custom component creation code here
    statusTable = new JBTable();
    statusTable.setRowSelectionAllowed(false);
    statusTable.setCellSelectionEnabled(false);
}
Also used : JBTable(com.intellij.ui.table.JBTable)

Example 24 with JBTable

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

the class SubscriptionsDialog method createUIComponents.

private void createUIComponents() {
    DefaultTableModel model = new SubscriptionTableModel();
    model.addColumn("");
    model.addColumn("Subscription name");
    model.addColumn("Subscription ID");
    table = new JBTable();
    table.setModel(model);
    TableColumn column = table.getColumnModel().getColumn(0);
    column.setMinWidth(23);
    column.setMaxWidth(23);
    table.setRowSelectionAllowed(false);
    table.setCellSelectionEnabled(false);
    AnActionButton refreshAction = new AnActionButton("Refresh", AllIcons.Actions.Refresh) {

        @Override
        public void actionPerformed(AnActionEvent anActionEvent) {
            AppInsightsClient.createByType(AppInsightsClient.EventType.Subscription, "", "Refresh", null);
            refreshSubscriptions();
        }
    };
    ToolbarDecorator tableToolbarDecorator = ToolbarDecorator.createDecorator(table).disableUpDownActions().addExtraActions(refreshAction);
    panelTable = tableToolbarDecorator.createPanel();
}
Also used : DefaultTableModel(javax.swing.table.DefaultTableModel) ToolbarDecorator(com.intellij.ui.ToolbarDecorator) JBTable(com.intellij.ui.table.JBTable) AnActionEvent(com.intellij.openapi.actionSystem.AnActionEvent) TableColumn(javax.swing.table.TableColumn) AnActionButton(com.intellij.ui.AnActionButton)

Example 25 with JBTable

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

the class EditVariableDialog method createVariablesTable.

private JComponent createVariablesTable() {
    final String[] names = { CodeInsightBundle.message("templates.dialog.edit.variables.table.column.name"), CodeInsightBundle.message("templates.dialog.edit.variables.table.column.expression"), CodeInsightBundle.message("templates.dialog.edit.variables.table.column.default.value"), CodeInsightBundle.message("templates.dialog.edit.variables.table.column.skip.if.defined") };
    // Create a model of the data.
    TableModel dataModel = new VariablesModel(names);
    // Create the table
    myTable = new JBTable(dataModel);
    myTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    myTable.setPreferredScrollableViewportSize(new Dimension(500, myTable.getRowHeight() * 8));
    myTable.getColumn(names[0]).setPreferredWidth(120);
    myTable.getColumn(names[1]).setPreferredWidth(200);
    myTable.getColumn(names[2]).setPreferredWidth(200);
    myTable.getColumn(names[3]).setPreferredWidth(100);
    if (myVariables.size() > 0) {
        myTable.getSelectionModel().setSelectionInterval(0, 0);
    }
    Predicate<Macro> isAcceptableInContext = macro -> myContextTypes.stream().anyMatch(macro::isAcceptableInContext);
    Stream<String> availableMacroNames = Arrays.stream(MacroFactory.getMacros()).filter(isAcceptableInContext).map(Macro::getPresentableName).sorted();
    Set<String> uniqueNames = availableMacroNames.collect(Collectors.toCollection(LinkedHashSet::new));
    ComboBox comboField = new ComboBox();
    uniqueNames.forEach(comboField::addItem);
    comboField.setEditable(true);
    DefaultCellEditor cellEditor = new DefaultCellEditor(comboField);
    cellEditor.setClickCountToStart(1);
    myTable.getColumn(names[1]).setCellEditor(cellEditor);
    myTable.setRowHeight(comboField.getPreferredSize().height);
    JTextField textField = new JTextField();
    /*textField.addMouseListener(
      new PopupHandler(){
        public void invokePopup(Component comp,int x,int y){
          showCellPopup((JTextField)comp,x,y);
        }
      }
    );*/
    cellEditor = new DefaultCellEditor(textField);
    cellEditor.setClickCountToStart(1);
    myTable.setDefaultEditor(String.class, cellEditor);
    final ToolbarDecorator decorator = ToolbarDecorator.createDecorator(myTable).disableAddAction().disableRemoveAction();
    return decorator.createPanel();
}
Also used : java.util(java.util) Document(com.intellij.openapi.editor.Document) ToolbarDecorator(com.intellij.ui.ToolbarDecorator) CodeInsightBundle(com.intellij.codeInsight.CodeInsightBundle) TableCellEditor(javax.swing.table.TableCellEditor) DialogWrapper(com.intellij.openapi.ui.DialogWrapper) CommonBundle(com.intellij.CommonBundle) AbstractTableModel(javax.swing.table.AbstractTableModel) TemplateContextType(com.intellij.codeInsight.template.TemplateContextType) TableModel(javax.swing.table.TableModel) ComboBox(com.intellij.openapi.ui.ComboBox) Predicate(java.util.function.Predicate) Editor(com.intellij.openapi.editor.Editor) Collectors(java.util.stream.Collectors) MacroFactory(com.intellij.codeInsight.template.macro.MacroFactory) java.awt(java.awt) CommandProcessor(com.intellij.openapi.command.CommandProcessor) HelpManager(com.intellij.openapi.help.HelpManager) JBTable(com.intellij.ui.table.JBTable) List(java.util.List) Stream(java.util.stream.Stream) Macro(com.intellij.codeInsight.template.Macro) EditableModel(com.intellij.util.ui.EditableModel) ApplicationManager(com.intellij.openapi.application.ApplicationManager) NotNull(org.jetbrains.annotations.NotNull) javax.swing(javax.swing) Macro(com.intellij.codeInsight.template.Macro) ComboBox(com.intellij.openapi.ui.ComboBox) JBTable(com.intellij.ui.table.JBTable) ToolbarDecorator(com.intellij.ui.ToolbarDecorator) AbstractTableModel(javax.swing.table.AbstractTableModel) TableModel(javax.swing.table.TableModel)

Aggregations

JBTable (com.intellij.ui.table.JBTable)41 VirtualFile (com.intellij.openapi.vfs.VirtualFile)9 AnActionEvent (com.intellij.openapi.actionSystem.AnActionEvent)8 DefaultTableModel (javax.swing.table.DefaultTableModel)8 NotNull (org.jetbrains.annotations.NotNull)7 FileChooserDescriptor (com.intellij.openapi.fileChooser.FileChooserDescriptor)6 Nullable (org.jetbrains.annotations.Nullable)6 JBLabel (com.intellij.ui.components.JBLabel)5 ActionEvent (java.awt.event.ActionEvent)5 AbstractTableModel (javax.swing.table.AbstractTableModel)5 TableColumn (javax.swing.table.TableColumn)5 TableColumnModel (javax.swing.table.TableColumnModel)5 DumbAwareAction (com.intellij.openapi.project.DumbAwareAction)4 Project (com.intellij.openapi.project.Project)4 JBScrollPane (com.intellij.ui.components.JBScrollPane)4 MouseEvent (java.awt.event.MouseEvent)4 List (java.util.List)4 StringUtil (com.intellij.openapi.util.text.StringUtil)3 JavaCodeFragmentTableCellEditor (com.intellij.refactoring.ui.JavaCodeFragmentTableCellEditor)3 UsageInfo (com.intellij.usageView.UsageInfo)3