Search in sources :

Example 1 with VendorOptionInfo

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

the class MinimumVersion method getMinimumVersion.

/**
 * Gets the minimum version.
 *
 * @param userDefaultVendorOption the user default vendor option
 * @return the minimum version
 */
public List<VersionData> getMinimumVersion(List<VersionData> userDefaultVendorOption) {
    List<VersionData> list = new ArrayList<VersionData>();
    if (vendorOptionsPresentList.isEmpty()) {
        list = userDefaultVendorOption;
    } else {
        VendorOptionPresent lastVendorOption = vendorOptionsPresentList.get(vendorOptionsPresentList.size() - 1);
        VendorOptionInfo vendorOptionInfo = lastVendorOption.getVendorOptionInfo();
        VersionData earliestReadFromSymbol = vendorOptionInfo.getVersionData().getEarliest();
        list.add(findLatest(earliestReadFromSymbol, userDefaultVendorOption));
    }
    return list;
}
Also used : VersionData(com.sldeditor.common.vendoroption.VersionData) ArrayList(java.util.ArrayList) VendorOptionInfo(com.sldeditor.common.vendoroption.info.VendorOptionInfo)

Example 2 with VendorOptionInfo

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

the class VendorOptionPresentModel method getValueAt.

/*
     * (non-Javadoc)
     * 
     * @see javax.swing.table.TableModel#getValueAt(int, int)
     */
@Override
public Object getValueAt(int rowIndex, int columnIndex) {
    if ((rowIndex >= 0) && (rowIndex < vendorOptionsPresentList.size())) {
        VendorOptionPresent voPresent = vendorOptionsPresentList.get(rowIndex);
        VendorOptionInfo info = voPresent.getVendorOptionInfo();
        switch(columnIndex) {
            case 0:
                return info.getName();
            case 1:
                return info.getVersionString();
            default:
                break;
        }
    }
    return null;
}
Also used : VendorOptionInfo(com.sldeditor.common.vendoroption.info.VendorOptionInfo)

Example 3 with VendorOptionInfo

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

the class VendorOptionManagerTest method testLoadSLDFile.

/**
 * Test method for {@link com.sldeditor.common.vendoroption.VendorOptionManager#getVendorOptionVersion()}.
 */
