Search in sources :

Example 16 with VendorOptionVersion

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

the class VendorOptionStatusTest method testGetVendorOptionVersionString.

/**
 * Test method for {@link com.sldeditor.common.vendoroption.VendorOptionStatus#getVendorOptionVersionString(VersionData)}.
 */
@Test
public void testGetVendorOptionVersionString() {
    VersionData versionDataMin = VersionData.decode(getClass(), "2.4.1");
    VersionData versionDataMax = VersionData.decode(getClass(), "2.8.3");
    VendorOptionVersion versionData = new VendorOptionVersion(GeoServerVendorOption.class, versionDataMin, versionDataMax);
    assertEquals("", VendorOptionStatus.getVendorOptionVersionString(null));
    assertEquals("GeoServer 2.4.1-2.8.3", VendorOptionStatus.getVendorOptionVersionString(versionData));
    versionData = new VendorOptionVersion(GeoServerVendorOption.class, versionDataMin, VersionData.decode(getClass(), "Latest"));
    assertEquals("GeoServer 2.4.1-", VendorOptionStatus.getVendorOptionVersionString(versionData));
    versionData = new VendorOptionVersion(GeoServerVendorOption.class, VersionData.decode(getClass(), "Earliest"), versionDataMax);
    assertEquals("GeoServer -2.8.3", VendorOptionStatus.getVendorOptionVersionString(versionData));
}
Also used : GeoServerVendorOption(com.sldeditor.common.vendoroption.GeoServerVendorOption) VersionData(com.sldeditor.common.vendoroption.VersionData) VendorOptionVersion(com.sldeditor.common.vendoroption.VendorOptionVersion) Test(org.junit.Test)

Example 17 with VendorOptionVersion

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

the class VendorOptionVersionTest method testVendorOptionVersionClassOfQVersionDataVersionData.

/**
 * Test method for {@link com.sldeditor.common.vendoroption.VendorOptionVersion#VendorOptionVersion(java.lang.Class, com.sldeditor.common.vendoroption.VersionData, com.sldeditor.common.vendoroption.VersionData)}.
 */
@Test
public void testVendorOptionVersionClassOfQVersionDataVersionData() {
    VersionData versionDataMin = VersionData.decode(getClass(), "2.4.1");
    VersionData versionDataMax = VersionData.decode(getClass(), "2.8.3");
    VendorOptionVersion vo = new VendorOptionVersion(getClass(), versionDataMin, versionDataMax);
    assertEquals(versionDataMax, vo.getLatest());
}
Also used : VersionData(com.sldeditor.common.vendoroption.VersionData) VendorOptionVersion(com.sldeditor.common.vendoroption.VendorOptionVersion) Test(org.junit.Test)

Example 18 with VendorOptionVersion

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

the class VendorOptionVersionTest method testIsAllowed.

/**
 * Test method for {@link com.sldeditor.common.vendoroption.VendorOptionVersion#isAllowed(com.sldeditor.common.vendoroption.VersionData)}.
 */
@Test
public void testIsAllowed() {
    VersionData versionDataMin = VersionData.decode(getClass(), "2.4.1");
    VersionData versionDataMax = VersionData.decode(getClass(), "2.8.3");
    VendorOptionVersion vo = new VendorOptionVersion(getClass(), versionDataMin, versionDataMax);
    assertFalse(vo.isAllowed(null));
    assertFalse(vo.isAllowed(VersionData.decode(getClass(), "1.8.3")));
    assertFalse(vo.isAllowed(VersionData.decode(getClass(), "2.8.4")));
    assertTrue(vo.isAllowed(VersionData.decode(getClass(), "2.5.4")));
    assertFalse(vo.isAllowed(VersionData.decode(String.class, "2.5.4")));
    assertFalse(vo.isAllowed(VersionData.decode(VersionData.class, "2.8.4")));
}
Also used : VersionData(com.sldeditor.common.vendoroption.VersionData) VendorOptionVersion(com.sldeditor.common.vendoroption.VendorOptionVersion) Test(org.junit.Test)

Example 19 with VendorOptionVersion

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

the class VendorOptionInfoModelTest method testAddVendorOptionInfo.

/**
 * Test method for {@link com.sldeditor.common.vendoroption.info.VendorOptionInfoModel#addVendorOptionInfo(java.util.List)}.
 */
