Search in sources :

Example 76 with UndoEvent

use of com.sldeditor.common.undo.UndoEvent in project sldeditor by robward-scisys.

the class FieldConfigGeometryFieldTest method testUndoAction.

/**
 * Test method for
 * {@link com.sldeditor.ui.detail.config.FieldConfigGeometryField#undoAction(com.sldeditor.common.undo.UndoInterface)}.
 * Test method for
 * {@link com.sldeditor.ui.detail.config.FieldConfigGeometryField#redoAction(com.sldeditor.common.undo.UndoInterface)}.
 * Test method for
 * {@link com.sldeditor.ui.detail.config.FieldConfigGeometryField#dataSourceLoaded(com.sldeditor.datasource.impl.GeometryTypeEnum, boolean)}.
 */
@Test
public void testUndoAction() {
    FieldConfigGeometryField field = new FieldConfigGeometryField(new FieldConfigCommonData(String.class, FieldIdEnum.NAME, "test label", true));
    field.undoAction(null);
    field.redoAction(null);
    field.createUI();
    field.undoAction(null);
    field.redoAction(null);
    TestDataSource testDataSource = new TestDataSource();
    @SuppressWarnings("unused") DataSourceInterface dataSource = DataSourceFactory.createDataSource(testDataSource);
    field.dataSourceLoaded(GeometryTypeEnum.POLYGON, false);
    String expectedTestValue = testDataSource.getDefaultGeometryField();
    field.setTestValue(FieldIdEnum.UNKNOWN, expectedTestValue);
    assertTrue(expectedTestValue.compareTo(field.getStringValue()) == 0);
    String expectedUndoTestValue = "";
    String expectedRedoTestValue = testDataSource.getDefaultGeometryField();
    UndoEvent undoEvent = new UndoEvent(null, FieldIdEnum.UNKNOWN, expectedUndoTestValue, expectedRedoTestValue);
    field.undoAction(undoEvent);
    assertTrue(expectedUndoTestValue.compareTo(field.getStringValue()) == 0);
    field.redoAction(undoEvent);
    assertTrue(expectedRedoTestValue.compareTo(field.getStringValue()) == 0);
}
Also used : DataSourceInterface(com.sldeditor.datasource.DataSourceInterface) CreateDataSourceInterface(com.sldeditor.datasource.impl.CreateDataSourceInterface) UndoEvent(com.sldeditor.common.undo.UndoEvent) FieldConfigCommonData(com.sldeditor.ui.detail.config.FieldConfigCommonData) FieldConfigGeometryField(com.sldeditor.ui.detail.config.FieldConfigGeometryField) Test(org.junit.Test)

Example 77 with UndoEvent

use of com.sldeditor.common.undo.UndoEvent in project sldeditor by robward-scisys.

the class FieldConfigGeometryTest method testUndoAction.

/**
 * Test method for
 * {@link com.sldeditor.ui.detail.config.FieldConfigGeometry#undoAction(com.sldeditor.common.undo.UndoInterface)}.
 * Test method for
 * {@link com.sldeditor.ui.detail.config.FieldConfigGeometry#redoAction(com.sldeditor.common.undo.UndoInterface)}.
 */
@Test
public void testUndoAction() {
    FieldConfigGeometry field = new FieldConfigGeometry(new FieldConfigCommonData(Geometry.class, FieldIdEnum.NAME, "label", false), "button text");
    field.undoAction(null);
    field.redoAction(null);
    field.createUI();
    field.setTestValue(FieldIdEnum.UNKNOWN, (String) null);
    field.populateField((String) null);
    field.populateExpression((String) null);
    String wktPoint = "POINT( 48.44 -123.37)";
    field.populateField(wktPoint);
    String actualValue = field.getStringValue();
    assertTrue(wktPoint.compareTo(actualValue) == 0);
    String wktPolygon = "POLYGON((20 10, 30 0, 40 10, 30 20, 20 10))";
    field.populateField(wktPolygon);
    actualValue = field.getStringValue();
    assertTrue(wktPolygon.compareTo(actualValue) == 0);
    String wktLine = "LINESTRING(0 2, 2 0, 8 6)";
    field.populateExpression(wktLine);
    actualValue = field.getStringValue();
    assertTrue(wktLine.compareTo(actualValue) == 0);
    UndoManager.getInstance().undo();
    actualValue = field.getStringValue();
    assertTrue(wktPolygon.compareTo(actualValue) == 0);
    UndoManager.getInstance().redo();
    actualValue = field.getStringValue();
    assertTrue(wktLine.compareTo(actualValue) == 0);
    // 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"));
}
Also used : FieldConfigGeometry(com.sldeditor.ui.detail.config.FieldConfigGeometry) Geometry(com.vividsolutions.jts.geom.Geometry) UndoEvent(com.sldeditor.common.undo.UndoEvent) FieldConfigGeometry(com.sldeditor.ui.detail.config.FieldConfigGeometry) FieldConfigCommonData(com.sldeditor.ui.detail.config.FieldConfigCommonData) Test(org.junit.Test)

