Search in sources :

Example 71 with DefaultTableModel

use of javax.swing.table.DefaultTableModel in project EnrichmentMapApp by BaderLab.

the class DataSetSelector method getTable.

private JTable getTable() {
    if (table == null) {
        final DefaultSelectorTableCellRenderer defRenderer = new DefaultSelectorTableCellRenderer();
        final CheckBoxTableCellRenderer checkBoxRenderer = new CheckBoxTableCellRenderer();
        table = new JTable(new DefaultTableModel(HEARDER_NAMES, 0)) {

            @Override
            public TableCellRenderer getCellRenderer(int row, int column) {
                if (column == SELECTED_COL_IDX)
                    return checkBoxRenderer;
                return defRenderer;
            }
        };
        table.setTableHeader(null);
        table.setShowGrid(false);
        JTextField tmpField = new JTextField();
        makeSmall(tmpField);
        table.setRowHeight(Math.max(table.getRowHeight(), tmpField.getPreferredSize().height - 4));
        table.setIntercellSpacing(new Dimension(0, 1));
        table.getSelectionModel().addListSelectionListener(e -> {
            if (!e.getValueIsAdjusting()) {
                updateRemoveButton();
                if (table.getSelectedRowCount() > 0)
                    previousSelectedRows = Arrays.stream(table.getSelectedRows()).boxed().collect(Collectors.toList());
            }
        });
        table.addMouseListener(new MouseAdapter() {

            @Override
            public void mousePressed(MouseEvent e) {
                final boolean isMac = LookAndFeelUtil.isMac();
                // COMMAND button down on MacOS (or CONTROL button down on another OS) or SHIFT?
                if ((isMac && e.isMetaDown()) || (!isMac && e.isControlDown()) || e.isShiftDown())
                    // Ignore!
                    return;
                final int col = table.columnAtPoint(e.getPoint());
                if (col == SELECTED_COL_IDX) {
                    final int row = table.rowAtPoint(e.getPoint());
                    // Restore previous multiple-row selection first
                    if (previousSelectedRows != null && previousSelectedRows.contains(row)) {
                        for (int i : previousSelectedRows) table.addRowSelectionInterval(i, i);
                    }
                    toggleChecked(row);
                }
            }
        });
    }
    return table;
}
Also used : TableCellRenderer(javax.swing.table.TableCellRenderer) DefaultTableCellRenderer(javax.swing.table.DefaultTableCellRenderer) MouseEvent(java.awt.event.MouseEvent) JTable(javax.swing.JTable) DefaultTableModel(javax.swing.table.DefaultTableModel) MouseAdapter(java.awt.event.MouseAdapter) Dimension(java.awt.Dimension) JTextField(javax.swing.JTextField)

Example 72 with DefaultTableModel

use of javax.swing.table.DefaultTableModel in project CoreNLP by stanfordnlp.

the class InputPanel method showHistory.

private void showHistory() {
    if (historyFrame == null) {
        historyFrame = new JFrame("Statistics History");
    } else {
        historyFrame.setVisible(false);
        historyFrame = new JFrame("Statistics History");
    }
    historyFrame.setLayout(new GridLayout(1, 0));
    Object[][] entries = new Object[historyList.size()][3];
    for (int i = 0; i < historyList.size(); i++) {
        entries[i] = historyList.get(i).toArray();
    }
    DefaultTableModel tableModel = new TregexGUITableModel(entries, HistoryEntry.columnNamesArray());
    JTable statTable = new JTable(tableModel);
    DefaultTableCellRenderer dtcr = (DefaultTableCellRenderer) statTable.getDefaultRenderer(String.class);
    dtcr.setHorizontalAlignment(DefaultTableCellRenderer.CENTER);
    JScrollPane scroller = new JScrollPane(statTable);
    historyFrame.add(scroller);
    historyFrame.pack();
    historyFrame.setLocationRelativeTo(TregexGUI.getInstance());
    historyFrame.setBackground(Color.WHITE);
    historyFrame.setVisible(true);
    historyFrame.repaint();
}
Also used : GridLayout(java.awt.GridLayout) DefaultTableModel(javax.swing.table.DefaultTableModel) DefaultTableCellRenderer(javax.swing.table.DefaultTableCellRenderer)

Example 73 with DefaultTableModel

use of javax.swing.table.DefaultTableModel in project jBPM5-Developer-Guide by Salaboy.

the class TaskListJFrame method refreshTable.

private void refreshTable() {
    List<TaskSummary> tasks = TaskClientHelper.getInstance().getAssignedTasksByUser("salaboy");
    DefaultTableModel tableModel = new javax.swing.table.DefaultTableModel(new String[] { "Id", "Task Name" }, 0) {

        Class[] types = new Class[] { java.lang.Number.class, java.lang.String.class };

        public Class getColumnClass(int columnIndex) {
            return types[columnIndex];
        }
    };
    int i = 0;
    for (TaskSummary task : tasks) {
        String name = task.getName();
        tableModel.addRow(new Object[] { task.getId(), name });
    }
    tasksjTable.setModel(tableModel);
}
Also used : DefaultTableModel(javax.swing.table.DefaultTableModel) TaskSummary(org.jbpm.task.query.TaskSummary)

Example 74 with DefaultTableModel

use of javax.swing.table.DefaultTableModel in project intellij-plugins by JetBrains.

the class FilesToPackageForm method initTable.

