diff options
Diffstat (limited to 'src/com')
31 files changed, 346 insertions, 203 deletions
diff --git a/src/com/vaadin/event/Transferable.java b/src/com/vaadin/event/Transferable.java index c2b75630cb..973b01dce9 100644 --- a/src/com/vaadin/event/Transferable.java +++ b/src/com/vaadin/event/Transferable.java @@ -4,13 +4,18 @@ import java.util.Collection; import com.vaadin.ui.Component; +/** + * TODO Javadoc! + * + * @since 6.3 + */ public interface Transferable { - public Object getData(String dataFlawor); + public Object getData(String dataFlavor); - public void setData(String dataFlawor, Object value); + public void setData(String dataFlavor, Object value); - public Collection<String> getDataFlawors(); + public Collection<String> getDataFlavors(); /** * @return the component that created the Transferable diff --git a/src/com/vaadin/event/TransferableImpl.java b/src/com/vaadin/event/TransferableImpl.java index a03c572330..bd263c6c64 100644 --- a/src/com/vaadin/event/TransferableImpl.java +++ b/src/com/vaadin/event/TransferableImpl.java @@ -6,6 +6,11 @@ import java.util.Map; import com.vaadin.ui.Component; +/** + * TODO Javadoc! + * + * @since 6.3 + */ public class TransferableImpl implements Transferable { private Map<String, Object> rawVariables = new HashMap<String, Object>(); private Component sourceComponent; @@ -20,15 +25,15 @@ public class TransferableImpl implements Transferable { return sourceComponent; } - public Object getData(String dataFlawor) { - return rawVariables.get(dataFlawor); + public Object getData(String dataFlavor) { + return rawVariables.get(dataFlavor); } - public void setData(String dataFlawor, Object value) { - rawVariables.put(dataFlawor, value); + public void setData(String dataFlavor, Object value) { + rawVariables.put(dataFlavor, value); } - public Collection<String> getDataFlawors() { + public Collection<String> getDataFlavors() { return rawVariables.keySet(); } diff --git a/src/com/vaadin/event/dd/DragAndDropEvent.java b/src/com/vaadin/event/dd/DragAndDropEvent.java index 4adc4e757e..2e0ffbaa48 100644 --- a/src/com/vaadin/event/dd/DragAndDropEvent.java +++ b/src/com/vaadin/event/dd/DragAndDropEvent.java @@ -4,21 +4,29 @@ import java.io.Serializable; import com.vaadin.event.Transferable; +/** + * TODO Javadoc + * + * @since 6.3 + * + */ public class DragAndDropEvent implements Serializable { private static final long serialVersionUID = -2232591107911385564L; private Transferable transferable; - private DropTargetDetails dropDetails; + private DropTargetDetails dropTargetDetails; - public DragAndDropEvent(Transferable tr, DropTargetDetails details) { - transferable = tr; - dropDetails = details; + public DragAndDropEvent(Transferable transferable, + DropTargetDetails dropTargetDetails) { + this.transferable = transferable; + this.dropTargetDetails = dropTargetDetails; } public Transferable getTransferable() { return transferable; } - public DropTargetDetails getDropTargetData() { - return dropDetails; + public DropTargetDetails getDropTargetDetails() { + return dropTargetDetails; } + } diff --git a/src/com/vaadin/event/dd/DragSource.java b/src/com/vaadin/event/dd/DragSource.java index 73f8c09a41..263b4e780d 100644 --- a/src/com/vaadin/event/dd/DragSource.java +++ b/src/com/vaadin/event/dd/DragSource.java @@ -5,19 +5,28 @@ import java.util.Map; import com.vaadin.event.Transferable; +/** + * TODO Javadoc + * + * @since 6.3 + * + */ public interface DragSource extends Serializable { /** * DragSource may convert client side variables to meaningful values on - * server side. For example in Selects we convert item identifiers to - * generated string keys for the client side. Translators in Selects should - * convert them back to item identifiers. + * server side. For example Tree converts item identifiers to generated + * string keys for the client side. Translators in Selects should convert + * them back to item identifiers. + * * <p> * Translator should remove variables it handled from rawVariables. All non * handled variables are added to Transferable automatically by terminal. + * </p> * * <p> * + * @since 6.3 * @param rawVariables * @return the drag source related transferable */ diff --git a/src/com/vaadin/event/dd/DropHandler.java b/src/com/vaadin/event/dd/DropHandler.java index 4bdc435b9e..fd720a3978 100644 --- a/src/com/vaadin/event/dd/DropHandler.java +++ b/src/com/vaadin/event/dd/DropHandler.java @@ -5,6 +5,12 @@ import java.io.Serializable; import com.vaadin.event.dd.acceptCriteria.AcceptAll; import com.vaadin.event.dd.acceptCriteria.AcceptCriterion; +/** + * TODO Javadoc + * + * @since 6.3 + * + */ public interface DropHandler extends Serializable { public void drop(DragAndDropEvent dropEvent); diff --git a/src/com/vaadin/event/dd/DropTarget.java b/src/com/vaadin/event/dd/DropTarget.java index 407bb23958..1c9e30dd71 100644 --- a/src/com/vaadin/event/dd/DropTarget.java +++ b/src/com/vaadin/event/dd/DropTarget.java @@ -5,30 +5,29 @@ import java.util.Map; import com.vaadin.ui.Component; /** - * DropTarget is a marker interface for components supporting drop operations. A + * DropTarget is an interface for components supporting drop operations. A * component that wants to receive drop events should implement this interface * and provide a DropHandler which will handle the actual drop event. * + * @since 6.3 */ public interface DropTarget extends Component { public DropHandler getDropHandler(); /** - * Called before a drop operation to translate the drop data provided by the - * client widget. Should return a DropData implementation with the new - * values. If null is returned the terminal implementation will - * automatically create a {@link DropTargetDetails} with all the client - * variables. - * <p> - * If this method returns null the data from client side will be passed - * through as-is without conversion. + * Called before a drop operation to translate the drop target details + * provided by the client widget (drop target). Should return a DropData + * implementation with the new values. If null is returned the terminal + * implementation will automatically create a {@link DropTargetDetails} with + * all the client variables. * * @param rawVariables * Parameters passed from the client side widget. - * @return A DropData object with the translated data or null. + * @return A DropTargetDetails object with the translated data or null to + * use a default implementation. */ - public DropTargetDetails translateDragDropDetails( + public DropTargetDetails translateDropTargetDetails( Map<String, Object> clientVariables); }
\ No newline at end of file diff --git a/src/com/vaadin/event/dd/DropTargetDetails.java b/src/com/vaadin/event/dd/DropTargetDetails.java index 6b8f124535..4f5428b29d 100644 --- a/src/com/vaadin/event/dd/DropTargetDetails.java +++ b/src/com/vaadin/event/dd/DropTargetDetails.java @@ -2,6 +2,12 @@ package com.vaadin.event.dd; import java.io.Serializable; +/** + * TODO Javadoc + * + * @since 6.3 + * + */ public interface DropTargetDetails extends Serializable { public Object getData(String key); diff --git a/src/com/vaadin/event/dd/DropTargetDetailsImpl.java b/src/com/vaadin/event/dd/DropTargetDetailsImpl.java index 3046f03b88..8a607395c0 100644 --- a/src/com/vaadin/event/dd/DropTargetDetailsImpl.java +++ b/src/com/vaadin/event/dd/DropTargetDetailsImpl.java @@ -5,6 +5,12 @@ import java.util.Map; import com.vaadin.terminal.gwt.server.DragAndDropService; +/** + * TODO Javadoc + * + * @since 6.3 + * + */ public class DropTargetDetailsImpl implements DropTargetDetails { private HashMap<String, Object> data = new HashMap<String, Object>(); diff --git a/src/com/vaadin/event/dd/acceptCriteria/AcceptAll.java b/src/com/vaadin/event/dd/acceptCriteria/AcceptAll.java index 93a28a4d99..a6a6f92746 100644 --- a/src/com/vaadin/event/dd/acceptCriteria/AcceptAll.java +++ b/src/com/vaadin/event/dd/acceptCriteria/AcceptAll.java @@ -6,6 +6,12 @@ package com.vaadin.event.dd.acceptCriteria; import com.vaadin.event.dd.DragAndDropEvent; import com.vaadin.terminal.gwt.client.ui.dd.VAcceptAll; +/** + * Criterion that accepts all drops anywhere on the component. + * + * @since 6.3 + * + */ @ClientCriterion(VAcceptAll.class) public final class AcceptAll extends ClientSideCriterion { diff --git a/src/com/vaadin/event/dd/acceptCriteria/AcceptCriterion.java b/src/com/vaadin/event/dd/acceptCriteria/AcceptCriterion.java index 1029e51baa..f561bf82df 100644 --- a/src/com/vaadin/event/dd/acceptCriteria/AcceptCriterion.java +++ b/src/com/vaadin/event/dd/acceptCriteria/AcceptCriterion.java @@ -11,6 +11,12 @@ import com.vaadin.event.dd.DropHandler; import com.vaadin.terminal.PaintException; import com.vaadin.terminal.PaintTarget; +/** + * TODO Javadoc + * + * @since 6.3 + * + */ public interface AcceptCriterion extends Serializable { /** diff --git a/src/com/vaadin/event/dd/acceptCriteria/And.java b/src/com/vaadin/event/dd/acceptCriteria/And.java index 91144771f9..f70d3563b3 100644 --- a/src/com/vaadin/event/dd/acceptCriteria/And.java +++ b/src/com/vaadin/event/dd/acceptCriteria/And.java @@ -8,15 +8,15 @@ import com.vaadin.terminal.PaintException; import com.vaadin.terminal.PaintTarget; /** - * TODO consider replacing this with Union + * Criterion that joins two {@link ClientSideCriterion} together and validates + * if both sub criterion validate. + * + * @since 6.3 * */ @ClientCriterion(com.vaadin.terminal.gwt.client.ui.dd.VAnd.class) public class And extends ClientSideCriterion { - /** - * - */ - private static final long serialVersionUID = 1L; + private AcceptCriterion f1; private AcceptCriterion f2; @@ -25,20 +25,11 @@ public class And extends ClientSideCriterion { this.f2 = f2; } - // @Override - // public boolean isClientSideVerifiable() { - // boolean a1 = f1 instanceof AcceptCriterion ? (f1) - // .isClientSideVerifiable() : false; - // boolean a2 = f2 instanceof AcceptCriterion ? (f2) - // .isClientSideVerifiable() : false; - // return a1 && a2; - // } - @Override public void paintContent(PaintTarget target) throws PaintException { super.paintContent(target); - (f1).paint(target); - (f2).paint(target); + f1.paint(target); + f2.paint(target); } public boolean accepts(DragAndDropEvent dragEvent) { diff --git a/src/com/vaadin/event/dd/acceptCriteria/ClientCriterion.java b/src/com/vaadin/event/dd/acceptCriteria/ClientCriterion.java index e5cfea6c9c..1d2d31750e 100644 --- a/src/com/vaadin/event/dd/acceptCriteria/ClientCriterion.java +++ b/src/com/vaadin/event/dd/acceptCriteria/ClientCriterion.java @@ -10,7 +10,7 @@ import com.vaadin.terminal.gwt.client.ui.dd.VAcceptCriterion; /** * TODO * - * @since 6.2 + * @since 6.3 */ @Retention(RetentionPolicy.RUNTIME) @Target(ElementType.TYPE) diff --git a/src/com/vaadin/event/dd/acceptCriteria/ClientSideCriterion.java b/src/com/vaadin/event/dd/acceptCriteria/ClientSideCriterion.java index 79b87b55df..228a1a8316 100644 --- a/src/com/vaadin/event/dd/acceptCriteria/ClientSideCriterion.java +++ b/src/com/vaadin/event/dd/acceptCriteria/ClientSideCriterion.java @@ -5,34 +5,46 @@ import java.io.Serializable; import com.vaadin.terminal.PaintException; import com.vaadin.terminal.PaintTarget; +/** + * Parent class for criteria that can be completely validated on client side. + * All classes that provide criteria that can be completely validated on client + * side should extend this class. + * + * @since 6.3 + */ public abstract class ClientSideCriterion implements Serializable, - AcceptCriterion { + AcceptCriterion { - /** + /* + * All criteria that extend this must be completely validatable on client + * side. * + * (non-Javadoc) + * + * @see + * com.vaadin.event.dd.acceptCriteria.AcceptCriterion#isClientSideVerifiable + * () */ - private static final long serialVersionUID = 1L; - - public final boolean isClientSideVerifiable() { - return true; - } - - public void paint(PaintTarget target) throws PaintException { - target.startTag("-ac"); - target.addAttribute("name", getIdentifier()); - paintContent(target); - target.endTag("-ac"); - } - - public void paintContent(PaintTarget target) throws PaintException { - } - - protected String getIdentifier() { - return getClass().getCanonicalName(); - } - - public final void paintResponse(PaintTarget target) throws PaintException { - // NOP, nothing to do as this is client side verified criterion - } + public final boolean isClientSideVerifiable() { + return true; + } + + public void paint(PaintTarget target) throws PaintException { + target.startTag("-ac"); + target.addAttribute("name", getIdentifier()); + paintContent(target); + target.endTag("-ac"); + } + + protected void paintContent(PaintTarget target) throws PaintException { + } + + protected String getIdentifier() { + return getClass().getCanonicalName(); + } + + public final void paintResponse(PaintTarget target) throws PaintException { + // NOP, nothing to do as this is client side verified criterion + } } diff --git a/src/com/vaadin/event/dd/acceptCriteria/ContainsDataFlawor.java b/src/com/vaadin/event/dd/acceptCriteria/ContainsDataFlavor.java index 536de5e4fe..0c9c2f0181 100644 --- a/src/com/vaadin/event/dd/acceptCriteria/ContainsDataFlawor.java +++ b/src/com/vaadin/event/dd/acceptCriteria/ContainsDataFlavor.java @@ -6,12 +6,18 @@ package com.vaadin.event.dd.acceptCriteria; import com.vaadin.event.dd.DragAndDropEvent; import com.vaadin.terminal.PaintException; import com.vaadin.terminal.PaintTarget; -import com.vaadin.terminal.gwt.client.ui.dd.VContainsDataFlawor; +import com.vaadin.terminal.gwt.client.ui.dd.VContainsDataFlavor; -@ClientCriterion(VContainsDataFlawor.class) -public final class ContainsDataFlawor extends ClientSideCriterion { +/** + * TODO Javadoc! + * + * @since 6.3 + * + */ +@ClientCriterion(VContainsDataFlavor.class) +public final class ContainsDataFlavor extends ClientSideCriterion { - private String dataFlaworId; + private String dataFlavorId; /** * TODO should support basic UIDL data types @@ -19,18 +25,18 @@ public final class ContainsDataFlawor extends ClientSideCriterion { * @param dataFlawor * @param value */ - public ContainsDataFlawor(String dataFlawor) { - dataFlaworId = dataFlawor; + public ContainsDataFlavor(String dataFlawor) { + dataFlavorId = dataFlawor; } @Override public void paintContent(PaintTarget target) throws PaintException { super.paintContent(target); - target.addAttribute("p", dataFlaworId); + target.addAttribute("p", dataFlavorId); } public boolean accepts(DragAndDropEvent dragEvent) { - return dragEvent.getTransferable().getDataFlawors().contains( - dataFlaworId); + return dragEvent.getTransferable().getDataFlavors().contains( + dataFlavorId); } }
\ No newline at end of file diff --git a/src/com/vaadin/event/dd/acceptCriteria/DropDetailEquals.java b/src/com/vaadin/event/dd/acceptCriteria/DropTargetDetailEquals.java index a7852a6c82..fb075756a0 100644 --- a/src/com/vaadin/event/dd/acceptCriteria/DropDetailEquals.java +++ b/src/com/vaadin/event/dd/acceptCriteria/DropTargetDetailEquals.java @@ -8,8 +8,15 @@ import com.vaadin.terminal.PaintException; import com.vaadin.terminal.PaintTarget; import com.vaadin.terminal.gwt.client.ui.dd.VDropDetailEquals; +/** + * Criteria for checking if drop target details contain the specific property + * with the specific value. + * + * @since 6.3 + * + */ @ClientCriterion(VDropDetailEquals.class) -public final class DropDetailEquals extends ClientSideCriterion { +public final class DropTargetDetailEquals extends ClientSideCriterion { private String propertyName; private String value; @@ -20,7 +27,7 @@ public final class DropDetailEquals extends ClientSideCriterion { * @param propertyName * @param value */ - public DropDetailEquals(String propertyName, String value) { + public DropTargetDetailEquals(String propertyName, String value) { this.propertyName = propertyName; this.value = value; } @@ -33,7 +40,7 @@ public final class DropDetailEquals extends ClientSideCriterion { } public boolean accepts(DragAndDropEvent dragEvent) { - Object data = dragEvent.getDropTargetData().getData(propertyName); + Object data = dragEvent.getDropTargetDetails().getData(propertyName); return value.equals(data); } }
\ No newline at end of file diff --git a/src/com/vaadin/event/dd/acceptCriteria/IsDatabound.java b/src/com/vaadin/event/dd/acceptCriteria/IsDataBound.java index 10ac493bf3..c3f5353fa7 100644 --- a/src/com/vaadin/event/dd/acceptCriteria/IsDatabound.java +++ b/src/com/vaadin/event/dd/acceptCriteria/IsDataBound.java @@ -7,14 +7,20 @@ import com.vaadin.event.DataBoundTransferable; import com.vaadin.event.dd.DragAndDropEvent; import com.vaadin.terminal.gwt.client.ui.dd.VDataBound; +/** + * TODO Javadoc + * + * @since 6.3 + * + */ @ClientCriterion(VDataBound.class) -public final class IsDatabound extends ClientSideCriterion { - private static IsDatabound singleton = new IsDatabound(); +public final class IsDataBound extends ClientSideCriterion { + private static IsDataBound singleton = new IsDataBound(); - private IsDatabound() { + private IsDataBound() { } - public static IsDatabound get() { + public static IsDataBound get() { return singleton; } diff --git a/src/com/vaadin/event/dd/acceptCriteria/ComponentFilter.java b/src/com/vaadin/event/dd/acceptCriteria/IsDragSource.java index 2da81d64bd..f1b4d420a4 100644 --- a/src/com/vaadin/event/dd/acceptCriteria/ComponentFilter.java +++ b/src/com/vaadin/event/dd/acceptCriteria/IsDragSource.java @@ -7,14 +7,21 @@ import com.vaadin.event.TransferableImpl; import com.vaadin.event.dd.DragAndDropEvent; import com.vaadin.terminal.PaintException; import com.vaadin.terminal.PaintTarget; -import com.vaadin.terminal.gwt.client.ui.dd.VComponentFilter; +import com.vaadin.terminal.gwt.client.ui.dd.VIsDragSource; import com.vaadin.ui.Component; -@ClientCriterion(VComponentFilter.class) -public class ComponentFilter extends ClientSideCriterion { +/** + * Client side criteria that checks if the drag source is one of the given + * components. + * + * @since 6.3 + */ +@ClientCriterion(VIsDragSource.class) +public class IsDragSource extends ClientSideCriterion { + private Component[] component; - public ComponentFilter(Component... component) { + public IsDragSource(Component... component) { this.component = component; } diff --git a/src/com/vaadin/event/dd/acceptCriteria/SourceIsSameAsTarget.java b/src/com/vaadin/event/dd/acceptCriteria/IsSameSourceAndTarget.java index 778088a304..2172172091 100644 --- a/src/com/vaadin/event/dd/acceptCriteria/SourceIsSameAsTarget.java +++ b/src/com/vaadin/event/dd/acceptCriteria/IsSameSourceAndTarget.java @@ -9,14 +9,20 @@ import com.vaadin.event.dd.DropTarget; import com.vaadin.terminal.gwt.client.ui.dd.VSourceIsSameAsTarget; import com.vaadin.ui.Component; +/** + * TODO Javadoc + * + * @since 6.3 + * + */ @ClientCriterion(VSourceIsSameAsTarget.class) -public class SourceIsSameAsTarget extends ClientSideCriterion { +public class IsSameSourceAndTarget extends ClientSideCriterion { public boolean accepts(DragAndDropEvent dragEvent) { if (dragEvent.getTransferable() instanceof TransferableImpl) { Component sourceComponent = ((TransferableImpl) dragEvent .getTransferable()).getSourceComponent(); - DropTarget target = dragEvent.getDropTargetData().getTarget(); + DropTarget target = dragEvent.getDropTargetDetails().getTarget(); return sourceComponent == target; } diff --git a/src/com/vaadin/event/dd/acceptCriteria/Not.java b/src/com/vaadin/event/dd/acceptCriteria/Not.java index 72c1f5e629..12cb932c65 100644 --- a/src/com/vaadin/event/dd/acceptCriteria/Not.java +++ b/src/com/vaadin/event/dd/acceptCriteria/Not.java @@ -8,6 +8,12 @@ import com.vaadin.terminal.PaintException; import com.vaadin.terminal.PaintTarget; import com.vaadin.terminal.gwt.client.ui.dd.VNot; +/** + * TODO Javadoc + * + * @since 6.3 + * + */ @ClientCriterion(VNot.class) public class Not extends ClientSideCriterion { diff --git a/src/com/vaadin/event/dd/acceptCriteria/Or.java b/src/com/vaadin/event/dd/acceptCriteria/Or.java index 60b7152338..676ea5f5aa 100644 --- a/src/com/vaadin/event/dd/acceptCriteria/Or.java +++ b/src/com/vaadin/event/dd/acceptCriteria/Or.java @@ -9,7 +9,9 @@ import com.vaadin.terminal.PaintTarget; import com.vaadin.terminal.gwt.client.ui.dd.VOr; /** - * TODO consider replacing this with intersection + * TODO Javadoc + * + * @since 6.3 * */ @ClientCriterion(VOr.class) diff --git a/src/com/vaadin/event/dd/acceptCriteria/OverTreeNode.java b/src/com/vaadin/event/dd/acceptCriteria/OverTreeNode.java deleted file mode 100644 index 9eeed0b617..0000000000 --- a/src/com/vaadin/event/dd/acceptCriteria/OverTreeNode.java +++ /dev/null @@ -1,41 +0,0 @@ -/** - * - */ -package com.vaadin.event.dd.acceptCriteria; - -import com.vaadin.event.dd.DragAndDropEvent; -import com.vaadin.terminal.gwt.client.ui.dd.VOverTreeNode; -import com.vaadin.ui.Tree; -import com.vaadin.ui.Tree.Location; -import com.vaadin.ui.Tree.TreeDropDetails; - -/** - * Accepts transferable only on tree Node (middle of the node + can has child) - * - * TODO relocate close to {@link Tree} as this is tree specifif - * - */ -@ClientCriterion(VOverTreeNode.class) -public class OverTreeNode extends ClientSideCriterion { - - private static final long serialVersionUID = 1L; - - public boolean accepts(DragAndDropEvent dragEvent) { - try { - // must be over tree node and in the middle of it (not top or bottom - // part) - TreeDropDetails eventDetails = (TreeDropDetails) dragEvent - .getDropTargetData(); - - Object itemIdOver = eventDetails.getItemIdOver(); - if (!eventDetails.getTarget().areChildrenAllowed(itemIdOver)) { - return false; - } - - return eventDetails.getDropLocation() == Location.MIDDLE; - } catch (Exception e) { - return false; - } - } - -}
\ No newline at end of file diff --git a/src/com/vaadin/event/dd/acceptCriteria/ServerSideCriterion.java b/src/com/vaadin/event/dd/acceptCriteria/ServerSideCriterion.java index 382af29237..0acefab8aa 100644 --- a/src/com/vaadin/event/dd/acceptCriteria/ServerSideCriterion.java +++ b/src/com/vaadin/event/dd/acceptCriteria/ServerSideCriterion.java @@ -6,15 +6,16 @@ import com.vaadin.terminal.PaintException; import com.vaadin.terminal.PaintTarget; import com.vaadin.terminal.gwt.client.ui.dd.VServerAccept; +/** + * TODO Javadoc + * + * @since 6.3 + * + */ @ClientCriterion(VServerAccept.class) public abstract class ServerSideCriterion implements Serializable, AcceptCriterion { - /** - * - */ - private static final long serialVersionUID = 1L; - public final boolean isClientSideVerifiable() { return false; } diff --git a/src/com/vaadin/terminal/gwt/client/ui/dd/VContainsDataFlawor.java b/src/com/vaadin/terminal/gwt/client/ui/dd/VContainsDataFlavor.java index 0e16515bc7..a1bda815cd 100644 --- a/src/com/vaadin/terminal/gwt/client/ui/dd/VContainsDataFlawor.java +++ b/src/com/vaadin/terminal/gwt/client/ui/dd/VContainsDataFlavor.java @@ -5,11 +5,11 @@ package com.vaadin.terminal.gwt.client.ui.dd; import com.vaadin.terminal.gwt.client.UIDL; -final public class VContainsDataFlawor extends VAcceptCriterion { +final public class VContainsDataFlavor extends VAcceptCriterion { @Override public boolean validates(VDragEvent drag, UIDL configuration) { String name = configuration.getStringAttribute("p"); - return drag.getTransferable().getDataFlawors().contains(name); + return drag.getTransferable().getDataFlavors().contains(name); } }
\ No newline at end of file diff --git a/src/com/vaadin/terminal/gwt/client/ui/dd/VComponentFilter.java b/src/com/vaadin/terminal/gwt/client/ui/dd/VIsDragSource.java index 6c3216bbc3..5c98f736fe 100644 --- a/src/com/vaadin/terminal/gwt/client/ui/dd/VComponentFilter.java +++ b/src/com/vaadin/terminal/gwt/client/ui/dd/VIsDragSource.java @@ -1,12 +1,14 @@ -/** - * - */ package com.vaadin.terminal.gwt.client.ui.dd; import com.vaadin.terminal.gwt.client.Paintable; import com.vaadin.terminal.gwt.client.UIDL; -final public class VComponentFilter extends VAcceptCriterion { +/** + * TODO Javadoc! + * + * @since 6.3 + */ +final public class VIsDragSource extends VAcceptCriterion { @Override public boolean validates(VDragEvent drag, UIDL configuration) { diff --git a/src/com/vaadin/terminal/gwt/client/ui/dd/VTransferable.java b/src/com/vaadin/terminal/gwt/client/ui/dd/VTransferable.java index e810fa6cea..c341ae4115 100644 --- a/src/com/vaadin/terminal/gwt/client/ui/dd/VTransferable.java +++ b/src/com/vaadin/terminal/gwt/client/ui/dd/VTransferable.java @@ -50,7 +50,7 @@ public class VTransferable { variables.put(dataFlawor, value); } - public Collection<String> getDataFlawors() { + public Collection<String> getDataFlavors() { return variables.keySet(); } diff --git a/src/com/vaadin/terminal/gwt/server/DragAndDropService.java b/src/com/vaadin/terminal/gwt/server/DragAndDropService.java index f88903bdee..473140ed23 100644 --- a/src/com/vaadin/terminal/gwt/server/DragAndDropService.java +++ b/src/com/vaadin/terminal/gwt/server/DragAndDropService.java @@ -141,7 +141,7 @@ public class DragAndDropService implements VariableOwner { .get("evt"); DropTargetDetails dropData = dropTarget - .translateDragDropDetails(rawDragDropDetails); + .translateDropTargetDetails(rawDragDropDetails); if (dropData == null) { // Create a default DragDropDetails with all the raw variables diff --git a/src/com/vaadin/ui/AbstractSelect.java b/src/com/vaadin/ui/AbstractSelect.java index 9a6917331f..6b4136fd4e 100644 --- a/src/com/vaadin/ui/AbstractSelect.java +++ b/src/com/vaadin/ui/AbstractSelect.java @@ -20,7 +20,6 @@ import com.vaadin.data.Item; import com.vaadin.data.Property; import com.vaadin.data.util.IndexedContainer; import com.vaadin.event.DataBoundTransferable; -import com.vaadin.event.Transferable; import com.vaadin.event.dd.DragAndDropEvent; import com.vaadin.event.dd.DropTargetDetailsImpl; import com.vaadin.event.dd.acceptCriteria.ClientCriterion; @@ -1691,24 +1690,33 @@ public abstract class AbstractSelect extends AbstractField implements } /** - * Criterion for selects that support drop (Tree and Table). With this - * criterion drop is accepted on given identifier or set of identifiers. + * Criterion which accepts a drop only if the drop target is (one of) the + * given item identifier(s). Meaningful only for drop targets that extends + * AbstractSelect. + * + * @since 6.3 */ @ClientCriterion(VIsOverId.class) - public static class IsOverId extends AbstractItemSetCriterion { + public static class DropTargetItemId extends AbstractItemSetCriterion { - public IsOverId(AbstractSelect select, Object... itemId) { + public DropTargetItemId(AbstractSelect select, Object... itemId) { super(select, itemId); } public boolean accepts(DragAndDropEvent dragEvent) { - AbstractSelectDropDetails dropTargetData = (AbstractSelectDropDetails) dragEvent - .getDropTargetData(); + AbstractSelectDropTargetDetails dropTargetData = (AbstractSelectDropTargetDetails) dragEvent + .getDropTargetDetails(); return itemIds.contains(dropTargetData.getItemIdOver()); } } + /** + * TODO Javadoc! + * + * @since 6.3 + * + */ private static abstract class AbstractItemSetCriterion extends ClientSideCriterion { protected final Collection<Object> itemIds = new HashSet<Object>(); @@ -1738,13 +1746,17 @@ public abstract class AbstractSelect extends AbstractField implements } /** - * Criterion for selects that support drop (Tree and Table). With this - * criterion drop is accepted only if {@link Transferable} (from this - * {@link AbstractSelect}) contains given item identifier or identifiers. + * Criterion which accepts a drop only if the transferable contains the + * given item identifier(s). The item ids relate to the drag source + * (AbstractSelect). + * + * @since 6.3 */ @ClientCriterion(VItemIdIs.class) - public static class ItemIdIs extends AbstractItemSetCriterion { - public ItemIdIs(AbstractSelect select, Object... itemId) { + public static class TransferableContainsItemId extends + AbstractItemSetCriterion { + public TransferableContainsItemId(AbstractSelect select, + Object... itemId) { super(select, itemId); } @@ -1756,11 +1768,20 @@ public abstract class AbstractSelect extends AbstractField implements } - public class AbstractSelectDropDetails extends DropTargetDetailsImpl { + /** + * TODO Javadoc! + * + * @since 6.3 + */ + public class AbstractSelectDropTargetDetails extends DropTargetDetailsImpl { private Object idOver; - AbstractSelectDropDetails(Map<String, Object> rawVariables) { + /** + * TODO Javadoc! + * + */ + AbstractSelectDropTargetDetails(Map<String, Object> rawVariables) { super(rawVariables); // eagar fetch itemid, mapper may be emptied String keyover = (String) getData("itemIdOver"); @@ -1769,10 +1790,19 @@ public abstract class AbstractSelect extends AbstractField implements } } + /** + * TODO Javadoc! + * + */ public Object getItemIdOver() { return idOver; } + /** + * TODO Javadoc! + * + * @since 6.3 + */ public Location getDropLocation() { String s = (String) getData("detail"); if ("TOP".equals(s)) { diff --git a/src/com/vaadin/ui/DragAndDropWrapper.java b/src/com/vaadin/ui/DragAndDropWrapper.java index 232c65f9c6..53eeacadd3 100644 --- a/src/com/vaadin/ui/DragAndDropWrapper.java +++ b/src/com/vaadin/ui/DragAndDropWrapper.java @@ -128,7 +128,7 @@ public class DragAndDropWrapper extends CustomComponent implements DropTarget, requestRepaint(); } - public DropTargetDetails translateDragDropDetails( + public DropTargetDetails translateDropTargetDetails( Map<String, Object> clientVariables) { return new WrapperDropDetails(clientVariables); } diff --git a/src/com/vaadin/ui/DragDropPane.java b/src/com/vaadin/ui/DragDropPane.java index f925fda221..22a1eedc72 100644 --- a/src/com/vaadin/ui/DragDropPane.java +++ b/src/com/vaadin/ui/DragDropPane.java @@ -74,10 +74,10 @@ public class DragDropPane extends AbsoluteLayout implements DropTarget { public static class ImportPrettyMuchAnything implements DropHandler { public void drop(DragAndDropEvent event) { - DragDropPane pane = (DragDropPane) event.getDropTargetData() + DragDropPane pane = (DragDropPane) event.getDropTargetDetails() .getTarget(); - DragEventDetails ed = (DragEventDetails) event.getDropTargetData(); + DragEventDetails ed = (DragEventDetails) event.getDropTargetDetails(); Transferable transferable = event.getTransferable(); if (transferable instanceof TransferableImpl) { TransferableImpl ctr = (TransferableImpl) transferable; @@ -191,7 +191,7 @@ public class DragDropPane extends AbsoluteLayout implements DropTarget { } - public DropTargetDetails translateDragDropDetails( + public DropTargetDetails translateDropTargetDetails( Map<String, Object> clientVariables) { return new DragEventDetails(clientVariables); } diff --git a/src/com/vaadin/ui/Table.java b/src/com/vaadin/ui/Table.java index 0db68525f8..9246067541 100644 --- a/src/com/vaadin/ui/Table.java +++ b/src/com/vaadin/ui/Table.java @@ -3364,8 +3364,8 @@ public class Table extends AbstractSelect implements Action.Container, this.dropHandler = dropHandler; } - public AbstractSelectDropDetails translateDragDropDetails( + public AbstractSelectDropTargetDetails translateDropTargetDetails( Map<String, Object> clientVariables) { - return new AbstractSelectDropDetails(clientVariables); + return new AbstractSelectDropTargetDetails(clientVariables); } } diff --git a/src/com/vaadin/ui/Tree.java b/src/com/vaadin/ui/Tree.java index 5e0e66fae5..56c2cac421 100644 --- a/src/com/vaadin/ui/Tree.java +++ b/src/com/vaadin/ui/Tree.java @@ -33,6 +33,7 @@ import com.vaadin.event.dd.DragSource; import com.vaadin.event.dd.DropHandler; import com.vaadin.event.dd.DropTarget; import com.vaadin.event.dd.acceptCriteria.ClientCriterion; +import com.vaadin.event.dd.acceptCriteria.ClientSideCriterion; import com.vaadin.event.dd.acceptCriteria.ServerSideCriterion; import com.vaadin.terminal.KeyMapper; import com.vaadin.terminal.PaintException; @@ -41,6 +42,7 @@ import com.vaadin.terminal.Resource; import com.vaadin.terminal.gwt.client.MouseEventDetails; import com.vaadin.terminal.gwt.client.ui.VTree; import com.vaadin.terminal.gwt.client.ui.dd.VLazyInitItemIdentifiers; +import com.vaadin.terminal.gwt.client.ui.dd.VOverTreeNode; /** * Tree component. A Tree can be used to select an item (or multiple items) from @@ -121,35 +123,6 @@ public class Tree extends AbstractSelect implements Container.Hierarchical, } - class TreeTransferable extends DataBoundTransferable { - - public TreeTransferable(Component sourceComponent, - Map<String, Object> rawVariables) { - super(sourceComponent, rawVariables); - } - - @Override - public Object getItemId() { - return getData("itemId"); - } - - @Override - public Object getPropertyId() { - return getItemCaptionPropertyId(); - } - } - - public Transferable getTransferable(Map<String, Object> payload) { - TreeTransferable transferable = new TreeTransferable(this, payload); - // updating drag source variables - Object object = payload.get("itemId"); - if (object != null) { - transferable.setData("itemId", itemIdMapper.get((String) object)); - } - - return transferable; - } - /* Tree constructors */ /** @@ -1146,9 +1119,14 @@ public class Tree extends AbstractSelect implements Container.Hierarchical, TOP, BOTTOM, MIDDLE; } - public class TreeDropDetails extends AbstractSelectDropDetails { + /** + * TODO Javadoc! + * + * @since 6.3 + */ + public class TreeDropTargetDetails extends AbstractSelectDropTargetDetails { - TreeDropDetails(Map<String, Object> rawVariables) { + TreeDropTargetDetails(Map<String, Object> rawVariables) { super(rawVariables); } @@ -1159,9 +1137,14 @@ public class Tree extends AbstractSelect implements Container.Hierarchical, } - public TreeDropDetails translateDragDropDetails( + /** + * TODO Javadoc! + * + * @since 6.3 + */ + public TreeDropTargetDetails translateDropTargetDetails( Map<String, Object> clientVariables) { - return new TreeDropDetails(clientVariables); + return new TreeDropTargetDetails(clientVariables); } /** @@ -1175,6 +1158,45 @@ public class Tree extends AbstractSelect implements Container.Hierarchical, } /** + * TODO Javadoc! + * + * @since 6.3 + */ + public class TreeTransferable extends DataBoundTransferable { + + public TreeTransferable(Component sourceComponent, + Map<String, Object> rawVariables) { + super(sourceComponent, rawVariables); + } + + @Override + public Object getItemId() { + return getData("itemId"); + } + + @Override + public Object getPropertyId() { + return getItemCaptionPropertyId(); + } + } + + /* + * (non-Javadoc) + * + * @see com.vaadin.event.dd.DragSource#getTransferable(java.util.Map) + */ + public Transferable getTransferable(Map<String, Object> payload) { + TreeTransferable transferable = new TreeTransferable(this, payload); + // updating drag source variables + Object object = payload.get("itemId"); + if (object != null) { + transferable.setData("itemId", itemIdMapper.get((String) object)); + } + + return transferable; + } + + /** * An example of lazy initializing criterion. Initially pretty much no data * is sent to client, on first accepts set (per drag request) the client * side data structure is initialized and no subsequent requests requests @@ -1209,9 +1231,9 @@ public class Tree extends AbstractSelect implements Container.Hierarchical, * .event.dd.DragAndDropEvent) */ public boolean accepts(DragAndDropEvent dragEvent) { - AbstractSelectDropDetails dropTargetData = (AbstractSelectDropDetails) dragEvent - .getDropTargetData(); - tree = (Tree) dragEvent.getDropTargetData().getTarget(); + AbstractSelectDropTargetDetails dropTargetData = (AbstractSelectDropTargetDetails) dragEvent + .getDropTargetDetails(); + tree = (Tree) dragEvent.getDropTargetDetails().getTarget(); allowedItemIds = getAllowedItemIds(dragEvent, tree); return allowedItemIds.contains(dropTargetData.getItemIdOver()); @@ -1243,4 +1265,34 @@ public class Tree extends AbstractSelect implements Container.Hierarchical, } + /** + * Accepts transferable only on tree Node (middle of the node + can has + * child) + * + * @since 6.3 + */ + @ClientCriterion(VOverTreeNode.class) + public static class OverTreeNode extends ClientSideCriterion { + + private static final long serialVersionUID = 1L; + + public boolean accepts(DragAndDropEvent dragEvent) { + try { + // must be over tree node and in the middle of it (not top or + // bottom part) + TreeDropTargetDetails eventDetails = (TreeDropTargetDetails) dragEvent + .getDropTargetDetails(); + + Object itemIdOver = eventDetails.getItemIdOver(); + if (!eventDetails.getTarget().areChildrenAllowed(itemIdOver)) { + return false; + } + + return eventDetails.getDropLocation() == Location.MIDDLE; + } catch (Exception e) { + return false; + } + } + + } } |