Search in sources :

Example 31 with UndoEvent

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

the class FieldConfigSymbolType method optionSelected.

/**
 * Symbol type menu option selected.
 *
 * @param selectedData the selected data
 */
/*
     * (non-Javadoc)
     * 
     * @see
     * com.sldeditor.ui.menucombobox.ValueComboBoxDataSelectedInterface#optionSelected(com.sldeditor
     * .ui.ValueComboBoxData)
     */
@Override
public void optionSelected(ValueComboBoxData selectedData) {
    if (selectedData != null) {
        String newValueObj = selectedData.getKey();
        // Show the correct panel in the card layout for the selected symbol type
        CardLayout cl = (CardLayout) (containingPanel.getLayout());
        String name = selectedData.getPanelId().getName();
        cl.show(containingPanel, name);
        FieldConfigBase fieldConfig = fieldConfigMap.get(selectedData.getPanelId());
        if (fieldConfig == null) {
            ConsoleManager.getInstance().error(this, "Failed to find field config for panel id :" + selectedData.getPanelId());
        } else {
            fieldConfig.justSelected();
            JPanel p = fieldConfig.getPanel();
            Dimension preferredSize = null;
            if (p.isPreferredSizeSet()) {
                preferredSize = p.getPreferredSize();
            } else {
                preferredSize = new Dimension(BasePanel.FIELD_PANEL_WIDTH, BasePanel.WIDGET_HEIGHT);
            }
            containingPanel.setPreferredSize(preferredSize);
            if (oldValueObj == null) {
                oldValueObj = comboBox.getDefaultValue();
            }
            UndoManager.getInstance().addUndoEvent(new UndoEvent(this, getFieldId(), oldValueObj, newValueObj));
            oldValueObj = new String(newValueObj);
            if (symbolSelectedListener != null) {
                logger.debug(String.format("Field %s selected %s", getFieldId(), selectedData.getKey()));
                symbolSelectedListener.optionSelected(selectedData.getPanelId(), selectedData.getKey());
            } else {
                valueUpdated();
            }
        }
    }
}
Also used : UndoEvent(com.sldeditor.common.undo.UndoEvent) CardLayout(java.awt.CardLayout) JPanel(javax.swing.JPanel) Dimension(java.awt.Dimension)

Example 32 with UndoEvent

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

the class FieldConfigSortBy method populateField.

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

Example 33 with UndoEvent

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

the class FieldConfigSortBy method sortByUpdated.

/*
     * (non-Javadoc)
     * 
     * @see
     * com.sldeditor.ui.detail.config.sortby.SortByUpdateInterface#sortByUpdated(java.lang.String)
     */
@Override
public void sortByUpdated(String sortByString) {
    if (!Controller.getInstance().isPopulating()) {
        UndoManager.getInstance().addUndoEvent(new UndoEvent(this, getFieldId(), oldValueObj, new String(sortByString)));
        oldValueObj = new String(sortByString);
        valueUpdated();
    }
}
Also used : UndoEvent(com.sldeditor.common.undo.UndoEvent)

Example 34 with UndoEvent

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

the class ExternalGraphicDetails method userSelectedFileURL.

/**
 * User selected file URL.
 *
 * @param url the url
 */
protected void userSelectedFileURL(URL url) {
    if (url != null) {
        externalURL = url;
        UndoManager.getInstance().addUndoEvent(new UndoEvent(this, FieldIdEnum.EXTERNAL_GRAPHIC, oldValueObj, externalURL));
        oldValueObj = externalURL;
        lastURLValue = RelativePath.convert(externalURL, useRelativePaths);
        fieldConfigVisitor.populateTextField(FieldIdEnum.EXTERNAL_GRAPHIC, lastURLValue);
        updateSymbol();
    }
}
Also used : UndoEvent(com.sldeditor.common.undo.UndoEvent)

Example 35 with UndoEvent

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

the class ExternalGraphicDetails method setValue.

/**
 * Sets the value.
 *
 * @param externalGraphic the new value
 */
public void setValue(ExternalGraphicImpl externalGraphic) {
    if (externalGraphic != null) {
        try {
            externalURL = externalGraphic.getLocation();
        } catch (MalformedURLException e) {
            ConsoleManager.getInstance().exception(this, e);
        }
        UndoManager.getInstance().addUndoEvent(new UndoEvent(this, FieldIdEnum.EXTERNAL_GRAPHIC, oldValueObj, externalURL));
        oldValueObj = externalURL;
        String path = RelativePath.convert(externalURL, useRelativePaths);
        populateExpression(path);
    }
}
Also used : UndoEvent(com.sldeditor.common.undo.UndoEvent) MalformedURLException(java.net.MalformedURLException)

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