Search in sources :

Example 11 with ValueComboBoxData

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

the class InlineFeaturePanel method createCRSList.

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

        @Override
        public void actionPerformed(ActionEvent e) {
            if (!isPopulating()) {
                model.updateCRS(crsComboBox.getSelectedValue());
            }
        }
    });
    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 12 with ValueComboBoxData

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

the class FieldConfigEnum method undoAction.

/**
 * Undo action.
 *
 * @param undoRedoObject the undo redo object
 */
/*
     * (non-Javadoc)
     * 
     * @see com.sldeditor.undo.UndoActionInterface#undoAction(com.sldeditor.undo.UndoInterface)
     */
@Override
public void undoAction(UndoInterface undoRedoObject) {
    if ((comboBox != null) && (undoRedoObject != null)) {
        if (undoRedoObject.getOldValue() instanceof String) {
            String oldValue = (String) undoRedoObject.getOldValue();
            ValueComboBoxData valueComboBoxData = comboDataMap.get(oldValue);
            if (valueComboBoxData != null) {
                comboBox.setSelectedItem(valueComboBoxData);
            }
        }
    }
}
Also used : ValueComboBoxData(com.sldeditor.ui.widgets.ValueComboBoxData)

Example 13 with ValueComboBoxData

use of com.sldeditor.ui.widgets.ValueComboBoxData 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 14 with ValueComboBoxData

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

the class FieldConfigMarker method accept.

/**
 * Accept.
 *
 * @param symbol the symbol
 * @return true, if successful
 */
@Override
public boolean accept(GraphicalSymbol symbol) {
    if (symbol != null) {
        if (symbol instanceof MarkImpl) {
            MarkImpl marker = (MarkImpl) symbol;
            Expression expression = marker.getWellKnownName();
            if (expression instanceof LiteralExpressionImpl) {
                LiteralExpressionImpl lExpression = (LiteralExpressionImpl) expression;
                Object value = lExpression.getValue();
                if (value instanceof String) {
                    String valueString = (String) value;
                    List<ValueComboBoxData> localSymbolList = getLocalSymbolList();
                    if (localSymbolList != null) {
                        for (ValueComboBoxData data : localSymbolList) {
                            if (data.getKey().compareTo(valueString) == 0) {
                                return true;
                            }
                        }
                    }
                }
            }
        }
    }
    return false;
}
Also used : Expression(org.opengis.filter.expression.Expression) LiteralExpressionImpl(org.geotools.filter.LiteralExpressionImpl) MarkImpl(org.geotools.styling.MarkImpl) ValueComboBoxData(com.sldeditor.ui.widgets.ValueComboBoxData)

Example 15 with ValueComboBoxData

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

the class VOGeoServerLabelling method internal_updateSymbolEnumField.

/**
 * Internal_update symbol enum field.
 *
 * @param options the options
 * @param field the field
 * @param key the key
 */
private void internal_updateSymbolEnumField(Map<String, String> options, FieldIdEnum field, String key) {
    ValueComboBoxData value = fieldConfigVisitor.getComboBox(field);
    Object object = getDefaultFieldValue(field);
    String defaultValue = null;
    if (object instanceof TextSymbolizer.PolygonAlignOptions) {
        TextSymbolizer.PolygonAlignOptions option = (PolygonAlignOptions) object;
        defaultValue = option.toString();
    } else {
        defaultValue = (String) object;
    }
    if (defaultValue == null) {
        ConsoleManager.getInstance().error(this, "Failed to find default for field : " + field);
    } else if ((value.getKey().compareToIgnoreCase(defaultValue) != 0) || includeValue(field)) {
        options.put(key, value.getKey());
    }
}
Also used : PolygonAlignOptions(org.geotools.styling.TextSymbolizer.PolygonAlignOptions) TextSymbolizer(org.geotools.styling.TextSymbolizer) PolygonAlignOptions(org.geotools.styling.TextSymbolizer.PolygonAlignOptions) 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