swingwt.awt
Class Container

java.lang.Object
  extended byswingwt.awt.Component
      extended byswingwt.awt.Container
All Implemented Interfaces:
ImageObserver, MenuContainer
Direct Known Subclasses:
JComponent, Window

public class Container
extends Component

Any component that can contain other components. This class maps the Swing layouts/placements to SWT


Field Summary
 org.eclipse.swt.widgets.Composite composite
          The SWT peer this container represents
protected  java.util.Vector comps
          Cache of components waiting to be laid out
protected  java.util.Vector containerListeners
           
protected  LayoutManager layout
          The layout manager being used to position child components
protected  boolean queuedValidateRequest
           
 
Fields inherited from class swingwt.awt.Component
accessibleContext, actionCommand, actionListeners, BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, componentListeners, componentName, consumeAvailableHeight, consumeAvailableWidth, focusable, focusListeners, graphicsConfig, inputMethodListeners, isUserSetFont, keyListeners, layoutModifier, LEFT_ALIGNMENT, LOCK, mouseListeners, mouseMotionListeners, mouseWheelListeners, parent, pBackground, pCursor, pDoubleBuffered, peer, pEnabled, pFont, pForeground, pLayoutData, pLocation, pMaxSize, pMinSize, ppeer, pPrefSize, pSize, pToolTipText, pVisible, RIGHT_ALIGNMENT, swingWTDefaultActionEventAdapter, swingWTEventAdapter, TOP_ALIGNMENT
 
Fields inherited from interface swingwt.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
Container()
           
 
Method Summary
 Component add(Component c)
           
 Component add(Component c, int index)
           
 void add(Component c, java.lang.Object layoutModifier)
          Addition for layouts requiring object based modifiers
 void add(Component c, java.lang.Object layoutModifier, int index)
           
 Component add(java.lang.String name, Component c)
           
 void addComponentToLayout(Component c)
          Adds an existing component to the layout manager
 void addContainerListener(ContainerListener l)
           
 void debug_showContainmentTree()
          Useful for debugging purposes.
 void dispose()
          Destroys the component and stops all listeners
 Component doAdd(Component c)
          Actually does the hard work of adding something to a container
 void doLayout()
          Forces laying out of this container's child components again.
 Component getComponent(int i)
           
 int getComponentCount()
           
 ComponentOrientation getComponentOrientation()
           
 Component[] getComponents()
           
 org.eclipse.swt.widgets.Composite getComposite()
          Returns the SWT peer being used for this container
 Insets getInsets()
           
 LayoutManager getLayout()
          Returns the layout used by this container
 Dimension getMaximumSize()
          Returns the maximum size of the component
 Dimension getMinimumSize()
          Returns the minimum size of the component
 Container getParent()
          Returns the component's parent
 Dimension getPreferredSize()
          Returns the preferred size the component would like to be displayed at - very important for proper layout managers.
 void invalidate()
          Forces laying out of this container's child components again.
 Dimension minimumSize()
           
 Dimension preferredSize()
           
protected  void processContainerEvent(ContainerEvent e)
           
protected  void processEvent(AWTEvent e)
           
 void queuedValidate()
          Attempts to ensure that a request to layout a container is only done once whilst adding many components to a container.
 void remove(Component c)
          Removes a component from the the container by destroying the peer.
 void remove(int index)
           
 void removeAll()
           
 void removeComponentFromCache(Component c)
          Removes a cached component only
 void removeContainerListener(ContainerListener l)
           
 void revalidate()
          Forces laying out of this container's child components again.
 void setLayout(LayoutManager l)
          I'm totally re-writing this method.
protected  void setLayoutImpl(LayoutManager l)
          The actual code that handles assignment of the layout manager.
 void setSwingWTParent(Container parent)
          Called when this gets added.
 void validate()
          Forces laying out of this container's child components again.
 
Methods inherited from class swingwt.awt.Component
add, addActionListener, addComponentListener, addFocusListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, addNotify, calculatePreferredSize, componentOnlyDispose, computePreferredSize, contains, contains, createImage, createListenerArrayFromVector, createVolatileImage, dispatchEvent, getAccessibleContext, getActionCommand, getAlignmentX, getAlignmentY, getBackground, getBounds, getCursor, getFont, getFontMetrics, getForeground, getGraphics, getGraphicsConfiguration, getHeight, getListeners, getLocation, getLocationOnScreen, getName, getPeer, getPeerSize, getSize, getSize, getSWTPeer, getToolkit, getToolTipText, getTreeLock, getWidth, getX, getY, grabFocus, hasFocus, hasSetFont, hide, imageUpdate, inside, isEnabled, isFocusable, isMinimumSizeSet, isShowing, isVisible, paint, paintComponent, processActionEvent, processComponentEvent, processFocusEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, processMouseWheelEvent, processTraverseEvent, registerActionEvents, registerComponentEvents, registerEvents, registerExtendedModifyEvents, registerFocusEvents, registerKeyEvents, registerModifyEvents, registerMouseEvents, registerPaintEvents, registerTraversalEvents, remove, removeActionListener, removeComponentListener, removeFocusListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removeNotify, repaint, repaint, repaint, requestFocus, setActionCommand, setAlignmentX, setAlignmentY, setBackground, setBounds, setBounds, setCachedProperties, setComponentOrientation, setComponentRemoved, setCursor, setEnabled, setFocusable, setFocusTraversalKeysEnabled, setFont, setForeground, setHeight, setLocation, setLocation, setMaximumSize, setMinimumSize, setName, setPreferredSize, setSize, setSize, setToolTipText, setVisible, setWidth, show, transferFocus, transferFocusBackward, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

