projectviewer.vpt
Class VPTFile

java.lang.Object
  extended by javax.swing.tree.DefaultMutableTreeNode
      extended by projectviewer.vpt.VPTNode
          extended by projectviewer.vpt.VPTFile
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, java.lang.Comparable<VPTNode>, javax.swing.tree.MutableTreeNode, javax.swing.tree.TreeNode

public class VPTFile
extends VPTNode

Models a file that is part of a project.

Author:
Marcelo Vanzin
See Also:
Serialized Form

Field Summary
 
Fields inherited from class projectviewer.vpt.VPTNode
name, treeNoSelectionBackground, treeNoSelectionForeground, treeSelectionBackground, treeSelectionForeground
 
Fields inherited from class javax.swing.tree.DefaultMutableTreeNode
allowsChildren, children, EMPTY_ENUMERATION, parent, userObject
 
Constructor Summary
VPTFile(java.lang.String url)
           
 
Method Summary
 boolean canOpen()
          File nodes can be opened, so return true.
 boolean canRename()
          Returns whether the VFS of the file allows renaming.
 boolean canWrite()
          Returns is the underlying file is writable.
protected  void changed()
          Flush the internal VFSFile instance, and force retrieval of a new one.
 void close()
          Globally closes the jEdit buffer that contains the file.
 void close(org.gjt.sp.jedit.View view, org.gjt.sp.jedit.bufferset.BufferSet.Scope scope)
          Closes the jEdit buffer that contains the file.
 int compareTo(VPTNode node)
          Files are at the same level of every leaf node.
 boolean delete()
          Deletes the file from the VFS.
 org.gjt.sp.jedit.io.VFSFile getFile()
          Return the VFS file associated with this node.
protected  org.gjt.sp.jedit.io.VFSFile getFile(boolean lazy)
          Returns the VFS file associated with this node.
 java.awt.Color getForegroundColor(boolean sel)
          Returns the node's foreground color.
 javax.swing.Icon getIcon(boolean expanded)
          Returns the icon to be shown on the tree next to the node name.
 java.lang.String getNodePath()
          Returns the path to the file represented by this node.
 java.lang.String getURL()
          Returns the VFS URL for this file.
 boolean isOpened()
          Returns "true" if the node is a file and is currently opened in jEdit.
 void open()
          Opens a new buffer in jEdit with the file pointed by this node.
 void open(org.gjt.sp.jedit.View v)
          Opens the file in the specified view, if it's not yet open.
 void setURL(java.lang.String url)
          Changes this file's URL.
 java.lang.String toString()
          Returns a string representation of the current node.
 
Methods inherited from class projectviewer.vpt.VPTNode
compareName, findIndexForChild, findProjectFor, getBackgroundColor, getChildWithName, getClipType, getGroup, getLock, getName, getVersionControlState, insert, isDirectory, isFile, isGroup, isProject, isRoot, lock, persistChildren, remove, remove, removeAllChildren, removeFromParent, setName, setParent, setVersionControlState, sortChildren, sortChildren, unlock
 
Methods inherited from class javax.swing.tree.DefaultMutableTreeNode
add, breadthFirstEnumeration, children, clone, depthFirstEnumeration, getAllowsChildren, getChildAfter, getChildAt, getChildBefore, getChildCount, getDepth, getFirstChild, getFirstLeaf, getIndex, getLastChild, getLastLeaf, getLeafCount, getLevel, getNextLeaf, getNextNode, getNextSibling, getParent, getPath, getPathToRoot, getPreviousLeaf, getPreviousNode, getPreviousSibling, getRoot, getSharedAncestor, getSiblingCount, getUserObject, getUserObjectPath, isLeaf, isNodeAncestor, isNodeChild, isNodeDescendant, isNodeRelated, isNodeSibling, pathFromAncestorEnumeration, postorderEnumeration, preorderEnumeration, setAllowsChildren, setUserObject
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

