Package org.freeplane.plugin.workspace.model

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


      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);
View Full Code Here


  /**
   * @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;
  }
View Full Code Here

  public Component getTreeCellRendererComponent(JTree tree, Object treeNode, boolean sel, boolean expanded, boolean leaf, int row,
      boolean hasFocus) {
    if(treeNode != null && treeNode instanceof AWorkspaceTreeNode ) {
      DefaultTreeCellRenderer renderer = new DefaultTreeCellRenderer();
      AWorkspaceTreeNode node = (AWorkspaceTreeNode) treeNode;
      setNodeIcon(renderer, node);
      setToolTip(renderer, node);
      JLabel label = (JLabel) renderer.getTreeCellRendererComponent(tree, treeNode, sel, expanded, leaf, row, hasFocus);     
      if(row == this.highlightedRow) {
        try {
        label.setBorder(BorderFactory.createLineBorder(UIManager.getColor(borderSelectionColor), 1));
        }
        catch (Exception e) {
          label.setBorder(BorderFactory.createLineBorder(label.getForeground(), 1));
        }
      }
      label.setText(node.getName());
      if(isCut(node)) {
        //WORKSPACE - ToDo: make the item transparent (including the icon?)
        int alpha = new Double(255 * 0.5).intValue();
        label.setForeground(new Color(label.getForeground().getRed(), label.getForeground().getGreen(), label.getForeground().getBlue(), alpha));
      }
View Full Code Here

  /***********************************************************************************
   * REQUIRED METHODS FOR INTERFACES
   **********************************************************************************/
 
  public void actionPerformed(final ActionEvent e) {
    AWorkspaceTreeNode node = this.getNodeFromActionEvent(e);
    int yesorno = JOptionPane.showConfirmDialog(UITools.getFrame(),
        TextUtils.format("workspace.action.file.delete.confirm.text", node.getName()),
        TextUtils.getText("workspace.action.file.delete.confirm.title"),
        JOptionPane.YES_NO_OPTION);
    if (yesorno == JOptionPane.OK_OPTION) {
      deleteFile(node);
   
View Full Code Here

        if(!file.delete()) {
          //show message?
        }
      }     
    }
    AWorkspaceTreeNode parent = node.getParent();
    node.getModel().removeNodeFromParent(node);
    parent.refresh();
    parent.getModel().requestSave();
   
  }
View Full Code Here

      setEnabled();
    }
  }

  public void actionPerformed(final ActionEvent e) {
    AWorkspaceTreeNode targetNode = this.getNodeFromActionEvent(e);
   
    String oldName = targetNode.getName();
    NodeRenameDialogPanel panel;
//    if (targetNode instanceof IMutableLinkNode) {
//      panel = new NodeRenameDialogPanel(oldName, true);
//    }
//    else {
      panel = new NodeRenameDialogPanel(oldName);
      if(targetNode instanceof DefaultFileNode) {
        panel.setCheckboxSelected(true);
      }
//    }
    int okButton = JOptionPane.showConfirmDialog(UITools.getFrame(), panel, TextUtils.getText("confirm_rename_file_action"),  JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE);
    String newName = panel.getText();
   
    if(okButton != JOptionPane.OK_OPTION || oldName.equals(newName)) {
      return;
    }
   
    if (newName != null) {
      if (targetNode instanceof IMutableLinkNode) {
        if (((IMutableLinkNode) targetNode).changeName(newName, panel.applyChangesForLink())) {
          targetNode.refresh();
        }
        else {
          JOptionPane.showMessageDialog(UITools.getFrame(), TextUtils.getText("error_rename_file"),
              TextUtils.getText("error_rename_file_title"), JOptionPane.ERROR_MESSAGE);
          targetNode.setName(oldName);
        }
      }
      else {
        try {
          targetNode.getModel().changeNodeName(targetNode, newName);
          targetNode.refresh();
        }
        catch(Exception ex) {
          JOptionPane.showMessageDialog(UITools.getFrame(), TextUtils.getText("error_rename_file") + " ("+ex.getMessage()+")",
              TextUtils.getText("error_rename_file_title"), JOptionPane.ERROR_MESSAGE);
        }
View Full Code Here

    public boolean isLeaf(Object node) {
      return ((AWorkspaceTreeNode) node).isLeaf();
    }

    public void valueForPathChanged(TreePath path, Object newValue) {
      AWorkspaceTreeNode node = (AWorkspaceTreeNode) path.getLastPathComponent();
      if (node instanceof IWorkspaceNodeActionListener) {
        ((IWorkspaceNodeActionListener) node).handleAction(new WorkspaceActionEvent(node, WorkspaceActionEvent.WSNODE_CHANGED, newValue));
        //nodeChanged(node);
      }
      else {
        node.setName(newValue.toString());
      }
    }
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);
    int mode = WorkspaceNewFolderPanel.MODE_VIRTUAL_PHYSICAL;
    if(targetNode instanceof IFileSystemRepresentation) {
      mode = WorkspaceNewFolderPanel.MODE_VIRTUAL_ONLY;
    }
    WorkspaceNewFolderPanel dialog = new WorkspaceNewFolderPanel(mode , targetNode);
    int response = JOptionPane.showConfirmDialog(UITools.getFrame(), dialog, TextUtils.getText("workspace.action.node.new.folder.dialog.title"), JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE);
    if(response == JOptionPane.OK_OPTION) {
      String value = dialog.getFolderName();
      if(value == null || value.trim().length() <= 0) {
        //WORKSPACE - ToDo: prepare message, or call this method (with error message) again?
        return;
      }
      if(dialog.isLinkedFolder()) {
        File path = new File(dialog.getLinkPath());
        if (path != null) {
          FolderLinkNode node = new FolderLinkNode();       
          node.setName(value);
          URI uri = project.getRelativeURI(path.toURI());
          if(uri == null) {
            node.setPath(path.toURI());
          }
          else {
            node.setPath(uri);
          }
          targetNode.getModel().addNodeTo(node, targetNode);         
          node.refresh();
        }       
      }
      else {
        if(targetNode instanceof IFileSystemRepresentation) {
          try {
            WorkspaceController.getFileSystemMgr().createDirectory(value, ((IFileSystemRepresentation) targetNode).getFile());
          }
          catch (IOException e1) {
            JOptionPane.showMessageDialog(UITools.getFrame(), e1.getMessage());
          }
        }
        else {
          FolderVirtualNode node = new FolderVirtualNode();
          node.setName(value);
          targetNode.getModel().addNodeTo(node, targetNode);
        }
         
      }
      targetNode.refresh();
      targetNode.getModel().requestSave();     
    }
  }
View Full Code Here

  public Transferable createTransferable(JComponent comp) {
    WorkspaceTransferable transferable = null;
    if (comp instanceof JTree) {
      JTree t = (JTree) comp;     
      for (TreePath p : t.getSelectionPaths()) {
        AWorkspaceTreeNode node = (AWorkspaceTreeNode) p.getLastPathComponent();
        if (node instanceof IWorkspaceTransferableCreator) {
          if(transferable == null) {
            transferable = ((IWorkspaceTransferableCreator)node).getTransferable();
          }
          else {
View Full Code Here

  public boolean importData(JComponent comp, Transferable transf) {
    if (comp instanceof JTree) {
      JTree t = (JTree) comp;     
      for (TreePath p : t.getSelectionPaths()) {
        AWorkspaceTreeNode targetNode = (AWorkspaceTreeNode) p.getLastPathComponent();
        if (DnDController.isDropAllowed(targetNode)) {
          if(transf == null) {
                return false;
              }
              try {
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.