Search in sources :

Example 6 with FieldConfigEnum

use of com.sldeditor.ui.detail.config.FieldConfigEnum in project sldeditor by robward-scisys.

the class VOGeoServerLabelling method includeValue.

/**
 * Find out whether to include value based on the value of another field.
 *
 * @param field the field
 * @return true, if successful
 */
private boolean includeValue(FieldIdEnum field) {
    DefaultOverride override = overrideMap.get(field);
    if (override != null) {
        String value = null;
        FieldConfigBase fieldConfig = fieldConfigManager.get(override.getField());
        if (fieldConfig instanceof FieldConfigBoolean) {
            value = String.valueOf(fieldConfigVisitor.getBoolean(override.getField()));
        } else if (fieldConfig instanceof FieldConfigInteger) {
            value = String.valueOf(fieldConfigVisitor.getInteger(override.getField()));
        } else if (fieldConfig instanceof FieldConfigDouble) {
            value = String.valueOf(fieldConfigVisitor.getDouble(override.getField()));
        } else if (fieldConfig instanceof FieldConfigEnum) {
            value = String.valueOf(fieldConfigVisitor.getComboBox(override.getField()));
        } else {
            ConsoleManager.getInstance().error(this, "Unsupported field type : " + field + " " + fieldConfig.getClass().getName());
        }
        if (value != null) {
            for (String legalValue : override.getLegalValues()) {
                if (value.compareToIgnoreCase(legalValue) == 0) {
                    return true;
                }
            }
        }
    }
    return false;
}
Also used : FieldConfigInteger(com.sldeditor.ui.detail.config.FieldConfigInteger) FieldConfigBase(com.sldeditor.ui.detail.config.FieldConfigBase) FieldConfigDouble(com.sldeditor.ui.detail.config.FieldConfigDouble) FieldConfigEnum(com.sldeditor.ui.detail.config.FieldConfigEnum) FieldConfigBoolean(com.sldeditor.ui.detail.config.FieldConfigBoolean)

Example 7 with FieldConfigEnum

use of com.sldeditor.ui.detail.config.FieldConfigEnum in project sldeditor by robward-scisys.

the class VOGeoServerFTSComposite method populate.

/*
     * (non-Javadoc)
     * 
     * @see
     * com.sldeditor.ui.detail.vendor.geoserver.VendorOptionInterface#populate(org.geotools.styling.
     * FeatureTypeStyle)
     */
@Override
public void populate(FeatureTypeStyle featureTypeStyle) {
    Map<String, String> options = featureTypeStyle.getOptions();
    String compositeString = options.get(FeatureTypeStyle.COMPOSITE);
    String name = null;
    double opacity = DEFAULT_COMPOSITE_OPACITY;
    if (compositeString != null) {
        String[] components = compositeString.split(",");
        FieldConfigEnum optionData = (FieldConfigEnum) fieldConfigVisitor.getFieldConfig(FieldIdEnum.VO_FTS_COMPOSITE_OPTION);
        if (optionData.isValidOption(components[0])) {
            name = components[0];
        }
        if (components.length == 2) {
            try {
                opacity = Double.valueOf(components[1]);
            } catch (Exception e) {
            // Do nothing and revert to default
            }
        }
    }
    fieldConfigVisitor.populateComboBoxField(FieldIdEnum.VO_FTS_COMPOSITE_OPTION, name);
    fieldConfigVisitor.populateDoubleField(FieldIdEnum.VO_FTS_COMPOSITE_OPACITY, opacity);
    GroupConfigInterface groupPanel = getGroup(GroupIdEnum.VO_FTS_COMPOSITE);
    groupPanel.enable(compositeString != null);
}
Also used : FieldConfigEnum(com.sldeditor.ui.detail.config.FieldConfigEnum) GroupConfigInterface(com.sldeditor.ui.detail.config.base.GroupConfigInterface)

Example 8 with FieldConfigEnum

use of com.sldeditor.ui.detail.config.FieldConfigEnum in project sldeditor by robward-scisys.

the class BaseValue method createEnum.

/**
 * Creates the enum.
 *
 * @param commonData the common data
 * @return the field config base
 */
protected FieldConfigBase createEnum(FieldConfigCommonData commonData) {
    FieldConfigEnum fieldConfigEnum = new FieldConfigEnum(commonData);
    List<SymbolTypeConfig> configList = new ArrayList<SymbolTypeConfig>();
    SymbolTypeConfig symbolTypeConfig = new SymbolTypeConfig(null);
    populateSymbolType(symbolTypeConfig);
    configList.add(symbolTypeConfig);
    fieldConfigEnum.addConfig(configList);
    return fieldConfigEnum;
}
Also used : FieldConfigEnum(com.sldeditor.ui.detail.config.FieldConfigEnum) ArrayList(java.util.ArrayList) SymbolTypeConfig(com.sldeditor.ui.detail.config.symboltype.SymbolTypeConfig)

Example 9 with FieldConfigEnum

use of com.sldeditor.ui.detail.config.FieldConfigEnum in project sldeditor by robward-scisys.

the class FieldConfigEnumTest method testSetVisible.

/**
 * Test method for {@link com.sldeditor.ui.detail.config.FieldConfigEnum#setVisible(boolean)}.
 */
