Author: abelevich
Date: 2010-12-03 08:42:22 -0500 (Fri, 03 Dec 2010)
New Revision: 20341
Added:
trunk/ui/dnd/api/
trunk/ui/dnd/api/src/main/java/org/richfaces/event/DropEvent.java
trunk/ui/dnd/pom.xml
trunk/ui/dnd/ui/
trunk/ui/dnd/ui/src/main/java/org/richfaces/renderkit/DropBehaviorRendererBase.java
Removed:
trunk/ui/dnd/api/src/main/java/org/richfaces/event/DropEvent.java
trunk/ui/dnd/ui/src/main/java/org/richfaces/renderkit/DropBehaviorRendererBase.java
Log:
move dnd from sandbox
Copied: trunk/ui/dnd/api (from rev 20328, sandbox/trunk/ui/drag-drop/api)
Deleted: trunk/ui/dnd/api/src/main/java/org/richfaces/event/DropEvent.java
===================================================================
---
sandbox/trunk/ui/drag-drop/api/src/main/java/org/richfaces/event/DropEvent.java 2010-12-03
09:36:22 UTC (rev 20328)
+++ trunk/ui/dnd/api/src/main/java/org/richfaces/event/DropEvent.java 2010-12-03 13:42:22
UTC (rev 20341)
@@ -1,95 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright ${year}, Red Hat, Inc. and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
- */
-
-package org.richfaces.event;
-
-import java.util.Set;
-
-import javax.faces.component.UIComponent;
-import javax.faces.component.behavior.Behavior;
-import javax.faces.event.BehaviorEvent;
-import javax.faces.event.FacesListener;
-
-/**
- * @author abelevich
- *
- */
-public class DropEvent extends BehaviorEvent {
-
- private static final long serialVersionUID = 3717071628237886288L;
-
- private Object dropValue;
-
- private Object dragValue;
-
- private Set<String> acceptedTypes;
-
- private UIComponent dragSource;
-
-
- public DropEvent(UIComponent component, Behavior behavior) {
- super(component, behavior);
- }
-
- public Set<String> getAcceptedTypes() {
- return acceptedTypes;
- }
-
- public void setAcceptedTypes(Set<String> acceptedTypes) {
- this.acceptedTypes = acceptedTypes;
- }
-
- public Object getDropValue() {
- return dropValue;
- }
-
- public void setDropValue(Object dropValue) {
- this.dropValue = dropValue;
- }
-
- public Object getDragValue() {
- return dragValue;
- }
-
- public void setDragValue(Object dragValue) {
- this.dragValue = dragValue;
- }
-
- public UIComponent getDragSource() {
- return dragSource;
- }
-
- public void setDragSource(UIComponent dragSource) {
- this.dragSource = dragSource;
- }
-
- @Override
- public boolean isAppropriateListener(FacesListener listener) {
- return (listener instanceof DropListener);
- }
-
- @Override
- public void processListener(FacesListener listener) {
- ((DropListener) listener).processDrop(this);
- }
-
-}
\ No newline at end of file
Copied: trunk/ui/dnd/api/src/main/java/org/richfaces/event/DropEvent.java (from rev 20335,
sandbox/trunk/ui/drag-drop/api/src/main/java/org/richfaces/event/DropEvent.java)
===================================================================
--- trunk/ui/dnd/api/src/main/java/org/richfaces/event/DropEvent.java
(rev 0)
+++ trunk/ui/dnd/api/src/main/java/org/richfaces/event/DropEvent.java 2010-12-03 13:42:22
UTC (rev 20341)
@@ -0,0 +1,84 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright ${year}, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+
+package org.richfaces.event;
+
+import javax.faces.component.UIComponent;
+import javax.faces.event.BehaviorEvent;
+import javax.faces.event.FacesListener;
+
+import org.richfaces.component.behavior.ClientDragBehavior;
+import org.richfaces.component.behavior.ClientDropBehavior;
+
+/**
+ * @author abelevich
+ *
+ */
+public class DropEvent extends BehaviorEvent {
+
+ private static final long serialVersionUID = 3717071628237886288L;
+
+ private ClientDragBehavior dragSource;
+
+ private UIComponent dragComponent;
+
+ public DropEvent(UIComponent component, ClientDropBehavior behavior) {
+ super(component, behavior);
+ }
+
+ public ClientDragBehavior getDragSource() {
+ return dragSource;
+ }
+
+
+ public void setDragSource(ClientDragBehavior dragSource) {
+ this.dragSource = dragSource;
+ }
+
+ public UIComponent getDragComponent() {
+ return dragComponent;
+ }
+
+ public void setDragComponent(UIComponent dragComponent) {
+ this.dragComponent = dragComponent;
+ }
+
+ public ClientDropBehavior getDropSource() {
+ return (ClientDropBehavior)getBehavior();
+ }
+
+ public UIComponent getDropComponent() {
+ return getComponent();
+ }
+
+
+ @Override
+ public boolean isAppropriateListener(FacesListener listener) {
+ return (listener instanceof DropListener);
+ }
+
+ @Override
+ public void processListener(FacesListener listener) {
+ ((DropListener) listener).processDrop(this);
+ }
+
+}
\ No newline at end of file
Copied: trunk/ui/dnd/pom.xml (from rev 20328, sandbox/trunk/ui/drag-drop/pom.xml)
===================================================================
--- trunk/ui/dnd/pom.xml (rev 0)
+++ trunk/ui/dnd/pom.xml 2010-12-03 13:42:22 UTC (rev 20341)
@@ -0,0 +1,48 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ JBoss, Home of Professional Open Source Copyright 2010, Red Hat,
+ Inc. and individual contributors by the @authors tag. See the
+ copyright.txt in the distribution for a full listing of
+ individual contributors. This is free software; you can
+ redistribute it and/or modify it under the terms of the GNU
+ Lesser General Public License as published by the Free Software
+ Foundation; either version 2.1 of the License, or (at your
+ option) any later version. This software is distributed in the
+ hope that it will be useful, but WITHOUT ANY WARRANTY; without
+ even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ for more details. You should have received a copy of the GNU
+ Lesser General Public License along with this software; if not,
+ write to the Free Software Foundation, Inc., 51 Franklin St,
+ Fifth Floor, Boston, MA 02110-1301 USA, or see the FSF site:
+
http://www.fsf.org.
+-->
+
+<project
xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd">
+
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.richfaces</groupId>
+ <artifactId>richfaces-root-parent</artifactId>
+ <version>4.0.0-SNAPSHOT</version>
+ <relativePath>../../parent/pom.xml</relativePath>
+ </parent>
+
+ <groupId>org.richfaces.ui.output</groupId>
+ <artifactId>richfaces-ui-output-aggregator</artifactId>
+ <version>4.0.0-SNAPSHOT</version>
+ <packaging>pom</packaging>
+ <name>Richfaces UI Components: Drag-n-Drop Aggregator</name>
+
+ <modules>
+ <module>api</module>
+ <module>ui</module>
+ </modules>
+
+ <scm>
+
<
connection>scm:svn:http://anonsvn.jboss.org/repos/richfaces/trunk/ui/o...
+
<
developerConnection>scm:svn:https://svn.jboss.org/repos/richfaces/trun...
+ <
url>http://fisheye.jboss.org/browse/richfaces</url>
+ </scm>
+</project>
\ No newline at end of file
Copied: trunk/ui/dnd/ui (from rev 20328, sandbox/trunk/ui/drag-drop/ui)
Deleted:
trunk/ui/dnd/ui/src/main/java/org/richfaces/renderkit/DropBehaviorRendererBase.java
===================================================================
---
sandbox/trunk/ui/drag-drop/ui/src/main/java/org/richfaces/renderkit/DropBehaviorRendererBase.java 2010-12-03
09:36:22 UTC (rev 20328)
+++
trunk/ui/dnd/ui/src/main/java/org/richfaces/renderkit/DropBehaviorRendererBase.java 2010-12-03
13:42:22 UTC (rev 20341)
@@ -1,179 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright ${year}, Red Hat, Inc. and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
- */
-
-package org.richfaces.renderkit;
-
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.Set;
-
-import javax.faces.application.ResourceDependencies;
-import javax.faces.application.ResourceDependency;
-import javax.faces.component.ActionSource;
-import javax.faces.component.ContextCallback;
-import javax.faces.component.EditableValueHolder;
-import javax.faces.component.UIComponent;
-import javax.faces.component.behavior.ClientBehavior;
-import javax.faces.component.behavior.ClientBehaviorContext;
-import javax.faces.component.behavior.ClientBehaviorHolder;
-import javax.faces.context.FacesContext;
-import javax.faces.event.PhaseId;
-import javax.faces.render.FacesBehaviorRenderer;
-import javax.faces.render.RenderKitFactory;
-
-import org.richfaces.component.behavior.ClientDragBehavior;
-import org.richfaces.component.behavior.ClientDropBehavior;
-import org.richfaces.component.behavior.DropBehavior;
-import org.richfaces.event.DropEvent;
-
-
-/**
- * @author abelevich
- *
- */
-
-
-@FacesBehaviorRenderer(rendererType = DropBehavior.BEHAVIOR_ID, renderKitId =
RenderKitFactory.HTML_BASIC_RENDER_KIT)
-
-@ResourceDependencies({
- @ResourceDependency(name = "jquery.js"),
- @ResourceDependency(name = "jquery.position.js"),
- @ResourceDependency(name = "richfaces.js"),
- @ResourceDependency(name = "richfaces.js"),
- @ResourceDependency(library = "org.richfaces", name =
"jquery-ui-core.js"),
- @ResourceDependency(library = "org.richfaces", name =
"jquery-dnd.js"),
- @ResourceDependency(library = "org.richfaces", name =
"dnd-droppable.js"),
- @ResourceDependency(library = "org.richfaces", name =
"dnd-manager.js")
-})
-public class DropBehaviorRendererBase extends DnDBehaviorRenderBase {
-
- @Override
- public void decode(FacesContext facesContext, UIComponent component, ClientBehavior
behavior) {
- if (null == facesContext || null == component || behavior == null) {
- throw new NullPointerException();
- }
-
- Map<String, String> requestParamMap =
facesContext.getExternalContext().getRequestParameterMap();
- String dragSource = (String) requestParamMap.get("dragSource");
- facesContext.getViewRoot().invokeOnComponent(facesContext, dragSource, new
DropBehaviorContextCallBack(component, (ClientDropBehavior)behavior));
- }
-
- @Override
- protected String getScriptName() {
- return "RichFaces.ui.DnDManager.droppable";
- }
-
- public Map<String, Object> getOptions(ClientBehaviorContext behaviorContext,
ClientBehavior behavior) {
- Map<String, Object> options = new HashMap<String, Object>();
-
- if(behavior instanceof ClientDropBehavior) {
- ClientDropBehavior dropBehavior = (ClientDropBehavior)behavior;
- options.put("acceptedTypes", dropBehavior.getAcceptedTypes());
- }
-
- return options;
- }
-
- private final class DropBehaviorContextCallBack implements ContextCallback {
-
- private ClientDropBehavior dropBehavior;
-
- private UIComponent dropSource;
-
- public DropBehaviorContextCallBack(UIComponent dropSource, ClientDropBehavior
dropBehavior) {
- this.dropSource = dropSource;
- this.dropBehavior = dropBehavior;
- }
-
- public void invokeContextCallback(FacesContext context, UIComponent target) {
- ClientDragBehavior dragBehavior = getDragBehavior(target,
"mouseover");
- if(dragBehavior != null) {
- DropEvent dropEvent = new DropEvent(dropSource, dropBehavior);
- dropEvent.setDragSource(target);
- dropEvent.setDragValue(dragBehavior.getDragValue());
- dropEvent.setDropValue(dropBehavior.getDropValue());
- dropEvent.setAcceptedTypes(dropBehavior.getAcceptedTypes());
- queueDropEvent(dropEvent);
- } else {
- //TODO: log
- }
- }
-
- private void queueDropEvent(DropEvent event) {
- PhaseId phaseId = PhaseId.INVOKE_APPLICATION;
-
- if (isImmediate()) {
- phaseId = PhaseId.APPLY_REQUEST_VALUES;
- } else if (isBypassUpdates()) {
- phaseId = PhaseId.PROCESS_VALIDATIONS;
- }
-
- event.setPhaseId(phaseId);
- this.dropSource.queueEvent(event);
- }
-
- private boolean isImmediate(){
- boolean immediate = this.dropBehavior.isImmediate();
- if(!immediate) {
- if (dropSource instanceof EditableValueHolder) {
- immediate = ((EditableValueHolder) dropSource).isImmediate();
- } else if (dropSource instanceof ActionSource) {
- immediate = ((ActionSource) dropSource).isImmediate();
- }
- }
-
- return immediate;
- }
-
- private boolean isBypassUpdates(){
- boolean bypassUpdates = this.dropBehavior.isBypassUpdates();
- if (!bypassUpdates) {
- bypassUpdates = getUtils().isBooleanAttribute(this.dropSource,
"bypassUpdates");
- }
- return bypassUpdates;
- }
-
- private ClientDragBehavior getDragBehavior(UIComponent parent, String event) {
- if(parent instanceof ClientBehaviorHolder) {
- Map<String, List<ClientBehavior>> behaviorsMap =
((ClientBehaviorHolder)parent).getClientBehaviors();
- Set<Map.Entry<String, List<ClientBehavior>>> entries =
behaviorsMap.entrySet();
-
- for(Entry<String, List<ClientBehavior>> entry: entries) {
- if(event.equals(entry.getKey())){
- List<ClientBehavior> behaviors = entry.getValue();
- for(ClientBehavior behavior: behaviors) {
- if(behavior instanceof ClientDragBehavior) {
- return (ClientDragBehavior)behavior;
- }
- }
- }
- }
-
- }
- return null;
- }
-
- }
-
-}
Copied:
trunk/ui/dnd/ui/src/main/java/org/richfaces/renderkit/DropBehaviorRendererBase.java (from
rev 20336,
sandbox/trunk/ui/drag-drop/ui/src/main/java/org/richfaces/renderkit/DropBehaviorRendererBase.java)
===================================================================
--- trunk/ui/dnd/ui/src/main/java/org/richfaces/renderkit/DropBehaviorRendererBase.java
(rev 0)
+++
trunk/ui/dnd/ui/src/main/java/org/richfaces/renderkit/DropBehaviorRendererBase.java 2010-12-03
13:42:22 UTC (rev 20341)
@@ -0,0 +1,177 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright ${year}, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+
+package org.richfaces.renderkit;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.Set;
+
+import javax.faces.application.ResourceDependencies;
+import javax.faces.application.ResourceDependency;
+import javax.faces.component.ActionSource;
+import javax.faces.component.ContextCallback;
+import javax.faces.component.EditableValueHolder;
+import javax.faces.component.UIComponent;
+import javax.faces.component.behavior.ClientBehavior;
+import javax.faces.component.behavior.ClientBehaviorContext;
+import javax.faces.component.behavior.ClientBehaviorHolder;
+import javax.faces.context.FacesContext;
+import javax.faces.event.PhaseId;
+import javax.faces.render.FacesBehaviorRenderer;
+import javax.faces.render.RenderKitFactory;
+
+import org.richfaces.component.behavior.ClientDragBehavior;
+import org.richfaces.component.behavior.ClientDropBehavior;
+import org.richfaces.component.behavior.DropBehavior;
+import org.richfaces.event.DropEvent;
+
+
+/**
+ * @author abelevich
+ *
+ */
+
+
+@FacesBehaviorRenderer(rendererType = DropBehavior.BEHAVIOR_ID, renderKitId =
RenderKitFactory.HTML_BASIC_RENDER_KIT)
+
+@ResourceDependencies({
+ @ResourceDependency(name = "jquery.js"),
+ @ResourceDependency(name = "jquery.position.js"),
+ @ResourceDependency(name = "richfaces.js"),
+ @ResourceDependency(name = "richfaces.js"),
+ @ResourceDependency(library = "org.richfaces", name =
"jquery-ui-core.js"),
+ @ResourceDependency(library = "org.richfaces", name =
"jquery-dnd.js"),
+ @ResourceDependency(library = "org.richfaces", name =
"dnd-droppable.js"),
+ @ResourceDependency(library = "org.richfaces", name =
"dnd-manager.js")
+})
+public class DropBehaviorRendererBase extends DnDBehaviorRenderBase {
+
+ @Override
+ public void decode(FacesContext facesContext, UIComponent component, ClientBehavior
behavior) {
+ if (null == facesContext || null == component || behavior == null) {
+ throw new NullPointerException();
+ }
+
+ Map<String, String> requestParamMap =
facesContext.getExternalContext().getRequestParameterMap();
+ String dragSource = (String) requestParamMap.get("dragSource");
+ facesContext.getViewRoot().invokeOnComponent(facesContext, dragSource, new
DropBehaviorContextCallBack(component, (ClientDropBehavior)behavior));
+ }
+
+ @Override
+ protected String getScriptName() {
+ return "RichFaces.ui.DnDManager.droppable";
+ }
+
+ public Map<String, Object> getOptions(ClientBehaviorContext behaviorContext,
ClientBehavior behavior) {
+ Map<String, Object> options = new HashMap<String, Object>();
+
+ if(behavior instanceof ClientDropBehavior) {
+ ClientDropBehavior dropBehavior = (ClientDropBehavior)behavior;
+ options.put("acceptedTypes", dropBehavior.getAcceptedTypes());
+ }
+
+ return options;
+ }
+
+ private final class DropBehaviorContextCallBack implements ContextCallback {
+
+ private ClientDropBehavior dropBehavior;
+
+ private UIComponent dropSource;
+
+ public DropBehaviorContextCallBack(UIComponent dropSource, ClientDropBehavior
dropBehavior) {
+ this.dropSource = dropSource;
+ this.dropBehavior = dropBehavior;
+ }
+
+ public void invokeContextCallback(FacesContext context, UIComponent target) {
+ ClientDragBehavior dragBehavior = getDragBehavior(target,
"mouseover");
+ if(dragBehavior != null) {
+ DropEvent dropEvent = new DropEvent(dropSource, dropBehavior);
+ dropEvent.setDragSource(dragBehavior);
+ dropEvent.setDragComponent(target);
+ queueDropEvent(dropEvent);
+ } else {
+ //TODO: log
+ }
+ }
+
+ private void queueDropEvent(DropEvent event) {
+ PhaseId phaseId = PhaseId.INVOKE_APPLICATION;
+
+ if (isImmediate()) {
+ phaseId = PhaseId.APPLY_REQUEST_VALUES;
+ } else if (isBypassUpdates()) {
+ phaseId = PhaseId.PROCESS_VALIDATIONS;
+ }
+
+ event.setPhaseId(phaseId);
+ this.dropSource.queueEvent(event);
+ }
+
+ private boolean isImmediate(){
+ boolean immediate = this.dropBehavior.isImmediate();
+ if(!immediate) {
+ if (dropSource instanceof EditableValueHolder) {
+ immediate = ((EditableValueHolder) dropSource).isImmediate();
+ } else if (dropSource instanceof ActionSource) {
+ immediate = ((ActionSource) dropSource).isImmediate();
+ }
+ }
+
+ return immediate;
+ }
+
+ private boolean isBypassUpdates(){
+ boolean bypassUpdates = this.dropBehavior.isBypassUpdates();
+ if (!bypassUpdates) {
+ bypassUpdates = getUtils().isBooleanAttribute(this.dropSource,
"bypassUpdates");
+ }
+ return bypassUpdates;
+ }
+
+ private ClientDragBehavior getDragBehavior(UIComponent parent, String event) {
+ if(parent instanceof ClientBehaviorHolder) {
+ Map<String, List<ClientBehavior>> behaviorsMap =
((ClientBehaviorHolder)parent).getClientBehaviors();
+ Set<Map.Entry<String, List<ClientBehavior>>> entries =
behaviorsMap.entrySet();
+
+ for(Entry<String, List<ClientBehavior>> entry: entries) {
+ if(event.equals(entry.getKey())){
+ List<ClientBehavior> behaviors = entry.getValue();
+ for(ClientBehavior behavior: behaviors) {
+ if(behavior instanceof ClientDragBehavior) {
+ return (ClientDragBehavior)behavior;
+ }
+ }
+ }
+ }
+
+ }
+ return null;
+ }
+
+ }
+
+}