Author: ilya_shaikovsky
Date: 2010-12-02 08:20:26 -0500 (Thu, 02 Dec 2010)
New Revision: 20303
Added:
trunk/examples/richfaces-showcase/src/main/java/org/richfaces/demo/tree/adaptors/
trunk/examples/richfaces-showcase/src/main/java/org/richfaces/demo/tree/adaptors/FileSystemBean.java
trunk/examples/richfaces-showcase/src/main/java/org/richfaces/demo/tree/adaptors/FileSystemNode.java
trunk/examples/richfaces-showcase/src/main/webapp/richfaces/treeAdaptors/
trunk/examples/richfaces-showcase/src/main/webapp/richfaces/treeAdaptors/samples/
trunk/examples/richfaces-showcase/src/main/webapp/richfaces/treeAdaptors/samples/treeModelRecursiveAdaptor-sample.xhtml
trunk/examples/richfaces-showcase/src/main/webapp/richfaces/treeAdaptors/treeModelRecursiveAdaptor.xhtml
Modified:
trunk/examples/richfaces-showcase/src/main/java/org/richfaces/demo/panelmenu/PanelMenuBean.java
trunk/examples/richfaces-showcase/src/main/java/org/richfaces/demo/progressBar/ProgressBarBean.java
trunk/examples/richfaces-showcase/src/main/java/org/richfaces/demo/tree/TreeBean.java
trunk/examples/richfaces-showcase/src/main/resources/org/richfaces/demo/data/common/navigation.xml
trunk/examples/richfaces-showcase/src/main/webapp/richfaces/panelMenu/samples/panelMenu-sample.xhtml
trunk/examples/richfaces-showcase/src/main/webapp/richfaces/progressBar/samples/ajaxProgressBar-sample.xhtml
trunk/examples/richfaces-showcase/src/main/webapp/richfaces/tree/samples/tree-sample.xhtml
Log:
tree Adaptors, checkstyle fixes, PanelBar fixes after component refactoring.
Modified:
trunk/examples/richfaces-showcase/src/main/java/org/richfaces/demo/panelmenu/PanelMenuBean.java
===================================================================
---
trunk/examples/richfaces-showcase/src/main/java/org/richfaces/demo/panelmenu/PanelMenuBean.java 2010-12-02
12:11:55 UTC (rev 20302)
+++
trunk/examples/richfaces-showcase/src/main/java/org/richfaces/demo/panelmenu/PanelMenuBean.java 2010-12-02
13:20:26 UTC (rev 20303)
@@ -4,30 +4,31 @@
import javax.faces.bean.RequestScoped;
import org.richfaces.event.ItemChangeEvent;
+
@ManagedBean
@RequestScoped
public class PanelMenuBean {
- private String current;
- private boolean singleMode;
- public boolean isSingleMode() {
- return singleMode;
- }
+ private String current;
+ private boolean singleMode;
- public void setSingleMode(boolean singleMode) {
- this.singleMode = singleMode;
- }
+ public boolean isSingleMode() {
+ return singleMode;
+ }
- public PanelMenuBean() {
- }
-
- public String getCurrent() {
- return this.current;
- }
-
- public void setCurrent(String current) {
- this.current = current;
- }
- public void updateCurrent(ItemChangeEvent event) {
- setCurrent(event.getNewItem());
- }
+ public void setSingleMode(boolean singleMode) {
+ this.singleMode = singleMode;
+ }
+
+ public String getCurrent() {
+ return this.current;
+ }
+
+ public void setCurrent(String current) {
+ this.current = current;
+ }
+
+ public void updateCurrent(ItemChangeEvent event) {
+ setCurrent(event.getNewItem());
+ System.out.println(event.getNewItem());
+ }
}
Modified:
trunk/examples/richfaces-showcase/src/main/java/org/richfaces/demo/progressBar/ProgressBarBean.java
===================================================================
---
trunk/examples/richfaces-showcase/src/main/java/org/richfaces/demo/progressBar/ProgressBarBean.java 2010-12-02
12:11:55 UTC (rev 20302)
+++
trunk/examples/richfaces-showcase/src/main/java/org/richfaces/demo/progressBar/ProgressBarBean.java 2010-12-02
13:20:26 UTC (rev 20303)
@@ -11,18 +11,18 @@
/**
* @author Ilya Shaikovsky
- *
+ *
*/
@ManagedBean
@ViewScoped
public class ProgressBarBean implements Serializable {
-
+
private static final long serialVersionUID = -314414475508376585L;
private boolean buttonRendered = true;
- private boolean enabled=false;
+ private boolean enabled = false;
private Long startTime;
-
+
public String startProcess() {
setEnabled(true);
setButtonRendered(false);
@@ -30,24 +30,23 @@
return null;
}
- public Long getCurrentValue(){
+ public Long getCurrentValue() {
if (isEnabled()) {
- Long current = (new Date().getTime() - startTime)/1000;
- if (current>100){
+ Long current = (new Date().getTime() - startTime) / 1000;
+ if (current >= 100) {
setButtonRendered(true);
} else if (current.equals(0)) {
return new Long(1);
}
- return (new Date().getTime() - startTime)/1000;
- }
+ return (new Date().getTime() - startTime) / 1000;
+ }
if (startTime == null) {
return Long.valueOf(-1);
} else {
- return Long.valueOf(101);
+ return Long.valueOf(100);
}
-
}
-
+
public boolean isEnabled() {
return enabled;
}
Modified:
trunk/examples/richfaces-showcase/src/main/java/org/richfaces/demo/tree/TreeBean.java
===================================================================
---
trunk/examples/richfaces-showcase/src/main/java/org/richfaces/demo/tree/TreeBean.java 2010-12-02
12:11:55 UTC (rev 20302)
+++
trunk/examples/richfaces-showcase/src/main/java/org/richfaces/demo/tree/TreeBean.java 2010-12-02
13:20:26 UTC (rev 20303)
@@ -50,7 +50,7 @@
private List<TreeNode> rootNodes = new ArrayList<TreeNode>();
private Map<String, Country> countriesCache = new HashMap<String,
Country>();
private Map<String, Company> companiesCache = new HashMap<String,
Company>();
-
+ private Object currentSelection;
@PostConstruct
public void init() {
for (CDXmlDescriptor current : cdXmlDescriptors) {
@@ -62,6 +62,13 @@
company.getCds().add(cd);
}
}
+
+ public void selectionChanged(TreeSelectionChangeEvent selectionChangeEvent){
+ //considering only single selection
+ List<Object> selection = new
ArrayList<Object>(selectionChangeEvent.getNewSelection());
+ currentSelection = selection.get(0);
+
+ }
private Country getCountryByName(CDXmlDescriptor descriptor) {
String countryName = descriptor.getCountry();
@@ -88,10 +95,6 @@
return company;
}
- private void selectionListener(TreeSelectionChangeEvent event) {
- //TODO: implement when ready
- }
-
public List<CDXmlDescriptor> getCdXmlDescriptors() {
return cdXmlDescriptors;
}
Added:
trunk/examples/richfaces-showcase/src/main/java/org/richfaces/demo/tree/adaptors/FileSystemBean.java
===================================================================
---
trunk/examples/richfaces-showcase/src/main/java/org/richfaces/demo/tree/adaptors/FileSystemBean.java
(rev 0)
+++
trunk/examples/richfaces-showcase/src/main/java/org/richfaces/demo/tree/adaptors/FileSystemBean.java 2010-12-02
13:20:26 UTC (rev 20303)
@@ -0,0 +1,22 @@
+package org.richfaces.demo.tree.adaptors;
+
+import java.util.List;
+
+import javax.faces.bean.ManagedBean;
+import javax.faces.bean.RequestScoped;
+
+@ManagedBean
+@RequestScoped
+public class FileSystemBean {
+ private static final String SRC_PATH = "/WEB-INF";
+
+ private List<FileSystemNode> srcRoots;
+
+ public synchronized List<FileSystemNode> getSourceRoots() {
+ if (srcRoots == null) {
+ srcRoots = new FileSystemNode(SRC_PATH).getNodes();
+ }
+
+ return srcRoots;
+ }
+}
Added:
trunk/examples/richfaces-showcase/src/main/java/org/richfaces/demo/tree/adaptors/FileSystemNode.java
===================================================================
---
trunk/examples/richfaces-showcase/src/main/java/org/richfaces/demo/tree/adaptors/FileSystemNode.java
(rev 0)
+++
trunk/examples/richfaces-showcase/src/main/java/org/richfaces/demo/tree/adaptors/FileSystemNode.java 2010-12-02
13:20:26 UTC (rev 20303)
@@ -0,0 +1,51 @@
+package org.richfaces.demo.tree.adaptors;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Set;
+
+import javax.faces.context.ExternalContext;
+import javax.faces.context.FacesContext;
+
+public class FileSystemNode {
+ private String path;
+
+ private List<FileSystemNode> children;
+
+ private String shortPath;
+
+ public FileSystemNode(String path) {
+ this.path = path;
+ int idx = path.lastIndexOf('/');
+ if (idx != -1) {
+ shortPath = path.substring(idx + 1);
+ } else {
+ shortPath = path;
+ }
+ }
+
+ public synchronized List<FileSystemNode> getNodes() {
+ if (children == null) {
+ children = new ArrayList<FileSystemNode>();
+ FacesContext facesContext = FacesContext.getCurrentInstance();
+ ExternalContext externalContext = facesContext.getExternalContext();
+ Set resourcePaths = externalContext.getResourcePaths(this.path);
+ if (resourcePaths != null) {
+ Object[] nodes = (Object[]) resourcePaths.toArray();
+ for (Object node : nodes) {
+ String nodePath = node.toString();
+ if (nodePath.endsWith("/")) {
+ nodePath = nodePath.substring(0, nodePath.length() - 1);
+ }
+ children.add(new FileSystemNode(nodePath));
+ }
+ }
+ }
+ return children;
+ }
+
+ public String getShortPath() {
+ return shortPath;
+ }
+
+}
\ No newline at end of file
Modified:
trunk/examples/richfaces-showcase/src/main/resources/org/richfaces/demo/data/common/navigation.xml
===================================================================
---
trunk/examples/richfaces-showcase/src/main/resources/org/richfaces/demo/data/common/navigation.xml 2010-12-02
12:11:55 UTC (rev 20302)
+++
trunk/examples/richfaces-showcase/src/main/resources/org/richfaces/demo/data/common/navigation.xml 2010-12-02
13:20:26 UTC (rev 20303)
@@ -291,6 +291,16 @@
</sample>
</samples>
</demo>
+ <demo new="true">
+ <id>treeAdaptors</id>
+ <name>Tree Adaptors</name>
+ <samples>
+ <sample>
+ <id>treeModelRecursiveAdaptor</id>
+ <name>Simple treeModelRecursiveAdaptor usage</name>
+ </sample>
+ </samples>
+ </demo>
</demos>
</group>
<group>
Modified:
trunk/examples/richfaces-showcase/src/main/webapp/richfaces/panelMenu/samples/panelMenu-sample.xhtml
===================================================================
---
trunk/examples/richfaces-showcase/src/main/webapp/richfaces/panelMenu/samples/panelMenu-sample.xhtml 2010-12-02
12:11:55 UTC (rev 20302)
+++
trunk/examples/richfaces-showcase/src/main/webapp/richfaces/panelMenu/samples/panelMenu-sample.xhtml 2010-12-02
13:20:26 UTC (rev 20303)
@@ -16,7 +16,7 @@
iconExpandedGroup="disc" iconCollapsedGroup="disc"
iconExpandedTopGroup="chevronUp" iconGroupTopPosition="right"
iconCollapsedTopGroup="chevronDown"
- itemChangeListener="#{panelMenuBean.updateCurrent}">
+ activeItem="#{panelMenuBean.current}">
<rich:panelMenuGroup label="Group 1">
<rich:panelMenuItem label="Item 1.1">
<f:param name="current" value="Item 1.1" />
@@ -71,8 +71,5 @@
</a4j:outputPanel>
</rich:panel>
</h:panelGrid>
- <rich:tabPanel>
- <rich:tab label="12 ">asdasd</rich:tab>
- </rich:tabPanel>
</h:form>
</ui:composition>
\ No newline at end of file
Modified:
trunk/examples/richfaces-showcase/src/main/webapp/richfaces/progressBar/samples/ajaxProgressBar-sample.xhtml
===================================================================
---
trunk/examples/richfaces-showcase/src/main/webapp/richfaces/progressBar/samples/ajaxProgressBar-sample.xhtml 2010-12-02
12:11:55 UTC (rev 20302)
+++
trunk/examples/richfaces-showcase/src/main/webapp/richfaces/progressBar/samples/ajaxProgressBar-sample.xhtml 2010-12-02
13:20:26 UTC (rev 20303)
@@ -5,28 +5,29 @@
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:a4j="http://richfaces.org/a4j"
xmlns:rich="http://richfaces.org/rich">
- <h:form id="form">
- <rich:progressBar mode="ajax"
value="#{progressBarBean.currentValue}"
- interval="2000"
- enabled="#{progressBarBean.enabled}" minValue="-1"
maxValue="100"
- reRenderAfterComplete="progressPanel">
- <f:facet name="initial">
- <br />
- <h:outputText value="Process doesn't started yet"
/>
- <a4j:commandButton
action="#{progressBarBean.startProcess}"
- value="Start Process" execute="@form"
- rendered="#{progressBarBean.buttonRendered}"
- style="margin: 9px 0px 5px;" />
- </f:facet>
- <f:facet name="complete">
- <br />
- <h:outputText value="Process Done" />
- <a4j:commandButton
action="#{progressBarBean.startProcess}"
- value="Restart Process" execute="@form"
- rendered="#{progressBarBean.buttonRendered}"
- style="margin: 9px 0px 5px;" />
- </f:facet>
- <h:outputText value="#{progressBarBean.currentValue} %"/>
- </rich:progressBar>
- </h:form>
+ <h:form id="form">
+ <rich:progressBar mode="ajax"
value="#{progressBarBean.currentValue}"
+ interval="2000" id="pb"
enabled="#{progressBarBean.enabled}"
+ minValue="0" maxValue="100"
reRenderAfterComplete="progressPanel">
+ <f:facet name="initial">
+ <h:panelGroup>
+ <h:outputText value="Process doesn't started yet" />
+ <a4j:commandButton action="#{progressBarBean.startProcess}"
+ value="Start Process" execute="@form" render="pb"
+ rendered="#{progressBarBean.buttonRendered}"
+ style="margin: 9px 0px 5px;" />
+ </h:panelGroup>
+ </f:facet>
+ <f:facet name="finish">
+ <h:panelGroup>
+ <h:outputText value="Process Done" />
+ <a4j:commandButton action="#{progressBarBean.startProcess}"
+ value="Restart Process" execute="@form"
+ rendered="#{progressBarBean.buttonRendered}"
+ style="margin: 9px 0px 5px;" />
+ </h:panelGroup>
+ </f:facet>
+ <h:outputText value="#{progressBarBean.currentValue} %" />
+ </rich:progressBar>
+ </h:form>
</ui:composition>
\ No newline at end of file
Modified:
trunk/examples/richfaces-showcase/src/main/webapp/richfaces/tree/samples/tree-sample.xhtml
===================================================================
---
trunk/examples/richfaces-showcase/src/main/webapp/richfaces/tree/samples/tree-sample.xhtml 2010-12-02
12:11:55 UTC (rev 20302)
+++
trunk/examples/richfaces-showcase/src/main/webapp/richfaces/tree/samples/tree-sample.xhtml 2010-12-02
13:20:26 UTC (rev 20303)
@@ -7,7 +7,8 @@
xmlns:rich="http://richfaces.org/rich">
<rich:tree id="tree" nodeType="#{node.type}"
var="node"
- value="#{treeBean.rootNodes}" toggleType="client">
+ value="#{treeBean.rootNodes}" toggleType="client"
+ >
<rich:treeNode type="country">
#{node.name}
</rich:treeNode>
Added:
trunk/examples/richfaces-showcase/src/main/webapp/richfaces/treeAdaptors/samples/treeModelRecursiveAdaptor-sample.xhtml
===================================================================
---
trunk/examples/richfaces-showcase/src/main/webapp/richfaces/treeAdaptors/samples/treeModelRecursiveAdaptor-sample.xhtml
(rev 0)
+++
trunk/examples/richfaces-showcase/src/main/webapp/richfaces/treeAdaptors/samples/treeModelRecursiveAdaptor-sample.xhtml 2010-12-02
13:20:26 UTC (rev 20303)
@@ -0,0 +1,18 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<ui:composition
xmlns="http://www.w3.org/1999/xhtml"
+
xmlns:h="http://java.sun.com/jsf/html"
+
xmlns:f="http://java.sun.com/jsf/core"
+
xmlns:ui="http://java.sun.com/jsf/facelets"
+
xmlns:a4j="http://richfaces.org/a4j"
+
xmlns:rich="http://richfaces.org/rich">
+
+ <h:form>
+ <rich:tree style="width:300px" toggleType="ajax"
var="item">
+ <rich:treeModelRecursiveAdaptor
roots="#{fileSystemBean.sourceRoots}" nodes="#{item.nodes}" >
+ <rich:treeNode>
+ #{item.shortPath}
+ </rich:treeNode>
+ </rich:treeModelRecursiveAdaptor>
+ </rich:tree>
+ </h:form>
+</ui:composition>
\ No newline at end of file
Added:
trunk/examples/richfaces-showcase/src/main/webapp/richfaces/treeAdaptors/treeModelRecursiveAdaptor.xhtml
===================================================================
---
trunk/examples/richfaces-showcase/src/main/webapp/richfaces/treeAdaptors/treeModelRecursiveAdaptor.xhtml
(rev 0)
+++
trunk/examples/richfaces-showcase/src/main/webapp/richfaces/treeAdaptors/treeModelRecursiveAdaptor.xhtml 2010-12-02
13:20:26 UTC (rev 20303)
@@ -0,0 +1,18 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html
xmlns="http://www.w3.org/1999/xhtml"
+
xmlns:h="http://java.sun.com/jsf/html"
+
xmlns:f="http://java.sun.com/jsf/core"
+
xmlns:ui="http://java.sun.com/jsf/facelets">
+
+<ui:composition>
+ <p>DESC</p>
+ <ui:include src="#{demoNavigator.sampleIncludeURI}" />
+ <ui:include src="/templates/includes/source-view.xhtml">
+ <ui:param name="src" value="#{demoNavigator.sampleIncludeURI}"
/>
+ <ui:param name="sourceType" value="xhtml" />
+ <ui:param name="openLabel" value="View Source" />
+ <ui:param name="hideLabel" value="Hide Source" />
+ </ui:include>
+</ui:composition>
+
+</html>
\ No newline at end of file