The Meta-Environment API

nl.cwi.sen1.gui.component
Class StudioComponentImpl

java.lang.Object
  extended by nl.cwi.sen1.gui.component.StudioComponentImpl
All Implemented Interfaces:
StudioComponent

public class StudioComponentImpl
extends java.lang.Object
implements StudioComponent

A default implementation of a StudioComponent. This is the starting point for any StudioComponent. This convience class wraps a JComponent, and implements the default behavior for the StudioComponent interface.


Field Summary
private  javax.swing.Icon icon
           
private  javax.swing.event.EventListenerList listenerList
           
private  java.lang.String name
           
private  java.lang.String tooltip
           
private  javax.swing.JComponent viewComponent
           
 
Constructor Summary
StudioComponentImpl(java.lang.String name, javax.swing.JComponent viewComponent)
          Construct a new component.
StudioComponentImpl(java.lang.String name, javax.swing.JComponent viewComonent, java.lang.String tooltip)
           
 
Method Summary
 void addNameChangedListener(NameChangedListener l)
          Register a NameChangedListener.
 void addStudioComponentListener(StudioComponentListener l)
          Register a listener (usually the plugin that this Component belongs to, and the MetaStudio).
 void addTooltipChangedListener(TooltipChangedListener l)
          Register a TooltipChangedListener.
 void close()
          Closes a component.
protected  void fireComponentClose()
           
protected  void fireComponentFocusReceived()
           
protected  void fireComponentRequestClose()
           
 void fireNameChangedEvent()
           
 void fireTooltipChangedEvent()
           
 javax.swing.Icon getIcon()
          Tabs can be labelled with small icons too.
 java.lang.String getName()
          The name is used to construct labels of tabs.
 javax.swing.JComponent[] getStatusBarComponents()
          The MetaStudio has a status bar at the bottom.
 java.lang.String getTooltip()
          The tooltip is used to show when hovering the mouse over tabs.
 javax.swing.JComponent getViewComponent()
          The bridge to Swing is made here.
 void receiveFocus()
          Receive the focus.
 void removeNameChangedListener(NameChangedListener l)
          Unregister a NameChangedListener.
 void removeStudioComponentListener(StudioComponentListener l)
          Unregister a listener.
 void removeTooltipChangedListener(TooltipChangedListener l)
          Unregister a TooltipChangedListener.
 void requestClose()
          Request to close the window.
 void setIcon(javax.swing.Icon icon)
           
 void setName(java.lang.String name)
          The name can be changed.
 void setTooltip(java.lang.String tooltip)
          The tooltip can be changed.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

icon

private javax.swing.Icon icon

listenerList

private javax.swing.event.EventListenerList listenerList

name

private java.lang.String name

tooltip

private java.lang.String tooltip

viewComponent

private javax.swing.JComponent viewComponent
Constructor Detail

StudioComponentImpl

public StudioComponentImpl(java.lang.String name,
                           javax.swing.JComponent viewComponent)
Construct a new component.

Parameters:
name - the name of the component (for a tab label).
viewComponent - the Swing component to show in the tab.

StudioComponentImpl

public StudioComponentImpl(java.lang.String name,
                           javax.swing.JComponent viewComonent,
                           java.lang.String tooltip)
Method Detail

getName

public java.lang.String getName()
Description copied from interface: StudioComponent
The name is used to construct labels of tabs.

Specified by:
getName in interface StudioComponent
Returns:
the label of a tab.

setName

public void setName(java.lang.String name)
Description copied from interface: StudioComponent
The name can be changed.

Specified by:
setName in interface StudioComponent
Parameters:
name - new name for this component.

getTooltip

public java.lang.String getTooltip()
Description copied from interface: StudioComponent
The tooltip is used to show when hovering the mouse over tabs.

Specified by:
getTooltip in interface StudioComponent
Returns:
the tooltip of a tab.

setTooltip

public void setTooltip(java.lang.String tooltip)
Description copied from interface: StudioComponent
The tooltip can be changed.

