use of com.sldeditor.ui.detail.GraphicPanelFieldManager in project sldeditor by robward-scisys.
the class GraphicPanelFieldManagerTest method testRemoveField.
/**
* Test method for {@link com.sldeditor.ui.detail.GraphicPanelFieldManager#removeField(com.sldeditor.ui.detail.config.FieldConfigBase)}.
*/
@Test
public void testRemoveField() {
Class<?> expectedPanelId = StrokeDetails.class;
GraphicPanelFieldManager mgr = new GraphicPanelFieldManager(expectedPanelId);
FieldIdEnum expectedFieldId = FieldIdEnum.NAME;
FieldConfigString stringField = new FieldConfigString(new FieldConfigCommonData(String.class, expectedFieldId, "test label", false), "button text");
mgr.removeField(null);
// Does n't exists yet
mgr.removeField(stringField);
mgr.addField(stringField);
FieldIdEnum actualFieldId = mgr.getFieldEnum(expectedPanelId, stringField);
assertEquals(stringField, mgr.getData(expectedPanelId, actualFieldId));
mgr.removeField(stringField);
actualFieldId = mgr.getFieldEnum(expectedPanelId, stringField);
assertEquals(FieldIdEnum.UNKNOWN, actualFieldId);
}
use of com.sldeditor.ui.detail.GraphicPanelFieldManager in project sldeditor by robward-scisys.
the class GraphicPanelFieldManagerTest method testAddMultiOptionGroup.
/**
* Test method for {@link com.sldeditor.ui.detail.GraphicPanelFieldManager#addMultiOptionGroup(com.sldeditor.ui.detail.config.base.MultiOptionGroup)}.
* Test method for {@link com.sldeditor.ui.detail.GraphicPanelFieldManager#getMultiOptionGroup(java.lang.Class, com.sldeditor.common.xml.ui.GroupIdEnum)}.
*/
@Test
public void testAddMultiOptionGroup() {
Class<?> expectedPanelId = StrokeDetails.class;
GraphicPanelFieldManager mgr = new GraphicPanelFieldManager(expectedPanelId);
FieldIdEnum expectedFieldId = FieldIdEnum.NAME;
FieldConfigString stringField = new FieldConfigString(new FieldConfigCommonData(String.class, expectedFieldId, "test label", false), "button text");
mgr.addField(stringField);
MultiOptionGroup multiOption = new MultiOptionGroup();
GroupIdEnum expectedGroupId = GroupIdEnum.FILLSYMBOL;
multiOption.setId(expectedGroupId);
mgr.addMultiOptionGroup(multiOption);
MultiOptionGroup actualValue = mgr.getMultiOptionGroup(null, null);
assertNull(actualValue);
actualValue = mgr.getMultiOptionGroup(expectedPanelId, expectedGroupId);
assertEquals(multiOption, actualValue);
}
use of com.sldeditor.ui.detail.GraphicPanelFieldManager in project sldeditor by robward-scisys.
the class GraphicPanelFieldManagerTest method testAddGraphicPanelFieldManager.
/**
* Test method for {@link com.sldeditor.ui.detail.GraphicPanelFieldManager#add(com.sldeditor.ui.detail.GraphicPanelFieldManager)}.
*/
@Test
public void testAddGraphicPanelFieldManager() {
// Set up manager 1
Class<?> expectedPanelId = StrokeDetails.class;
GraphicPanelFieldManager mgr1 = new GraphicPanelFieldManager(expectedPanelId);
FieldIdEnum expectedFieldId = FieldIdEnum.NAME;
FieldConfigString stringField = new FieldConfigString(new FieldConfigCommonData(String.class, expectedFieldId, "test label", false), "button text");
mgr1.addField(stringField);
assertTrue(mgr1.getFields(FieldConfigBoolean.class).isEmpty());
assertEquals(1, mgr1.getFields(FieldConfigString.class).size());
// Set up manager 2
Class<?> expectedPanelId2 = PointFillDetails.class;
GraphicPanelFieldManager mgr2 = new GraphicPanelFieldManager(expectedPanelId2);
FieldIdEnum expectedFieldId2 = FieldIdEnum.ANGLE;
FieldConfigDouble doubleField = new FieldConfigDouble(new FieldConfigCommonData(Double.class, expectedFieldId2, "test label", false));
mgr2.addField(doubleField);
assertEquals(1, mgr2.getFields(FieldConfigDouble.class).size());
// Add manager 2 to manager 1
mgr1.add(mgr2);
FieldIdEnum actualFieldId = mgr1.getFieldEnum(expectedPanelId, stringField);
assertEquals(expectedFieldId, actualFieldId);
actualFieldId = mgr1.getFieldEnum(expectedPanelId2, doubleField);
assertEquals(expectedFieldId2, actualFieldId);
}
use of com.sldeditor.ui.detail.GraphicPanelFieldManager in project sldeditor by robward-scisys.
the class GraphicPanelFieldManagerTest method testGraphicPanelFieldManager.
/**
* Test method for {@link com.sldeditor.ui.detail.GraphicPanelFieldManager#GraphicPanelFieldManager(java.lang.Class)}.
* Test method for {@link com.sldeditor.ui.detail.GraphicPanelFieldManager#get(com.sldeditor.ui.detail.config.FieldId)}.
* Test method for {@link com.sldeditor.ui.detail.GraphicPanelFieldManager#get(com.sldeditor.common.xml.ui.FieldIdEnum)}.
* Test method for {@link com.sldeditor.ui.detail.GraphicPanelFieldManager#getFieldEnum(java.lang.Class, com.sldeditor.ui.detail.config.FieldConfigBase)}.
* Test method for {@link com.sldeditor.ui.detail.GraphicPanelFieldManager#getComponentId()}.
* Test method for {@link com.sldeditor.ui.detail.GraphicPanelFieldManager#addField(com.sldeditor.ui.detail.config.FieldConfigBase)}.
* Test method for {@link com.sldeditor.ui.detail.GraphicPanelFieldManager#add(com.sldeditor.ui.detail.config.FieldId, com.sldeditor.ui.detail.config.FieldConfigBase)}.
* Test method for {@link com.sldeditor.ui.detail.GraphicPanelFieldManager#getData(java.lang.Class, com.sldeditor.ui.detail.config.FieldId)}.
*/
@Test
public void testGraphicPanelFieldManager() {
// Try with a null panel id
GraphicPanelFieldManager mgr = new GraphicPanelFieldManager(null);
assertNull(mgr.get(FieldIdEnum.FILTER));
Class<?> expectedPanelId = StrokeDetails.class;
mgr = new GraphicPanelFieldManager(expectedPanelId);
assertEquals(FieldIdEnum.UNKNOWN, mgr.getFieldEnum(PointFillDetails.class, null));
assertEquals(expectedPanelId, mgr.getComponentId());
// Now try with a field
FieldIdEnum expectedFieldId = FieldIdEnum.NAME;
FieldConfigString stringField = new FieldConfigString(new FieldConfigCommonData(String.class, expectedFieldId, "test label", false), "button text");
mgr.addField(null);
mgr.addField(stringField);
FieldIdEnum actualFieldId = mgr.getFieldEnum(expectedPanelId, stringField);
assertEquals(expectedFieldId, actualFieldId);
assertNull(mgr.getData(null, null));
assertNull(mgr.getData(expectedPanelId, null));
assertEquals(stringField, mgr.getData(expectedPanelId, actualFieldId));
}
use of com.sldeditor.ui.detail.GraphicPanelFieldManager in project sldeditor by robward-scisys.
the class LineSymbolizerDetailsTest method testLineSymbolizerDetails.
/**
* Test method for {@link com.sldeditor.ui.detail.LineSymbolizerDetails#LineSymbolizerDetails(com.sldeditor.filter.v2.function.FunctionNameInterface)}.
* Test method for {@link com.sldeditor.ui.detail.LineSymbolizerDetails#populate(com.sldeditor.common.data.SelectedSymbol)}.
* Test method for {@link com.sldeditor.ui.detail.LineSymbolizerDetails#dataChanged(com.sldeditor.ui.detail.config.FieldId)}.
* Test method for {@link com.sldeditor.ui.detail.LineSymbolizerDetails#getFieldDataManager()}.
* Test method for {@link com.sldeditor.ui.detail.LineSymbolizerDetails#isDataPresent()}.
* Test method for {@link com.sldeditor.ui.detail.LineSymbolizerDetails#preLoadSymbol()}.
*/
@Test
public void testLineSymbolizerDetails() {
LineSymbolizerDetails panel = new LineSymbolizerDetails();
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 expectedRuleValue = "rule test value";
rule.setName(expectedRuleValue);
LineSymbolizer symbolizer = DefaultSymbols.createDefaultLineSymbolizer();
String expectedNameValue = "symbolizer test value";
symbolizer.setName(expectedNameValue);
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);
SelectedSymbol.getInstance().setSymbolizer(symbolizer);
panel.populate(SelectedSymbol.getInstance());
GraphicPanelFieldManager fieldDataManager = panel.getFieldDataManager();
assertNotNull(fieldDataManager);
panel.dataChanged(null);
FieldConfigString nameField = (FieldConfigString) fieldDataManager.get(FieldIdEnum.NAME);
assertNull(nameField);
assertTrue(panel.isDataPresent());
// Reset to default value
panel.preLoadSymbol();
}
Aggregations