Tree Editor

This is an example, to show how to write an editor for a tree. Some commands are using popups and AJAX.

<?xml version="1.0" encoding="UTF-8"?> <!-- * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. --> <ui:composition template="/main.xhtml" xmlns="http://www.w3.org/1999/xhtml" xmlns:tc="http://myfaces.apache.org/tobago/component" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:f="http://java.sun.com/jsf/core"> <ui:param name="title" value="#{demoBundle.tree_editor}"/> <p>This is an example, to show how to write an editor for a tree. Some commands are using popups and AJAX.</p> <tc:buttons> <tc:button label="New" omit="true" image="fa-file-o"> <tc:operation name="show" for="createPopup"/> </tc:button> <tc:button label="Delete" image="fa-trash-o" action="#{treeEditorController.delete}"/> <tc:button label="Rename" omit="true" image="fa-edit"> <tc:operation name="show" for="renamePopup"/> </tc:button> <tc:button label="Cut" action="#{treeEditorController.cut}" image="fa-cut"/> <tc:button label="Copy" action="#{treeEditorController.copy}" image="fa-copy"/> <tc:button label="Paste" action="#{treeEditorController.paste}" image="fa-paste"/> <tc:button label="Up" action="#{treeEditorController.moveUp}" image="fa-level-up"/> <tc:button label="Down" action="#{treeEditorController.moveDown}" image="fa-level-down"/> <tc:button label="Reset" action="#{treeEditorController.reset}" image="fa-undo"/> </tc:buttons> <tc:popup id="createPopup" collapsedMode="hidden"> <tc:box label="New"> <tc:in label="New Name" id="newName" value="#{treeEditorController.name}"/> <tc:button label="OK" action="#{treeEditorController.create}"> <f:ajax render=":::tree" execute=":::tree newName"/> <tc:operation name="hide" for="createPopup"/> </tc:button> <tc:button label="Cancel" omit="true"> <tc:operation name="hide" for="createPopup"/> </tc:button> </tc:box> </tc:popup> <tc:popup id="renamePopup" collapsedMode="hidden"> <tc:box label="Rename"> <tc:in label="New Name" id="renameName" value="#{treeEditorController.name}"/> <tc:button label="OK" action="#{treeEditorController.rename}"> <f:ajax render=":::tree" execute=":::tree renameName"/> <tc:operation name="hide" for="renamePopup"/> </tc:button> <tc:button label="Cancel" omit="true"> <tc:operation name="hide" for="renamePopup"/> </tc:button> </tc:box> </tc:popup> <tc:tree value="#{treeEditorController.categoryTree}" var="node" id="tree" showRoot="true" showRootJunction="true" selectable="single"> <tc:treeNode> <tc:treeIndent showJunctions="true"/> <tc:treeSelect label="#{node.userObject.name}" value="#{node.userObject.selected}"/> </tc:treeNode> </tc:tree> </ui:composition>