public abstract class Importer
extends org.gjt.sp.util.Task
Trees are updated in the following manner: when a node is inserted, the folder tree is updated immediately. The other two trees (which are a "flat" version of the file list, basically) are updated once at the end of the importing (to make the code simpler for those trees).
Since a lot of time may be required to import large number of files, the importing is done in its own separate thread, so that the GUI may be used normally during the process. This behaviour can be prevented if wished. If importing in a separate thread, the PV GUI will be blocked during the import phase (but the rest of jEdit will be usable).
Modifier and Type | Class and Description |
---|---|
protected class |
Importer.NodeStructureChange |
protected class |
Importer.ShowNodes
Makes sure all newly imported nodes are visible.
|
Modifier and Type | Field and Description |
---|---|
protected boolean |
isNodeStructureUpdate
Whether to do one single "node structure" update on the selected
node instead of individual updates on each modified node.
|
protected java.lang.Runnable |
postAction
An action to be executed after the import occurs.
|
protected VPTProject |
project |
protected VPTNode |
selected |
protected boolean |
silent |
protected ProjectViewer |
viewer
The node to where the imported nodes will be added.
|
Constructor and Description |
---|
Importer(VPTNode node,
ProjectViewer viewer) |
Importer(VPTNode node,
ProjectViewer viewer,
boolean noThread)
If noThread is true, inhibits the use of a separate Thread to do the
importing.
|
Modifier and Type | Method and Description |
---|---|
void |
_run() |
protected void |
addNode(VPTNode node,
VPTNode parent)
Marks a node for importing.
|
protected void |
cleanup()
This is called after
internalDoImport() is invoked, so
implementations can clean up any internal state. |
protected VPTNode |
constructPath(VPTNode root,
java.lang.String path)
Creates a subtree starting at the given root, going down to the
given path, updating the given list of added nodes as necessary.
|
void |
doImport()
Main import method.
|
protected VPTNode |
findChild(java.lang.String url,
VPTNode parent,
boolean create)
Looks, in the children list for the given parent, for a node with
the given path.
|
protected void |
importFiles(VPTNode dest,
org.gjt.sp.jedit.io.VFSFileFilter filter,
boolean recurse,
boolean flatten)
Imports the files directly under the given node, optionally
recursing into sub-directories.
|
protected void |
importFiles(VPTNode dest,
org.gjt.sp.jedit.io.VFSFileFilter filter,
boolean recurse,
boolean flatten,
boolean addHidden)
Imports the files directly under the given node, optionally
recursing into sub-directories.
|
protected abstract void |
internalDoImport()
Method called when importing nodes.
|
protected ImporterFileFilter |
loadImportFilterStatus(VPTProject project,
ImportDialog dlg,
java.lang.String name) |
protected void |
removeDirectory(VPTDirectory dir)
Marks a directory for removal.
|
protected void |
removeFile(VPTFile file)
Marks a file for removal.
|
protected void |
saveImportFilterStatus(VPTProject project,
ImportDialog dlg,
java.lang.String name) |
void |
setSilent(boolean silent)
Sets the silent member.
|
protected void |
setViewerEnabled(boolean flag) |
protected void |
setViewStatus(java.lang.String msgKey)
Sets a message in the view's status bar.
|
protected final ProjectViewer viewer
protected boolean isNodeStructureUpdate
protected final VPTNode selected
protected final VPTProject project
protected boolean silent
protected java.lang.Runnable postAction
public Importer(VPTNode node, ProjectViewer viewer, boolean noThread)
public Importer(VPTNode node, ProjectViewer viewer)
public final void doImport()
This method should be called from the AWT thread. It will lock the project, so if the calling code also locks the project for any reason, make sure it does so from the AWT thread or it will result in a deadlock.
protected abstract void internalDoImport()
protected void cleanup()
internalDoImport()
is invoked, so
implementations can clean up any internal state. Default implementation
does nothing.protected void addNode(VPTNode node, VPTNode parent)
Task.run()
method of this
class will take care of processing all these nodes and properly
registering files and updating the trees.
It is assumed that either the parent node already exists in the
project, or it has been properly imported using this method.
If the node is a direct descendent of an already existing node,
then it will be processed later when the UI is updated. Otherwise
it will be added to the parent's list of children right away.node
- The node being inserted.parent
- Where the node is being inserted.protected VPTNode findChild(java.lang.String url, VPTNode parent, boolean create) throws java.io.IOException
url
- The URL of the directory to look for.parent
- The node where to look for the directory.create
- Whether to create a new node if a corresponding path is
not found in the parent node.java.io.IOException
protected VPTNode constructPath(VPTNode root, java.lang.String path) throws java.io.IOException
root
- Root node where to start constructing the path.path
- Path to insert (should be under the given root).java.io.IOException
- If an I/O error occur.protected void importFiles(VPTNode dest, org.gjt.sp.jedit.io.VFSFileFilter filter, boolean recurse, boolean flatten) throws java.io.IOException
dest
- Node where to add the new imported files.filter
- File filter to use when listing directories.recurse
- Whether to recurse into sub-directories.flatten
- Whether to import all files (even from
sub-directories) into the dest node.java.io.IOException
protected void importFiles(VPTNode dest, org.gjt.sp.jedit.io.VFSFileFilter filter, boolean recurse, boolean flatten, boolean addHidden) throws java.io.IOException
dest
- Node where to add the new imported files.filter
- File filter to use when listing directories.recurse
- Whether to recurse into sub-directories.flatten
- Whether to import all files (even from
sub-directories) into the dest node.addHidden
- Whether to add hidden files.java.io.IOException
protected void removeDirectory(VPTDirectory dir)
protected void removeFile(VPTFile file)
protected void setViewerEnabled(boolean flag)
public void _run()
_run
in class org.gjt.sp.util.Task
protected void saveImportFilterStatus(VPTProject project, ImportDialog dlg, java.lang.String name)
protected ImporterFileFilter loadImportFilterStatus(VPTProject project, ImportDialog dlg, java.lang.String name)
protected void setViewStatus(java.lang.String msgKey)
msgKey
- jEdit property key, or message to be displayed.public void setSilent(boolean silent)