use of javax.swing.table.DefaultTableModel in project intellij-community by JetBrains.
the class AnnotationsEditor method moduleStateChanged.
@Override
public void moduleStateChanged() {
if (myTable != null) {
final DefaultTableModel tableModel = createModel();
myTable.setModel(tableModel);
}
}
use of javax.swing.table.DefaultTableModel in project intellij-community by JetBrains.
the class ShowUIDefaultsAction method actionPerformed.
@Override
public void actionPerformed(AnActionEvent e) {
final UIDefaults defaults = UIManager.getDefaults();
Enumeration keys = defaults.keys();
final Object[][] data = new Object[defaults.size()][2];
int i = 0;
while (keys.hasMoreElements()) {
Object key = keys.nextElement();
data[i][0] = key;
data[i][1] = defaults.get(key);
i++;
}
Arrays.sort(data, (o1, o2) -> StringUtil.naturalCompare(o1[0].toString(), o2[0].toString()));
final Project project = getEventProject(e);
new DialogWrapper(project) {
{
setTitle("Edit LaF Defaults");
setModal(false);
init();
}
public JBTable myTable;
@Nullable
@Override
public JComponent getPreferredFocusedComponent() {
return myTable;
}
@Nullable
@Override
protected String getDimensionServiceKey() {
return project == null ? null : "UI.Defaults.Dialog";
}
@Override
protected JComponent createCenterPanel() {
final JBTable table = new JBTable(new DefaultTableModel(data, new Object[] { "Name", "Value" }) {
@Override
public boolean isCellEditable(int row, int column) {
return column == 1 && getValueAt(row, column) instanceof Color;
}
}) {
@Override
public boolean editCellAt(int row, int column, EventObject e) {
if (isCellEditable(row, column) && e instanceof MouseEvent) {
final Object color = getValueAt(row, column);
final Color newColor = ColorPicker.showDialog(this, "Choose Color", (Color) color, true, null, true);
if (newColor != null) {
final ColorUIResource colorUIResource = new ColorUIResource(newColor);
final Object key = getValueAt(row, 0);
UIManager.put(key, colorUIResource);
setValueAt(colorUIResource, row, column);
}
}
return false;
}
};
table.setDefaultRenderer(Object.class, new DefaultTableCellRenderer() {
@Override
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
final JPanel panel = new JPanel(new BorderLayout());
final JLabel label = new JLabel(value == null ? "" : value.toString());
panel.add(label, BorderLayout.CENTER);
if (value instanceof Color) {
final Color c = (Color) value;
label.setText(String.format("[r=%d,g=%d,b=%d] hex=0x%s", c.getRed(), c.getGreen(), c.getBlue(), ColorUtil.toHex(c)));
label.setForeground(ColorUtil.isDark(c) ? Color.white : Color.black);
panel.setBackground(c);
return panel;
} else if (value instanceof Icon) {
try {
final Icon icon = new IconWrap((Icon) value);
if (icon.getIconHeight() <= 20) {
label.setIcon(icon);
}
label.setText(String.format("(%dx%d) %s)", icon.getIconWidth(), icon.getIconHeight(), label.getText()));
} catch (Throwable e1) {
//
}
return panel;
} else if (value instanceof Border) {
try {
final Insets i = ((Border) value).getBorderInsets(null);
label.setText(String.format("[%d, %d, %d, %d] %s", i.top, i.left, i.bottom, i.right, label.getText()));
return panel;
} catch (Exception ignore) {
}
}
return super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
}
});
final JBScrollPane pane = new JBScrollPane(table);
new TableSpeedSearch(table, (o, cell) -> cell.column == 1 ? null : String.valueOf(o));
table.setShowGrid(false);
final JPanel panel = new JPanel(new BorderLayout());
panel.add(pane, BorderLayout.CENTER);
myTable = table;
TableUtil.ensureSelectionExists(myTable);
return panel;
}
}.show();
}
use of javax.swing.table.DefaultTableModel in project adempiere by adempiere.
the class VCreateFromInvoiceUI method loadTableOIS.
/**
* Load Order/Invoice/Shipment data into Table
* @param data data
*/
protected void loadTableOIS(Vector<?> data) {
// Remove previous listeners
v_CreateFromPanel.getMiniTable().removeMiniTableSelectionListener(v_CreateFromPanel);
// Set Model
DefaultTableModel model = new DefaultTableModel(data, getOISColumnNames());
v_CreateFromPanel.getMiniTable().setModel(model);
//
configureMiniTable(v_CreateFromPanel.getMiniTable());
v_CreateFromPanel.getMiniTable().addMiniTableSelectionListener(v_CreateFromPanel);
}
use of javax.swing.table.DefaultTableModel in project adempiere by adempiere.
the class VCharge method refresh.
private void refresh() {
DefaultTableModel model = new DefaultTableModel(getData(), getColumnNames());
dataTable.setModel(model);
setColumnClass(dataTable);
}
use of javax.swing.table.DefaultTableModel in project adempiere by adempiere.
the class VFactReconcile method resetReconciliation.
// zoom
private void resetReconciliation() {
log.info("");
//
miniTable.stopEditor(true);
if (miniTable.getRowCount() == 0)
return;
miniTable.setRowSelectionInterval(0, 0);
calculateSelection();
if (m_noSelected == 0)
return;
for (int r = 0; r < miniTable.getModel().getRowCount(); r++) {
if (((IDColumn) miniTable.getModel().getValueAt(r, idColIndex)).isSelected()) {
int factId = ((IDColumn) miniTable.getModel().getValueAt(r, idColIndex)).getRecord_ID();
MFactReconciliation rec = new Query(Env.getCtx(), MFactReconciliation.Table_Name, "Fact_Acct_ID = ?", null).setParameters(new Object[] { factId }).first();
if (rec == null) {
continue;
}
rec.setMatchCode(null);
rec.saveEx();
((DefaultTableModel) miniTable.getModel()).removeRow(r--);
}
}
}
Aggregations