Search in sources :

Example 41 with AWorkspaceTreeNode

use of org.freeplane.plugin.workspace.model.AWorkspaceTreeNode in project freeplane by freeplane.

the class WorkspaceCellEditor method getTreeCellEditorComponent.

/**
 *********************************************************************************
 * METHODS
 *********************************************************************************
 */
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);
}
Also used : AWorkspaceTreeNode(org.freeplane.plugin.workspace.model.AWorkspaceTreeNode)

Example 42 with AWorkspaceTreeNode

use of org.freeplane.plugin.workspace.model.AWorkspaceTreeNode in project freeplane by freeplane.

the class ExpandedStateHandler method treeExpanded.

public void treeExpanded(TreeExpansionEvent event) {
    final AWorkspaceTreeNode node = (AWorkspaceTreeNode) event.getPath().getLastPathComponent();
    expandedNodeKeys.add(node.getKey());
}
Also used : AWorkspaceTreeNode(org.freeplane.plugin.workspace.model.AWorkspaceTreeNode)

Example 43 with AWorkspaceTreeNode

use of org.freeplane.plugin.workspace.model.AWorkspaceTreeNode in project freeplane by freeplane.

the class ExpandedStateHandler method treeCollapsed.

public void treeCollapsed(TreeExpansionEvent event) {
    final AWorkspaceTreeNode node = (AWorkspaceTreeNode) event.getPath().getLastPathComponent();
    expandedNodeKeys.remove(node.getKey());
}
Also used : AWorkspaceTreeNode(org.freeplane.plugin.workspace.model.AWorkspaceTreeNode)

Example 44 with AWorkspaceTreeNode

use of org.freeplane.plugin.workspace.model.AWorkspaceTreeNode in project freeplane by freeplane.

the class WorkspaceNodeRenderer method getTreeCellRendererComponent.

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));
        }
        return label;
    }
    return super.getTreeCellRendererComponent(tree, treeNode, sel, expanded, leaf, row, hasFocus);
}
Also used : AWorkspaceTreeNode(org.freeplane.plugin.workspace.model.AWorkspaceTreeNode) Color(java.awt.Color) JLabel(javax.swing.JLabel) DefaultTreeCellRenderer(javax.swing.tree.DefaultTreeCellRenderer)

Example 45 with AWorkspaceTreeNode

use of org.freeplane.plugin.workspace.model.AWorkspaceTreeNode in project freeplane by freeplane.

the class NodeNewFolderAction method actionPerformed.

/**
 *********************************************************************************
 * METHODS
 *********************************************************************************
 */
/**
 *********************************************************************************
 * 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();
    }
}
Also used : AWorkspaceProject(org.freeplane.plugin.workspace.model.project.AWorkspaceProject) IFileSystemRepresentation(org.freeplane.plugin.workspace.io.IFileSystemRepresentation) FolderVirtualNode(org.freeplane.plugin.workspace.nodes.FolderVirtualNode) AWorkspaceTreeNode(org.freeplane.plugin.workspace.model.AWorkspaceTreeNode) WorkspaceNewFolderPanel(org.freeplane.plugin.workspace.components.dialog.WorkspaceNewFolderPanel) IOException(java.io.IOException) File(java.io.File) URI(java.net.URI) FolderLinkNode(org.freeplane.plugin.workspace.nodes.FolderLinkNode)

Aggregations

AWorkspaceTreeNode (org.freeplane.plugin.workspace.model.AWorkspaceTreeNode)51 File (java.io.File)13 URI (java.net.URI)9 ArrayList (java.util.ArrayList)8 WorkspaceTransferable (org.freeplane.plugin.workspace.dnd.WorkspaceTransferable)7 TreePath (javax.swing.tree.TreePath)6 DefaultFileNode (org.freeplane.plugin.workspace.nodes.DefaultFileNode)6 JTree (javax.swing.JTree)5 IOException (java.io.IOException)4 IWorkspaceView (org.freeplane.plugin.workspace.components.IWorkspaceView)4 IFileSystemRepresentation (org.freeplane.plugin.workspace.io.IFileSystemRepresentation)4 LinkTypeFileNode (org.freeplane.plugin.workspace.nodes.LinkTypeFileNode)4 Vector (java.util.Vector)3 IWorkspaceNodeActionListener (org.freeplane.plugin.workspace.event.IWorkspaceNodeActionListener)3 WorkspaceActionEvent (org.freeplane.plugin.workspace.event.WorkspaceActionEvent)3 SkipTaskException (org.freeplane.plugin.workspace.io.SkipTaskException)3 AWorkspaceProject (org.freeplane.plugin.workspace.model.project.AWorkspaceProject)3 FolderLinkNode (org.freeplane.plugin.workspace.nodes.FolderLinkNode)3 List (java.util.List)2 WorkspacePopupMenu (org.freeplane.plugin.workspace.components.menu.WorkspacePopupMenu)2