org.ocd.dcf
Class DCComponent

java.lang.Object
  |
  +--java.awt.Component
        |
        +--java.awt.Container
              |
              +--javax.swing.JComponent
                    |
                    +--javax.swing.JPanel
                          |
                          +--org.ocd.dcf.DCComponent
All Implemented Interfaces:
javax.accessibility.Accessible, java.awt.image.ImageObserver, IXMLPersistable, java.awt.MenuContainer, java.io.Serializable
Direct Known Subclasses:
DCMenu, DCTile, LaunchPanel, MasterTile, StickyNote, TileSet

public class DCComponent
extends javax.swing.JPanel
implements IXMLPersistable

Component

The Component class is the base class for DCF based Components. The Component supports the IXMLPersistable interface.

The Component can be placed on the Desktop or reside inside a traditional Swing container When placed on the Desktop the Component is placed in its own delegate Window.

The Component also supports the basic DCF drag and drop operations.

Sub classes should overridge the setBLXElement and getXMLElement methods to add support for storing their own data in XML.

Since:
$Date: 2002/06/12 03:58:04 $
Version:
$Revision: 1.18 $
Author:
$Author: drichan $
See Also:
Serialized Form

Inner Class Summary
static class DCComponent.DesktopWindow
          Used to fix a problem with Window Focus see JDK Bug: 4186928
 
Inner classes inherited from class javax.swing.JPanel
javax.swing.JPanel.AccessibleJPanel
 
Inner classes inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent
 
Inner classes inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
 
Inner classes inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent
 
Field Summary
protected  java.util.HashSet dcComponentListeners
           
protected static java.awt.Frame desktopFrame
           
protected  boolean draggable_flag
           
protected  java.awt.dnd.DragGestureRecognizer dragRecognizer
           
protected  java.awt.dnd.DragSource dragSource
           
protected  java.awt.dnd.DragSourceListener dragSourceListener
           
protected  java.lang.String extensionHREF
           
protected  java.lang.String extensionName
           
protected  java.lang.String extensionVersion
           
protected  boolean onDesktop_flag
           
protected  java.net.URL relativeURL
           
protected  java.awt.datatransfer.Transferable transferObject
           
protected  boolean visible_flag
           
protected  java.awt.Window window
           
protected  boolean xmlChanged_flag
           
protected static IXMLParser xmlParser
           
 
Fields inherited from class javax.swing.JComponent
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface org.ocd.blx.IXMLPersistable
BLX_CLASS_NAME_ATTR, BLX_COMP_HEIGHT_ATTR, BLX_COMP_ID, BLX_COMP_NODE_NAME, BLX_COMP_WIDTH_ATTR, BLX_COMP_X_ATTR, BLX_COMP_Y_ATTR, BLX_DOCUMENT_NAME, BLX_EXT_HREF_ATTR, BLX_EXT_VERSION_ATTR, BLX_EXTENSION_ATTR, BLX_FACTORY_NODE_NAME, BLX_FACTORY_TYPE_ATTR, BLX_HREF_ATTR, BLX_NS, BLX_OBJ_NODE_NAME, COMP_TYPE, COMPONENT_FACTORY_TYPE, COMPONENT_FACTORY_TYPE_STR, FACTORY_TYPE, FILE_EXT, OBJECT_FACTORY_TYPE, OBJECT_FACTORY_TYPE_STR, OBJECT_TYPE
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
DCComponent()
           
 
Method Summary
 void addDCComponentListener(DCComponentListener pListener)
          Add A DCComponentListener.
static void addDesktopFrameListener(java.awt.event.WindowListener listener)
          Add a window listener to the Main Desktop Frame
protected  org.w3c.dom.Node appendChild(org.w3c.dom.Document doc, org.w3c.dom.Node parent, org.w3c.dom.Node child)
          Add a Child Node to a Parent Node for the Given Document
protected  org.w3c.dom.Document createDOMDocument()
          Helper Method Used by sub-classes to easily create a DOM Document using the xmlParser
 void dispose()
          Dispose of this Component.
 org.w3c.dom.Element getBLXElement()
          Get the BLX-Node for this Component.
 java.awt.Image getComponentDragImage()
          Returns the Image that will be used while this Component is being Dragged
static java.awt.Frame getDesktopFrame()
          Get the Desktop Frame that owns all components on the Desktop
 java.lang.String getID()
          Get this Components unique ID
 java.awt.Point getLocation()
          Get the Location of this Component Relative to its Parent.
 java.awt.Frame getOwnerFrame()
          Get OwnerFrame of this Componet This component will return the Frame that owns this Component
 java.awt.datatransfer.Transferable getTransferable()
          Gets this components Transferable Object
 org.w3c.dom.Element getXMLElement()
          Get the Data Node for this Component.
 boolean isDraggable()
          Return true if this Component is Draggable
 boolean isOnDesktop()
          Returns true if this component is on the Desktop
protected  void placeOnDesktop()
          placed the component on the desktop
 void removeDCComponentListener(DCComponentListener pListener)
          Remove a Disposed Listener
