use of com.sldeditor.common.undo.UndoEvent in project sldeditor by robward-scisys.
the class FieldConfigBoundingBox method createRow.
/**
* Creates the row.
*
* @param label the label
* @param xPos the x pos
* @param fieldPanel the field panel
* @param row the row
* @return the j text field
*/
private JTextField createRow(String label, int xPos, FieldPanel fieldPanel, int row) {
final UndoActionInterface parentObj = this;
JLabel lbl = new JLabel(label);
lbl.setHorizontalAlignment(SwingConstants.TRAILING);
lbl.setBounds(xPos, getRowY(row), BasePanel.LABEL_WIDTH, BasePanel.WIDGET_HEIGHT);
fieldPanel.add(lbl);
JTextField textField = new JTextField();
textField.setBounds(xPos + BasePanel.WIDGET_X_START, getRowY(row), 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();
}
}
});
return textField;
}
use of com.sldeditor.common.undo.UndoEvent in project sldeditor by robward-scisys.
the class FieldConfigColour method populateExpression.
/**
* Populate expression.
*
* @param objValue the obj value
*/
/*
* (non-Javadoc)
*
* @see com.sldeditor.ui.detail.config.FieldConfigBase#populateExpression(java.lang.Object)
*/
@Override
public void populateExpression(Object objValue) {
String sValue = null;
boolean validColour = true;
if (objValue instanceof LiteralExpressionImpl) {
sValue = ((LiteralExpressionImpl) objValue).toString();
} else if (objValue instanceof String) {
sValue = (String) objValue;
} else {
validColour = false;
if (objValue != null) {
ConsoleManager.getInstance().error(this, "Colour expression is of unknown type : " + objValue.getClass().getName());
} else {
// Null is allowed, just will not be shown
}
}
if ((colourButton != null) && validColour) {
if (!sValue.startsWith("#")) {
ConsoleManager.getInstance().error(this, "Colour string does not start with #" + sValue);
} else {
Expression opacity = getFilterFactory().literal(DefaultSymbols.defaultColourOpacity());
colourButton.populate(sValue, opacity);
Color newValue = colourButton.getColour();
UndoManager.getInstance().addUndoEvent(new UndoEvent(this, getFieldId(), oldValueObj, newValue));
oldValueObj = newValue;
}
}
}
use of com.sldeditor.common.undo.UndoEvent in project sldeditor by robward-scisys.
the class FieldConfigColour method createUI.
/**
* Creates the ui.
*/
/*
* (non-Javadoc)
*
* @see com.sldeditor.ui.detail.config.FieldConfigBase#createUI()
*/
@Override
public void createUI() {
if (colourButton == null) {
final UndoActionInterface parentObj = this;
int xPos = getXPos();
FieldPanel fieldPanel = createFieldPanel(xPos, getLabel());
colourButton = new ColourButton();
colourButton.setBounds(xPos + BasePanel.WIDGET_X_START, 0, BasePanel.WIDGET_STANDARD_WIDTH, BasePanel.WIDGET_HEIGHT);
fieldPanel.add(colourButton);
if (!isValueOnly()) {
setAttributeSelectionPanel(fieldPanel.internalCreateAttrButton(String.class, this, isRasterSymbol()));
}
colourButton.registerObserver(new ColourNotifyInterface() {
@Override
public void notify(String colourString, double opacity) {
Color newValueObj = colourButton.getColour();
UndoManager.getInstance().addUndoEvent(new UndoEvent(parentObj, getFieldId(), oldValueObj, newValueObj));
oldValueObj = newValueObj;
valueUpdated();
}
});
}
}
use of com.sldeditor.common.undo.UndoEvent in project sldeditor by robward-scisys.
the class FieldConfigFont method setFont.
/**
* Sets the font.
*
* @param font the new font
* @return true, if successful
*/
private boolean setFont(Font font) {
String fontName = "";
boolean differentFamilyName = false;
if (font != null) {
fontName = getFontName(font);
String oldFontName = getFontName(currentFont);
differentFamilyName = (fontName.compareTo(oldFontName) != 0);
} else {
differentFamilyName = (currentFont != null);
}
if (comboBox == null) {
return false;
}
comboBox.setSelectValueKey(fontName);
currentFont = font;
if (differentFamilyName) {
UndoManager.getInstance().addUndoEvent(new UndoEvent(this, getFieldId(), oldValueObj, fontName));
oldValueObj = fontName;
}
return differentFamilyName;
}
use of com.sldeditor.common.undo.UndoEvent in project sldeditor by robward-scisys.
the class FieldConfigInlineFeature method inlineFeatureUpdated.
/*
* (non-Javadoc)
*
* @see com.sldeditor.ui.detail.config.inlinefeature.InlineFeatureUpdateInterface#inlineFeatureUpdated()
*/
@Override
public void inlineFeatureUpdated() {
if (!Controller.getInstance().isPopulating()) {
String value = "";
if (inlineFeature != null) {
value = inlineFeature.getInlineFeatures();
UndoManager.getInstance().addUndoEvent(new UndoEvent(this, getFieldId(), oldValueObj, new String(value)));
oldValueObj = new String(value);
if (inlineGML != null) {
inlineGML.setInlineFeatures(value);
}
valueUpdated();
}
}
}
Aggregations