private void initTable() {
    myFilesToPackageTable = new JBTable();
    // otherwise model is not in sync with view
    myFilesToPackageTable.putClientProperty("terminateEditOnFocusLost", Boolean.TRUE);
    myFilesToPackageTable.setPreferredScrollableViewportSize(JBUI.size(400, 150));
    myFilesToPackageTable.setRowHeight(new JTextField("Fake").getPreferredSize().height + myFilesToPackageTable.getRowMargin());
    myFilesToPackageTable.setModel(new DefaultTableModel() {

        public int getColumnCount() {
            return Column.values().length;
        }

        public int getRowCount() {
            return myFilesToPackage.size();
        }

        public String getColumnName(int column) {
            return Column.values()[column].getColumnName();
        }

        public Class<?> getColumnClass(int column) {
            return Column.values()[column].getColumnClass();
        }

        public Object getValueAt(int row, int column) {
            return Column.values()[column].getValue(myFilesToPackage.get(row));
        }

        public void setValueAt(Object aValue, int row, int column) {
            Column.values()[column].setValue(myFilesToPackage, row, aValue);
        }
    });
    myFilesToPackageTable.getColumnModel().getColumn(0).setCellEditor(new AbstractTableCellEditor() {

        private CellEditorComponentWithBrowseButton<JTextField> myComponent;

        public Component getTableCellEditorComponent(final JTable table, Object value, boolean isSelected, int row, int column) {
            final ActionListener listener = new ActionListener() {

                public void actionPerformed(ActionEvent e) {
                    FileChooserDescriptor d = new FileChooserDescriptor(true, true, false, true, false, false);
                    VirtualFile initialFile = LocalFileSystem.getInstance().findFileByPath((String) getCellEditorValue());
                    VirtualFile file = FileChooser.chooseFile(d, myProject, initialFile);
                    if (file != null) {
                        myComponent.getChildComponent().setText(file.getPresentableUrl());
                    }
                }
            };
            myComponent = new CellEditorComponentWithBrowseButton<>(new TextFieldWithBrowseButton(listener), this);
            myComponent.getChildComponent().setText((String) value);
            return myComponent;
        }

        public Object getCellEditorValue() {
            return myComponent.getChildComponent().getText();
        }
    });
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) ActionEvent(java.awt.event.ActionEvent) FileChooserDescriptor(com.intellij.openapi.fileChooser.FileChooserDescriptor) DefaultTableModel(javax.swing.table.DefaultTableModel) JBTable(com.intellij.ui.table.JBTable) AbstractTableCellEditor(com.intellij.util.ui.AbstractTableCellEditor) CellEditorComponentWithBrowseButton(com.intellij.util.ui.CellEditorComponentWithBrowseButton) TextFieldWithBrowseButton(com.intellij.openapi.ui.TextFieldWithBrowseButton) ActionListener(java.awt.event.ActionListener)

Example 75 with DefaultTableModel

use of javax.swing.table.DefaultTableModel in project intellij-community by JetBrains.

the class ArrangementGroupingRulesControl method getRules.

@NotNull
public List<ArrangementGroupingRule> getRules() {
    List<ArrangementGroupingRule> result = new ArrayList<>();
    DefaultTableModel model = getModel();
    for (int i = 0, max = model.getRowCount(); i < max; i++) {
        ArrangementGroupingComponent component = (ArrangementGroupingComponent) model.getValueAt(i, 0);
        if (!component.isSelected()) {
            continue;
        }
        ArrangementSettingsToken orderType = component.getOrderType();
        if (orderType == null) {
            result.add(new ArrangementGroupingRule(component.getGroupingType()));
        } else {
            result.add(new ArrangementGroupingRule(component.getGroupingType(), orderType));
        }
    }
    return result;
}
Also used : ArrangementGroupingRule(com.intellij.psi.codeStyle.arrangement.group.ArrangementGroupingRule) CompositeArrangementSettingsToken(com.intellij.psi.codeStyle.arrangement.std.CompositeArrangementSettingsToken) ArrangementSettingsToken(com.intellij.psi.codeStyle.arrangement.std.ArrangementSettingsToken) DefaultTableModel(javax.swing.table.DefaultTableModel) ArrayList(java.util.ArrayList) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

DefaultTableModel (javax.swing.table.DefaultTableModel)139 JTable (javax.swing.JTable)18 Dimension (java.awt.Dimension)14 Vector (java.util.Vector)14 JScrollPane (javax.swing.JScrollPane)14 TableColumn (javax.swing.table.TableColumn)12 JBTable (com.intellij.ui.table.JBTable)10 Point (java.awt.Point)10 ActionEvent (java.awt.event.ActionEvent)9 JPanel (javax.swing.JPanel)9 ListSelectionEvent (javax.swing.event.ListSelectionEvent)9 ListSelectionListener (javax.swing.event.ListSelectionListener)9 JButton (javax.swing.JButton)8 ActionListener (java.awt.event.ActionListener)7 WebAppDetails (com.microsoft.azuretools.utils.WebAppUtils.WebAppDetails)6 Color (java.awt.Color)6 ArrayList (java.util.ArrayList)6 AnActionEvent (com.intellij.openapi.actionSystem.AnActionEvent)5 ProgressIndicator (com.intellij.openapi.progress.ProgressIndicator)5 VirtualFile (com.intellij.openapi.vfs.VirtualFile)5