use of com.sldeditor.common.NodeInterface in project sldeditor by robward-scisys.
the class DataFlavourManager method displayMessages.
/**
* Display messages.
*
* @param destinationTreeNode the destination tree node
* @param transferredData the transferred data
* @param action the action
*/
public static void displayMessages(NodeInterface destinationTreeNode, TransferredData transferredData, int action) {
if ((destinationTreeNode == null) || (transferredData == null)) {
return;
}
String actionString = "???";
if (action == TransferHandler.MOVE) {
actionString = "Moved";
} else if (action == TransferHandler.COPY) {
actionString = "Copied";
}
String destinationString = destinationTreeNode.getHandler().getDestinationText(destinationTreeNode);
for (int index = 0; index < transferredData.getDataListSize(); index++) {
NodeInterface nodeToTransfer = (NodeInterface) transferredData.getTreePath(index).getLastPathComponent();
SelectedFiles selectedFiles = nodeToTransfer.getHandler().getSLDContents(nodeToTransfer);
for (SLDDataInterface sldData : selectedFiles.getSldData()) {
ConsoleManager.getInstance().information(DataFlavourManager.class, String.format("%s %s -> %s", actionString, sldData.getLayerName(), destinationString));
}
}
}
use of com.sldeditor.common.NodeInterface in project sldeditor by robward-scisys.
the class FSTreeCellRenderer method getTreeCellRendererComponent.
/**
* This is the only TreeCellRenderer method.
* Compute the string to display, and pass it to the wrapped renderer
*
* @see javax.swing.tree.DefaultTreeCellRenderer#getTreeCellRendererComponent(javax.swing.JTree, java.lang.Object, boolean, boolean, boolean, int, boolean)
*/
public Component getTreeCellRendererComponent(JTree tree, Object value, boolean selected, boolean expanded, boolean leaf, int row, boolean hasFocus) {
DefaultMutableTreeNode node = (DefaultMutableTreeNode) value;
Object userObject = node.getUserObject();
String name = getItemText(node, userObject);
super.getTreeCellRendererComponent(tree, name, selected, expanded, leaf, row, hasFocus);
if (node instanceof NodeInterface) {
Icon icon = ((NodeInterface) node).getIcon();
if (icon != null) {
setIcon(icon);
}
}
return this;
}
use of com.sldeditor.common.NodeInterface in project sldeditor by robward-scisys.
the class FileSystemInput method copyNodes.
/*
* (non-Javadoc)
*
* @see com.sldeditor.extension.input.FileSystemInterface#drop(com.sldeditor.extension.input.
* NodeInterface, java.util.Map)
*/
@Override
public boolean copyNodes(NodeInterface destinationTreeNode, Map<NodeInterface, List<SLDDataInterface>> copyDataMap) {
if ((destinationTreeNode == null) || (copyDataMap == null)) {
return false;
}
FileTreeNode destinationNode = (FileTreeNode) destinationTreeNode;
if (!destinationNode.isDir()) {
destinationNode = (FileTreeNode) destinationNode.getParent();
}
File destinationFolder = destinationNode.getFile();
for (NodeInterface key : copyDataMap.keySet()) {
List<SLDDataInterface> sldDataList = copyDataMap.get(key);
for (SLDDataInterface sldData : sldDataList) {
String sldFilename = sldData.getSLDFile().getAbsolutePath();
FileHandlerInterface handler = getFileHandler(sldFilename);
if (handler != null) {
String sldName = handler.getSLDName(sldData);
File existingFolder = new File(sldFilename).getParentFile();
if (existingFolder.equals(destinationFolder)) {
sldName = "Copy of " + sldName;
}
File updateFile = new File(destinationFolder, sldName);
sldData.setSLDFile(updateFile);
save(sldData);
}
}
destinationNode.refreshFolder();
if (treeModel != null) {
treeModel.reload(destinationNode);
}
}
return true;
}
use of com.sldeditor.common.NodeInterface in project sldeditor by robward-scisys.
the class GeoServerConnectionListTool method setSelectedItems.
/*
* (non-Javadoc)
*
* @see com.sldeditor.tool.ToolInterface#setSelectedItems(java.util.List, java.util.List)
*/
@Override
public void setSelectedItems(List<NodeInterface> nodeTypeList, List<SLDDataInterface> sldDataList) {
connectionList.clear();
boolean geoServerNodesSelected = false;
for (NodeInterface nodeType : nodeTypeList) {
if (nodeType instanceof GeoServerNode) {
GeoServerNode geoserverNode = (GeoServerNode) nodeType;
connectionList.add(geoserverNode.getConnection());
geoServerNodesSelected = true;
}
}
btnDuplicate.setEnabled(geoServerNodesSelected && (connectionList.size() == 1));
btnEdit.setEnabled(geoServerNodesSelected && (connectionList.size() == 1));
btnDelete.setEnabled(geoServerNodesSelected);
}
use of com.sldeditor.common.NodeInterface in project sldeditor by robward-scisys.
the class DatabaseConnectionTool method setSelectedItems.
/*
* (non-Javadoc)
*
* @see com.sldeditor.tool.ToolInterface#setSelectedItems(java.util.List, java.util.List)
*/
@Override
public void setSelectedItems(List<NodeInterface> nodeTypeList, List<SLDDataInterface> sldDataList) {
connectionList.clear();
if (nodeTypeList != null) {
for (NodeInterface node : nodeTypeList) {
if (node instanceof DatabaseNode) {
DatabaseNode databaseNode = (DatabaseNode) node;
connectionList.add(databaseNode.getConnection());
} else if (node instanceof FileTreeNode) {
FileTreeNode fileNode = (FileTreeNode) node;
if (fileNode.getFileCategory() == FileTreeNodeTypeEnum.DATABASE) {
DatabaseConnection databaseConnection = DatabaseConnectionFactory.getConnection(fileNode.getFile().getAbsolutePath());
connectionList.add(databaseConnection);
}
}
}
}
updateButtonState();
}
Aggregations