Example 78 with UndoEvent

use of com.sldeditor.common.undo.UndoEvent in project sldeditor by robward-scisys.

the class FieldConfigStringTest method testUndoAction.

/**
 * Test method for
 * {@link com.sldeditor.ui.detail.config.FieldConfigString#undoAction(com.sldeditor.common.undo.UndoInterface)}.
 * Test method for
 * {@link com.sldeditor.ui.detail.config.FieldConfigString#redoAction(com.sldeditor.common.undo.UndoInterface)}.
 */
@Test
public void testUndoAction() {
    boolean valueOnly = true;
    FieldConfigString field = new FieldConfigString(new FieldConfigCommonData(String.class, FieldIdEnum.NAME, "test label", valueOnly), "button text");
    field.undoAction(null);
    field.redoAction(null);
    field.createUI();
    field.createUI();
    field.undoAction(null);
    field.redoAction(null);
    String expectedTestValue = "test value";
    field.setTestValue(null, expectedTestValue);
    assertTrue(expectedTestValue.compareTo(field.getStringValue()) == 0);
    String expectedUndoTestValue = "undo value";
    String expectedRedoTestValue = "redo value";
    UndoEvent undoEvent = new UndoEvent(null, FieldIdEnum.UNKNOWN, expectedUndoTestValue, expectedRedoTestValue);
    field.undoAction(undoEvent);
    assertTrue(expectedUndoTestValue.compareTo(field.getStringValue()) == 0);
    field.redoAction(undoEvent);
    assertTrue(expectedRedoTestValue.compareTo(field.getStringValue()) == 0);
}
Also used : UndoEvent(com.sldeditor.common.undo.UndoEvent) FieldConfigString(com.sldeditor.ui.detail.config.FieldConfigString) FieldConfigCommonData(com.sldeditor.ui.detail.config.FieldConfigCommonData) FieldConfigString(com.sldeditor.ui.detail.config.FieldConfigString) Test(org.junit.Test)

Example 79 with UndoEvent

use of com.sldeditor.common.undo.UndoEvent in project sldeditor by robward-scisys.

the class FieldConfigTransformationTest method testUndoAction.

/**
 * Test method for
 * {@link com.sldeditor.ui.detail.config.transform.FieldConfigTransformation#undoAction(com.sldeditor.common.undo.UndoInterface)}.
 * Test method for
 * {@link com.sldeditor.ui.detail.config.transform.FieldConfigTransformation#redoAction(com.sldeditor.common.undo.UndoInterface)}.
 */
@Test
public void testUndoAction() {
    boolean valueOnly = true;
    FieldConfigTransformation field = new FieldConfigTransformation(new FieldConfigCommonData(String.class, FieldIdEnum.NAME, "test label", valueOnly), "edit", "clear");
    field.undoAction(null);
    field.redoAction(null);
    field.createUI();
    field.undoAction(null);
    field.redoAction(null);
    String expectedTestValue = "test value";
    field.setTestValue(FieldIdEnum.UNKNOWN, expectedTestValue);
    assertTrue(expectedTestValue.compareTo(field.getStringValue()) == 0);
    String expectedUndoTestValue = "undo value";
    String expectedRedoTestValue = "redo value";
    UndoEvent undoEvent = new UndoEvent(null, FieldIdEnum.UNKNOWN, expectedUndoTestValue, expectedRedoTestValue);
    field.undoAction(undoEvent);
    assertTrue(expectedUndoTestValue.compareTo(field.getStringValue()) == 0);
    field.redoAction(undoEvent);
    assertTrue(expectedRedoTestValue.compareTo(field.getStringValue()) == 0);
    // Increase code coverage status
    undoEvent = new UndoEvent(null, FieldIdEnum.UNKNOWN, Integer.valueOf(0), Double.valueOf(10.0));
    field.undoAction(undoEvent);
    field.redoAction(undoEvent);
}
Also used : FieldConfigTransformation(com.sldeditor.ui.detail.config.transform.FieldConfigTransformation) UndoEvent(com.sldeditor.common.undo.UndoEvent) FieldConfigCommonData(com.sldeditor.ui.detail.config.FieldConfigCommonData) Test(org.junit.Test)

