Author: nbelaevski
Date: 2010-12-15 18:05:47 -0500 (Wed, 15 Dec 2010)
New Revision: 20598
Added:
trunk/examples/richfaces-showcase/src/main/java/org/richfaces/demo/dragdrop/
trunk/examples/richfaces-showcase/src/main/java/org/richfaces/demo/dragdrop/DragDropBean.java
trunk/examples/richfaces-showcase/src/main/java/org/richfaces/demo/dragdrop/DragDropEventBean.java
trunk/examples/richfaces-showcase/src/main/java/org/richfaces/demo/dragdrop/Framework.java
trunk/examples/richfaces-showcase/src/main/webapp/richfaces/dragDrop/
trunk/examples/richfaces-showcase/src/main/webapp/richfaces/dragDrop/dragDrop.xhtml
trunk/examples/richfaces-showcase/src/main/webapp/richfaces/dragDrop/samples/
trunk/examples/richfaces-showcase/src/main/webapp/richfaces/dragDrop/samples/dragDrop-sample.xhtml
Modified:
trunk/examples/richfaces-showcase/src/main/resources/org/richfaces/demo/data/common/navigation.xml
Log:
DnD showcase demo initial check-in
Added:
trunk/examples/richfaces-showcase/src/main/java/org/richfaces/demo/dragdrop/DragDropBean.java
===================================================================
---
trunk/examples/richfaces-showcase/src/main/java/org/richfaces/demo/dragdrop/DragDropBean.java
(rev 0)
+++
trunk/examples/richfaces-showcase/src/main/java/org/richfaces/demo/dragdrop/DragDropBean.java 2010-12-15
23:05:47 UTC (rev 20598)
@@ -0,0 +1,102 @@
+package org.richfaces.demo.dragdrop;
+
+import static org.richfaces.demo.dragdrop.Framework.Family.cf;
+import static org.richfaces.demo.dragdrop.Framework.Family.dotNet;
+import static org.richfaces.demo.dragdrop.Framework.Family.php;
+
+import java.io.Serializable;
+import java.util.Collection;
+import java.util.List;
+
+import javax.faces.bean.ManagedBean;
+import javax.faces.bean.ViewScoped;
+
+import org.richfaces.demo.dragdrop.Framework.Family;
+
+import com.google.common.base.Predicate;
+import com.google.common.collect.Collections2;
+import com.google.common.collect.Lists;
+
+@ManagedBean
+@ViewScoped
+public class DragDropBean implements Serializable {
+
+ private static final long serialVersionUID = 1416925735640720492L;
+
+ private static final FrameworkFamilyPredicate CF_PREDICATE = new
FrameworkFamilyPredicate(cf);
+
+ private static final FrameworkFamilyPredicate DOT_NET_PREDICATE = new
FrameworkFamilyPredicate(dotNet);
+
+ private static final FrameworkFamilyPredicate PHP_PREDICATE = new
FrameworkFamilyPredicate(php);
+
+ private static final class FrameworkFamilyPredicate implements
Predicate<Framework> {
+
+ private Framework.Family family;
+
+ public FrameworkFamilyPredicate(Family family) {
+ super();
+ this.family = family;
+ }
+
+ public boolean apply(Framework input) {
+ return family.equals(input.getFamily());
+ }
+
+ }
+
+ private List<Framework> source;
+
+ private List<Framework> target;
+
+ public DragDropBean() {
+ initList();
+ }
+
+ public Collection<Framework> getSource() {
+ return source;
+ }
+
+ public Collection<Framework> getTarget() {
+ return target;
+ }
+
+ public List<Framework> getTargetPHP() {
+ return Lists.newLinkedList(Collections2.filter(target, PHP_PREDICATE));
+ }
+
+ public List<Framework> getTargetDotNet() {
+ return Lists.newLinkedList(Collections2.filter(target, DOT_NET_PREDICATE));
+ }
+
+ public List<Framework> getTargetCF() {
+ return Lists.newLinkedList(Collections2.filter(target, CF_PREDICATE));
+ }
+
+ public void moveFramework(Framework framework) {
+ source.remove(framework);
+ target.add(framework);
+ }
+
+ public void reset() {
+ initList();
+ }
+
+ private void initList() {
+ source = Lists.newArrayList();
+ target = Lists.newArrayList();
+
+ source.add(new Framework("Flexible Ajax", php));
+ source.add(new Framework("ajaxCFC", cf));
+ source.add(new Framework("AJAXEngine", dotNet));
+ source.add(new Framework("AjaxAC", php));
+ source.add(new Framework("MonoRail", dotNet));
+ source.add(new Framework("wddxAjax", cf));
+ source.add(new Framework("AJAX AGENT", php));
+ source.add(new Framework("FastPage", dotNet));
+ source.add(new Framework("JSMX", cf));
+ source.add(new Framework("PAJAJ", php));
+ source.add(new Framework("Symfony", php));
+ source.add(new Framework("PowerWEB", dotNet));
+ }
+
+}
Added:
trunk/examples/richfaces-showcase/src/main/java/org/richfaces/demo/dragdrop/DragDropEventBean.java
===================================================================
---
trunk/examples/richfaces-showcase/src/main/java/org/richfaces/demo/dragdrop/DragDropEventBean.java
(rev 0)
+++
trunk/examples/richfaces-showcase/src/main/java/org/richfaces/demo/dragdrop/DragDropEventBean.java 2010-12-15
23:05:47 UTC (rev 20598)
@@ -0,0 +1,24 @@
+package org.richfaces.demo.dragdrop;
+
+import javax.faces.bean.ManagedBean;
+import javax.faces.bean.ManagedProperty;
+import javax.faces.bean.RequestScoped;
+
+import org.richfaces.event.DropEvent;
+import org.richfaces.event.DropListener;
+
+@ManagedBean
+@RequestScoped
+public class DragDropEventBean implements DropListener {
+
+ @ManagedProperty(value = "#{dragDropBean}")
+ private DragDropBean dragDropBean;
+
+ public void setDragDropBean(DragDropBean dragDropBean) {
+ this.dragDropBean = dragDropBean;
+ }
+
+ public void processDrop(DropEvent event) {
+ dragDropBean.moveFramework((Framework) event.getDragValue());
+ }
+}
\ No newline at end of file
Added:
trunk/examples/richfaces-showcase/src/main/java/org/richfaces/demo/dragdrop/Framework.java
===================================================================
---
trunk/examples/richfaces-showcase/src/main/java/org/richfaces/demo/dragdrop/Framework.java
(rev 0)
+++
trunk/examples/richfaces-showcase/src/main/java/org/richfaces/demo/dragdrop/Framework.java 2010-12-15
23:05:47 UTC (rev 20598)
@@ -0,0 +1,64 @@
+package org.richfaces.demo.dragdrop;
+
+import java.io.Serializable;
+
+public class Framework implements Serializable {
+
+ private static final long serialVersionUID = -2316100725668694225L;
+
+ public enum Family {
+ php, cf, dotNet
+ }
+
+ private String name;
+
+ private Family family;
+
+ public Framework(String name, Family family) {
+ this.name = name;
+ this.family = family;
+ }
+
+ public Family getFamily() {
+ return family;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((family == null) ? 0 : family.hashCode());
+ result = prime * result + ((name == null) ? 0 : name.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj == null) {
+ return false;
+ }
+ if (getClass() != obj.getClass()) {
+ return false;
+ }
+ Framework other = (Framework) obj;
+ if (family != other.family) {
+ return false;
+ }
+ if (name == null) {
+ if (other.name != null) {
+ return false;
+ }
+ } else if (!name.equals(other.name)) {
+ return false;
+ }
+ return true;
+ }
+
+}
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-15
23:03:53 UTC (rev 20597)
+++
trunk/examples/richfaces-showcase/src/main/resources/org/richfaces/demo/data/common/navigation.xml 2010-12-15
23:05:47 UTC (rev 20598)
@@ -593,4 +593,19 @@
</demo>
</demos>
</group>
+ <group>
+ <name>Drag'n'Drop</name>
+ <demos>
+ <demo>
+ <id>dragDrop</id>
+ <name>Drag'n'Drop</name>
+ <samples>
+ <sample>
+ <id>dragDrop</id>
+ <name>Drag'n'Drop usage example</name>
+ </sample>
+ </samples>
+ </demo>
+ </demos>
+ </group>
</root>
Added:
trunk/examples/richfaces-showcase/src/main/webapp/richfaces/dragDrop/dragDrop.xhtml
===================================================================
--- trunk/examples/richfaces-showcase/src/main/webapp/richfaces/dragDrop/dragDrop.xhtml
(rev 0)
+++
trunk/examples/richfaces-showcase/src/main/webapp/richfaces/dragDrop/dragDrop.xhtml 2010-12-15
23:05:47 UTC (rev 20598)
@@ -0,0 +1,16 @@
+<!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>
+ <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
Added:
trunk/examples/richfaces-showcase/src/main/webapp/richfaces/dragDrop/samples/dragDrop-sample.xhtml
===================================================================
---
trunk/examples/richfaces-showcase/src/main/webapp/richfaces/dragDrop/samples/dragDrop-sample.xhtml
(rev 0)
+++
trunk/examples/richfaces-showcase/src/main/webapp/richfaces/dragDrop/samples/dragDrop-sample.xhtml 2010-12-15
23:05:47 UTC (rev 20598)
@@ -0,0 +1,106 @@
+<!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:outputStylesheet>
+ .panelc {
+ width:25%;
+ vertical-align:top;
+ }
+
+ .dropTargetPanel {
+ width: 90%;
+ }
+
+ .footerClass {
+ text-align: center;
+ padding-top: 5px;
+ }
+ </h:outputStylesheet>
+
+ <h:form id="form">
+
+ <h:panelGrid columnClasses="panelc" columns="4"
width="100%">
+
+ <rich:panel style="width:133px">
+ <f:facet name="header">
+ <h:outputText value="Source List" />
+ </f:facet>
+ <h:dataTable id="src" columns="1"
value="#{dragDropBean.source}"
+ var="fm" footerClass="footerClass">
+
+ <h:column>
+ <a4j:outputPanel
+ style="width:100px;border:1px solid gray;padding:2px"
+ layout="block">
+ <rich:dragBehavior event="mouseover"
+ type="#{fm.family}" dragValue="#{fm}" />
+ <h:outputText value="#{fm.name}"></h:outputText>
+ </a4j:outputPanel>
+ </h:column>
+ <f:facet name="footer">
+ <a4j:commandButton action="#{dragDropBean.reset}" value="Start
Over"
+ render="src,phptable,cftable,dnettable" />
+ </f:facet>
+ </h:dataTable>
+ </rich:panel>
+
+ <rich:panel styleClass="dropTargetPanel">
+ <f:facet name="header">
+ <h:outputText value="PHP Frameworks" />
+ </f:facet>
+ <rich:dropBehavior event="mouseover" acceptedTypes="php"
dropValue="PHP"
+ listener="#{dragDropEventBean.processDrop}" render="phptable,
src" />
+
+ <h:dataTable id="phptable" columns="1"
+ value="#{dragDropBean.targetPHP}" var="fm">
+ <h:column>
+ <h:outputText value="#{fm.name}"></h:outputText>
+ </h:column>
+ </h:dataTable>
+
+
+ </rich:panel>
+
+ <rich:panel styleClass="dropTargetPanel">
+ <f:facet name="header">
+ <h:outputText
value=".NET Frameworks" />
+ </f:facet>
+ <rich:dropBehavior event="mouseover" acceptedTypes="dotNet"
dropValue="DNET"
+ listener="#{dragDropEventBean.processDrop}" render="dnettable,
src" />
+
+ <h:dataTable id="dnettable" columns="1"
+ value="#{dragDropBean.targetDotNet}" var="fm">
+ <h:column>
+ <h:outputText value="#{fm.name}"></h:outputText>
+ </h:column>
+ </h:dataTable>
+
+
+ </rich:panel>
+
+ <rich:panel styleClass="dropTargetPanel">
+ <f:facet name="header">
+ <h:outputText value="ColdFusion Frameworks" />
+ </f:facet>
+ <rich:dropBehavior event="mouseover" acceptedTypes="cf"
dropValue="CF"
+ listener="#{dragDropEventBean.processDrop}" render="cftable,
src" />
+
+ <h:dataTable id="cftable" columns="1"
value="#{dragDropBean.targetCF}"
+ var="fm">
+ <h:column>
+ <h:outputText value="#{fm.name}"></h:outputText>
+ </h:column>
+ </h:dataTable>
+ </rich:panel>
+ </h:panelGrid>
+
+ </h:form>
+ <a4j:outputPanel ajaxRendered="true">
+ <h:messages></h:messages>
+ </a4j:outputPanel>
+</ui:composition>
\ No newline at end of file