use of com.sldeditor.common.undo.UndoActionInterface 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.UndoActionInterface in project sldeditor by robward-scisys.
the class FieldConfigTransformation 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();
int width = BasePanel.FIELD_PANEL_WIDTH - xPos - 20;
int height = BasePanel.WIDGET_HEIGHT * (NO_OF_ROWS - 1);
textField = new JTextArea();
textField.setBounds(xPos, BasePanel.WIDGET_HEIGHT, width, height);
textField.setEditable(false);
JScrollPane scroll = new JScrollPane(textField);
scroll.setBounds(xPos, BasePanel.WIDGET_HEIGHT, width, height);
scroll.setAutoscrolls(true);
FieldPanel fieldPanel = createFieldPanel(xPos, BasePanel.WIDGET_HEIGHT * NO_OF_ROWS, getLabel());
fieldPanel.add(scroll);
//
// Edit button
//
final JButton buttonEdit = new JButton(editButtonText);
buttonEdit.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
ProcessFunction expression = showTransformationDialog(processFunction);
if (expression != null) {
ProcessFunction newValueObj = processFunction;
processFunction = expression;
textField.setText(ParameterFunctionUtils.getString(processFunction));
UndoManager.getInstance().addUndoEvent(new UndoEvent(parentObj, getFieldId(), oldValueObj, newValueObj));
valueUpdated();
}
}
});
buttonEdit.setBounds(xPos + BasePanel.WIDGET_X_START, 0, BasePanel.WIDGET_BUTTON_WIDTH, BasePanel.WIDGET_HEIGHT);
fieldPanel.add(buttonEdit);
//
// Clear button
//
final JButton buttonClear = new JButton(clearButtonText);
buttonClear.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
processFunction = null;
textField.setText("");
UndoManager.getInstance().addUndoEvent(new UndoEvent(parentObj, getFieldId(), oldValueObj, null));
valueUpdated();
}
});
buttonClear.setBounds((int) buttonEdit.getBounds().getMaxX() + 5, 0, BasePanel.WIDGET_BUTTON_WIDTH, BasePanel.WIDGET_HEIGHT);
fieldPanel.add(buttonClear);
}
}
use of com.sldeditor.common.undo.UndoActionInterface in project sldeditor by robward-scisys.
the class ColourRampPanel method createTopPanel.
/**
* Creates the top panel.
*/
private void createTopPanel() {
final UndoActionInterface undoObj = this;
JPanel topPanel = new JPanel();
topPanel.setPreferredSize(new Dimension(BasePanel.FIELD_PANEL_WIDTH, BasePanel.WIDGET_HEIGHT));
topPanel.setLayout(null);
panel.add(topPanel, BorderLayout.NORTH);
List<ValueComboBoxData> dataList = populateColourRamps(false);
rampComboBox = new ValueComboBox();
rampComboBox.initialiseSingle(dataList);
rampComboBox.setBounds(BasePanel.WIDGET_X_START, 0, BasePanel.WIDGET_EXTENDED_WIDTH, BasePanel.WIDGET_HEIGHT);
topPanel.add(rampComboBox);
rampComboBox.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
if (!isPopulating()) {
Integer newValueObj = rampComboBox.getSelectedIndex();
UndoManager.getInstance().addUndoEvent(new UndoEvent(undoObj, FieldIdEnum.COLOUR_RAMP_COLOUR, oldColourRampIndex, newValueObj));
oldColourRampIndex = newValueObj;
}
}
});
reverseCheckbox = new JCheckBox(Localisation.getString(ColourRampConfigPanel.class, "ColourRampPanel.reverse"));
reverseCheckbox.setBounds(rampComboBox.getX() + rampComboBox.getWidth() + 20, 0, BasePanel.WIDGET_STANDARD_WIDTH, BasePanel.WIDGET_HEIGHT);
reverseCheckbox.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
boolean isSelected = reverseCheckbox.isSelected();
Boolean oldValueObj = Boolean.valueOf(!isSelected);
Boolean newValueObj = Boolean.valueOf(isSelected);
UndoManager.getInstance().addUndoEvent(new UndoEvent(undoObj, FieldIdEnum.COLOUR_RAMP_REVERSE, oldValueObj, newValueObj));
reverseColourRamp(isSelected);
}
});
topPanel.add(reverseCheckbox);
}
use of com.sldeditor.common.undo.UndoActionInterface 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.UndoActionInterface 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();
}
});
}
}
Aggregations