@Test
public void testLoadSLDFile() {
    VendorOptionManager.destroyInstance();
    PrefData prefData = PrefManager.getInstance().getPrefData();
    List<VersionData> vendorOptionList = new ArrayList<VersionData>();
    VersionData actualPrefVO = VersionData.decode(GeoServerVendorOption.class, "2.4.2");
    vendorOptionList.add(actualPrefVO);
    prefData.setVendorOptionVersionList(vendorOptionList);
    PrefManager.getInstance().setPrefData(prefData);
    SLDData sldData = new SLDData(null, null);
    StyledLayerDescriptor sld = null;
    VendorOptionManager.getInstance().addVendorOptionListener(obj);
    obj.vendorOptionVersionsList.clear();
    // No SLD Editor file, SLD is empty so it should you PrefManager default set above
    VendorOptionManager.getInstance().loadSLDFile(null, sld, sldData);
    assertEquals(1, obj.vendorOptionVersionsList.size());
    assertEquals(actualPrefVO, obj.vendorOptionVersionsList.get(0));
    // No SLD Editor file, SLD contains PointSymboliser with vendor
    // option so it should use the SLD vendor option
    obj.vendorOptionVersionsList.clear();
    sld = DefaultSymbols.createNewSLD();
    SelectedSymbol.getInstance().createNewSLD(sld);
    NamedLayer namedLayer = DefaultSymbols.createNewNamedLayer();
    String expectedNameLayerValue = "named layer test value";
    namedLayer.setName(expectedNameLayerValue);
    Style style = DefaultSymbols.createNewStyle();
    String expectedNameStyleValue = "style test value";
    style.setName(expectedNameStyleValue);
    namedLayer.addStyle(style);
    FeatureTypeStyle fts = DefaultSymbols.createNewFeatureTypeStyle();
    String expectedNameFTSValue = "feature type style test value";
    fts.setName(expectedNameFTSValue);
    style.featureTypeStyles().add(fts);
    Rule rule = DefaultSymbols.createNewRule();
    String expectedNameValue = "rule test value";
    rule.setName(expectedNameValue);
    PointSymbolizer symbolizer = DefaultSymbols.createDefaultPointSymbolizer();
    rule.symbolizers().add(symbolizer);
    fts.rules().add(rule);
    sld.layers().add(namedLayer);
    VersionData testVersionData = VersionData.decode(GeoServerVendorOption.class, "2.8.0");
    VendorOptionManager.getInstance().loadSLDFile(new GetMinimumVersionInterface() {

        @Override
        public void getMinimumVersion(Object parentObj, Object sldObj, List<VendorOptionPresent> vendorOptionsPresentList) {
            VendorOptionInfo vendorOptionInfo = new VendorOptionInfo("qgis://", new VendorOptionVersion(testVersionData.getVendorOptionType(), testVersionData), "");
            VendorOptionPresent voPresent = new VendorOptionPresent(sldObj, vendorOptionInfo);
            vendorOptionsPresentList.add(voPresent);
        }
    }, sld, sldData);
    assertEquals(1, obj.vendorOptionVersionsList.size());
    assertEquals(testVersionData, obj.vendorOptionVersionsList.get(0));
    // Now set the SLD Editor file vendor option
    obj.vendorOptionVersionsList.clear();
    List<VersionData> sldEditorVendorOptionList = new ArrayList<VersionData>();
    VersionData testVersionData2 = VersionData.decode(GeoServerVendorOption.class, "2.10.0");
    sldEditorVendorOptionList.add(testVersionData2);
    sldEditorVendorOptionList.add(VendorOptionManager.getInstance().getDefaultVendorOptionVersionData());
    sldData.setVendorOptionList(sldEditorVendorOptionList);
    sldData.setSldEditorFile(new File("."));
    VendorOptionManager.getInstance().loadSLDFile(new GetMinimumVersionInterface() {

        @Override
        public void getMinimumVersion(Object parentObj, Object sldObj, List<VendorOptionPresent> vendorOptionsPresentList) {
            VendorOptionInfo vendorOptionInfo = new VendorOptionInfo("qgis://", new VendorOptionVersion(testVersionData.getVendorOptionType(), testVersionData), "");
            VendorOptionPresent voPresent = new VendorOptionPresent(sldObj, vendorOptionInfo);
            vendorOptionsPresentList.add(voPresent);
        }
    }, sld, sldData);
    Collections.sort(obj.vendorOptionVersionsList);
    assertEquals(2, obj.vendorOptionVersionsList.size());
    assertEquals(testVersionData2, obj.vendorOptionVersionsList.get(obj.vendorOptionVersionsList.size() - 1));
    // Increase code coverage
    VendorOptionManager.getInstance().loadSLDFile(null, null, null);
}
Also used : SLDData(com.sldeditor.common.data.SLDData) PointSymbolizer(org.geotools.styling.PointSymbolizer) VendorOptionPresent(com.sldeditor.common.vendoroption.minversion.VendorOptionPresent) ArrayList(java.util.ArrayList) StyledLayerDescriptor(org.geotools.styling.StyledLayerDescriptor) PrefData(com.sldeditor.common.preferences.PrefData) VersionData(com.sldeditor.common.vendoroption.VersionData) VendorOptionVersion(com.sldeditor.common.vendoroption.VendorOptionVersion) GetMinimumVersionInterface(com.sldeditor.ui.panels.GetMinimumVersionInterface) Style(org.geotools.styling.Style) FeatureTypeStyle(org.geotools.styling.FeatureTypeStyle) FeatureTypeStyle(org.geotools.styling.FeatureTypeStyle) Rule(org.geotools.styling.Rule) NamedLayer(org.geotools.styling.NamedLayer) VendorOptionInfo(com.sldeditor.common.vendoroption.info.VendorOptionInfo) File(java.io.File) Test(org.junit.Test)

Example 4 with VendorOptionInfo

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

the class VendorOptionInfoTest method testVendorOptionInfo.

/**
 * Test method for {@link com.sldeditor.common.vendoroption.info.VendorOptionInfo#VendorOptionInfo(java.lang.String, com.sldeditor.common.vendoroption.VendorOptionVersion, java.lang.String)}.
 * Test method for {@link com.sldeditor.common.vendoroption.info.VendorOptionInfo#getName()}.
 * Test method for {@link com.sldeditor.common.vendoroption.info.VendorOptionInfo#getDescription()}.
 * Test method for {@link com.sldeditor.common.vendoroption.info.VendorOptionInfo#getVersionData()}.
 * Test method for {@link com.sldeditor.common.vendoroption.info.VendorOptionInfo#getVersionString()}.
 */
@Test
public void testVendorOptionInfo() {
    String name = "name";
    String description = "test description";
    VendorOptionInfo info = new VendorOptionInfo(name, null, description);
    assertEquals(name, info.getName());
    assertEquals(description, info.getDescription());
    assertNull(info.getVersionData());
    assertEquals("", info.getVersionString());
    VersionData versionDataMin = VersionData.decode(getClass(), "2.4.1");
    VersionData versionDataMax = VersionData.decode(getClass(), "2.8.3");
    VendorOptionVersion versionData = new VendorOptionVersion(GeoServerVendorOption.class, versionDataMin, versionDataMax);
    VendorOptionInfo info2 = new VendorOptionInfo(name, versionData, description);
    assertEquals("GeoServer 2.4.1-2.8.3", info2.getVersionString());
    assertEquals(0, info.compareTo(info));
    assertEquals(1, info.compareTo(info2));
    assertEquals(-1, info2.compareTo(info));
    VendorOptionVersion versionData2 = new VendorOptionVersion(GeoServerVendorOption.class, VersionData.decode(getClass(), "2.2.1"), versionDataMax);
    VendorOptionInfo info3 = new VendorOptionInfo(name, versionData2, description);
    assertEquals(-1, info3.compareTo(info2));
    assertEquals(1, info2.compareTo(info3));
}
Also used : VersionData(com.sldeditor.common.vendoroption.VersionData) VendorOptionVersion(com.sldeditor.common.vendoroption.VendorOptionVersion) VendorOptionInfo(com.sldeditor.common.vendoroption.info.VendorOptionInfo) Test(org.junit.Test)

