Search in sources :

Example 6 with UndoActionInterface

use of com.sldeditor.common.undo.UndoActionInterface 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 7 with UndoActionInterface

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

the class FieldConfigDSProperties method createUI.

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

        public void actionPerformed(ActionEvent e) {
            if (isAttributeComboBoxPopulated()) {
                if (comboBox.getSelectedItem() != null) {
                    String newValueObj = new String((String) comboBox.getSelectedItem());
                    UndoManager.getInstance().addUndoEvent(new UndoEvent(parentObj, getFieldId(), oldValueObj, newValueObj));
                    oldValueObj = new String(newValueObj);
                    valueUpdated();
                }
            }
        }
    });
}
Also used : 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 8 with UndoActionInterface

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

the class FieldConfigEnum 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;
        List<ValueComboBoxData> dataList = new ArrayList<ValueComboBoxData>();
        for (String key : keyList) {
            dataList.add(new ValueComboBoxData(key, valueMap.get(key), getPanelId()));
        }
        if (!dataList.isEmpty()) {
            defaultValue = dataList.get(0).getKey();
        }
        int xPos = getXPos();
        comboBox = new ValueComboBox();
        comboBox.initialiseSingle(dataList);
        comboBox.setBounds(xPos + BasePanel.WIDGET_X_START, 0, isValueOnly() ? BasePanel.WIDGET_EXTENDED_WIDTH : BasePanel.WIDGET_STANDARD_WIDTH, BasePanel.WIDGET_HEIGHT);
        FieldPanel fieldPanel = createFieldPanel(xPos, getLabel());
        fieldPanel.add(comboBox);
        if (!isValueOnly()) {
            setAttributeSelectionPanel(fieldPanel.internalCreateAttrButton(String.class, this, isRasterSymbol()));
        }
        if (dataList != null) {
            for (ValueComboBoxData data : dataList) {
                this.comboDataMap.put(data.getKey(), data);
            }
        }
        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();
                }
            }
        });
    }
}
Also used : UndoEvent(com.sldeditor.common.undo.UndoEvent) ValueComboBox(com.sldeditor.ui.widgets.ValueComboBox) ActionListener(java.awt.event.ActionListener) ActionEvent(java.awt.event.ActionEvent) ArrayList(java.util.ArrayList) FieldPanel(com.sldeditor.ui.widgets.FieldPanel) UndoActionInterface(com.sldeditor.common.undo.UndoActionInterface) ValueComboBoxData(com.sldeditor.ui.widgets.ValueComboBoxData)

Example 9 with UndoActionInterface

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

the class FieldConfigGeometry method createUI.

/**
 * Creates the ui.
 */
/*
     * (non-Javadoc)
     * 
     * @see com.sldeditor.ui.detail.config.FieldConfigBase#createUI()
     */
@Override
public void createUI() {
    if (textField == null) {
        final UndoActionInterface parentObj = this;
        int xPos = getXPos();
        FieldPanel fieldPanel = createFieldPanel(xPos, getLabel());
        textField = new JTextField();
        textField.setBounds(xPos + BasePanel.WIDGET_X_START, 0, 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();
                }
            }
        });
        if (buttonText != null) {
            final JButton buttonExternal = new JButton(buttonText);
            buttonExternal.addActionListener(new ActionListener() {

                public void actionPerformed(ActionEvent e) {
                    if (buttonPressedListenerList != null) {
                        // CHECKSTYLE:OFF
                        for (FieldConfigStringButtonInterface listener : buttonPressedListenerList) {
                            listener.buttonPressed(buttonExternal);
                        }
                    // CHECKSTYLE:ON
                    }
                }
            });
            int buttonWidth = 26;
            int padding = 3;
            buttonExternal.setBounds(xPos + textField.getX() - buttonWidth - padding, 0, buttonWidth, BasePanel.WIDGET_HEIGHT);
            fieldPanel.add(buttonExternal);
        }
        if (!isValueOnly()) {
            setAttributeSelectionPanel(fieldPanel.internalCreateAttrButton(Geometry.class, this, isRasterSymbol()));
        }
    }
}
Also used : UndoEvent(com.sldeditor.common.undo.UndoEvent) ActionEvent(java.awt.event.ActionEvent) JButton(javax.swing.JButton) JTextField(javax.swing.JTextField) FocusEvent(java.awt.event.FocusEvent) UndoActionInterface(com.sldeditor.common.undo.UndoActionInterface) Geometry(com.vividsolutions.jts.geom.Geometry) ActionListener(java.awt.event.ActionListener) FieldPanel(com.sldeditor.ui.widgets.FieldPanel) FocusListener(java.awt.event.FocusListener)

Example 10 with UndoActionInterface

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

the class FieldConfigInteger 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());
        spinner = new IntegerSpinner(minValue, maxValue, stepSize);
        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) {
                Integer oldValueObj = Double.valueOf(oldValue).intValue();
                Integer newValueObj = Double.valueOf(newValue).intValue();
                UndoManager.getInstance().addUndoEvent(new UndoEvent(parentObj, getFieldId(), oldValueObj, newValueObj));
                valueUpdated();
            }
        });
    }
}
Also used : UndoEvent(com.sldeditor.common.undo.UndoEvent) SpinnerNotifyInterface(com.sldeditor.ui.iface.SpinnerNotifyInterface) FieldPanel(com.sldeditor.ui.widgets.FieldPanel) IntegerSpinner(com.sldeditor.ui.widgets.IntegerSpinner) 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