Search in sources :

Example 1 with VendorOptionVersion

use of com.sldeditor.common.vendoroption.VendorOptionVersion in project sldeditor by robward-scisys.

the class VOGeoServerFTSCompositeBaseTest method testVOGeoServerFTSCompositeBase.

/**
 * Test method for
 * {@link com.sldeditor.ui.detail.vendor.geoserver.featuretypestyle.VOGeoServerFTSCompositeBase#VOGeoServerFTSCompositeBase(java.lang.Class)}.
 */
@Test
public void testVOGeoServerFTSCompositeBase() {
    Class<FeatureTypeStyleDetails> panelId = FeatureTypeStyleDetails.class;
    VOGeoServerFTSCompositeBase obj = new VOGeoServerFTSCompositeBase(panelId);
    assertEquals(panelId, obj.getPanelId());
    assertNotNull(obj.getFieldDataManager());
    assertNotNull(obj.getPanel());
    assertTrue(obj.isDataPresent());
    assertNotNull(obj.getVendorOptionInfo());
    // Check getVendorOptionVersion
    VendorOptionVersion vendorOption = obj.getVendorOption();
    assertEquals(GeoServerVendorOption.class, vendorOption.getClassType());
    String actualVersionString = vendorOption.getEarliest().getVersionString();
    String expectedVersionString = "2.7.0";
    assertEquals(expectedVersionString, actualVersionString);
    obj.setParentPanel(null);
    assertNull(obj.getParentPanel());
    obj.preLoadSymbol();
    List<VendorOptionPresent> vendorOptionsPresentList = new ArrayList<VendorOptionPresent>();
    String testString = "test";
    obj.getMinimumVersion(null, testString, vendorOptionsPresentList);
    assertTrue(vendorOptionsPresentList.isEmpty());
    StyleFactoryImpl styleFactory = (StyleFactoryImpl) CommonFactoryFinder.getStyleFactory();
    FeatureTypeStyle fts = styleFactory.createFeatureTypeStyle();
    obj.getMinimumVersion(null, fts, vendorOptionsPresentList);
    assertEquals(0, vendorOptionsPresentList.size());
    // Valid string
    String expectedValue = "true";
    fts.getOptions().put(FeatureTypeStyle.COMPOSITE_BASE, expectedValue);
    obj.getMinimumVersion(null, fts, vendorOptionsPresentList);
    assertEquals(1, vendorOptionsPresentList.size());
    obj.populate(fts);
    obj.updateSymbol(fts);
    String actualValue = fts.getOptions().get(FeatureTypeStyle.COMPOSITE_BASE);
    assertEquals(actualValue, expectedValue);
    // No opacity
    expectedValue = "false";
    fts.getOptions().put(FeatureTypeStyle.COMPOSITE_BASE, expectedValue);
    obj.populate(fts);
    obj.updateSymbol(fts);
    actualValue = fts.getOptions().get(FeatureTypeStyle.COMPOSITE_BASE);
    assertEquals(actualValue, expectedValue);
    // Invalid string
    expectedValue = "invalid";
    fts.getOptions().put(FeatureTypeStyle.COMPOSITE_BASE, expectedValue);
    obj.populate(fts);
    obj.updateSymbol(fts);
    actualValue = fts.getOptions().get(FeatureTypeStyle.COMPOSITE_BASE);
    assertEquals("false", actualValue);
    // Increase code coverage
    obj.populate((PolygonSymbolizer) null);
    obj.updateSymbol((PolygonSymbolizer) null);
    obj.populate((RasterSymbolizer) null);
    obj.updateSymbol((RasterSymbolizer) null);
    obj.populate((TextSymbolizer) null);
    obj.updateSymbol((TextSymbolizer) null);
    obj.populate((SelectedSymbol) null);
    obj.dataChanged(FieldIdEnum.VO_FTS_COMPOSITE_BASE_BOOL);
}
Also used : VendorOptionPresent(com.sldeditor.common.vendoroption.minversion.VendorOptionPresent) StyleFactoryImpl(org.geotools.styling.StyleFactoryImpl) VendorOptionVersion(com.sldeditor.common.vendoroption.VendorOptionVersion) FeatureTypeStyleDetails(com.sldeditor.ui.detail.FeatureTypeStyleDetails) ArrayList(java.util.ArrayList) FeatureTypeStyle(org.geotools.styling.FeatureTypeStyle) VOGeoServerFTSCompositeBase(com.sldeditor.ui.detail.vendor.geoserver.featuretypestyle.VOGeoServerFTSCompositeBase) Test(org.junit.Test)

