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);
}
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;
}
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;
}
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;
}
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;
}
Aggregations