Package org.freeplane.plugin.workspace.model

Examples of org.freeplane.plugin.workspace.model.AWorkspaceTreeNode


      return;
    }
   
    TreePath targetPath = view.getPathForLocation(event.getLocation().x, event.getLocation().y);
    if(targetPath != null) {
      AWorkspaceTreeNode targetNode = (AWorkspaceTreeNode) targetPath.getLastPathComponent();
      if(processDrop(targetNode, event)) {
        return;
     
    }
    event.rejectDrop();
View Full Code Here


   **********************************************************************************/

  public Component getTreeCellEditorComponent(JTree tree, Object treeNode, boolean isSelected, boolean expanded, boolean leaf,
      int row) {
    if (treeNode instanceof AWorkspaceTreeNode) {
      AWorkspaceTreeNode node = (AWorkspaceTreeNode) treeNode;
      setNodeIcon(renderer,node);
      return super.getTreeCellEditorComponent(tree, node.getName(), isSelected, expanded, leaf, row)
    }
    return super.getTreeCellEditorComponent(tree, treeNode, isSelected, expanded, leaf, row);
  }
View Full Code Here

    if (event != null && event.getSource() instanceof JTree) {
      setTree((JTree) event.getSource());
      if (event instanceof MouseEvent) {
        TreePath path = tree.getPathForLocation(((MouseEvent) event).getX(), ((MouseEvent) event).getY());
        if (path != null) {
          AWorkspaceTreeNode treeNode = (AWorkspaceTreeNode) path.getLastPathComponent();
          if(!treeNode.isEditable()) {
            return false;
          }         
        }
      }
    }
View Full Code Here

  public NodeOpenLocationAction() {
    super(KEY);
  }
 
  public void actionPerformed(ActionEvent event) {
    AWorkspaceTreeNode targetNode = getNodeFromActionEvent(event);
    if(targetNode instanceof IFileSystemRepresentation) {
      openFolder(((IFileSystemRepresentation) targetNode).getFile());
    }
    else if(targetNode instanceof ProjectRootNode) {
      openFolder(URIUtils.getAbsoluteFile(WorkspaceController.getProject(targetNode).getProjectHome()));
View Full Code Here

  public ExpandedStateHandler(JTree tree) {
    this.treeView = tree;
  }

  public void treeExpanded(TreeExpansionEvent event) {
    final AWorkspaceTreeNode node = (AWorkspaceTreeNode)event.getPath().getLastPathComponent();
    expandedNodeKeys.add(node.getKey());
  }
View Full Code Here

    final AWorkspaceTreeNode node = (AWorkspaceTreeNode)event.getPath().getLastPathComponent();
    expandedNodeKeys.add(node.getKey());
  }

  public void treeCollapsed(TreeExpansionEvent event) {
    final AWorkspaceTreeNode node = (AWorkspaceTreeNode)event.getPath().getLastPathComponent();
    expandedNodeKeys.remove(node.getKey());
   
  }
View Full Code Here

 
  public void setExpandedStates(WorkspaceTreeModel targetModel, boolean cleanInvalidEntries) {
    Iterator<String> iter = expandedNodeKeys.iterator();
    try {
      while(iter.hasNext()) {
        AWorkspaceTreeNode node = targetModel.getNode(iter.next());
        if(node != null) {
          treeView.expandPath(node.getTreePath());
        }
        else {
          if(cleanInvalidEntries) {
            iter.remove();
          }
View Full Code Here

  /***********************************************************************************
   * REQUIRED METHODS FOR INTERFACES
   **********************************************************************************/

  public void actionPerformed(ActionEvent e) {
    AWorkspaceTreeNode targetNode = null;
    if(e == null || getRootPopupMenu((Component) e.getSource()) == null) {
      targetNode = WorkspaceController.getCurrentProject().getModel().getRoot();
    }
    else {
      targetNode = getNodeFromActionEvent(e);
    }
   
    if(targetNode == null) {
      return;
    }
    AWorkspaceProject project = WorkspaceController.getProject(targetNode);
    if(targetNode instanceof AFolderNode) {
      JFileChooser chooser = new JFileChooser(URIUtils.getAbsoluteFile(((AFolderNode) targetNode).getPath() == null ? WorkspaceController.getCurrentProject().getProjectHome() : ((AFolderNode) targetNode).getPath()));
      chooser.setMultiSelectionEnabled(false);
      int response = chooser.showOpenDialog(UITools.getFrame());
      if(response == JFileChooser.APPROVE_OPTION) {
        File file = chooser.getSelectedFile();
        if(file != null) {
          LinkTypeFileNode node = new LinkTypeFileNode();
          node.setName(file.getName());
          URI path = chooser.getSelectedFile().toURI();
          if (path == null) {
            return;
          }
          URI uri = project.getRelativeURI(path);
          if(uri == null) {
            node.setLinkURI(path);
          }
          else {
            node.setLinkURI(uri);
          }
          targetNode.getModel().addNodeTo(node, targetNode);
          targetNode.refresh();
          targetNode.getModel().requestSave();
        }
      }
    }
   
  }
View Full Code Here

        public void popupMenuWillBecomeVisible(final PopupMenuEvent e) {
          if(action instanceof AWorkspaceAction && e.getSource() instanceof WorkspacePopupMenu) {
            WorkspacePopupMenu menu = ((WorkspacePopupMenu)e.getSource());
            TreePath[] selectedNodes = ((JTree)menu.getInvoker()).getSelectionPaths();
            AWorkspaceTreeNode node = (AWorkspaceTreeNode) ((JTree)menu.getInvoker()).getClosestPathForLocation(menu.getInvokerLocation().x, menu.getInvokerLocation().y).getLastPathComponent();
            ((AWorkspaceAction) action).setSelectedFor(node, selectedNodes);
          }
          else {
            action.setSelected();
          }
        }
      });
    }
    if (AWorkspaceAction.checkEnabledOnPopup(action)) {
      popupMenu.addPopupMenuListener(new PopupMenuListener() {
        public void popupMenuCanceled(final PopupMenuEvent e) {
        }

        public void popupMenuWillBecomeInvisible(final PopupMenuEvent e) {
        }

        public void popupMenuWillBecomeVisible(final PopupMenuEvent e) {
          if(action instanceof AWorkspaceAction && e.getSource() instanceof WorkspacePopupMenu) {
            WorkspacePopupMenu menu = ((WorkspacePopupMenu)e.getSource());
            TreePath[] selectedNodes = ((JTree)menu.getInvoker()).getSelectionPaths();
            TreePath path = ((JTree)menu.getInvoker()).getClosestPathForLocation( menu.getInvokerLocation().x , menu.getInvokerLocation().y);
            if(path != null) {
              AWorkspaceTreeNode node = (AWorkspaceTreeNode) path.getLastPathComponent();
              ((AWorkspaceAction) action).setEnabledFor(node, selectedNodes);
            }
            else {
              ((AWorkspaceAction) action).setEnabledFor((AWorkspaceTreeNode) WorkspaceController.getCurrentModel().getRoot(), selectedNodes);
            }
View Full Code Here

//Make sure expansion is threaded and updating the tree model
//only occurs within the event dispatching thread.
public class DefaultTreeExpansionListener implements TreeExpansionListener {
   
    public void treeExpanded(TreeExpansionEvent event) {     
        final AWorkspaceTreeNode node = (AWorkspaceTreeNode)event.getPath().getLastPathComponent();
        if(node instanceof TreeExpansionListener) {
          ((TreeExpansionListener)node).treeExpanded(event);
        }
    }
View Full Code Here

TOP

Related Classes of org.freeplane.plugin.workspace.model.AWorkspaceTreeNode

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.