Search in sources :

Example 6 with ValueComboBoxData

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

the class VendorOptionMenuUtils method createMenu.

/**
 * Creates the menu.
 *
 * @param versionDataList the list version data
 * @return the list
 */
public static List<ValueComboBoxDataGroup> createMenu(List<VersionData> versionDataList) {
    if (dataSelectionList.isEmpty()) {
        Map<String, List<ValueComboBoxData>> map = new HashMap<String, List<ValueComboBoxData>>();
        List<String> keyOrderList = new ArrayList<String>();
        if (versionDataList != null) {
            for (VersionData versionData : versionDataList) {
                String key = getKey(versionData);
                List<ValueComboBoxData> dataList = map.get(key);
                if (dataList == null) {
                    dataList = new ArrayList<ValueComboBoxData>();
                    map.put(key, dataList);
                    keyOrderList.add(key);
                }
                VendorOptionVersion vendorOptionVersion = new VendorOptionVersion(versionData.getVendorOptionType(), versionData);
                ValueComboBoxData value = new ValueComboBoxData(versionData.getVersionString(), versionData.getVersionString(), vendorOptionVersion, String.class);
                dataList.add(value);
                valueMap.put(versionData.getVersionString(), value);
            }
            // Add groups to menu combo
            for (String key : keyOrderList) {
                List<ValueComboBoxData> dataList = map.get(key);
                ValueComboBoxDataGroup group = new ValueComboBoxDataGroup(key + ".x", dataList, (dataList.size() > 1));
                dataSelectionList.add(group);
            }
        }
    }
    return dataSelectionList;
}
Also used : ValueComboBoxDataGroup(com.sldeditor.ui.widgets.ValueComboBoxDataGroup) HashMap(java.util.HashMap) VersionData(com.sldeditor.common.vendoroption.VersionData) VendorOptionVersion(com.sldeditor.common.vendoroption.VendorOptionVersion) ArrayList(java.util.ArrayList) List(java.util.List) ArrayList(java.util.ArrayList) ValueComboBoxData(com.sldeditor.ui.widgets.ValueComboBoxData)

Example 7 with ValueComboBoxData

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

the class MultiOptionGroup method optionSelected.

/**
 * Option selected.
 *
 * @param box the box
 * @param fieldConfigManager the field config manager
 * @param panel the panel
 * @param parentObj the parent obj
 */
private void optionSelected(Box box, GraphicPanelFieldManager fieldConfigManager, FieldPanel panel, UndoActionInterface parentObj) {
    if ((comboBox != null) && (comboBox.getSelectedItem() != null)) {
        ValueComboBoxData value = comboBox.getSelectedValue();
        if (value != null) {
            // Remove the fields from the previous selection
            removeOptionFields(box, fieldConfigManager);
            optionPanel = new JPanel();
            optionPanel.setLayout(new BorderLayout());
            Box optionBox = Box.createVerticalBox();
            optionPanel.add(optionBox, BorderLayout.CENTER);
            int index = findOptionPanel(box, panel);
            OptionGroup optionGroup = optionMap.get(value.getKey());
            populateOptionGroup(fieldConfigManager, optionBox, optionGroup.getGroupList());
            box.add(optionPanel, index + 1);
            Object newValueObj = value.getKey();
            if ((oldValueObj == null) && (comboBox.getItemCount() > 0)) {
                oldValueObj = comboBox.getFirstItem().getKey();
            }
            UndoManager.getInstance().addUndoEvent(new UndoEvent(parentObj, "Multi option : " + getId(), oldValueObj, newValueObj));
            oldValueObj = newValueObj;
            box.revalidate();
        }
    }
}
Also used : UndoEvent(com.sldeditor.common.undo.UndoEvent) JPanel(javax.swing.JPanel) BorderLayout(java.awt.BorderLayout) Box(javax.swing.Box) ValueComboBox(com.sldeditor.ui.widgets.ValueComboBox) JCheckBox(javax.swing.JCheckBox) ValueComboBoxData(com.sldeditor.ui.widgets.ValueComboBoxData)

Example 8 with ValueComboBoxData

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

