Search in sources :

Example 16 with UndoActionInterface

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

the class FieldConfigRange method createRow.

/**
 * Creates the row.
 *
 * @param fieldPanel the field panel
 * @param xPos the x pos
 * @param y the y coordinate
 * @param rangeConfig the range config
 * @param label the label
 */
private void createRow(FieldPanel fieldPanel, int xPos, int y, RangeData rangeConfig, String label) {
    final UndoActionInterface parentObj = this;
    if (configurationSet) {
        rangeConfig.spinner = new DecimalSpinner(rangeConfig.minValue, rangeConfig.maxValue, rangeConfig.stepSize, rangeConfig.noOfDecimalPlaces);
    } else {
        rangeConfig.spinner = new DecimalSpinner();
    }
    JLabel lbl = new JLabel(label);
    lbl.setHorizontalAlignment(SwingConstants.TRAILING);
    lbl.setBounds(xPos, y, BasePanel.LABEL_WIDTH, BasePanel.WIDGET_HEIGHT);
    fieldPanel.add(lbl);
    rangeConfig.spinner.setBounds(xPos + BasePanel.WIDGET_X_START, y, BasePanel.WIDGET_STANDARD_WIDTH, BasePanel.WIDGET_HEIGHT);
    fieldPanel.add(rangeConfig.spinner);
    rangeConfig.includedCheckBox = new JCheckBox(Localisation.getString(FieldConfigBase.class, "FieldConfigRange.included"));
    rangeConfig.includedCheckBox.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            uiInteraction(parentObj);
        }
    });
    rangeConfig.includedCheckBox.setBounds(rangeConfig.spinner.getX() + rangeConfig.spinner.getWidth() + 5, y, BasePanel.WIDGET_STANDARD_WIDTH, BasePanel.WIDGET_HEIGHT);
    fieldPanel.add(rangeConfig.includedCheckBox);
    rangeConfig.spinner.registerObserver(new SpinnerNotifyInterface() {

        @Override
        public void notify(double oldValue, double newValue) {
            uiInteraction(parentObj);
        }
    });
}
Also used : JCheckBox(javax.swing.JCheckBox) SpinnerNotifyInterface(com.sldeditor.ui.iface.SpinnerNotifyInterface) DecimalSpinner(com.sldeditor.ui.widgets.DecimalSpinner) ActionListener(java.awt.event.ActionListener) ActionEvent(java.awt.event.ActionEvent) JLabel(javax.swing.JLabel) UndoActionInterface(com.sldeditor.common.undo.UndoActionInterface)

Example 17 with UndoActionInterface

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

the class FieldConfigSlider method createUI.

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

            @Override
            public void stateChanged(ChangeEvent e) {
                JSlider source = (JSlider) e.getSource();
                Integer newValueObj = (int) source.getValue();
                UndoManager.getInstance().addUndoEvent(new UndoEvent(parentObj, getFieldId(), oldValueObj, newValueObj));
                oldValueObj = newValueObj;
                valueUpdated();
            }
        });
        if (!isValueOnly()) {
            setAttributeSelectionPanel(fieldPanel.internalCreateAttrButton(Double.class, this, isRasterSymbol()));
        }
    }
}
Also used : UndoEvent(com.sldeditor.common.undo.UndoEvent) ChangeEvent(javax.swing.event.ChangeEvent) JSlider(javax.swing.JSlider) ChangeListener(javax.swing.event.ChangeListener) FieldPanel(com.sldeditor.ui.widgets.FieldPanel) UndoActionInterface(com.sldeditor.common.undo.UndoActionInterface)

Example 18 with UndoActionInterface

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

the class FieldConfigDouble method createUI.

/**
 * Creates the ui.
 */
/*
     * (non-Javadoc)
     * 
     * @see com.sldeditor.ui.detail.config.FieldConfigBase#createUI()
     */
