Search in sources :

Example 56 with ListSelectionListener

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);
}
Also used : JPanel(javax.swing.JPanel) MalformedURLException(java.net.MalformedURLException) FlowLayout(java.awt.FlowLayout) ActionEvent(java.awt.event.ActionEvent) BoxLayout(javax.swing.BoxLayout) JButton(javax.swing.JButton) ListSelectionEvent(javax.swing.event.ListSelectionEvent) JTextField(javax.swing.JTextField) URL(java.net.URL) BorderLayout(java.awt.BorderLayout) EnvVar(com.sldeditor.filter.v2.envvar.EnvVar) JScrollPane(javax.swing.JScrollPane) JComboBox(javax.swing.JComboBox) UnsupportedEncodingException(java.io.UnsupportedEncodingException) TableColumn(javax.swing.table.TableColumn) DefaultCellEditor(javax.swing.DefaultCellEditor) ListSelectionListener(javax.swing.event.ListSelectionListener) ActionListener(java.awt.event.ActionListener) JTable(javax.swing.JTable) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map)

Example 57 with ListSelectionListener

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);
}
Also used : JScrollPane(javax.swing.JScrollPane) JPanel(javax.swing.JPanel) FlowLayout(java.awt.FlowLayout) ActionEvent(java.awt.event.ActionEvent) ListSelectionEvent(javax.swing.event.ListSelectionEvent) JButton(javax.swing.JButton) ListSelectionModel(javax.swing.ListSelectionModel) JLabel(javax.swing.JLabel) TableColumn(javax.swing.table.TableColumn) ListSelectionListener(javax.swing.event.ListSelectionListener) BorderLayout(java.awt.BorderLayout) ActionListener(java.awt.event.ActionListener) JTable(javax.swing.JTable)

Example 58 with ListSelectionListener

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);
    }
}
Also used : JScrollPane(javax.swing.JScrollPane) ActionEvent(java.awt.event.ActionEvent) ListSelectionEvent(javax.swing.event.ListSelectionEvent) ArrayList(java.util.ArrayList) JButton(javax.swing.JButton) ColorMapEntry(org.geotools.styling.ColorMapEntry) ListSelectionListener(javax.swing.event.ListSelectionListener) ActionListener(java.awt.event.ActionListener) JTable(javax.swing.JTable) ArrayList(java.util.ArrayList) List(java.util.List) FieldPanel(com.sldeditor.ui.widgets.FieldPanel) ColourRampConfigPanel(com.sldeditor.colourramp.ColourRampConfigPanel)

Example 59 with ListSelectionListener

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);
}
Also used : JScrollPane(javax.swing.JScrollPane) ActionListener(java.awt.event.ActionListener) ActionEvent(java.awt.event.ActionEvent) JTable(javax.swing.JTable) ListSelectionEvent(javax.swing.event.ListSelectionEvent) JButton(javax.swing.JButton) FeatureTypeConstraint(org.geotools.styling.FeatureTypeConstraint) ListSelectionListener(javax.swing.event.ListSelectionListener)

Example 60 with ListSelectionListener

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);
}
Also used : JScrollPane(javax.swing.JScrollPane) JPanel(javax.swing.JPanel) FlowLayout(java.awt.FlowLayout) ActionEvent(java.awt.event.ActionEvent) ListSelectionEvent(javax.swing.event.ListSelectionEvent) JButton(javax.swing.JButton) JLabel(javax.swing.JLabel) Dimension(java.awt.Dimension) ListSelectionListener(javax.swing.event.ListSelectionListener) BorderLayout(java.awt.BorderLayout) ActionListener(java.awt.event.ActionListener) JList(javax.swing.JList) List(java.util.List)

Aggregations

ListSelectionListener (javax.swing.event.ListSelectionListener)216 ListSelectionEvent (javax.swing.event.ListSelectionEvent)210 ActionEvent (java.awt.event.ActionEvent)90 ActionListener (java.awt.event.ActionListener)76 JScrollPane (javax.swing.JScrollPane)72 JPanel (javax.swing.JPanel)67 JButton (javax.swing.JButton)61 BorderLayout (java.awt.BorderLayout)53 MouseEvent (java.awt.event.MouseEvent)47 Dimension (java.awt.Dimension)44 JLabel (javax.swing.JLabel)40 MouseAdapter (java.awt.event.MouseAdapter)37 JTable (javax.swing.JTable)36 FlowLayout (java.awt.FlowLayout)28 Insets (java.awt.Insets)28 JList (javax.swing.JList)27 List (java.util.List)24 ArrayList (java.util.ArrayList)22 KeyEvent (java.awt.event.KeyEvent)21 GridBagConstraints (java.awt.GridBagConstraints)20