use of javax.swing.event.TableModelListener 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.TableModelListener in project intellij-community by JetBrains.
the class ExternalResourceConfigurable method createComponent.
@Override
public JComponent createComponent() {
myPanel = new JPanel(new GridBagLayout()) {
@Override
public Dimension getPreferredSize() {
return new Dimension(-1, 400);
}
};
myExtPanel = new AddEditRemovePanel<NameLocationPair>(new ExtUrlsTableModel(), myPairs, XmlBundle.message("label.edit.external.resource.configure.external.resources")) {
@Override
protected NameLocationPair addItem() {
return addExtLocation();
}
@Override
protected boolean removeItem(NameLocationPair o) {
setModified(true);
return true;
}
@Override
protected NameLocationPair editItem(NameLocationPair o) {
return editExtLocation(o);
}
};
myExtPanel.getTable().setShowColumns(true);
myExtPanel.setRenderer(1, new PathRenderer());
JTable table = myExtPanel.getTable();
if (myProject != null) {
TableColumn column = table.getColumn(table.getColumnName(2));
column.setMaxWidth(50);
column.setCellEditor(JBTable.createBooleanEditor());
}
table.getModel().addTableModelListener(new TableModelListener() {
@Override
public void tableChanged(TableModelEvent e) {
setModified(true);
}
});
myIgnorePanel = new AddEditRemovePanel<String>(new IgnoredUrlsModel(), myIgnoredUrls, XmlBundle.message("label.edit.external.resource.configure.ignored.resources")) {
@Override
protected String addItem() {
return addIgnoreLocation();
}
@Override
protected boolean removeItem(String o) {
setModified(true);
return true;
}
@Override
protected String editItem(String o) {
return editIgnoreLocation(o);
}
};
myPanel.add(myExtPanel, new GridBagConstraints(0, 0, 1, 1, 1, 1, GridBagConstraints.NORTH, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0));
myPanel.add(myIgnorePanel, new GridBagConstraints(0, 1, 1, 1, 1, 1, GridBagConstraints.NORTH, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0));
myExtPanel.setData(myPairs);
myIgnorePanel.setData(myIgnoredUrls);
myExtPanel.getEmptyText().setText(XmlBundle.message("no.external.resources"));
myIgnorePanel.getEmptyText().setText(XmlBundle.message("no.ignored.resources"));
return myPanel;
}
use of javax.swing.event.TableModelListener 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.TableModelListener in project sldeditor by robward-scisys.
the class SortByPanel method createUI.
/**
* Creates the UI.
*/
private void createUI(int noOfRows) {
int xPos = 0;
int width = BasePanel.FIELD_PANEL_WIDTH - xPos - 20;
int height = BasePanel.WIDGET_HEIGHT * (noOfRows - 1);
this.setBounds(0, 0, width, height);
JPanel panel = new JPanel();
add(panel, BorderLayout.CENTER);
panel.setLayout(new BoxLayout(panel, BoxLayout.X_AXIS));
// Source list
JScrollPane scrollPaneSource = new JScrollPane();
scrollPaneSource.setPreferredSize(new Dimension(200, 200));
panel.add(scrollPaneSource);
sourceList = new JList<String>(sourceModel);
sourceList.addListSelectionListener(new ListSelectionListener() {
public void valueChanged(ListSelectionEvent e) {
if (e.getValueIsAdjusting() == false) {
sourceSelected();
}
}
});
scrollPaneSource.setViewportView(sourceList);
JPanel panel_1 = new JPanel();
panel_1.setLayout(new BorderLayout(0, 0));
JPanel centrePanel = new JPanel();
centrePanel.setPreferredSize(new Dimension(50, 50));
centrePanel.setMaximumSize(new Dimension(50, 50));
panel.add(centrePanel);
centrePanel.setLayout(new BoxLayout(centrePanel, BoxLayout.Y_AXIS));
btnSrcToDestButton = new JButton("->");
btnSrcToDestButton.setEnabled(false);
btnSrcToDestButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
moveSrcToDestination();
}
});
centrePanel.add(btnSrcToDestButton);
btnDestToSrcButton = new JButton("<-");
btnDestToSrcButton.setEnabled(false);
btnDestToSrcButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
moveDestinationToSource();
}
});
centrePanel.add(btnDestToSrcButton);
// Destination list
JScrollPane scrollPaneDest = new JScrollPane();
scrollPaneDest.setPreferredSize(new Dimension(200, 200));
panel.add(scrollPaneDest);
destinationTable = new JTable();
destinationTable.setModel(destinationModel);
TableColumnModel columnModel = destinationTable.getColumnModel();
TableColumn col = columnModel.getColumn(SortByTableModel.getSortOrderColumn());
SortByCheckBoxRenderer checkBoxRenderer = new SortByCheckBoxRenderer();
col.setCellRenderer(checkBoxRenderer);
col.setCellEditor(new SortByOptionalValueEditor(destinationModel));
destinationTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
public void valueChanged(ListSelectionEvent e) {
if (e.getValueIsAdjusting() == false) {
ListSelectionModel model = destinationTable.getSelectionModel();
if (!model.isSelectionEmpty()) {
destinationSelected();
}
}
}
});
destinationModel.addTableModelListener(new TableModelListener() {
@Override
public void tableChanged(TableModelEvent e) {
if (e.getColumn() == SortByTableModel.getSortOrderColumn()) {
ListSelectionModel model = destinationTable.getSelectionModel();
model.clearSelection();
btnMoveDown.setEnabled(false);
btnMoveUp.setEnabled(false);
btnSrcToDestButton.setEnabled(false);
btnDestToSrcButton.setEnabled(false);
}
}
});
scrollPaneDest.setViewportView(destinationTable);
JPanel buttonPanel = new JPanel();
FlowLayout fl_buttonPanel = (FlowLayout) buttonPanel.getLayout();
fl_buttonPanel.setAlignment(FlowLayout.RIGHT);
add(buttonPanel, BorderLayout.SOUTH);
btnMoveUp = new JButton(Localisation.getString(SortByPanel.class, "sortby.up"));
btnMoveUp.setEnabled(false);
btnMoveUp.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
moveDestinationUp();
}
});
buttonPanel.add(btnMoveUp);
btnMoveDown = new JButton(Localisation.getString(SortByPanel.class, "sortby.down"));
btnMoveDown.setEnabled(false);
btnMoveDown.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
moveDestinationDown();
}
});
buttonPanel.add(btnMoveDown);
}
use of javax.swing.event.TableModelListener in project sldeditor by robward-scisys.
the class WKTDialog method createPointPanel.
/**
* Creates the point panel.
*
* @param panel the panel
*/
private void createPointPanel(JPanel panel) {
JPanel coordinatePanel = new JPanel();
panel.add(coordinatePanel);
coordinatePanel.setLayout(new BorderLayout(5, 0));
coordinatePanel.setPreferredSize(new Dimension(200, 200));
JScrollPane scrollPanePoint = new JScrollPane();
coordinatePanel.add(scrollPanePoint);
table = new JTable();
table.setModel(tablePointModel);
tablePointModel.addTableModelListener(new TableModelListener() {
@Override
public void tableChanged(TableModelEvent e) {
updatePointButtons();
updateWKTString();
}
});
// Handle table selection changes
ListSelectionModel selectionModel = table.getSelectionModel();
selectionModel.addListSelectionListener(new ListSelectionListener() {
public void valueChanged(ListSelectionEvent e) {
updatePointButtons();
}
});
scrollPanePoint.setViewportView(table);
JPanel pointButtonPanel = new JPanel();
FlowLayout flowLayout_3 = (FlowLayout) pointButtonPanel.getLayout();
flowLayout_3.setAlignment(FlowLayout.RIGHT);
coordinatePanel.add(pointButtonPanel, BorderLayout.SOUTH);
//
// Add point button
//
addPointButton = new JButton("+");
addPointButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
addPoint();
}
});
pointButtonPanel.add(addPointButton);
removePointButton = new JButton("-");
removePointButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
removePoint();
}
});
pointButtonPanel.add(removePointButton);
JLabel lblCoordinates = new JLabel("Coordinates");
coordinatePanel.add(lblCoordinates, BorderLayout.NORTH);
}
Aggregations