wt.clients.util
Class FileChooserDropApplet

java.lang.Object
  extended byjava.awt.Component
      extended byjava.awt.Container
          extended byjava.awt.Panel
              extended byjava.applet.Applet
                  extended byjavax.swing.JApplet
                      extended bywt.clients.util.FileChooserDropApplet
All Implemented Interfaces:
Accessible, ActionListener, EventListener, ImageObserver, MenuContainer, RootPaneContainer, Serializable, SimpleDragStateListener

public class FileChooserDropApplet
extends JApplet
implements ActionListener, SimpleDragStateListener

Applet used to select files (actually, filepath strings), requires Java plugin. This applet is used in HTML pages to launch a Java file dialog and return the the selected filepath(s) to the HTML page, or to accept one or more dragged-and-dropped files and return the dropped filepath(s) to the HTML page. Visible portion of applet is either a standard button that typically says "Browse..." or a transparent button that looks like a hyperlink, typically saying something like "Add Files..." or "Add Attachments..." When the applet button is clicked, a file chooser dialog is launched. The user uses the file dialog to selects file(s) and clicks "Save" (or custom label) button. The filepath (or multiple concatenated filepaths) string is provided to the page by the applet calling the JavaScript method setPath() (or jsSetMethod-specified custom method). The optional drop target is displayed next to the button/"hyperlink". Used in single-select mode for selecting primary content in single-document Create/Update/Check In wizards for documents and document templates. Used in multi-select mode for selecting primary content in Create Multiple Documents wizard, secondary content (attachments) of FormatContentHolder objects, and attachments for ContentHolder objects (such as change objects).

See Also:
JFileChooserApplet, FileLocatorApplet, The following parameters are absolutely required:, Serialized Form

Nested Class Summary
 class FileChooserDropApplet.DragHandler
           
(package private)  class FileChooserDropApplet.WorkerThread
           
 
Nested classes inherited from class javax.swing.JApplet
JApplet.AccessibleJApplet
 
Nested classes inherited from class java.applet.Applet
Applet.AccessibleApplet
 
Nested classes inherited from class java.awt.Panel
Panel.AccessibleAWTPanel
 
Nested classes inherited from class java.awt.Container
Container.AccessibleAWTContainer
 
Nested classes inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BltBufferStrategy, Component.FlipBufferStrategy
 
Field Summary
private  String actionLabel
           
protected  String addImageFilename
           
protected  ImageIcon addImageIcon
           
(package private)  int bgcolor
           
(package private)  int bgcoloractive
           
protected static String BROWSE
           
protected  JButton browseButton
           
(package private)  int buttoncolor
           
(package private)  int buttoncoloractive
           
private  String buttonLabel
           
(package private)  int chunk
           
(package private)  URL codeBase
           
private  ThreadGroup contextGroup
           
private  Font crossLocaleFont
           
(package private)  boolean DEBUG
           
private  String defaultPath
           
private  String DELIM
           
protected  JButton dropButton
           
protected  String dropImageFilename
           
protected  String dropImageFilenameActive
           
protected  ImageIcon dropImageIcon
           
protected  ImageIcon dropImageIconActive
           
private  FileAccess fileAccess
           
private  boolean inAnApplet
           
private static Object initSync
           
private  String jsGetMethod
           
private  String jsSetMethod
           
private  boolean MULTI_SELECT_ENABLED
           
private  String orientation
           
 
Fields inherited from class javax.swing.JApplet
accessibleContext, rootPane, rootPaneCheckingEnabled
 
Fields inherited from class java.applet.Applet
 
Fields inherited from class java.awt.Panel
 
Fields inherited from class java.awt.Container
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
FileChooserDropApplet()
           
FileChooserDropApplet(boolean inAnApplet)
           
 
Method Summary
 void actionPerformed(ActionEvent e)
           
private  boolean confirm(String displayMessage)
          Displays modal dialog of message with OK/Cancel buttons.
 String createValidDefaultPath(String path)
           
 void destroy()
           
private  boolean display(String displayMessage)
          Displays modal dialog of message with OK button.
 String doShowFileLocator(String path)
          Launches file dialog in this thread.
private  String EncodeHTMLPath(String path)
           
 void enterDragOverState()
          Change drop target's appearance to active state
 void exitDragOverState()
          Return drop target's appearance to inactive state.
private  FileAccess getFileAccess()
           
private  String getParameter(String paramName, String defaultParamValue)
          Return applet parameter value, or return default value if parameter not available.
 Applet getParentApplet()
           
 Frame getParentFrame()
           
protected  URL getURL(String filename)
           
 void init()
           
 boolean isDirectory(File maybeDirectory)
          Return true if File is actually a directory
 boolean isDirectory(String path)
          Return true if path leads to a directory
 boolean isValidTarget(File file)
          Checks whether local file exists and is readable.
 boolean isValidTarget(String target)
          Checks whether local file exists and is readable.
static void main(String[] args)
           
 Container makeContentPane()
           
 String multipleSelectionProcessing(File[] files)
          Return concatenated escaped filepath strings for validated File objects (file exists, is readable, is not a shortcut or directory).
protected  void setElement(String returnValue)
          Sends value from applet to page.
protected  void setElement(String value, boolean complete)
          Used by setElement(String) to send value from applet to page via WTJSObject call.
 void showFileLocator(String path)
          Launches file dialog in separate thread.
 String singleSelectionProcessing(File file)
          Return escaped filepath string for validated File object (file exists, is readable, is not a shortcut or directory).
 void start()
           
 void stop()
           
 
