KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > cocoon > forms > formmodel > tree > TreeDefinition


1 /*
2  * Copyright 1999-2005 The Apache Software Foundation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16 package org.apache.cocoon.forms.formmodel.tree;
17
18 import org.apache.cocoon.forms.event.WidgetEventMulticaster;
19 import org.apache.cocoon.forms.formmodel.AbstractWidgetDefinition;
20 import org.apache.cocoon.forms.formmodel.Widget;
21
22 /**
23  * Definition of a {@link Tree} widget.
24  *
25  * @version $Id: TreeDefinition.java 190962 2005-06-16 17:17:00Z sylvain $
26  */

27 public class TreeDefinition extends AbstractWidgetDefinition {
28     
29     private TreeModelDefinition modelDefinition;
30     private boolean rootVisible = true;
31     private TreeSelectionListener selectionListener;
32     private int selectionModel = Tree.MULTIPLE_SELECTION;
33
34     public Widget createInstance() {
35         return new Tree(this);
36     }
37     
38     public TreeModel createModel() {
39         TreeModel model;
40         if (this.modelDefinition == null) {
41             model = DefaultTreeModel.UNSPECIFIED_MODEL;
42         } else {
43             model = modelDefinition.createInstance();
44         }
45         return model;
46     }
47
48     public void setModelDefinition(TreeModelDefinition definition) {
49         checkMutable();
50         this.modelDefinition = definition;
51     }
52
53     public void setRootVisible(boolean visible) {
54         checkMutable();
55         this.rootVisible = visible;
56     }
57     
58     public boolean isRootVisible() {
59         return this.rootVisible;
60     }
61     
62     public void setSelectionModel(int model) {
63         checkMutable();
64         this.selectionModel = model;
65     }
66     
67     public int getSelectionModel() {
68         return this.selectionModel;
69     }
70
71     public void addSelectionListener(TreeSelectionListener listener) {
72         checkMutable();
73         this.selectionListener = WidgetEventMulticaster.add(this.selectionListener, listener);
74     }
75     
76     public TreeSelectionListener getSelectionListener() {
77         return this.selectionListener;
78     }
79 }
80
Popular Tags