Search in sources :

Example 6 with UndoEvent

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

the class FieldConfigColourMapTest method testUndoAction.

/**
 * Test method for
 * {@link com.sldeditor.ui.detail.config.colourmap.FieldConfigColourMap#undoAction(com.sldeditor.common.undo.UndoInterface)}.
 * Test method for
 * {@link com.sldeditor.ui.detail.config.colourmap.FieldConfigColourMap#redoAction(com.sldeditor.common.undo.UndoInterface)}.
 */
@Test
public void testUndoAction() {
    FieldConfigColourMap field = new FieldConfigColourMap(new FieldConfigCommonData(Geometry.class, FieldIdEnum.NAME, "label", true));
    field.undoAction(null);
    field.redoAction(null);
    field.createUI();
    ColorMap expectedValue1 = new ColorMapImpl();
    field.populateField(expectedValue1);
    assertEquals(expectedValue1, field.getColourMap());
    FilterFactory ff = CommonFactoryFinder.getFilterFactory();
    ColorMap expectedValue2 = new ColorMapImpl();
    ColorMapEntryImpl entry = new ColorMapEntryImpl();
    entry.setColor(ff.literal("#001122"));
    expectedValue2.addColorMapEntry(entry);
    field.populateField(expectedValue2);
    UndoManager.getInstance().undo();
    assertEquals(expectedValue1.getColorMapEntries().length, field.getColourMap().getColorMapEntries().length);
    UndoManager.getInstance().redo();
    assertEquals(expectedValue2.getColorMapEntries().length, field.getColourMap().getColorMapEntries().length);
    // 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 : Geometry(com.vividsolutions.jts.geom.Geometry) UndoEvent(com.sldeditor.common.undo.UndoEvent) ColorMapImpl(org.geotools.styling.ColorMapImpl) FieldConfigColourMap(com.sldeditor.ui.detail.config.colourmap.FieldConfigColourMap) ColorMapEntryImpl(org.geotools.styling.ColorMapEntryImpl) ColorMap(org.geotools.styling.ColorMap) FieldConfigCommonData(com.sldeditor.ui.detail.config.FieldConfigCommonData) FilterFactory(org.opengis.filter.FilterFactory) Test(org.junit.Test)

Example 7 with UndoEvent

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

the class FieldConfigDoubleTest method testUndoAction.

/**
 * Test method for
 * {@link com.sldeditor.ui.detail.config.FieldConfigDouble#undoAction(com.sldeditor.common.undo.UndoInterface)}.
 * Test method for
 * {@link com.sldeditor.ui.detail.config.FieldConfigDouble#redoAction(com.sldeditor.common.undo.UndoInterface)}.
 */
@Test
public void testUndoAction() {
    boolean valueOnly = true;
    FieldConfigDouble field = new FieldConfigDouble(new FieldConfigCommonData(Double.class, FieldIdEnum.NAME, "label", valueOnly));
    field.undoAction(null);
    field.redoAction(null);
    double expectedValue1 = 13.4;
    field.createUI();
    field.populateField(expectedValue1);
    assertTrue(Math.abs(field.getDoubleValue() - expectedValue1) < 0.001);
    double expectedValue2 = 987.6;
    field.setTestValue(FieldIdEnum.UNKNOWN, expectedValue2);
    assertTrue(Math.abs(field.getDoubleValue() - expectedValue2) < 0.001);
    UndoManager.getInstance().undo();
    assertTrue(Math.abs(field.getDoubleValue() - expectedValue1) < 0.001);
    UndoManager.getInstance().redo();
    assertTrue(Math.abs(field.getDoubleValue() - expectedValue2) < 0.001);
    // Increase the code coverage
    field.undoAction(null);
    field.redoAction(null);
    field.undoAction(new UndoEvent(null, FieldIdEnum.NAME, "", "new"));
    field.redoAction(new UndoEvent(null, FieldIdEnum.NAME, "", "new"));
}
Also used : UndoEvent(com.sldeditor.common.undo.UndoEvent) FieldConfigDouble(com.sldeditor.ui.detail.config.FieldConfigDouble) FieldConfigCommonData(com.sldeditor.ui.detail.config.FieldConfigCommonData) FieldConfigDouble(com.sldeditor.ui.detail.config.FieldConfigDouble) Test(org.junit.Test)

Example 8 with UndoEvent

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

the class FieldConfigIntegerTest method testUndoAction.

/**
 * Test method for
 * {@link com.sldeditor.ui.detail.config.FieldConfigInteger#undoAction(com.sldeditor.common.undo.UndoInterface)}.
 * Test method for
 * {@link com.sldeditor.ui.detail.config.FieldConfigInteger#redoAction(com.sldeditor.common.undo.UndoInterface)}.
 */
@Test
public void testUndoAction() {
    boolean valueOnly = true;
    FieldConfigInteger field = new FieldConfigInteger(new FieldConfigCommonData(Integer.class, FieldIdEnum.NAME, "label", valueOnly));
    field.undoAction(null);
    field.redoAction(null);
    int expectedValue1 = 134;
    field.createUI();
    field.populateField(expectedValue1);
    assertEquals(expectedValue1, field.getIntValue());
    int expectedValue2 = 9876;
    field.setTestValue(FieldIdEnum.UNKNOWN, expectedValue2);
    assertEquals(expectedValue2, field.getIntValue());
    UndoManager.getInstance().undo();
    assertEquals(expectedValue1, field.getIntValue());
    UndoManager.getInstance().redo();
    assertEquals(expectedValue2, field.getIntValue());
    // 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 : FieldConfigInteger(com.sldeditor.ui.detail.config.FieldConfigInteger) UndoEvent(com.sldeditor.common.undo.UndoEvent) FieldConfigInteger(com.sldeditor.ui.detail.config.FieldConfigInteger) FieldConfigCommonData(com.sldeditor.ui.detail.config.FieldConfigCommonData) Test(org.junit.Test)

Example 9 with UndoEvent

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

the class FieldConfigRangeTest method testUndoAction.

/**
 * Test method for {@link com.sldeditor.ui.detail.config.FieldConfigRange#undoAction(com.sldeditor.common.undo.UndoInterface)}. Test method for
 * {@link com.sldeditor.ui.detail.config.FieldConfigRange#redoAction(com.sldeditor.common.undo.UndoInterface)}.
 */
@SuppressWarnings("rawtypes")
@Test
public void testUndoAction() {
    boolean valueOnly = true;
    FieldConfigRange field = new FieldConfigRange(new FieldConfigCommonData(Double.class, FieldIdEnum.NAME, "label", valueOnly), org.jaitools.numeric.Range.class);
    field.undoAction(null);
    field.redoAction(null);
    Range expectedValue1 = Range.create(3.0, false, 11.0, false);
    field.createUI();
    field.populateField(expectedValue1);
    Range actualValue = field.getRange();
    assertTrue(Math.abs(actualValue.getMin().doubleValue() - expectedValue1.getMin().doubleValue()) < 0.001);
    assertEquals(actualValue.isMinIncluded(), expectedValue1.isMinIncluded());
    assertTrue(Math.abs(actualValue.getMax().doubleValue() - expectedValue1.getMax().doubleValue()) < 0.001);
    assertEquals(actualValue.isMaxIncluded(), expectedValue1.isMaxIncluded());
    Range expectedValue2 = Range.create(23.0, true, 51.0, false);
    field.populateField(expectedValue2);
    actualValue = field.getRange();
    assertTrue(Math.abs(actualValue.getMin().doubleValue() - expectedValue2.getMin().doubleValue()) < 0.001);
    assertEquals(actualValue.isMinIncluded(), expectedValue2.isMinIncluded());
    assertTrue(Math.abs(actualValue.getMax().doubleValue() - expectedValue2.getMax().doubleValue()) < 0.001);
    assertEquals(actualValue.isMaxIncluded(), expectedValue2.isMaxIncluded());
    UndoManager.getInstance().undo();
    actualValue = field.getRange();
    assertTrue(Math.abs(actualValue.getMin().doubleValue() - expectedValue1.getMin().doubleValue()) < 0.001);
    assertEquals(actualValue.isMinIncluded(), expectedValue1.isMinIncluded());
    assertTrue(Math.abs(actualValue.getMax().doubleValue() - expectedValue1.getMax().doubleValue()) < 0.001);
    assertEquals(actualValue.isMaxIncluded(), expectedValue1.isMaxIncluded());
    UndoManager.getInstance().redo();
    actualValue = field.getRange();
    assertTrue(Math.abs(actualValue.getMin().doubleValue() - expectedValue2.getMin().doubleValue()) < 0.001);
    assertEquals(actualValue.isMinIncluded(), expectedValue2.isMinIncluded());
    assertTrue(Math.abs(actualValue.getMax().doubleValue() - expectedValue2.getMax().doubleValue()) < 0.001);
    assertEquals(actualValue.isMaxIncluded(), expectedValue2.isMaxIncluded());
    // Increase the code coverage
    field.undoAction(null);
    field.redoAction(null);
    field.undoAction(new UndoEvent(null, FieldIdEnum.NAME, "", "new"));
    field.redoAction(new UndoEvent(null, FieldIdEnum.NAME, "", "new"));
}
Also used : UndoEvent(com.sldeditor.common.undo.UndoEvent) FieldConfigRange(com.sldeditor.ui.detail.config.FieldConfigRange) FieldConfigCommonData(com.sldeditor.ui.detail.config.FieldConfigCommonData) Range(org.jaitools.numeric.Range) FieldConfigRange(com.sldeditor.ui.detail.config.FieldConfigRange) Test(org.junit.Test)

Example 10 with UndoEvent

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

the class FieldConfigSliderTest method testUndoAction.

/**
 * Test method for
 * {@link com.sldeditor.ui.detail.config.FieldConfigSlider#undoAction(com.sldeditor.common.undo.UndoInterface)}.
 * Test method for
 * {@link com.sldeditor.ui.detail.config.FieldConfigSlider#redoAction(com.sldeditor.common.undo.UndoInterface)}.
 */
@Test
public void testUndoAction() {
    boolean valueOnly = true;
    FieldConfigSlider field = new FieldConfigSlider(new FieldConfigCommonData(Double.class, FieldIdEnum.NAME, "label", valueOnly));
    field.undoAction(null);
    field.redoAction(null);
    double expectedValue1 = 0.13;
    field.createUI();
    field.populateField(expectedValue1);
    assertTrue(Math.abs(field.getDoubleValue() - expectedValue1) < 0.001);
    double expectedValue2 = 0.98;
    field.setTestValue(null, expectedValue2);
    assertTrue(Math.abs(field.getDoubleValue() - expectedValue2) < 0.001);
    UndoManager.getInstance().undo();
    assertTrue(Math.abs(field.getDoubleValue() - expectedValue1) < 0.001);
    UndoManager.getInstance().redo();
    assertTrue(Math.abs(field.getDoubleValue() - expectedValue2) < 0.001);
    // 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 : UndoEvent(com.sldeditor.common.undo.UndoEvent) FieldConfigCommonData(com.sldeditor.ui.detail.config.FieldConfigCommonData) FieldConfigSlider(com.sldeditor.ui.detail.config.FieldConfigSlider) 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