Example 80 with UndoEvent

use of com.sldeditor.common.undo.UndoEvent in project sldeditor by robward-scisys.

the class FieldConfigBoundingBoxTest method testUndoAction.

/**
 * Test method for
 * {@link com.sldeditor.ui.detail.config.FieldConfigBoundingBox#undoAction(com.sldeditor.common.undo.UndoInterface)}.
 * Test method for
 * {@link com.sldeditor.ui.detail.config.FieldConfigBoundingBox#redoAction(com.sldeditor.common.undo.UndoInterface)}.
 */
@Test
public void testUndoAction() {
    FieldConfigBoundingBox field = new FieldConfigBoundingBox(new FieldConfigCommonData(Geometry.class, FieldIdEnum.NAME, "label", false));
    field.undoAction(null);
    field.redoAction(null);
    field.createUI();
    field.createUI();
    CoordinateReferenceSystem crs = CoordManager.getInstance().getWGS84();
    ReferencedEnvelope envelope1 = new ReferencedEnvelope(0.0, 1.0, 51.0, 51.1, crs);
    field.populateField(envelope1);
    assertTrue(envelope1.toString().compareTo(field.getStringValue()) == 0);
    ReferencedEnvelope envelope2 = new ReferencedEnvelope(-10.0, -4.0, 31.0, 45.11, crs);
    field.populateField(envelope2);
    assertTrue(envelope2.toString().compareTo(field.getStringValue()) == 0);
    UndoManager.getInstance().undo();
    String actualValue = field.getStringValue();
    assertTrue(actualValue.compareTo(envelope1.toString()) == 0);
    UndoManager.getInstance().redo();
    actualValue = field.getStringValue();
    assertTrue(actualValue.compareTo(envelope2.toString()) == 0);
    field.undoAction(null);
    field.undoAction(new UndoEvent(null, FieldIdEnum.NAME, "", "new"));
    field.redoAction(null);
    field.redoAction(new UndoEvent(null, FieldIdEnum.NAME, "", "new"));
}
Also used : Geometry(com.vividsolutions.jts.geom.Geometry) UndoEvent(com.sldeditor.common.undo.UndoEvent) ReferencedEnvelope(org.geotools.geometry.jts.ReferencedEnvelope) FieldConfigCommonData(com.sldeditor.ui.detail.config.FieldConfigCommonData) CoordinateReferenceSystem(org.opengis.referencing.crs.CoordinateReferenceSystem) FieldConfigBoundingBox(com.sldeditor.ui.detail.config.FieldConfigBoundingBox) Test(org.junit.Test)

Aggregations

UndoEvent (com.sldeditor.common.undo.UndoEvent)84 Test (org.junit.Test)27 FieldConfigCommonData (com.sldeditor.ui.detail.config.FieldConfigCommonData)20 UndoActionInterface (com.sldeditor.common.undo.UndoActionInterface)16 FieldPanel (com.sldeditor.ui.widgets.FieldPanel)12 ActionEvent (java.awt.event.ActionEvent)11 ActionListener (java.awt.event.ActionListener)11 DefaultMutableTreeNode (javax.swing.tree.DefaultMutableTreeNode)11 TreePath (javax.swing.tree.TreePath)10 Geometry (com.vividsolutions.jts.geom.Geometry)9 ValueComboBoxData (com.sldeditor.ui.widgets.ValueComboBoxData)5 ArrayList (java.util.ArrayList)4 JPanel (javax.swing.JPanel)4 PolygonSymbolizer (org.geotools.styling.PolygonSymbolizer)4 RenderSymbolInterface (com.sldeditor.datasource.RenderSymbolInterface)3 ValueComboBox (com.sldeditor.ui.widgets.ValueComboBox)3 Color (java.awt.Color)3 JButton (javax.swing.JButton)3 JCheckBox (javax.swing.JCheckBox)3 LineSymbolizer (org.geotools.styling.LineSymbolizer)3