Specified by:
setTooltip in interface StudioComponent
Parameters:
tooltip - new tooltip for this component.

getViewComponent

public javax.swing.JComponent getViewComponent()
Description copied from interface: StudioComponent
The bridge to Swing is made here. The returned JComponent will fill exactly one tab. Any JComponent will do.

Specified by:
getViewComponent in interface StudioComponent

addStudioComponentListener

public void addStudioComponentListener(StudioComponentListener l)
Description copied from interface: StudioComponent
Register a listener (usually the plugin that this Component belongs to, and the MetaStudio). The studio and the plugin listen to important changes in the state of a component. This may be used to implement window management, by the plugin, or by the Studio.

Specified by:
addStudioComponentListener in interface StudioComponent
Parameters:
l - the listener to register.

removeStudioComponentListener

public void removeStudioComponentListener(StudioComponentListener l)
Description copied from interface: StudioComponent
Unregister a listener.

Specified by:
removeStudioComponentListener in interface StudioComponent

fireComponentRequestClose

protected void fireComponentRequestClose()
                                  throws CloseAbortedException
Throws:
CloseAbortedException

fireComponentClose

protected void fireComponentClose()

fireComponentFocusReceived

protected void fireComponentFocusReceived()

getIcon

public javax.swing.Icon getIcon()
Description copied from interface: StudioComponent
Tabs can be labelled with small icons too.

Specified by:
getIcon in interface StudioComponent
Returns:
an icon to be used by the Studio

setIcon

public void setIcon(javax.swing.Icon icon)

requestClose

public void requestClose()
                  throws CloseAbortedException
Description copied from interface: StudioComponent
Request to close the window. The controls on a tab window are implemented by the @see MetaStudio. If a user clicks the close icon on a tab, the component will be notified using this method. This gives the component the chance to save resources, or start save/cancel dialogs if necessary.

Specified by:
requestClose in interface StudioComponent
Throws:
CloseAbortedException - if the component can not be closed (for example when the user chooses to cancel.

close

public void close()
Description copied from interface: StudioComponent
Closes a component. This makes the component invisible immediately.

Specified by:
close in interface StudioComponent

receiveFocus

public void receiveFocus()
Description copied from interface: StudioComponent
Receive the focus. When a component receives the focus, there is sometimes something to do, like reset or set the focus to a particular part of the component.

Specified by:
receiveFocus in interface StudioComponent

getStatusBarComponents

public javax.swing.JComponent[] getStatusBarComponents()
Description copied from interface: StudioComponent
The MetaStudio has a status bar at the bottom. When a component receives the focus, the status bar will show the returned JComponents from left to right in a certain part of the status bar.

Specified by:
getStatusBarComponents in interface StudioComponent
Returns:
an array of JComponents to show in the status bar.

addNameChangedListener

public void addNameChangedListener(NameChangedListener l)
Description copied from interface: StudioComponent
Register a NameChangedListener. If a tab wants to change its name, it should notify all NameChangedListeners. The MetaStudio itself uses it to update the label on the tab.

Specified by:
addNameChangedListener in interface StudioComponent

removeNameChangedListener

public void removeNameChangedListener(NameChangedListener l)
Description copied from interface: StudioComponent
Unregister a NameChangedListener.

Specified by:
removeNameChangedListener in interface StudioComponent

fireNameChangedEvent

public void fireNameChangedEvent()

addTooltipChangedListener

public void addTooltipChangedListener(TooltipChangedListener l)
Description copied from interface: StudioComponent
Register a TooltipChangedListener. If a tab wants to change its tooltip, it should notify all TooltipChangedListeners. The MetaStudio itself uses it to update the tooltip off the tab.

Specified by:
addTooltipChangedListener in interface StudioComponent

removeTooltipChangedListener

public void removeTooltipChangedListener(TooltipChangedListener l)
Description copied from interface: StudioComponent
Unregister a TooltipChangedListener.

Specified by:
removeTooltipChangedListener in interface StudioComponent

fireTooltipChangedEvent

public void fireTooltipChangedEvent()

The Meta-Environment API