VPTFile

public VPTFile(java.lang.String url)
Method Detail

canWrite

public boolean canWrite()
Returns is the underlying file is writable.

Overrides:
canWrite in class VPTNode

delete

public boolean delete()
Deletes the file from the VFS. Before deleting, try to close the file.

Overrides:
delete in class VPTNode
Returns:
Whether the file was successfully deleted.

getFile

public org.gjt.sp.jedit.io.VFSFile getFile()
Return the VFS file associated with this node. May return null if an I/O error occurs.

Should not be called from outside ProjectViewer.


getFile

protected org.gjt.sp.jedit.io.VFSFile getFile(boolean lazy)
Returns the VFS file associated with this node. Optionally, does lazy initialization of the internal cached file node.

Should not be called from outside ProjectViewer. The "lazy" flag is for use by code that cannot cope with the possibility of instantiating the VFS file causing any interaction with the UI (e.g., an FTP login dialog). For VFS instances that have the LOW_LATENCY_CAP capability, the file is always retrieved from the VFS so that updates to the filesystem are reflected in the project tree. An example of non-low latency vfs is one provided by FTP plugin.

Parameters:
lazy - Whether to use lazy initialization of the file.
Returns:
The VFSFile backing this node. May be null if doing lazy initialization, the file doesn't exist, or an I/O error occurs.
Since:
PV 3.0.0

isOpened

public boolean isOpened()
Returns "true" if the node is a file and is currently opened in jEdit.

Overrides:
isOpened in class VPTNode

getURL

public java.lang.String getURL()
Returns the VFS URL for this file.

Since:
PV 3.0.0

setURL

public void setURL(java.lang.String url)
Changes this file's URL.

Since:
PV 3.0.0

getIcon

public javax.swing.Icon getIcon(boolean expanded)
Returns the icon to be shown on the tree next to the node name.

Specified by:
getIcon in class VPTNode
Parameters:
expanded - If the node is currently expanded or not.

getForegroundColor

public java.awt.Color getForegroundColor(boolean sel)
Returns the node's foreground color.

Overrides:
getForegroundColor in class VPTNode
Parameters:
sel - If the node is currently selected.

toString

public java.lang.String toString()
Returns a string representation of the current node.

Overrides:
toString in class VPTNode

canOpen

public boolean canOpen()
File nodes can be opened, so return true.

Overrides:
canOpen in class VPTNode

canRename

public boolean canRename()
Returns whether the VFS of the file allows renaming.

Overrides:
canRename in class VPTNode
Returns:
Default implementation returns true.
Since:
PV 3.0.0

open

public void open()
Opens a new buffer in jEdit with the file pointed by this node. The buffer is loaded in the currently active view.

Overrides:
open in class VPTNode

open

public void open(org.gjt.sp.jedit.View v)
Opens the file in the specified view, if it's not yet open.

Parameters:
v - Where to open the file (null = active view).
Since:
PV 3.2.0

close

public void close()
Globally closes the jEdit buffer that contains the file.

Overrides:
close in class VPTNode

close

public void close(org.gjt.sp.jedit.View view,
                  org.gjt.sp.jedit.bufferset.BufferSet.Scope scope)
Closes the jEdit buffer that contains the file.

Parameters:
scope - Scope to use. Null defaults to current jEdit scope. EditPane scope is treated as View scope, because PV manages the whole view.
Since:
3.4.0

getNodePath

public java.lang.String getNodePath()
Returns the path to the file represented by this node.

Specified by:
getNodePath in class VPTNode

compareTo

public int compareTo(VPTNode node)
Files are at the same level of every leaf node.

Specified by:
compareTo in interface java.lang.Comparable<VPTNode>
Overrides:
compareTo in class VPTNode

changed

protected void changed()
Flush the internal VFSFile instance, and force retrieval of a new one.

Overrides:
changed in class VPTNode