You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by lo...@apache.org on 2016/08/25 09:15:42 UTC
svn commit: r1757637 - in
/myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main:
java/org/apache/myfaces/tobago/example/demo/TreeEditorController.java
webapp/content/20-component/090-tree/02-editor/tree-editor.xhtml
Author: lofwyr
Date: Thu Aug 25 09:15:42 2016
New Revision: 1757637
URL: http://svn.apache.org/viewvc?rev=1757637&view=rev
Log:
TOBAGO 1544 Demo
Modified:
myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/java/org/apache/myfaces/tobago/example/demo/TreeEditorController.java
myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/content/20-component/090-tree/02-editor/tree-editor.xhtml
Modified: myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/java/org/apache/myfaces/tobago/example/demo/TreeEditorController.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/java/org/apache/myfaces/tobago/example/demo/TreeEditorController.java?rev=1757637&r1=1757636&r2=1757637&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/java/org/apache/myfaces/tobago/example/demo/TreeEditorController.java (original)
+++ myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/java/org/apache/myfaces/tobago/example/demo/TreeEditorController.java Thu Aug 25 09:15:42 2016
@@ -53,7 +53,7 @@ public class TreeEditorController implem
}
public String getName() {
- return "";
+ return name;
}
public void setName(String name) {
@@ -64,6 +64,9 @@ public class TreeEditorController implem
final DefaultMutableTreeNode node = findFirstSelected();
if (node != null) {
node.insert(CategoryTree.createNode(name, "id" + System.identityHashCode(name)), 0);
+ LOG.debug("Creating one node in {}", node.getUserObject());
+ } else {
+ LOG.warn("No node selected.");
}
return null;
}
@@ -77,6 +80,8 @@ public class TreeEditorController implem
FacesContext.getCurrentInstance().addMessage(null,
new FacesMessage(FacesMessage.SEVERITY_INFO, "Root node cannot be removed", null));
}
+ } else {
+ LOG.warn("No node selected.");
}
return null;
}
@@ -84,7 +89,11 @@ public class TreeEditorController implem
public String rename() {
final DefaultMutableTreeNode node = findFirstSelected();
if (node != null && node.getUserObject() instanceof Node) {
- ((Node) node.getUserObject()).setName(name);
+ final Node userObject = (Node) node.getUserObject();
+ LOG.debug("Renaming node from {} to {}", userObject.getName(), name);
+ userObject.setName(name);
+ } else {
+ LOG.warn("No node selected.");
}
return null;
}
Modified: myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/content/20-component/090-tree/02-editor/tree-editor.xhtml
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/content/20-component/090-tree/02-editor/tree-editor.xhtml?rev=1757637&r1=1757636&r2=1757637&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/content/20-component/090-tree/02-editor/tree-editor.xhtml (original)
+++ myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/content/20-component/090-tree/02-editor/tree-editor.xhtml Thu Aug 25 09:15:42 2016
@@ -23,50 +23,16 @@
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:f="http://java.sun.com/jsf/core">
<ui:param name="title" value="#{overviewBundle.tree_editor}"/>
- <p>This is an example, to show how to edit a tree.</p>
+ <p>This is an example, to show how to write an editor for a tree.
+ Some commands are using popups and AJAX.</p>
- <!-- todo -->
- <p>TODO: to be refactored because of TOBAGO-1565. Replace attribute "popupClose" with tc:operation</p>
-
- <tc:button label="New">
- <f:facet name="popup">
- <tc:popup id="createPopup">
- <tc:box label="New">
- <tc:in label="New Name" value="#{treeEditorController.name}"/>
- <tc:button label="OK" action="#{treeEditorController.create}">
- <tc:attribute name="popupClose" value="afterSubmit"/>
- </tc:button>
- <tc:button label="Cancel">
- <tc:attribute name="popupClose" value="immediate"/>
- </tc:button>
- </tc:box>
- </tc:popup>
- </f:facet>
- </tc:button>
- <tc:button label="Rename">
- <f:facet name="popup">
- <tc:popup id="renamePopup">
- <tc:box label="Rename">
- <tc:in label="New Name" value="#{treeEditorController.name}"/>
- <tc:button label="OK" action="#{treeEditorController.rename}">
- <tc:attribute name="popupClose" value="afterSubmit"/>
- </tc:button>
- <tc:button label="Cancel">
- <tc:attribute name="popupClose" value="immediate"/>
- </tc:button>
- </tc:box>
- </tc:popup>
- </f:facet>
- </tc:button>
-
- <p>Currently, the buttons 'New' and 'Rename' doesn't work in the toolbar. Use the alternative buttons above.</p>
<tc:buttons>
<tc:button label="New" omit="true" image="fa-file-o">
- <tc:dataAttribute name="alert-text" value="Not implemented yet"/>
+ <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:dataAttribute name="alert-text" value="Not implemented yet"/>
+ <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"/>
@@ -76,11 +42,38 @@
<tc:button label="Reset" action="#{treeEditorController.reset}" image="fa-undo"/>
</tc:buttons>
- <tc:tree value="#{treeEditorController.categoryTree}" var="node"
+ <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>