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.cocoon.forms.formmodel.tree;
18:
19: import org.apache.cocoon.forms.event.WidgetEventMulticaster;
20: import org.apache.cocoon.forms.formmodel.AbstractWidgetDefinition;
21: import org.apache.cocoon.forms.formmodel.Widget;
22:
23: /**
24: * Definition of a {@link Tree} widget.
25: *
26: * @version $Id: TreeDefinition.java 449149 2006-09-23 03:58:05Z crossley $
27: */
28: public class TreeDefinition extends AbstractWidgetDefinition {
29:
30: private TreeModelDefinition modelDefinition;
31: private boolean rootVisible = true;
32: private TreeSelectionListener selectionListener;
33: private int selectionModel = Tree.MULTIPLE_SELECTION;
34:
35: public Widget createInstance() {
36: return new Tree(this );
37: }
38:
39: public TreeModel createModel() {
40: TreeModel model;
41: if (this .modelDefinition == null) {
42: model = DefaultTreeModel.UNSPECIFIED_MODEL;
43: } else {
44: model = modelDefinition.createInstance();
45: }
46: return model;
47: }
48:
49: public void setModelDefinition(TreeModelDefinition definition) {
50: checkMutable();
51: this .modelDefinition = definition;
52: }
53:
54: public void setRootVisible(boolean visible) {
55: checkMutable();
56: this .rootVisible = visible;
57: }
58:
59: public boolean isRootVisible() {
60: return this .rootVisible;
61: }
62:
63: public void setSelectionModel(int model) {
64: checkMutable();
65: this .selectionModel = model;
66: }
67:
68: public int getSelectionModel() {
69: return this .selectionModel;
70: }
71:
72: public void addSelectionListener(TreeSelectionListener listener) {
73: checkMutable();
74: this .selectionListener = WidgetEventMulticaster.add(
75: this .selectionListener, listener);
76: }
77:
78: public TreeSelectionListener getSelectionListener() {
79: return this.selectionListener;
80: }
81: }
|