the class MultiOptionGroup method createUI.

/**
 * Creates the ui.
 *
 * @param fieldConfigManager the field config manager
 * @param box the box
 * @param parent the parent
 * @param panelId the panel id
 */
public void createUI(GraphicPanelFieldManager fieldConfigManager, Box box, UpdateSymbolInterface parent, Class<?> panelId) {
    final UndoActionInterface parentObj = this;
    this.fieldConfigManager = fieldConfigManager;
    this.parentBox = box;
    this.parent = parent;
    this.panelId = panelId;
    int x = 2;
    box.add(GroupConfig.createSeparator());
    fieldPanel = new FieldPanel(0, "", BasePanel.WIDGET_HEIGHT * 2, false, null);
    // Set up title
    if (isOptional()) {
        groupTitleCheckbox = new JCheckBox(getLabel());
        groupTitleCheckbox.setBounds(x, 0, BasePanel.WIDGET_EXTENDED_WIDTH, BasePanel.WIDGET_HEIGHT);
        groupTitleCheckbox.setOpaque(true);
        fieldPanel.add(groupTitleCheckbox);
        multiOptionGroupEnabled = false;
        groupTitleCheckbox.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
                enable(groupTitleCheckbox.isSelected());
                if (parent != null) {
                    if (!Controller.getInstance().isPopulating()) {
                        parent.dataChanged(FieldIdEnum.UNKNOWN);
                    }
                }
            }
        });
    } else {
        JLabel groupTitle = new JLabel(getLabel());
        groupTitle.setBounds(x, 0, BasePanel.WIDGET_EXTENDED_WIDTH, BasePanel.WIDGET_HEIGHT);
        groupTitle.setOpaque(true);
        fieldPanel.add(groupTitle);
    }
    // Set up options in the drop down
    List<ValueComboBoxData> valueComboDataMap = new ArrayList<ValueComboBoxData>();
    for (OptionGroup optionGroup : optionList) {
        valueComboDataMap.add(new ValueComboBoxData(optionGroup.getId().toString(), optionGroup.getLabel(), panelId));
    }
    comboBox = new ValueComboBox();
    comboBox.initialiseSingle(valueComboDataMap);
    comboBox.setBounds(BasePanel.WIDGET_X_START, BasePanel.WIDGET_HEIGHT, BasePanel.WIDGET_STANDARD_WIDTH, BasePanel.WIDGET_HEIGHT);
    fieldPanel.add(comboBox);
    comboBox.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            optionSelected(parentBox, fieldConfigManager, fieldPanel, parentObj);
            if (parent != null) {
                if (!Controller.getInstance().isPopulating()) {
                    parent.dataChanged(FieldIdEnum.UNKNOWN);
                }
            }
        }
    });
    box.add(fieldPanel);
}
Also used : ActionEvent(java.awt.event.ActionEvent) ArrayList(java.util.ArrayList) JLabel(javax.swing.JLabel) UndoActionInterface(com.sldeditor.common.undo.UndoActionInterface) ValueComboBoxData(com.sldeditor.ui.widgets.ValueComboBoxData) JCheckBox(javax.swing.JCheckBox) ActionListener(java.awt.event.ActionListener) ValueComboBox(com.sldeditor.ui.widgets.ValueComboBox) FieldPanel(com.sldeditor.ui.widgets.FieldPanel)

Example 9 with ValueComboBoxData

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

the class FieldConfigBoundingBox method createCRSList.

/**
 * Creates the crs list.
 *
 * @param label the label
 * @param xPos the x pos
 * @param fieldPanel the field panel
 * @param row the row
 * @return the value combo box
 */
