use of com.sldeditor.ui.detail.config.FieldConfigInteger in project sldeditor by robward-scisys.
the class FieldConfigIntegerTest method testSetEnabled.
/**
* Test method for
* {@link com.sldeditor.ui.detail.config.FieldConfigInteger#internal_setEnabled(boolean)}. Test
* method for {@link com.sldeditor.ui.detail.config.FieldConfigInteger#isEnabled()}. Test method
* for {@link com.sldeditor.ui.detail.config.FieldConfigInteger#createUI(javax.swing.Box)}.
*/
@Test
public void testSetEnabled() {
// Value only, no attribute/expression dropdown
boolean valueOnly = true;
FieldConfigInteger field = new FieldConfigInteger(new FieldConfigCommonData(Integer.class, FieldIdEnum.NAME, "label", valueOnly));
// 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;
FieldConfigInteger field2 = new FieldConfigInteger(new FieldConfigCommonData(Integer.class, FieldIdEnum.NAME, "label", valueOnly));
// 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.FieldConfigInteger 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.config.FieldConfigInteger 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));
}
use of com.sldeditor.ui.detail.config.FieldConfigInteger in project sldeditor by robward-scisys.
the class ColourRampPanel method createFieldPanel.
/**
* Creates the field panel.
*/
private void createFieldPanel() {
JPanel tablePanel = new JPanel();
tablePanel.setLayout(new BorderLayout());
panel.add(tablePanel, BorderLayout.CENTER);
JPanel dataPanel = new JPanel();
tablePanel.add(dataPanel, BorderLayout.NORTH);
dataPanel.setLayout(new BoxLayout(dataPanel, BoxLayout.Y_AXIS));
minValueSpinner = new FieldConfigInteger(new FieldConfigCommonData(getClass(), FieldIdEnum.UNKNOWN, Localisation.getField(ColourRampConfigPanel.class, "ColourRampPanel.minValue"), true));
minValueSpinner.createUI();
FieldPanel fieldPanel = minValueSpinner.getPanel();
dataPanel.add(fieldPanel);
JButton resetValueButton = new JButton(Localisation.getString(ColourRampConfigPanel.class, "ColourRampPanel.reset"));
minValueSpinner.addUI(resetValueButton, 20, BasePanel.WIDGET_BUTTON_WIDTH, BasePanel.WIDGET_HEIGHT);
minValueSpinner.populateField(0);
resetValueButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
if (parentObj != null) {
ColourMapModel model = parentObj.getColourMapModel();
populate(model.getColourMap());
}
}
});
maxValueSpinner = new FieldConfigInteger(new FieldConfigCommonData(getClass(), FieldIdEnum.UNKNOWN, Localisation.getField(ColourRampConfigPanel.class, "ColourRampPanel.maxValue"), true));
maxValueSpinner.createUI();
maxValueSpinner.populateField(100);
dataPanel.add(maxValueSpinner.getPanel());
JPanel buttonPanel = new JPanel();
buttonPanel.setLayout(new FlowLayout(FlowLayout.CENTER));
buttonPanel.setSize(BasePanel.FIELD_PANEL_WIDTH, BasePanel.WIDGET_HEIGHT);
JButton applyButton = new JButton(Localisation.getString(ColourRampConfigPanel.class, "common.apply"));
applyButton.setPreferredSize(new Dimension(BasePanel.WIDGET_BUTTON_WIDTH, BasePanel.WIDGET_HEIGHT));
applyButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
if (parentObj != null) {
ColourRampData data = new ColourRampData();
data.setMaxValue(maxValueSpinner.getIntValue());
data.setMinValue(minValueSpinner.getIntValue());
data.setReverseColours(reverseCheckbox.isSelected());
ValueComboBoxData selectedItem = (ValueComboBoxData) rampComboBox.getSelectedItem();
ColourRamp colourRamp = colourRampCache.get(selectedItem.getKey());
data.setColourRamp(colourRamp);
parentObj.colourRampUpdate(data);
}
}
});
buttonPanel.add(applyButton);
dataPanel.add(buttonPanel);
}
use of com.sldeditor.ui.detail.config.FieldConfigInteger in project sldeditor by robward-scisys.
the class FontSizePanel method createUI.
/**
* Creates the UI.
*/
private void createUI() {
setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
value = new FieldConfigInteger(new FieldConfigCommonData(getClass(), FieldIdEnum.FONT_SIZE, Localisation.getField(BatchUpdateFontPanel.class, "BatchUpdateFontPanel.fontSize"), true, false, false));
value.createUI();
value.addDataChangedListener(this);
add(value.getPanel());
populate(null);
}
Aggregations