Search in sources :

Example 1 with FilterPanelInterface

use of com.sldeditor.filter.FilterPanelInterface in project sldeditor by robward-scisys.

the class FieldConfigFeatureTypeConstraint method createFilterTable.

/**
 * Creates the filter table.
 *
 * @param xPos the x pos
 * @param maxNoOfRows the max no of rows
 * @param fieldPanel the field panel
 */
private void createFilterTable(int xPos, int maxNoOfRows, FieldPanel fieldPanel) {
    filterTable = new JTable(filterModel);
    filterTable.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION);
    filterTable.setBounds(xPos, 0, BasePanel.FIELD_PANEL_WIDTH, getRowY(maxNoOfRows - 2));
    filterTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() {

        @Override
        public void valueChanged(ListSelectionEvent e) {
            if (!e.getValueIsAdjusting()) {
                FeatureTypeConstraint ftc = filterModel.getFeatureTypeConstraint(filterTable.getSelectedRow());
                if (ftc != null) {
                    extentModel.populate(ftc.getExtents());
                    addExtentButton.setEnabled(true);
                    removeFTCButton.setEnabled(true);
                    int[] selectedColumns = filterTable.getSelectedColumns();
                    if (filterModel.isFilterColumn(selectedColumns)) {
                        FilterPanelInterface filterPanel = ExpressionPanelFactory.getFilterPanel(null);
                        String panelTitle = Localisation.getString(FieldConfigBase.class, "FieldConfigFeatureTypeConstraint.filterPanel");
                        filterPanel.configure(panelTitle, Object.class, SelectedSymbol.getInstance().isRasterSymbol());
                        filterPanel.populate(ftc.getFilter());
                        if (filterPanel.showDialog()) {
                            ftc.setFilter(filterPanel.getFilter());
                            filterModel.fireTableDataChanged();
                            featureTypeConstraintUpdated();
                        }
                    }
                }
            }
        }
    });
    JScrollPane scrollPanel = new JScrollPane(filterTable);
    scrollPanel.setBounds(xPos, BasePanel.WIDGET_HEIGHT, BasePanel.FIELD_PANEL_WIDTH, BasePanel.WIDGET_HEIGHT * (maxNoOfRows - 2));
    fieldPanel.add(scrollPanel);
    int buttonY = getRowY(maxNoOfRows - 1);
    // 
    // Add button
    // 
    addFTCButton = new JButton(Localisation.getString(FieldConfigBase.class, "FieldConfigFeatureTypeConstraint.add"));
    addFTCButton.setBounds(xPos + BasePanel.WIDGET_X_START, buttonY, BasePanel.WIDGET_BUTTON_WIDTH, BasePanel.WIDGET_HEIGHT);
    addFTCButton.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            addEntry();
        }
    });
    fieldPanel.add(addFTCButton);
    // 
    // Remove button
    // 
    removeFTCButton = new JButton(Localisation.getString(FieldConfigBase.class, "FieldConfigFeatureTypeConstraint.remove"));
    removeFTCButton.setBounds(xPos + BasePanel.WIDGET_BUTTON_WIDTH + BasePanel.WIDGET_X_START + 10, buttonY, BasePanel.WIDGET_BUTTON_WIDTH, BasePanel.WIDGET_HEIGHT);
    removeFTCButton.setEnabled(false);
    removeFTCButton.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            removeEntry();
        }
    });
    fieldPanel.add(removeFTCButton);
}
Also used : JScrollPane(javax.swing.JScrollPane) FilterPanelInterface(com.sldeditor.filter.FilterPanelInterface) FieldConfigBase(com.sldeditor.ui.detail.config.FieldConfigBase) ActionEvent(java.awt.event.ActionEvent) ListSelectionEvent(javax.swing.event.ListSelectionEvent) JButton(javax.swing.JButton) FeatureTypeConstraint(org.geotools.styling.FeatureTypeConstraint) ListSelectionListener(javax.swing.event.ListSelectionListener) FeatureTypeConstraint(org.geotools.styling.FeatureTypeConstraint) ActionListener(java.awt.event.ActionListener) JTable(javax.swing.JTable)

Example 2 with FilterPanelInterface

use of com.sldeditor.filter.FilterPanelInterface in project sldeditor by robward-scisys.

the class RuleDetails method editFilter.

/**
 * Edits the filter.
 *
 * @param filterFieldId the filter field id
 */
protected void editFilter(FieldIdEnum filterFieldId) {
    FilterPanelInterface filterPanel = ExpressionPanelFactory.getFilterPanel(null);
    String panelTitle = Localisation.getString(RuleDetails.class, "RuleDetails.panelTitle");
    filterPanel.configure(panelTitle, Object.class, SelectedSymbol.getInstance().isRasterSymbol());
    Rule rule = SelectedSymbol.getInstance().getRule();
    if (rule != null) {
        filterPanel.populate(rule.getFilter());
    }
    if (filterPanel.showDialog()) {
        originalFilter = filterPanel.getFilter();
        fieldConfigVisitor.populateTextField(filterFieldId, filterPanel.getFilterString());
        updateSymbol();
    }
}
Also used : FilterPanelInterface(com.sldeditor.filter.FilterPanelInterface) FieldConfigString(com.sldeditor.ui.detail.config.FieldConfigString) Rule(org.opengis.style.Rule)

Aggregations

FilterPanelInterface (com.sldeditor.filter.FilterPanelInterface)2 FieldConfigBase (com.sldeditor.ui.detail.config.FieldConfigBase)1 FieldConfigString (com.sldeditor.ui.detail.config.FieldConfigString)1 ActionEvent (java.awt.event.ActionEvent)1 ActionListener (java.awt.event.ActionListener)1 JButton (javax.swing.JButton)1 JScrollPane (javax.swing.JScrollPane)1 JTable (javax.swing.JTable)1 ListSelectionEvent (javax.swing.event.ListSelectionEvent)1 ListSelectionListener (javax.swing.event.ListSelectionListener)1 FeatureTypeConstraint (org.geotools.styling.FeatureTypeConstraint)1 Rule (org.opengis.style.Rule)1