Methods inherited from class javax.swing.JApplet
addImpl, createRootPane, getAccessibleContext, getContentPane, getGlassPane, getJMenuBar, getLayeredPane, getRootPane, isRootPaneCheckingEnabled, paramString, remove, setContentPane, setGlassPane, setJMenuBar, setLayeredPane, setLayout, setRootPane, setRootPaneCheckingEnabled, update
 
Methods inherited from class java.applet.Applet
getAppletContext, getAppletInfo, getAudioClip, getAudioClip, getCodeBase, getDocumentBase, getImage, getImage, getLocale, getParameter, getParameterInfo, isActive, newAudioClip, play, play, resize, resize, setStub, showStatus
 
Methods inherited from class java.awt.Panel
addNotify
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getInsets, getLayout, getListeners, getMaximumSize, getMinimumSize, getPreferredSize, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paint, paintComponents, preferredSize, print, printComponents, processContainerEvent, processEvent, remove, removeAll, removeContainerListener, removeNotify, setFocusCycleRoot, setFocusTraversalKeys, setFocusTraversalPolicy, setFont, transferFocusBackward, transferFocusDownCycle, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, createVolatileImage, createVolatileImage, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphics, getGraphicsConfiguration, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocation, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getToolkit, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isOpaque, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, printAll, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, reshape, setBackground, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeysEnabled, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, setVisible, show, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

initSync

private static Object initSync

contextGroup

private ThreadGroup contextGroup

defaultPath

private String defaultPath

actionLabel

private String actionLabel

buttonLabel

private String buttonLabel

jsGetMethod

private String jsGetMethod

jsSetMethod

private String jsSetMethod

fileAccess

private FileAccess fileAccess

MULTI_SELECT_ENABLED

private boolean MULTI_SELECT_ENABLED

DELIM

private String DELIM

BROWSE

protected static final String BROWSE
See Also:
Constant Field Values

DEBUG

boolean DEBUG

browseButton

protected JButton browseButton

dropButton

protected JButton dropButton

orientation

private String orientation

bgcolor

int bgcolor

bgcoloractive

int bgcoloractive

buttoncolor

int buttoncolor

buttoncoloractive

int buttoncoloractive

chunk

int chunk

addImageFilename

protected String addImageFilename

dropImageFilename

protected String dropImageFilename

dropImageFilenameActive

protected String dropImageFilenameActive

addImageIcon

protected ImageIcon addImageIcon

dropImageIcon

protected ImageIcon dropImageIcon

dropImageIconActive

protected ImageIcon dropImageIconActive

inAnApplet

private boolean inAnApplet

codeBase

URL codeBase

crossLocaleFont

private Font crossLocaleFont
Constructor Detail

FileChooserDropApplet

public FileChooserDropApplet()

FileChooserDropApplet

public FileChooserDropApplet(boolean inAnApplet)
Method Detail

init

public void init()

start

public void start()

stop

public void stop()

destroy

public void destroy()

makeContentPane

public Container makeContentPane()

actionPerformed

public void actionPerformed(ActionEvent e)
Specified by:
actionPerformed in interface ActionListener

getURL

protected URL getURL(String filename)

main

public static void main(String[] args)

getParentApplet

public Applet getParentApplet()

getParentFrame

public Frame getParentFrame()

getParameter

private String getParameter(String paramName,
                            String defaultParamValue)
Return applet parameter value, or return default value if parameter not available.


showFileLocator

public void showFileLocator(String path)
Launches file dialog in separate thread.


doShowFileLocator

public String doShowFileLocator(String path)
Launches file dialog in this thread.

Returns:
- selected filepath(s) if valid, "" empty string if invalid and need to browse again, null if user cancelled out of dialog/prompt.

isValidTarget

public boolean isValidTarget(String target)
Checks whether local file exists and is readable.


isValidTarget

public boolean isValidTarget(File file)
Checks whether local file exists and is readable.


confirm

private boolean confirm(String displayMessage)
Displays modal dialog of message with OK/Cancel buttons.

Returns:
- true if user clicks OK, false if user clicks Cancel

display

private boolean display(String displayMessage)
Displays modal dialog of message with OK button.


setElement

protected void setElement(String returnValue)
Sends value from applet to page. For long values, may break value into chunks and send in multiple calls.


setElement

protected void setElement(String value,
                          boolean complete)
Used by setElement(String) to send value from applet to page via WTJSObject call.


getFileAccess

private FileAccess getFileAccess()

EncodeHTMLPath

private String EncodeHTMLPath(String path)

createValidDefaultPath

public String createValidDefaultPath(String path)

isDirectory

public boolean isDirectory(String path)
Return true if path leads to a directory


isDirectory

public boolean isDirectory(File maybeDirectory)
Return true if File is actually a directory


singleSelectionProcessing

public String singleSelectionProcessing(File file)
Return escaped filepath string for validated File object (file exists, is readable, is not a shortcut or directory).


multipleSelectionProcessing

public String multipleSelectionProcessing(File[] files)
Return concatenated escaped filepath strings for validated File objects (file exists, is readable, is not a shortcut or directory).


enterDragOverState

public void enterDragOverState()
Change drop target's appearance to active state

Specified by:
enterDragOverState in interface SimpleDragStateListener

exitDragOverState

public void exitDragOverState()
Return drop target's appearance to inactive state.

Specified by:
exitDragOverState in interface SimpleDragStateListener