use of javax.swing.event.ListSelectionListener in project sldeditor by robward-scisys.
the class EnvVarDlg method createUI.
/**
* Creates the ui.
*/
private void createUI() {
JPanel buttonPanel = new JPanel();
FlowLayout flowLayout = (FlowLayout) buttonPanel.getLayout();
flowLayout.setAlignment(FlowLayout.TRAILING);
getContentPane().add(buttonPanel, BorderLayout.SOUTH);
JButton btnOk = new JButton(Localisation.getString(EnvVarDlg.class, "common.ok"));
btnOk.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
okButtonPressed = true;
dataModel.updateEnvVarManager();
setVisible(false);
}
});
buttonPanel.add(btnOk);
JButton btnCancel = new JButton(Localisation.getString(EnvVarDlg.class, "common.cancel"));
btnCancel.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
okButtonPressed = false;
setVisible(false);
}
});
buttonPanel.add(btnCancel);
JPanel panel = new JPanel();
getContentPane().add(panel, BorderLayout.CENTER);
panel.setLayout(new BorderLayout(0, 0));
table = new JTable();
dataModel = new EnvVarModel(envVarMgr);
table.setModel(dataModel);
TableColumn column = table.getColumnModel().getColumn(1);
JComboBox<Class<?>> typeComboBox = new JComboBox<Class<?>>();
typeComboBox.setModel(new EnvVarComboBoxModel(envVarMgr));
column.setCellEditor(new DefaultCellEditor(typeComboBox));
JScrollPane scrollPane = new JScrollPane(table);
panel.add(scrollPane, BorderLayout.CENTER);
table.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
@Override
public void valueChanged(ListSelectionEvent e) {
boolean enableRemoveButton = false;
EnvVar envVar = dataModel.getEnvVar(table.getSelectedRow());
if (envVar != null) {
enableRemoveButton = !envVar.isPredefined();
}
btnRemove.setEnabled(enableRemoveButton);
}
});
JPanel panelWMS = new JPanel();
panel.add(panelWMS, BorderLayout.NORTH);
panelWMS.setLayout(new BoxLayout(panelWMS, BoxLayout.X_AXIS));
JButton btnDecode = new JButton(Localisation.getString(EnvVarDlg.class, "EnvVarDlg.decode"));
btnDecode.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
URL url;
try {
url = new URL(textField.getText());
Map<String, List<String>> parameterMap = splitQuery(url);
if (parameterMap.containsKey(WMS_ENV_PARAMETER)) {
dataModel.addNew(parameterMap.get(WMS_ENV_PARAMETER));
}
} catch (MalformedURLException e1) {
ConsoleManager.getInstance().exception(this, e1);
} catch (UnsupportedEncodingException e1) {
ConsoleManager.getInstance().exception(this, e1);
}
}
});
panelWMS.add(btnDecode);
textField = new JTextField();
panelWMS.add(textField);
textField.setColumns(40);
JPanel panel_1 = new JPanel();
panel.add(panel_1, BorderLayout.SOUTH);
JButton btnAdd = new JButton(Localisation.getString(EnvVarDlg.class, "EnvVarDlg.add"));
btnAdd.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
dataModel.addNewVariable();
btnRemove.setEnabled(false);
}
});
panel_1.add(btnAdd);
btnRemove = new JButton(Localisation.getString(EnvVarDlg.class, "EnvVarDlg.remove"));
btnRemove.setEnabled(false);
btnRemove.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
dataModel.removeEnvVar(table.getSelectedRow());
btnRemove.setEnabled(false);
}
});
panel_1.add(btnRemove);
}
use of javax.swing.event.ListSelectionListener in project sldeditor by robward-scisys.
the class RenderTransformationDialog method createUI.
/**
* Creates the ui.
*/
private void createUI() {
JPanel panel = new JPanel();
getContentPane().add(panel, BorderLayout.WEST);
panel.setLayout(new BorderLayout(0, 0));
JScrollPane scrollPane = new JScrollPane();
panel.add(scrollPane);
functionList = new JList<String>();
functionList.setModel(functionListModel);
populateBuiltInProcessFunctions();
scrollPane.setViewportView(functionList);
functionList.addListSelectionListener(new ListSelectionListener() {
@Override
public void valueChanged(ListSelectionEvent arg0) {
if (!arg0.getValueIsAdjusting()) {
displayFunction(functionList.getSelectedValue());
}
}
});
JPanel panel_1 = new JPanel();
getContentPane().add(panel_1, BorderLayout.CENTER);
panel_1.setLayout(new BorderLayout(0, 0));
JScrollPane scrollPane_1 = new JScrollPane();
panel_1.add(scrollPane_1);
functionParameterTable = new JTable();
functionParameterTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
functionParameterTable.setModel(functionParameterTableModel);
ListSelectionModel selectionModel = functionParameterTable.getSelectionModel();
selectionModel.addListSelectionListener(new ListSelectionListener() {
public void valueChanged(ListSelectionEvent e) {
handleTableSelectionEvent(e);
}
});
TableColumn col = functionParameterTable.getColumnModel().getColumn(FunctionTableModel.getValueColumn());
// col.setCellEditor(new ExpressionEditor(functionParameterTableModel));
col = functionParameterTable.getColumnModel().getColumn(FunctionTableModel.getOptionalColumn());
CheckBoxRenderer checkBoxRenderer = new CheckBoxRenderer(functionParameterTableModel);
col.setCellRenderer(checkBoxRenderer);
col.setCellEditor(new OptionalValueEditor(functionParameterTableModel));
scrollPane_1.setViewportView(functionParameterTable);
JPanel panel_3 = new JPanel();
panel_1.add(panel_3, BorderLayout.SOUTH);
//
// Add value button
//
btnAdd = new JButton(Localisation.getString(RenderTransformationDialog.class, "RenderTransformationDialog.add"));
btnAdd.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
int row = functionParameterTable.getSelectedRow();
functionParameterTableModel.addNewValue(row);
}
});
btnAdd.setEnabled(false);
panel_3.add(btnAdd);
//
// Remove value button
//
btnRemove = new JButton(Localisation.getString(RenderTransformationDialog.class, "RenderTransformationDialog.remove"));
btnRemove.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
int row = functionParameterTable.getSelectedRow();
functionParameterTableModel.removeValue(row);
}
});
btnRemove.setEnabled(false);
panel_3.add(btnRemove);
//
// Top panel
//
JPanel panel_2 = new JPanel();
panel_2.setLayout(new BorderLayout(0, 0));
getContentPane().add(panel_2, BorderLayout.NORTH);
btnEditConnection = new JButton(Localisation.getString(RenderTransformationDialog.class, "RenderTransformationDialog.editConnection"));
panel_2.add(btnEditConnection, BorderLayout.EAST);
btnEditConnection.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
}
});
//
// Connect button
//
btnConnect = new JButton(Localisation.getString(RenderTransformationDialog.class, "RenderTransformationDialog.connect"));
btnConnect.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
updateButtonState(false);
populateFunctionList((String) connectionComboBox.getSelectedItem());
}
});
panel_2.add(btnConnect, BorderLayout.WEST);
connectionComboBox = new JComboBox<String>();
populateConnectionComboBox();
panel_2.add(connectionComboBox, BorderLayout.CENTER);
//
// Error label
//
lblError = new JLabel(" ");
panel_2.add(lblError, BorderLayout.SOUTH);
//
// Ok button
//
JPanel buttonPanel = new JPanel();
FlowLayout flowLayout = (FlowLayout) buttonPanel.getLayout();
flowLayout.setAlignment(FlowLayout.TRAILING);
getContentPane().add(buttonPanel, BorderLayout.SOUTH);
JButton btnOk = new JButton(Localisation.getString(RenderTransformationDialog.class, "RenderTransformationDialog.ok"));
btnOk.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
okButtonPressed = true;
setVisible(false);
}
});
buttonPanel.add(btnOk);
JButton btnCancel = new JButton(Localisation.getString(RenderTransformationDialog.class, "RenderTransformationDialog.cancel"));
btnCancel.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
okButtonPressed = false;
setVisible(false);
}
});
buttonPanel.add(btnCancel);
}
use of javax.swing.event.ListSelectionListener in project sldeditor by robward-scisys.
the class FieldConfigColourMap method createUI.
/**
* Creates the ui.
*/
@Override
public void createUI() {
if (colourRampConfig == null) {
int xPos = getXPos();
int maxNoOfConfigRows = 7;
int maxNoOfTableRows = 12;
int totalRows = maxNoOfConfigRows + maxNoOfTableRows + ColourMapEntryPanel.getNoOfRows();
FieldPanel fieldPanel = createFieldPanel(xPos, getRowY(totalRows), getLabel());
colourRampConfig = new ColourRampConfigPanel(this, model);
colourRampConfig.setBounds(xPos, 0, BasePanel.FIELD_PANEL_WIDTH, getRowY(maxNoOfConfigRows));
fieldPanel.add(colourRampConfig);
table = new JTable(model);
table.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION);
table.setBounds(xPos, getRowY(maxNoOfConfigRows), BasePanel.FIELD_PANEL_WIDTH, getRowY(totalRows - 2));
table.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
@Override
public void valueChanged(ListSelectionEvent e) {
if (!e.getValueIsAdjusting()) {
removeButton.setEnabled(true);
List<ColorMapEntry> entries;
if (table.getSelectedRowCount() == 1) {
ColorMapEntry entry = model.getColourMapEntry(table.getSelectedRow());
entries = new ArrayList<ColorMapEntry>();
entries.add(entry);
} else {
entries = model.getColourMapEntries(table.getSelectedRows());
}
colourMapEntryPanel.setSelectedEntry(entries);
}
}
});
model.setCellRenderer(table);
JScrollPane scrollPanel = new JScrollPane(table);
int endOfTableRow = maxNoOfConfigRows + maxNoOfTableRows - 2;
scrollPanel.setBounds(xPos, getRowY(maxNoOfConfigRows), BasePanel.FIELD_PANEL_WIDTH, getRowY(endOfTableRow) - getRowY(maxNoOfConfigRows));
fieldPanel.add(scrollPanel);
int buttonY = getRowY(endOfTableRow);
//
// Add button
//
addButton = new JButton(Localisation.getString(FieldConfigBase.class, "FieldConfigColourMap.add"));
addButton.setBounds(xPos + BasePanel.WIDGET_X_START, buttonY, BasePanel.WIDGET_BUTTON_WIDTH, BasePanel.WIDGET_HEIGHT);
addButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
addEntry();
}
});
fieldPanel.add(addButton);
//
// Remove button
//
removeButton = new JButton(Localisation.getString(FieldConfigBase.class, "FieldConfigColourMap.remove"));
removeButton.setBounds(xPos + BasePanel.WIDGET_BUTTON_WIDTH + BasePanel.WIDGET_X_START + 10, buttonY, BasePanel.WIDGET_BUTTON_WIDTH, BasePanel.WIDGET_HEIGHT);
removeButton.setEnabled(false);
removeButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
removeEntry();
}
});
fieldPanel.add(removeButton);
colourMapEntryPanel = new ColourMapEntryPanel(getPanelId(), this);
colourMapEntryPanel.setBounds(xPos, getRowY(maxNoOfConfigRows + maxNoOfTableRows - 1), BasePanel.FIELD_PANEL_WIDTH, colourMapEntryPanel.getPanelHeight());
fieldPanel.add(colourMapEntryPanel);
}
}
use of javax.swing.event.ListSelectionListener in project sldeditor by robward-scisys.
the class FieldConfigFeatureTypeConstraint method createExtentTable.
/**
* Creates the extent table.
*
* @param xPos the x pos
* @param maxNoOfRows the max no of rows
* @param fieldPanel the field panel
*/
private void createExtentTable(int xPos, int startRows, int noOfRows, FieldPanel fieldPanel) {
extentTable = new JTable(extentModel);
extentTable.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION);
extentTable.setBounds(xPos, getRowY(startRows + 1), BasePanel.FIELD_PANEL_WIDTH, getRowY(noOfRows - 2));
extentTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
@Override
public void valueChanged(ListSelectionEvent e) {
removeExtentButton.setEnabled(true);
}
});
JScrollPane scrollPanel = new JScrollPane(extentTable);
scrollPanel.setBounds(xPos, getRowY(startRows), BasePanel.FIELD_PANEL_WIDTH, BasePanel.WIDGET_HEIGHT * (noOfRows - 2));
fieldPanel.add(scrollPanel);
int maxNoOfRows = startRows + noOfRows;
int buttonY = getRowY(maxNoOfRows - 2);
//
// Add button
//
addExtentButton = new JButton(Localisation.getString(FieldConfigBase.class, "FieldConfigFeatureTypeConstraint.add"));
addExtentButton.setBounds(xPos + BasePanel.WIDGET_X_START, buttonY, BasePanel.WIDGET_BUTTON_WIDTH, BasePanel.WIDGET_HEIGHT);
addExtentButton.setEnabled(false);
addExtentButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
addExtentEntry();
}
});
fieldPanel.add(addExtentButton);
//
// Remove button
//
removeExtentButton = new JButton(Localisation.getString(FieldConfigBase.class, "FieldConfigFeatureTypeConstraint.remove"));
removeExtentButton.setBounds(xPos + BasePanel.WIDGET_BUTTON_WIDTH + BasePanel.WIDGET_X_START + 10, buttonY, BasePanel.WIDGET_BUTTON_WIDTH, BasePanel.WIDGET_HEIGHT);
removeExtentButton.setEnabled(false);
removeExtentButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
removeExtentEntry();
}
});
fieldPanel.add(removeExtentButton);
}
use of javax.swing.event.ListSelectionListener in project sldeditor by robward-scisys.
the class WKTDialog method createSegmentPanel.
/**
* Creates the segment panel.
*
* @param panel the panel
*/
private void createSegmentPanel(JPanel panel) {
JPanel segmentPanel = new JPanel();
panel.add(segmentPanel);
segmentPanel.setLayout(new BorderLayout(0, 0));
segmentPanel.setPreferredSize(new Dimension(150, 200));
JScrollPane segmentScrollPane = new JScrollPane();
segmentPanel.add(segmentScrollPane, BorderLayout.CENTER);
segmentList = new JList<String>();
segmentList.setModel(segmentListModel);
segmentList.addListSelectionListener(new ListSelectionListener() {
/**
* Value changed.
*
* @param e the e
*/
@Override
public void valueChanged(ListSelectionEvent e) {
if (!e.getValueIsAdjusting()) {
int selectedIndex = segmentList.getSelectedIndex();
if (wktGeometry.getNoOfSegments() == 1) {
if (selectedIndex >= 0) {
tablePointModel.populate(wktGeometry.getSegmentList(0).get(selectedIndex));
}
} else {
int multiSelectedIndex = multiList.getSelectedIndex();
if (selectedIndex < 0) {
selectedIndex = 0;
}
WKTSegmentList wktPointList = null;
List<WKTSegmentList> segmentList2 = wktGeometry.getSegmentList(multiSelectedIndex);
if ((segmentList2 != null) && (selectedIndex >= 0) && (selectedIndex < segmentList2.size())) {
wktPointList = segmentList2.get(selectedIndex);
}
tablePointModel.populate(wktPointList);
}
updateSegmentButtons();
}
}
});
segmentScrollPane.setViewportView(segmentList);
JPanel segmentButtonPanel = new JPanel();
FlowLayout flowLayout_1 = (FlowLayout) segmentButtonPanel.getLayout();
flowLayout_1.setAlignment(FlowLayout.RIGHT);
segmentPanel.add(segmentButtonPanel, BorderLayout.SOUTH);
//
// Add segment button
//
addSegmentButton = new JButton("+");
addSegmentButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
addSegment();
}
});
segmentButtonPanel.add(addSegmentButton);
//
// Remove segment button
//
removeSegmentButton = new JButton("-");
removeSegmentButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
removeSegment();
}
});
segmentButtonPanel.add(removeSegmentButton);
JLabel lblSegment = new JLabel("Segment");
segmentPanel.add(lblSegment, BorderLayout.NORTH);
}
Aggregations