use of com.sldeditor.filter.v2.envvar.EnvVar in project sldeditor by robward-scisys.
the class ExpressionSubPanel method setUpEnvVarPanel.
/**
* Sets the up env var panel.
*/
protected void setUpEnvVarPanel() {
if (VendorOptionManager.getInstance().isAllowed(this.parent.getVendorOptionList(), EnvironmentVariableField.getVendorOption())) {
panelEnvVar = new JPanel();
FlowLayout fl_panelEnvVar = (FlowLayout) panelEnvVar.getLayout();
fl_panelEnvVar.setAlignment(FlowLayout.LEFT);
rdbtnEnvVar = new JRadioButton(ENVVAR);
rdbtnEnvVar.setActionCommand(ENVVAR);
buttonGroup.add(rdbtnEnvVar);
panelEnvVar.add(rdbtnEnvVar);
envVarField = new EnvironmentVariableField(new SubPanelUpdatedInterface() {
@Override
public void updateSymbol() {
buttonGroup.setSelected(rdbtnEnvVar.getModel(), true);
updateButtonState(true);
}
}, EnvironmentVariableManager.getInstance());
panelEnvVar.add(envVarField);
box.add(panelEnvVar);
}
}
use of com.sldeditor.filter.v2.envvar.EnvVar 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.filter.v2.envvar.EnvVar in project sldeditor by robward-scisys.
the class SLDEditorFileHandler method extractEnvironmentVariables.
/**
* Extract environment variables.
*
* @param document the document
* @param envvarElement the environment variable element
* @return the list
*/
private List<EnvVar> extractEnvironmentVariables(Document document, String elementName) {
List<EnvVar> list = new ArrayList<EnvVar>();
NodeList nodeList = document.getElementsByTagName(elementName);
for (int index = 0; index < nodeList.getLength(); index++) {
Element element = (Element) nodeList.item(index);
Class<?> type = null;
try {
type = Class.forName(element.getAttribute(ENVVAR_TYPE_ATTRIBUTE));
} catch (ClassNotFoundException e) {
ConsoleManager.getInstance().exception(this, e);
}
// Assume not predefined, will get sorted out later
EnvVar envVar = new EnvVar(element.getAttribute(ENVVAR_NAME_ATTRIBUTE), type, false);
if (element.hasAttribute(ENVVAR_VALUE_ATTRIBUTE)) {
envVar.setValue(element.getAttribute(ENVVAR_VALUE_ATTRIBUTE));
}
list.add(envVar);
}
return list;
}
use of com.sldeditor.filter.v2.envvar.EnvVar in project sldeditor by robward-scisys.
the class EnvVarDlg method createUI.
/**
* Creates the ui.
*/
private void createUI() {
JPanel buttonPanel = new JPanel();
FlowLayout flowLayout = (FlowLayout) buttonPanel.getLayout();
flowLayout.setAlignment(FlowLayout.TRAILING);
getContentPane().add(buttonPanel, BorderLayout.SOUTH);
JButton btnOk = new JButton(Localisation.getString(EnvVarDlg.class, "common.ok"));
btnOk.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
okButtonPressed = true;
dataModel.updateEnvVarManager();
setVisible(false);
}
});
buttonPanel.add(btnOk);
JButton btnCancel = new JButton(Localisation.getString(EnvVarDlg.class, "common.cancel"));
btnCancel.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
okButtonPressed = false;
setVisible(false);
}
});
buttonPanel.add(btnCancel);
JPanel panel = new JPanel();
getContentPane().add(panel, BorderLayout.CENTER);
panel.setLayout(new BorderLayout(0, 0));
table = new JTable();
dataModel = new EnvVarModel(envVarMgr);
table.setModel(dataModel);
TableColumn column = table.getColumnModel().getColumn(1);
JComboBox<Class<?>> typeComboBox = new JComboBox<Class<?>>();
typeComboBox.setModel(new EnvVarComboBoxModel(envVarMgr));
column.setCellEditor(new DefaultCellEditor(typeComboBox));
JScrollPane scrollPane = new JScrollPane(table);
panel.add(scrollPane, BorderLayout.CENTER);
table.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
@Override
public void valueChanged(ListSelectionEvent e) {
boolean enableRemoveButton = false;
EnvVar envVar = dataModel.getEnvVar(table.getSelectedRow());
if (envVar != null) {
enableRemoveButton = !envVar.isPredefined();
}
btnRemove.setEnabled(enableRemoveButton);
}
});
JPanel panelWMS = new JPanel();
panel.add(panelWMS, BorderLayout.NORTH);
panelWMS.setLayout(new BoxLayout(panelWMS, BoxLayout.X_AXIS));
JButton btnDecode = new JButton(Localisation.getString(EnvVarDlg.class, "EnvVarDlg.decode"));
btnDecode.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
URL url;
try {
url = new URL(textField.getText());
Map<String, List<String>> parameterMap = splitQuery(url);
if (parameterMap.containsKey(WMS_ENV_PARAMETER)) {
dataModel.addNew(parameterMap.get(WMS_ENV_PARAMETER));
}
} catch (MalformedURLException e1) {
ConsoleManager.getInstance().exception(this, e1);
} catch (UnsupportedEncodingException e1) {
ConsoleManager.getInstance().exception(this, e1);
}
}
});
panelWMS.add(btnDecode);
textField = new JTextField();
panelWMS.add(textField);
textField.setColumns(40);
JPanel panel_1 = new JPanel();
panel.add(panel_1, BorderLayout.SOUTH);
JButton btnAdd = new JButton(Localisation.getString(EnvVarDlg.class, "EnvVarDlg.add"));
btnAdd.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
dataModel.addNewVariable();
btnRemove.setEnabled(false);
}
});
panel_1.add(btnAdd);
btnRemove = new JButton(Localisation.getString(EnvVarDlg.class, "EnvVarDlg.remove"));
btnRemove.setEnabled(false);
btnRemove.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
dataModel.removeEnvVar(table.getSelectedRow());
btnRemove.setEnabled(false);
}
});
panel_1.add(btnRemove);
}
use of com.sldeditor.filter.v2.envvar.EnvVar in project sldeditor by robward-scisys.
the class EnvVarModel method addNewVariable.
/**
* Adds the new variable.
*/
public void addNewVariable() {
EnvVar envVar = this.envMgr.addNewEnvVar("NewEnvVar", String.class, null);
if (envVar != null) {
dataList.add(envVar);
this.fireTableDataChanged();
}
}
Aggregations