Search in sources :

Example 11 with FieldPanel

use of com.sldeditor.ui.widgets.FieldPanel 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 12 with FieldPanel

use of com.sldeditor.ui.widgets.FieldPanel 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)

Example 13 with FieldPanel

use of com.sldeditor.ui.widgets.FieldPanel in project sldeditor by robward-scisys.

the class FieldConfigString 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 TextFieldPropertyChange();
        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.addPropertyChangeListener(TextFieldPropertyChange.TEXT_PROPERTY, new PropertyChangeListener() {

            /*
                         * (non-Javadoc)
                         * 
                         * @see java.beans.PropertyChangeListener#propertyChange(java.beans.PropertyChangeEvent)
                         */
            @Override
            public void propertyChange(PropertyChangeEvent evt) {
                String originalValue = (String) evt.getOldValue();
                String newValueObj = (String) evt.getNewValue();
                if ((originalValue.compareTo(newValueObj) != 0)) {
                    if (!suppressUpdateOnSet) {
                        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(String.class, this, isRasterSymbol()));
        }
    }
}
Also used : UndoEvent(com.sldeditor.common.undo.UndoEvent) PropertyChangeEvent(java.beans.PropertyChangeEvent) PropertyChangeListener(java.beans.PropertyChangeListener) ActionEvent(java.awt.event.ActionEvent) JButton(javax.swing.JButton) UndoActionInterface(com.sldeditor.common.undo.UndoActionInterface) ActionListener(java.awt.event.ActionListener) FieldPanel(com.sldeditor.ui.widgets.FieldPanel)

Example 14 with FieldPanel

use of com.sldeditor.ui.widgets.FieldPanel in project sldeditor by robward-scisys.

the class FieldConfigSymbolType method createUI.

/**
 * Creates the ui.
 */
@Override
public void createUI() {
    if (comboBox == null) {
        int xPos = getXPos();
        comboBox = new MenuComboBox(this);
        comboBox.setBounds(xPos + BasePanel.WIDGET_X_START, 0, BasePanel.WIDGET_STANDARD_WIDTH, BasePanel.WIDGET_HEIGHT);
        // Register for changes in vendor option selections
        VendorOptionManager.getInstance().addVendorOptionListener(comboBox);
        FieldPanel fieldPanel = createFieldPanel(xPos, getLabel());
        fieldPanel.add(comboBox);
        if (!isValueOnly()) {
            setAttributeSelectionPanel(fieldPanel.internalCreateAttrButton(String.class, this, isRasterSymbol()));
        }
        // Create
        containingPanel = new JPanel();
        containingPanel.setLayout(new CardLayout());
        containingPanel.setBounds(0, 0, BasePanel.WIDGET_STANDARD_WIDTH, BasePanel.WIDGET_HEIGHT * 3);
        addCustomPanel(containingPanel);
    }
}
Also used : JPanel(javax.swing.JPanel) CardLayout(java.awt.CardLayout) MenuComboBox(com.sldeditor.ui.menucombobox.MenuComboBox) FieldPanel(com.sldeditor.ui.widgets.FieldPanel)

Example 15 with FieldPanel

use of com.sldeditor.ui.widgets.FieldPanel in project sldeditor by robward-scisys.

the class FieldConfigTimePeriod method createUI.

/**
 * Creates the ui.
 */
@Override
public void createUI() {
    if (!start.areFieldsConfigured()) {
        FieldPanel fieldPanel = createFieldPanel(getXPos(), getLabel());
        createUIPanel(fieldPanel, start, 0, Localisation.getString(FieldConfigBase.class, "FieldConfigTimePeriod.from"));
        createUIPanel(fieldPanel, end, 1, Localisation.getString(FieldConfigBase.class, "FieldConfigTimePeriod.to"));
        Dimension preferredSize = new Dimension((int) fieldPanel.getPreferredSize().getWidth(), end.panel.getY() + end.panel.getHeight());
        fieldPanel.setPreferredSize(preferredSize);
        if (!isValueOnly()) {
            setAttributeSelectionPanel(fieldPanel.internalCreateAttrButton(Double.class, this, isRasterSymbol()));
        }
    }
}
Also used : Dimension(java.awt.Dimension) FieldPanel(com.sldeditor.ui.widgets.FieldPanel)

Aggregations

FieldPanel (com.sldeditor.ui.widgets.FieldPanel)31 UndoActionInterface (com.sldeditor.common.undo.UndoActionInterface)13 UndoEvent (com.sldeditor.common.undo.UndoEvent)12 ActionEvent (java.awt.event.ActionEvent)12 ActionListener (java.awt.event.ActionListener)12 Dimension (java.awt.Dimension)9 BorderLayout (java.awt.BorderLayout)6 JButton (javax.swing.JButton)6 FieldConfigBase (com.sldeditor.ui.detail.config.FieldConfigBase)3 ValueComboBox (com.sldeditor.ui.widgets.ValueComboBox)3 ValueComboBoxData (com.sldeditor.ui.widgets.ValueComboBoxData)3 ArrayList (java.util.ArrayList)3 JScrollPane (javax.swing.JScrollPane)3 ColourRampConfigPanel (com.sldeditor.colourramp.ColourRampConfigPanel)2 SpinnerNotifyInterface (com.sldeditor.ui.iface.SpinnerNotifyInterface)2 Geometry (com.vividsolutions.jts.geom.Geometry)2 JCheckBox (javax.swing.JCheckBox)2 JPanel (javax.swing.JPanel)2 JTextArea (javax.swing.JTextArea)2 ChangeEvent (javax.swing.event.ChangeEvent)2