Module: Redcar::Tree::Mirror
- Includes:
- Observable
- Included in:
- Project::DirMirror, Runnables::TreeMirror, Scm::ScmChangesMirror, Scm::ScmCommitsMirror, Redcar::Textmate::TreeMirror, WebBookmarks::TreeMirror
- Defined in:
- plugins/application/lib/application/tree/mirror.rb
Overview
SPI specification. Implement a class including this module and pass an instance to Tree#new to populate the contents of a Tree.
Defined Under Namespace
Modules: NodeMirror
Constant Summary
Constant Summary
Constants included from Observable
Instance Method Summary (collapse)
-
- (Boolean) changed?
Has the top nodes changed since the last time `top` was called?.
-
- (Symbol) data_type
What type of data does the tree contain? If Node#to_data returns an absolute path to a file, then :file may be specified for OS integration.
-
- (Boolean) drag_and_drop?
Should drag and drop be permitted?.
-
- (Boolean) exist?
Does the resource still exist.
-
- (NodeMirror) from_data(data)
Create a node from the data created by to_data.
-
- (String) title
Return the title of the tree.
-
- (String or Array<String>) to_data(nodes)
This must be implemented (along with a from_data method) in order to allow drag and drop and copy and paste within the tree.
-
- (Array<NodeMirror>) top
Return the top level entries in the Tree.
Methods included from Observable
#add_listener, #notify_listeners, #remove_listener
Instance Method Details
- (Boolean) changed?
Has the top nodes changed since the last time `top` was called?
44 45 46 |
# File 'plugins/application/lib/application/tree/mirror.rb', line 44 def changed? false end |
- (Symbol) data_type
What type of data does the tree contain? If Node#to_data returns an absolute path to a file, then :file may be specified for OS integration.
36 37 38 |
# File 'plugins/application/lib/application/tree/mirror.rb', line 36 def data_type :text end |
- (Boolean) drag_and_drop?
Should drag and drop be permitted?
51 52 53 |
# File 'plugins/application/lib/application/tree/mirror.rb', line 51 def drag_and_drop? false end |
- (Boolean) exist?
Does the resource still exist
28 29 30 |
# File 'plugins/application/lib/application/tree/mirror.rb', line 28 def exist? true end |
- (NodeMirror) from_data(data)
Create a node from the data created by to_data. This is the reverse operation to #to_data, and should turn the String (in case data_type if :text) or Array of Strings (in case data_type is :file) into an array of nodes
61 62 63 |
# File 'plugins/application/lib/application/tree/mirror.rb', line 61 def from_data(data) raise "not implemented" end |
- (String) title
Return the title of the tree. It should NOT change.
13 14 15 |
# File 'plugins/application/lib/application/tree/mirror.rb', line 13 def title "Tree" end |
- (String or Array<String>) to_data(nodes)
This must be implemented (along with a from_data method) in order to allow drag and drop and copy and paste within the tree.
If the Tree::Mirror data_type is :text (the default), this must return a String. The string should be a complete representation of the data in the nodes, so that the from_data method can turn the string back into nodes
If the Tree::Mirror data_type is :file, this must return an array of Strings, where each string is the absolute path to the file.
77 78 79 |
# File 'plugins/application/lib/application/tree/mirror.rb', line 77 def to_data(nodes) raise "not implemented" end |
- (Array<NodeMirror>) top
Return the top level entries in the Tree. Each element should be an instance of a class implementing Redcar::Tree::Mirror::NodeMirror
21 22 23 |
# File 'plugins/application/lib/application/tree/mirror.rb', line 21 def top [] end |