use of com.sldeditor.datasource.extension.filesystem.node.database.DatabaseFeatureClassNode in project sldeditor by robward-scisys.
the class VectorToolTest method testSupports.
/**
* Test method for {@link com.sldeditor.tool.vector.VectorTool#supports(java.util.List, java.util.List, java.util.List)}.
*/
@Test
public void testSupports() {
try {
FileTreeNode vectorTreeNode = new FileTreeNode(new File("/test"), "sld_cookbook_polygon.shp");
vectorTreeNode.setFileCategory(FileTreeNodeTypeEnum.VECTOR);
FileTreeNode rasterTreeNode = new FileTreeNode(new File("/test"), "sld_cookbook_polygon.tif");
rasterTreeNode.setFileCategory(FileTreeNodeTypeEnum.RASTER);
List<Class<?>> uniqueNodeTypeList = new ArrayList<Class<?>>();
List<NodeInterface> nodeTypeList = new ArrayList<NodeInterface>();
List<SLDDataInterface> sldDataList = new ArrayList<SLDDataInterface>();
// Try vector file
nodeTypeList.add(vectorTreeNode);
VectorTool vectorTool = new VectorTool(null);
assertTrue(vectorTool.supports(uniqueNodeTypeList, nodeTypeList, sldDataList));
// Try raster file
nodeTypeList.clear();
nodeTypeList.add(rasterTreeNode);
assertFalse(vectorTool.supports(uniqueNodeTypeList, nodeTypeList, sldDataList));
// Try database feature class
nodeTypeList.clear();
DatabaseFeatureClassNode databaseFeatureClassNode = new DatabaseFeatureClassNode(null, null, "db fc");
nodeTypeList.add(databaseFeatureClassNode);
assertTrue(vectorTool.supports(uniqueNodeTypeList, nodeTypeList, sldDataList));
// Try invalid node class
nodeTypeList.clear();
nodeTypeList.add(new GeoServerStyleHeadingNode(null, null, "test"));
assertFalse(vectorTool.supports(uniqueNodeTypeList, nodeTypeList, sldDataList));
// Try with no nodes
nodeTypeList.clear();
assertFalse(vectorTool.supports(uniqueNodeTypeList, nodeTypeList, sldDataList));
// Try with null
assertFalse(vectorTool.supports(uniqueNodeTypeList, null, sldDataList));
} catch (SecurityException e) {
e.printStackTrace();
fail();
} catch (FileNotFoundException e) {
e.printStackTrace();
fail();
}
}
use of com.sldeditor.datasource.extension.filesystem.node.database.DatabaseFeatureClassNode in project sldeditor by robward-scisys.
the class DatabaseInput method getSLDContents.
/*
* (non-Javadoc)
*
* @see com.sldeditor.extension.input.FileSystemInterface#getSLDContents(com.sldeditor.extension.input.NodeInterface)
*/
@Override
public SelectedFiles getSLDContents(NodeInterface node) {
SelectedFiles selectedFiles = new SelectedFiles();
if (node instanceof DatabaseFeatureClassNode) {
List<SLDDataInterface> sldContentList = new ArrayList<SLDDataInterface>();
selectedFiles.setSldData(sldContentList);
selectedFiles.setDataSource(true);
}
return selectedFiles;
}
use of com.sldeditor.datasource.extension.filesystem.node.database.DatabaseFeatureClassNode in project sldeditor by robward-scisys.
the class DatabaseReadProgress method populateFeatureClasses.
/**
* Populate feature classes.
*
* @param connection the connection
* @param databaseNode the database node
*/
private void populateFeatureClasses(DatabaseConnection connection, DatabaseNode databaseNode) {
List<String> featureClassList = databaseFeatureClassMap.get(connection);
for (String featureClass : featureClassList) {
DatabaseFeatureClassNode fcNode = new DatabaseFeatureClassNode(this.handler, connection, featureClass);
// It is key to invoke this on the TreeModel, and NOT DefaultMutableTreeNode
treeModel.insertNodeInto(fcNode, databaseNode, databaseNode.getChildCount());
}
}
use of com.sldeditor.datasource.extension.filesystem.node.database.DatabaseFeatureClassNode in project sldeditor by robward-scisys.
the class VectorFileHandler method getSLDContents.
/**
* Gets the SLD contents.
*
* @param node the node
* @return the SLD contents
*/
/*
* (non-Javadoc)
*
* @see com.sldeditor.extension.input.FileHandlerInterface#getSLDContents(com.sldeditor.extension.input.NodeInterface)
*/
@Override
public List<SLDDataInterface> getSLDContents(NodeInterface node) {
if (node instanceof FileTreeNode) {
FileTreeNode fileTreeNode = (FileTreeNode) node;
File f = fileTreeNode.getFile();
String fileExtension = ExternalFilenames.getFileExtension(f.getAbsolutePath());
if (getFileExtensionList().contains(fileExtension)) {
return open(f);
}
} else if (node instanceof DatabaseFeatureClassNode) {
return open(null);
}
return null;
}
use of com.sldeditor.datasource.extension.filesystem.node.database.DatabaseFeatureClassNode in project sldeditor by robward-scisys.
the class VectorTool method createUI.
/**
* Creates the ui.
*/
private void createUI() {
vectorPanel = new JPanel();
FlowLayout flowLayout = (FlowLayout) vectorPanel.getLayout();
flowLayout.setVgap(0);
flowLayout.setHgap(0);
vectorPanel.setBorder(BorderFactory.createTitledBorder(Localisation.getString(VectorTool.class, "VectorTool.title")));
//
// Import vector
//
importVectorButton = new ToolButton(Localisation.getString(VectorTool.class, "VectorTool.import"), "tool/importvector.png");
vectorPanel.add(importVectorButton);
importVectorButton.setEnabled(false);
importVectorButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
if ((nodeTypeList != null) && (nodeTypeList.size() == 1)) {
if (sldEditorInterface != null) {
NodeInterface nodeInterface = nodeTypeList.get(0);
if (nodeInterface instanceof FileTreeNode) {
FileTreeNode fileTreeNode = (FileTreeNode) nodeInterface;
if (!importFile(fileTreeNode)) {
return;
}
} else if (nodeInterface instanceof DatabaseFeatureClassNode) {
DatabaseFeatureClassNode featureClassNode = (DatabaseFeatureClassNode) nodeInterface;
if (!importFeatureClass(featureClassNode)) {
return;
}
}
}
}
}
});
//
// Set data source
//
dataSourceButton = new ToolButton(Localisation.getString(VectorTool.class, "VectorTool.dataSource"), "tool/setdatasource.png");
vectorPanel.add(dataSourceButton);
dataSourceButton.setEnabled(false);
dataSourceButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
if ((nodeTypeList != null) && (nodeTypeList.size() == 1)) {
if (sldEditorInterface != null) {
NodeInterface nodeInterface = nodeTypeList.get(0);
if (nodeInterface instanceof FileTreeNode) {
FileTreeNode fileTreeNode = (FileTreeNode) nodeInterface;
setDataSource(fileTreeNode);
} else if (nodeInterface instanceof DatabaseFeatureClassNode) {
DatabaseFeatureClassNode featureClassNode = (DatabaseFeatureClassNode) nodeInterface;
setDataSource(featureClassNode);
}
}
}
}
});
vectorPanel.setPreferredSize(new Dimension(PANEL_WIDTH, ToolPanel.TOOL_PANEL_HEIGHT));
}
Aggregations