use of com.sldeditor.common.undo.UndoEvent in project sldeditor by robward-scisys.
the class FieldConfigFeatureTypeConstraintTest method testUndoAction.
/**
* Test method for
* {@link com.sldeditor.ui.detail.config.featuretypeconstraint.FieldConfigFeatureTypeConstraint#undoAction(com.sldeditor.common.undo.UndoInterface)}.
* Test method for
* {@link com.sldeditor.ui.detail.config.featuretypeconstraint.FieldConfigFeatureTypeConstraint#redoAction(com.sldeditor.common.undo.UndoInterface)}.
*/
@Test
public void testUndoAction() {
FieldConfigFeatureTypeConstraint field = new FieldConfigFeatureTypeConstraint(new FieldConfigCommonData(Geometry.class, FieldIdEnum.NAME, "label", true));
field.undoAction(null);
field.redoAction(null);
field.createUI();
StyleFactoryImpl styleFactory = (StyleFactoryImpl) CommonFactoryFinder.getStyleFactory();
FeatureTypeConstraint expectedValue1 = styleFactory.createFeatureTypeConstraint("Feature", Filter.INCLUDE, new Extent[0]);
List<FeatureTypeConstraint> testValue = new ArrayList<FeatureTypeConstraint>();
testValue.add(expectedValue1);
field.populateField(testValue);
assertEquals(expectedValue1, field.getFeatureTypeConstraint().get(0));
FeatureTypeConstraint expectedValue2 = styleFactory.createFeatureTypeConstraint("Feature2", Filter.INCLUDE, new Extent[0]);
List<FeatureTypeConstraint> testValue2 = new ArrayList<FeatureTypeConstraint>();
testValue2.add(expectedValue1);
testValue2.add(expectedValue2);
field.populateField(testValue2);
UndoManager.getInstance().undo();
assertEquals(1, field.getFeatureTypeConstraint().size());
assertEquals(expectedValue1, field.getFeatureTypeConstraint().get(0));
UndoManager.getInstance().redo();
assertEquals(2, field.getFeatureTypeConstraint().size());
assertEquals(expectedValue2, field.getFeatureTypeConstraint().get(1));
// Increase the code coverage
field.undoAction(null);
field.undoAction(new UndoEvent(null, FieldIdEnum.NAME, "", "new"));
field.redoAction(null);
field.redoAction(new UndoEvent(null, FieldIdEnum.NAME, "", "new"));
}
use of com.sldeditor.common.undo.UndoEvent in project sldeditor by robward-scisys.
the class FieldConfigFontTest method testUndoAction.
/**
* Test method for
* {@link com.sldeditor.ui.detail.config.font.FieldConfigFont#undoAction(com.sldeditor.common.undo.UndoInterface)}.
* Test method for
* {@link com.sldeditor.ui.detail.config.font.FieldConfigFont#redoAction(com.sldeditor.common.undo.UndoInterface)}.
*/
@Test
public void testUndoAction() {
boolean valueOnly = true;
FieldConfigFont field = new FieldConfigFont(new FieldConfigCommonData(String.class, FieldIdEnum.NAME, "test label", valueOnly));
String expectedDefaultValue1 = fontFamilies[0];
field.createUI();
field.populateField(expectedDefaultValue1);
String actualValue1 = field.getStringValue();
assertTrue(expectedDefaultValue1.compareTo(actualValue1) == 0);
String expectedDefaultValue2 = fontFamilies[0];
field.populateField(expectedDefaultValue2);
String actualValue2 = field.getStringValue();
assertTrue(expectedDefaultValue2.compareTo(actualValue2) == 0);
UndoManager.getInstance().undo();
String actualValue = field.getStringValue();
assertTrue(expectedDefaultValue1.compareTo(actualValue) == 0);
UndoManager.getInstance().redo();
actualValue = field.getStringValue();
assertTrue(expectedDefaultValue2.compareTo(actualValue) == 0);
// Increase the code coverage
field.undoAction(null);
field.undoAction(new UndoEvent(null, FieldIdEnum.NAME, Double.valueOf(1.0), Double.valueOf(2.0)));
field.redoAction(null);
field.redoAction(new UndoEvent(null, FieldIdEnum.NAME, Double.valueOf(1.0), Double.valueOf(2.0)));
}
use of com.sldeditor.common.undo.UndoEvent in project sldeditor by robward-scisys.
the class FieldConfigSymbolTypeTest method testUndoAction.
/**
* Test method for
* {@link com.sldeditor.ui.detail.config.FieldConfigSymbolType#undoAction(com.sldeditor.common.undo.UndoInterface)}.
* Test method for
* {@link com.sldeditor.ui.detail.config.FieldConfigSymbolType#redoAction(com.sldeditor.common.undo.UndoInterface)}.
*/
@Test
public void testUndoAction() {
UndoManager.getInstance().setPopulationCheck(Controller.getInstance());
boolean valueOnly = true;
FieldConfigSymbolType field = new FieldConfigSymbolType(new FieldConfigCommonData(Integer.class, FieldIdEnum.NAME, "label", valueOnly));
field.undoAction(null);
field.redoAction(null);
field.createUI();
field.createUI();
FieldConfigMarker marker = new FieldConfigMarker(new FieldConfigCommonData(String.class, FieldIdEnum.ANGLE, "label", valueOnly), null, null, null);
marker.createUI();
List<ValueComboBoxData> dataList = new ArrayList<ValueComboBoxData>();
dataList.add(new ValueComboBoxData("key 1", "Value 1", FieldConfigMarker.class));
dataList.add(new ValueComboBoxData("key 2", "Value 2", FieldConfigMarker.class));
dataList.add(new ValueComboBoxData("key 3", "Value 3", FieldConfigMarker.class));
List<ValueComboBoxDataGroup> combinedSymbolList = new ArrayList<ValueComboBoxDataGroup>();
combinedSymbolList.add(new ValueComboBoxDataGroup(dataList));
field.createUI();
field.addField(marker);
field.populate(null, combinedSymbolList);
String expectedValue2 = "key 2";
field.populateExpression(expectedValue2);
String actualValue2 = field.getStringValue();
assertTrue(actualValue2.compareTo(field.getStringValue()) == 0);
ValueComboBoxData actualValueObj2 = field.getEnumValue();
assertNotNull(actualValueObj2.getKey());
assertTrue(actualValueObj2.getKey().compareTo(expectedValue2) == 0);
String expectedValue3 = "key 1";
field.populateField(expectedValue3);
String actualValue3 = field.getStringValue();
assertTrue(expectedValue3.compareTo(actualValue3) == 0);
String expectedValue4 = "key 3";
field.populateField(expectedValue4);
String actualValue4 = field.getStringValue();
assertTrue(expectedValue4.compareTo(actualValue4) == 0);
UndoManager.getInstance().undo();
String actualValue = field.getStringValue();
assertTrue(expectedValue3.compareTo(actualValue) == 0);
UndoManager.getInstance().redo();
actualValue = field.getStringValue();
assertTrue(expectedValue4.compareTo(actualValue) == 0);
// Increase the code coverage
field.undoAction(null);
field.undoAction(new UndoEvent(null, FieldIdEnum.NAME, Double.valueOf(0), Double.valueOf(23)));
field.redoAction(null);
field.redoAction(new UndoEvent(null, FieldIdEnum.NAME, Double.valueOf(0), Double.valueOf(54)));
UndoManager.getInstance().setPopulationCheck(null);
}
use of com.sldeditor.common.undo.UndoEvent in project sldeditor by robward-scisys.
the class DataSourceConfigPanel method applyData.
/**
* Apply data.
*
* @param parentObj the parent obj
*/
protected void applyData(final UndoActionInterface parentObj) {
Object oldValueObj = attributeData;
Object newValueObj = dataModel.getAttributeData();
UndoManager.getInstance().addUndoEvent(new UndoEvent(parentObj, "Preferences", oldValueObj, newValueObj));
attributeData = (DataSourceAttributeListInterface) newValueObj;
dataSource.updateFields(attributeData);
dataChanged = false;
updateButtonState();
}
Aggregations