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;
}
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();
}
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);
}
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();
}
});
}
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;
}
Aggregations