use of com.sldeditor.tool.ToolButton in project sldeditor by robward-scisys.
the class MapBoxToolTest method testSetSelectedItems.
/**
* Test method for
* {@link com.sldeditor.tool.mapbox.MapBoxTool#setSelectedItems(java.util.List, java.util.List)}.
*/
@Test
public void testSetSelectedItems() {
MapBoxTool tool = new MapBoxTool();
JPanel panel = tool.getPanel();
ToolButton toSLD = null;
for (Component c : panel.getComponents()) {
if (c instanceof ToolButton) {
ToolButton button = (ToolButton) c;
String toolTipText = button.getToolTipText();
if (toolTipText.compareTo(Localisation.getString(MapBoxTool.class, "MapBoxTool.exportToSLD")) == 0) {
toSLD = button;
}
}
}
File testFile1 = null;
File testFile3 = null;
try {
testFile1 = File.createTempFile("invalid", ".tst");
testFile3 = File.createTempFile("valid", ".json");
} catch (IOException e1) {
e1.printStackTrace();
}
// Should both be disabled
assertFalse(toSLD.isEnabled());
tool.setSelectedItems(null, null);
// Invalid file
List<SLDDataInterface> sldDataList = new ArrayList<SLDDataInterface>();
SLDData sldData1 = new SLDData(null, null);
sldData1.setSLDFile(testFile1);
sldDataList.add(sldData1);
tool.setSelectedItems(null, sldDataList);
// Should both be disabled
assertFalse(toSLD.isEnabled());
/*
* // Try with valid mapbox file sldDataList = new ArrayList<SLDDataInterface>(); SLDData
* sldData3 = getSLDDataFile("/point/mapbox/circleStyleTest.json");
* sldDataList.add(sldData3); tool.setSelectedItems(null, sldDataList);
*
* // SLD should be enabled assertTrue(toSLD.isEnabled()); toSLD.doClick();
*
* // Try with valid sld files sldDataList = new ArrayList<SLDDataInterface>();
* sldDataList.add(sldData3); tool.setSelectedItems(null, sldDataList);
*
* // SLD should be enabled assertTrue(toSLD.isEnabled());
*/
testFile1.delete();
testFile3.delete();
// tidyUpTempFiles(sldData3.getSLDFile());
}
use of com.sldeditor.tool.ToolButton in project sldeditor by robward-scisys.
the class DatabaseConnectionTool method createUI.
/**
* Creates the ui.
*/
private void createUI() {
panel = new JPanel();
FlowLayout flowLayout = (FlowLayout) panel.getLayout();
flowLayout.setVgap(0);
flowLayout.setHgap(0);
panel.setBorder(BorderFactory.createTitledBorder(Localisation.getString(DatabaseConnectionTool.class, "DatabaseConnectionTool.title")));
//
// Connect button
//
connectButton = new ToolButton(Localisation.getString(DatabaseConnectionTool.class, "DatabaseConnectionTool.connect"), "tool/connect.png");
connectButton.setEnabled(true);
connectButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
connect();
}
});
panel.add(connectButton);
//
// Disconnect button
//
disconnectButton = new ToolButton(Localisation.getString(DatabaseConnectionTool.class, "DatabaseConnectionTool.disconnect"), "tool/disconnect.png");
disconnectButton.setEnabled(false);
disconnectButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
disconnect();
}
});
panel.add(disconnectButton);
panel.setPreferredSize(new Dimension(PANEL_WIDTH, ToolPanel.TOOL_PANEL_HEIGHT));
}
use of com.sldeditor.tool.ToolButton in project sldeditor by robward-scisys.
the class GeoServerLayerUpdateTool method createUI.
/**
* Creates the ui.
*/
private void createUI() {
panel = new JPanel();
panel.setBorder(BorderFactory.createTitledBorder(Localisation.getString(GeoServerLayerUpdateTool.class, "GeoServerLayerUpdateTool.title")));
button = new ToolButton(Localisation.getString(GeoServerLayerUpdateTool.class, "GeoServerLayerUpdateTool.layer"), "tool/layerupdate.png");
button.setEnabled(true);
button.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
ConfigureLayerStyleDialog dlg = new ConfigureLayerStyleDialog();
Map<String, List<StyleWrapper>> styleMap = geoServerLayerUpdate.getStyleMap(connection);
if (dlg.populate(styleMap, layerList)) {
geoServerLayerUpdate.updateLayerStyle(dlg.getUpdatedLayerStyles());
}
}
});
panel.add(button);
panel.setPreferredSize(new Dimension(PANEL_WIDTH, ToolPanel.TOOL_PANEL_HEIGHT));
}
use of com.sldeditor.tool.ToolButton in project sldeditor by robward-scisys.
the class ScaleTool method createUI.
/**
* Creates the ui.
*/
private void createUI() {
scaleGroupPanel = new JPanel();
FlowLayout flowLayout = (FlowLayout) scaleGroupPanel.getLayout();
flowLayout.setVgap(0);
flowLayout.setHgap(0);
scaleGroupPanel.setBorder(BorderFactory.createTitledBorder(Localisation.getString(ScaleTool.class, "ScaleTool.scale")));
scaleButton = new ToolButton(Localisation.getString(ScaleTool.class, "ScaleTool.scale"), "tool/scaletool.png");
scaleGroupPanel.add(scaleButton);
scaleButton.setEnabled(false);
scaleButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
ScaleToolPanel scalePanel = new ScaleToolPanel(application);
scalePanel.populate(sldDataList);
scalePanel.setVisible(true);
}
});
scaleGroupPanel.setPreferredSize(new Dimension(PANEL_WIDTH, ToolPanel.TOOL_PANEL_HEIGHT));
}
use of com.sldeditor.tool.ToolButton in project sldeditor by robward-scisys.
the class RasterTool method createUI.
/**
* Creates the ui.
*/
private void createUI() {
rasterPanel = new JPanel();
FlowLayout flowLayout = (FlowLayout) rasterPanel.getLayout();
flowLayout.setVgap(0);
flowLayout.setHgap(0);
rasterPanel.setBorder(BorderFactory.createTitledBorder(Localisation.getString(RasterTool.class, "RasterTool.title")));
//
// Import raster
//
importRasterButton = new ToolButton(Localisation.getString(RasterTool.class, "RasterTool.import"), "tool/importraster.png");
rasterPanel.add(importRasterButton);
importRasterButton.setEnabled(false);
importRasterButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
if ((nodeTypeList != null) && (nodeTypeList.size() == 1)) {
if (sldEditorInterface != null) {
FileTreeNode fileTreeNode = (FileTreeNode) nodeTypeList.get(0);
File rasterFile = fileTreeNode.getFile();
ConsoleManager.getInstance().information(this, String.format("%s : %s", Localisation.getString(RasterTool.class, "RasterTool.createSymbol"), rasterFile.getAbsolutePath()));
SLDDataInterface sldData = rasterReader.createRasterSLDData(rasterFile);
// Raster file
DataSourcePropertiesInterface dsProperties = SLDEditorFile.getInstance().getDataSource();
DataSourceConnectorInterface dsc = DataSourceConnectorFactory.getDataSource(DataSourceConnector.class);
dsProperties = dsc.getDataSourceProperties(DataSourceProperties.encodeFilename(rasterFile.getAbsolutePath()));
SLDEditorFile.getInstance().setSLDData(sldData);
SLDEditorFile.getInstance().setDataSource(dsProperties);
// Clear the data change flag
SLDEditorFile.getInstance().fileOpenedSaved();
// Load sld
List<SLDDataInterface> sldFilesToLoad = new ArrayList<SLDDataInterface>();
sldFilesToLoad.add(sldData);
SelectedFiles selectedFiles = new SelectedFiles();
selectedFiles.setSldData(sldFilesToLoad);
selectedFiles.setFolderName(rasterFile.getParent());
LoadSLDInterface loadSLD = sldEditorInterface.getLoadSLDInterface();
loadSLD.loadSLDString(selectedFiles);
}
}
}
});
//
// Set data source
//
dataSourceButton = new ToolButton(Localisation.getString(RasterTool.class, "RasterTool.dataSource"), "tool/setdatasource.png");
rasterPanel.add(dataSourceButton);
dataSourceButton.setEnabled(false);
dataSourceButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
if ((nodeTypeList != null) && (nodeTypeList.size() == 1)) {
if (sldEditorInterface != null) {
FileTreeNode fileTreeNode = (FileTreeNode) nodeTypeList.get(0);
File rasterFile = fileTreeNode.getFile();
ConsoleManager.getInstance().information(this, String.format("%s : %s", Localisation.getString(RasterTool.class, "RasterTool.setDataSource"), rasterFile.getAbsolutePath()));
// Raster file
DataSourceConnectorInterface dsc = DataSourceConnectorFactory.getDataSource(DataSourceConnector.class);
String rasterFilename = null;
try {
rasterFilename = rasterFile.toURI().toURL().toString();
} catch (MalformedURLException exceptionObj) {
ConsoleManager.getInstance().exception(RasterTool.class, exceptionObj);
return;
}
DataSourcePropertiesInterface dsProperties = dsc.getDataSourceProperties(DataSourceProperties.encodeFilename(rasterFilename));
SLDEditorFile.getInstance().setDataSource(dsProperties);
DataSourceInterface dataSource = DataSourceFactory.createDataSource(null);
if (dataSource != null) {
dataSource.connect(rasterFilename, SLDEditorFile.getInstance(), null);
}
}
}
}
});
rasterPanel.setPreferredSize(new Dimension(PANEL_WIDTH, ToolPanel.TOOL_PANEL_HEIGHT));
}
Aggregations