use of com.sldeditor.common.undo.UndoEvent in project sldeditor by robward-scisys.
the class UndoManagerTest method testCheckPopulationFlag.
/**
* Test method for {@link com.sldeditor.common.undo.UndoManager#shouldProcessUndoRedoAction()}.
*/
@Test
public void testCheckPopulationFlag() {
UndoManager.destroyInstance();
DummyUndo listener = new DummyUndo();
DummyUndoParent parentListener = new DummyUndoParent();
UndoManager.getInstance().addListener(listener);
DummyPopulating populationCheck = new DummyPopulating();
UndoManager.getInstance().setPopulationCheck(populationCheck);
// CHECKSTYLE:OFF
UndoEvent event1 = new UndoEvent(parentListener, FieldIdEnum.ANCHOR_POINT_H, Integer.valueOf(2), Integer.valueOf(3));
UndoEvent event2 = new UndoEvent(parentListener, FieldIdEnum.ANCHOR_POINT_H, Integer.valueOf(2), Integer.valueOf(3));
UndoEvent event3 = new UndoEvent(parentListener, FieldIdEnum.DISPLACEMENT_Y, Integer.valueOf(20), Integer.valueOf(900));
UndoEvent event4 = new UndoEvent(parentListener, FieldIdEnum.DEFAULT_STYLE, Boolean.TRUE, Boolean.FALSE);
UndoEvent event5 = new UndoEvent(parentListener, FieldIdEnum.HALO_RADIUS, Double.valueOf(44.3), Double.valueOf(67.5));
// CHECKSTYLE:ON
UndoManager.getInstance().addUndoEvent(event1);
assertTrue(listener.undoAllowed);
assertFalse(listener.redoAllowed);
populationCheck.setPopulating(true);
// These should be added
UndoManager.getInstance().addUndoEvent(event2);
UndoManager.getInstance().addUndoEvent(event3);
UndoManager.getInstance().undo();
assertEquals(event1, parentListener.undoAction);
assertNull(parentListener.redoAction);
UndoManager.getInstance().addUndoEvent(event4);
populationCheck.setPopulating(false);
UndoManager.getInstance().addUndoEvent(event5);
UndoManager.getInstance().undo();
assertEquals(event5, parentListener.undoAction);
assertNull(parentListener.redoAction);
UndoManager.getInstance().setPopulationCheck(null);
}
use of com.sldeditor.common.undo.UndoEvent in project sldeditor by robward-scisys.
the class UndoManagerTest method testFileSaved.
@Test
public void testFileSaved() {
UndoManager.destroyInstance();
DummyUndo listener = new DummyUndo();
DummyUndoParent parentListener = new DummyUndoParent();
UndoManager.getInstance().addListener(listener);
UndoEvent event1 = new UndoEvent(parentListener, FieldIdEnum.ANCHOR_POINT_H, Integer.valueOf(2), Integer.valueOf(3));
UndoEvent event2 = new UndoEvent(parentListener, FieldIdEnum.ANCHOR_POINT_H, Integer.valueOf(2), Integer.valueOf(3));
UndoEvent event3 = new UndoEvent(parentListener, FieldIdEnum.DISPLACEMENT_Y, Integer.valueOf(20), Integer.valueOf(900));
UndoEvent event4 = new UndoEvent(parentListener, FieldIdEnum.DEFAULT_STYLE, Boolean.TRUE, Boolean.FALSE);
UndoEvent event5 = new UndoEvent(parentListener, FieldIdEnum.HALO_RADIUS, Double.valueOf(44.3), Double.valueOf(67.5));
UndoManager.getInstance().addUndoEvent(event1);
UndoManager.getInstance().addUndoEvent(event2);
UndoManager.getInstance().addUndoEvent(event3);
UndoManager.getInstance().addUndoEvent(event4);
UndoManager.getInstance().addUndoEvent(event5);
// This clears out all the undo events
UndoManager.getInstance().fileSaved();
assertFalse(listener.undoAllowed);
assertFalse(listener.redoAllowed);
}
use of com.sldeditor.common.undo.UndoEvent in project sldeditor by robward-scisys.
the class PrefManagerTest method testUndoAction.
/**
* Test method for {@link com.sldeditor.common.preferences.PrefManager#undoAction(com.sldeditor.common.undo.UndoInterface)}. Test method for
* {@link com.sldeditor.common.preferences.PrefManager#redoAction(com.sldeditor.common.undo.UndoInterface)}.
*/
@Test
public void testUndoAction() {
PrefManager.initialise(null);
PrefManager.getInstance().finish();
DummyPropertyManager propertyManager = new DummyPropertyManager();
PrefManager.initialise(propertyManager);
// Set up data as if it had been read in
PrefData prefData = new PrefData();
prefData.setUseAntiAlias(true);
Color backgroundColour = Color.GRAY;
prefData.setBackgroundColour(backgroundColour);
List<VersionData> vendorOptionList = new ArrayList<VersionData>();
vendorOptionList.add(VendorOptionManager.getInstance().getDefaultVendorOptionVersionData());
vendorOptionList.add(VersionData.getEarliestVersion(GeoServerVendorOption.class));
prefData.setVendorOptionVersionList(vendorOptionList);
String uiLayoutClass = "perfect curve";
prefData.setUiLayoutClass(uiLayoutClass);
String lastFolderViewed = "secret";
prefData.setLastFolderViewed(lastFolderViewed);
prefData.setLastViewedKey(PrefDataLastViewedEnum.FOLDER);
prefData.setSaveLastFolderView(true);
PrefManager.getInstance().setPrefData(prefData);
PrefData copy = prefData.clone();
copy.setLastViewedKey(PrefDataLastViewedEnum.GEOSERVER);
PrefManager.getInstance().setPrefData(copy);
PrefData actual = PrefManager.getInstance().getPrefData();
assertEquals(PrefDataLastViewedEnum.GEOSERVER, actual.getLastViewedKey());
UndoManager.getInstance().undo();
actual = PrefManager.getInstance().getPrefData();
assertEquals(PrefDataLastViewedEnum.FOLDER, actual.getLastViewedKey());
UndoManager.getInstance().redo();
actual = PrefManager.getInstance().getPrefData();
assertEquals(PrefDataLastViewedEnum.GEOSERVER, actual.getLastViewedKey());
// Increase the code coverage
PrefManager.getInstance().undoAction(null);
PrefManager.getInstance().undoAction(new UndoEvent(null, FieldIdEnum.NAME, "", "new"));
PrefManager.getInstance().redoAction(null);
PrefManager.getInstance().redoAction(new UndoEvent(null, FieldIdEnum.NAME, "", "new"));
}
use of com.sldeditor.common.undo.UndoEvent in project sldeditor by robward-scisys.
the class UndoEventTest method testUndoEvent2.
/**
* Test method for {@link com.sldeditor.common.undo.UndoEvent#UndoEvent(com.sldeditor.common.undo.UndoActionInterface, java.lang.String, java.lang.Object, java.lang.Object)}.
*/
@Test
public void testUndoEvent2() {
DummyUndoParent parent = new DummyUndoParent();
Double oldValue = Double.valueOf(22.0);
Double newValue = Double.valueOf(42.0);
String expectedField = "one more";
UndoEvent undoEvent = new UndoEvent(parent, expectedField, oldValue, newValue);
assertEquals(FieldIdEnum.UNKNOWN, undoEvent.getFieldId());
assertEquals(oldValue, undoEvent.getOldValue());
assertEquals(newValue, undoEvent.getNewValue());
assertNull(parent.redoAction);
assertNull(parent.undoAction);
undoEvent.doUndo();
assertEquals(oldValue, ((UndoEvent) parent.undoAction).getOldValue());
assertNull(parent.redoAction);
undoEvent.doRedo();
assertEquals(newValue, ((UndoEvent) parent.redoAction).getNewValue());
assertNull(parent.undoAction);
undoEvent.doUndo();
assertEquals(oldValue, ((UndoEvent) parent.undoAction).getOldValue());
assertNull(parent.redoAction);
}
use of com.sldeditor.common.undo.UndoEvent in project sldeditor by robward-scisys.
the class UndoEventTest method testUndoEvent1.
/**
* Test method for {@link com.sldeditor.common.undo.UndoEvent#UndoEvent(com.sldeditor.common.undo.UndoActionInterface, com.sldeditor.common.xml.ui.FieldIdEnum, java.lang.Object, java.lang.Object)}.
*/
@Test
public void testUndoEvent1() {
DummyUndoParent parent = new DummyUndoParent();
Double oldValue = Double.valueOf(22.0);
Double newValue = Double.valueOf(42.0);
FieldIdEnum expectedField = FieldIdEnum.ANGLE;
UndoEvent undoEvent = new UndoEvent(parent, expectedField, oldValue, newValue);
assertEquals(expectedField, undoEvent.getFieldId());
assertEquals(oldValue, undoEvent.getOldValue());
assertEquals(newValue, undoEvent.getNewValue());
assertNull(parent.redoAction);
assertNull(parent.undoAction);
undoEvent.doUndo();
assertEquals(oldValue, ((UndoEvent) parent.undoAction).getOldValue());
assertNull(parent.redoAction);
undoEvent.doRedo();
assertEquals(newValue, ((UndoEvent) parent.redoAction).getNewValue());
assertNull(parent.undoAction);
undoEvent.doUndo();
assertEquals(oldValue, ((UndoEvent) parent.undoAction).getOldValue());
assertNull(parent.redoAction);
}
Aggregations