Search in sources :

Example 1 with ArrowIcon

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);
}
Also used : JScrollPane(javax.swing.JScrollPane) JPanel(javax.swing.JPanel) FlowLayout(java.awt.FlowLayout) MouseEvent(java.awt.event.MouseEvent) FieldConfigBase(com.sldeditor.ui.detail.config.FieldConfigBase) ArrowIcon(com.sldeditor.ui.menucombobox.ArrowIcon) ActionEvent(java.awt.event.ActionEvent) ListSelectionEvent(javax.swing.event.ListSelectionEvent) JButton(javax.swing.JButton) MouseAdapter(java.awt.event.MouseAdapter) ListSelectionModel(javax.swing.ListSelectionModel) JTextField(javax.swing.JTextField) JPopupMenu(javax.swing.JPopupMenu) ListSelectionListener(javax.swing.event.ListSelectionListener) MatteBorder(javax.swing.border.MatteBorder) BorderLayout(java.awt.BorderLayout) ActionListener(java.awt.event.ActionListener) JTable(javax.swing.JTable)

Aggregations

FieldConfigBase (com.sldeditor.ui.detail.config.FieldConfigBase)1 ArrowIcon (com.sldeditor.ui.menucombobox.ArrowIcon)1 BorderLayout (java.awt.BorderLayout)1 FlowLayout (java.awt.FlowLayout)1 ActionEvent (java.awt.event.ActionEvent)1 ActionListener (java.awt.event.ActionListener)1 MouseAdapter (java.awt.event.MouseAdapter)1 MouseEvent (java.awt.event.MouseEvent)1 JButton (javax.swing.JButton)1 JPanel (javax.swing.JPanel)1 JPopupMenu (javax.swing.JPopupMenu)1 JScrollPane (javax.swing.JScrollPane)1 JTable (javax.swing.JTable)1 JTextField (javax.swing.JTextField)1 ListSelectionModel (javax.swing.ListSelectionModel)1 MatteBorder (javax.swing.border.MatteBorder)1 ListSelectionEvent (javax.swing.event.ListSelectionEvent)1 ListSelectionListener (javax.swing.event.ListSelectionListener)1