Example 2 with VendorOptionVersion

use of com.sldeditor.common.vendoroption.VendorOptionVersion in project sldeditor by robward-scisys.

the class VendorOptionMenuUtils method createMenu.

/**
 * Creates the menu.
 *
 * @param versionDataList the list version data
 * @return the list
 */
public static List<ValueComboBoxDataGroup> createMenu(List<VersionData> versionDataList) {
    if (dataSelectionList.isEmpty()) {
        Map<String, List<ValueComboBoxData>> map = new HashMap<String, List<ValueComboBoxData>>();
        List<String> keyOrderList = new ArrayList<String>();
        if (versionDataList != null) {
            for (VersionData versionData : versionDataList) {
                String key = getKey(versionData);
                List<ValueComboBoxData> dataList = map.get(key);
                if (dataList == null) {
                    dataList = new ArrayList<ValueComboBoxData>();
                    map.put(key, dataList);
                    keyOrderList.add(key);
                }
                VendorOptionVersion vendorOptionVersion = new VendorOptionVersion(versionData.getVendorOptionType(), versionData);
                ValueComboBoxData value = new ValueComboBoxData(versionData.getVersionString(), versionData.getVersionString(), vendorOptionVersion, String.class);
                dataList.add(value);
                valueMap.put(versionData.getVersionString(), value);
            }
            // Add groups to menu combo
            for (String key : keyOrderList) {
                List<ValueComboBoxData> dataList = map.get(key);
                ValueComboBoxDataGroup group = new ValueComboBoxDataGroup(key + ".x", dataList, (dataList.size() > 1));
                dataSelectionList.add(group);
            }
        }
    }
    return dataSelectionList;
}
Also used : ValueComboBoxDataGroup(com.sldeditor.ui.widgets.ValueComboBoxDataGroup) HashMap(java.util.HashMap) VersionData(com.sldeditor.common.vendoroption.VersionData) VendorOptionVersion(com.sldeditor.common.vendoroption.VendorOptionVersion) ArrayList(java.util.ArrayList) List(java.util.List) ArrayList(java.util.ArrayList) ValueComboBoxData(com.sldeditor.ui.widgets.ValueComboBoxData)

Example 3 with VendorOptionVersion

use of com.sldeditor.common.vendoroption.VendorOptionVersion in project sldeditor by robward-scisys.

the class VendorOptionInfoModel method isVendorOptionAvailable.

/**
 * Checks if is vendor option available.
 *
 * @param row the row
 * @return true, if is vendor option available
 */
public boolean isVendorOptionAvailable(int row) {
    if ((row >= 0) && (row < infoList.size())) {
        VendorOptionInfo info = infoList.get(row);
        VendorOptionVersion vendorOptionVersion = info.getVersionData();
        // Check to see if it is strict SLD, always allowed
        if (vendorOptionVersion.getClassType() == NoVendorOption.class) {
            return true;
        }
        if (vendorOptionVersion.getClassType() != selectedVersion.getVendorOptionType()) {
            return false;
        }
        return selectedVersion.inRange(vendorOptionVersion.getEarliest(), vendorOptionVersion.getLatest());
    }
    return false;
}
Also used : VendorOptionVersion(com.sldeditor.common.vendoroption.VendorOptionVersion)

Example 4 with VendorOptionVersion

use of com.sldeditor.common.vendoroption.VendorOptionVersion in project sldeditor by robward-scisys.

the class SLDEditorFileHandler method extractVendorOptionData.

/**
 * Extract vendor option data.
 *
 * @param document the document
 * @param elementName the element name
 * @return the list
 */
