Search in sources :

Example 6 with ValueComboBox

use of com.sldeditor.ui.widgets.ValueComboBox in project sldeditor by robward-scisys.

the class FieldConfigEnum method createUI.

/**
 * Creates the ui.
 */
/*
     * (non-Javadoc)
     * 
     * @see com.sldeditor.ui.detail.config.FieldConfigBase#createUI()
     */
@Override
public void createUI() {
    if (comboBox == null) {
        final UndoActionInterface parentObj = this;
        List<ValueComboBoxData> dataList = new ArrayList<ValueComboBoxData>();
        for (String key : keyList) {
            dataList.add(new ValueComboBoxData(key, valueMap.get(key), getPanelId()));
        }
        if (!dataList.isEmpty()) {
            defaultValue = dataList.get(0).getKey();
        }
        int xPos = getXPos();
        comboBox = new ValueComboBox();
        comboBox.initialiseSingle(dataList);
        comboBox.setBounds(xPos + BasePanel.WIDGET_X_START, 0, isValueOnly() ? BasePanel.WIDGET_EXTENDED_WIDTH : BasePanel.WIDGET_STANDARD_WIDTH, BasePanel.WIDGET_HEIGHT);
        FieldPanel fieldPanel = createFieldPanel(xPos, getLabel());
        fieldPanel.add(comboBox);
        if (!isValueOnly()) {
            setAttributeSelectionPanel(fieldPanel.internalCreateAttrButton(String.class, this, isRasterSymbol()));
        }
        if (dataList != null) {
            for (ValueComboBoxData data : dataList) {
                this.comboDataMap.put(data.getKey(), data);
            }
        }
        comboBox.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent e) {
                ValueComboBox comboBox = (ValueComboBox) e.getSource();
                if (comboBox.getSelectedItem() != null) {
                    Object newValueObj = comboBox.getSelectedValue().getKey();
                    if ((oldValueObj == null) && comboBox.getItemCount() > 0) {
                        oldValueObj = comboBox.getFirstItem().getKey();
                    }
                    UndoManager.getInstance().addUndoEvent(new UndoEvent(parentObj, getFieldId(), oldValueObj, newValueObj));
                    oldValueObj = newValueObj;
                    valueUpdated();
                }
            }
        });
    }
}
Also used : UndoEvent(com.sldeditor.common.undo.UndoEvent) ValueComboBox(com.sldeditor.ui.widgets.ValueComboBox) ActionListener(java.awt.event.ActionListener) ActionEvent(java.awt.event.ActionEvent) ArrayList(java.util.ArrayList) FieldPanel(com.sldeditor.ui.widgets.FieldPanel) UndoActionInterface(com.sldeditor.common.undo.UndoActionInterface) ValueComboBoxData(com.sldeditor.ui.widgets.ValueComboBoxData)

Example 7 with ValueComboBox

use of com.sldeditor.ui.widgets.ValueComboBox in project sldeditor by robward-scisys.

the class SLDTextArea method makeTextAreaPanel.

/**
 * Make text area panel.
 *
 * @return the j component
 */
private JPanel makeTextAreaPanel() {
    JPanel sldSourcePanel = new JPanel(false);
    sldSourcePanel.setLayout(new BorderLayout());
    List<ValueComboBoxData> dataList = new ArrayList<ValueComboBoxData>();
    dataList.add(new ValueComboBoxData(SLDOutputFormatEnum.SLD.name(), "SLD", VendorOptionManager.getInstance().getDefaultVendorOptionVersion()));
    dataList.add(new ValueComboBoxData(SLDOutputFormatEnum.YSLD.name(), "YSLD", VendorOptionManager.getInstance().getDefaultVendorOptionVersion()));
    /*
         * Code to be uncommented to used when gt-mbstyles becomes a supported module.
         * 
         * dataList.add(new ValueComboBoxData(SLDOutputFormatEnum.MAPBOX.name(), "MapBox",
         * VendorOptionManager.getInstance().getDefaultVendorOptionVersion()));
         */
    // Options panel
    JPanel optionsPanel = new JPanel();
    JLabel label = new JLabel(Localisation.getField(SLDTextArea.class, "SLDTextArea.format"));
    optionsPanel.add(label);
    comboBox = new ValueComboBox();
    comboBox.setPreferredSize(new Dimension(BasePanel.WIDGET_STANDARD_WIDTH, BasePanel.WIDGET_HEIGHT));
    comboBox.initialiseSingle(dataList);
    comboBox.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            ValueComboBox comboBox = (ValueComboBox) e.getSource();
            if (comboBox.getSelectedItem() != null) {
                String name = comboBox.getSelectedValue().getKey();
                outputFormat = SLDOutputFormatEnum.valueOf(SLDOutputFormatEnum.class, name);
                outputText();
            }
        }
    });
    optionsPanel.add(comboBox);
    sldSourcePanel.add(optionsPanel, BorderLayout.NORTH);
    // Scroll pane
    JScrollPane scrollPane = new JScrollPane();
    sldSourcePanel.add(scrollPane);
    sldSourceTextArea = new JTextArea();
    scrollPane.setViewportView(sldSourceTextArea);
    sldSourceTextArea.setEditable(false);
    sldSourceTextArea.setWrapStyleWord(true);
    sldSourceTextArea.setLineWrap(true);
    sldSourcePanel.add(scrollPane, BorderLayout.CENTER);
    return sldSourcePanel;
}
Also used : JScrollPane(javax.swing.JScrollPane) JPanel(javax.swing.JPanel) JTextArea(javax.swing.JTextArea) ActionEvent(java.awt.event.ActionEvent) ArrayList(java.util.ArrayList) JLabel(javax.swing.JLabel) Dimension(java.awt.Dimension) ValueComboBoxData(com.sldeditor.ui.widgets.ValueComboBoxData) BorderLayout(java.awt.BorderLayout) ValueComboBox(com.sldeditor.ui.widgets.ValueComboBox) ActionListener(java.awt.event.ActionListener)

