Search in sources :

Example 6 with VersionData

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;
}
Also used : VersionData(com.sldeditor.common.vendoroption.VersionData)

Example 7 with VersionData

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;
}
Also used : VersionData(com.sldeditor.common.vendoroption.VersionData) ArrayList(java.util.ArrayList) VendorOptionInfo(com.sldeditor.common.vendoroption.info.VendorOptionInfo)

Example 8 with VersionData

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;
}
Also used : VersionData(com.sldeditor.common.vendoroption.VersionData)

Example 9 with VersionData

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;
}
Also used : SLDData(com.sldeditor.common.data.SLDData) DataSourceAttributeData(com.sldeditor.datasource.attribute.DataSourceAttributeData) DocumentBuilderFactory(javax.xml.parsers.DocumentBuilderFactory) IOException(java.io.IOException) Document(org.w3c.dom.Document) DataSourcePropertiesInterface(com.sldeditor.common.DataSourcePropertiesInterface) LegendOptionData(com.sldeditor.ui.legend.option.LegendOptionData) SAXException(org.xml.sax.SAXException) SLDDataInterface(com.sldeditor.common.SLDDataInterface) DocumentBuilder(javax.xml.parsers.DocumentBuilder) StyleWrapper(com.sldeditor.common.data.StyleWrapper) VersionData(com.sldeditor.common.vendoroption.VersionData) EnvVar(com.sldeditor.filter.v2.envvar.EnvVar) ParserConfigurationException(javax.xml.parsers.ParserConfigurationException) SLDEditorFile(com.sldeditor.datasource.SLDEditorFile) File(java.io.File)

Example 10 with VersionData

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;
}
Also used : VersionData(com.sldeditor.common.vendoroption.VersionData) NodeList(org.w3c.dom.NodeList) VendorOptionVersion(com.sldeditor.common.vendoroption.VendorOptionVersion) ArrayList(java.util.ArrayList)

Aggregations

VersionData (com.sldeditor.common.vendoroption.VersionData)56 Test (org.junit.Test)36 ArrayList (java.util.ArrayList)26 VendorOptionVersion (com.sldeditor.common.vendoroption.VendorOptionVersion)13 GeoServerVendorOption (com.sldeditor.common.vendoroption.GeoServerVendorOption)9 PrefData (com.sldeditor.common.preferences.PrefData)7 VendorOptionInfo (com.sldeditor.common.vendoroption.info.VendorOptionInfo)5 Color (java.awt.Color)5 SLDData (com.sldeditor.common.data.SLDData)4 VendorOptionTypeInterface (com.sldeditor.common.vendoroption.VendorOptionTypeInterface)4 File (java.io.File)4 VendorOptionTableModel (com.sldeditor.common.vendoroption.selection.VendorOptionTableModel)3 ValueComboBoxDataGroup (com.sldeditor.ui.widgets.ValueComboBoxDataGroup)3 IOException (java.io.IOException)3 LinkedHashMap (java.util.LinkedHashMap)3 DataSourcePropertiesInterface (com.sldeditor.common.DataSourcePropertiesInterface)2 StyleWrapper (com.sldeditor.common.data.StyleWrapper)2 JsonArray (com.google.gson.JsonArray)1 JsonObject (com.google.gson.JsonObject)1 JsonParser (com.google.gson.JsonParser)1