@Override
public void createUI() {
    if (spinner == null) {
        final UndoActionInterface parentObj = this;
        int xPos = getXPos();
        FieldPanel fieldPanel = createFieldPanel(xPos, getLabel());
        if (configurationSet) {
            spinner = new DecimalSpinner(minValue, maxValue, stepSize, noOfDecimalPlaces);
        } else {
            spinner = new DecimalSpinner();
        }
        spinner.setBounds(xPos + BasePanel.WIDGET_X_START, 0, BasePanel.WIDGET_STANDARD_WIDTH, BasePanel.WIDGET_HEIGHT);
        fieldPanel.add(spinner);
        if (!isValueOnly()) {
            setAttributeSelectionPanel(fieldPanel.internalCreateAttrButton(Double.class, this, isRasterSymbol()));
        }
        spinner.registerObserver(new SpinnerNotifyInterface() {

            @Override
            public void notify(double oldValue, double newValue) {
                Double oldValueObj = Double.valueOf(oldValue);
                Double newValueObj = Double.valueOf(newValue);
                UndoManager.getInstance().addUndoEvent(new UndoEvent(parentObj, getFieldId(), oldValueObj, newValueObj));
                valueUpdated();
            }
        });
    }
}
Also used : UndoEvent(com.sldeditor.common.undo.UndoEvent) SpinnerNotifyInterface(com.sldeditor.ui.iface.SpinnerNotifyInterface) DecimalSpinner(com.sldeditor.ui.widgets.DecimalSpinner) FieldPanel(com.sldeditor.ui.widgets.FieldPanel) UndoActionInterface(com.sldeditor.common.undo.UndoActionInterface)

Example 19 with UndoActionInterface

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

the class FieldConfigGeometryField method createUI.

/**
 * Creates the ui.
 */
/*
     * (non-Javadoc)
     * 
     * @see com.sldeditor.ui.detail.config.FieldConfigBase#createUI()
     */
@Override
public void createUI() {
    if (attributeComboBox == null) {
        final UndoActionInterface parentObj = this;
        int xPos = getXPos();
        FieldPanel fieldPanel = createFieldPanel(xPos, getLabel());
        attributeComboBox = new JComboBox<String>();
        attributeComboBox.setBounds(xPos + BasePanel.WIDGET_X_START, 0, BasePanel.WIDGET_STANDARD_WIDTH, BasePanel.WIDGET_HEIGHT);
        fieldPanel.add(attributeComboBox);
        populateAttributeComboBox();
        if (!isValueOnly()) {
            setAttributeSelectionPanel(fieldPanel.internalCreateAttrButton(Geometry.class, this, true));
        }
        attributeComboBox.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent e) {
                if (isAttributeComboBoxPopulated()) {
                    String newValueObj = (String) attributeComboBox.getSelectedItem();
                    UndoManager.getInstance().addUndoEvent(new UndoEvent(parentObj, "DataSourceAttribute", oldValueObj, newValueObj));
                    valueUpdated();
                }
            }
        });
    }
}
Also used : Geometry(com.vividsolutions.jts.geom.Geometry) 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)

Aggregations

UndoActionInterface (com.sldeditor.common.undo.UndoActionInterface)19 UndoEvent (com.sldeditor.common.undo.UndoEvent)16 ActionEvent (java.awt.event.ActionEvent)14 ActionListener (java.awt.event.ActionListener)14 FieldPanel (com.sldeditor.ui.widgets.FieldPanel)13 JCheckBox (javax.swing.JCheckBox)5 ValueComboBox (com.sldeditor.ui.widgets.ValueComboBox)4 JButton (javax.swing.JButton)4 JLabel (javax.swing.JLabel)4 JPanel (javax.swing.JPanel)4 SpinnerNotifyInterface (com.sldeditor.ui.iface.SpinnerNotifyInterface)3 ValueComboBoxData (com.sldeditor.ui.widgets.ValueComboBoxData)3 DecimalSpinner (com.sldeditor.ui.widgets.DecimalSpinner)2 Geometry (com.vividsolutions.jts.geom.Geometry)2 Dimension (java.awt.Dimension)2 FocusEvent (java.awt.event.FocusEvent)2 FocusListener (java.awt.event.FocusListener)2 ArrayList (java.util.ArrayList)2 JComboBox (javax.swing.JComboBox)2 JScrollPane (javax.swing.JScrollPane)2