Example 8 with ValueComboBox

use of com.sldeditor.ui.widgets.ValueComboBox in project sldeditor by robward-scisys.

the class ColourRampPanel method createTopPanel.

/**
 * Creates the top panel.
 */
private void createTopPanel() {
    final UndoActionInterface undoObj = this;
    JPanel topPanel = new JPanel();
    topPanel.setPreferredSize(new Dimension(BasePanel.FIELD_PANEL_WIDTH, BasePanel.WIDGET_HEIGHT));
    topPanel.setLayout(null);
    panel.add(topPanel, BorderLayout.NORTH);
    List<ValueComboBoxData> dataList = populateColourRamps(false);
    rampComboBox = new ValueComboBox();
    rampComboBox.initialiseSingle(dataList);
    rampComboBox.setBounds(BasePanel.WIDGET_X_START, 0, BasePanel.WIDGET_EXTENDED_WIDTH, BasePanel.WIDGET_HEIGHT);
    topPanel.add(rampComboBox);
    rampComboBox.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            if (!isPopulating()) {
                Integer newValueObj = rampComboBox.getSelectedIndex();
                UndoManager.getInstance().addUndoEvent(new UndoEvent(undoObj, FieldIdEnum.COLOUR_RAMP_COLOUR, oldColourRampIndex, newValueObj));
                oldColourRampIndex = newValueObj;
            }
        }
    });
    reverseCheckbox = new JCheckBox(Localisation.getString(ColourRampConfigPanel.class, "ColourRampPanel.reverse"));
    reverseCheckbox.setBounds(rampComboBox.getX() + rampComboBox.getWidth() + 20, 0, BasePanel.WIDGET_STANDARD_WIDTH, BasePanel.WIDGET_HEIGHT);
    reverseCheckbox.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            boolean isSelected = reverseCheckbox.isSelected();
            Boolean oldValueObj = Boolean.valueOf(!isSelected);
            Boolean newValueObj = Boolean.valueOf(isSelected);
            UndoManager.getInstance().addUndoEvent(new UndoEvent(undoObj, FieldIdEnum.COLOUR_RAMP_REVERSE, oldValueObj, newValueObj));
            reverseColourRamp(isSelected);
        }
    });
    topPanel.add(reverseCheckbox);
}
Also used : UndoEvent(com.sldeditor.common.undo.UndoEvent) JPanel(javax.swing.JPanel) ActionEvent(java.awt.event.ActionEvent) Dimension(java.awt.Dimension) UndoActionInterface(com.sldeditor.common.undo.UndoActionInterface) ValueComboBoxData(com.sldeditor.ui.widgets.ValueComboBoxData) FieldConfigInteger(com.sldeditor.ui.detail.config.FieldConfigInteger) JCheckBox(javax.swing.JCheckBox) ValueComboBox(com.sldeditor.ui.widgets.ValueComboBox) ActionListener(java.awt.event.ActionListener)

Aggregations

ValueComboBox (com.sldeditor.ui.widgets.ValueComboBox)8 ActionEvent (java.awt.event.ActionEvent)8 ActionListener (java.awt.event.ActionListener)8 ValueComboBoxData (com.sldeditor.ui.widgets.ValueComboBoxData)7 UndoActionInterface (com.sldeditor.common.undo.UndoActionInterface)4 ArrayList (java.util.ArrayList)4 JLabel (javax.swing.JLabel)4 UndoEvent (com.sldeditor.common.undo.UndoEvent)3 FieldPanel (com.sldeditor.ui.widgets.FieldPanel)3 Dimension (java.awt.Dimension)3 JPanel (javax.swing.JPanel)3 JCheckBox (javax.swing.JCheckBox)2 FieldConfigInteger (com.sldeditor.ui.detail.config.FieldConfigInteger)1 BorderLayout (java.awt.BorderLayout)1 JScrollPane (javax.swing.JScrollPane)1 JTextArea (javax.swing.JTextArea)1 Font (org.geotools.styling.Font)1