use of com.sldeditor.datasource.attribute.DataSourceAttributeData in project sldeditor by robward-scisys.
the class DataSourceAttributeModel method addNewField.
/**
* Adds the new field.
*/
public void addNewField() {
int index = valueMap.size();
String name = String.format("%s_%d", DEFAULT_NEW_FIELD_NAME, index);
Class<?> fieldType = DEFAULT_NEW_FIELD_TYPE;
Object value = CreateSampleData.getFieldTypeValue(index, name, fieldType, null);
DataSourceAttributeData newField = new DataSourceAttributeData(name, fieldType, value);
valueList.add(newField);
valueMap.put(newField.getName(), newField);
}
use of com.sldeditor.datasource.attribute.DataSourceAttributeData in project sldeditor by robward-scisys.
the class DataSourceAttributeModel method retrieveData.
/**
* Retrieve data.
*
* @return the map
*/
public List<DataSourceAttributeData> retrieveData() {
List<DataSourceAttributeData> attributeList = new ArrayList<DataSourceAttributeData>();
for (int row = 0; row < this.getRowCount(); row++) {
String name = (String) this.getValueAt(row, FIELD_COLUMN_ID);
Object objValue = this.getValueAt(row, VALUE_COLUMN_ID);
DataSourceAttributeData existingData = valueMap.get(name);
if (existingData != null) {
DataSourceAttributeData data = new DataSourceAttributeData(name, existingData.getType(), objValue);
attributeList.add(data);
}
}
return attributeList;
}
use of com.sldeditor.datasource.attribute.DataSourceAttributeData in project sldeditor by robward-scisys.
the class DataSourceAttributeModel method removeFields.
/**
* Removes the fields.
*
* @param selectedRowIndexes the selected row indexes
*/
public void removeFields(int[] selectedRowIndexes) {
if (selectedRowIndexes != null) {
int index = selectedRowIndexes.length - 1;
while (index >= 0) {
int rowIndex = selectedRowIndexes[index];
if ((rowIndex >= 0) && (rowIndex < valueList.size())) {
DataSourceAttributeData data = valueList.remove(rowIndex);
if (data != null) {
valueMap.remove(data.getName());
}
}
index--;
}
}
}
use of com.sldeditor.datasource.attribute.DataSourceAttributeData in project sldeditor by robward-scisys.
the class DataSourceAttributeModel method populate.
/**
* Populate model.
*
* @param attributeList the attribute list
*/
public void populate(List<DataSourceAttributeData> attributeList) {
valueList.clear();
valueMap.clear();
if (attributeList != null) {
for (DataSourceAttributeData data : attributeList) {
valueList.add(data);
valueMap.put(data.getName(), data);
}
}
}
use of com.sldeditor.datasource.attribute.DataSourceAttributeData 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;
}
Aggregations