Search in sources :

Example 11 with UndoEvent

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

the class PrefManager method setPrefData.

/**
 * Sets the pref data.
 *
 * @param newPrefData the new pref data
 */
public void setPrefData(PrefData newPrefData) {
    oldValueObj = prefData.clone();
    setUseAntiAlias(newPrefData.isUseAntiAlias());
    setVendorOptionList(newPrefData.getVendorOptionVersionList(), true);
    setUiLayoutClass(newPrefData.getUiLayoutClass());
    setBackgroundColour(newPrefData.getBackgroundColour());
    setLastFolderViewed(newPrefData.isSaveLastFolderView(), newPrefData.getLastViewedKey(), newPrefData.getLastFolderViewed());
    setCheckAppVersionOnStartUp(newPrefData.isCheckAppVersionOnStartUp());
    UndoManager.getInstance().addUndoEvent(new UndoEvent(this, "Preferences", oldValueObj, newPrefData));
}
Also used : UndoEvent(com.sldeditor.common.undo.UndoEvent)

Example 12 with UndoEvent

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

the class AttributeSelection method createUI.

/**
 * Creates the ui.
 *
 * @param expectedDataType the expected data type
 */
@SuppressWarnings({ "unchecked" })
private void createUI(Class<?> expectedDataType) {
    final UndoActionInterface thisObj = this;
    outerPanel = new JPanel();
    add(outerPanel, BorderLayout.CENTER);
    outerPanel.setLayout(new CardLayout(5, 0));
    valuePanel = createValuePanel(false);
    expressionPanel = createExpressionPanel(expectedDataType);
    dataSourceAttributePanel = createDataSourceAttributePanel(expectedDataType);
    attributeChooserComboBox = new JComboBox<String>();
    attributeChooserComboBox.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            JComboBox<String> cb = (JComboBox<String>) e.getSource();
            String selected = (String) cb.getSelectedItem();
            showPanel(selected);
            if ((oldValueObj == null) && cb.getItemCount() > 0) {
                oldValueObj = cb.getItemAt(0);
            }
            UndoManager.getInstance().addUndoEvent(new UndoEvent(thisObj, "DataSourceAttribute", oldValueObj, selected));
            updateSymbol();
        }
    });
    add(attributeChooserComboBox, BorderLayout.WEST);
}
Also used : UndoEvent(com.sldeditor.common.undo.UndoEvent) JPanel(javax.swing.JPanel) CardLayout(java.awt.CardLayout) ActionListener(java.awt.event.ActionListener) JComboBox(javax.swing.JComboBox) ActionEvent(java.awt.event.ActionEvent) UndoActionInterface(com.sldeditor.common.undo.UndoActionInterface)

Example 13 with UndoEvent

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

the class GroupConfig method createTitle.

/**
 * Creates the title components.
 *
 * @param box the box to add the components to
 * @param parent the parent object to be called when fields are changed
 */
@Override
public void createTitle(Box box, UpdateSymbolInterface parent) {
    this.parentBox = box;
    if (isShowLabel()) {
        Component separator = createSeparator();
        componentList.add(createSeparator());
        box.add(separator);
        Component component;
        if (isOptional()) {
            final UndoActionInterface parentObj = this;
            groupCheckbox = new JCheckBox(getLabel());
            component = groupCheckbox;
            groupCheckbox.setBounds(0, 0, FULL_WIDTH, BasePanel.WIDGET_HEIGHT);
            groupCheckbox.addActionListener(new ActionListener() {

                public void actionPerformed(ActionEvent e) {
                    enableSubGroups(groupCheckbox.isSelected());
                    boolean isSelected = groupCheckbox.isSelected();
                    Boolean oldValueObj = Boolean.valueOf(!isSelected);
                    Boolean newValueObj = Boolean.valueOf(isSelected);
                    UndoManager.getInstance().addUndoEvent(new UndoEvent(parentObj, "Group : " + getId(), oldValueObj, newValueObj));
                    if (parent != null) {
                        parent.dataChanged(FieldIdEnum.UNKNOWN);
                    }
                }
            });
        } else {
            groupTitle = new JLabel(getLabel());
            groupTitle.setBounds(0, 0, FULL_WIDTH, BasePanel.WIDGET_HEIGHT);
            groupTitle.setOpaque(true);
            component = groupTitle;
        }
        // Make sure label/check box appears left aligned within the group
        JPanel panel = new JPanel();
        panel.setLayout(null);
        Dimension size = new Dimension(FULL_WIDTH, BasePanel.WIDGET_HEIGHT);
        panel.setPreferredSize(size);
        panel.setMaximumSize(size);
        panel.setSize(size);
        panel.add(component);
        box.add(panel);
        componentList.add(panel);
    }
}
Also used : JCheckBox(javax.swing.JCheckBox) UndoEvent(com.sldeditor.common.undo.UndoEvent) JPanel(javax.swing.JPanel) ActionListener(java.awt.event.ActionListener) ActionEvent(java.awt.event.ActionEvent) JLabel(javax.swing.JLabel) Dimension(java.awt.Dimension) Component(java.awt.Component) UndoActionInterface(com.sldeditor.common.undo.UndoActionInterface)

Example 14 with UndoEvent

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

the class MultiOptionGroup method optionSelected.

/**
 * Option selected.
 *
 * @param box the box
 * @param fieldConfigManager the field config manager
 * @param panel the panel
 * @param parentObj the parent obj
 */
private void optionSelected(Box box, GraphicPanelFieldManager fieldConfigManager, FieldPanel panel, UndoActionInterface parentObj) {
    if ((comboBox != null) && (comboBox.getSelectedItem() != null)) {
        ValueComboBoxData value = comboBox.getSelectedValue();
        if (value != null) {
            // Remove the fields from the previous selection
            removeOptionFields(box, fieldConfigManager);
            optionPanel = new JPanel();
            optionPanel.setLayout(new BorderLayout());
            Box optionBox = Box.createVerticalBox();
            optionPanel.add(optionBox, BorderLayout.CENTER);
            int index = findOptionPanel(box, panel);
            OptionGroup optionGroup = optionMap.get(value.getKey());
            populateOptionGroup(fieldConfigManager, optionBox, optionGroup.getGroupList());
            box.add(optionPanel, index + 1);
            Object newValueObj = value.getKey();
            if ((oldValueObj == null) && (comboBox.getItemCount() > 0)) {
                oldValueObj = comboBox.getFirstItem().getKey();
            }
            UndoManager.getInstance().addUndoEvent(new UndoEvent(parentObj, "Multi option : " + getId(), oldValueObj, newValueObj));
            oldValueObj = newValueObj;
            box.revalidate();
        }
    }
}
Also used : UndoEvent(com.sldeditor.common.undo.UndoEvent) JPanel(javax.swing.JPanel) BorderLayout(java.awt.BorderLayout) Box(javax.swing.Box) ValueComboBox(com.sldeditor.ui.widgets.ValueComboBox) JCheckBox(javax.swing.JCheckBox) ValueComboBoxData(com.sldeditor.ui.widgets.ValueComboBoxData)

Example 15 with UndoEvent

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

the class FieldConfigBoolean method populateField.

/**
 * Populate field.
 *
 * @param value the value
 */
@Override
public void populateField(Boolean value) {
    if ((value != null) && (this.checkBox != null)) {
        checkBox.setSelected(value);
        UndoManager.getInstance().addUndoEvent(new UndoEvent(this, getFieldId(), oldValueObj, value));
        oldValueObj = value;
    }
}
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