use of com.sldeditor.common.filesystem.FileSystemInterface in project sldeditor by robward-scisys.
the class FileSystemExtension method save.
/**
* Save.
*
* @param sldData the sld data
* @return true, if successful
*/
/*
* (non-Javadoc)
*
* @see com.sldeditor.extension.ExtensionInterface#save(java.net.URL, com.sldeditor.ui.iface.SLDDataInterface)
*/
@Override
public boolean save(SLDDataInterface sldData) {
boolean saved = false;
for (FileSystemInterface extension : extensionList) {
if (saved == false) {
saved = extension.save(sldData);
}
}
if (saved) {
FileSystemInput fileSystemInput = FileSystemExtensionFactory.getFileSystemInput();
if (fileSystemInput != null) {
fileSystemInput.setFolder(sldData.getSLDURL(), true);
}
}
sldSaved = true;
return saved;
}
use of com.sldeditor.common.filesystem.FileSystemInterface in project sldeditor by robward-scisys.
the class FileSystemExtension method initialise.
/**
* Initialise.
*
* @param parent the parent
* @param toolMgr the tool manager
*/
@Override
public void initialise(LoadSLDInterface parent, ToolSelectionInterface toolMgr) {
this.toolMgr = toolMgr;
this.parentObj = parent;
if (toolMgr != null) {
toolMgr.addRecursiveListener(this);
}
// Add extensions
extensionList = FileSystemExtensionFactory.getFileExtensionList(toolMgr);
extensionPanel = new JPanel();
extensionPanel.setLayout(new BorderLayout());
extensionPanel.setPreferredSize(new Dimension(450, 400));
JPanel toolPanel = null;
if (toolMgr != null) {
toolPanel = toolMgr.getPanel();
}
if (toolPanel != null) {
extensionPanel.add(toolPanel, BorderLayout.NORTH);
}
tree = new FSTree();
tree.setRootVisible(true);
DefaultMutableTreeNode rootNode;
try {
rootNode = new DefaultMutableTreeNode(ROOT_NODE);
model = new DefaultTreeModel(rootNode);
FileSystemNodeManager.create(tree, model);
for (FileSystemInterface extension : extensionList) {
extension.populate(tree, model, rootNode);
}
} catch (SecurityException e1) {
ConsoleManager.getInstance().exception(this, e1);
}
tree.setModel(model);
tree.setDragEnabled(true);
tree.getSelectionModel().setSelectionMode(TreeSelectionModel.DISCONTIGUOUS_TREE_SELECTION);
tree.addMouseListener(new MouseListener() {
@Override
public void mouseClicked(MouseEvent e) {
if (SwingUtilities.isRightMouseButton(e)) {
int row = tree.getClosestRowForLocation(e.getX(), e.getY());
tree.setSelectionRow(row);
Object selectedItem = tree.getLastSelectedPathComponent();
Thread t1 = new Thread(new Runnable() {
public void run() {
JPopupMenu popupMenu = new JPopupMenu();
for (FileSystemInterface extension : extensionList) {
extension.rightMouseButton(popupMenu, selectedItem, e);
}
if ((popupMenu.getComponentCount() > 0) && (e != null)) {
popupMenu.show(e.getComponent(), e.getX(), e.getY());
}
}
});
t1.start();
}
}
@Override
public void mousePressed(MouseEvent e) {
}
@Override
public void mouseReleased(MouseEvent e) {
}
@Override
public void mouseEntered(MouseEvent e) {
}
@Override
public void mouseExited(MouseEvent e) {
}
});
// Listen for Tree Selection Events
tree.addTreeExpansionListener(new TreeExpansionListener() {
/*
* (non-Javadoc)
*
* @see javax.swing.event.TreeExpansionListener#treeExpanded(javax.swing.event.TreeExpansionEvent)
*/
public void treeExpanded(TreeExpansionEvent evt) {
TreePath path = evt.getPath();
Object selectedItem = path.getLastPathComponent();
for (FileSystemInterface extension : extensionList) {
if (extension.treeExpanded(selectedItem)) {
((DefaultTreeModel) tree.getModel()).nodeStructureChanged((TreeNode) selectedItem);
}
}
}
/*
* (non-Javadoc)
*
* @see javax.swing.event.TreeExpansionListener#treeCollapsed(javax.swing.event.TreeExpansionEvent)
*/
public void treeCollapsed(TreeExpansionEvent evt) {
// Nothing to do
}
});
// Tree selection listener
tree.setTreeSelection(this);
JPanel panel = new JPanel();
panel.setLayout(new BoxLayout(panel, BoxLayout.LINE_AXIS));
panel.add(new JScrollPane(tree));
extensionPanel.add(panel, BorderLayout.CENTER);
logger.debug("FileSystem initialise finished");
}
use of com.sldeditor.common.filesystem.FileSystemInterface in project sldeditor by robward-scisys.
the class FileSystemExtensionTest method testInitialise.
/**
* Test method for
* {@link com.sldeditor.extension.filesystem.FileSystemExtension#initialise(com.sldeditor.common.LoadSLDInterface, com.sldeditor.common.ToolSelectionInterface)}.
*/
@Test
public void testInitialise() {
FileSystemExtension fsExt = new FileSystemExtension();
DummyExtension dummyExtension = new DummyExtension();
List<FileSystemInterface> overrideExtensionList = new ArrayList<FileSystemInterface>();
overrideExtensionList.add(dummyExtension);
FileSystemExtensionFactory.override(overrideExtensionList);
fsExt.initialise(null, null);
fsExt.initialise(null, new DummyToolMgr());
}
use of com.sldeditor.common.filesystem.FileSystemInterface in project sldeditor by robward-scisys.
the class FileSystemExtensionTest method testGetPanel.
/**
* Test method for {@link com.sldeditor.extension.filesystem.FileSystemExtension#getPanel()}.
*/
@Test
public void testGetPanel() {
FileSystemExtension fsExt = new FileSystemExtension();
DummyExtension dummyExtension = new DummyExtension();
List<FileSystemInterface> overrideExtensionList = new ArrayList<FileSystemInterface>();
overrideExtensionList.add(dummyExtension);
FileSystemExtensionFactory.override(overrideExtensionList);
fsExt.initialise(null, null);
assertTrue(fsExt.getPanel() != null);
}
use of com.sldeditor.common.filesystem.FileSystemInterface in project sldeditor by robward-scisys.
the class FileSystemExtensionTest method testSave.
/**
* Test method for
* {@link com.sldeditor.extension.filesystem.FileSystemExtension#save(com.sldeditor.common.SLDDataInterface)}.
*/
@Test
public void testSave() {
FileSystemExtension fsExt = new FileSystemExtension();
DummyExtension dummyExtension = new DummyExtension();
List<FileSystemInterface> overrideExtensionList = new ArrayList<FileSystemInterface>();
overrideExtensionList.add(dummyExtension);
FileSystemExtensionFactory.override(overrideExtensionList);
fsExt.initialise(null, null);
// Try null parameter
assertFalse(fsExt.save(null));
assertTrue(fsExt.save(new SLDData(null, null)));
}
Aggregations