use of com.sldeditor.ui.detail.GraphicPanelFieldManager in project sldeditor by robward-scisys.
the class RuleDetailsTest method testRuleDetails.
/**
* Test method for {@link com.sldeditor.ui.detail.RuleDetails#RuleDetails(com.sldeditor.filter.v2.function.FunctionNameInterface)}.
* Test method for {@link com.sldeditor.ui.detail.RuleDetails#populate(com.sldeditor.common.data.SelectedSymbol)}.
* Test method for {@link com.sldeditor.ui.detail.RuleDetails#dataChanged(com.sldeditor.ui.detail.config.FieldId)}.
* Test method for {@link com.sldeditor.ui.detail.RuleDetails#getFieldDataManager()}.
* Test method for {@link com.sldeditor.ui.detail.RuleDetails#isDataPresent()}.
* Test method for {@link com.sldeditor.ui.detail.RuleDetails#preLoadSymbol()}.
*/
@Test
public void testRuleDetails() {
RuleDetails panel = new RuleDetails();
panel.populate(null);
// Set up test data
StyledLayerDescriptor sld = DefaultSymbols.createNewSLD();
SelectedSymbol.getInstance().createNewSLD(sld);
NamedLayer namedLayer = DefaultSymbols.createNewNamedLayer();
String expectedNameLayerValue = "named layer test value";
namedLayer.setName(expectedNameLayerValue);
Style style = DefaultSymbols.createNewStyle();
String expectedNameStyleValue = "style test value";
style.setName(expectedNameStyleValue);
namedLayer.addStyle(style);
FeatureTypeStyle fts = DefaultSymbols.createNewFeatureTypeStyle();
String expectedNameFTSValue = "feature type style test value";
fts.setName(expectedNameFTSValue);
style.featureTypeStyles().add(fts);
Rule rule = DefaultSymbols.createNewRule();
String expectedNameValue = "rule test value";
rule.setName(expectedNameValue);
Symbolizer symbolizer = DefaultSymbols.createDefaultPolygonSymbolizer();
rule.symbolizers().add(symbolizer);
fts.rules().add(rule);
sld.layers().add(namedLayer);
SelectedSymbol.getInstance().addNewStyledLayer(namedLayer);
SelectedSymbol.getInstance().setStyledLayer(namedLayer);
SelectedSymbol.getInstance().setStyle(style);
SelectedSymbol.getInstance().setFeatureTypeStyle(fts);
SelectedSymbol.getInstance().setRule(rule);
panel.populate(SelectedSymbol.getInstance());
GraphicPanelFieldManager fieldDataManager = panel.getFieldDataManager();
assertNotNull(fieldDataManager);
FieldConfigString filterField = (FieldConfigString) fieldDataManager.get(FieldIdEnum.FILTER);
String filterString = "STATE_ABBR >= 'B' AND STATE_ABBR <= 'O'";
filterField.populateField(filterString);
panel.dataChanged(null);
FieldConfigString nameField = (FieldConfigString) fieldDataManager.get(FieldIdEnum.NAME);
String actualValue = nameField.getStringValue();
assertTrue(expectedNameValue.compareTo(actualValue) == 0);
assertTrue(panel.isDataPresent());
// Reset to default value
panel.preLoadSymbol();
actualValue = nameField.getStringValue();
assertTrue("".compareTo(actualValue) == 0);
}
use of com.sldeditor.ui.detail.GraphicPanelFieldManager in project sldeditor by robward-scisys.
the class FieldConfigPopulationTest method testExpression.
/**
* Test method for
* {@link com.sldeditor.ui.detail.config.FieldConfigPopulation#populateField(com.sldeditor.ui.detail.config.FieldId, org.opengis.filter.expression.Expression)}.
* Test method for
* {@link com.sldeditor.ui.detail.config.FieldConfigPopulation#populateField(com.sldeditor.common.xml.ui.FieldIdEnum, org.opengis.filter.expression.Expression)}.
* Test method for
* {@link com.sldeditor.ui.detail.config.FieldConfigPopulation#getExpression(com.sldeditor.ui.detail.config.FieldId)}.
* Test method for
* {@link com.sldeditor.ui.detail.config.FieldConfigPopulation#getExpression(com.sldeditor.common.xml.ui.FieldIdEnum)}.
*/
@Test
public void testExpression() {
FieldIdEnum fieldId = FieldIdEnum.DESCRIPTION;
GraphicPanelFieldManager fieldConfigManager = new GraphicPanelFieldManager(String.class);
FieldConfigInteger intField = new FieldConfigInteger(new FieldConfigCommonData(Geometry.class, fieldId, "label", true));
intField.createUI();
fieldConfigManager.add(fieldId, intField);
FieldConfigPopulation obj = new FieldConfigPopulation(fieldConfigManager);
int expectedValue = 1256;
StyleBuilder styleBuilder = new StyleBuilder();
Expression expression = styleBuilder.literalExpression(expectedValue);
obj.populateField(fieldId, expression);
LiteralExpressionImpl actualValue = (LiteralExpressionImpl) obj.getExpression(fieldId);
assertEquals(expectedValue, ((Integer) actualValue.getValue()).intValue());
actualValue = (LiteralExpressionImpl) obj.getExpression(fieldId);
assertEquals(expectedValue, ((Integer) actualValue.getValue()).intValue());
// This shouldn't work as it does not know about the field
FieldIdEnum wrongFieldEnum = FieldIdEnum.ELSE_FILTER;
obj.populateField(wrongFieldEnum, expression);
assertNull(obj.getExpression(wrongFieldEnum));
// Try with null
obj.populateField(fieldId, null);
}
use of com.sldeditor.ui.detail.GraphicPanelFieldManager in project sldeditor by robward-scisys.
the class FieldConfigPopulationTest method testBoolean.
/**
* Test method for
* {@link com.sldeditor.ui.detail.config.FieldConfigPopulation#populateBooleanField(com.sldeditor.ui.detail.config.FieldId, java.lang.Boolean)}.
* Test method for
* {@link com.sldeditor.ui.detail.config.FieldConfigPopulation#populateBooleanField(com.sldeditor.common.xml.ui.FieldIdEnum, java.lang.Boolean)}.
* Test method for
* {@link com.sldeditor.ui.detail.config.FieldConfigPopulation#getBoolean(com.sldeditor.ui.detail.config.FieldId)}.
* Test method for
* {@link com.sldeditor.ui.detail.config.FieldConfigPopulation#getBoolean(com.sldeditor.common.xml.ui.FieldIdEnum)}.
*/
@Test
public void testBoolean() {
FieldIdEnum fieldId = FieldIdEnum.DESCRIPTION;
GraphicPanelFieldManager fieldConfigManager = new GraphicPanelFieldManager(String.class);
FieldConfigBoolean booleanField = new FieldConfigBoolean(new FieldConfigCommonData(Geometry.class, fieldId, "label", true));
booleanField.createUI();
fieldConfigManager.add(fieldId, booleanField);
FieldConfigPopulation obj = new FieldConfigPopulation(fieldConfigManager);
Boolean expectedValue = Boolean.TRUE;
obj.populateBooleanField(fieldId, expectedValue);
assertEquals(expectedValue.booleanValue(), obj.getBoolean(fieldId));
// This shouldn't work as it does not know about the field
FieldIdEnum wrongFieldEnum = FieldIdEnum.ELSE_FILTER;
assertFalse(obj.getBoolean(wrongFieldEnum));
// Try with null - should revert to default value (false)
obj.populateBooleanField(fieldId, null);
assertFalse(obj.getBoolean(fieldId));
}
use of com.sldeditor.ui.detail.GraphicPanelFieldManager in project sldeditor by robward-scisys.
the class FieldConfigPopulationTest method testComboBox.
/**
* Test method for
* {@link com.sldeditor.ui.detail.config.FieldConfigPopulation#populateComboBoxField(com.sldeditor.ui.detail.config.FieldId, java.lang.String)}.
* Test method for
* {@link com.sldeditor.ui.detail.config.FieldConfigPopulation#populateComboBoxField(com.sldeditor.common.xml.ui.FieldIdEnum, java.lang.String)}.
* Test method for
* {@link com.sldeditor.ui.detail.config.FieldConfigPopulation#getComboBox(com.sldeditor.common.xml.ui.FieldIdEnum)}.
* Test method for
* {@link com.sldeditor.ui.detail.config.FieldConfigPopulation#getComboBox(com.sldeditor.ui.detail.config.FieldId)}.
*/
@Test
public void testComboBox() {
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);
FieldIdEnum fieldId = FieldIdEnum.DESCRIPTION;
List<SymbolTypeConfig> configList = new ArrayList<SymbolTypeConfig>();
configList.add(s1);
FieldConfigEnum enumField = new FieldConfigEnum(new FieldConfigCommonData(Geometry.class, fieldId, "label", true));
enumField.addConfig(configList);
enumField.createUI();
GraphicPanelFieldManager fieldConfigManager = new GraphicPanelFieldManager(String.class);
fieldConfigManager.add(fieldId, enumField);
FieldConfigPopulation obj = new FieldConfigPopulation(fieldConfigManager);
String expectedValue = "key2";
obj.populateComboBoxField(fieldId, expectedValue);
assertTrue(expectedValue.compareTo(obj.getComboBox(fieldId).getKey()) == 0);
// This shouldn't work as it does not know about the field
FieldIdEnum wrongFieldEnum = FieldIdEnum.ELSE_FILTER;
assertNull(obj.getComboBox(wrongFieldEnum));
// Try with null - should revert to default value (first enum item)
obj.populateComboBoxField(fieldId, null);
expectedValue = "key1";
assertTrue(expectedValue.compareTo(obj.getComboBox(fieldId).getKey()) == 0);
}
use of com.sldeditor.ui.detail.GraphicPanelFieldManager in project sldeditor by robward-scisys.
the class FieldConfigPopulationTest method testGetFieldConfig.
/**
* Test method for
* {@link com.sldeditor.ui.detail.config.FieldConfigPopulation#getFieldConfig(com.sldeditor.ui.detail.config.FieldId)}.
*/
@Test
public void testGetFieldConfig() {
FieldIdEnum fieldId = FieldIdEnum.DESCRIPTION;
GraphicPanelFieldManager fieldConfigManager = new GraphicPanelFieldManager(String.class);
FieldConfigInteger intField = new FieldConfigInteger(new FieldConfigCommonData(Geometry.class, fieldId, "label", true));
intField.createUI();
fieldConfigManager.add(fieldId, intField);
FieldConfigPopulation obj = new FieldConfigPopulation(fieldConfigManager);
assertNotNull(obj.getFieldConfig(fieldId));
FieldIdEnum wrongFieldEnum = FieldIdEnum.ELSE_FILTER;
assertNull(obj.getFieldConfig(wrongFieldEnum));
}
Aggregations