@Test
public void testSetVisible() {
    boolean valueOnly = true;
    FieldConfigEnum field = new FieldConfigEnum(new FieldConfigCommonData(Integer.class, FieldIdEnum.NAME, "label", valueOnly));
    boolean expectedValue = true;
    field.setVisible(expectedValue);
    field.createUI();
    field.setVisible(expectedValue);
    expectedValue = false;
    field.setVisible(expectedValue);
}
Also used : FieldConfigEnum(com.sldeditor.ui.detail.config.FieldConfigEnum) FieldConfigCommonData(com.sldeditor.ui.detail.config.FieldConfigCommonData) Test(org.junit.Test)

Example 10 with FieldConfigEnum

use of com.sldeditor.ui.detail.config.FieldConfigEnum in project sldeditor by robward-scisys.

the class FieldConfigEnumTest method testGenerateExpression.

/**
 * Test method for {@link com.sldeditor.ui.detail.config.FieldConfigEnum#generateExpression()}.
 * Test method for
 * {@link com.sldeditor.ui.detail.config.FieldConfigEnum#populateExpression(java.lang.Object, org.opengis.filter.expression.Expression)}.
 * Test method for
 * {@link com.sldeditor.ui.detail.config.FieldConfigEnum#populateField(java.lang.String)}. Test
 * method for
 * {@link com.sldeditor.ui.detail.config.FieldConfigEnum#setTestValue(com.sldeditor.ui.detail.config.FieldId, java.lang.String)}.
 * Test method for {@link com.sldeditor.ui.detail.config.FieldConfigEnum#getEnumValue()}. Test
 * method for {@link com.sldeditor.ui.detail.config.FieldConfigEnum#getStringValue()}.
 */
@Test
public void testGenerateExpression() {
    SymbolTypeConfig s1 = new SymbolTypeConfig(null);
    s1.addOption("key1", "Value 1");
    s1.addOption("key2", "Value 2");
    s1.addOption("key3", "Value 3");
    s1.addField(FieldIdEnum.ANCHOR_POINT_H, true);
    s1.addField(FieldIdEnum.ANCHOR_POINT_V, false);
    List<SymbolTypeConfig> configList = new ArrayList<SymbolTypeConfig>();
    configList.add(s1);
    SymbolTypeConfig s2 = new SymbolTypeConfig(null);
    s2.addOption("key4", "Value 4");
    s2.addOption("key5", "Value 5");
    s2.addOption("key6", "Value 6");
    s2.addField(FieldIdEnum.ANGLE, true);
    s2.addField(FieldIdEnum.DESCRIPTION, false);
    configList.add(s2);
    boolean valueOnly = true;
    FieldConfigEnum field = new FieldConfigEnum(new FieldConfigCommonData(Integer.class, FieldIdEnum.NAME, "label", valueOnly));
    field.undoAction(null);
    field.redoAction(null);
    field.addConfig(null);
    assertNull(field.getStringValue());
    field.addConfig(configList);
    // Try without creating the ui
    field.populateExpression(null);
    field.populateField((String) null);
    field.setTestValue(null, (String) null);
    // Now create the ui
    field.createUI();
    field.createUI();
    String expectedValue1 = "key2";
    field.populateField(expectedValue1);
    String actualValueString = field.getStringValue();
    assertTrue(expectedValue1.compareTo(actualValueString) == 0);
    ValueComboBoxData actualValue = field.getEnumValue();
    assertTrue(expectedValue1.compareTo(actualValue.getKey()) == 0);
    // Try valid/invalid option values
    assertTrue(field.isValidOption("key1"));
    assertTrue(field.isValidOption("key4"));
    assertFalse(field.isValidOption("key24"));
    assertFalse(field.isValidOption(null));
}
Also used : FieldConfigEnum(com.sldeditor.ui.detail.config.FieldConfigEnum) ArrayList(java.util.ArrayList) FieldConfigCommonData(com.sldeditor.ui.detail.config.FieldConfigCommonData) SymbolTypeConfig(com.sldeditor.ui.detail.config.symboltype.SymbolTypeConfig) ValueComboBoxData(com.sldeditor.ui.widgets.ValueComboBoxData) Test(org.junit.Test)

Aggregations

FieldConfigEnum (com.sldeditor.ui.detail.config.FieldConfigEnum)14 FieldConfigCommonData (com.sldeditor.ui.detail.config.FieldConfigCommonData)9 Test (org.junit.Test)9 SymbolTypeConfig (com.sldeditor.ui.detail.config.symboltype.SymbolTypeConfig)6 ArrayList (java.util.ArrayList)6 FieldIdEnum (com.sldeditor.common.xml.ui.FieldIdEnum)4 FieldConfigBase (com.sldeditor.ui.detail.config.FieldConfigBase)4 ValueComboBoxData (com.sldeditor.ui.widgets.ValueComboBoxData)2 UndoEvent (com.sldeditor.common.undo.UndoEvent)1 GraphicPanelFieldManager (com.sldeditor.ui.detail.GraphicPanelFieldManager)1 FieldConfigBoolean (com.sldeditor.ui.detail.config.FieldConfigBoolean)1 FieldConfigDouble (com.sldeditor.ui.detail.config.FieldConfigDouble)1 FieldConfigInteger (com.sldeditor.ui.detail.config.FieldConfigInteger)1 FieldConfigPopulation (com.sldeditor.ui.detail.config.FieldConfigPopulation)1 FieldConfigString (com.sldeditor.ui.detail.config.FieldConfigString)1 GroupConfigInterface (com.sldeditor.ui.detail.config.base.GroupConfigInterface)1 Geometry (com.vividsolutions.jts.geom.Geometry)1