use of com.sldeditor.ui.attribute.AttributeSelection 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.ui.attribute.AttributeSelection in project sldeditor by robward-scisys.
the class FieldPanel method internalCreateAttrButton.
/**
* Internal create attribute button.
*
* @param classType the class type
* @param field the field
* @param rasterSymbol the raster symbol
* @return the attribute selection
*/
public AttributeSelection internalCreateAttrButton(Class<?> classType, FieldConfigBase field, boolean rasterSymbol) {
AttributeSelection buttonAttrLabel = AttributeSelection.createAttributes(classType, field, rasterSymbol);
buttonAttrLabel.setBounds(xPos + BasePanel.ATTRIBUTE_BTN_X, 0, AttributeSelection.getPanelWidth(), BasePanel.WIDGET_HEIGHT);
add(buttonAttrLabel);
return buttonAttrLabel;
}
use of com.sldeditor.ui.attribute.AttributeSelection in project sldeditor by robward-scisys.
the class FieldConfigBaseTest method testPopulateExpressionExpression.
/**
* Test method for
* {@link com.sldeditor.ui.detail.config.FieldConfigBase#populate(org.opengis.filter.expression.Expression)}.
* Test method for
* {@link com.sldeditor.ui.detail.config.FieldConfigBase#populate(org.opengis.filter.expression.Expression, org.opengis.filter.expression.Expression)}.
*/
@Test
public void testPopulateExpressionExpression() {
FieldIdEnum expectedFieldId = FieldIdEnum.NAME;
String expectedLabel = "test label";
TestFieldConfigBase field = new TestFieldConfigBase(new FieldConfigCommonData(String.class, expectedFieldId, expectedLabel, false));
AttributeSelection attributeSelectionPanel = AttributeSelection.createAttributes(String.class, field, false);
field.testAttributeSelectionPanel(attributeSelectionPanel);
TestUpdateSymbolInterface listener = new TestUpdateSymbolInterface();
field.addDataChangedListener(listener);
assertFalse(listener.hasBeenCalled());
FilterFactory ff = CommonFactoryFinder.getFilterFactory();
// Test function
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.populate(testExpression);
// Updated because the attribute pulldown changed
assertTrue(listener.hasBeenCalled());
assertEquals(ExpressionTypeEnum.E_EXPRESSION, field.getExpressionType());
Expression expression = field.getExpression();
assertTrue(expression.toString().startsWith(functionName.getName()));
// Attribute expression wrapped in a literal expression
String testAttributeName = "test attribute";
NameImpl name = new NameImpl(testAttributeName);
AttributeExpressionImpl attributeExpression = new AttributeExpressionImpl(name);
Expression literalExpression = ff.literal(attributeExpression);
field.populate(literalExpression);
assertEquals(ExpressionTypeEnum.E_ATTRIBUTE, field.getExpressionType());
// Process Function
// ProcessFunctionFactory factory = new ProcessFunctionFactory();
// FunctionTableModel functionParameterTableModel = new FunctionTableModel();
// ProcessFunction processFunction = functionParameterTableModel.getExpression(factory);
// field.populate(processFunction);
// assertEquals(ExpressionTypeEnum.E_VALUE, field.getExpressionType());
}
Aggregations