use of com.sldeditor.ui.menucombobox.ArrowIcon in project sldeditor by robward-scisys.
the class InlineFeaturePanel method createUI.
/**
* Creates the UI.
*
* @param noOfRows the no of rows
*/
private void createUI(int noOfRows) {
setLayout(new BorderLayout());
int xPos = 0;
int width = BasePanel.FIELD_PANEL_WIDTH - xPos - 20;
int height = BasePanel.WIDGET_HEIGHT * (noOfRows - 1);
this.setBounds(0, 0, width, height);
// CRS dropdown
JPanel topPanel = new JPanel();
topPanel.add(createCRSList("CRS", xPos, topPanel));
add(topPanel, BorderLayout.NORTH);
// Feature table panel
featureTable = new JTable(model);
featureTable.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION);
featureTable.setColumnSelectionAllowed(true);
featureTable.setAutoscrolls(true);
featureTable.getTableHeader().setReorderingAllowed(false);
featureTable.setBounds(xPos, 0, BasePanel.FIELD_PANEL_WIDTH, getRowY(noOfRows - 2));
model.setTable(featureTable, crsComboBox);
ListSelectionModel selectionModel = featureTable.getSelectionModel();
selectionModel.addListSelectionListener(new ListSelectionListener() {
public void valueChanged(ListSelectionEvent e) {
if (!e.getValueIsAdjusting()) {
removeFeatureButton.setEnabled(true);
}
}
});
JScrollPane scrollPanel = new JScrollPane(featureTable);
scrollPanel.setBounds(xPos, 0, BasePanel.FIELD_PANEL_WIDTH, getRowY(noOfRows - 2));
JPanel tablePanel = new JPanel();
tablePanel.add(scrollPanel);
add(tablePanel, BorderLayout.CENTER);
// Buttons
JPanel bottomPanel = new JPanel();
bottomPanel.setLayout(new FlowLayout());
// Feature panel
JPanel addFeaturePanel = new JPanel();
addFeaturePanel.setBorder(BorderFactory.createTitledBorder(Localisation.getString(FieldConfigBase.class, "InlineFeature.features")));
JButton addButton = new JButton(Localisation.getString(FieldConfigBase.class, "InlineFeature.addfeature"));
addButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
addButtonPressed();
}
});
addFeaturePanel.add(addButton);
removeFeatureButton = new JButton(Localisation.getString(FieldConfigBase.class, "InlineFeature.removefeature"));
removeFeatureButton.setEnabled(false);
removeFeatureButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
removeFeatureButtonPressed();
}
});
addFeaturePanel.add(removeFeatureButton);
bottomPanel.add(addFeaturePanel);
// Attribute panel
JPanel attributePanel = new JPanel();
attributePanel.setBorder(BorderFactory.createTitledBorder(Localisation.getString(FieldConfigBase.class, "InlineFeature.attributes")));
JButton addColumnButton = new JButton(Localisation.getString(FieldConfigBase.class, "InlineFeature.addattribute"));
addColumnButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
model.addNewColumn();
}
});
attributePanel.add(addColumnButton);
JButton removeColumnButton = new JButton(Localisation.getString(FieldConfigBase.class, "InlineFeature.removeattribute"));
ArrowIcon arrow = new ArrowIcon(SwingConstants.SOUTH, true);
removeColumnButton.setIcon(arrow);
removeColumnButton.setHorizontalTextPosition(AbstractButton.LEFT);
removeColumnButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
removeColumnButton(removeColumnButton, e);
}
});
attributePanel.add(removeColumnButton);
bottomPanel.add(attributePanel);
add(bottomPanel, BorderLayout.SOUTH);
//
// Set up the column header editing
//
columnHeader = featureTable.getTableHeader();
columnHeader.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent event) {
if (event.getClickCount() == 2) {
int columnIndex = columnHeader.columnAtPoint(event.getPoint());
editColumnAt(columnIndex);
}
}
});
columnTextField = new JTextField();
columnTextField.setBorder(null);
columnTextField.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
renameColumn();
}
});
renamePopup = new JPopupMenu();
renamePopup.setBorder(new MatteBorder(0, 1, 1, 1, Color.DARK_GRAY));
renamePopup.add(columnTextField);
}
Aggregations