use of javax.swing.table.AbstractTableModel in project cuba by cuba-platform.
the class VclTestApp method createTableTab.
private Component createTableTab() {
final JPanel box = new JPanel();
box.setFocusable(false);
MigLayout boxLayout = new MigLayout("fill");
box.setLayout(boxLayout);
final JScrollPane outerScrollPane = new JScrollPane();
outerScrollPane.setViewportView(box);
outerScrollPane.addComponentListener(new ComponentAdapter() {
@Override
public void componentResized(ComponentEvent e) {
final Dimension minimumSize = box.getMinimumSize();
final int width = Math.max(minimumSize.width, outerScrollPane.getViewport().getWidth());
box.setPreferredSize(new Dimension(width, minimumSize.height));
}
});
JPanel tablePanel = new JPanel();
MigLayout tablePanellayout = new MigLayout("flowy, fill, insets 0", "", "[min!][fill]");
tablePanel.setLayout(tablePanellayout);
JPanel topPanel = new JPanel(new FlowLayout());
topPanel.setVisible(true);
tablePanel.add(topPanel);
topPanel.add(new JButton("Button1"));
topPanel.add(new JButton("Button2"));
topPanel.add(new JButton("Button3"));
topPanel.add(new JButton("Button4"));
topPanel.add(new JButton("Button5"));
JXTableExt table = new JXTableExt();
JScrollPane tableScrollPane = new JScrollPane(table);
// table.setFillsViewportHeight(true);
tablePanel.add(tableScrollPane, "grow");
table.setShowGrid(true);
table.setGridColor(Color.lightGray);
table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
table.setColumnControlVisible(true);
table.setModel(new AbstractTableModel() {
@Override
public int getRowCount() {
return 20;
}
@Override
public int getColumnCount() {
return 20;
}
@Override
public Object getValueAt(int rowIndex, int columnIndex) {
return rowIndex + "-" + columnIndex;
}
});
CC cc = new CC();
// cc.growX(0);
// cc.width("300!");
cc.width("100%");
// cc.growY(0.0f);
cc.height("200!");
// cc.height("100%");
box.add(tablePanel);
boxLayout.setComponentConstraints(tablePanel, cc);
return outerScrollPane;
}
use of javax.swing.table.AbstractTableModel in project cayenne by apache.
the class MergerTokenSelectorController method checkAllAction.
public void checkAllAction() {
stopEditing();
final boolean isCheckAllSelected = view.getCheckAll().isSelected();
if (isCheckAllSelected) {
excludedTokens.clear();
} else {
excludedTokens.addAll(selectableTokensList);
}
final AbstractTableModel model = (AbstractTableModel) view.getTokens().getModel();
model.fireTableDataChanged();
}
use of javax.swing.table.AbstractTableModel in project omegat by omegat-org.
the class RepositoriesMappingController method initTableModels.
@SuppressWarnings("serial")
void initTableModels() {
modelRepo = new AbstractTableModel() {
@Override
public Object getValueAt(int rowIndex, int columnIndex) {
if (rowIndex >= listRepo.size()) {
return null;
}
RowRepo r = listRepo.get(rowIndex);
switch(columnIndex) {
case 0:
return r.type == null ? null : r.type.getLocalizedString();
case 1:
return r.url;
}
return null;
}
@Override
public void setValueAt(Object aValue, int rowIndex, int columnIndex) {
RowRepo r = listRepo.get(rowIndex);
switch(columnIndex) {
case 0:
r.type = (RepoType) aValue;
break;
case 1:
String old = r.url;
r.url = (String) aValue;
changeRepoUrl(old, r.url);
reinitRepoUrlDropdown();
break;
}
repoSizer.reset();
repoSizer.adjustTableColumns();
}
@Override
public int getRowCount() {
return listRepo.size();
}
@Override
public int getColumnCount() {
return 2;
}
@Override
public boolean isCellEditable(int rowIndex, int columnIndex) {
return true;
}
@Override
public String getColumnName(int column) {
switch(column) {
case 0:
return OStrings.getString("RMD_TABLE_REPOSITORIES_TYPE");
case 1:
return OStrings.getString("RMD_TABLE_REPOSITORIES_URL");
}
return null;
}
};
dialog.tableRepositories.setModel(modelRepo);
JComboBox<RepoType> comboBox = new JComboBox<>(RepoType.values());
comboBox.setRenderer(new DelegatingComboBoxRenderer<RepoType, String>() {
@Override
protected String getDisplayText(RepoType value) {
return value == null ? "" : value.getLocalizedString();
}
});
dialog.tableRepositories.getColumnModel().getColumn(0).setCellEditor(new DefaultCellEditor(comboBox));
modelMapping = new AbstractTableModel() {
@Override
public Object getValueAt(int rowIndex, int columnIndex) {
if (rowIndex >= listMapping.size()) {
return null;
}
RowMapping r = listMapping.get(rowIndex);
switch(columnIndex) {
case 0:
return r.repoUrl;
case 1:
return r.local;
case 2:
return r.remote;
case 3:
return r.excludes;
case 4:
return r.includes;
}
return null;
}
@Override
public void setValueAt(Object aValue, int rowIndex, int columnIndex) {
RowMapping r = listMapping.get(rowIndex);
switch(columnIndex) {
case 0:
r.repoUrl = (String) aValue;
break;
case 1:
r.local = (String) aValue;
break;
case 2:
r.remote = (String) aValue;
break;
case 3:
r.excludes = (String) aValue;
break;
case 4:
r.includes = (String) aValue;
break;
}
mappingSizer.reset();
mappingSizer.adjustTableColumns();
}
@Override
public int getRowCount() {
return listMapping.size();
}
@Override
public int getColumnCount() {
return 5;
}
@Override
public boolean isCellEditable(int rowIndex, int columnIndex) {
return true;
}
@Override
public String getColumnName(int column) {
switch(column) {
case 0:
return OStrings.getString("RMD_TABLE_MAPPING_REPO");
case 1:
return OStrings.getString("RMD_TABLE_MAPPING_LOCAL");
case 2:
return OStrings.getString("RMD_TABLE_MAPPING_REMOTE");
case 3:
return OStrings.getString("RMD_TABLE_MAPPING_EXCLUDES");
case 4:
return OStrings.getString("RMD_TABLE_MAPPING_INCLUDES");
}
return null;
}
};
dialog.tableMapping.setModel(modelMapping);
}
use of javax.swing.table.AbstractTableModel in project omegat by omegat-org.
the class FilenamePatternsEditorController method show.
public static List<String> show(List<String> excludes) {
result = null;
data = new ArrayList<String>(excludes);
final FilenamePatternsEditor dialog = new FilenamePatternsEditor(Core.getMainWindow().getApplicationFrame(), true);
@SuppressWarnings("serial") final AbstractTableModel model = new AbstractTableModel() {
public int getColumnCount() {
return 1;
}
public String getColumnName(int column) {
return OStrings.getString("FILENAMEPATTERNS_MASK");
}
public int getRowCount() {
return data.size();
}
public Object getValueAt(int row, int col) {
return data.get(row);
}
@Override
public void setValueAt(Object aValue, int rowIndex, int columnIndex) {
data.set(rowIndex, aValue.toString());
}
public boolean isCellEditable(int row, int col) {
return true;
}
};
dialog.table.setModel(model);
dialog.btnOk.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
if (dialog.table.getCellEditor() != null) {
dialog.table.getCellEditor().stopCellEditing();
}
result = data;
dialog.dispose();
}
});
dialog.btnCancel.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
dialog.dispose();
}
});
dialog.btnAdd.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
data.add("");
model.fireTableDataChanged();
dialog.table.changeSelection(data.size() - 1, 0, false, false);
dialog.table.editCellAt(data.size() - 1, 0);
dialog.table.transferFocus();
}
});
dialog.btnRemove.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
if (dialog.table.getSelectedRow() >= 0 && dialog.table.getSelectedRow() < data.size()) {
data.remove(dialog.table.getSelectedRow());
}
model.fireTableDataChanged();
}
});
ListSelectionListener listener = e -> dialog.btnRemove.setEnabled(dialog.table.getSelectedRow() != -1);
dialog.table.getSelectionModel().addListSelectionListener(listener);
listener.valueChanged(null);
dialog.setLocationRelativeTo(Core.getMainWindow().getApplicationFrame());
StaticUIUtils.setEscapeClosable(dialog);
dialog.getRootPane().setDefaultButton(dialog.btnOk);
dialog.setVisible(true);
return result;
}
use of javax.swing.table.AbstractTableModel in project MtgDesktopCompanion by nicho92.
the class DrawProbabilityPanel method initDeck.
private void initDeck() {
model = new AbstractTableModel() {
@Override
public String getColumnName(int t) {
if (t == 0)
return "Card";
else
return "Turn " + t;
}
@Override
public Object getValueAt(int r, int c) {
if (c == 0) {
return calc.getUniqueCards().get(r);
} else {
return calc.format(calc.getProbability(c - 1, calc.getUniqueCards().get(r)));
}
}
@Override
public int getRowCount() {
return calc.getDeck().getMap().keySet().size();
}
@Override
public int getColumnCount() {
return maxTurn + 1;
}
};
table.setModel(model);
model.fireTableDataChanged();
table.packAll();
}
Aggregations