static void removeDesktopFrameListener(java.awt.event.WindowListener listener)
          Add a window listener to the Main Desktop Frame
protected  void removeFromDesktop()
          Remove the component from the Desktop
 void setBLXElement(org.w3c.dom.Element pElement, java.net.URL pRelativeURL)
          Set the Node on this Component
static void setDesktopFrameIconImage(java.awt.Image pImage)
          Set the Image used for the DCComponents Desktop Frame This Frame is the owner of all DCComponents when they are on the Desktop
static void setDesktopFrameTitle(java.lang.String pTitle)
          Set the Title used for the DCComponents Desktop Frame This Frame is the owner of all DCComponents when they are on the Desktop
static void setDesktopFrameVisible(boolean pVisible)
          Set Visiblity of the Desktop Frame This Frame is the owner of all DCComponents when they are on the Desktop If the frame is Visible then it will be in an Iconified state
 void setDraggable(boolean pDraggable)
          True if This Component can be dragged.
protected  void setDragSourceListener(java.awt.dnd.DragSourceListener pListener)
          Sets the Drag Source Listener of this Component
 void setLocation(int pX, int pY)
          Sets the Location of the Component in its parent or on the Screen
 void setOnDesktop(boolean pUseDesktop)
          Place the Component on the Desktop or remove it from the Desktop When placed on the Desktop the Component is placed in its own Window When removed from the Desktop the component acts like a standard JComponent
 void setSize(int width, int height)
          Set the Size of this Component
 void setTransferable(java.awt.datatransfer.Transferable pTransfer)
          Sets this component Transferable Object
 void setVisible(boolean pVisible)
          Hides or Shows this Component
 void setXMLChanged(boolean pChanged)
          Set the xmlChanged Flag Only sub classes can call this
 boolean xmlHasChanged()
          Return true if this components state has changed in a way that Requires a new XML Node to be fetched
 
Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUIClassID, paramString, updateUI
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addPropertyChangeListener, addPropertyChangeListener, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentGraphics, getConditionForKeyStroke, getDebugGraphicsOptions, getGraphics, getHeight, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getVerifyInputWhenFocusTarget, getVisibleRect, getWidth, getX, getY, grabFocus, hasFocus, hide, isDoubleBuffered, isFocusCycleRoot, isFocusTraversable, isLightweightComponent, isManagingFocus, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isPreferredSizeSet, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processFocusEvent, processKeyBinding, processKeyEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setDebugGraphicsOptions, setDoubleBuffered, setEnabled, setFont, setForeground, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setUI, setVerifyInputWhenFocusTarget, unregisterKeyboardAction, update
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getLayout, insets, invalidate, isAncestorOf, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setLayout, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, getBackground, getBounds, getColorModel, getComponentOrientation, getCursor, getDropTarget, getFont, getFontMetrics, getForeground, getGraphicsConfiguration, getInputContext, getInputMethodRequests, getLocale, getLocationOnScreen, getName, getParent, getPeer, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, imageUpdate, inside, isDisplayable, isEnabled, isLightweight, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setLocale, setLocation, setName, setSize, show, show, size, toString, transferFocus
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

onDesktop_flag

protected boolean onDesktop_flag

visible_flag

protected boolean visible_flag

draggable_flag

protected boolean draggable_flag

window

protected java.awt.Window window

dragSource

protected java.awt.dnd.DragSource dragSource

dragRecognizer

protected java.awt.dnd.DragGestureRecognizer dragRecognizer

dragSourceListener

protected java.awt.dnd.DragSourceListener dragSourceListener

desktopFrame

protected static java.awt.Frame desktopFrame

dcComponentListeners

protected java.util.HashSet dcComponentListeners

transferObject

protected java.awt.datatransfer.Transferable transferObject

xmlChanged_flag

protected boolean xmlChanged_flag

xmlParser

protected static IXMLParser xmlParser

extensionName

protected java.lang.String extensionName

extensionHREF

protected java.lang.String extensionHREF

extensionVersion

protected java.lang.String extensionVersion

relativeURL

protected java.net.URL relativeURL
Constructor Detail

DCComponent

public DCComponent()
Method Detail

setOnDesktop

public void setOnDesktop(boolean pUseDesktop)
Place the Component on the Desktop or remove it from the Desktop When placed on the Desktop the Component is placed in its own Window When removed from the Desktop the component acts like a standard JComponent

When a component is set on the Desktop its visibility is set to false. setVisible(true) must be called after calling setOnDesktop(true)

Parameters:
pUseDesktop - true if the component should be placed on the Desktop

isOnDesktop

public boolean isOnDesktop()
Returns true if this component is on the Desktop

placeOnDesktop

protected void placeOnDesktop()
placed the component on the desktop

getOwnerFrame

public java.awt.Frame getOwnerFrame()
Get OwnerFrame of this Componet This component will return the Frame that owns this Component
Returns:
Frame

getTransferable

public java.awt.datatransfer.Transferable getTransferable()
Gets this components Transferable Object

