use of com.sldeditor.common.xml.ui.FieldIdEnum in project sldeditor by robward-scisys.
the class FieldConfigBaseTest method testGetCustomPanels.
/**
* Test method for
* {@link com.sldeditor.ui.detail.config.FieldConfigBase#addCustomPanel(javax.swing.JPanel)}.
* Test method for {@link com.sldeditor.ui.detail.config.FieldConfigBase#getCustomPanels()}.
*/
@Test
public void testGetCustomPanels() {
boolean valueOnly = true;
FieldIdEnum expectedFieldId = FieldIdEnum.NAME;
String expectedLabel = "test label";
TestFieldConfigBase field = new TestFieldConfigBase(new FieldConfigCommonData(String.class, expectedFieldId, expectedLabel, valueOnly));
assertNull(field.getCustomPanels());
JPanel expectedPanel = new JPanel();
field.testAddCustomPanel(expectedPanel);
List<Component> customPanelList = field.getCustomPanels();
assertEquals(1, customPanelList.size());
assertEquals(expectedPanel, customPanelList.get(0));
}
use of com.sldeditor.common.xml.ui.FieldIdEnum in project sldeditor by robward-scisys.
the class FieldConfigBaseTest method testDuplicate.
/**
* Test method for {@link com.sldeditor.ui.detail.config.FieldConfigBase#duplicate()}.
*/
@Test
public void testDuplicate() {
FieldIdEnum expectedFieldId = FieldIdEnum.NAME;
String expectedLabel = "test label";
TestFieldConfigBase field = new TestFieldConfigBase(new FieldConfigCommonData(String.class, expectedFieldId, expectedLabel, false));
TestUpdateSymbolInterface listener = new TestUpdateSymbolInterface();
field.addDataChangedListener(listener);
FieldConfigString copy = (FieldConfigString) field.duplicate();
assertNotNull(copy);
}
use of com.sldeditor.common.xml.ui.FieldIdEnum in project sldeditor by robward-scisys.
the class FieldConfigBaseTest method testSetValueFieldState.
/**
* Test method for {@link com.sldeditor.ui.detail.config.FieldConfigBase#setValueFieldState()}.
*/
@Test
public void testSetValueFieldState() {
boolean valueOnly = true;
FieldIdEnum expectedFieldId = FieldIdEnum.NAME;
String expectedLabel = "test label";
TestFieldConfigBase field = new TestFieldConfigBase(new FieldConfigCommonData(String.class, expectedFieldId, expectedLabel, valueOnly));
AttributeSelection attributeSelectionPanel = AttributeSelection.createAttributes(String.class, field, false);
attributeSelectionPanel.setEnabled(true);
field.testAttributeSelectionPanel(attributeSelectionPanel);
field.testSetValueFieldState();
assertFalse(field.isEnabled());
assertTrue(field.getAttributeSelectionPanel().isEnabled());
boolean fieldEnabledFlag = false;
field.testSetValueFieldState();
assertEquals(fieldEnabledFlag, field.isEnabled());
field.attributeUpdated("");
assertEquals(fieldEnabledFlag, field.isEnabled());
}
use of com.sldeditor.common.xml.ui.FieldIdEnum in project sldeditor by robward-scisys.
the class FieldConfigBaseTest method testFireExpressionUpdated.
/**
* Test method for
* {@link com.sldeditor.ui.detail.config.FieldConfigBase#setExpressionUpdateListener(com.sldeditor.ui.iface.ExpressionUpdateInterface)}.
* Test method for
* {@link com.sldeditor.ui.detail.config.FieldConfigBase#fireExpressionUpdated(org.opengis.filter.expression.Expression)}.
*/
@Test
public void testFireExpressionUpdated() {
FieldIdEnum expectedFieldId = FieldIdEnum.NAME;
String expectedLabel = "test label";
TestFieldConfigBase field = new TestFieldConfigBase(new FieldConfigCommonData(String.class, expectedFieldId, expectedLabel, false));
TestExpressionUpdateInterface testExpressionUpdate = new TestExpressionUpdateInterface();
field.setExpressionUpdateListener(null);
field.testFireExpressionUpdated(null);
field.setExpressionUpdateListener(testExpressionUpdate);
field.testFireExpressionUpdated(null);
assertTrue(testExpressionUpdate.hasExpressionBeenCalled());
}
use of com.sldeditor.common.xml.ui.FieldIdEnum in project sldeditor by robward-scisys.
the class FieldConfigBaseTest method testFunctionUpdated.
/**
* Test method for
* {@link com.sldeditor.ui.detail.config.FieldConfigBase#functionUpdated(org.opengis.filter.expression.Expression)}.
*/
@Test
public void testFunctionUpdated() {
FieldIdEnum expectedFieldId = FieldIdEnum.NAME;
String expectedLabel = "test label";
TestFieldConfigBase field = new TestFieldConfigBase(new FieldConfigCommonData(String.class, expectedFieldId, expectedLabel, false));
TestUpdateSymbolInterface listener = new TestUpdateSymbolInterface();
field.addDataChangedListener(listener);
assertFalse(listener.hasBeenCalled());
FilterFactory ff = CommonFactoryFinder.getFilterFactory();
DefaultFunctionFactory functionFactory = new DefaultFunctionFactory();
FunctionName functionName = null;
for (FunctionName func : functionFactory.getFunctionNames()) {
if (func.getName() == "greaterThan") {
functionName = func;
break;
}
}
assertNotNull(functionName);
Expression testExpression = ff.function(functionName.getFunctionName(), ff.literal(1), ff.literal(2));
field.functionUpdated(testExpression);
assertTrue(listener.hasBeenCalled());
assertEquals(ExpressionTypeEnum.E_FUNCTION, field.getExpressionType());
Expression expression = field.getExpression();
assertTrue(expression.toString().startsWith(functionName.getName()));
}
Aggregations