Search in sources :

Example 56 with UndoEvent

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;
}
Also used : UndoEvent(com.sldeditor.common.undo.UndoEvent) JLabel(javax.swing.JLabel) JTextField(javax.swing.JTextField) FocusListener(java.awt.event.FocusListener) FocusEvent(java.awt.event.FocusEvent) UndoActionInterface(com.sldeditor.common.undo.UndoActionInterface)

Example 57 with UndoEvent

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;
        }
    }
}
Also used : UndoEvent(com.sldeditor.common.undo.UndoEvent) Expression(org.opengis.filter.expression.Expression) LiteralExpressionImpl(org.geotools.filter.LiteralExpressionImpl) Color(java.awt.Color)

Example 58 with UndoEvent

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();
            }
        });
    }
}
Also used : UndoEvent(com.sldeditor.common.undo.UndoEvent) Color(java.awt.Color) ColourButton(com.sldeditor.ui.widgets.ColourButton) FieldPanel(com.sldeditor.ui.widgets.FieldPanel) UndoActionInterface(com.sldeditor.common.undo.UndoActionInterface) ColourNotifyInterface(com.sldeditor.ui.iface.ColourNotifyInterface)

Example 59 with UndoEvent

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;
}
Also used : UndoEvent(com.sldeditor.common.undo.UndoEvent)

Example 60 with UndoEvent

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();
        }
    }
}
Also used : UndoEvent(com.sldeditor.common.undo.UndoEvent)

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