Author: nbelaevski
Date: 2007-11-11 22:03:07 -0500 (Sun, 11 Nov 2007)
New Revision: 3899
Added:
trunk/framework/api/src/main/java/org/richfaces/event/DnDEvent.java
Removed:
trunk/framework/api/src/main/java/org/richfaces/event/DropListenerBinding.java
Modified:
trunk/framework/api/src/main/java/org/richfaces/event/DragEvent.java
trunk/framework/api/src/main/java/org/richfaces/event/DropEvent.java
Log:
http://jira.jboss.com/jira/browse/RF-1330
Added: trunk/framework/api/src/main/java/org/richfaces/event/DnDEvent.java
===================================================================
--- trunk/framework/api/src/main/java/org/richfaces/event/DnDEvent.java
(rev 0)
+++ trunk/framework/api/src/main/java/org/richfaces/event/DnDEvent.java 2007-11-12
03:03:07 UTC (rev 3899)
@@ -0,0 +1,68 @@
+/**
+ * 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;
+import javax.faces.event.FacesListener;
+
+/**
+ *
+ * <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);
+ }
+
+ protected Object value;
+
+ private boolean valid = true;
+
+ public boolean isAppropriateListener(FacesListener listener) {
+ return valid;
+ }
+
+ public void invalidate() {
+ valid = false;
+ }
+
+ public boolean isValid() {
+ return valid;
+ }
+
+ public void processListener(FacesListener listener) {
+ if (!valid) {
+ throw new IllegalStateException();
+ }
+ }
+}
Modified: trunk/framework/api/src/main/java/org/richfaces/event/DragEvent.java
===================================================================
--- trunk/framework/api/src/main/java/org/richfaces/event/DragEvent.java 2007-11-12
03:03:02 UTC (rev 3898)
+++ trunk/framework/api/src/main/java/org/richfaces/event/DragEvent.java 2007-11-12
03:03:07 UTC (rev 3899)
@@ -22,7 +22,6 @@
package org.richfaces.event;
import javax.faces.component.UIComponent;
-import javax.faces.event.FacesEvent;
import javax.faces.event.FacesListener;
import org.richfaces.component.Draggable;
@@ -33,11 +32,10 @@
* created 27.12.2006
*
*/
-public class DragEvent extends FacesEvent {
+public class DragEvent extends DnDEvent {
private Dropzone dropTarget;
private Object acceptedTypes;
- private Object dropValue;
/**
*
*/
@@ -51,13 +49,14 @@
* @see
javax.faces.event.FacesEvent#isAppropriateListener(javax.faces.event.FacesListener)
*/
public boolean isAppropriateListener(FacesListener faceslistener) {
- return faceslistener instanceof DragListener;
+ return super.isAppropriateListener(faceslistener) && faceslistener instanceof
DragListener;
}
/* (non-Javadoc)
* @see javax.faces.event.FacesEvent#processListener(javax.faces.event.FacesListener)
*/
public void processListener(FacesListener faceslistener) {
+ super.processListener(faceslistener);
((DragListener) faceslistener).processDrag(this);
}
@@ -94,10 +93,10 @@
}
public Object getDropValue() {
- return dropValue;
+ return value;
}
public void setDropValue(Object dropValue) {
- this.dropValue = dropValue;
+ this.value = dropValue;
}
}
Modified: trunk/framework/api/src/main/java/org/richfaces/event/DropEvent.java
===================================================================
--- trunk/framework/api/src/main/java/org/richfaces/event/DropEvent.java 2007-11-12
03:03:02 UTC (rev 3898)
+++ trunk/framework/api/src/main/java/org/richfaces/event/DropEvent.java 2007-11-12
03:03:07 UTC (rev 3899)
@@ -22,7 +22,6 @@
package org.richfaces.event;
import javax.faces.component.UIComponent;
-import javax.faces.event.FacesEvent;
import javax.faces.event.FacesListener;
import org.richfaces.component.Draggable;
@@ -32,7 +31,7 @@
* @author shura
*
*/
-public class DropEvent extends FacesEvent {
+public class DropEvent extends DnDEvent {
/**
*
@@ -41,7 +40,6 @@
private Draggable draggableSource;
private String dragType;
- private Object dragValue;
public DropEvent(UIComponent component) {
super(component);
@@ -51,19 +49,15 @@
* @see
javax.faces.event.FacesEvent#isAppropriateListener(javax.faces.event.FacesListener)
*/
public boolean isAppropriateListener(FacesListener listener) {
-
- return listener instanceof DropListener;
+ return super.isAppropriateListener(listener) && listener instanceof
DropListener;
}
/* (non-Javadoc)
* @see javax.faces.event.FacesEvent#processListener(javax.faces.event.FacesListener)
*/
public void processListener(FacesListener listener) {
- if (listener instanceof DropListener) {
- DropListener dropListener = (DropListener) listener;
- dropListener.processDrop(this);
- }
-
+ super.processListener(listener);
+ ((DropListener) listener).processDrop(this);
}
/**
@@ -104,10 +98,10 @@
}
public Object getDragValue() {
- return dragValue;
+ return value;
}
public void setDragValue(Object dragValue) {
- this.dragValue = dragValue;
+ this.value = dragValue;
}
}
Deleted: trunk/framework/api/src/main/java/org/richfaces/event/DropListenerBinding.java
===================================================================
---
trunk/framework/api/src/main/java/org/richfaces/event/DropListenerBinding.java 2007-11-12
03:03:02 UTC (rev 3898)
+++
trunk/framework/api/src/main/java/org/richfaces/event/DropListenerBinding.java 2007-11-12
03:03:07 UTC (rev 3899)
@@ -1,104 +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.StateHolder;
-import javax.faces.component.UIComponentBase;
-import javax.faces.context.FacesContext;
-import javax.faces.el.ValueBinding;
-
-/**
- * Wrapper for bind DrolListener to EL expression.
- * @author shura
- *
- */
-public class DropListenerBinding implements DropListener, StateHolder {
-
- private ValueBinding _binding;
-
- private String _dragType;
-
- private ValueBinding _dragTypeBinding;
-
- private boolean _transient = false;
-
- public DropListenerBinding() {
- }
-
- /**
- * @param binding
- */
- public DropListenerBinding(ValueBinding binding) {
- super();
- _binding = binding;
- }
-
- private DropListener getHandler(FacesContext context) {
- return (DropListener) _binding.getValue(context);
- }
-
- public void processDrop(DropEvent event) {
- DropListener handler = getHandler(FacesContext.getCurrentInstance());
- handler.processDrop(event);
- }
-
- public boolean isTransient() {
- // TODO Auto-generated method stub
- return _transient;
- }
-
- public void restoreState(FacesContext context, Object state) {
- _binding = (ValueBinding) UIComponentBase.restoreAttachedState(context, state);
-
- }
-
- public Object saveState(FacesContext context) {
- return UIComponentBase.saveAttachedState(context, _binding);
- }
-
- public void setTransient(boolean newTransientValue) {
- _transient = newTransientValue;
-
- }
-
- /**
- * @return the dragType
- */
- public String getDragType() {
- return _dragType;
- }
-
- /**
- * @param dragType the dragType to set
- */
- public void setDragType(String dragType) {
- _dragType = dragType;
- }
-
- /**
- * @param dragTypeBinding the dragTypeBinding to set
- */
- public void setDragTypeBinding(ValueBinding dragTypeBinding) {
- _dragTypeBinding = dragTypeBinding;
- }
-
-}