@Test
public void testAddVendorOptionInfo() {
    VendorOptionInfoModel model = new VendorOptionInfoModel();
    assertEquals(0, model.getRowCount());
    model.addVendorOptionInfo(null);
    List<VendorOptionInfo> vendorOptionInfoList = new ArrayList<VendorOptionInfo>();
    String name = "name";
    VersionData versionDataMin = VersionData.decode(getClass(), "2.4.1");
    VersionData versionDataMax = VersionData.decode(getClass(), "2.8.3");
    VendorOptionVersion versionData = new VendorOptionVersion(GeoServerVendorOption.class, versionDataMin, versionDataMax);
    String description = "test description";
    VendorOptionInfo info = new VendorOptionInfo(name, versionData, description);
    vendorOptionInfoList.add(info);
    String name2 = "name2";
    String description2 = "test description2";
    VendorOptionVersion versionData2 = VendorOptionManager.getInstance().getDefaultVendorOptionVersion();
    vendorOptionInfoList.add(new VendorOptionInfo(name2, versionData2, description2));
    VersionData versionDataMin3 = VersionData.decode(getClass(), "2.8.1");
    VersionData versionDataMax3 = VersionData.decode(getClass(), "Latest");
    VendorOptionVersion versionData3 = new VendorOptionVersion(GeoServerVendorOption.class, versionDataMin3, versionDataMax3);
    String name3 = "name3";
    String description3 = "test description3";
    vendorOptionInfoList.add(new VendorOptionInfo(name3, versionData3, description3));
    model.addVendorOptionInfo(vendorOptionInfoList);
    assertEquals(vendorOptionInfoList.size(), model.getRowCount());
    assertNull(model.getValueAt(-1, 0));
    assertNull(model.getValueAt(-1, -1));
    assertNull(model.getValueAt(4, -1));
    assertNull(model.getValueAt(4, 4));
    assertEquals(name2, model.getValueAt(0, 0));
    assertEquals("Strict SLD", model.getValueAt(0, 1));
    assertEquals("GeoServer 2.4.1-2.8.3", model.getValueAt(1, 1));
    // Test get description
    assertNull(model.getDescription(-1));
    assertNull(model.getDescription(10));
    assertEquals(description2, model.getDescription(0));
    model.setSelectedVersion(VersionData.decode(getClass(), "2.5.1"));
    model.isVendorOptionAvailable(-1);
    model.isVendorOptionAvailable(42);
    model.isVendorOptionAvailable(1);
}
Also used : VersionData(com.sldeditor.common.vendoroption.VersionData) VendorOptionVersion(com.sldeditor.common.vendoroption.VendorOptionVersion) ArrayList(java.util.ArrayList) VendorOptionInfoModel(com.sldeditor.common.vendoroption.info.VendorOptionInfoModel) VendorOptionInfo(com.sldeditor.common.vendoroption.info.VendorOptionInfo) Test(org.junit.Test)

Example 20 with VendorOptionVersion

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

the class CoordManager method populateCRSList.

/**
 * Populate crs list.
 */
public void populateCRSList() {
    if (isPopulated()) {
        Runnable runnable = () -> {
            VendorOptionVersion vendorOptionVersion = VendorOptionManager.getInstance().getDefaultVendorOptionVersion();
            ValueComboBoxData notSetValue = new ValueComboBoxData(NOT_SET_CRS, Localisation.getString(CoordManager.class, "common.notSet"), vendorOptionVersion);
            crsDataList.add(notSetValue);
            Hints hints = null;
            for (AuthorityFactory factory : ReferencingFactoryFinder.getCRSAuthorityFactories(hints)) {
                String authorityCode = NOT_SET_CRS;
                Citation citation = factory.getAuthority();
                if (citation != null) {
                    @SuppressWarnings("unchecked") Collection<Identifier> identifierList = (Collection<Identifier>) citation.getIdentifiers();
                    authorityCode = identifierList.iterator().next().getCode();
                }
                Set<String> codeList;
                try {
                    codeList = factory.getAuthorityCodes(CoordinateReferenceSystem.class);
                    for (String code : codeList) {
                        String fullCode = String.format("%s:%s", authorityCode, code);
                        String descriptionText = factory.getDescriptionText(code).toString();
                        String text = String.format("%s - %s", fullCode, descriptionText);
                        ValueComboBoxData value = new ValueComboBoxData(fullCode, text, vendorOptionVersion);
                        crsDataList.add(value);
                        crsMap.put(fullCode, value);
                    }
                } catch (NoSuchAuthorityCodeException e) {
                // ConsoleManager.getInstance().exception(this, e);
                } catch (FactoryException e) {
                    ConsoleManager.getInstance().exception(this, e);
                }
            }
        };
        Thread thread = new Thread(runnable);
        thread.start();
    }
}
Also used : NoSuchAuthorityCodeException(org.opengis.referencing.NoSuchAuthorityCodeException) Set(java.util.Set) Hints(org.geotools.factory.Hints) FactoryException(org.opengis.referencing.FactoryException) ValueComboBoxData(com.sldeditor.ui.widgets.ValueComboBoxData) Identifier(org.opengis.metadata.Identifier) ReferenceIdentifier(org.opengis.referencing.ReferenceIdentifier) VendorOptionVersion(com.sldeditor.common.vendoroption.VendorOptionVersion) Collection(java.util.Collection) AuthorityFactory(org.opengis.referencing.AuthorityFactory) Citation(org.opengis.metadata.citation.Citation)

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