1 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 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 |