Search in sources :

Example 1 with FieldPanel

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

the class ColourRampPanel method createFieldPanel.

/**
 * Creates the field panel.
 */
private void createFieldPanel() {
    JPanel tablePanel = new JPanel();
    tablePanel.setLayout(new BorderLayout());
    panel.add(tablePanel, BorderLayout.CENTER);
    JPanel dataPanel = new JPanel();
    tablePanel.add(dataPanel, BorderLayout.NORTH);
    dataPanel.setLayout(new BoxLayout(dataPanel, BoxLayout.Y_AXIS));
    minValueSpinner = new FieldConfigInteger(new FieldConfigCommonData(getClass(), FieldIdEnum.UNKNOWN, Localisation.getField(ColourRampConfigPanel.class, "ColourRampPanel.minValue"), true));
    minValueSpinner.createUI();
    FieldPanel fieldPanel = minValueSpinner.getPanel();
    dataPanel.add(fieldPanel);
    JButton resetValueButton = new JButton(Localisation.getString(ColourRampConfigPanel.class, "ColourRampPanel.reset"));
    minValueSpinner.addUI(resetValueButton, 20, BasePanel.WIDGET_BUTTON_WIDTH, BasePanel.WIDGET_HEIGHT);
    minValueSpinner.populateField(0);
    resetValueButton.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            if (parentObj != null) {
                ColourMapModel model = parentObj.getColourMapModel();
                populate(model.getColourMap());
            }
        }
    });
    maxValueSpinner = new FieldConfigInteger(new FieldConfigCommonData(getClass(), FieldIdEnum.UNKNOWN, Localisation.getField(ColourRampConfigPanel.class, "ColourRampPanel.maxValue"), true));
    maxValueSpinner.createUI();
    maxValueSpinner.populateField(100);
    dataPanel.add(maxValueSpinner.getPanel());
    JPanel buttonPanel = new JPanel();
    buttonPanel.setLayout(new FlowLayout(FlowLayout.CENTER));
    buttonPanel.setSize(BasePanel.FIELD_PANEL_WIDTH, BasePanel.WIDGET_HEIGHT);
    JButton applyButton = new JButton(Localisation.getString(ColourRampConfigPanel.class, "common.apply"));
    applyButton.setPreferredSize(new Dimension(BasePanel.WIDGET_BUTTON_WIDTH, BasePanel.WIDGET_HEIGHT));
    applyButton.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            if (parentObj != null) {
                ColourRampData data = new ColourRampData();
                data.setMaxValue(maxValueSpinner.getIntValue());
                data.setMinValue(minValueSpinner.getIntValue());
                data.setReverseColours(reverseCheckbox.isSelected());
                ValueComboBoxData selectedItem = (ValueComboBoxData) rampComboBox.getSelectedItem();
                ColourRamp colourRamp = colourRampCache.get(selectedItem.getKey());
                data.setColourRamp(colourRamp);
                parentObj.colourRampUpdate(data);
            }
        }
    });
    buttonPanel.add(applyButton);
    dataPanel.add(buttonPanel);
}
Also used : JPanel(javax.swing.JPanel) FieldConfigInteger(com.sldeditor.ui.detail.config.FieldConfigInteger) FlowLayout(java.awt.FlowLayout) ActionEvent(java.awt.event.ActionEvent) BoxLayout(javax.swing.BoxLayout) JButton(javax.swing.JButton) Dimension(java.awt.Dimension) ValueComboBoxData(com.sldeditor.ui.widgets.ValueComboBoxData) BorderLayout(java.awt.BorderLayout) ActionListener(java.awt.event.ActionListener) XMLTwoColourRamp(com.sldeditor.common.xml.ui.XMLTwoColourRamp) ColourRamp(com.sldeditor.colourramp.ColourRamp) FieldConfigCommonData(com.sldeditor.ui.detail.config.FieldConfigCommonData) FieldPanel(com.sldeditor.ui.widgets.FieldPanel) ColourRampConfigPanel(com.sldeditor.colourramp.ColourRampConfigPanel) ColourMapModel(com.sldeditor.ui.detail.config.colourmap.ColourMapModel)

