Search in sources :

Example 1 with UndoActionInterface

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

the class DataSourceConfigPanel method createTable.

/**
 * Creates the table.
 *
 * @return the component
 */
private Component createTable() {
    final UndoActionInterface parentObj = this;
    dataModel = new DataSourceAttributeModel();
    dataModel.addTableModelListener(new TableModelListener() {

        /**
         * Table changed.
         *
         * @param arg0 the arg0
         */
        @Override
        public void tableChanged(TableModelEvent arg0) {
            if (!isPopulatingTable()) {
                dataChanged = true;
                updateButtonState();
            }
        }
    });
    table = new JTable();
    table.setModel(dataModel);
    table.getSelectionModel().addListSelectionListener(new ListSelectionListener() {

        @Override
        public void valueChanged(ListSelectionEvent arg0) {
            updateButtonState();
        }
    });
    TableColumn tmpColum = table.getColumnModel().getColumn(1);
    JComboBox<String> comboBox = new JComboBox<String>(dataModel.getTypeData());
    DefaultCellEditor defaultCellEditor = new DefaultCellEditor(comboBox);
    tmpColum.setCellEditor(defaultCellEditor);
    tmpColum.setCellRenderer(new ComboBoxCellRenderer(comboBox));
    JPanel buttonPanel = new JPanel();
    FlowLayout flowLayout = (FlowLayout) buttonPanel.getLayout();
    flowLayout.setHgap(1);
    flowLayout.setAlignment(FlowLayout.TRAILING);
    add(buttonPanel, BorderLayout.SOUTH);
    btnDisconnect = new JButton(Localisation.getString(DataSourceConfigPanel.class, "DataSourceConfigPanel.disconnect"));
    btnDisconnect.setEnabled(false);
    btnDisconnect.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            SLDEditorFile.getInstance().getSLDData().setDataSourceProperties(DataSourceConnectorFactory.getNoDataSource());
            applyData(parentObj);
        }
    });
    buttonPanel.add(btnDisconnect);
    btnAddField = new JButton(Localisation.getString(DataSourceConfigPanel.class, "DataSourceConfigPanel.add"));
    btnAddField.setEnabled(false);
    btnAddField.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            addNewField();
        }
    });
    buttonPanel.add(btnAddField);
    btnRemoveField = new JButton(Localisation.getString(DataSourceConfigPanel.class, "DataSourceConfigPanel.remove"));
    btnRemoveField.setEnabled(false);
    btnRemoveField.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            removeField();
        }
    });
    buttonPanel.add(btnRemoveField);
    btnApply = new JButton(Localisation.getString(DataSourceConfigPanel.class, "common.apply"));
    btnApply.setEnabled(false);
    btnApply.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            applyData(parentObj);
        }
    });
    buttonPanel.add(btnApply);
    btnCancel = new JButton(Localisation.getString(DataSourceConfigPanel.class, "common.cancel"));
    btnCancel.setEnabled(false);
    btnCancel.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            cancelData();
        }
    });
    buttonPanel.add(btnCancel);
    JScrollPane scrollPane = new JScrollPane(table);
    return scrollPane;
}
Also used : JScrollPane(javax.swing.JScrollPane) JPanel(javax.swing.JPanel) FlowLayout(java.awt.FlowLayout) JComboBox(javax.swing.JComboBox) TableModelEvent(javax.swing.event.TableModelEvent) ActionEvent(java.awt.event.ActionEvent) ListSelectionEvent(javax.swing.event.ListSelectionEvent) JButton(javax.swing.JButton) TableColumn(javax.swing.table.TableColumn) UndoActionInterface(com.sldeditor.common.undo.UndoActionInterface) ListSelectionListener(javax.swing.event.ListSelectionListener) DefaultCellEditor(javax.swing.DefaultCellEditor) ActionListener(java.awt.event.ActionListener) TableModelListener(javax.swing.event.TableModelListener) JTable(javax.swing.JTable)

Example 2 with UndoActionInterface

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

the class AttributeSelection method createUI.

/**
 * Creates the ui.
 *
 * @param expectedDataType the expected data type
 */
