Search in sources :

Example 16 with UndoEvent

use of com.sldeditor.common.undo.UndoEvent in project sldeditor by robward-scisys.

the class FieldConfigBoolean method createUI.

/**
 * Creates the ui.
 */
/*
     * (non-Javadoc)
     * 
     * @see com.sldeditor.ui.detail.config.FieldConfigBase#createUI()
     */
@Override
public void createUI() {
    if (checkBox == null) {
        final UndoActionInterface parentObj = this;
        int xPos = getXPos();
        FieldPanel fieldPanel = createFieldPanel(xPos, getLabel());
        checkBox = new JCheckBox("");
        checkBox.setBounds(xPos + BasePanel.WIDGET_X_START, 0, BasePanel.WIDGET_STANDARD_WIDTH, BasePanel.WIDGET_HEIGHT);
        fieldPanel.add(checkBox);
        checkBox.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent e) {
                boolean isSelected = checkBox.isSelected();
                Boolean oldValueObj = Boolean.valueOf(!isSelected);
                Boolean newValueObj = Boolean.valueOf(isSelected);
                UndoManager.getInstance().addUndoEvent(new UndoEvent(parentObj, getFieldId(), oldValueObj, newValueObj));
                valueUpdated();
            }
        });
        if (!isValueOnly()) {
            setAttributeSelectionPanel(fieldPanel.internalCreateAttrButton(Boolean.class, this, isRasterSymbol()));
        }
    }
}
Also used : JCheckBox(javax.swing.JCheckBox) UndoEvent(com.sldeditor.common.undo.UndoEvent) ActionListener(java.awt.event.ActionListener) ActionEvent(java.awt.event.ActionEvent) FieldPanel(com.sldeditor.ui.widgets.FieldPanel) UndoActionInterface(com.sldeditor.common.undo.UndoActionInterface)

Example 17 with UndoEvent

use of com.sldeditor.common.undo.UndoEvent in project sldeditor by robward-scisys.

the class FieldConfigBoundingBox method populateField.

/**
 * Populate field.
 *
 * @param value the value
 */
@Override
public void populateField(ReferencedEnvelope value) {
    xMinTextField.setText(Double.toString(value.getMinX()));
    xMaxTextField.setText(Double.toString(value.getMaxX()));
    yMinTextField.setText(Double.toString(value.getMinY()));
    yMaxTextField.setText(Double.toString(value.getMaxY()));
    String key = CoordManager.getInstance().getCRSCode(value.getCoordinateReferenceSystem());
    crsComboBox.setSelectValueKey(key);
    UndoManager.getInstance().addUndoEvent(new UndoEvent(this, getFieldId(), oldValueObj, value));
    oldValueObj = value;
}
Also used : UndoEvent(com.sldeditor.common.undo.UndoEvent)

Example 18 with UndoEvent

use of com.sldeditor.common.undo.UndoEvent in project sldeditor by robward-scisys.

the class FieldConfigFont method createUI.

/**
 * Creates the ui.
 */
/*
     * (non-Javadoc)
     * 
     * @see com.sldeditor.ui.detail.config.FieldConfigBase#createUI()
     */
@Override
public void createUI() {
    if (comboBox == null) {
        final UndoActionInterface parentObj = this;
        populateFontFamilyList();
        if (!fontFamilyList.isEmpty()) {
            defaultValue = fontFamilyList.get(0).getKey();
        }
        comboBox = new ValueComboBox();
        comboBox.initialiseSingle(fontFamilyList);
        int xPos = getXPos();
        comboBox.setBounds(xPos + BasePanel.WIDGET_X_START, 0, BasePanel.WIDGET_STANDARD_WIDTH, BasePanel.WIDGET_HEIGHT);
        FieldPanel fieldPanel = createFieldPanel(xPos, getLabel());
        fieldPanel.add(comboBox);
        comboBox.setSelectValueKey(defaultValue);
        comboBox.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent e) {
                ValueComboBox comboBox = (ValueComboBox) e.getSource();
                if (comboBox.getSelectedItem() != null) {
                    Object newValueObj = comboBox.getSelectedValue().getKey();
                    if ((oldValueObj == null) && comboBox.getItemCount() > 0) {
                        oldValueObj = comboBox.getFirstItem().getKey();
                    }
                    UndoManager.getInstance().addUndoEvent(new UndoEvent(parentObj, getFieldId(), oldValueObj, newValueObj));
                    oldValueObj = newValueObj;
                    valueUpdated();
                }
            }
        });
        if (!isValueOnly()) {
            setAttributeSelectionPanel(fieldPanel.internalCreateAttrButton(Font.class, this, isRasterSymbol()));
        }
    }
}
Also used : UndoEvent(com.sldeditor.common.undo.UndoEvent) ValueComboBox(com.sldeditor.ui.widgets.ValueComboBox) ActionListener(java.awt.event.ActionListener) ActionEvent(java.awt.event.ActionEvent) FieldPanel(com.sldeditor.ui.widgets.FieldPanel) UndoActionInterface(com.sldeditor.common.undo.UndoActionInterface) Font(org.geotools.styling.Font)

Example 19 with UndoEvent

use of com.sldeditor.common.undo.UndoEvent in project sldeditor by robward-scisys.

the class FieldConfigInlineFeature method populateField.

/**
 * Populate field.
 *
 * @param value the value
 */
@Override
public void populateField(UserLayer value) {
    String inlineFeaturesText = InlineFeatureUtils.getInlineFeaturesText(value);
    if (inlineGML != null) {
        inlineGML.setInlineFeatures(inlineFeaturesText);
    }
    if (inlineFeature != null) {
        inlineFeature.setInlineFeatures(value);
    }
    UndoManager.getInstance().addUndoEvent(new UndoEvent(this, getFieldId(), oldValueObj, new String(inlineFeaturesText)));
    oldValueObj = new String(inlineFeaturesText);
    valueUpdated();
}
Also used : UndoEvent(com.sldeditor.common.undo.UndoEvent)

Example 20 with UndoEvent

use of com.sldeditor.common.undo.UndoEvent in project sldeditor by robward-scisys.

the class FieldConfigColourMap method populateField.

/**
 * Populate field.
 *
 * @param value the value
 */
@Override
public void populateField(ColorMap value) {
    if (model != null) {
        if (value != null) {
            if (colourRampConfig != null) {
                colourRampConfig.populate(value);
            }
            model.populate(value);
            if (colourMapEntryPanel != null) {
                colourMapEntryPanel.setSelectedEntry(null);
            }
            UndoManager.getInstance().addUndoEvent(new UndoEvent(this, getFieldId(), oldValueObj, value));
            oldValueObj = 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