Example 2 with FieldPanel

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

the class RuleDetails method createFilter.

/**
 * Creates the filter.
 *
 * @return the j panel
 */
private void createFilter() {
    FieldIdEnum filterFieldId = FieldIdEnum.FILTER;
    FieldConfigBase fieldConfig = fieldConfigManager.get(filterFieldId);
    if (fieldConfig != null) {
        FieldPanel fieldPanel = fieldConfig.getPanel();
        JButton btnEditFilter = new JButton(Localisation.getString(RuleDetails.class, "RuleDetails.edit"));
        btnEditFilter.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent e) {
                editFilter(filterFieldId);
            }
        });
        btnEditFilter.setBounds(WIDGET_X_START + WIDGET_EXTENDED_WIDTH, 0, WIDGET_BUTTON_WIDTH, WIDGET_HEIGHT);
        fieldPanel.add(btnEditFilter);
        JButton btnClearFilter = new JButton(Localisation.getString(RuleDetails.class, "RuleDetails.clear"));
        btnClearFilter.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent e) {
                clearFilter(filterFieldId);
            }
        });
        int x = btnEditFilter.getX() + btnEditFilter.getWidth() + 5;
        btnClearFilter.setBounds(x, 0, WIDGET_BUTTON_WIDTH, WIDGET_HEIGHT);
        fieldPanel.add(btnClearFilter);
    }
}
Also used : FieldConfigBase(com.sldeditor.ui.detail.config.FieldConfigBase) ActionListener(java.awt.event.ActionListener) ActionEvent(java.awt.event.ActionEvent) JButton(javax.swing.JButton) FieldIdEnum(com.sldeditor.common.xml.ui.FieldIdEnum) FieldPanel(com.sldeditor.ui.widgets.FieldPanel)

Example 3 with FieldPanel

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

the class MultiOptionGroup method createUI.

/**
 * Creates the ui.
 *
 * @param fieldConfigManager the field config manager
 * @param box the box
 * @param parent the parent
 * @param panelId the panel id
 */
public void createUI(GraphicPanelFieldManager fieldConfigManager, Box box, UpdateSymbolInterface parent, Class<?> panelId) {
    final UndoActionInterface parentObj = this;
    this.fieldConfigManager = fieldConfigManager;
    this.parentBox = box;
    this.parent = parent;
    this.panelId = panelId;
    int x = 2;
    box.add(GroupConfig.createSeparator());
    fieldPanel = new FieldPanel(0, "", BasePanel.WIDGET_HEIGHT * 2, false, null);
    // Set up title
    if (isOptional()) {
        groupTitleCheckbox = new JCheckBox(getLabel());
        groupTitleCheckbox.setBounds(x, 0, BasePanel.WIDGET_EXTENDED_WIDTH, BasePanel.WIDGET_HEIGHT);
        groupTitleCheckbox.setOpaque(true);
        fieldPanel.add(groupTitleCheckbox);
        multiOptionGroupEnabled = false;
        groupTitleCheckbox.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
                enable(groupTitleCheckbox.isSelected());
                if (parent != null) {
                    if (!Controller.getInstance().isPopulating()) {
                        parent.dataChanged(FieldIdEnum.UNKNOWN);
                    }
                }
            }
        });
    } else {
        JLabel groupTitle = new JLabel(getLabel());
        groupTitle.setBounds(x, 0, BasePanel.WIDGET_EXTENDED_WIDTH, BasePanel.WIDGET_HEIGHT);
        groupTitle.setOpaque(true);
        fieldPanel.add(groupTitle);
    }
    // Set up options in the drop down
    List<ValueComboBoxData> valueComboDataMap = new ArrayList<ValueComboBoxData>();
    for (OptionGroup optionGroup : optionList) {
        valueComboDataMap.add(new ValueComboBoxData(optionGroup.getId().toString(), optionGroup.getLabel(), panelId));
    }
    comboBox = new ValueComboBox();
    comboBox.initialiseSingle(valueComboDataMap);
    comboBox.setBounds(BasePanel.WIDGET_X_START, BasePanel.WIDGET_HEIGHT, BasePanel.WIDGET_STANDARD_WIDTH, BasePanel.WIDGET_HEIGHT);
    fieldPanel.add(comboBox);
    comboBox.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            optionSelected(parentBox, fieldConfigManager, fieldPanel, parentObj);
            if (parent != null) {
                if (!Controller.getInstance().isPopulating()) {
                    parent.dataChanged(FieldIdEnum.UNKNOWN);
                }
            }
        }
    });
    box.add(fieldPanel);
}
Also used : ActionEvent(java.awt.event.ActionEvent) ArrayList(java.util.ArrayList) JLabel(javax.swing.JLabel) UndoActionInterface(com.sldeditor.common.undo.UndoActionInterface) ValueComboBoxData(com.sldeditor.ui.widgets.ValueComboBoxData) JCheckBox(javax.swing.JCheckBox) ActionListener(java.awt.event.ActionListener) ValueComboBox(com.sldeditor.ui.widgets.ValueComboBox) FieldPanel(com.sldeditor.ui.widgets.FieldPanel)

