use of com.sldeditor.datasource.extension.filesystem.node.file.FileTreeNode in project sldeditor by robward-scisys.
the class GeoServerInput method rightMouseButton.
/*
* (non-Javadoc)
*
* @see com.sldeditor.common.filesystem.FileSystemInterface#rightMouseButton(javax.swing.JPopupMenu, java.lang.Object, java.awt.event.MouseEvent)
*/
@Override
public void rightMouseButton(JPopupMenu popupMenu, Object selectedItem, MouseEvent e) {
if (selectedItem instanceof GeoServerNode) {
GeoServerNode geoServerNode = (GeoServerNode) selectedItem;
GeoServerConnection connection = geoServerNode.getConnection();
GeoServerClientInterface client = GeoServerConnectionManager.getInstance().getConnectionMap().get(connection);
if (client != null) {
if (client.isConnected()) {
JMenuItem connectMenuItem = new JMenuItem(Localisation.getString(GeoServerInput.class, "GeoServerInput.disconnect"));
connectMenuItem.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent event) {
disconnectFromGeoServer(client);
}
});
popupMenu.add(connectMenuItem);
} else {
JMenuItem connectMenuItem = new JMenuItem(Localisation.getString(GeoServerInput.class, "GeoServerInput.connect"));
connectMenuItem.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent event) {
GeoServerNode geoserver = (GeoServerNode) selectedItem;
GeoServerConnection connection = geoserver.getConnection();
connectToGeoServer(connection);
}
});
popupMenu.add(connectMenuItem);
}
}
} else if (selectedItem instanceof FileTreeNode) {
FileTreeNode fileNode = (FileTreeNode) selectedItem;
if (ExternalFilenames.getFileExtension(fileNode.getFile().getAbsolutePath()).compareToIgnoreCase(SLD_FILE_EXTENSION) == 0) {
JMenu uploadToGeoServerMenu = new JMenu(Localisation.getString(GeoServerInput.class, "GeoServerInput.uploadToGeoServer"));
populateGeoServerConnections(uploadToGeoServerMenu);
popupMenu.add(uploadToGeoServerMenu);
}
}
}
use of com.sldeditor.datasource.extension.filesystem.node.file.FileTreeNode in project sldeditor by robward-scisys.
the class FileSystemInput method rightMouseButton.
/*
* (non-Javadoc)
*
* @see
* com.sldeditor.common.filesystem.FileSystemInterface#rightMouseButton(javax.swing.JPopupMenu,
* java.lang.Object, java.awt.event.MouseEvent)
*/
@Override
public void rightMouseButton(JPopupMenu popupMenu, Object selectedItem, MouseEvent e) {
if (selectedItem instanceof FileTreeNode) {
FileTreeNode fileTreeNode = (FileTreeNode) selectedItem;
File file = fileTreeNode.getFile();
JMenuItem connectMenuItem = new JMenuItem(Localisation.getString(FileSystemInput.class, "FileSystemInput.copyPathToClipboard"));
connectMenuItem.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent event) {
StringSelection selection = new StringSelection(file.getAbsolutePath());
Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
clipboard.setContents(selection, selection);
}
});
popupMenu.add(connectMenuItem);
}
}
use of com.sldeditor.datasource.extension.filesystem.node.file.FileTreeNode in project sldeditor by robward-scisys.
the class FileSystemInput method populate.
/*
* (non-Javadoc)
*
* @see com.sldeditor.common.filesystem.FileSystemInterface#populate(com.sldeditor.datasource.
* extension.filesystem.node.FSTree, javax.swing.tree.DefaultTreeModel,
* javax.swing.tree.DefaultMutableTreeNode)
*/
@Override
public void populate(FSTree tree, DefaultTreeModel model, DefaultMutableTreeNode rootNode) {
this.treeModel = model;
this.tree = tree;
FileTreeNode.setTreeModel(model);
FileTreeNode.setInputInterface(this);
try {
if (rootNode != null) {
boolean prePopulateFirstLevelFolders = false;
for (Path path : FileSystems.getDefault().getRootDirectories()) {
logger.debug("Adding root folder : " + path.toString());
FileTreeNode fileSystemRootNode = new FileTreeNode(path);
fileSystemRootNode.populateDirectories(prePopulateFirstLevelFolders);
rootNode.add(fileSystemRootNode);
}
}
} catch (SecurityException e) {
ConsoleManager.getInstance().exception(this, e);
} catch (FileNotFoundException e) {
ConsoleManager.getInstance().exception(this, e);
}
}
use of com.sldeditor.datasource.extension.filesystem.node.file.FileTreeNode in project sldeditor by robward-scisys.
the class MapBoxFileHandler method getSLDContents.
/*
* (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;
if (fileTreeNode.isDir()) {
// Cater for folders
return open(fileTreeNode.getFile());
} else {
// Cater for single file
File f = fileTreeNode.getFile();
String fileExtension = ExternalFilenames.getFileExtension(f.getAbsolutePath());
if (getFileExtensionList().contains(fileExtension)) {
return open(f);
}
}
}
return null;
}
use of com.sldeditor.datasource.extension.filesystem.node.file.FileTreeNode 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