01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: */
17: package org.apache.wicket.markup.html.tree;
18:
19: import java.io.Serializable;
20:
21: import javax.swing.tree.TreeModel;
22: import javax.swing.tree.TreeNode;
23:
24: import org.apache.wicket.Component;
25: import org.apache.wicket.ajax.AjaxRequestTarget;
26: import org.apache.wicket.model.IModel;
27: import org.apache.wicket.model.Model;
28:
29: /**
30: * Simple tree component that provides node panel with link allowing user to
31: * select individual nodes.
32: *
33: * @author Matej Knopp
34: */
35: public class LinkTree extends BaseTree {
36: private static final long serialVersionUID = 1L;
37:
38: /**
39: * Construct.
40: *
41: * @param id
42: */
43: public LinkTree(String id) {
44: super (id);
45: }
46:
47: /**
48: *
49: * Construct.
50: *
51: * @param id
52: * @param model
53: * model that provides the {@link TreeModel}
54: */
55: public LinkTree(String id, IModel model) {
56: super (id, model);
57: }
58:
59: /**
60: *
61: * Construct.
62: *
63: * @param id
64: * @param model
65: * Tree model
66: */
67: public LinkTree(String id, TreeModel model) {
68: super (id, new Model((Serializable) model));
69: }
70:
71: /**
72: * @see org.apache.wicket.markup.html.tree.BaseTree#newNodeComponent(java.lang.String, org.apache.wicket.model.IModel)
73: */
74: protected Component newNodeComponent(String id, IModel model) {
75: return new LinkIconPanel(id, model, LinkTree.this ) {
76: private static final long serialVersionUID = 1L;
77:
78: protected void onNodeLinkClicked(TreeNode node,
79: BaseTree tree, AjaxRequestTarget target) {
80: super .onNodeLinkClicked(node, tree, target);
81: LinkTree.this .onNodeLinkClicked(node, tree, target);
82: }
83: };
84: }
85:
86: /**
87: * Method invoked after the node has been selected / unselected.
88: * @param node
89: * @param tree
90: * @param target
91: */
92: protected void onNodeLinkClicked(TreeNode node, BaseTree tree,
93: AjaxRequestTarget target) {
94:
95: }
96: }
|