use of org.freeplane.plugin.workspace.model.AWorkspaceTreeNode in project freeplane by freeplane.
the class FolderLinkNode method getTransferable.
public WorkspaceTransferable getTransferable() {
WorkspaceTransferable transferable = new WorkspaceTransferable();
try {
URI uri = URIUtils.getAbsoluteURI(getPath());
transferable.addData(WorkspaceTransferable.WORKSPACE_URI_LIST_FLAVOR, uri.toString());
List<File> fileList = new Vector<File>();
fileList.add(new File(uri));
transferable.addData(WorkspaceTransferable.WORKSPACE_FILE_LIST_FLAVOR, fileList);
if (!this.isSystem()) {
List<AWorkspaceTreeNode> objectList = new ArrayList<AWorkspaceTreeNode>();
objectList.add(this);
transferable.addData(WorkspaceTransferable.WORKSPACE_NODE_FLAVOR, objectList);
}
return transferable;
} catch (Exception e) {
LogUtils.warn(e);
}
return null;
}
use of org.freeplane.plugin.workspace.model.AWorkspaceTreeNode in project freeplane by freeplane.
the class InputController method mouseClicked.
/**
*********************************************************************************
* REQUIRED METHODS FOR INTERFACES
*********************************************************************************
*/
public void mouseClicked(MouseEvent e) {
if (e.isConsumed()) {
return;
}
TreePath path = ((JTree) e.getSource()).getClosestPathForLocation(e.getX(), e.getY());
((TreeView) WorkspaceController.getCurrentModeExtension().getView()).addSelectionPath(path);
if (path != null) {
AWorkspaceTreeNode node = (AWorkspaceTreeNode) path.getLastPathComponent();
// encode buttons
int eventType = 0;
if (e.getButton() == MouseEvent.BUTTON1) {
eventType += WorkspaceActionEvent.MOUSE_LEFT;
}
if (e.getButton() == MouseEvent.BUTTON3) {
eventType += WorkspaceActionEvent.MOUSE_RIGHT;
}
if (e.getClickCount() % 2 == 0) {
eventType += WorkspaceActionEvent.MOUSE_DBLCLICK;
} else {
eventType += WorkspaceActionEvent.MOUSE_CLICK;
}
if (e.isPopupTrigger()) {
eventType += WorkspaceActionEvent.POPUP_TRIGGER;
}
WorkspaceActionEvent event = new WorkspaceActionEvent(node, eventType, e.getX(), e.getY(), e.getComponent());
List<IWorkspaceNodeActionListener> nodeEventListeners = WorkspaceController.getCurrentModeExtension().getIOController().getNodeActionListeners(node.getClass(), eventType);
if (nodeEventListeners != null) {
for (IWorkspaceNodeActionListener listener : nodeEventListeners) {
if (event.isConsumed()) {
break;
}
listener.handleAction(event);
}
}
if (!event.isConsumed() && node instanceof IWorkspaceNodeActionListener) {
((IWorkspaceNodeActionListener) node).handleAction(event);
}
} else {
if (e.getButton() == MouseEvent.BUTTON3) {
// WorkspaceController.getController().getPopups().showWorkspacePopup(e.getComponent(), e.getX(), e.getY());
((AWorkspaceTreeNode) WorkspaceController.getCurrentModel().getRoot()).showPopup(e.getComponent(), e.getX(), e.getY());
}
}
}
use of org.freeplane.plugin.workspace.model.AWorkspaceTreeNode in project freeplane by freeplane.
the class VirtualFolderDropHandler method processUriListDrop.
private void processUriListDrop(AWorkspaceTreeNode targetNode, List<URI> uris, int dropAction) {
try {
for (URI uri : uris) {
File srcFile = new File(uri);
if (srcFile == null || !srcFile.exists()) {
continue;
}
AWorkspaceTreeNode node = createFSNodeLinks(targetNode, srcFile);
targetNode.getModel().addNodeTo(node, targetNode);
node.refresh();
}
;
// WorkspaceUtils.saveCurrentConfiguration();
} catch (Exception e) {
LogUtils.warn(e);
}
}
use of org.freeplane.plugin.workspace.model.AWorkspaceTreeNode in project freeplane by freeplane.
the class VirtualFolderDropHandler method processDrop.
/**
*********************************************************************************
* REQUIRED METHODS FOR INTERFACES
*********************************************************************************
*/
@SuppressWarnings("unchecked")
public boolean processDrop(AWorkspaceTreeNode targetNode, Transferable transferable, int dropAction) {
try {
if (transferable.isDataFlavorSupported(WorkspaceTransferable.WORKSPACE_NODE_FLAVOR)) {
processWorkspaceNodeDrop(targetNode, (List<AWorkspaceTreeNode>) transferable.getTransferData(WorkspaceTransferable.WORKSPACE_NODE_FLAVOR), dropAction);
} else if (transferable.isDataFlavorSupported(WorkspaceTransferable.WORKSPACE_FILE_LIST_FLAVOR)) {
processFileListDrop(targetNode, (List<File>) transferable.getTransferData(WorkspaceTransferable.WORKSPACE_FILE_LIST_FLAVOR), dropAction);
} else if (transferable.isDataFlavorSupported(WorkspaceTransferable.WORKSPACE_URI_LIST_FLAVOR)) {
ArrayList<URI> uriList = new ArrayList<URI>();
String uriString = (String) transferable.getTransferData(WorkspaceTransferable.WORKSPACE_URI_LIST_FLAVOR);
if (!uriString.startsWith("file://")) {
return false;
}
String[] uriArray = uriString.split("\r\n");
for (String singleUri : uriArray) {
try {
uriList.add(URIUtils.createURI(singleUri));
} catch (Exception e) {
LogUtils.info("org.freeplane.plugin.workspace.mindmapmode.VirtualFolderDropHandler.processDrop(targetNode, transferable, dropAction)@1:" + e.getMessage());
}
}
processUriListDrop(targetNode, uriList, dropAction);
}
targetNode.refresh();
IWorkspaceView view = WorkspaceController.getCurrentModeExtension().getView();
if (view != null) {
view.expandPath(targetNode.getTreePath());
WorkspaceController.getCurrentModeExtension().getView().refreshView();
}
} catch (Exception e) {
LogUtils.warn("org.freeplane.plugin.workspace.mindmapmode.VirtualFolderDropHandler.processDrop(targetNode, transferable, dropAction)@2", e);
}
return true;
}
use of org.freeplane.plugin.workspace.model.AWorkspaceTreeNode in project freeplane by freeplane.
the class VirtualFolderDropHandler method createFSNodeLinks.
/**
* @param file
* @return
*/
private AWorkspaceTreeNode createFSNodeLinks(AWorkspaceTreeNode targetNode, File file) {
AWorkspaceTreeNode node = null;
AWorkspaceProject project = WorkspaceController.getProject(targetNode);
if (file.isDirectory()) {
FolderLinkNode pNode = new FolderLinkNode();
pNode.setPath(project.getRelativeURI(file.toURI()));
node = pNode;
} else {
LinkTypeFileNode lNode = new LinkTypeFileNode();
lNode.setLinkURI(project.getRelativeURI(file.toURI()));
node = lNode;
}
node.setName(file.getName());
return node;
}
Aggregations