Example 4 with FieldPanel

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

the class FieldConfigBoolean method createUI.

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

            public void actionPerformed(ActionEvent e) {
                boolean isSelected = checkBox.isSelected();
                Boolean oldValueObj = Boolean.valueOf(!isSelected);
                Boolean newValueObj = Boolean.valueOf(isSelected);
                UndoManager.getInstance().addUndoEvent(new UndoEvent(parentObj, getFieldId(), oldValueObj, newValueObj));
                valueUpdated();
            }
        });
        if (!isValueOnly()) {
            setAttributeSelectionPanel(fieldPanel.internalCreateAttrButton(Boolean.class, this, isRasterSymbol()));
        }
    }
}
Also used : JCheckBox(javax.swing.JCheckBox) 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 5 with FieldPanel

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

the class FieldConfigBoundingBox method createUI.

/**
 * Creates the ui.
 */
/*
     * (non-Javadoc)
     * 
     * @see com.sldeditor.ui.detail.config.FieldConfigBase#createUI()
     */
@Override
public void createUI() {
    if (xMinTextField == null) {
        int xPos = getXPos();
        FieldPanel fieldPanel = createFieldPanel(xPos, "");
        int row = 0;
        xMinTextField = createRow(Localisation.getField(FieldConfigBase.class, "FieldConfigBoundingBox.minx"), xPos, fieldPanel, row);
        xMaxTextField = createRow(Localisation.getField(FieldConfigBase.class, "FieldConfigBoundingBox.maxx"), xPos, fieldPanel, ++row);
        yMinTextField = createRow(Localisation.getField(FieldConfigBase.class, "FieldConfigBoundingBox.miny"), xPos, fieldPanel, ++row);
        yMaxTextField = createRow(Localisation.getField(FieldConfigBase.class, "FieldConfigBoundingBox.maxy"), xPos, fieldPanel, ++row);
        crsComboBox = createCRSList(Localisation.getField(FieldConfigBase.class, "FieldConfigBoundingBox.crs"), xPos, fieldPanel, ++row);
        Dimension preferredSize = new Dimension((int) fieldPanel.getPreferredSize().getWidth(), crsComboBox.getY() + crsComboBox.getHeight());
        fieldPanel.setPreferredSize(preferredSize);
        if (!isValueOnly()) {
            setAttributeSelectionPanel(fieldPanel.internalCreateAttrButton(Boolean.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