use of com.sldeditor.common.vendoroption.VersionData in project sldeditor by robward-scisys.
the class VersionCellRenderer method getTableCellRendererComponent.
/**
* (non-Javadoc)
*
* @see javax.swing.table.DefaultTableCellRenderer#getTableCellRendererComponent(javax.swing.JTable, java.lang.Object, boolean, boolean, int, int)
*/
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
if (value instanceof VersionData) {
VersionData versonData = (VersionData) value;
setText(versonData.getVersionString());
}
if (isSelected) {
setBackground(table.getSelectionBackground());
} else {
setBackground(table.getSelectionForeground());
}
return this;
}
use of com.sldeditor.common.vendoroption.VersionData 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;
}
use of com.sldeditor.common.vendoroption.VersionData in project sldeditor by robward-scisys.
the class MinimumVersion method findLatest.
/**
* Find latest version data between the vendor option version read
* from the symbol and the user default.
*
* @param earliestReadFromSymbol the earliest read from symbol
* @param userDefaultVendorOptionList the user default vendor option
* @return the version data
*/
protected VersionData findLatest(VersionData earliestReadFromSymbol, List<VersionData> userDefaultVendorOptionList) {
// Sort the list, the latest will be last
Collections.sort(userDefaultVendorOptionList);
VersionData latestUserDefault = userDefaultVendorOptionList.get(userDefaultVendorOptionList.size() - 1);
return (earliestReadFromSymbol.compareTo(latestUserDefault) == -1) ? latestUserDefault : earliestReadFromSymbol;
}
use of com.sldeditor.common.vendoroption.VersionData in project sldeditor by robward-scisys.
the class SLDEditorFileHandler method readSLDEditorFile.
/**
* Read sld editor file.
*
* @param file the file
* @return the SLD data
*/
private SLDDataInterface readSLDEditorFile(File file) {
SLDDataInterface sldData = null;
DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
DocumentBuilder documentBuilder;
try {
documentBuilder = documentBuilderFactory.newDocumentBuilder();
Document document = documentBuilder.parse(file);
String sldFile = extractTextData(document, SLDEditorFileHandler.SLD_ELEMENT);
DataSourcePropertiesInterface dataSourceProperties = DataSourceProperties.decodeXML(document, SLDEditorFileHandler.DATASOURCE_ELEMENT);
List<VersionData> vendorOptionList = extractVendorOptionData(document, SLDEditorFileHandler.VENDOR_OPTION_ELEMENT);
File f = new File(sldFile);
String sldContents = readFile(f, Charset.defaultCharset());
sldData = new SLDData(new StyleWrapper(sldFile), sldContents);
sldData.setDataSourceProperties(dataSourceProperties);
sldData.setVendorOptionList(vendorOptionList);
List<DataSourceAttributeData> fieldList = null;
sldData.setFieldList(fieldList);
sldData.setSLDFile(f);
sldData.setReadOnly(false);
sldData.setSldEditorFile(file);
List<EnvVar> envVarList = extractEnvironmentVariables(document, SLDEditorFileHandler.ENVVAR_ELEMENT);
sldData.setEnvVarList(envVarList);
LegendOptionData legendOption = LegendOptionData.decodeXML(document, SLDEditorFileHandler.LEGEND_OPTION_ELEMENT);
sldData.setLegendOptions(legendOption);
} catch (ParserConfigurationException e) {
ConsoleManager.getInstance().exception(this, e);
} catch (SAXException e) {
ConsoleManager.getInstance().exception(this, e);
} catch (IOException e) {
ConsoleManager.getInstance().exception(this, e);
}
return sldData;
}
use of com.sldeditor.common.vendoroption.VersionData 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;
}
Aggregations