svn changeset:11377/svn branch:6.3_ddtags/6.7.0.beta1
import java.lang.annotation.RetentionPolicy; | import java.lang.annotation.RetentionPolicy; | ||||
import java.lang.annotation.Target; | import java.lang.annotation.Target; | ||||
import com.vaadin.terminal.gwt.client.ui.dd.VAcceptCriteria; | |||||
import com.vaadin.terminal.gwt.client.ui.dd.VAcceptCriterion; | |||||
/** | /** | ||||
* TODO | * TODO | ||||
/** | /** | ||||
* @return the client side counterpart for the annotated criterion | * @return the client side counterpart for the annotated criterion | ||||
*/ | */ | ||||
Class<? extends VAcceptCriteria> value(); | |||||
Class<? extends VAcceptCriterion> value(); | |||||
} | } |
public abstract class VAbstractDropHandler implements VDropHandler { | public abstract class VAbstractDropHandler implements VDropHandler { | ||||
private UIDL criterioUIDL; | private UIDL criterioUIDL; | ||||
private VAcceptCriteria acceptCriteria = new VAcceptAll(); | |||||
private VAcceptCriterion acceptCriteria = new VAcceptAll(); | |||||
/** | /** | ||||
* Implementor/user of {@link VAbstractDropHandler} must pass the UIDL | * Implementor/user of {@link VAbstractDropHandler} must pass the UIDL | ||||
uidl = (UIDL) childIterator.next(); | uidl = (UIDL) childIterator.next(); | ||||
} | } | ||||
} | } | ||||
acceptCriteria = VAcceptCriterion.get(uidl.getStringAttribute("name")); | |||||
acceptCriteria = VAcceptCriteria.get(uidl.getStringAttribute("name")); | |||||
if (acceptCriteria == null) { | if (acceptCriteria == null) { | ||||
throw new IllegalArgumentException( | throw new IllegalArgumentException( | ||||
"No accept criteria found with given name " | "No accept criteria found with given name " |
import com.vaadin.terminal.gwt.client.UIDL; | import com.vaadin.terminal.gwt.client.UIDL; | ||||
final public class VAcceptAll implements VAcceptCriteria { | |||||
final public class VAcceptAll implements VAcceptCriterion { | |||||
public void accept(VDragEvent drag, UIDL configuration, | public void accept(VDragEvent drag, UIDL configuration, | ||||
VAcceptCallback callback) { | VAcceptCallback callback) { | ||||
callback.accepted(drag); | callback.accepted(drag); |
package com.vaadin.terminal.gwt.client.ui.dd; | package com.vaadin.terminal.gwt.client.ui.dd; | ||||
import com.vaadin.terminal.gwt.client.UIDL; | |||||
import com.google.gwt.core.client.GWT; | |||||
public interface VAcceptCriteria { | |||||
/** | |||||
* A class via all AcceptCriteria instances are fetched by an identifier. | |||||
*/ | |||||
public class VAcceptCriteria { | |||||
private static VAcceptCriterionFactory impl; | |||||
/** | |||||
* Checks if current drag event has valid drop target and target accepts the | |||||
* transferable. If drop target is valid, callback is used. | |||||
* | |||||
* @param drag | |||||
* @param configuration | |||||
* @param callback | |||||
*/ | |||||
public void accept(VDragEvent drag, UIDL configuration, | |||||
VAcceptCallback callback); | |||||
static { | |||||
impl = GWT.create(VAcceptCriterionFactory.class); | |||||
} | |||||
public boolean needsServerSideCheck(VDragEvent drag, UIDL criterioUIDL); | |||||
public static VAcceptCriterion get(String name) { | |||||
return impl.get(name); | |||||
} | |||||
} | } |
package com.vaadin.terminal.gwt.client.ui.dd; | package com.vaadin.terminal.gwt.client.ui.dd; | ||||
import com.google.gwt.core.client.GWT; | |||||
import com.vaadin.terminal.gwt.client.UIDL; | |||||
/** | |||||
* A class via all AcceptCriteria instances are fetched by an identifier. | |||||
*/ | |||||
public class VAcceptCriterion { | |||||
private static VAcceptCriterionFactory impl; | |||||
public interface VAcceptCriterion { | |||||
static { | |||||
impl = GWT.create(VAcceptCriterionFactory.class); | |||||
} | |||||
/** | |||||
* Checks if current drag event has valid drop target and target accepts the | |||||
* transferable. If drop target is valid, callback is used. | |||||
* | |||||
* @param drag | |||||
* @param configuration | |||||
* @param callback | |||||
*/ | |||||
public void accept(VDragEvent drag, UIDL configuration, | |||||
VAcceptCallback callback); | |||||
public static VAcceptCriteria get(String name) { | |||||
return impl.get(name); | |||||
} | |||||
public boolean needsServerSideCheck(VDragEvent drag, UIDL criterioUIDL); | |||||
} | } |
public abstract class VAcceptCriterionFactory { | public abstract class VAcceptCriterionFactory { | ||||
public abstract VAcceptCriteria get(String name); | |||||
public abstract VAcceptCriterion get(String name); | |||||
// name = name.intern(); | // name = name.intern(); | ||||
// // FIXME make all lazy inited and possibility to use instances per | // // FIXME make all lazy inited and possibility to use instances per | ||||
// // handler | // // handler |
import com.vaadin.terminal.gwt.client.ApplicationConnection; | import com.vaadin.terminal.gwt.client.ApplicationConnection; | ||||
import com.vaadin.terminal.gwt.client.UIDL; | import com.vaadin.terminal.gwt.client.UIDL; | ||||
final public class VAnd implements VAcceptCriteria { | |||||
final public class VAnd implements VAcceptCriterion { | |||||
private boolean b1; | private boolean b1; | ||||
private boolean b2; | private boolean b2; | ||||
private VAcceptCriteria crit1; | |||||
private VAcceptCriteria crit2; | |||||
private VAcceptCriterion crit1; | |||||
private VAcceptCriterion crit2; | |||||
public void accept(VDragEvent drag, UIDL configuration, | public void accept(VDragEvent drag, UIDL configuration, | ||||
VAcceptCallback callback) { | VAcceptCallback callback) { | ||||
} | } | ||||
} | } | ||||
private VAcceptCriteria getCriteria(VDragEvent drag, UIDL configuration, | |||||
private VAcceptCriterion getCriteria(VDragEvent drag, UIDL configuration, | |||||
int i) { | int i) { | ||||
UIDL childUIDL = configuration.getChildUIDL(i); | UIDL childUIDL = configuration.getChildUIDL(i); | ||||
return VAcceptCriterion.get(childUIDL.getStringAttribute("name")); | |||||
return VAcceptCriteria.get(childUIDL.getStringAttribute("name")); | |||||
} | } | ||||
public boolean needsServerSideCheck(VDragEvent drag, UIDL criterioUIDL) { | public boolean needsServerSideCheck(VDragEvent drag, UIDL criterioUIDL) { |
import com.vaadin.terminal.gwt.client.Paintable; | import com.vaadin.terminal.gwt.client.Paintable; | ||||
import com.vaadin.terminal.gwt.client.UIDL; | import com.vaadin.terminal.gwt.client.UIDL; | ||||
final public class VComponentFilter implements VAcceptCriteria { | |||||
final public class VComponentFilter implements VAcceptCriterion { | |||||
public void accept(VDragEvent drag, UIDL configuration, | public void accept(VDragEvent drag, UIDL configuration, | ||||
VAcceptCallback callback) { | VAcceptCallback callback) { | ||||
try { | try { |
import com.vaadin.terminal.gwt.client.UIDL; | import com.vaadin.terminal.gwt.client.UIDL; | ||||
final public class VContainsDataFlawor implements VAcceptCriteria { | |||||
final public class VContainsDataFlawor implements VAcceptCriterion { | |||||
public void accept(VDragEvent drag, UIDL configuration, | public void accept(VDragEvent drag, UIDL configuration, | ||||
VAcceptCallback callback) { | VAcceptCallback callback) { | ||||
String name = configuration.getStringAttribute("p"); | String name = configuration.getStringAttribute("p"); |
import com.vaadin.terminal.gwt.client.UIDL; | import com.vaadin.terminal.gwt.client.UIDL; | ||||
final public class VDataBound implements VAcceptCriteria { | |||||
final public class VDataBound implements VAcceptCriterion { | |||||
public void accept(VDragEvent drag, UIDL configuration, | public void accept(VDragEvent drag, UIDL configuration, | ||||
VAcceptCallback callback) { | VAcceptCallback callback) { | ||||
if (drag.getTransferable().getData("itemId") != null) { | if (drag.getTransferable().getData("itemId") != null) { |
import com.vaadin.terminal.gwt.client.UIDL; | import com.vaadin.terminal.gwt.client.UIDL; | ||||
final public class VDropDetailEquals implements VAcceptCriteria { | |||||
final public class VDropDetailEquals implements VAcceptCriterion { | |||||
public void accept(VDragEvent drag, UIDL configuration, | public void accept(VDragEvent drag, UIDL configuration, | ||||
VAcceptCallback callback) { | VAcceptCallback callback) { | ||||
String name = configuration.getStringAttribute("p"); | String name = configuration.getStringAttribute("p"); |
import com.vaadin.terminal.gwt.client.UIDL; | import com.vaadin.terminal.gwt.client.UIDL; | ||||
final public class VIdentifierIs implements VAcceptCriteria { | |||||
final public class VIdentifierIs implements VAcceptCriterion { | |||||
public void accept(VDragEvent drag, UIDL configuration, | public void accept(VDragEvent drag, UIDL configuration, | ||||
VAcceptCallback callback) { | VAcceptCallback callback) { | ||||
try { | try { |
import com.vaadin.terminal.gwt.client.UIDL; | import com.vaadin.terminal.gwt.client.UIDL; | ||||
final public class VIsOverId implements VAcceptCriteria { | |||||
final public class VIsOverId implements VAcceptCriterion { | |||||
public void accept(VDragEvent drag, UIDL configuration, | public void accept(VDragEvent drag, UIDL configuration, | ||||
VAcceptCallback callback) { | VAcceptCallback callback) { | ||||
try { | try { |
* @deprecated example class testing custom behavior | * @deprecated example class testing custom behavior | ||||
*/ | */ | ||||
@Deprecated | @Deprecated | ||||
final public class VLazyInitItemIdentifiers implements VAcceptCriteria { | |||||
final public class VLazyInitItemIdentifiers implements VAcceptCriterion { | |||||
private boolean loaded = false; | private boolean loaded = false; | ||||
private HashSet<String> hashSet; | private HashSet<String> hashSet; | ||||
private VDragEvent lastDragEvent; | private VDragEvent lastDragEvent; |
import com.vaadin.terminal.gwt.client.ApplicationConnection; | import com.vaadin.terminal.gwt.client.ApplicationConnection; | ||||
import com.vaadin.terminal.gwt.client.UIDL; | import com.vaadin.terminal.gwt.client.UIDL; | ||||
final public class VNot implements VAcceptCriteria { | |||||
final public class VNot implements VAcceptCriterion { | |||||
private boolean b1; | private boolean b1; | ||||
private VAcceptCriteria crit1; | |||||
private VAcceptCriterion crit1; | |||||
public void accept(VDragEvent drag, UIDL configuration, | public void accept(VDragEvent drag, UIDL configuration, | ||||
VAcceptCallback callback) { | VAcceptCallback callback) { | ||||
} | } | ||||
} | } | ||||
private VAcceptCriteria getCriteria(VDragEvent drag, UIDL configuration, | |||||
private VAcceptCriterion getCriteria(VDragEvent drag, UIDL configuration, | |||||
int i) { | int i) { | ||||
UIDL childUIDL = configuration.getChildUIDL(i); | UIDL childUIDL = configuration.getChildUIDL(i); | ||||
return VAcceptCriterion.get(childUIDL.getStringAttribute("name")); | |||||
return VAcceptCriteria.get(childUIDL.getStringAttribute("name")); | |||||
} | } | ||||
public boolean needsServerSideCheck(VDragEvent drag, UIDL criterioUIDL) { | public boolean needsServerSideCheck(VDragEvent drag, UIDL criterioUIDL) { |
import com.vaadin.terminal.gwt.client.ApplicationConnection; | import com.vaadin.terminal.gwt.client.ApplicationConnection; | ||||
import com.vaadin.terminal.gwt.client.UIDL; | import com.vaadin.terminal.gwt.client.UIDL; | ||||
final public class VOr implements VAcceptCriteria { | |||||
final public class VOr implements VAcceptCriterion { | |||||
private boolean b1; | private boolean b1; | ||||
private boolean b2; | private boolean b2; | ||||
private VAcceptCriteria crit1; | |||||
private VAcceptCriteria crit2; | |||||
private VAcceptCriterion crit1; | |||||
private VAcceptCriterion crit2; | |||||
public void accept(VDragEvent drag, UIDL configuration, | public void accept(VDragEvent drag, UIDL configuration, | ||||
VAcceptCallback callback) { | VAcceptCallback callback) { | ||||
} | } | ||||
} | } | ||||
private VAcceptCriteria getCriteria(VDragEvent drag, UIDL configuration, | |||||
private VAcceptCriterion getCriteria(VDragEvent drag, UIDL configuration, | |||||
int i) { | int i) { | ||||
UIDL childUIDL = configuration.getChildUIDL(i); | UIDL childUIDL = configuration.getChildUIDL(i); | ||||
return VAcceptCriterion.get(childUIDL.getStringAttribute("name")); | |||||
return VAcceptCriteria.get(childUIDL.getStringAttribute("name")); | |||||
} | } | ||||
public boolean needsServerSideCheck(VDragEvent drag, UIDL criterioUIDL) { | public boolean needsServerSideCheck(VDragEvent drag, UIDL criterioUIDL) { |
import com.vaadin.terminal.gwt.client.UIDL; | import com.vaadin.terminal.gwt.client.UIDL; | ||||
final public class VOverTreeNode implements VAcceptCriteria { | |||||
final public class VOverTreeNode implements VAcceptCriterion { | |||||
public void accept(VDragEvent drag, UIDL configuration, | public void accept(VDragEvent drag, UIDL configuration, | ||||
VAcceptCallback callback) { | VAcceptCallback callback) { | ||||
Boolean containsKey = (Boolean) drag.getDropDetails().get( | Boolean containsKey = (Boolean) drag.getDropDetails().get( |
import com.vaadin.terminal.gwt.client.UIDL; | import com.vaadin.terminal.gwt.client.UIDL; | ||||
final public class VServerAccept implements VAcceptCriteria { | |||||
final public class VServerAccept implements VAcceptCriterion { | |||||
public void accept(final VDragEvent drag, UIDL configuration, | public void accept(final VDragEvent drag, UIDL configuration, | ||||
final VAcceptCallback callback) { | final VAcceptCallback callback) { | ||||
import com.vaadin.terminal.gwt.client.Paintable; | import com.vaadin.terminal.gwt.client.Paintable; | ||||
import com.vaadin.terminal.gwt.client.UIDL; | import com.vaadin.terminal.gwt.client.UIDL; | ||||
final public class VSourceIsSameAsTarget implements VAcceptCriteria { | |||||
final public class VSourceIsSameAsTarget implements VAcceptCriterion { | |||||
public void accept(VDragEvent drag, UIDL configuration, | public void accept(VDragEvent drag, UIDL configuration, | ||||
VAcceptCallback callback) { | VAcceptCallback callback) { | ||||
Paintable dragSource = drag.getTransferable().getDragSource(); | Paintable dragSource = drag.getTransferable().getDragSource(); |
import com.google.gwt.user.rebind.SourceWriter; | import com.google.gwt.user.rebind.SourceWriter; | ||||
import com.vaadin.event.dd.acceptCriteria.AcceptCriterion; | import com.vaadin.event.dd.acceptCriteria.AcceptCriterion; | ||||
import com.vaadin.event.dd.acceptCriteria.ClientCriterion; | import com.vaadin.event.dd.acceptCriteria.ClientCriterion; | ||||
import com.vaadin.terminal.gwt.client.ui.dd.VAcceptCriteria; | |||||
import com.vaadin.terminal.gwt.client.ui.dd.VAcceptCriterion; | |||||
import com.vaadin.ui.ClientWidget; | import com.vaadin.ui.ClientWidget; | ||||
/** | /** | ||||
private void generateInstantiatorMethod(SourceWriter sourceWriter, | private void generateInstantiatorMethod(SourceWriter sourceWriter, | ||||
GeneratorContext context, TreeLogger logger) { | GeneratorContext context, TreeLogger logger) { | ||||
sourceWriter.println("public VAcceptCriteria get(String name) {"); | |||||
sourceWriter.println("public VAcceptCriterion get(String name) {"); | |||||
sourceWriter.indent(); | sourceWriter.indent(); | ||||
sourceWriter.println("name = name.intern();"); | sourceWriter.println("name = name.intern();"); | ||||
for (Class<? extends AcceptCriterion> class1 : clientSideVerifiableCriterion) { | for (Class<? extends AcceptCriterion> class1 : clientSideVerifiableCriterion) { | ||||
String canonicalName = class1.getCanonicalName(); | String canonicalName = class1.getCanonicalName(); | ||||
Class<? extends VAcceptCriteria> clientClass = class1 | |||||
Class<? extends VAcceptCriterion> clientClass = class1 | |||||
.getAnnotation(ClientCriterion.class).value(); | .getAnnotation(ClientCriterion.class).value(); | ||||
sourceWriter.print("if (\""); | sourceWriter.print("if (\""); | ||||
sourceWriter.print(canonicalName); | sourceWriter.print(canonicalName); |