Example 5 with VendorOptionInfo

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

the class VendorOptionInfoManagerTest method testAddVendorOptionInfo.

/**
 * Test method for
 * {@link com.sldeditor.common.vendoroption.info.VendorOptionInfoManager#addVendorOptionInfo(com.sldeditor.ui.detail.vendor.VendorOptionFactoryInterface)}.
 * {@link com.sldeditor.common.vendoroption.info.VendorOptionInfoManager#getPanel(java.lang.Class)}.
 * {@link com.sldeditor.common.vendoroption.info.VendorOptionInfoManager#setSelectedVersion(java.lang.Class, com.sldeditor.common.vendoroption.VersionData)}.
 */
@Test
public void testAddVendorOptionInfo() {
    VendorOptionInfoManager.getInstance().addVendorOptionInfo(null);
    VendorOptionFactoryInterface f1 = new VendorOptionFactoryInterface() {

        @Override
        public List<VendorOptionInterface> getVendorOptionList() {
            return null;
        }

        @Override
        public List<VendorOptionInterface> getVendorOptionList(String className) {
            return null;
        }

        @Override
        public List<VendorOptionInfo> getVendorOptionInfoList() {
            List<VendorOptionInfo> list = new ArrayList<VendorOptionInfo>();
            return list;
        }
    };
    VendorOptionInfoManager.getInstance().addVendorOptionInfo(f1);
    VendorOptionInfoManager.getInstance().addVendorOptionInfo(f1);
    VendorOptionInfoPanel panel1 = VendorOptionInfoManager.getInstance().getPanel(String.class);
    VendorOptionInfoPanel panel2 = VendorOptionInfoManager.getInstance().getPanel(Double.class);
    VendorOptionInfoPanel panel3 = VendorOptionInfoManager.getInstance().getPanel(String.class);
    assertTrue(panel1 == panel3);
    assertTrue(panel1 != panel2);
    VendorOptionInfoManager.getInstance().setSelectedVersion(null, null);
    VersionData versionData = VersionData.decode(GeoServerVendorOption.class, "3.1.4");
    VendorOptionInfoManager.getInstance().setSelectedVersion(String.class, versionData);
}
Also used : VendorOptionInfoPanel(com.sldeditor.common.vendoroption.info.VendorOptionInfoPanel) VersionData(com.sldeditor.common.vendoroption.VersionData) ArrayList(java.util.ArrayList) VendorOptionInfo(com.sldeditor.common.vendoroption.info.VendorOptionInfo) VendorOptionFactoryInterface(com.sldeditor.ui.detail.vendor.VendorOptionFactoryInterface) VendorOptionInterface(com.sldeditor.ui.detail.vendor.geoserver.VendorOptionInterface) Test(org.junit.Test)

Aggregations

VendorOptionInfo (com.sldeditor.common.vendoroption.info.VendorOptionInfo)6 VersionData (com.sldeditor.common.vendoroption.VersionData)5 ArrayList (java.util.ArrayList)4 Test (org.junit.Test)4 VendorOptionVersion (com.sldeditor.common.vendoroption.VendorOptionVersion)3 SLDData (com.sldeditor.common.data.SLDData)1 PrefData (com.sldeditor.common.preferences.PrefData)1 VendorOptionInfoModel (com.sldeditor.common.vendoroption.info.VendorOptionInfoModel)1 VendorOptionInfoPanel (com.sldeditor.common.vendoroption.info.VendorOptionInfoPanel)1 VendorOptionPresent (com.sldeditor.common.vendoroption.minversion.VendorOptionPresent)1 VendorOptionFactoryInterface (com.sldeditor.ui.detail.vendor.VendorOptionFactoryInterface)1 VendorOptionInterface (com.sldeditor.ui.detail.vendor.geoserver.VendorOptionInterface)1 GetMinimumVersionInterface (com.sldeditor.ui.panels.GetMinimumVersionInterface)1 File (java.io.File)1 FeatureTypeStyle (org.geotools.styling.FeatureTypeStyle)1 NamedLayer (org.geotools.styling.NamedLayer)1 PointSymbolizer (org.geotools.styling.PointSymbolizer)1 Rule (org.geotools.styling.Rule)1 Style (org.geotools.styling.Style)1 StyledLayerDescriptor (org.geotools.styling.StyledLayerDescriptor)1