use of javax.swing.ListSelectionModel in project sldeditor by robward-scisys.
the class SortByPanel method selectDestination.
/**
* Select destination rows.
*
* @param selectedIndexes the selected indexes
*/
protected void selectDestination(int[] selectedIndexes) {
ListSelectionModel model = destinationTable.getSelectionModel();
model.clearSelection();
for (int index : selectedIndexes) {
model.addSelectionInterval(index, index);
}
}
use of javax.swing.ListSelectionModel in project sldeditor by robward-scisys.
the class SortByPanel method moveDestinationDown.
/**
* Move destination down.
*/
protected void moveDestinationDown() {
int[] indices = destinationTable.getSelectedRows();
int[] updatedIndices = new int[indices.length];
for (int arrayIndex = indices.length - 1; arrayIndex >= 0; arrayIndex--) {
int index = indices[arrayIndex];
if (index < destinationModel.getRowCount() - 1) {
destinationModel.moveRowDown(index);
updatedIndices[arrayIndex] = index + 1;
} else {
// At the bottom of the list so make sure it is still highlighted
updatedIndices[arrayIndex] = index;
}
}
// Reselect the items after they have moved
ListSelectionModel model = destinationTable.getSelectionModel();
model.clearSelection();
for (int index : updatedIndices) {
model.addSelectionInterval(index, index);
}
}
use of javax.swing.ListSelectionModel in project sldeditor by robward-scisys.
the class SortByPanel method setText.
/**
* Sets the text.
*
* @param value the new text
*/
public void setText(String value) {
Map<String, String> options = new HashMap<>();
ListSelectionModel model = destinationTable.getSelectionModel();
model.clearSelection();
SortBy[] sortArray = null;
if (!value.isEmpty()) {
options.put(FeatureTypeStyle.SORT_BY, value);
sortArray = SLDStyleFactory.getSortBy(options);
}
destinationModel.populate(sortArray);
updateLists();
btnMoveDown.setEnabled(false);
btnMoveUp.setEnabled(false);
btnDestToSrcButton.setEnabled(false);
btnSrcToDestButton.setEnabled(false);
}
use of javax.swing.ListSelectionModel 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<>(sourceModel);
sourceList.addListSelectionListener(new ListSelectionListener() {
public void valueChanged(ListSelectionEvent e) {
if (!e.getValueIsAdjusting()) {
sourceSelected();
}
}
});
scrollPaneSource.setViewportView(sourceList);
JPanel panel1 = new JPanel();
panel1.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()) {
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 flButtonPanel = (FlowLayout) buttonPanel.getLayout();
flButtonPanel.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.ListSelectionModel in project sldeditor by robward-scisys.
the class ConfigureLayerStyleDialog method createUI.
/**
* Creates the ui.
*/
private void createUI() {
JPanel panel = new JPanel();
getContentPane().add(panel, BorderLayout.CENTER);
panel.setLayout(new BorderLayout(0, 0));
table = new JTable(dataModel);
dataModel.setColumnRenderer(table.getColumnModel());
ListSelectionModel selectionModel = table.getSelectionModel();
selectionModel.addListSelectionListener(new ListSelectionListener() {
@Override
public void valueChanged(ListSelectionEvent e) {
if (e.getValueIsAdjusting()) {
return;
}
itemSelected();
}
});
JScrollPane scrollPane = new JScrollPane(table);
panel.add(scrollPane, BorderLayout.CENTER);
//
// Button panel
//
JPanel buttonPanel = new JPanel();
FlowLayout flowLayout = (FlowLayout) buttonPanel.getLayout();
flowLayout.setAlignment(FlowLayout.TRAILING);
getContentPane().add(buttonPanel, BorderLayout.SOUTH);
JButton btnOk = new JButton(Localisation.getString(ConfigureLayerStyleDialog.class, "common.ok"));
btnOk.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
okButtonPressed = false;
updatedLayerList = dataModel.getUpdatedLayers();
if (!updatedLayerList.isEmpty()) {
okButtonPressed = true;
}
setVisible(false);
}
});
buttonPanel.add(btnOk);
JButton btnCancel = new JButton(Localisation.getString(ConfigureLayerStyleDialog.class, "common.cancel"));
btnCancel.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
okButtonPressed = false;
setVisible(false);
}
});
buttonPanel.add(btnCancel);
geoServerStyleTree = new GeoServerStyleTree(this);
getContentPane().add(geoServerStyleTree, BorderLayout.EAST);
}
Aggregations