diff options
author | Artur Signell <artur@vaadin.com> | 2012-08-13 18:34:33 +0300 |
---|---|---|
committer | Artur Signell <artur@vaadin.com> | 2012-08-13 19:18:33 +0300 |
commit | e85d933b25cc3c5cc85eb7eb4b13b950fd8e1569 (patch) | |
tree | 9ab6f13f7188cab44bbd979b1cf620f15328a03f /src/com/vaadin/event/dd | |
parent | 14dd4d0b28c76eb994b181a4570f3adec53342e6 (diff) | |
download | vaadin-framework-e85d933b25cc3c5cc85eb7eb4b13b950fd8e1569.tar.gz vaadin-framework-e85d933b25cc3c5cc85eb7eb4b13b950fd8e1569.zip |
Moved server files to a server src folder (#9299)
Diffstat (limited to 'src/com/vaadin/event/dd')
17 files changed, 0 insertions, 905 deletions
diff --git a/src/com/vaadin/event/dd/DragAndDropEvent.java b/src/com/vaadin/event/dd/DragAndDropEvent.java deleted file mode 100644 index b920d43469..0000000000 --- a/src/com/vaadin/event/dd/DragAndDropEvent.java +++ /dev/null @@ -1,50 +0,0 @@ -/* -@VaadinApache2LicenseForJavaFiles@ - */ -package com.vaadin.event.dd; - -import java.io.Serializable; - -import com.vaadin.event.Transferable; -import com.vaadin.event.dd.acceptcriteria.AcceptCriterion; - -/** - * DragAndDropEvent wraps information related to drag and drop operation. It is - * passed by terminal implementation for - * {@link DropHandler#drop(DragAndDropEvent)} and - * {@link AcceptCriterion#accept(DragAndDropEvent)} methods. - * <p> - * DragAndDropEvent instances contains both the dragged data in - * {@link Transferable} (generated by {@link DragSource} and details about the - * current drop event in {@link TargetDetails} (generated by {@link DropTarget}. - * - * @since 6.3 - * - */ -public class DragAndDropEvent implements Serializable { - private Transferable transferable; - private TargetDetails dropTargetDetails; - - public DragAndDropEvent(Transferable transferable, - TargetDetails dropTargetDetails) { - this.transferable = transferable; - this.dropTargetDetails = dropTargetDetails; - } - - /** - * @return the Transferable instance representing the data dragged in this - * drag and drop event - */ - public Transferable getTransferable() { - return transferable; - } - - /** - * @return the TargetDetails containing drop target related details of drag - * and drop operation - */ - public TargetDetails getTargetDetails() { - return dropTargetDetails; - } - -} diff --git a/src/com/vaadin/event/dd/DragSource.java b/src/com/vaadin/event/dd/DragSource.java deleted file mode 100644 index 4daf0dcb18..0000000000 --- a/src/com/vaadin/event/dd/DragSource.java +++ /dev/null @@ -1,52 +0,0 @@ -/* -@VaadinApache2LicenseForJavaFiles@ - */ -package com.vaadin.event.dd; - -import java.util.Map; - -import com.vaadin.event.Transferable; -import com.vaadin.event.dd.acceptcriteria.AcceptCriterion; -import com.vaadin.ui.Component; -import com.vaadin.ui.Tree; - -/** - * DragSource is a {@link Component} that builds a {@link Transferable} for a - * drag and drop operation. - * <p> - * In Vaadin the drag and drop operation practically starts from client side - * component. The client side component initially defines the data that will be - * present in {@link Transferable} object on server side. If the server side - * counterpart of the component implements this interface, terminal - * implementation lets it create the {@link Transferable} instance from the raw - * client side "seed data". This way server side implementation may translate or - * extend the data that will be available for {@link DropHandler}. - * - * @since 6.3 - * - */ -public interface DragSource extends Component { - - /** - * DragSource may convert data added by client side component to meaningful - * values for server side developer or add other data based on it. - * - * <p> - * For example Tree converts item identifiers to generated string keys for - * the client side. Vaadin developer don't and can't know anything about - * these generated keys, only about item identifiers. When tree node is - * dragged client puts that key to {@link Transferable}s client side - * counterpart. In {@link Tree#getTransferable(Map)} the key is converted - * back to item identifier that the server side developer can use. - * <p> - * - * @since 6.3 - * @param rawVariables - * the data that client side initially included in - * {@link Transferable}s client side counterpart. - * @return the {@link Transferable} instance that will be passed to - * {@link DropHandler} (and/or {@link AcceptCriterion}) - */ - public Transferable getTransferable(Map<String, Object> rawVariables); - -}
\ No newline at end of file diff --git a/src/com/vaadin/event/dd/DropHandler.java b/src/com/vaadin/event/dd/DropHandler.java deleted file mode 100644 index 7a15ea5b68..0000000000 --- a/src/com/vaadin/event/dd/DropHandler.java +++ /dev/null @@ -1,61 +0,0 @@ -/* -@VaadinApache2LicenseForJavaFiles@ - */ -package com.vaadin.event.dd; - -import java.io.Serializable; - -import com.vaadin.event.Transferable; -import com.vaadin.event.dd.acceptcriteria.AcceptAll; -import com.vaadin.event.dd.acceptcriteria.AcceptCriterion; -import com.vaadin.event.dd.acceptcriteria.ServerSideCriterion; - -/** - * DropHandlers contain the actual business logic for drag and drop operations. - * <p> - * The {@link #drop(DragAndDropEvent)} method is used to receive the transferred - * data and the {@link #getAcceptCriterion()} method contains the (possibly - * client side verifiable) criterion whether the dragged data will be handled at - * all. - * - * @since 6.3 - * - */ -public interface DropHandler extends Serializable { - - /** - * Drop method is called when the end user has finished the drag operation - * on a {@link DropTarget} and {@link DragAndDropEvent} has passed - * {@link AcceptCriterion} defined by {@link #getAcceptCriterion()} method. - * The actual business logic of drag and drop operation is implemented into - * this method. - * - * @param event - * the event related to this drop - */ - public void drop(DragAndDropEvent event); - - /** - * Returns the {@link AcceptCriterion} used to evaluate whether the - * {@link Transferable} will be handed over to - * {@link DropHandler#drop(DragAndDropEvent)} method. If client side can't - * verify the {@link AcceptCriterion}, the same criteria may be tested also - * prior to actual drop - during the drag operation. - * <p> - * Based on information from {@link AcceptCriterion} components may display - * some hints for the end user whether the drop will be accepted or not. - * <p> - * Vaadin contains a variety of criteria built in that can be composed to - * more complex criterion. If the build in criteria are not enough, - * developer can use a {@link ServerSideCriterion} or build own custom - * criterion with client side counterpart. - * <p> - * If developer wants to handle everything in the - * {@link #drop(DragAndDropEvent)} method, {@link AcceptAll} instance can be - * returned. - * - * @return the {@link AcceptCriterion} - */ - public AcceptCriterion getAcceptCriterion(); - -} diff --git a/src/com/vaadin/event/dd/DropTarget.java b/src/com/vaadin/event/dd/DropTarget.java deleted file mode 100644 index c18aa60b19..0000000000 --- a/src/com/vaadin/event/dd/DropTarget.java +++ /dev/null @@ -1,42 +0,0 @@ -/* -@VaadinApache2LicenseForJavaFiles@ - */ -package com.vaadin.event.dd; - -import java.util.Map; - -import com.vaadin.ui.Component; - -/** - * DropTarget is an interface for components supporting drop operations. A - * component that wants to receive drop events should implement this interface - * and provide a {@link DropHandler} which will handle the actual drop event. - * - * @since 6.3 - */ -public interface DropTarget extends Component { - - /** - * @return the drop hanler that will receive the dragged data or null if - * drops are not currently accepted - */ - public DropHandler getDropHandler(); - - /** - * Called before the {@link DragAndDropEvent} is passed to - * {@link DropHandler}. Implementation may for example translate the drop - * target details provided by the client side (drop target) to meaningful - * server side values. If null is returned the terminal implementation will - * automatically create a {@link TargetDetails} with raw client side data. - * - * @see DragSource#getTransferable(Map) - * - * @param clientVariables - * data passed from the DropTargets client side counterpart. - * @return A DropTargetDetails object with the translated data or null to - * use a default implementation. - */ - public TargetDetails translateDropTargetDetails( - Map<String, Object> clientVariables); - -}
\ No newline at end of file diff --git a/src/com/vaadin/event/dd/TargetDetails.java b/src/com/vaadin/event/dd/TargetDetails.java deleted file mode 100644 index a352fbec60..0000000000 --- a/src/com/vaadin/event/dd/TargetDetails.java +++ /dev/null @@ -1,37 +0,0 @@ -/* -@VaadinApache2LicenseForJavaFiles@ - */ -package com.vaadin.event.dd; - -import java.io.Serializable; - -import com.vaadin.ui.Tree.TreeTargetDetails; - -/** - * TargetDetails wraps drop target related information about - * {@link DragAndDropEvent}. - * <p> - * When a TargetDetails object is used in {@link DropHandler} it is often - * preferable to cast the TargetDetails to an implementation provided by - * DropTarget like {@link TreeTargetDetails}. They often provide a better typed, - * drop target specific API. - * - * @since 6.3 - * - */ -public interface TargetDetails extends Serializable { - - /** - * Gets target data associated with the given string key - * - * @param key - * @return The data associated with the key - */ - public Object getData(String key); - - /** - * @return the drop target on which the {@link DragAndDropEvent} happened. - */ - public DropTarget getTarget(); - -} diff --git a/src/com/vaadin/event/dd/TargetDetailsImpl.java b/src/com/vaadin/event/dd/TargetDetailsImpl.java deleted file mode 100644 index 4a459777ed..0000000000 --- a/src/com/vaadin/event/dd/TargetDetailsImpl.java +++ /dev/null @@ -1,46 +0,0 @@ -/* -@VaadinApache2LicenseForJavaFiles@ - */ -package com.vaadin.event.dd; - -import java.util.HashMap; -import java.util.Map; - -/** - * A HashMap backed implementation of {@link TargetDetails} for terminal - * implementation and for extension. - * - * @since 6.3 - * - */ -@SuppressWarnings("serial") -public class TargetDetailsImpl implements TargetDetails { - - private HashMap<String, Object> data = new HashMap<String, Object>(); - private DropTarget dropTarget; - - protected TargetDetailsImpl(Map<String, Object> rawDropData) { - data.putAll(rawDropData); - } - - public TargetDetailsImpl(Map<String, Object> rawDropData, - DropTarget dropTarget) { - this(rawDropData); - this.dropTarget = dropTarget; - } - - @Override - public Object getData(String key) { - return data.get(key); - } - - public Object setData(String key, Object value) { - return data.put(key, value); - } - - @Override - public DropTarget getTarget() { - return dropTarget; - } - -}
\ No newline at end of file diff --git a/src/com/vaadin/event/dd/acceptcriteria/AcceptAll.java b/src/com/vaadin/event/dd/acceptcriteria/AcceptAll.java deleted file mode 100644 index 1457ea9df3..0000000000 --- a/src/com/vaadin/event/dd/acceptcriteria/AcceptAll.java +++ /dev/null @@ -1,36 +0,0 @@ -/* -@VaadinApache2LicenseForJavaFiles@ - */ -/** - * - */ -package com.vaadin.event.dd.acceptcriteria; - -import com.vaadin.event.dd.DragAndDropEvent; - -/** - * Criterion that accepts all drops anywhere on the component. - * <p> - * Note! Class is singleton, use {@link #get()} method to get the instance. - * - * - * @since 6.3 - * - */ -public final class AcceptAll extends ClientSideCriterion { - - private static final long serialVersionUID = 7406683402153141461L; - private static AcceptCriterion singleton = new AcceptAll(); - - private AcceptAll() { - } - - public static AcceptCriterion get() { - return singleton; - } - - @Override - public boolean accept(DragAndDropEvent dragEvent) { - return true; - } -}
\ No newline at end of file diff --git a/src/com/vaadin/event/dd/acceptcriteria/AcceptCriterion.java b/src/com/vaadin/event/dd/acceptcriteria/AcceptCriterion.java deleted file mode 100644 index c0f04d362f..0000000000 --- a/src/com/vaadin/event/dd/acceptcriteria/AcceptCriterion.java +++ /dev/null @@ -1,75 +0,0 @@ -/* -@VaadinApache2LicenseForJavaFiles@ - */ -/** - * - */ -package com.vaadin.event.dd.acceptcriteria; - -import java.io.Serializable; - -import com.vaadin.event.Transferable; -import com.vaadin.event.dd.DragAndDropEvent; -import com.vaadin.event.dd.DropHandler; -import com.vaadin.terminal.PaintException; -import com.vaadin.terminal.PaintTarget; - -/** - * Criterion that can be used create policy to accept/discard dragged content - * (presented by {@link Transferable}). - * - * The drag and drop mechanism will verify the criteria returned by - * {@link DropHandler#getAcceptCriterion()} before calling - * {@link DropHandler#drop(DragAndDropEvent)}. - * - * The criteria can be evaluated either on the client (browser - see - * {@link ClientSideCriterion}) or on the server (see - * {@link ServerSideCriterion}). If no constraints are needed, an - * {@link AcceptAll} can be used. - * - * In addition to accepting or rejecting a possible drop, criteria can provide - * additional hints for client side painting. - * - * @see DropHandler - * @see ClientSideCriterion - * @see ServerSideCriterion - * - * @since 6.3 - */ -public interface AcceptCriterion extends Serializable { - - /** - * Returns whether the criteria can be checked on the client or whether a - * server request is needed to check the criteria. - * - * This requirement may depend on the state of the criterion (e.g. logical - * operations between criteria), so this cannot be based on a marker - * interface. - */ - public boolean isClientSideVerifiable(); - - public void paint(PaintTarget target) throws PaintException; - - /** - * This needs to be implemented iff criterion does some lazy server side - * initialization. The UIDL painted in this method will be passed to client - * side drop handler implementation. Implementation can assume that - * {@link #accept(DragAndDropEvent)} is called before this method. - * - * @param target - * @throws PaintException - */ - public void paintResponse(PaintTarget target) throws PaintException; - - /** - * Validates the data in event to be appropriate for the - * {@link DropHandler#drop(DragAndDropEvent)} method. - * <p> - * Note that even if your criterion is validated on client side, you should - * always validate the data on server side too. - * - * @param dragEvent - * @return - */ - public boolean accept(DragAndDropEvent dragEvent); -}
\ No newline at end of file diff --git a/src/com/vaadin/event/dd/acceptcriteria/And.java b/src/com/vaadin/event/dd/acceptcriteria/And.java deleted file mode 100644 index 4122d67160..0000000000 --- a/src/com/vaadin/event/dd/acceptcriteria/And.java +++ /dev/null @@ -1,54 +0,0 @@ -/* -@VaadinApache2LicenseForJavaFiles@ - */ -/** - * - */ -package com.vaadin.event.dd.acceptcriteria; - -import com.vaadin.event.dd.DragAndDropEvent; -import com.vaadin.terminal.PaintException; -import com.vaadin.terminal.PaintTarget; - -/** - * A compound criterion that accepts the drag if all of its criteria accepts the - * drag. - * - * @see Or - * - * @since 6.3 - * - */ -public class And extends ClientSideCriterion { - - private static final long serialVersionUID = -5242574480825471748L; - protected ClientSideCriterion[] criteria; - - /** - * - * @param criteria - * criteria of which the And criterion will be composed - */ - public And(ClientSideCriterion... criteria) { - this.criteria = criteria; - } - - @Override - public void paintContent(PaintTarget target) throws PaintException { - super.paintContent(target); - for (ClientSideCriterion crit : criteria) { - crit.paint(target); - } - } - - @Override - public boolean accept(DragAndDropEvent dragEvent) { - for (ClientSideCriterion crit : criteria) { - if (!crit.accept(dragEvent)) { - return false; - } - } - return true; - } - -}
\ No newline at end of file diff --git a/src/com/vaadin/event/dd/acceptcriteria/ClientSideCriterion.java b/src/com/vaadin/event/dd/acceptcriteria/ClientSideCriterion.java deleted file mode 100644 index 7d2c42ecb0..0000000000 --- a/src/com/vaadin/event/dd/acceptcriteria/ClientSideCriterion.java +++ /dev/null @@ -1,61 +0,0 @@ -/* -@VaadinApache2LicenseForJavaFiles@ - */ -package com.vaadin.event.dd.acceptcriteria; - -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. - * - * It is recommended that subclasses of ClientSideCriterion re-validate the - * condition on the server side in - * {@link AcceptCriterion#accept(com.vaadin.event.dd.DragAndDropEvent)} after - * the client side validation has accepted a transfer. - * - * @since 6.3 - */ -public abstract class ClientSideCriterion implements Serializable, - AcceptCriterion { - - /* - * All criteria that extend this must be completely validatable on client - * side. - * - * (non-Javadoc) - * - * @see - * com.vaadin.event.dd.acceptCriteria.AcceptCriterion#isClientSideVerifiable - * () - */ - @Override - public final boolean isClientSideVerifiable() { - return true; - } - - @Override - 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(); - } - - @Override - 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/ContainsDataFlavor.java b/src/com/vaadin/event/dd/acceptcriteria/ContainsDataFlavor.java deleted file mode 100644 index 4c52698a4a..0000000000 --- a/src/com/vaadin/event/dd/acceptcriteria/ContainsDataFlavor.java +++ /dev/null @@ -1,53 +0,0 @@ -/* -@VaadinApache2LicenseForJavaFiles@ - */ -/** - * - */ -package com.vaadin.event.dd.acceptcriteria; - -import com.vaadin.event.Transferable; -import com.vaadin.event.dd.DragAndDropEvent; -import com.vaadin.terminal.PaintException; -import com.vaadin.terminal.PaintTarget; - -/** - * A Criterion that checks whether {@link Transferable} contains given data - * flavor. The developer might for example accept the incoming data only if it - * contains "Url" or "Text". - * - * @since 6.3 - */ -public class ContainsDataFlavor extends ClientSideCriterion { - - private String dataFlavorId; - - /** - * Constructs a new instance of {@link ContainsDataFlavor}. - * - * @param dataFlawor - * the type of data that will be checked from - * {@link Transferable} - */ - public ContainsDataFlavor(String dataFlawor) { - dataFlavorId = dataFlawor; - } - - @Override - public void paintContent(PaintTarget target) throws PaintException { - super.paintContent(target); - target.addAttribute("p", dataFlavorId); - } - - @Override - public boolean accept(DragAndDropEvent dragEvent) { - return dragEvent.getTransferable().getDataFlavors() - .contains(dataFlavorId); - } - - @Override - protected String getIdentifier() { - // extending classes use client side implementation from this class - return ContainsDataFlavor.class.getCanonicalName(); - } -}
\ No newline at end of file diff --git a/src/com/vaadin/event/dd/acceptcriteria/Not.java b/src/com/vaadin/event/dd/acceptcriteria/Not.java deleted file mode 100644 index 1ed40a324d..0000000000 --- a/src/com/vaadin/event/dd/acceptcriteria/Not.java +++ /dev/null @@ -1,39 +0,0 @@ -/* -@VaadinApache2LicenseForJavaFiles@ - */ -/** - * - */ -package com.vaadin.event.dd.acceptcriteria; - -import com.vaadin.event.dd.DragAndDropEvent; -import com.vaadin.terminal.PaintException; -import com.vaadin.terminal.PaintTarget; - -/** - * Criterion that wraps another criterion and inverts its return value. - * - * @since 6.3 - * - */ -public class Not extends ClientSideCriterion { - - private static final long serialVersionUID = 1131422338558613244L; - private AcceptCriterion acceptCriterion; - - public Not(ClientSideCriterion acceptCriterion) { - this.acceptCriterion = acceptCriterion; - } - - @Override - public void paintContent(PaintTarget target) throws PaintException { - super.paintContent(target); - acceptCriterion.paint(target); - } - - @Override - public boolean accept(DragAndDropEvent dragEvent) { - return !acceptCriterion.accept(dragEvent); - } - -}
\ No newline at end of file diff --git a/src/com/vaadin/event/dd/acceptcriteria/Or.java b/src/com/vaadin/event/dd/acceptcriteria/Or.java deleted file mode 100644 index 6ad45c54af..0000000000 --- a/src/com/vaadin/event/dd/acceptcriteria/Or.java +++ /dev/null @@ -1,52 +0,0 @@ -/* -@VaadinApache2LicenseForJavaFiles@ - */ -/** - * - */ -package com.vaadin.event.dd.acceptcriteria; - -import com.vaadin.event.dd.DragAndDropEvent; -import com.vaadin.terminal.PaintException; -import com.vaadin.terminal.PaintTarget; - -/** - * A compound criterion that accepts the drag if any of its criterion accepts - * it. - * - * @see And - * - * @since 6.3 - * - */ -public class Or extends ClientSideCriterion { - private static final long serialVersionUID = 1L; - private AcceptCriterion criteria[]; - - /** - * @param criteria - * the criteria of which the Or criteria will be composed - */ - public Or(ClientSideCriterion... criteria) { - this.criteria = criteria; - } - - @Override - public void paintContent(PaintTarget target) throws PaintException { - super.paintContent(target); - for (AcceptCriterion crit : criteria) { - crit.paint(target); - } - } - - @Override - public boolean accept(DragAndDropEvent dragEvent) { - for (AcceptCriterion crit : criteria) { - if (crit.accept(dragEvent)) { - return true; - } - } - 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 deleted file mode 100644 index 47f06d434c..0000000000 --- a/src/com/vaadin/event/dd/acceptcriteria/ServerSideCriterion.java +++ /dev/null @@ -1,57 +0,0 @@ -/* -@VaadinApache2LicenseForJavaFiles@ - */ -package com.vaadin.event.dd.acceptcriteria; - -import java.io.Serializable; - -import com.vaadin.event.Transferable; -import com.vaadin.terminal.PaintException; -import com.vaadin.terminal.PaintTarget; - -/** - * Parent class for criteria which are verified on the server side during a drag - * operation to accept/discard dragged content (presented by - * {@link Transferable}). - * <p> - * Subclasses should implement the - * {@link AcceptCriterion#accept(com.vaadin.event.dd.DragAndDropEvent)} method. - * <p> - * As all server side state can be used to make a decision, this is more - * flexible than {@link ClientSideCriterion}. However, this does require - * additional requests from the browser to the server during a drag operation. - * - * @see AcceptCriterion - * @see ClientSideCriterion - * - * @since 6.3 - */ -public abstract class ServerSideCriterion implements Serializable, - AcceptCriterion { - - private static final long serialVersionUID = 2128510128911628902L; - - @Override - public final boolean isClientSideVerifiable() { - return false; - } - - @Override - public void paint(PaintTarget target) throws PaintException { - target.startTag("-ac"); - target.addAttribute("name", getIdentifier()); - paintContent(target); - target.endTag("-ac"); - } - - public void paintContent(PaintTarget target) { - } - - @Override - public void paintResponse(PaintTarget target) throws PaintException { - } - - protected String getIdentifier() { - return ServerSideCriterion.class.getCanonicalName(); - } -} diff --git a/src/com/vaadin/event/dd/acceptcriteria/SourceIs.java b/src/com/vaadin/event/dd/acceptcriteria/SourceIs.java deleted file mode 100644 index d4fd20c952..0000000000 --- a/src/com/vaadin/event/dd/acceptcriteria/SourceIs.java +++ /dev/null @@ -1,67 +0,0 @@ -/* -@VaadinApache2LicenseForJavaFiles@ - */ -/** - * - */ -package com.vaadin.event.dd.acceptcriteria; - -import java.util.logging.Level; -import java.util.logging.Logger; - -import com.vaadin.event.TransferableImpl; -import com.vaadin.event.dd.DragAndDropEvent; -import com.vaadin.terminal.PaintException; -import com.vaadin.terminal.PaintTarget; -import com.vaadin.ui.Component; - -/** - * Client side criteria that checks if the drag source is one of the given - * components. - * - * @since 6.3 - */ -@SuppressWarnings("serial") -public class SourceIs extends ClientSideCriterion { - - private Component[] components; - - public SourceIs(Component... component) { - components = component; - } - - @Override - public void paintContent(PaintTarget target) throws PaintException { - super.paintContent(target); - int paintedComponents = 0; - for (int i = 0; i < components.length; i++) { - Component c = components[i]; - if (c.getApplication() != null) { - target.addAttribute("component" + paintedComponents++, c); - } else { - Logger.getLogger(SourceIs.class.getName()) - .log(Level.WARNING, - "SourceIs component {0} at index {1} is not attached to the component hierachy and will thus be ignored", - new Object[] { c.getClass().getName(), - Integer.valueOf(i) }); - } - } - target.addAttribute("c", paintedComponents); - } - - @Override - public boolean accept(DragAndDropEvent dragEvent) { - if (dragEvent.getTransferable() instanceof TransferableImpl) { - Component sourceComponent = ((TransferableImpl) dragEvent - .getTransferable()).getSourceComponent(); - for (Component c : components) { - if (c == sourceComponent) { - return true; - } - } - } - - return false; - } - -}
\ No newline at end of file diff --git a/src/com/vaadin/event/dd/acceptcriteria/SourceIsTarget.java b/src/com/vaadin/event/dd/acceptcriteria/SourceIsTarget.java deleted file mode 100644 index a644b858e2..0000000000 --- a/src/com/vaadin/event/dd/acceptcriteria/SourceIsTarget.java +++ /dev/null @@ -1,51 +0,0 @@ -/* -@VaadinApache2LicenseForJavaFiles@ - */ -/** - * - */ -package com.vaadin.event.dd.acceptcriteria; - -import com.vaadin.event.Transferable; -import com.vaadin.event.TransferableImpl; -import com.vaadin.event.dd.DragAndDropEvent; -import com.vaadin.event.dd.DropTarget; -import com.vaadin.ui.Component; -import com.vaadin.ui.Table; -import com.vaadin.ui.Tree; - -/** - * - * A criterion that ensures the drag source is the same as drop target. Eg. - * {@link Tree} or {@link Table} could support only re-ordering of items, but no - * {@link Transferable}s coming outside. - * <p> - * Note! Class is singleton, use {@link #get()} method to get the instance. - * - * @since 6.3 - * - */ -public class SourceIsTarget extends ClientSideCriterion { - - private static final long serialVersionUID = -451399314705532584L; - private static SourceIsTarget instance = new SourceIsTarget(); - - private SourceIsTarget() { - } - - @Override - public boolean accept(DragAndDropEvent dragEvent) { - if (dragEvent.getTransferable() instanceof TransferableImpl) { - Component sourceComponent = ((TransferableImpl) dragEvent - .getTransferable()).getSourceComponent(); - DropTarget target = dragEvent.getTargetDetails().getTarget(); - return sourceComponent == target; - } - return false; - } - - public static synchronized SourceIsTarget get() { - return instance; - } - -}
\ No newline at end of file diff --git a/src/com/vaadin/event/dd/acceptcriteria/TargetDetailIs.java b/src/com/vaadin/event/dd/acceptcriteria/TargetDetailIs.java deleted file mode 100644 index 5df8f3f618..0000000000 --- a/src/com/vaadin/event/dd/acceptcriteria/TargetDetailIs.java +++ /dev/null @@ -1,72 +0,0 @@ -/* -@VaadinApache2LicenseForJavaFiles@ - */ -/** - * - */ -package com.vaadin.event.dd.acceptcriteria; - -import com.vaadin.event.dd.DragAndDropEvent; -import com.vaadin.event.dd.TargetDetails; -import com.vaadin.terminal.PaintException; -import com.vaadin.terminal.PaintTarget; - -/** - * Criterion for checking if drop target details contains the specific property - * with the specific value. Currently only String values are supported. - * - * @since 6.3 - * - * TODO add support for other basic data types that we support in UIDL. - * - */ -public class TargetDetailIs extends ClientSideCriterion { - - private static final long serialVersionUID = 763165450054331246L; - private String propertyName; - private Object value; - - /** - * Constructs a criterion which ensures that the value there is a value in - * {@link TargetDetails} that equals the reference value. - * - * @param dataFlavor - * the type of data to be checked - * @param value - * the reference value to which the drop target detail will be - * compared - */ - public TargetDetailIs(String dataFlavor, String value) { - propertyName = dataFlavor; - this.value = value; - } - - public TargetDetailIs(String dataFlavor, Boolean true1) { - propertyName = dataFlavor; - value = true1; - } - - @Override - public void paintContent(PaintTarget target) throws PaintException { - super.paintContent(target); - target.addAttribute("p", propertyName); - if (value instanceof Boolean) { - target.addAttribute("v", ((Boolean) value).booleanValue()); - target.addAttribute("t", "b"); - } else if (value instanceof String) { - target.addAttribute("v", (String) value); - } - } - - @Override - public boolean accept(DragAndDropEvent dragEvent) { - Object data = dragEvent.getTargetDetails().getData(propertyName); - return value.equals(data); - } - - @Override - protected String getIdentifier() { - // sub classes by default use VDropDetailEquals a client implementation - return TargetDetailIs.class.getCanonicalName(); - } -}
\ No newline at end of file |