Class DropZone

All Implemented Interfaces:
HasAttachHandlers, HasHandlers, EventListener, HasVisibility, IsWidget, LogicalStructure, HasClearHandlers, HasClickHandlers, HasDoubleClickHandlers, HasDragMoveHandlers, HasDragRepositionMoveHandlers, HasDragRepositionStartHandlers, HasDragRepositionStopHandlers, HasDragResizeMoveHandlers, HasDragResizeStartHandlers, HasDragResizeStopHandlers, HasDragStartHandlers, HasDragStopHandlers, HasDropHandlers, HasDropMoveHandlers, HasDropOutHandlers, HasDropOverHandlers, HasFocusChangedHandlers, HasHoverHandlers, HasHoverHiddenHandlers, HasIconClickHandlers, HasKeyDownHandlers, HasKeyPressHandlers, HasMouseDownHandlers, HasMouseMoveHandlers, HasMouseOutHandlers, HasMouseOverHandlers, HasMouseStillDownHandlers, HasMouseUpHandlers, HasMouseWheelHandlers, HasMovedHandlers, HasParentMovedHandlers, HasResizedHandlers, HasRightMouseDownHandlers, HasRuleContextChangedHandlers, HasScrolledHandlers, HasShowContextMenuHandlers, HasTitleHoverHandlers, HasVisibilityChangedHandlers
Direct Known Subclasses:
FileDropZone

public class DropZone extends Label
Base class for drop zones that accept HTML5 drag-and-drop of files and/or content.

DropZone extends Label (StatefulCanvas), providing standard state-based styling for drag interactions. Subclasses can accept file drops (canDropFiles), content drops (canDropContent), or both.

