use of com.sldeditor.common.undo.UndoEvent in project sldeditor by robward-scisys.
the class TTFDetails method buttonPressed.
/**
* Button pressed.
*
* @param buttonExternal the button external
*/
@Override
public void buttonPressed(Component buttonExternal) {
CharMap4 charMap4 = new CharMap4();
charMap4.loadConfig();
charMap4.setTTFString(fieldConfigVisitor.getText(FieldIdEnum.TTF_SYMBOL));
String selectedChar = charMap4.showDialog();
if (selectedChar != null) {
fieldConfigVisitor.populateTextField(FieldIdEnum.TTF_SYMBOL, selectedChar);
UndoManager.getInstance().addUndoEvent(new UndoEvent(this, FieldIdEnum.TTF_SYMBOL, oldValueObj, selectedChar));
oldValueObj = selectedChar;
EventQueue.invokeLater(new Runnable() {
public void run() {
updateSymbol();
}
});
}
}
use of com.sldeditor.common.undo.UndoEvent in project sldeditor by robward-scisys.
the class FieldConfigTransformation method populateField.
/**
* Populate field.
*
* @param value the value
*/
@Override
public void populateField(String value) {
if (textField != null) {
textField.setText(value);
UndoManager.getInstance().addUndoEvent(new UndoEvent(this, getFieldId(), oldValueObj, value));
oldValueObj = value;
valueUpdated();
}
}
use of com.sldeditor.common.undo.UndoEvent in project sldeditor by robward-scisys.
the class FieldConfigTransformation method populateField.
/**
* Populate process function field.
*
* @param value the value
*/
@Override
public void populateField(ProcessFunction value) {
processFunction = value;
if (textField != null) {
textField.setText(ParameterFunctionUtils.getString(processFunction));
UndoManager.getInstance().addUndoEvent(new UndoEvent(this, getFieldId(), oldValueObj, value));
oldValueObj = value;
valueUpdated();
}
}
use of com.sldeditor.common.undo.UndoEvent in project sldeditor by robward-scisys.
the class FieldConfigDateTest method testUndoAction.
/**
* Test method for
* {@link com.sldeditor.ui.detail.config.FieldConfigDate#undoAction(com.sldeditor.common.undo.UndoInterface)}.
* Test method for
* {@link com.sldeditor.ui.detail.config.FieldConfigDate#redoAction(com.sldeditor.common.undo.UndoInterface)}.
*/
@Test
public void testUndoAction() {
FieldConfigDate field = new FieldConfigDate(new FieldConfigCommonData(Date.class, FieldIdEnum.NAME, "label", false));
field.undoAction(null);
field.redoAction(null);
field.createUI();
SimpleDateFormat f = new SimpleDateFormat("dd-MM-yyyy HH:mm:ss");
String dateString1 = "10-01-2012 23:13:26";
String dateString2 = "05-06-2018 12:34:56";
Date dateTime1 = null;
Date dateTime2 = null;
try {
dateTime1 = f.parse(dateString1);
dateTime2 = f.parse(dateString2);
} catch (ParseException e) {
e.printStackTrace();
}
field.populateField(dateTime1);
DateFormat df = new SimpleDateFormat("dd-MM-yyyy", Locale.ENGLISH);
DateFormat tf = new SimpleDateFormat("HH:mm:ss", Locale.ENGLISH);
String dateFormat1String = String.format("%sT%sZ", df.format(dateTime1), tf.format(dateTime1));
assertTrue(dateFormat1String.compareTo(field.getStringValue()) == 0);
field.populateField(dateTime2);
String dateFormat2String = String.format("%sT%sZ", df.format(dateTime2), tf.format(dateTime2));
assertTrue(dateFormat2String.compareTo(field.getStringValue()) == 0);
UndoManager.getInstance().undo();
String actualValue = field.getStringValue();
assertTrue(actualValue.compareTo(dateFormat1String) == 0);
UndoManager.getInstance().redo();
actualValue = field.getStringValue();
assertTrue(actualValue.compareTo(dateFormat2String) == 0);
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 FieldConfigEnumTest method testUndoAction.
/**
* Test method for
* {@link com.sldeditor.ui.detail.config.FieldConfigEnum#undoAction(com.sldeditor.common.undo.UndoInterface)}.
* Test method for
* {@link com.sldeditor.ui.detail.config.FieldConfigEnum#redoAction(com.sldeditor.common.undo.UndoInterface)}.
*/
@Test
public void testUndoAction() {
SymbolTypeConfig s1 = new SymbolTypeConfig(null);
s1.addOption("key1", "Value 1");
s1.addOption("key2", "Value 2");
s1.addOption("key3", "Value 3");
s1.addField(FieldIdEnum.ANCHOR_POINT_H, true);
s1.addField(FieldIdEnum.ANCHOR_POINT_V, false);
List<SymbolTypeConfig> configList = new ArrayList<SymbolTypeConfig>();
configList.add(s1);
SymbolTypeConfig s2 = new SymbolTypeConfig(null);
s2.addOption("key4", "Value 4");
s2.addOption("key5", "Value 5");
s2.addOption("key6", "Value 6");
s2.addField(FieldIdEnum.ANGLE, true);
s2.addField(FieldIdEnum.DESCRIPTION, false);
configList.add(s2);
boolean valueOnly = true;
FieldConfigEnum field = new FieldConfigEnum(new FieldConfigCommonData(Integer.class, FieldIdEnum.NAME, "label", valueOnly));
field.addConfig(null);
assertNull(field.getStringValue());
field.addConfig(configList);
// Now create the ui
field.createUI();
String expectedValue1 = "key2";
field.populateField(expectedValue1);
String expectedValue2 = "key6";
field.populateField(expectedValue2);
UndoManager.getInstance().undo();
String actualValueString = field.getStringValue();
assertTrue(expectedValue1.compareTo(actualValueString) == 0);
ValueComboBoxData actualValue = field.getEnumValue();
assertTrue(expectedValue1.compareTo(actualValue.getKey()) == 0);
UndoManager.getInstance().redo();
actualValueString = field.getStringValue();
assertTrue(expectedValue2.compareTo(actualValueString) == 0);
actualValue = field.getEnumValue();
assertTrue(expectedValue2.compareTo(actualValue.getKey()) == 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)));
}
Aggregations