setTransferable

public void setTransferable(java.awt.datatransfer.Transferable pTransfer)
Sets this component Transferable Object
Parameters:
pTransfer - Object used for passing data during Drag and Drop

removeFromDesktop

protected void removeFromDesktop()
Remove the component from the Desktop

setSize

public void setSize(int width,
                    int height)
Set the Size of this Component
Overrides:
setSize in class java.awt.Component
Parameters:
width -  
height -  

dispose

public void dispose()
Dispose of this Component. This method disposes of the component's Window if The component is on the Desktop. If the component is not on the desktop then it is removed from its parent.

The component should not be used after calling dispose.


addDCComponentListener

public void addDCComponentListener(DCComponentListener pListener)
Add A DCComponentListener. All DCComponentListeners are also added as ComponentListeners
Parameters:
pListener -  

removeDCComponentListener

public void removeDCComponentListener(DCComponentListener pListener)
Remove a Disposed Listener
Parameters:
pListener - to remove

getID

public java.lang.String getID()
Get this Components unique ID

getLocation

public java.awt.Point getLocation()
Get the Location of this Component Relative to its Parent. If the Component is on the Desktop then location is relative to the Screen
Overrides:
getLocation in class java.awt.Component
Returns:
Point

setLocation

public void setLocation(int pX,
                        int pY)
Sets the Location of the Component in its parent or on the Screen
Overrides:
setLocation in class java.awt.Component
Parameters:
pX -  
pY -  

setVisible

public void setVisible(boolean pVisible)
Hides or Shows this Component
Overrides:
setVisible in class javax.swing.JComponent
Parameters:
pVisible -  

setDragSourceListener

protected void setDragSourceListener(java.awt.dnd.DragSourceListener pListener)
Sets the Drag Source Listener of this Component
Parameters:
pListener -  

setDraggable

public void setDraggable(boolean pDraggable)
True if This Component can be dragged. False otherwise
Parameters:
pDraggable -  

getComponentDragImage

public java.awt.Image getComponentDragImage()
Returns the Image that will be used while this Component is being Dragged
Returns:
Image

isDraggable

public boolean isDraggable()
Return true if this Component is Draggable
Returns:
boolean

xmlHasChanged

public boolean xmlHasChanged()
Return true if this components state has changed in a way that Requires a new XML Node to be fetched
Specified by:
xmlHasChanged in interface IXMLPersistable
Returns:
true if component has changed

getXMLElement

public org.w3c.dom.Element getXMLElement()
Get the Data Node for this Component. Sub Classes should override this
Specified by:
getXMLElement in interface IXMLPersistable
Returns:
the Node that contains this Components Settings

createDOMDocument

protected org.w3c.dom.Document createDOMDocument()
Helper Method Used by sub-classes to easily create a DOM Document using the xmlParser

getBLXElement

public org.w3c.dom.Element getBLXElement()
Get the BLX-Node for this Component.
Specified by:
getBLXElement in interface IXMLPersistable
Returns:
the Node that contains this Components blx Settings

setXMLChanged

public void setXMLChanged(boolean pChanged)
Set the xmlChanged Flag Only sub classes can call this
Parameters:
Changed -  

appendChild

protected org.w3c.dom.Node appendChild(org.w3c.dom.Document doc,
                                       org.w3c.dom.Node parent,
                                       org.w3c.dom.Node child)
                                throws org.w3c.dom.DOMException
Add a Child Node to a Parent Node for the Given Document
Parameters:
doc - Document of Nodes
parent - Node child should be added to. This node will be imported into doc if it hasn't already
child - Node that will be added to parent node
Returns:
new parent node

setBLXElement

public void setBLXElement(org.w3c.dom.Element pElement,
                          java.net.URL pRelativeURL)
Set the Node on this Component
Specified by:
setBLXElement in interface IXMLPersistable
Parameters:
pElement - Node that contains this components settings
pRelativeURL - the URL that all HREFs would be relative to

getDesktopFrame

public static java.awt.Frame getDesktopFrame()
Get the Desktop Frame that owns all components on the Desktop

addDesktopFrameListener

public static void addDesktopFrameListener(java.awt.event.WindowListener listener)
Add a window listener to the Main Desktop Frame

removeDesktopFrameListener

public static void removeDesktopFrameListener(java.awt.event.WindowListener listener)
Add a window listener to the Main Desktop Frame

setDesktopFrameIconImage

public static void setDesktopFrameIconImage(java.awt.Image pImage)
Set the Image used for the DCComponents Desktop Frame This Frame is the owner of all DCComponents when they are on the Desktop

setDesktopFrameTitle

public static void setDesktopFrameTitle(java.lang.String pTitle)
Set the Title used for the DCComponents Desktop Frame This Frame is the owner of all DCComponents when they are on the Desktop

setDesktopFrameVisible

public static void setDesktopFrameVisible(boolean pVisible)
Set Visiblity of the Desktop Frame This Frame is the owner of all DCComponents when they are on the Desktop If the frame is Visible then it will be in an Iconified state