116 *
117 * // First getChildren() call, so we actually go off and
118 * // determine the children of the File contained in this TreeItem.
119 * super.getChildren().setAll(buildChildren(this));
120 * }
121 * return super.getChildren();
122 * }
123 *
124 * @Override public boolean isLeaf() {
125 * if (isFirstTimeLeaf) {
126 * isFirstTimeLeaf = false;
127 * File f = (File) getValue();
128 * isLeaf = f.isFile();
129 * }
130 *
131 * return isLeaf;
132 * }
133 *
134 * private ObservableList<TreeItem<File>> buildChildren(TreeItem<File> TreeItem) {
135 * File f = TreeItem.getValue();
136 * if (f != null && f.isDirectory()) {
137 * File[] files = f.listFiles();
138 * if (files != null) {
139 * ObservableList<TreeItem<File>> children = FXCollections.observableArrayList();
140 *
141 * for (File childFile : files) {
142 * children.add(createNode(childFile));
143 * }
144 *
145 * return children;
146 * }
147 * }
148 *
149 * return FXCollections.emptyObservableList();
150 * }
151 * };
152 * }</code></pre>
153 *
154 * <strong>TreeItem Events</strong>
155 * <p>TreeItem supports the same event bubbling concept as elsewhere in the
156 * scenegraph. This means that it is not necessary to listen for events on all
158 * cost solution is to instead attach event listeners to the TreeView
159 * {@link TreeView#rootProperty() root} item. As long as there is a path between
160 * where the event occurs and the root TreeItem, the event will be bubbled to the
161 * root item.
162 *
163 * <p>It is important to note however that a TreeItem is <strong>not</strong> a
164 * Node, which means that only the event types defined in TreeItem will be
165 * delivered. To listen to general events (for example mouse interactions), it is
166 * necessary to add the necessary listeners to the {@link Cell cells} contained
167 * within the TreeView (by providing a {@link TreeView#cellFactoryProperty()
168 * cell factory}).
169 *
170 * <p>The TreeItem class defines a number of events, with a defined hierarchy. These
171 * are shown below (follow the links to learn more about each event type):
172 *
173 * <ul>
174 * <li>{@link TreeItem#treeNotificationEvent() TreeItem.treeNotificationEvent()}</li>
175 * <ul>
176 * <li>{@link TreeItem#valueChangedEvent() TreeItem.valueChangedEvent()}</li>
177 * <li>{@link TreeItem#graphicChangedEvent() TreeItem.graphicChangedEvent()}</li>
178 * <li>{@link TreeItem#treeItemCountChangeEvent() TreeItem.treeItemCountChangeEvent()}</li>
179 * <ul>
180 * <li>{@link TreeItem#branchExpandedEvent() TreeItem.branchExpandedEvent()}</li>
181 * <li>{@link TreeItem#branchCollapsedEvent() TreeItem.branchCollapsedEvent()}</li>
182 * <li>{@link TreeItem#childrenModificationEvent() TreeItem.childrenModificationEvent()}</li>
183 * </ul>
184 * </ul>
185 * </ul>
186 *
187 * <p>The indentation shown above signifies the relationship between event types.
188 * For example, all TreeItem event types have
189 * {@link TreeItem#treeNotificationEvent() treeNotificationEvent()} as their
190 * parent event type, and the branch
191 * {@link TreeItem#branchExpandedEvent() expand} /
192 * {@link TreeItem#branchCollapsedEvent() collapse} event types are both
193 * {@link TreeItem#treeNotificationEvent() treeNotificationEvent()}. For
194 * performance reasons, it is encouraged to listen
195 * to only the events you need to listen to. This means that it is encouraged
196 * that it is better to listen to, for example,
197 * {@link TreeItem#valueChangedEvent() TreeItem.valueChangedEvent()},
198 * rather than {@link TreeItem#treeNotificationEvent() TreeItem.treeNotificationEvent()}.
|
116 *
117 * // First getChildren() call, so we actually go off and
118 * // determine the children of the File contained in this TreeItem.
119 * super.getChildren().setAll(buildChildren(this));
120 * }
121 * return super.getChildren();
122 * }
123 *
124 * @Override public boolean isLeaf() {
125 * if (isFirstTimeLeaf) {
126 * isFirstTimeLeaf = false;
127 * File f = (File) getValue();
128 * isLeaf = f.isFile();
129 * }
130 *
131 * return isLeaf;
132 * }
133 *
134 * private ObservableList<TreeItem<File>> buildChildren(TreeItem<File> TreeItem) {
135 * File f = TreeItem.getValue();
136 * if (f != null && f.isDirectory()) {
137 * File[] files = f.listFiles();
138 * if (files != null) {
139 * ObservableList<TreeItem<File>> children = FXCollections.observableArrayList();
140 *
141 * for (File childFile : files) {
142 * children.add(createNode(childFile));
143 * }
144 *
145 * return children;
146 * }
147 * }
148 *
149 * return FXCollections.emptyObservableList();
150 * }
151 * };
152 * }</code></pre>
153 *
154 * <strong>TreeItem Events</strong>
155 * <p>TreeItem supports the same event bubbling concept as elsewhere in the
156 * scenegraph. This means that it is not necessary to listen for events on all
158 * cost solution is to instead attach event listeners to the TreeView
159 * {@link TreeView#rootProperty() root} item. As long as there is a path between
160 * where the event occurs and the root TreeItem, the event will be bubbled to the
161 * root item.
162 *
163 * <p>It is important to note however that a TreeItem is <strong>not</strong> a
164 * Node, which means that only the event types defined in TreeItem will be
165 * delivered. To listen to general events (for example mouse interactions), it is
166 * necessary to add the necessary listeners to the {@link Cell cells} contained
167 * within the TreeView (by providing a {@link TreeView#cellFactoryProperty()
168 * cell factory}).
169 *
170 * <p>The TreeItem class defines a number of events, with a defined hierarchy. These
171 * are shown below (follow the links to learn more about each event type):
172 *
173 * <ul>
174 * <li>{@link TreeItem#treeNotificationEvent() TreeItem.treeNotificationEvent()}</li>
175 * <ul>
176 * <li>{@link TreeItem#valueChangedEvent() TreeItem.valueChangedEvent()}</li>
177 * <li>{@link TreeItem#graphicChangedEvent() TreeItem.graphicChangedEvent()}</li>
178 * <li>{@link TreeItem#expandedItemCountChangeEvent() TreeItem.expandedItemCountChangeEvent()}</li>
179 * <ul>
180 * <li>{@link TreeItem#branchExpandedEvent() TreeItem.branchExpandedEvent()}</li>
181 * <li>{@link TreeItem#branchCollapsedEvent() TreeItem.branchCollapsedEvent()}</li>
182 * <li>{@link TreeItem#childrenModificationEvent() TreeItem.childrenModificationEvent()}</li>
183 * </ul>
184 * </ul>
185 * </ul>
186 *
187 * <p>The indentation shown above signifies the relationship between event types.
188 * For example, all TreeItem event types have
189 * {@link TreeItem#treeNotificationEvent() treeNotificationEvent()} as their
190 * parent event type, and the branch
191 * {@link TreeItem#branchExpandedEvent() expand} /
192 * {@link TreeItem#branchCollapsedEvent() collapse} event types are both
193 * {@link TreeItem#treeNotificationEvent() treeNotificationEvent()}. For
194 * performance reasons, it is encouraged to listen
195 * to only the events you need to listen to. This means that it is encouraged
196 * that it is better to listen to, for example,
197 * {@link TreeItem#valueChangedEvent() TreeItem.valueChangedEvent()},
198 * rather than {@link TreeItem#treeNotificationEvent() TreeItem.treeNotificationEvent()}.
|