Author: abelevich
Date: 2010-11-26 13:16:17 -0500 (Fri, 26 Nov 2010)
New Revision: 20188
Added:
sandbox/trunk/ui/drag-drop/api/src/main/java/org/richfaces/event/MethodExpressionDropListener.java
sandbox/trunk/ui/drag-drop/ui/src/main/java/org/richfaces/renderkit/DnDBehaviorRenderBase.java
sandbox/trunk/ui/drag-drop/ui/src/main/java/org/richfaces/view/
sandbox/trunk/ui/drag-drop/ui/src/main/java/org/richfaces/view/facelets/
sandbox/trunk/ui/drag-drop/ui/src/main/java/org/richfaces/view/facelets/html/
sandbox/trunk/ui/drag-drop/ui/src/main/java/org/richfaces/view/facelets/html/DropBehaviorHandler.java
Removed:
sandbox/trunk/ui/drag-drop/api/src/main/java/org/richfaces/component/Draggable.java
sandbox/trunk/ui/drag-drop/api/src/main/java/org/richfaces/component/Dropzone.java
sandbox/trunk/ui/drag-drop/api/src/main/java/org/richfaces/event/DnDEvent.java
sandbox/trunk/ui/drag-drop/api/src/main/java/org/richfaces/event/DragEvent.java
sandbox/trunk/ui/drag-drop/api/src/main/java/org/richfaces/event/DragListener.java
sandbox/trunk/ui/drag-drop/api/src/main/java/org/richfaces/event/DropBehaviorEvent.java
sandbox/trunk/ui/drag-drop/api/src/main/java/org/richfaces/event/DropSource.java
Modified:
sandbox/trunk/ui/drag-drop/api/src/main/java/org/richfaces/component/behavior/ClientDragBehavior.java
sandbox/trunk/ui/drag-drop/api/src/main/java/org/richfaces/component/behavior/ClientDropBehavior.java
sandbox/trunk/ui/drag-drop/api/src/main/java/org/richfaces/event/DropEvent.java
sandbox/trunk/ui/drag-drop/api/src/main/java/org/richfaces/event/DropListener.java
sandbox/trunk/ui/drag-drop/ui/src/main/java/org/richfaces/component/AbstractDragIndicator.java
sandbox/trunk/ui/drag-drop/ui/src/main/java/org/richfaces/component/behavior/DropBehavior.java
sandbox/trunk/ui/drag-drop/ui/src/main/java/org/richfaces/renderkit/DragBehaviorRendererBase.java
sandbox/trunk/ui/drag-drop/ui/src/main/java/org/richfaces/renderkit/DragIndicatorRendererBase.java
sandbox/trunk/ui/drag-drop/ui/src/main/java/org/richfaces/renderkit/DropBehaviorRendererBase.java
sandbox/trunk/ui/drag-drop/ui/src/main/resources/META-INF/resources/org.richfaces/dnd-droppable.js
sandbox/trunk/ui/drag-drop/ui/src/main/resources/META-INF/resources/org.richfaces/dnd-manager.js
Log:
implement drop decode, dropEvent creation, drop listeners support
Deleted:
sandbox/trunk/ui/drag-drop/api/src/main/java/org/richfaces/component/Draggable.java
===================================================================
---
sandbox/trunk/ui/drag-drop/api/src/main/java/org/richfaces/component/Draggable.java 2010-11-26
17:27:32 UTC (rev 20187)
+++
sandbox/trunk/ui/drag-drop/api/src/main/java/org/richfaces/component/Draggable.java 2010-11-26
18:16:17 UTC (rev 20188)
@@ -1,154 +0,0 @@
-/**
- * License Agreement.
- *
- * Rich Faces - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library 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 library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.richfaces.component;
-
-import javax.faces.context.FacesContext;
-
-import org.richfaces.event.DragListener;
-
-/**
- * Interface for all draggable components. Describe bean properties, implemented
- * by component.
- *
- * @author shura
- *
- */
-public interface Draggable {
-
- /**
- * Getter for value parameter, used as key for draggable component.
- *
- * @return
- */
- public Object getDragValue();
-
- public void setDragValue(Object value);
-
- /**
- * Getter for id of component ( instance of {@link UIDragIndicator} ) used
- * for create drag cursor.
- *
- * @return
- */
- public String getDragIndicator();
-
- /**
- * @param dragIndicator
- * - id of cursor component
- */
- public void setDragIndicator(String dragIndicator);
-
- /**
- * Draggable implementation may wish to resolve drag indicator id to
- * clientId itself
- *
- * @param facesContext
- * {@link FacesContext} instance
- * @return resolved indicator client id or null
- * @since 3.1
- */
- public String getResolvedDragIndicator(FacesContext facesContext);
-
- /**
- * Getter for type of this draggable ( file, mail etc ).
- *
- * @return
- */
- public String getDragType();
-
- /**
- * @param dragType
- */
- public void setDragType(String dragType);
-
- /**
- * Getter for JavaScript event handler, called before start drag operation.
- * If this handler return false, drag operation is cancelled.
- *
- * @return javaScript code of event handler.
- */
- public String getOndragstart();
-
- /**
- * @param dragType
- */
- public void setOndragstart(String ondrag);
-
- /**
- * Getter for JavaScript event handler; Called when drag operation end.
- *
- * @return javaScript code of event handler.
- */
- public String getOndragend();
-
- public void setOndragend(String ondrag);
-
- /**
- * Getter for JavaScript event handler; Called when dragged element over the
- * dropzone.
- *
- * @return javaScript code of event handler.
- */
- public String getOndropover();
-
- public void setOndropover(String ondropover);
-
- /**
- * Getter for JavaScript event handler; Called when dragged element out the
- * dropzone.
- *
- * @return javaScript code of event handler.
- */
- public String getOndropout();
-
- public void setOndropout(String ondropout);
-
- /**
- * Append drag listener to component listeners collection
- *
- * @param listener
- */
- public void addDragListener(DragListener listener);
-
- /**
- * Get array of all Drop Listeners
- *
- * @return
- */
- public DragListener[] getDragListeners();
-
- /**
- * Remove drop listener from component listeners array.
- *
- * @param listener
- */
- public void removeDragListener(DragListener listener);
-
- public String getGrabCursors();
-
- public void setGrabCursors(String grabCursors);
-
- public String getGrabbingCursors();
-
- public void setGrabbingCursors(String grabbingCursors);
-
-}
Deleted:
sandbox/trunk/ui/drag-drop/api/src/main/java/org/richfaces/component/Dropzone.java
===================================================================
---
sandbox/trunk/ui/drag-drop/api/src/main/java/org/richfaces/component/Dropzone.java 2010-11-26
17:27:32 UTC (rev 20187)
+++
sandbox/trunk/ui/drag-drop/api/src/main/java/org/richfaces/component/Dropzone.java 2010-11-26
18:16:17 UTC (rev 20188)
@@ -1,139 +0,0 @@
-/**
- * License Agreement.
- *
- * Rich Faces - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library 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 library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.richfaces.component;
-
-import org.richfaces.event.DropSource;
-
-/**
- * Base interface for all components, accesible as drop zone.
- *
- * @author shura
- *
- */
-public interface Dropzone extends DropSource {
-
- /**
- * Getter for dropType's , accepted by this zone.
- *
- * @return
- */
- public Object getAcceptedTypes();
-
- public void setAcceptedTypes(Object types);
-
- /**
- * Getter for mapping between drop types and indicator states.
- *
- * @return
- */
- public Object getTypeMapping();
-
- public void setTypeMapping(Object types);
-
- /**
- * Getter for mapping between drop types and acceptable cursors
- *
- * @return
- */
- public Object getCursorTypeMapping();
-
- public void setCursorTypeMapping(Object types);
-
- /**
- * Getter for JavaScript event handler, called then drag curcor enter in
- * component area. If this handler return false, or "declined", drop
- * operation on this component not allowed. If handler return true or
- * "allowed" , or any other supported indicator states, drop operation is
- * allowed and corresponding indicator state will be displayed.
- *
- * @return javaScript code of event handler.
- */
- public String getOndragenter();
-
- /**
- * @param dragType
- */
- public void setOndragenter(String ondrag);
-
- /**
- * Getter for JavaScript event handler, called before drag cursor leave
- * component area.
- *
- * @return javaScript code of event handler.
- */
- public String getOndragexit();
-
- /**
- * @param dragType
- */
- public void setOndragexit(String ondrag);
-
- public Object getDropValue();
-
- public void setDropValue(Object o);
-
- /**
- * Javascript code called before drop event.
- *
- * @parameter
- * @return the acceptClass
- */
- public abstract String getOndrop();
-
- /**
- * @param newOndrop
- * the value to set
- */
- public abstract void setOndrop(String newOndrop);
-
- /**
- * Javascript handler for event fired on drop even the drop for given type
- * is not available
- *
- * @parameter
- * @return the acceptClass
- */
- public abstract String getOndropend();
-
- /**
- * @param newname
- * the value to set
- */
- public abstract void setOndropend(String ondropend);
-
- /**
- * Getter for the list of comma separated cursors that indicates when
- * acceptable draggable over dropzone
- */
- public String getAcceptCursors();
-
- public void setAcceptCursors(String acceptCursors);
-
- /**
- * Getter for the list of comma separated cursors that indicates when
- * rejectable draggable over dropzone
- */
- public String getRejectCursors();
-
- public void setRejectCursors(String rejectCursors);
-
-}
Modified:
sandbox/trunk/ui/drag-drop/api/src/main/java/org/richfaces/component/behavior/ClientDragBehavior.java
===================================================================
---
sandbox/trunk/ui/drag-drop/api/src/main/java/org/richfaces/component/behavior/ClientDragBehavior.java 2010-11-26
17:27:32 UTC (rev 20187)
+++
sandbox/trunk/ui/drag-drop/api/src/main/java/org/richfaces/component/behavior/ClientDragBehavior.java 2010-11-26
18:16:17 UTC (rev 20188)
@@ -1,3 +1,25 @@
+/*
+ * 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.component.behavior;
import javax.faces.component.behavior.ClientBehavior;
@@ -3,4 +25,8 @@
+/**
+ * @author abelevich
+ *
+ */
public interface ClientDragBehavior extends ClientBehavior {
Modified:
sandbox/trunk/ui/drag-drop/api/src/main/java/org/richfaces/component/behavior/ClientDropBehavior.java
===================================================================
---
sandbox/trunk/ui/drag-drop/api/src/main/java/org/richfaces/component/behavior/ClientDropBehavior.java 2010-11-26
17:27:32 UTC (rev 20187)
+++
sandbox/trunk/ui/drag-drop/api/src/main/java/org/richfaces/component/behavior/ClientDropBehavior.java 2010-11-26
18:16:17 UTC (rev 20188)
@@ -1,3 +1,25 @@
+/*
+ * 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.component.behavior;
import java.util.Set;
@@ -4,11 +26,21 @@
import javax.faces.component.behavior.ClientBehavior;
+import org.richfaces.event.DropListener;
+
+/**
+ * @author abelevich
+ *
+ */
public interface ClientDropBehavior extends ClientBehavior{
public Set<String> getAcceptType();
public Object getDropValue();
+
+ public void addDropListener(DropListener dropListener);
+
+ public void removeDropListener(DropListener dropListener);
}
Deleted: sandbox/trunk/ui/drag-drop/api/src/main/java/org/richfaces/event/DnDEvent.java
===================================================================
---
sandbox/trunk/ui/drag-drop/api/src/main/java/org/richfaces/event/DnDEvent.java 2010-11-26
17:27:32 UTC (rev 20187)
+++
sandbox/trunk/ui/drag-drop/api/src/main/java/org/richfaces/event/DnDEvent.java 2010-11-26
18:16:17 UTC (rev 20188)
@@ -1,48 +0,0 @@
-/**
- * License Agreement.
- *
- * JBoss RichFaces - Ajax4jsf Component Library
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library 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 library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.richfaces.event;
-
-import javax.faces.component.UIComponent;
-import javax.faces.event.FacesEvent;
-
-/**
- *
- * <br />
- * <br />
- *
- * Created 12.11.2007
- *
- * @author Nick Belaevski
- * @since 3.2
- */
-
-public abstract class DnDEvent extends FacesEvent {
- /**
- *
- */
- private static final long serialVersionUID = -2455016405742082110L;
-
- public DnDEvent(UIComponent component) {
- super(component);
- }
-
-}
Deleted: sandbox/trunk/ui/drag-drop/api/src/main/java/org/richfaces/event/DragEvent.java
===================================================================
---
sandbox/trunk/ui/drag-drop/api/src/main/java/org/richfaces/event/DragEvent.java 2010-11-26
17:27:32 UTC (rev 20187)
+++
sandbox/trunk/ui/drag-drop/api/src/main/java/org/richfaces/event/DragEvent.java 2010-11-26
18:16:17 UTC (rev 20188)
@@ -1,108 +0,0 @@
-/**
- * License Agreement.
- *
- * Rich Faces - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library 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 library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.richfaces.event;
-
-import javax.faces.component.UIComponent;
-import javax.faces.event.FacesListener;
-
-import org.richfaces.component.Draggable;
-import org.richfaces.component.Dropzone;
-
-/**
- * @author Nick Belaevski - nbelaevski(a)exadel.com created 27.12.2006
- *
- */
-public class DragEvent extends DnDEvent {
-
- private static final long serialVersionUID = 6179268394391836905L;
-
- private Dropzone dropTarget;
- private Object acceptedTypes;
- private Object dropValue;
- /**
- *
- */
-
- public DragEvent(UIComponent uiComponent) {
- super(uiComponent);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
- * javax.faces.event.FacesEvent#isAppropriateListener(javax.faces.event.
- * FacesListener)
- */
- public boolean isAppropriateListener(FacesListener faceslistener) {
- return faceslistener instanceof DragListener;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
- * javax.faces.event.FacesEvent#processListener(javax.faces.event.FacesListener
- * )
- */
- public void processListener(FacesListener faceslistener) {
- ((DragListener) faceslistener).processDrag(this);
- }
-
- public Object getDragValue() {
- return ((Draggable) this.getSource()).getDragValue();
- }
-
- public Dropzone getDropTarget() {
- return dropTarget;
- }
-
- /**
- * @see java.util.EventObject#toString()
- */
- /*
- * public String toString() { return new ToStringBuilder(this,
- * ToStringStyle.MULTI_LINE_STYLE). append("component",
- * getComponent()).append("source",
getSource()).append("phaseId",
- * getPhaseId()). append("dragValue", getDragValue()).
append("dropTarget",
- * getDropTarget()). append("dropValue", getDropValue()). toString(); }
- */
- public void setDropTarget(Dropzone dropTarget) {
- this.dropTarget = dropTarget;
- }
-
- public Object getAcceptedTypes() {
- return acceptedTypes;
- }
-
- public void setAcceptedTypes(Object acceptedTypes) {
- this.acceptedTypes = acceptedTypes;
- }
-
- public Object getDropValue() {
- return dropValue;
- }
-
- public void setDropValue(Object dropValue) {
- this.dropValue = dropValue;
- }
-}
Deleted:
sandbox/trunk/ui/drag-drop/api/src/main/java/org/richfaces/event/DragListener.java
===================================================================
---
sandbox/trunk/ui/drag-drop/api/src/main/java/org/richfaces/event/DragListener.java 2010-11-26
17:27:32 UTC (rev 20187)
+++
sandbox/trunk/ui/drag-drop/api/src/main/java/org/richfaces/event/DragListener.java 2010-11-26
18:16:17 UTC (rev 20188)
@@ -1,33 +0,0 @@
-/**
- * License Agreement.
- *
- * Rich Faces - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library 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 library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.richfaces.event;
-
-import javax.faces.event.FacesListener;
-
-/**
- * @author Nick Belaevski - nbelaevski(a)exadel.com created 27.12.2006
- *
- */
-public interface DragListener extends FacesListener {
- public void processDrag(DragEvent event);
-
-}
Deleted:
sandbox/trunk/ui/drag-drop/api/src/main/java/org/richfaces/event/DropBehaviorEvent.java
===================================================================
---
sandbox/trunk/ui/drag-drop/api/src/main/java/org/richfaces/event/DropBehaviorEvent.java 2010-11-26
17:27:32 UTC (rev 20187)
+++
sandbox/trunk/ui/drag-drop/api/src/main/java/org/richfaces/event/DropBehaviorEvent.java 2010-11-26
18:16:17 UTC (rev 20188)
@@ -1,56 +0,0 @@
-package org.richfaces.event;
-
-import javax.faces.component.UIComponent;
-import javax.faces.component.behavior.Behavior;
-import javax.faces.event.BehaviorEvent;
-import javax.faces.event.FacesListener;
-
-public class DropBehaviorEvent extends BehaviorEvent {
-
- private static final long serialVersionUID = 3717071628237886288L;
-
- private Object dropValue;
-
- private Object dragValue;
-
- private UIComponent dragSource;
-
- 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;
- }
-
- public DropBehaviorEvent(UIComponent component, Behavior behavior) {
- super(component, behavior);
- }
-
- @Override
- public boolean isAppropriateListener(FacesListener listener) {
- return (listener instanceof DropListener);
- }
-
- @Override
- public void processListener(FacesListener listener) {
- ((DropListener) listener).processDrop(this);
- }
-
-}
Modified: sandbox/trunk/ui/drag-drop/api/src/main/java/org/richfaces/event/DropEvent.java
===================================================================
---
sandbox/trunk/ui/drag-drop/api/src/main/java/org/richfaces/event/DropEvent.java 2010-11-26
17:27:32 UTC (rev 20187)
+++
sandbox/trunk/ui/drag-drop/api/src/main/java/org/richfaces/event/DropEvent.java 2010-11-26
18:16:17 UTC (rev 20188)
@@ -1,111 +1,95 @@
-/**
- * License Agreement.
+/*
+ * 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.
*
- * Rich Faces - Natural Ajax for Java Server Faces (JSF)
+ * 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.
*
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
+ * 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
+ * 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 library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ * 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;
-import org.richfaces.component.Draggable;
-import org.richfaces.component.Dropzone;
-
/**
- * @author shura
- *
+ * @author abelevich
+ *
*/
-public class DropEvent extends DnDEvent {
+public class DropEvent extends BehaviorEvent {
- /**
- *
- */
- private static final long serialVersionUID = 1660545054556302746L;
-
- private Draggable draggableSource;
- private String dragType;
+ private static final long serialVersionUID = 3717071628237886288L;
+
+ private Object dropValue;
+
private Object dragValue;
-
- public DropEvent(UIComponent component) {
- super(component);
+
+ private Set<String> acceptType;
+
+ private UIComponent dragSource;
+
+
+ public DropEvent(UIComponent component, Behavior behavior) {
+ super(component, behavior);
}
-
- /*
- * (non-Javadoc)
- *
- * @see
- * javax.faces.event.FacesEvent#isAppropriateListener(javax.faces.event.
- * FacesListener)
- */
- public boolean isAppropriateListener(FacesListener listener) {
- return listener instanceof DropListener;
+
+ public Set<String> getAcceptType() {
+ return acceptType;
}
- /*
- * (non-Javadoc)
- *
- * @see
- * javax.faces.event.FacesEvent#processListener(javax.faces.event.FacesListener
- * )
- */
- public void processListener(FacesListener listener) {
- //((DropListener) listener).processDrop(this);
+ public void setAcceptType(Set<String> acceptType) {
+ this.acceptType = acceptType;
}
-
- /**
- * @return the dropValue
- */
+
public Object getDropValue() {
- return ((Dropzone) this.getSource()).getDropValue();
+ return dropValue;
}
- public Draggable getDraggableSource() {
- return draggableSource;
+ public void setDropValue(Object dropValue) {
+ this.dropValue = dropValue;
}
- /**
- * @see java.util.EventObject#toString()
- */
- /*
- * public String toString() { return new ToStringBuilder(this,
- * ToStringStyle.MULTI_LINE_STYLE). append("component", getComponent()).
- * append("source", getSource()). append("phaseId",
getPhaseId()).
- * append("dropValue", getDropValue()).
append("draggableSource",
- * getDraggableSource()). append("dragValue", getDragValue()). toString();
}
- */
- public void setDraggableSource(Draggable draggableSource) {
- this.draggableSource = draggableSource;
+ public Object getDragValue() {
+ return dragValue;
}
- public String getDragType() {
- return dragType;
+ public void setDragValue(Object dragValue) {
+ this.dragValue = dragValue;
}
- public void setDragType(String dragType) {
- this.dragType = dragType;
+ public UIComponent getDragSource() {
+ return dragSource;
}
- public Object getDragValue() {
- return dragValue;
+ public void setDragSource(UIComponent dragSource) {
+ this.dragSource = dragSource;
}
- public void setDragValue(Object dragValue) {
- this.dragValue = dragValue;
+ @Override
+ public boolean isAppropriateListener(FacesListener listener) {
+ return (listener instanceof DropListener);
}
+
+ @Override
+ public void processListener(FacesListener listener) {
+ ((DropListener) listener).processDrop(this);
+ }
+
}
Modified:
sandbox/trunk/ui/drag-drop/api/src/main/java/org/richfaces/event/DropListener.java
===================================================================
---
sandbox/trunk/ui/drag-drop/api/src/main/java/org/richfaces/event/DropListener.java 2010-11-26
17:27:32 UTC (rev 20187)
+++
sandbox/trunk/ui/drag-drop/api/src/main/java/org/richfaces/event/DropListener.java 2010-11-26
18:16:17 UTC (rev 20188)
@@ -1,22 +1,23 @@
-/**
- * License Agreement.
+/*
+ * 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.
*
- * Rich Faces - Natural Ajax for Java Server Faces (JSF)
+ * 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.
*
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
+ * 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
+ * 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 library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ * 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;
@@ -24,8 +25,12 @@
import javax.faces.event.BehaviorListener;
+/**
+ * @author abelevich
+ *
+ */
public interface DropListener extends BehaviorListener {
- public void processDrop(DropBehaviorEvent event);
+ public void processDrop(DropEvent event);
}
Deleted: sandbox/trunk/ui/drag-drop/api/src/main/java/org/richfaces/event/DropSource.java
===================================================================
---
sandbox/trunk/ui/drag-drop/api/src/main/java/org/richfaces/event/DropSource.java 2010-11-26
17:27:32 UTC (rev 20187)
+++
sandbox/trunk/ui/drag-drop/api/src/main/java/org/richfaces/event/DropSource.java 2010-11-26
18:16:17 UTC (rev 20188)
@@ -1,59 +0,0 @@
-/**
- * License Agreement.
- *
- * Rich Faces - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library 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 library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.richfaces.event;
-
-import javax.faces.el.MethodBinding;
-
-/**
- * Interface for component applicable to process drag/drop events.
- *
- * @author shura
- *
- */
-public interface DropSource {
-
- /**
- * Append drop listener to component listeners collection
- *
- * @param listener
- */
- public void addDropListener(DropListener listener);
-
- /**
- * Get array of all Drop Listeners
- *
- * @return
- */
- public DropListener[] getDropListeners();
-
- /**
- * Remove drop listener from component listeners array.
- *
- * @param listener
- */
- public void removeDropListener(DropListener listener);
-
- public void setDropListener(MethodBinding binding);
-
- public MethodBinding getDropListener();
-
-}
Added:
sandbox/trunk/ui/drag-drop/api/src/main/java/org/richfaces/event/MethodExpressionDropListener.java
===================================================================
---
sandbox/trunk/ui/drag-drop/api/src/main/java/org/richfaces/event/MethodExpressionDropListener.java
(rev 0)
+++
sandbox/trunk/ui/drag-drop/api/src/main/java/org/richfaces/event/MethodExpressionDropListener.java 2010-11-26
18:16:17 UTC (rev 20188)
@@ -0,0 +1,49 @@
+/*
+ * 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.el.MethodExpression;
+import javax.faces.context.FacesContext;
+
+
+/**
+ * @author abelevich
+ *
+ */
+public class MethodExpressionDropListener implements DropListener {
+ private MethodExpression methodExpression;
+
+ public MethodExpressionDropListener() {
+ super();
+ }
+
+ public MethodExpressionDropListener(MethodExpression methodExpression) {
+ super();
+ this.methodExpression = methodExpression;
+ }
+
+ public void processDrop(DropEvent event) {
+ FacesContext facesContext = FacesContext.getCurrentInstance();
+ methodExpression.invoke(facesContext.getELContext(), new Object[] { event });
+ }
+}
Modified:
sandbox/trunk/ui/drag-drop/ui/src/main/java/org/richfaces/component/AbstractDragIndicator.java
===================================================================
---
sandbox/trunk/ui/drag-drop/ui/src/main/java/org/richfaces/component/AbstractDragIndicator.java 2010-11-26
17:27:32 UTC (rev 20187)
+++
sandbox/trunk/ui/drag-drop/ui/src/main/java/org/richfaces/component/AbstractDragIndicator.java 2010-11-26
18:16:17 UTC (rev 20188)
@@ -1,3 +1,25 @@
+/*
+ * 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.component;
import javax.faces.component.UIComponentBase;
@@ -7,6 +29,10 @@
import org.richfaces.cdk.annotations.JsfRenderer;
import org.richfaces.cdk.annotations.Tag;
+/**
+ * @author abelevich
+ *
+ */
@JsfComponent(
type = AbstractDragIndicator.COMPONENT_TYPE,
family = AbstractDragIndicator.COMPONENT_FAMILY,
Modified:
sandbox/trunk/ui/drag-drop/ui/src/main/java/org/richfaces/component/behavior/DropBehavior.java
===================================================================
---
sandbox/trunk/ui/drag-drop/ui/src/main/java/org/richfaces/component/behavior/DropBehavior.java 2010-11-26
17:27:32 UTC (rev 20187)
+++
sandbox/trunk/ui/drag-drop/ui/src/main/java/org/richfaces/component/behavior/DropBehavior.java 2010-11-26
18:16:17 UTC (rev 20188)
@@ -29,6 +29,7 @@
import org.richfaces.cdk.annotations.JsfBehavior;
import org.richfaces.cdk.annotations.Tag;
import org.richfaces.cdk.annotations.TagType;
+import org.richfaces.event.DropListener;
import org.richfaces.renderkit.util.CoreAjaxRendererUtils;
/**
@@ -37,7 +38,7 @@
*/
@JsfBehavior(
- id = DropBehavior.BEHAVIOR_ID, tag = @Tag(name = "dropBehavior", handler =
"org.richfaces.view.facelets.html.CustomBehaviorHandler", type =
TagType.Facelets)
+ id = DropBehavior.BEHAVIOR_ID, tag = @Tag(name = "dropBehavior", handler =
"org.richfaces.view.facelets.html.DropBehaviorHandler", type =
TagType.Facelets)
)
public class DropBehavior extends ClientBehavior implements ClientDropBehavior {
@@ -63,6 +64,14 @@
return (Set<String>)getStateHelper().eval(PropertyKeys.acceptType);
}
+ public void addDropListener(DropListener listener) {
+ addBehaviorListener(listener);
+ }
+
+ public void removeDropListener(DropListener listener) {
+ removeBehaviorListener(listener);
+ }
+
@Override
public void setLiteralAttribute(String name, Object value) {
if(compare(PropertyKeys.acceptType, name)) {
@@ -76,4 +85,5 @@
public String getRendererType() {
return BEHAVIOR_ID;
}
+
}
Added:
sandbox/trunk/ui/drag-drop/ui/src/main/java/org/richfaces/renderkit/DnDBehaviorRenderBase.java
===================================================================
---
sandbox/trunk/ui/drag-drop/ui/src/main/java/org/richfaces/renderkit/DnDBehaviorRenderBase.java
(rev 0)
+++
sandbox/trunk/ui/drag-drop/ui/src/main/java/org/richfaces/renderkit/DnDBehaviorRenderBase.java 2010-11-26
18:16:17 UTC (rev 20188)
@@ -0,0 +1,67 @@
+/*
+ * 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.Map;
+
+import javax.faces.component.UIComponent;
+import javax.faces.component.behavior.ClientBehavior;
+import javax.faces.component.behavior.ClientBehaviorContext;
+import javax.faces.render.ClientBehaviorRenderer;
+
+import org.ajax4jsf.javascript.JSFunction;
+import org.ajax4jsf.javascript.JSReference;
+import org.richfaces.renderkit.util.RendererUtils;
+
+/**
+ * @author abelevich
+ *
+ */
+public abstract class DnDBehaviorRenderBase extends ClientBehaviorRenderer {
+
+ private static final RendererUtils UTILS = RendererUtils.getInstance();
+
+
+ protected abstract Map<String, Object> getOptions(ClientBehaviorContext
behaviorContext, ClientBehavior clientBehavior);
+
+ protected abstract String getScriptName();
+
+ public String getScript(ClientBehaviorContext behaviorContext, ClientBehavior
behavior) {
+ UIComponent parent = behaviorContext.getComponent();
+ String scriptName = getScriptName();
+ String script = null;
+ if(!"".equals(scriptName)) {
+ JSFunction function = new JSFunction(scriptName);
+ function.addParameter(JSReference.EVENT);
+
function.addParameter(parent.getClientId(behaviorContext.getFacesContext()));
+ function.addParameter(getOptions(behaviorContext, behavior));
+ script = function.toScript();
+ }
+ return script;
+ }
+
+ public RendererUtils getUtils() {
+ return UTILS;
+ }
+
+}
Modified:
sandbox/trunk/ui/drag-drop/ui/src/main/java/org/richfaces/renderkit/DragBehaviorRendererBase.java
===================================================================
---
sandbox/trunk/ui/drag-drop/ui/src/main/java/org/richfaces/renderkit/DragBehaviorRendererBase.java 2010-11-26
17:27:32 UTC (rev 20187)
+++
sandbox/trunk/ui/drag-drop/ui/src/main/java/org/richfaces/renderkit/DragBehaviorRendererBase.java 2010-11-26
18:16:17 UTC (rev 20188)
@@ -31,14 +31,11 @@
import javax.faces.component.behavior.ClientBehavior;
import javax.faces.component.behavior.ClientBehaviorContext;
import javax.faces.context.FacesContext;
-import javax.faces.render.ClientBehaviorRenderer;
import javax.faces.render.FacesBehaviorRenderer;
import javax.faces.render.RenderKitFactory;
-import org.ajax4jsf.javascript.JSFunction;
-import org.richfaces.component.behavior.DragBehavior;
import org.richfaces.component.behavior.ClientDragBehavior;
-import org.richfaces.renderkit.util.RendererUtils;
+import org.richfaces.component.behavior.DragBehavior;
/**
* @author abelevich
@@ -56,19 +53,8 @@
@ResourceDependency(library = "org.richfaces", name =
"dnd-draggable.js"),
@ResourceDependency(library = "org.richfaces", name =
"dnd-manager.js")
})
-public class DragBehaviorRendererBase extends ClientBehaviorRenderer {
-
- private static final RendererUtils UTILS = RendererUtils.getInstance();
-
- @Override
- public String getScript(ClientBehaviorContext behaviorContext, ClientBehavior
behavior) {
- UIComponent parent = behaviorContext.getComponent();
- JSFunction function = new
JSFunction("RichFaces.ui.DnDManager.draggable");
- function.addParameter(parent.getClientId(behaviorContext.getFacesContext()));
- function.addParameter(getOptions(behaviorContext, behavior));
- return function.toString();
- }
-
+public class DragBehaviorRendererBase extends DnDBehaviorRenderBase {
+
public Map<String, Object> getOptions(ClientBehaviorContext
clientBehaviorContext, ClientBehavior behavior) {
Map<String, Object> options = new HashMap<String, Object>();
if(behavior instanceof ClientDragBehavior) {
@@ -79,6 +65,11 @@
return options;
}
+ @Override
+ protected String getScriptName() {
+ return "RichFaces.ui.DnDManager.draggable";
+ }
+
public String getDragIndicatorClientId(ClientBehaviorContext clientBehaviorContext,
ClientDragBehavior dragBehavior) {
String indicatorId = dragBehavior.getIndicator();
if(indicatorId != null) {
@@ -92,9 +83,4 @@
}
return indicatorId;
}
-
- public RendererUtils getUtils() {
- return UTILS;
- }
-
}
Modified:
sandbox/trunk/ui/drag-drop/ui/src/main/java/org/richfaces/renderkit/DragIndicatorRendererBase.java
===================================================================
---
sandbox/trunk/ui/drag-drop/ui/src/main/java/org/richfaces/renderkit/DragIndicatorRendererBase.java 2010-11-26
17:27:32 UTC (rev 20187)
+++
sandbox/trunk/ui/drag-drop/ui/src/main/java/org/richfaces/renderkit/DragIndicatorRendererBase.java 2010-11-26
18:16:17 UTC (rev 20188)
@@ -1,3 +1,25 @@
+/*
+ * 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 javax.faces.application.ResourceDependencies;
@@ -4,6 +26,11 @@
import javax.faces.application.ResourceDependency;
+/**
+ * @author abelevich
+ *
+ */
+
@ResourceDependencies({
@ResourceDependency(library = "javax.faces", name = "jsf.js"),
@ResourceDependency(name = "jquery.js"),
Modified:
sandbox/trunk/ui/drag-drop/ui/src/main/java/org/richfaces/renderkit/DropBehaviorRendererBase.java
===================================================================
---
sandbox/trunk/ui/drag-drop/ui/src/main/java/org/richfaces/renderkit/DropBehaviorRendererBase.java 2010-11-26
17:27:32 UTC (rev 20187)
+++
sandbox/trunk/ui/drag-drop/ui/src/main/java/org/richfaces/renderkit/DropBehaviorRendererBase.java 2010-11-26
18:16:17 UTC (rev 20188)
@@ -36,15 +36,13 @@
import javax.faces.component.behavior.ClientBehaviorContext;
import javax.faces.component.behavior.ClientBehaviorHolder;
import javax.faces.context.FacesContext;
-import javax.faces.render.ClientBehaviorRenderer;
import javax.faces.render.FacesBehaviorRenderer;
import javax.faces.render.RenderKitFactory;
-import org.ajax4jsf.javascript.JSFunction;
import org.richfaces.component.behavior.ClientDragBehavior;
import org.richfaces.component.behavior.ClientDropBehavior;
import org.richfaces.component.behavior.DropBehavior;
-import org.richfaces.event.DropBehaviorEvent;
+import org.richfaces.event.DropEvent;
/**
@@ -64,29 +62,22 @@
@ResourceDependency(library = "org.richfaces", name =
"dnd-droppable.js"),
@ResourceDependency(library = "org.richfaces", name =
"dnd-manager.js")
})
-public class DropBehaviorRendererBase extends ClientBehaviorRenderer {
+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();
}
-
- String clientId = component.getClientId(facesContext);
+
Map<String, String> requestParamMap =
facesContext.getExternalContext().getRequestParameterMap();
- if(clientId.equals(requestParamMap.containsKey("dropSource"))) {
- String dragSource = (String) requestParamMap.get("dragSource");
- facesContext.getViewRoot().invokeOnComponent(facesContext, dragSource, new
DropBehaviorContextCallBack(component, (ClientDropBehavior)behavior));
- }
+ String dragSource = (String) requestParamMap.get("dragSource");
+ facesContext.getViewRoot().invokeOnComponent(facesContext, dragSource, new
DropBehaviorContextCallBack(component, (ClientDropBehavior)behavior));
}
@Override
- public String getScript(ClientBehaviorContext behaviorContext, ClientBehavior
behavior) {
- UIComponent parent = behaviorContext.getComponent();
- JSFunction function = new
JSFunction("RichFaces.ui.DnDManager.droppable");
- function.addParameter(parent.getClientId(behaviorContext.getFacesContext()));
- function.addParameter(getOptions(behaviorContext, behavior));
- return function.toString();
+ protected String getScriptName() {
+ return "RichFaces.ui.DnDManager.droppable";
}
public Map<String, Object> getOptions(ClientBehaviorContext behaviorContext,
ClientBehavior behavior) {
@@ -115,10 +106,11 @@
ClientDragBehavior dragBehavior = getDragBehavior(target,
"mouseover");
if(dragBehavior != null) {
- DropBehaviorEvent dropEvent = new DropBehaviorEvent(dropSource,
dropBehavior);
+ DropEvent dropEvent = new DropEvent(dropSource, dropBehavior);
dropEvent.setDragSource(target);
dropEvent.setDragValue(dragBehavior.getDragValue());
dropEvent.setDropValue(dropBehavior.getDropValue());
+ dropEvent.setAcceptType(dropBehavior.getAcceptType());
dropEvent.queue();
} else {
//TODO: log
Added:
sandbox/trunk/ui/drag-drop/ui/src/main/java/org/richfaces/view/facelets/html/DropBehaviorHandler.java
===================================================================
---
sandbox/trunk/ui/drag-drop/ui/src/main/java/org/richfaces/view/facelets/html/DropBehaviorHandler.java
(rev 0)
+++
sandbox/trunk/ui/drag-drop/ui/src/main/java/org/richfaces/view/facelets/html/DropBehaviorHandler.java 2010-11-26
18:16:17 UTC (rev 20188)
@@ -0,0 +1,78 @@
+/*
+ * 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.view.facelets.html;
+
+import javax.faces.view.facelets.BehaviorConfig;
+import javax.faces.view.facelets.FaceletContext;
+import javax.faces.view.facelets.MetaRule;
+import javax.faces.view.facelets.MetaRuleset;
+import javax.faces.view.facelets.Metadata;
+import javax.faces.view.facelets.MetadataTarget;
+import javax.faces.view.facelets.TagAttribute;
+
+import org.richfaces.component.behavior.ClientDropBehavior;
+import org.richfaces.event.MethodExpressionDropListener;
+
+/**
+ * @author abelevich
+ *
+ */
+public class DropBehaviorHandler extends CustomBehaviorHandler{
+
+ private static final DropBehaviorMetaRule METARULE = new DropBehaviorMetaRule();
+
+ public DropBehaviorHandler(BehaviorConfig config) {
+ super(config);
+ }
+
+ protected MetaRuleset createMetaRuleset(Class type) {
+ MetaRuleset m = super.createMetaRuleset(type);
+ m.addRule(METARULE);
+ return m;
+ }
+
+ static class DropBehaviorMetaRule extends MetaRule {
+ public Metadata applyRule(String name, TagAttribute attribute, MetadataTarget
meta) {
+ if (meta.isTargetInstanceOf(ClientDropBehavior.class) &&
"dropListener".equals(name)) {
+ return new DropBehaviorMapper(attribute);
+ }
+ return null;
+ }
+ }
+
+ static class DropBehaviorMapper extends Metadata {
+
+ private static final Class[] SIGNATURE = new Class[] {
org.richfaces.event.DropEvent.class };
+
+ private final TagAttribute attribute;
+
+ public DropBehaviorMapper(TagAttribute attribute) {
+ this.attribute = attribute;
+ }
+
+ public void applyMetadata(FaceletContext ctx, Object instance) {
+ ((ClientDropBehavior) instance).addDropListener((new
MethodExpressionDropListener( this.attribute.getMethodExpression(ctx, null,
SIGNATURE))));
+ }
+ }
+
+}
Modified:
sandbox/trunk/ui/drag-drop/ui/src/main/resources/META-INF/resources/org.richfaces/dnd-droppable.js
===================================================================
---
sandbox/trunk/ui/drag-drop/ui/src/main/resources/META-INF/resources/org.richfaces/dnd-droppable.js 2010-11-26
17:27:32 UTC (rev 20187)
+++
sandbox/trunk/ui/drag-drop/ui/src/main/resources/META-INF/resources/org.richfaces/dnd-droppable.js 2010-11-26
18:16:17 UTC (rev 20188)
@@ -5,10 +5,8 @@
rf.ui.Droppable = function(id, options) {
this.options = options;
this.dropElement = $(document.getElementById(id));
-
+
this.dropElement.droppable({addClasses: false});
- this.dropElement.droppable("option", "hoverClass",
'rf-drop-hover');
- this.dropElement.droppable("option", "activeClass",
'rf-drop-highlight');
this.dropElement.data("init", true);
this.dropElement.bind('drop', $.proxy(this.drop, this));
this.dropElement.bind('dropover', $.proxy(this.dropover, this));
@@ -18,13 +16,15 @@
$.extend(rf.ui.Droppable.prototype, ( function () {
return {
drop: function(e, ui) {
- var helper = ui.helper;
- var indicator = rf.$(helper.attr("id"));
- if(indicator) {
- helper.removeClass(indicator.acceptClass());
- helper.removeClass(indicator.rejectClass());
+ if(this.accept(ui.draggable)) {
+ var helper = ui.helper;
+ var indicator = rf.$(helper.attr("id"));
+ if(indicator) {
+ helper.removeClass(indicator.acceptClass());
+ helper.removeClass(indicator.rejectClass());
+ }
+ this.__callAjax(e, ui);
}
- this.__callAjax(e, ui);
},
dropover: function(event, ui) {
@@ -65,11 +65,12 @@
__callAjax: function(e, ui){
var options = {};
+ var originalEvent = this.options['event'];
if(ui.draggable) {
options['dragSource'] = ui.draggable.attr("id");
- options['dropSource'] = this.dropElement.attr("id");
+ options['javax.faces.behavior.event'] = originalEvent.type;
}
- rf.ajax(this.dropElement[0], e, {parameters: options});
+ rf.ajax(this.dropElement[0], originalEvent, {parameters: options});
}
}
})());
Modified:
sandbox/trunk/ui/drag-drop/ui/src/main/resources/META-INF/resources/org.richfaces/dnd-manager.js
===================================================================
---
sandbox/trunk/ui/drag-drop/ui/src/main/resources/META-INF/resources/org.richfaces/dnd-manager.js 2010-11-26
17:27:32 UTC (rev 20187)
+++
sandbox/trunk/ui/drag-drop/ui/src/main/resources/META-INF/resources/org.richfaces/dnd-manager.js 2010-11-26
18:16:17 UTC (rev 20188)
@@ -9,16 +9,18 @@
var droppables = {};
return {
- draggable: function(id, options) {
+ draggable: function(event, id, options) {
var draggable = draggables[id];
if(!draggable) {
+ options['event'] = event;
draggables[id] = new rf.ui.Draggable(id, options);
}
},
- droppable: function(id, options) {
+ droppable: function(event, id, options) {
var droppable = droppables[id];
if(!droppable) {
+ options['event'] = event;
droppables[id] = new rf.ui.Droppable(id, options);
}
}