@SuppressWarnings({ "unchecked" })
private void createUI(Class<?> expectedDataType) {
    final UndoActionInterface thisObj = this;
    outerPanel = new JPanel();
    add(outerPanel, BorderLayout.CENTER);
    outerPanel.setLayout(new CardLayout(5, 0));
    valuePanel = createValuePanel(false);
    expressionPanel = createExpressionPanel(expectedDataType);
    dataSourceAttributePanel = createDataSourceAttributePanel(expectedDataType);
    attributeChooserComboBox = new JComboBox<String>();
    attributeChooserComboBox.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            JComboBox<String> cb = (JComboBox<String>) e.getSource();
            String selected = (String) cb.getSelectedItem();
            showPanel(selected);
            if ((oldValueObj == null) && cb.getItemCount() > 0) {
                oldValueObj = cb.getItemAt(0);
            }
            UndoManager.getInstance().addUndoEvent(new UndoEvent(thisObj, "DataSourceAttribute", oldValueObj, selected));
            updateSymbol();
        }
    });
    add(attributeChooserComboBox, BorderLayout.WEST);
}
Also used : UndoEvent(com.sldeditor.common.undo.UndoEvent) JPanel(javax.swing.JPanel) CardLayout(java.awt.CardLayout) ActionListener(java.awt.event.ActionListener) JComboBox(javax.swing.JComboBox) ActionEvent(java.awt.event.ActionEvent) UndoActionInterface(com.sldeditor.common.undo.UndoActionInterface)

Example 3 with UndoActionInterface

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

the class GroupConfig method createTitle.

/**
 * Creates the title components.
 *
 * @param box the box to add the components to
 * @param parent the parent object to be called when fields are changed
 */
@Override
public void createTitle(Box box, UpdateSymbolInterface parent) {
    this.parentBox = box;
    if (isShowLabel()) {
        Component separator = createSeparator();
        componentList.add(createSeparator());
        box.add(separator);
        Component component;
        if (isOptional()) {
            final UndoActionInterface parentObj = this;
            groupCheckbox = new JCheckBox(getLabel());
            component = groupCheckbox;
            groupCheckbox.setBounds(0, 0, FULL_WIDTH, BasePanel.WIDGET_HEIGHT);
            groupCheckbox.addActionListener(new ActionListener() {

                public void actionPerformed(ActionEvent e) {
                    enableSubGroups(groupCheckbox.isSelected());
                    boolean isSelected = groupCheckbox.isSelected();
                    Boolean oldValueObj = Boolean.valueOf(!isSelected);
                    Boolean newValueObj = Boolean.valueOf(isSelected);
                    UndoManager.getInstance().addUndoEvent(new UndoEvent(parentObj, "Group : " + getId(), oldValueObj, newValueObj));
                    if (parent != null) {
                        parent.dataChanged(FieldIdEnum.UNKNOWN);
                    }
                }
            });
        } else {
            groupTitle = new JLabel(getLabel());
            groupTitle.setBounds(0, 0, FULL_WIDTH, BasePanel.WIDGET_HEIGHT);
            groupTitle.setOpaque(true);
            component = groupTitle;
        }
        // Make sure label/check box appears left aligned within the group
        JPanel panel = new JPanel();
        panel.setLayout(null);
        Dimension size = new Dimension(FULL_WIDTH, BasePanel.WIDGET_HEIGHT);
        panel.setPreferredSize(size);
        panel.setMaximumSize(size);
        panel.setSize(size);
        panel.add(component);
        box.add(panel);
        componentList.add(panel);
    }
}
Also used : JCheckBox(javax.swing.JCheckBox) UndoEvent(com.sldeditor.common.undo.UndoEvent) JPanel(javax.swing.JPanel) ActionListener(java.awt.event.ActionListener) ActionEvent(java.awt.event.ActionEvent) JLabel(javax.swing.JLabel) Dimension(java.awt.Dimension) Component(java.awt.Component) UndoActionInterface(com.sldeditor.common.undo.UndoActionInterface)

Example 4 with UndoActionInterface

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

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

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