private List<VersionData> extractVendorOptionData(Document document, String elementName) {
    List<VersionData> list = new ArrayList<VersionData>();
    // Try and remove any duplicates
    List<String> nameList = new ArrayList<String>();
    nameList.add(VendorOptionManager.getInstance().getDefaultVendorOptionVersion().getLatest().toString());
    list.add(VendorOptionManager.getInstance().getDefaultVendorOptionVersion().getLatest());
    NodeList nodeList = document.getElementsByTagName(elementName);
    for (int index = 0; index < nodeList.getLength(); index++) {
        String value = nodeList.item(index).getTextContent();
        VendorOptionVersion vendorOption = VendorOptionVersion.fromString(value);
        VersionData newVersion = vendorOption.getLatest();
        if (!nameList.contains(newVersion.toString())) {
            list.add(newVersion);
            nameList.add(newVersion.toString());
        }
    }
    return list;
}
Also used : VersionData(com.sldeditor.common.vendoroption.VersionData) NodeList(org.w3c.dom.NodeList) VendorOptionVersion(com.sldeditor.common.vendoroption.VendorOptionVersion) ArrayList(java.util.ArrayList)

Example 5 with VendorOptionVersion

use of com.sldeditor.common.vendoroption.VendorOptionVersion in project sldeditor by robward-scisys.

the class ReadPanelConfig method getVendorOptionVersion.

/**
 * Gets the vendor option version.
 *
 * @param panelConfig the panel config
 * @return the vendor option version
 */
private VendorOptionVersion getVendorOptionVersion(PanelConfig panelConfig) {
    String vendorOptionClassName = panelConfig.getVendorOption();
    String startVersion = panelConfig.getStart();
    String endVersion = panelConfig.getEnd();
    VendorOptionVersion vendorOptionVersion = null;
    if (vendorOptionClassName != null) {
        Class<?> classType;
        try {
            classType = Class.forName(vendorOptionClassName);
            vendorOptionVersion = VendorOptionManager.getInstance().getVendorOptionVersion(classType, startVersion, endVersion);
        } catch (ClassNotFoundException e) {
            ConsoleManager.getInstance().error(ReadPanelConfig.class, "Unknown vendor option class : " + vendorOptionClassName);
            vendorOptionVersion = VendorOptionManager.getInstance().getDefaultVendorOptionVersion();
        }
    }
    return vendorOptionVersion;
}
Also used : VendorOptionVersion(com.sldeditor.common.vendoroption.VendorOptionVersion) XMLFieldConfigString(com.sldeditor.common.xml.ui.XMLFieldConfigString)

Aggregations

VendorOptionVersion (com.sldeditor.common.vendoroption.VendorOptionVersion)23 Test (org.junit.Test)16 VersionData (com.sldeditor.common.vendoroption.VersionData)13 ArrayList (java.util.ArrayList)8 VendorOptionPresent (com.sldeditor.common.vendoroption.minversion.VendorOptionPresent)4 FeatureTypeStyle (org.geotools.styling.FeatureTypeStyle)4 VendorOptionInfo (com.sldeditor.common.vendoroption.info.VendorOptionInfo)3 FeatureTypeStyleDetails (com.sldeditor.ui.detail.FeatureTypeStyleDetails)3 StyleFactoryImpl (org.geotools.styling.StyleFactoryImpl)3 GeoServerVendorOption (com.sldeditor.common.vendoroption.GeoServerVendorOption)2 ValueComboBoxData (com.sldeditor.ui.widgets.ValueComboBoxData)2 File (java.io.File)2 DataSourcePropertiesInterface (com.sldeditor.common.DataSourcePropertiesInterface)1 SLDData (com.sldeditor.common.data.SLDData)1 PrefData (com.sldeditor.common.preferences.PrefData)1 VendorOptionInfoModel (com.sldeditor.common.vendoroption.info.VendorOptionInfoModel)1 ParseXML (com.sldeditor.common.xml.ParseXML)1 XMLFieldConfigString (com.sldeditor.common.xml.ui.XMLFieldConfigString)1 SLDEditorFile (com.sldeditor.datasource.SLDEditorFile)1 EnvVar (com.sldeditor.filter.v2.envvar.EnvVar)1