For file-specific features like thumbnails, progress bars, and rich validation, see FileDropZone. For skin snapshot import, see SkinSnapshotDropZone.

  • Constructor Details

    • DropZone

      public DropZone()
    • DropZone

      public DropZone(JavaScriptObject jsObj)
  • Method Details

    • getOrCreateRef

      public static DropZone getOrCreateRef(JavaScriptObject jsObj)
    • changeAutoChildDefaults

      public static void changeAutoChildDefaults(String autoChildName, Canvas defaults)
      Changes the defaults for Canvas AutoChildren named autoChildName.
      Parameters:
      autoChildName - name of an AutoChild to customize the defaults for.
      defaults - Canvas defaults to apply. These defaults override any existing properties without destroying or wiping out non-overridden properties. For usage tips on this param, see SGWTProperties.
      See Also:
    • changeAutoChildDefaults

      public static void changeAutoChildDefaults(String autoChildName, FormItem defaults)
      Changes the defaults for FormItem AutoChildren named autoChildName.
      Parameters:
      autoChildName - name of an AutoChild to customize the defaults for.
      defaults - FormItem defaults to apply. These defaults override any existing properties without destroying or wiping out non-overridden properties. For usage tips on this param, see SGWTProperties.
      See Also:
    • create

      protected JavaScriptObject create()
      Overrides:
      create in class Label
    • setAcceptedFileTypes

      public DropZone setAcceptedFileTypes(String... acceptedFileTypes) throws IllegalStateException
      Array of accepted MIME types (e.g., ["image/*", "application/pdf"]). If null, all file types are accepted when canDropFiles is true.
      Parameters:
      acceptedFileTypes - New acceptedFileTypes value. Default value is null
      Returns:
      DropZone instance, for chaining setter calls
      Throws:
      IllegalStateException - this property cannot be changed after the component has been created
    • getAcceptedFileTypes

      public String[] getAcceptedFileTypes()
      Array of accepted MIME types (e.g., ["image/*", "application/pdf"]). If null, all file types are accepted when canDropFiles is true.
      Returns:
      Current acceptedFileTypes value. Default value is null
    • setAlign

      public DropZone setAlign(Alignment align) throws IllegalStateException
      Horizontal alignment for drop zone content.
      Overrides:
      setAlign in class Label
      Parameters:
      align - New align value. Default value is "center"
      Returns:
      DropZone instance, for chaining setter calls
      Throws:
      IllegalStateException - this property cannot be changed after the component has been created
      See Also:
    • getAlign

      public Alignment getAlign()
      Horizontal alignment for drop zone content.
      Overrides:
      getAlign in class Label
      Returns:
      Current align value. Default value is "center"
      See Also:
    • setBaseStyle

      public DropZone setBaseStyle(String baseStyle) throws IllegalStateException
      Base CSS class for the drop zone. Supports state suffixes: Over, Disabled.
      Overrides:
      setBaseStyle in class Button
      Parameters:
      baseStyle - New baseStyle value. Default value is "dropZone"
      Returns:
      DropZone instance, for chaining setter calls
      Throws:
      IllegalStateException - this property cannot be changed after the component has been created
      See Also:
    • getBaseStyle

      public String getBaseStyle()
      Base CSS class for the drop zone. Supports state suffixes: Over, Disabled.
      Overrides:
      getBaseStyle in class Button
      Returns:
      Current baseStyle value. Default value is "dropZone"
      See Also:
    • setCanDropContent

      public DropZone setCanDropContent(Boolean canDropContent) throws IllegalStateException
      Whether this drop zone accepts content drops (text, HTML) from other applications. When true, the contentDrop() notification fires when content is dropped.
      Overrides:
      setCanDropContent in class Canvas
      Parameters:
      canDropContent - New canDropContent value. Default value is false
      Returns:
      DropZone instance, for chaining setter calls
      Throws:
      IllegalStateException - this property cannot be changed after the component has been created
      See Also:
    • getCanDropContent

      public Boolean getCanDropContent()
      Whether this drop zone accepts content drops (text, HTML) from other applications. When true, the contentDrop() notification fires when content is dropped.
      Overrides:
      getCanDropContent in class Canvas
      Returns:
      Current canDropContent value. Default value is false
      See Also:
    • setCanDropFiles

      public DropZone setCanDropFiles(Boolean canDropFiles) throws IllegalStateException
      Whether this drop zone accepts file drops from the desktop. When true, the fileDrop() notification fires when files are dropped.
      Overrides:
      setCanDropFiles in class Canvas
      Parameters:
      canDropFiles - New canDropFiles value. Default value is true
      Returns:
      DropZone instance, for chaining setter calls
      Throws:
      IllegalStateException - this property cannot be changed after the component has been created
      See Also:
    • getCanDropFiles

      public Boolean getCanDropFiles()
      Whether this drop zone accepts file drops from the desktop. When true, the fileDrop() notification fires when files are dropped.
      Overrides:
      getCanDropFiles in class Canvas
      Returns:
      Current canDropFiles value. Default value is true
      See Also:
    • setValign

      public DropZone setValign(VerticalAlignment valign) throws IllegalStateException
      Vertical alignment for drop zone content.
      Overrides:
      setValign in class Label
      Parameters:
      valign - New valign value. Default value is "center"
      Returns:
      DropZone instance, for chaining setter calls
      Throws:
      IllegalStateException - this property cannot be changed after the component has been created
      See Also:
    • getValign

      public VerticalAlignment getValign()
      Vertical alignment for drop zone content.
      Overrides:
      getValign in class Label
      Returns:
      Current valign value. Default value is "center"
      See Also:
    • contentDrop

      public void contentDrop(String content)
      Notification fired when content (text, HTML) is dropped from another application. Only fires when canDropContent is true.
      Parameters:
      content - The dropped content
    • fileDrop

      public void fileDrop(JavaScriptObject[] files)
      Notification fired when files are dropped onto the drop zone. Only fires when canDropFiles is true.
      Parameters:
      files - JavaScript File objects that were dropped
    • setDefaultProperties

      public static void setDefaultProperties(DropZone dropZoneProperties)
      Class level method to set the default properties of this class. If set, then all existing and subsequently created instances of this class will automatically have default properties corresponding to the properties set on the SmartGWT class instance passed to this function before its underlying SmartClient JS object was created. This is a powerful feature that eliminates the need for users to create a separate hierarchy of subclasses that only alter the default properties of this class. Can also be used for skinning / styling purposes.

      Note: This method is intended for setting default attributes only and will affect all instances of the underlying class (including those automatically generated in JavaScript). This method should not be used to apply standard EventHandlers or override methods for a class - use a custom subclass instead. Calling this method after instances have been created can result in undefined behavior, since it bypasses any setters and a class instance may have already examined a particular property and not be expecting any changes through this route.

      Parameters:
      dropZoneProperties - properties that should be used as new defaults when instances of this class are created
      See Also:
    • setLogicalStructure

      public LogicalStructureObject setLogicalStructure(DropZoneLogicalStructure s)
      Setter implementing the LogicalStructure interface, which supports Eclipse's logical structure debugging facility.
    • getLogicalStructure

      public LogicalStructureObject getLogicalStructure()
      Getter implementing the LogicalStructure interface, which supports Eclipse's logical structure debugging facility.
      Specified by:
      getLogicalStructure in interface LogicalStructure
      Overrides:
      getLogicalStructure in class Label