Search in sources :

Example 11 with UndoActionInterface

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

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

the class FieldConfigTransformation 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();
        int width = BasePanel.FIELD_PANEL_WIDTH - xPos - 20;
        int height = BasePanel.WIDGET_HEIGHT * (NO_OF_ROWS - 1);
        textField = new JTextArea();
        textField.setBounds(xPos, BasePanel.WIDGET_HEIGHT, width, height);
        textField.setEditable(false);
        JScrollPane scroll = new JScrollPane(textField);
        scroll.setBounds(xPos, BasePanel.WIDGET_HEIGHT, width, height);
        scroll.setAutoscrolls(true);
        FieldPanel fieldPanel = createFieldPanel(xPos, BasePanel.WIDGET_HEIGHT * NO_OF_ROWS, getLabel());
        fieldPanel.add(scroll);
        // 
        // Edit button
        // 
        final JButton buttonEdit = new JButton(editButtonText);
        buttonEdit.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent e) {
                ProcessFunction expression = showTransformationDialog(processFunction);
                if (expression != null) {
                    ProcessFunction newValueObj = processFunction;
                    processFunction = expression;
                    textField.setText(ParameterFunctionUtils.getString(processFunction));
                    UndoManager.getInstance().addUndoEvent(new UndoEvent(parentObj, getFieldId(), oldValueObj, newValueObj));
                    valueUpdated();
                }
            }
        });
        buttonEdit.setBounds(xPos + BasePanel.WIDGET_X_START, 0, BasePanel.WIDGET_BUTTON_WIDTH, BasePanel.WIDGET_HEIGHT);
        fieldPanel.add(buttonEdit);
        // 
        // Clear button
        // 
        final JButton buttonClear = new JButton(clearButtonText);
        buttonClear.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent e) {
                processFunction = null;
                textField.setText("");
                UndoManager.getInstance().addUndoEvent(new UndoEvent(parentObj, getFieldId(), oldValueObj, null));
                valueUpdated();
            }
        });
        buttonClear.setBounds((int) buttonEdit.getBounds().getMaxX() + 5, 0, BasePanel.WIDGET_BUTTON_WIDTH, BasePanel.WIDGET_HEIGHT);
        fieldPanel.add(buttonClear);
    }
}
Also used : JScrollPane(javax.swing.JScrollPane) ProcessFunction(org.geotools.process.function.ProcessFunction) UndoEvent(com.sldeditor.common.undo.UndoEvent) JTextArea(javax.swing.JTextArea) ActionListener(java.awt.event.ActionListener) ActionEvent(java.awt.event.ActionEvent) JButton(javax.swing.JButton) FieldPanel(com.sldeditor.ui.widgets.FieldPanel) UndoActionInterface(com.sldeditor.common.undo.UndoActionInterface)

Example 13 with UndoActionInterface

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

the class ColourRampPanel method createTopPanel.

/**
 * Creates the top panel.
 */
private void createTopPanel() {
    final UndoActionInterface undoObj = this;
    JPanel topPanel = new JPanel();
    topPanel.setPreferredSize(new Dimension(BasePanel.FIELD_PANEL_WIDTH, BasePanel.WIDGET_HEIGHT));
    topPanel.setLayout(null);
    panel.add(topPanel, BorderLayout.NORTH);
    List<ValueComboBoxData> dataList = populateColourRamps(false);
    rampComboBox = new ValueComboBox();
    rampComboBox.initialiseSingle(dataList);
    rampComboBox.setBounds(BasePanel.WIDGET_X_START, 0, BasePanel.WIDGET_EXTENDED_WIDTH, BasePanel.WIDGET_HEIGHT);
    topPanel.add(rampComboBox);
    rampComboBox.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            if (!isPopulating()) {
                Integer newValueObj = rampComboBox.getSelectedIndex();
                UndoManager.getInstance().addUndoEvent(new UndoEvent(undoObj, FieldIdEnum.COLOUR_RAMP_COLOUR, oldColourRampIndex, newValueObj));
                oldColourRampIndex = newValueObj;
            }
        }
    });
    reverseCheckbox = new JCheckBox(Localisation.getString(ColourRampConfigPanel.class, "ColourRampPanel.reverse"));
    reverseCheckbox.setBounds(rampComboBox.getX() + rampComboBox.getWidth() + 20, 0, BasePanel.WIDGET_STANDARD_WIDTH, BasePanel.WIDGET_HEIGHT);
    reverseCheckbox.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            boolean isSelected = reverseCheckbox.isSelected();
            Boolean oldValueObj = Boolean.valueOf(!isSelected);
            Boolean newValueObj = Boolean.valueOf(isSelected);
            UndoManager.getInstance().addUndoEvent(new UndoEvent(undoObj, FieldIdEnum.COLOUR_RAMP_REVERSE, oldValueObj, newValueObj));
            reverseColourRamp(isSelected);
        }
    });
    topPanel.add(reverseCheckbox);
}
Also used : UndoEvent(com.sldeditor.common.undo.UndoEvent) JPanel(javax.swing.JPanel) ActionEvent(java.awt.event.ActionEvent) Dimension(java.awt.Dimension) UndoActionInterface(com.sldeditor.common.undo.UndoActionInterface) ValueComboBoxData(com.sldeditor.ui.widgets.ValueComboBoxData) FieldConfigInteger(com.sldeditor.ui.detail.config.FieldConfigInteger) JCheckBox(javax.swing.JCheckBox) ValueComboBox(com.sldeditor.ui.widgets.ValueComboBox) ActionListener(java.awt.event.ActionListener)

Example 14 with UndoActionInterface

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

the class FieldConfigBoundingBox method createRow.

/**
 * Creates the row.
 *
 * @param label the label
 * @param xPos the x pos
 * @param fieldPanel the field panel
 * @param row the row
 * @return the j text field
 */
private JTextField createRow(String label, int xPos, FieldPanel fieldPanel, int row) {
    final UndoActionInterface parentObj = this;
    JLabel lbl = new JLabel(label);
    lbl.setHorizontalAlignment(SwingConstants.TRAILING);
    lbl.setBounds(xPos, getRowY(row), BasePanel.LABEL_WIDTH, BasePanel.WIDGET_HEIGHT);
    fieldPanel.add(lbl);
    JTextField textField = new JTextField();
    textField.setBounds(xPos + BasePanel.WIDGET_X_START, getRowY(row), 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();
            }
        }
    });
    return textField;
}
Also used : UndoEvent(com.sldeditor.common.undo.UndoEvent) JLabel(javax.swing.JLabel) JTextField(javax.swing.JTextField) FocusListener(java.awt.event.FocusListener) FocusEvent(java.awt.event.FocusEvent) UndoActionInterface(com.sldeditor.common.undo.UndoActionInterface)

Example 15 with UndoActionInterface

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

the class FieldConfigColour method createUI.

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

            @Override
            public void notify(String colourString, double opacity) {
                Color newValueObj = colourButton.getColour();
                UndoManager.getInstance().addUndoEvent(new UndoEvent(parentObj, getFieldId(), oldValueObj, newValueObj));
                oldValueObj = newValueObj;
                valueUpdated();
            }
        });
    }
}
Also used : UndoEvent(com.sldeditor.common.undo.UndoEvent) Color(java.awt.Color) ColourButton(com.sldeditor.ui.widgets.ColourButton) FieldPanel(com.sldeditor.ui.widgets.FieldPanel) UndoActionInterface(com.sldeditor.common.undo.UndoActionInterface) ColourNotifyInterface(com.sldeditor.ui.iface.ColourNotifyInterface)

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