use of javax.swing.table.TableModel in project intellij-community by JetBrains.
the class ProcessorProfilePanel method createTablePanel.
private static JPanel createTablePanel(final JBTable table) {
return ToolbarDecorator.createDecorator(table).disableUpAction().disableDownAction().setAddAction(new AnActionButtonRunnable() {
@Override
public void run(AnActionButton anActionButton) {
final TableCellEditor cellEditor = table.getCellEditor();
if (cellEditor != null) {
cellEditor.stopCellEditing();
}
final TableModel model = table.getModel();
((EditableModel) model).addRow();
TableUtil.editCellAt(table, model.getRowCount() - 1, 0);
}
}).createPanel();
}
use of javax.swing.table.TableModel in project azure-tools-for-java by Microsoft.
the class TableEntityForm method doValidate.
@Nullable
@Override
protected ValidationInfo doValidate() {
final TableModel model = propertiesTable.getModel();
final String partitionKey = model.getValueAt(0, 3).toString();
final String rowKey = model.getValueAt(1, 3).toString();
for (int row = 2; row != model.getRowCount(); row++) {
TableEntity.PropertyType propertyType = (TableEntity.PropertyType) model.getValueAt(row, 2);
String name = model.getValueAt(row, 1).toString();
String value = model.getValueAt(row, 3).toString();
if (!isValidPropertyName(name)) {
return new ValidationInfo(String.format("The property name \"%s\" is invalid", name), propertiesTable);
}
TableEntity.Property property = getProperty(value, propertyType);
if (property == null) {
return new ValidationInfo(String.format("The field %s has an invalid value for its type", name), propertiesTable);
}
}
if (tableEntity == null) {
for (TableEntity te : tableEntityList) {
if (te.getPartitionKey().equals(partitionKey) && te.getRowKey().equals(rowKey)) {
return new ValidationInfo("An entity already exists with this partition key and row key pair", propertiesTable);
}
}
}
return null;
}
use of javax.swing.table.TableModel 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();
}
use of javax.swing.table.TableModel in project intellij-community by JetBrains.
the class UserActivityWatcher method unprocessComponent.
protected void unprocessComponent(final Component component) {
if (component instanceof JTextComponent) {
((JTextComponent) component).getDocument().removeDocumentListener(myDocumentListener);
} else if (component instanceof ItemSelectable) {
((ItemSelectable) component).removeItemListener(myItemListener);
} else if (component instanceof JTree) {
((JTree) component).getModel().removeTreeModelListener(myTreeModelListener);
} else if (component instanceof DocumentBasedComponent) {
((DocumentBasedComponent) component).getDocument().removeDocumentListener(myIdeaDocumentListener);
}
if (component instanceof JTable) {
component.removePropertyChangeListener(myTableListener);
TableModel model = ((JTable) component).getModel();
if (model != null) {
model.removeTableModelListener(myTableModelListener);
}
component.removePropertyChangeListener(myCellEditorChangeListener);
}
if (component instanceof JSlider) {
((JSlider) component).removeChangeListener(myChangeListener);
}
if (component instanceof UserActivityProviderComponent) {
((UserActivityProviderComponent) component).removeChangeListener(myChangeListener);
}
}
use of javax.swing.table.TableModel in project intellij-community by JetBrains.
the class OrderPanel method getEntries.
public List<T> getEntries() {
final TableModel model = myEntryTable.getModel();
final int size = model.getRowCount();
List<T> result = new ArrayList<>(size);
for (int idx = 0; idx < size; idx++) {
result.add(getValueAt(idx));
}
return result;
}
Aggregations