use of com.sldeditor.common.undo.UndoEvent in project sldeditor by robward-scisys.
the class FieldConfigGeometry method createUI.
/**
* Creates the ui.
*/
/*
* (non-Javadoc)
*
* @see com.sldeditor.ui.detail.config.FieldConfigBase#createUI()
*/
@Override
public void createUI() {
if (textField == null) {
final UndoActionInterface parentObj = this;
int xPos = getXPos();
FieldPanel fieldPanel = createFieldPanel(xPos, getLabel());
textField = new JTextField();
textField.setBounds(xPos + BasePanel.WIDGET_X_START, 0, this.isValueOnly() ? BasePanel.WIDGET_EXTENDED_WIDTH : BasePanel.WIDGET_STANDARD_WIDTH, BasePanel.WIDGET_HEIGHT);
fieldPanel.add(textField);
textField.addFocusListener(new FocusListener() {
private String originalValue = "";
@Override
public void focusGained(FocusEvent e) {
originalValue = textField.getText();
}
@Override
public void focusLost(FocusEvent e) {
String newValueObj = textField.getText();
if (originalValue.compareTo(newValueObj) != 0) {
UndoManager.getInstance().addUndoEvent(new UndoEvent(parentObj, getFieldId(), oldValueObj, newValueObj));
oldValueObj = originalValue;
valueUpdated();
}
}
});
if (buttonText != null) {
final JButton buttonExternal = new JButton(buttonText);
buttonExternal.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
if (buttonPressedListenerList != null) {
// CHECKSTYLE:OFF
for (FieldConfigStringButtonInterface listener : buttonPressedListenerList) {
listener.buttonPressed(buttonExternal);
}
// CHECKSTYLE:ON
}
}
});
int buttonWidth = 26;
int padding = 3;
buttonExternal.setBounds(xPos + textField.getX() - buttonWidth - padding, 0, buttonWidth, BasePanel.WIDGET_HEIGHT);
fieldPanel.add(buttonExternal);
}
if (!isValueOnly()) {
setAttributeSelectionPanel(fieldPanel.internalCreateAttrButton(Geometry.class, this, isRasterSymbol()));
}
}
}
use of com.sldeditor.common.undo.UndoEvent in project sldeditor by robward-scisys.
the class FieldConfigInteger method createUI.
/**
* Creates the ui.
*/
/*
* (non-Javadoc)
*
* @see com.sldeditor.ui.detail.config.FieldConfigBase#createUI()
*/
@Override
public void createUI() {
if (spinner == null) {
final UndoActionInterface parentObj = this;
int xPos = getXPos();
FieldPanel fieldPanel = createFieldPanel(xPos, getLabel());
spinner = new IntegerSpinner(minValue, maxValue, stepSize);
spinner.setBounds(xPos + BasePanel.WIDGET_X_START, 0, BasePanel.WIDGET_STANDARD_WIDTH, BasePanel.WIDGET_HEIGHT);
fieldPanel.add(spinner);
if (!isValueOnly()) {
setAttributeSelectionPanel(fieldPanel.internalCreateAttrButton(Double.class, this, isRasterSymbol()));
}
spinner.registerObserver(new SpinnerNotifyInterface() {
@Override
public void notify(double oldValue, double newValue) {
Integer oldValueObj = Double.valueOf(oldValue).intValue();
Integer newValueObj = Double.valueOf(newValue).intValue();
UndoManager.getInstance().addUndoEvent(new UndoEvent(parentObj, getFieldId(), oldValueObj, newValueObj));
valueUpdated();
}
});
}
}
use of com.sldeditor.common.undo.UndoEvent in project sldeditor by robward-scisys.
the class FieldConfigRange method uiInteraction.
/**
* Ui interaction.
*
* @param parentObj the parent obj
*/
@SuppressWarnings("rawtypes")
protected void uiInteraction(final UndoActionInterface parentObj) {
Range oldValueObj = previousValue;
Range newValueObj = getRangeValues();
if (oldValueObj != previousValue) {
UndoManager.getInstance().addUndoEvent(new UndoEvent(parentObj, getFieldId(), oldValueObj, newValueObj));
}
valueUpdated();
}
use of com.sldeditor.common.undo.UndoEvent in project sldeditor by robward-scisys.
the class FieldConfigString method createUI.
/**
* Creates the ui.
*/
/*
* (non-Javadoc)
*
* @see com.sldeditor.ui.detail.config.FieldConfigBase#createUI()
*/
@Override
public void createUI() {
if (textField == null) {
final UndoActionInterface parentObj = this;
int xPos = getXPos();
FieldPanel fieldPanel = createFieldPanel(xPos, getLabel());
textField = new TextFieldPropertyChange();
textField.setBounds(xPos + BasePanel.WIDGET_X_START, 0, this.isValueOnly() ? BasePanel.WIDGET_EXTENDED_WIDTH : BasePanel.WIDGET_STANDARD_WIDTH, BasePanel.WIDGET_HEIGHT);
fieldPanel.add(textField);
textField.addPropertyChangeListener(TextFieldPropertyChange.TEXT_PROPERTY, new PropertyChangeListener() {
/*
* (non-Javadoc)
*
* @see java.beans.PropertyChangeListener#propertyChange(java.beans.PropertyChangeEvent)
*/
@Override
public void propertyChange(PropertyChangeEvent evt) {
String originalValue = (String) evt.getOldValue();
String newValueObj = (String) evt.getNewValue();
if ((originalValue.compareTo(newValueObj) != 0)) {
if (!suppressUpdateOnSet) {
UndoManager.getInstance().addUndoEvent(new UndoEvent(parentObj, getFieldId(), oldValueObj, newValueObj));
oldValueObj = originalValue;
}
valueUpdated();
}
}
});
if (buttonText != null) {
final JButton buttonExternal = new JButton(buttonText);
buttonExternal.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
if (buttonPressedListenerList != null) {
// CHECKSTYLE:OFF
for (FieldConfigStringButtonInterface listener : buttonPressedListenerList) {
listener.buttonPressed(buttonExternal);
}
// CHECKSTYLE:ON
}
}
});
int buttonWidth = 26;
int padding = 3;
buttonExternal.setBounds(xPos + textField.getX() - buttonWidth - padding, 0, buttonWidth, BasePanel.WIDGET_HEIGHT);
fieldPanel.add(buttonExternal);
}
if (!isValueOnly()) {
setAttributeSelectionPanel(fieldPanel.internalCreateAttrButton(String.class, this, isRasterSymbol()));
}
}
}
use of com.sldeditor.common.undo.UndoEvent in project sldeditor by robward-scisys.
the class FieldConfigString method populateField.
/**
* Populate field.
*
* @param value the value
*/
@Override
public void populateField(String value) {
if (textField != null) {
textField.setText(value);
if (!suppressUpdateOnSet) {
UndoManager.getInstance().addUndoEvent(new UndoEvent(this, getFieldId(), oldValueObj, value));
oldValueObj = value;
valueUpdated();
}
}
}
Aggregations