Search in sources :

Example 1 with RemoteOWS

use of org.geotools.styling.RemoteOWS in project sldeditor by robward-scisys.

the class UserLayerDetails method populate.

/*
     * (non-Javadoc)
     * 
     * @see com.sldeditor.ui.iface.PopulateDetailsInterface#populate(com.sldeditor.ui.detail.SelectedSymbol)
     */
@Override
public void populate(SelectedSymbol selectedSymbol) {
    if (selectedSymbol != null) {
        StyledLayer styledLayer = selectedSymbol.getStyledLayer();
        if (styledLayer instanceof UserLayerImpl) {
            UserLayerImpl userLayer = (UserLayerImpl) styledLayer;
            fieldConfigVisitor.populateTextField(FieldIdEnum.NAME, userLayer.getName());
            // Feature layer constraint
            List<FeatureTypeConstraint> ftcList = userLayer.layerFeatureConstraints();
            fieldConfigVisitor.populateFieldTypeConstraint(FieldIdEnum.LAYER_FEATURE_CONSTRAINTS, ftcList);
            // Source
            GroupConfigInterface group = getGroup(GroupIdEnum.USER_LAYER_SOURCE);
            if (group != null) {
                MultiOptionGroup userLayerSourceGroup = (MultiOptionGroup) group;
                if (userLayer.getInlineFeatureDatastore() == null) {
                    userLayerSourceGroup.setOption(GroupIdEnum.REMOTE_OWS_OPTION);
                    // Remote OWS
                    String service = "";
                    String onlineResource = "";
                    RemoteOWS remoteOWS = userLayer.getRemoteOWS();
                    if (remoteOWS != null) {
                        service = remoteOWS.getService();
                        onlineResource = remoteOWS.getOnlineResource();
                    }
                    fieldConfigVisitor.populateTextField(FieldIdEnum.REMOTE_OWS_SERVICE, service);
                    fieldConfigVisitor.populateTextField(FieldIdEnum.REMOTE_OWS_ONLINERESOURCE, onlineResource);
                } else {
                    userLayerSourceGroup.setOption(GroupIdEnum.INLINE_FEATURE_OPTION);
                    // Inline features
                    fieldConfigVisitor.populateUserLayer(FieldIdEnum.INLINE_FEATURE, userLayer);
                }
            }
        }
    }
}
Also used : RemoteOWS(org.geotools.styling.RemoteOWS) UserLayerImpl(org.geotools.styling.UserLayerImpl) FeatureTypeConstraint(org.geotools.styling.FeatureTypeConstraint) StyledLayer(org.geotools.styling.StyledLayer) GroupConfigInterface(com.sldeditor.ui.detail.config.base.GroupConfigInterface) MultiOptionGroup(com.sldeditor.ui.detail.config.base.MultiOptionGroup)

Example 2 with RemoteOWS

use of org.geotools.styling.RemoteOWS in project sldeditor by robward-scisys.

the class UserLayerDetails method updateSymbol.

/**
 * Update symbol.
 *
 * @param changedField the changed field
 */
private void updateSymbol(FieldIdEnum changedField) {
    if (!Controller.getInstance().isPopulating()) {
        UserLayer userLayer = getStyleFactory().createUserLayer();
        String name = fieldConfigVisitor.getText(FieldIdEnum.NAME);
        userLayer.setName(name);
        // Feature type constraints
        List<FeatureTypeConstraint> ftcList = fieldConfigVisitor.getFeatureTypeConstraint(FieldIdEnum.LAYER_FEATURE_CONSTRAINTS);
        if ((ftcList != null) && !ftcList.isEmpty()) {
            FeatureTypeConstraint[] ftcArray = new FeatureTypeConstraint[ftcList.size()];
            userLayer.setLayerFeatureConstraints(ftcList.toArray(ftcArray));
        }
        // Source
        GroupConfigInterface group = getGroup(GroupIdEnum.USER_LAYER_SOURCE);
        if (group != null) {
            MultiOptionGroup userLayerSourceGroup = (MultiOptionGroup) group;
            OptionGroup selectedOption = userLayerSourceGroup.getSelectedOptionGroup();
            switch(selectedOption.getId()) {
                case REMOTE_OWS_OPTION:
                    {
                        RemoteOWS remoteOWS = new RemoteOWSImpl();
                        String service = fieldConfigVisitor.getText(FieldIdEnum.REMOTE_OWS_SERVICE);
                        remoteOWS.setService(service);
                        String onlineResource = fieldConfigVisitor.getText(FieldIdEnum.REMOTE_OWS_ONLINERESOURCE);
                        remoteOWS.setOnlineResource(onlineResource);
                        userLayer.setRemoteOWS(remoteOWS);
                    }
                    break;
                case INLINE_FEATURE_OPTION:
                    {
                        String inlineFeatures = fieldConfigVisitor.getText(FieldIdEnum.INLINE_FEATURE);
                        if ((inlineFeatures != null) && (!inlineFeatures.isEmpty())) {
                            InlineFeatureUtils.setInlineFeatures(userLayer, inlineFeatures);
                        }
                    }
                    break;
                default:
                    break;
            }
        }
        StyledLayer existingStyledLayer = SelectedSymbol.getInstance().getStyledLayer();
        if (existingStyledLayer instanceof UserLayerImpl) {
            UserLayerImpl existingUserLayer = (UserLayerImpl) existingStyledLayer;
            for (Style style : existingUserLayer.userStyles()) {
                userLayer.addUserStyle(style);
            }
        }
        SelectedSymbol.getInstance().replaceStyledLayer(userLayer);
        // reduces creation of datasources
        if (changedField != null) {
            if (changedField == FieldIdEnum.INLINE_FEATURE) {
                DataSourceInterface dataSource = DataSourceFactory.getDataSource();
                if (dataSource != null) {
                    dataSource.updateUserLayers();
                }
            }
        }
        this.fireUpdateSymbol();
    }
}
Also used : RemoteOWS(org.geotools.styling.RemoteOWS) StyledLayer(org.geotools.styling.StyledLayer) RemoteOWSImpl(org.geotools.styling.RemoteOWSImpl) DataSourceInterface(com.sldeditor.datasource.DataSourceInterface) FeatureTypeConstraint(org.geotools.styling.FeatureTypeConstraint) OptionGroup(com.sldeditor.ui.detail.config.base.OptionGroup) MultiOptionGroup(com.sldeditor.ui.detail.config.base.MultiOptionGroup) UserLayerImpl(org.geotools.styling.UserLayerImpl) Style(org.geotools.styling.Style) GroupConfigInterface(com.sldeditor.ui.detail.config.base.GroupConfigInterface) UserLayer(org.geotools.styling.UserLayer) MultiOptionGroup(com.sldeditor.ui.detail.config.base.MultiOptionGroup)

Aggregations

GroupConfigInterface (com.sldeditor.ui.detail.config.base.GroupConfigInterface)2 MultiOptionGroup (com.sldeditor.ui.detail.config.base.MultiOptionGroup)2 FeatureTypeConstraint (org.geotools.styling.FeatureTypeConstraint)2 RemoteOWS (org.geotools.styling.RemoteOWS)2 StyledLayer (org.geotools.styling.StyledLayer)2 UserLayerImpl (org.geotools.styling.UserLayerImpl)2 DataSourceInterface (com.sldeditor.datasource.DataSourceInterface)1 OptionGroup (com.sldeditor.ui.detail.config.base.OptionGroup)1 RemoteOWSImpl (org.geotools.styling.RemoteOWSImpl)1 Style (org.geotools.styling.Style)1 UserLayer (org.geotools.styling.UserLayer)1