composite

public org.eclipse.swt.widgets.Composite composite
The SWT peer this container represents


layout

protected LayoutManager layout
The layout manager being used to position child components


comps

protected java.util.Vector comps
Cache of components waiting to be laid out


containerListeners

protected java.util.Vector containerListeners

queuedValidateRequest

protected boolean queuedValidateRequest
Constructor Detail

Container

public Container()
Method Detail

getMinimumSize

public Dimension getMinimumSize()
Description copied from class: Component
Returns the minimum size of the component

Overrides:
getMinimumSize in class Component

minimumSize

public Dimension minimumSize()

preferredSize

public Dimension preferredSize()

getPreferredSize

public Dimension getPreferredSize()
Description copied from class: Component
Returns the preferred size the component would like to be displayed at - very important for proper layout managers.

Overrides:
getPreferredSize in class Component

getMaximumSize

public Dimension getMaximumSize()
Description copied from class: Component
Returns the maximum size of the component

Overrides:
getMaximumSize in class Component

addContainerListener

public void addContainerListener(ContainerListener l)

removeContainerListener

public void removeContainerListener(ContainerListener l)

add

public Component add(Component c)

add

public Component add(Component c,
                     int index)

doAdd

public Component doAdd(Component c)
Actually does the hard work of adding something to a container


processEvent

protected void processEvent(AWTEvent e)

processContainerEvent

protected void processContainerEvent(ContainerEvent e)

addComponentToLayout

public void addComponentToLayout(Component c)
Adds an existing component to the layout manager


invalidate

public void invalidate()
Forces laying out of this container's child components again.

Overrides:
invalidate in class Component

doLayout

public void doLayout()
Forces laying out of this container's child components again.


validate

public void validate()
Forces laying out of this container's child components again.

Overrides:
validate in class Component

revalidate

public void revalidate()
Forces laying out of this container's child components again.


queuedValidate

public void queuedValidate()
Attempts to ensure that a request to layout a container is only done once whilst adding many components to a container. What we do is basically set a flag to say we need to relayout the container, and if further requests come in the next 50ms, we ignore them. This should really take the heat off the CPU whilst building containers with many objects. Since this generally gets called as we work down the tree doing setSwingWTParent calls, that thread will basically block with no invalidation until all components have been added (what we want) - this is just horribly complex to get your head round, but it works :-)


add

public void add(Component c,
                java.lang.Object layoutModifier)
Addition for layouts requiring object based modifiers


add

public void add(Component c,
                java.lang.Object layoutModifier,
                int index)

add

public Component add(java.lang.String name,
                     Component c)

dispose

public void dispose()
Description copied from class: Component
Destroys the component and stops all listeners

Overrides:
dispose in class Component

remove

public void remove(Component c)
Removes a component from the the container by destroying the peer.


remove

public void remove(int index)

removeAll

public void removeAll()

removeComponentFromCache

public void removeComponentFromCache(Component c)
Removes a cached component only


getLayout

public LayoutManager getLayout()
Returns the layout used by this container


setLayout

public void setLayout(LayoutManager l)
I'm totally re-writing this method. No longer will it only mirror the layouts. From now on, it will actually use the layout managers to layout the component, not the mirrored SWT layouts. Two big advantages with this approach. (a) It allows custom layout managers. (b) It means less work since we don't have to port anything. (yea!)


setLayoutImpl

protected void setLayoutImpl(LayoutManager l)
The actual code that handles assignment of the layout manager. Separated out as setLayout will often get subclassed and my head will explode if I don't do something like this :-)


getComposite

public org.eclipse.swt.widgets.Composite getComposite()
Returns the SWT peer being used for this container


getParent

public Container getParent()
Description copied from class: Component
Returns the component's parent

Overrides:
getParent in class Component

setSwingWTParent

public void setSwingWTParent(Container parent)
                      throws java.lang.Exception
Called when this gets added. We can set layouts and things then if necessary. Note that subclasses are responsible for creating the actual peer and setting the protected "composite" variable

Overrides:
setSwingWTParent in class Component
Throws:
java.lang.Exception

getComponentOrientation

public ComponentOrientation getComponentOrientation()
Overrides:
getComponentOrientation in class Component

getInsets

public Insets getInsets()

getComponentCount

public int getComponentCount()

getComponent

public Component getComponent(int i)

getComponents

public Component[] getComponents()

debug_showContainmentTree

public void debug_showContainmentTree()
Useful for debugging purposes. Shows this container and all it's children.