private ValueComboBox createCRSList(String label, int xPos, FieldPanel fieldPanel, int row) {
    JLabel lbl = new JLabel(label);
    lbl.setHorizontalAlignment(SwingConstants.TRAILING);
    lbl.setBounds(xPos, getRowY(row), BasePanel.LABEL_WIDTH, BasePanel.WIDGET_HEIGHT);
    fieldPanel.add(lbl);
    // Populate data list
    List<ValueComboBoxData> crsDataList = CoordManager.getInstance().getCRSList();
    crsComboBox = new ValueComboBox();
    crsComboBox.initialiseSingle(crsDataList);
    crsComboBox.setBounds(xPos + BasePanel.WIDGET_X_START, getRowY(row), this.isValueOnly() ? BasePanel.WIDGET_EXTENDED_WIDTH : BasePanel.WIDGET_STANDARD_WIDTH, BasePanel.WIDGET_HEIGHT);
    fieldPanel.add(crsComboBox);
    crsComboBox.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            valueUpdated();
        }
    });
    return crsComboBox;
}
Also used : ValueComboBox(com.sldeditor.ui.widgets.ValueComboBox) ActionListener(java.awt.event.ActionListener) ActionEvent(java.awt.event.ActionEvent) JLabel(javax.swing.JLabel) ValueComboBoxData(com.sldeditor.ui.widgets.ValueComboBoxData)

Example 10 with ValueComboBoxData

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

the class FieldConfigBoundingBox method getBBox.

/**
 * Generates the bounding box from the ui.
 *
 * @return the b box
 */
private ReferencedEnvelope getBBox() {
    if (xMinTextField == null) {
        return null;
    }
    double minX = xMinTextField.getText().isEmpty() ? 0.0 : Double.valueOf(xMinTextField.getText());
    double maxX = xMaxTextField.getText().isEmpty() ? 0.0 : Double.valueOf(xMaxTextField.getText());
    double minY = yMinTextField.getText().isEmpty() ? 0.0 : Double.valueOf(yMinTextField.getText());
    double maxY = yMaxTextField.getText().isEmpty() ? 0.0 : Double.valueOf(yMaxTextField.getText());
    ValueComboBoxData crsDataValue = crsComboBox.getSelectedValue();
    CoordinateReferenceSystem crs = null;
    try {
        if (crsDataValue != null) {
            crs = CRS.decode(crsDataValue.getKey());
        }
    } catch (NoSuchAuthorityCodeException e) {
        ConsoleManager.getInstance().exception(this, e);
    } catch (FactoryException e) {
        ConsoleManager.getInstance().exception(this, e);
    }
    ReferencedEnvelope envelope = new ReferencedEnvelope(minX, maxX, minY, maxY, crs);
    return envelope;
}
Also used : NoSuchAuthorityCodeException(org.opengis.referencing.NoSuchAuthorityCodeException) ReferencedEnvelope(org.geotools.geometry.jts.ReferencedEnvelope) FactoryException(org.opengis.referencing.FactoryException) CoordinateReferenceSystem(org.opengis.referencing.crs.CoordinateReferenceSystem) ValueComboBoxData(com.sldeditor.ui.widgets.ValueComboBoxData)

Aggregations

ValueComboBoxData (com.sldeditor.ui.widgets.ValueComboBoxData)39 ArrayList (java.util.ArrayList)13 ValueComboBox (com.sldeditor.ui.widgets.ValueComboBox)8 ActionEvent (java.awt.event.ActionEvent)8 ActionListener (java.awt.event.ActionListener)8 ValueComboBoxDataGroup (com.sldeditor.ui.widgets.ValueComboBoxDataGroup)7 Test (org.junit.Test)7 FieldConfigCommonData (com.sldeditor.ui.detail.config.FieldConfigCommonData)6 JPanel (javax.swing.JPanel)6 UndoEvent (com.sldeditor.common.undo.UndoEvent)5 Dimension (java.awt.Dimension)4 JLabel (javax.swing.JLabel)4 UndoActionInterface (com.sldeditor.common.undo.UndoActionInterface)3 GroupConfigInterface (com.sldeditor.ui.detail.config.base.GroupConfigInterface)3 FieldConfigMarker (com.sldeditor.ui.detail.config.symboltype.FieldConfigMarker)3 FieldPanel (com.sldeditor.ui.widgets.FieldPanel)3 BorderLayout (java.awt.BorderLayout)3 JCheckBox (javax.swing.JCheckBox)3 Expression (org.opengis.filter.expression.Expression)3 ColourRamp (com.sldeditor.colourramp.ColourRamp)2