use of javax.swing.event.TableModelEvent in project libgdx by libgdx.
the class TemplatePickerPanel method initializeComponents.
protected void initializeComponents(Class<T> type, LoaderButton<T> loaderButton) {
int i = 0;
if (loaderButton != null) {
loaderButton.setListener(this);
contentPanel.add(loaderButton, new GridBagConstraints(0, i++, 1, 1, 1, 0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 6), 0, 0));
}
JScrollPane scroll = new JScrollPane();
contentPanel.add(scroll, new GridBagConstraints(0, i, 1, 1, 1, 0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 6), 0, 0));
{
templatesTable = new JTable() {
public Class getColumnClass(int column) {
return column == 1 ? Boolean.class : super.getColumnClass(column);
}
@Override
public Dimension getPreferredScrollableViewportSize() {
Dimension dim = super.getPreferredScrollableViewportSize();
dim.height = getPreferredSize().height;
return dim;
}
};
templatesTable.getTableHeader().setReorderingAllowed(false);
templatesTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
scroll.setViewportView(templatesTable);
templatesTableModel = new DefaultTableModel(new String[0][0], new String[] { "Template", "Selected" });
templatesTable.setModel(templatesTableModel);
reloadTemplates();
templatesTableModel.addTableModelListener(new TableModelListener() {
public void tableChanged(TableModelEvent event) {
if (event.getColumn() != 1)
return;
int row = event.getFirstRow();
boolean checked = (Boolean) templatesTable.getValueAt(row, 1);
if (isOneModelSelectedRequired && (value.size == 1 && !checked)) {
EditorPanel.setValue(templatesTableModel, true, row, 1);
return;
}
templateChecked(row, checked);
}
});
}
}
use of javax.swing.event.TableModelEvent in project libgdx by libgdx.
the class EffectPanel method initializeComponents.
private void initializeComponents() {
setLayout(new GridBagLayout());
{
JScrollPane scroll = new JScrollPane();
add(scroll, new GridBagConstraints(0, 0, 1, 1, 1, 0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 6), 0, 0));
{
emitterTable = new JTable() {
public Class getColumnClass(int column) {
return column == 1 ? Boolean.class : super.getColumnClass(column);
}
@Override
public Dimension getPreferredScrollableViewportSize() {
Dimension dim = super.getPreferredScrollableViewportSize();
dim.height = getPreferredSize().height;
return dim;
}
};
emitterTable.getTableHeader().setReorderingAllowed(false);
emitterTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
scroll.setViewportView(emitterTable);
emitterTableModel = new DefaultTableModel(new String[0][0], new String[] { "Emitter", "" });
emitterTable.setModel(emitterTableModel);
emitterTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
public void valueChanged(ListSelectionEvent event) {
if (event.getValueIsAdjusting())
return;
emitterSelected();
}
});
emitterTableModel.addTableModelListener(new TableModelListener() {
public void tableChanged(TableModelEvent event) {
if (event.getColumn() != 1)
return;
emitterChecked(event.getFirstRow(), (Boolean) emitterTable.getValueAt(event.getFirstRow(), 1));
}
});
}
}
{
JPanel sideButtons = new JPanel(new GridBagLayout());
add(sideButtons, new GridBagConstraints(1, 0, 1, 1, 0, 0, GridBagConstraints.NORTHWEST, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0));
{
controllerTypeCombo = new JComboBox();
controllerTypeCombo.setModel(new DefaultComboBoxModel(ControllerType.values()));
sideButtons.add(controllerTypeCombo, new GridBagConstraints(0, -1, 1, 1, 0, 0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 6, 0), 0, 0));
}
{
JButton newButton = new JButton("New");
sideButtons.add(newButton, new GridBagConstraints(0, -1, 1, 1, 0, 0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 6, 0), 0, 0));
newButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent event) {
ControllerType item = (ControllerType) controllerTypeCombo.getSelectedItem();
createDefaultEmitter(item, true, true);
}
});
}
{
JButton deleteButton = new JButton("Delete");
sideButtons.add(deleteButton, new GridBagConstraints(0, -1, 1, 1, 0, 0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 6, 0), 0, 0));
deleteButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent event) {
deleteEmitter();
}
});
}
{
JButton cloneButton = new JButton("Clone");
sideButtons.add(cloneButton, new GridBagConstraints(0, -1, 1, 1, 0, 0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 6, 0), 0, 0));
cloneButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent event) {
cloneEmitter();
}
});
}
{
sideButtons.add(new JSeparator(JSeparator.HORIZONTAL), new GridBagConstraints(0, -1, 1, 1, 0, 0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 6, 0), 0, 0));
}
{
JButton saveButton = new JButton("Save");
sideButtons.add(saveButton, new GridBagConstraints(0, -1, 1, 1, 0, 0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 6, 0), 0, 0));
saveButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent event) {
saveEffect();
}
});
}
{
JButton openButton = new JButton("Open");
sideButtons.add(openButton, new GridBagConstraints(0, -1, 1, 1, 0, 0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 6, 0), 0, 0));
openButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent event) {
openEffect();
}
});
}
{
JButton importButton = new JButton("Import");
sideButtons.add(importButton, new GridBagConstraints(0, -1, 1, 1, 0, 0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 6, 0), 0, 0));
importButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent event) {
importEffect();
}
});
}
/*
{
JButton importButton = new JButton("Export");
sideButtons.add(importButton, new GridBagConstraints(0, -1, 1, 1, 0, 0, GridBagConstraints.CENTER,
GridBagConstraints.HORIZONTAL, new Insets(0, 0, 6, 0), 0, 0));
importButton.addActionListener(new ActionListener() {
public void actionPerformed (ActionEvent event) {
exportEffect();
}
});
}
*/
}
}
use of javax.swing.event.TableModelEvent in project azure-tools-for-java by Microsoft.
the class AzureSelectDockerHostStep method createUIComponents.
private void createUIComponents() {
final DefaultTableModel dockerListTableModel = new DefaultTableModel() {
@Override
public boolean isCellEditable(int row, int col) {
return (col == 0);
}
public Class<?> getColumnClass(int colIndex) {
return getValueAt(0, colIndex).getClass();
}
};
dockerListTableModel.addColumn("");
dockerListTableModel.addColumn("Name");
dockerListTableModel.addColumn("State");
dockerListTableModel.addColumn("OS");
dockerListTableModel.addColumn("API URL");
dockerHostsTable = new JBTable(dockerListTableModel);
dockerHostsTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
TableColumn column = dockerHostsTable.getColumnModel().getColumn(0);
column.setMinWidth(23);
column.setMaxWidth(23);
column = dockerHostsTable.getColumnModel().getColumn(1);
column.setPreferredWidth(150);
column = dockerHostsTable.getColumnModel().getColumn(2);
column.setPreferredWidth(30);
column = dockerHostsTable.getColumnModel().getColumn(3);
column.setPreferredWidth(110);
column = dockerHostsTable.getColumnModel().getColumn(4);
column.setPreferredWidth(150);
dockerListTableModel.addTableModelListener(new TableModelListener() {
@Override
public void tableChanged(TableModelEvent tableEvent) {
if (tableEvent.getType() == TableModelEvent.UPDATE) {
DockerHostsTableSelection currentSelection = new DockerHostsTableSelection();
// int column = dockerHostsTable.getSelectedColumn();
int column = tableEvent.getColumn();
currentSelection.row = tableEvent.getFirstRow();
if (column == 0) {
DefaultTableModel tableModel = (DefaultTableModel) dockerHostsTable.getModel();
if ((Boolean) tableModel.getValueAt(currentSelection.row, 0)) {
if (dockerHostsTableSelection == null) {
dockerHostsTableSelection = currentSelection;
dockerHostsTableSelection.host = dockerManager.getDockerHostForURL((String) tableModel.getValueAt(currentSelection.row, 4));
if (dockerHostsTableSelection.host != null) {
model.setSubscription(dockerManager.getSubscriptionsMap().get(dockerHostsTableSelection.host.sid));
}
} else {
int oldRow = dockerHostsTableSelection.row;
dockerHostsTableSelection = null;
if (currentSelection.row != oldRow) {
// disable previous selection
tableModel.setValueAt(false, oldRow, 0);
dockerHostsTableSelection = currentSelection;
dockerHostsTableSelection.host = dockerManager.getDockerHostForURL((String) tableModel.getValueAt(dockerHostsTable.getSelectedRow(), 4));
if (dockerHostsTableSelection.host != null) {
model.setSubscription(dockerManager.getSubscriptionsMap().get(dockerHostsTableSelection.host.sid));
}
}
}
setFinishButtonState(doValidate(false) == null);
setNextButtonState(doValidate(false) == null);
} else {
dockerHostsTableSelection = null;
setFinishButtonState(false);
setNextButtonState(false);
}
}
}
}
});
AnActionButton viewDockerHostsAction = new ToolbarDecorator.ElementActionButton("Details", AllIcons.Actions.Export) {
@Override
public void actionPerformed(AnActionEvent anActionEvent) {
onViewDockerHostAction();
}
};
AnActionButton refreshDockerHostsAction = new AnActionButton("Refresh", AllIcons.Actions.Refresh) {
@Override
public void actionPerformed(AnActionEvent anActionEvent) {
AppInsightsClient.createByType(AppInsightsClient.EventType.DockerContainer, "", "Refresh", null);
onRefreshDockerHostAction();
}
};
ToolbarDecorator tableToolbarDecorator = ToolbarDecorator.createDecorator(dockerHostsTable).setAddAction(new AnActionButtonRunnable() {
@Override
public void run(AnActionButton button) {
onAddNewDockerHostAction();
}
}).setEditAction(new AnActionButtonRunnable() {
@Override
public void run(AnActionButton anActionButton) {
onEditDockerHostAction();
}
}).setRemoveAction(new AnActionButtonRunnable() {
@Override
public void run(AnActionButton button) {
onRemoveDockerHostAction();
}
}).setEditActionUpdater(new AnActionButtonUpdater() {
@Override
public boolean isEnabled(AnActionEvent e) {
return dockerHostsTable.getSelectedRow() != -1;
}
}).setRemoveActionUpdater(new AnActionButtonUpdater() {
@Override
public boolean isEnabled(AnActionEvent e) {
return dockerHostsTable.getSelectedRow() != -1;
}
}).disableUpDownActions().addExtraActions(viewDockerHostsAction, refreshDockerHostsAction);
dockerHostsPanel = tableToolbarDecorator.createPanel();
}
use of javax.swing.event.TableModelEvent in project intellij-community by JetBrains.
the class JBComboBoxTableCellEditorComponent method initAndShowPopup.
private void initAndShowPopup() {
myList.removeAll();
myList.setModel(JBList.createDefaultListModel(myOptions));
if (myRenderer != null) {
myList.setCellRenderer(myRenderer);
}
final Rectangle rect = myTable.getCellRect(myRow, myColumn, true);
Point point = new Point(rect.x, rect.y);
final boolean surrendersFocusOnKeystrokeOldValue = myTable instanceof JBTable ? ((JBTable) myTable).surrendersFocusOnKeyStroke() : myTable.getSurrendersFocusOnKeystroke();
final JBPopup popup = JBPopupFactory.getInstance().createListPopupBuilder(myList).setItemChoosenCallback(() -> {
myValue = myList.getSelectedValue();
final ActionEvent event = new ActionEvent(myList, ActionEvent.ACTION_PERFORMED, "elementChosen");
for (ActionListener listener : myListeners) {
listener.actionPerformed(event);
}
TableUtil.stopEditing(myTable);
// on Mac getCellEditorValue() called before myValue is set.
myTable.setValueAt(myValue, myRow, myColumn);
// force repaint
myTable.tableChanged(new TableModelEvent(myTable.getModel(), myRow));
}).setCancelCallback(() -> {
TableUtil.stopEditing(myTable);
return true;
}).addListener(new JBPopupAdapter() {
@Override
public void beforeShown(LightweightWindowEvent event) {
super.beforeShown(event);
myTable.setSurrendersFocusOnKeystroke(false);
}
@Override
public void onClosed(LightweightWindowEvent event) {
myTable.setSurrendersFocusOnKeystroke(surrendersFocusOnKeystrokeOldValue);
super.onClosed(event);
}
}).setMinSize(myWide ? new Dimension(((int) rect.getSize().getWidth()), -1) : null).createPopup();
popup.show(new RelativePoint(myTable, point));
}
use of javax.swing.event.TableModelEvent in project zaproxy by zaproxy.
the class OptionsCheckForUpdatesPanel method getScriptDirModel.
private OptionsAutoupdateDirsTableModel getScriptDirModel() {
if (scriptDirModel == null) {
scriptDirModel = new OptionsAutoupdateDirsTableModel();
scriptDirModel.addTableModelListener(new TableModelListener() {
@Override
public void tableChanged(TableModelEvent e) {
repopulatDownloadDirs();
}
});
}
return scriptDirModel;
}
Aggregations