use of com.sldeditor.ui.detail.config.FieldConfigString in project sldeditor by robward-scisys.
the class FieldConfigStringTest method testSetEnabled.
/**
* Test method for
* {@link com.sldeditor.ui.detail.config.FieldConfigString#internal_setEnabled(boolean)}. Test
* method for {@link com.sldeditor.ui.detail.config.FieldConfigString#isEnabled()}. Test method
* for {@link com.sldeditor.ui.detail.config.FieldConfigString#createUI(javax.swing.Box)}.
*/
@Test
public void testSetEnabled() {
// Value only, no attribute/expression dropdown
boolean valueOnly = true;
FieldConfigString field = new FieldConfigString(new FieldConfigCommonData(String.class, FieldIdEnum.NAME, "test label", valueOnly), "button text");
// Text field will not have been created
boolean expectedValue = true;
field.internal_setEnabled(expectedValue);
assertFalse(field.isEnabled());
// Create text field
field.createUI();
assertEquals(expectedValue, field.isEnabled());
expectedValue = false;
field.internal_setEnabled(expectedValue);
assertEquals(expectedValue, field.isEnabled());
// Has attribute/expression dropdown
valueOnly = false;
FieldConfigString field2 = new FieldConfigString(new FieldConfigCommonData(String.class, FieldIdEnum.NAME, "test label", valueOnly), "button text");
// Text field will not have been created
expectedValue = true;
field2.internal_setEnabled(expectedValue);
assertFalse(field2.isEnabled());
// Create text field
field2.createUI();
assertEquals(expectedValue, field2.isEnabled());
expectedValue = false;
field2.internal_setEnabled(expectedValue);
// Actual value is coming from the attribute panel, not the text field
assertEquals(!expectedValue, field2.isEnabled());
}
use of com.sldeditor.ui.detail.config.FieldConfigString in project sldeditor by robward-scisys.
the class FieldConfigStringTest method testSetVisible.
/**
* Test method for {@link com.sldeditor.ui.detail.config.FieldConfigString#setVisible(boolean)}.
*/
@Test
public void testSetVisible() {
boolean valueOnly = true;
FieldConfigString field = new FieldConfigString(new FieldConfigCommonData(String.class, FieldIdEnum.NAME, "test label", valueOnly), "button text");
boolean expectedValue = true;
field.setVisible(expectedValue);
expectedValue = false;
field.setVisible(expectedValue);
}
use of com.sldeditor.ui.detail.config.FieldConfigString in project sldeditor by robward-scisys.
the class UserLayerDetailsTest method testUserLayerDetails.
/**
* Test method for {@link com.sldeditor.ui.detail.UserLayerDetails#UserLayerDetails(com.sldeditor.filter.v2.function.FunctionNameInterface)}.
* Test method for {@link com.sldeditor.ui.detail.UserLayerDetails#populate(com.sldeditor.common.data.SelectedSymbol)}.
* Test method for {@link com.sldeditor.ui.detail.UserLayerDetails#dataChanged(com.sldeditor.ui.detail.config.FieldId)}.
* Test method for {@link com.sldeditor.ui.detail.UserLayerDetails#getFieldDataManager()}.
* Test method for {@link com.sldeditor.ui.detail.UserLayerDetails#isDataPresent()}.
* Test method for {@link com.sldeditor.ui.detail.UserLayerDetails#preLoadSymbol()}.
*/
@Test
public void testUserLayerDetails() {
UserLayerDetails panel = new UserLayerDetails();
panel.populate(null);
// Set up test data
StyledLayerDescriptor sld = DefaultSymbols.createNewSLD();
SelectedSymbol.getInstance().createNewSLD(sld);
UserLayer userLayer = DefaultSymbols.createNewUserLayer();
String expectedUserValue = "user layer test value";
userLayer.setName(expectedUserValue);
userLayer.addUserStyle(DefaultSymbols.createNewStyle());
sld.layers().add(userLayer);
SelectedSymbol.getInstance().addNewStyledLayer(userLayer);
SelectedSymbol.getInstance().setStyledLayer(userLayer);
panel.populate(SelectedSymbol.getInstance());
panel.dataChanged(null);
GraphicPanelFieldManager fieldDataManager = panel.getFieldDataManager();
assertNotNull(fieldDataManager);
panel.dataChanged(FieldIdEnum.INLINE_FEATURE);
FieldConfigString nameField = (FieldConfigString) fieldDataManager.get(FieldIdEnum.NAME);
assertTrue(expectedUserValue.compareTo(nameField.getStringValue()) == 0);
assertTrue(panel.isDataPresent());
// Reset to default value
panel.preLoadSymbol();
assertTrue("".compareTo(nameField.getStringValue()) == 0);
}
use of com.sldeditor.ui.detail.config.FieldConfigString in project sldeditor by robward-scisys.
the class RuleDetails method getMinimumValue.
/**
* Gets the minimum value.
*
* @param field the field
* @return the minimum value
*/
private static double getMinimumValue(FieldConfigBase field) {
double value = 0.0;
if (field.isEnabled()) {
FieldConfigString textFieldConfig = (FieldConfigString) field;
value = ScaleUtil.extractValue(textFieldConfig.getStringValue());
}
return value;
}
use of com.sldeditor.ui.detail.config.FieldConfigString in project sldeditor by robward-scisys.
the class FeatureTypeStyleDetailsTest method testFeatureTypeStyleDetails.
/**
* Test method for {@link com.sldeditor.ui.detail.FeatureTypeStyleDetails#FeatureTypeStyleDetails(com.sldeditor.filter.v2.function.FunctionNameInterface)}.
* Test method for {@link com.sldeditor.ui.detail.FeatureTypeStyleDetails#populate(com.sldeditor.common.data.SelectedSymbol)}.
* Test method for {@link com.sldeditor.ui.detail.FeatureTypeStyleDetails#dataChanged(com.sldeditor.ui.detail.config.FieldId)}.
* Test method for {@link com.sldeditor.ui.detail.FeatureTypeStyleDetails#getFieldDataManager()}.
* Test method for {@link com.sldeditor.ui.detail.FeatureTypeStyleDetails#isDataPresent()}.
* Test method for {@link com.sldeditor.ui.detail.FeatureTypeStyleDetails#preLoadSymbol()}.
*/
@Test
public void testFeatureTypeStyleDetails() {
FeatureTypeStyleDetails panel = new FeatureTypeStyleDetails();
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 expectedNameValue = "feature type style test value";
fts.setName(expectedNameValue);
style.featureTypeStyles().add(fts);
Rule rule = DefaultSymbols.createNewRule();
String expectedRuleNameValue = "rule test value";
rule.setName(expectedRuleNameValue);
fts.rules().add(rule);
sld.layers().add(namedLayer);
SelectedSymbol.getInstance().addNewStyledLayer(namedLayer);
SelectedSymbol.getInstance().setStyledLayer(namedLayer);
SelectedSymbol.getInstance().setStyle(style);
SelectedSymbol.getInstance().setFeatureTypeStyle(fts);
panel.populate(SelectedSymbol.getInstance());
panel.dataChanged(null);
GraphicPanelFieldManager fieldDataManager = panel.getFieldDataManager();
assertNotNull(fieldDataManager);
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);
}
Aggregations