JIDE 3.5.15

com.jidesoft.document
Class DocumentComponent

java.lang.Object
  extended by com.jidesoft.document.DocumentComponent
Direct Known Subclasses:
CodeEditorDocumentComponent

public class DocumentComponent
extends Object

A class that represents a document object.


Field Summary
static String PROPERTY_BACKGROUND
           
static String PROPERTY_CLOSABLE
           
static String PROPERTY_COMPONENT
           
static String PROPERTY_ENABLED
           
static String PROPERTY_FOREGROUND
           
static String PROPERTY_ICON
           
static String PROPERTY_TITLE
           
static String PROPERTY_TOOLTIP
           
 
Constructor Summary
DocumentComponent(JComponent component, String name)
          Creates a DocumentComponent with component and name, but no icon.
DocumentComponent(JComponent component, String name, String title)
          Creates a DocumentComponent with component, name and title, but no icon.
DocumentComponent(JComponent component, String name, String title, Icon icon)
          Creates a DocumentComponent with component, name, title, and icon.
 
Method Summary
 void addDocumentComponentListener(DocumentComponentListener l)
          Adds the specified listener to receive internal frame events from this titled frame.
 void addPropertyChangeListener(PropertyChangeListener listener)
          Adds a PropertyChangeListener to the listener list.
 void addPropertyChangeListener(String propertyName, PropertyChangeListener listener)
          Adds a PropertyChangeListener to the listener list for a specific property.
 boolean allowClosing()
          Allow this document closing.
 boolean allowMoving()
          Allow this document moving.
 void cleanup()
           
protected  void firePropertyChange(String propertyName, boolean oldValue, boolean newValue)
          Support for reporting bound property changes for boolean properties.
protected  void firePropertyChange(String propertyName, int oldValue, int newValue)
          Support for reporting bound property changes for integer properties.
protected  void firePropertyChange(String propertyName, Object oldValue, Object newValue)
          Support for reporting bound property changes for Object properties.
 Color getBackground()
          Gets the background.
 JComponent getComponent()
          Gets the component.
 Component getDefaultFocusComponent()
          Gets the default focus component for the document component.
 String getDisplayTitle()
          The title to be displayed.
 com.jidesoft.document.PreviousState getDockPreviousState()
           
 DocumentComponentListener[] getDocumentComponentListeners()
          Returns an array of all the DocumentComponentListeners added to this DockableFrame with addDocumentComponentListener.
 IDocumentPane getDocumentPane()
          Gets the DocumentPane where this DocumentComponent is added to.
 com.jidesoft.document.PreviousState getFloatPreviousState()
           
 Color getForeground()
          Gets the foreground.
 Icon getIcon()
          Gets the icon.
 Component getLastFocusedComponent()
          Gets the last sub-component of the document component which held focus.
 String getName()
          Gets the name of the document.
 PropertyChangeListener[] getPropertyChangeListeners()
          Returns an array of all the property change listeners registered on this component.
 PropertyChangeListener[] getPropertyChangeListeners(String propertyName)
          Returns an array of all the listeners which have been associated with the named property.
 String getTitle()
          Gets the title.
 String getTooltip()
          Gets the tooltip.
 boolean isClosable()
          Gets the closable attribute of this DocumentComponent.
 void refocusLastFocusedComponent()
          Set the last focused component to focus.
 void removeDocumentComponentListener(DocumentComponentListener l)
          Removes the specified titled frame listener so that it no longer receives titled frame events from this titled frame.
 void removePropertyChangeListener(PropertyChangeListener listener)
          Removes a PropertyChangeListener from the listener list.
 void removePropertyChangeListener(String propertyName, PropertyChangeListener listener)
          Removes a PropertyChangeListener from the listener list for a specific property.
protected  void renamePreviousState(String old, String name, com.jidesoft.document.PreviousState previousState)
           
 void setAllowClosing(boolean allowClosing)
          Sets allow closing.
 void setAllowMoving(boolean allowMoving)
          Sets allow moving.
 void setBackground(Color background)
          Sets the background.
 void setClosable(boolean closable)
          Sets the closable attribute.
 void setComponent(JComponent component)
          Sets the component.
 void setDefaultFocusComponent(Component defaultFocusComponent)
          Sets the default focus component for the document component.
 void setDockPreviousState(com.jidesoft.document.PreviousState dockPreviousState)
           
protected  void setDocumentPane(IDocumentPane documentPane)
          When this DocumentComponent is added to a DocumentPane, this method will be called.
 void setFloatPreviousState(com.jidesoft.document.PreviousState floatPreviousState)
           
 void setForeground(Color foreground)
          Sets the foreground.
 void setIcon(Icon icon)
          Sets the icon.
protected  void setLastFocusedComponent(Component lastFocusedComponent)
          Sets the sub-component of the document component which currently has focus.
 void setName(String name)
          Sets the name.
 void setTitle(String title)
          Sets the title.
 void setTooltip(String tooltip)
          Sets the tooltip.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PROPERTY_ICON

public static final String PROPERTY_ICON
See Also:
Constant Field Values

PROPERTY_TITLE

public static final String PROPERTY_TITLE
See Also:
Constant Field Values

PROPERTY_TOOLTIP

public static final String PROPERTY_TOOLTIP
See Also:
Constant Field Values

PROPERTY_BACKGROUND

public static final String PROPERTY_BACKGROUND
See Also:
Constant Field Values

PROPERTY_FOREGROUND

public static final String PROPERTY_FOREGROUND
See Also:
Constant Field Values

PROPERTY_COMPONENT

public static final String PROPERTY_COMPONENT
See Also:
Constant Field Values

PROPERTY_CLOSABLE

public static final String PROPERTY_CLOSABLE
See Also:
Constant Field Values

PROPERTY_ENABLED

public static final String PROPERTY_ENABLED
See Also:
Constant Field Values
Constructor Detail

DocumentComponent

public DocumentComponent(JComponent component,
                         String name)
Creates a DocumentComponent with component and name, but no icon.

Parameters:
component - the component of the document
name - the name of the document. It has to unique within the same DocumentPane. If you try to create two DocumentComponents with the same and try to open them in DocumentPane, only the first one will be opened because the name is the same. If the title is not specified, we will display the name on the tab. But if you specified the title, the name will never appear anywhere in the UI. In the other word, the name could be non-localized string and the title should be localized.

DocumentComponent

public DocumentComponent(JComponent component,
                         String name,
                         String title)
Creates a DocumentComponent with component, name and title, but no icon.

Parameters:
component - the component of the document
name - the name of the document. It has to unique within the same DocumentPane. If you try to create two DocumentComponents with the same and try to open them in DocumentPane, only the first one will be opened because the name is the same. If the title is not specified, we will display the name on the tab. But if you specified the title, the name will never appear anywhere in the UI. In the other word, the name could be non-localized string and the title should be localized.
title - the title of the document. It will be displayed on the tab on a DocumentPane. The title should be a localized string.

DocumentComponent

public DocumentComponent(JComponent component,
                         String name,
                         String title,
                         Icon icon)
Creates a DocumentComponent with component, name, title, and icon.

Parameters:
component - the component of the document
name - the name of the document. It has to unique within the same DocumentPane. If you try to create two DocumentComponents with the same and try to open them in DocumentPane, only the first one will be opened because the name is the same. If the title is not specified, we will display the name on the tab. But if you specified the title, the name will never appear anywhere in the UI. In the other word, the name could be non-localized string and the title should be localized.
title - the title of the document. It will be displayed on the tab on a DocumentPane. The title should be a localized string.
icon - the icon for the document It will be displayed on the tab on a DocumentPane.
Method Detail

getDocumentPane

public IDocumentPane getDocumentPane()
Gets the DocumentPane where this DocumentComponent is added to.

Returns:
DocumentPane whose has this DocumentComponent

cleanup

public void cleanup()

setDocumentPane

protected void setDocumentPane(IDocumentPane documentPane)
When this DocumentComponent is added to a DocumentPane, this method will be called.

Parameters:
documentPane - the document pane where the document component is added.

getName

public String getName()
Gets the name of the document.

Returns:
the name

setName

public void setName(String name)
Sets the name.

Please note, Name is passed in from constructor of DocumentComponent. End user shouldn't call setName directly once it is added to document pane. If you want to change the name, use DocumentPane.renameDocument(java.lang.String, java.lang.String).

Parameters:
name - name to be set

renamePreviousState

protected void renamePreviousState(String old,
                                   String name,
                                   com.jidesoft.document.PreviousState previousState)

getTitle

public String getTitle()
Gets the title.

Returns:
the title

setTitle

public void setTitle(String title)
Sets the title.

Parameters:
title - title to be set

getTooltip

public String getTooltip()
Gets the tooltip.

Returns:
the tooltip

setTooltip

public void setTooltip(String tooltip)
Sets the tooltip.

Parameters:
tooltip - tooltip to be set

getIcon

public Icon getIcon()
Gets the icon.

Returns:
the icon

setIcon

public void setIcon(Icon icon)
Sets the icon.

Parameters:
icon - icon to be set

getBackground

public Color getBackground()
Gets the background.

Returns:
the background

setBackground

public void setBackground(Color background)
Sets the background.

Parameters:
background - background to be set

getForeground

public Color getForeground()
Gets the foreground.

Returns:
the foreground

setForeground

public void setForeground(Color foreground)
Sets the foreground.

Parameters:
foreground - foreground to be set

getComponent

public JComponent getComponent()
Gets the component.

Returns:
component

setComponent

public void setComponent(JComponent component)
Sets the component.

Parameters:
component - component to be set

getDisplayTitle

public String getDisplayTitle()
The title to be displayed. By default it will return whatever getTitle() return.

Returns:
the display title

setAllowClosing

public void setAllowClosing(boolean allowClosing)
Sets allow closing. If true, the document cannot be closed. user can change the value in documentComponentClosing event to prevent document from being closed.

Parameters:
allowClosing - whether the document is allowed to be closed.

allowClosing

public boolean allowClosing()
Allow this document closing. By default it return true. User can override this method to return based on condition. A typical user case is: add a DocumentComponentListener. In documentComponentClosing, make this method return to false to prevent it from being closed.

Returns:
whether allow closing

setAllowMoving

public void setAllowMoving(boolean allowMoving)
Sets allow moving. If true, the document cannot be moved. user can change the value in documentComponentMoving event to prevent document from being moved.

Parameters:
allowMoving - whether the document is allowed to be moved.

allowMoving

public boolean allowMoving()
Allow this document moving. By default it return true. User can override this method to return based on condition. A typical user case is: add a DocumentComponentListener. In documentComponentMoving, make this method return to false to prevent it from being moved.

Returns:
whether allow moving

addDocumentComponentListener

public void addDocumentComponentListener(DocumentComponentListener l)
Adds the specified listener to receive internal frame events from this titled frame.

Parameters:
l - the titled frame listener

removeDocumentComponentListener

public void removeDocumentComponentListener(DocumentComponentListener l)
Removes the specified titled frame listener so that it no longer receives titled frame events from this titled frame.

Parameters:
l - the titled frame listener

getDocumentComponentListeners

public DocumentComponentListener[] getDocumentComponentListeners()
Returns an array of all the DocumentComponentListeners added to this DockableFrame with addDocumentComponentListener.

Returns:
all of the DocumentComponentListeners added or an empty array if no listeners have been added

getDefaultFocusComponent

public Component getDefaultFocusComponent()
Gets the default focus component for the document component. When the dockable frame is activated for the first time, this component will get focus.

See also setDefaultFocusComponent, getLastFocusedComponent, setLastFocusedComponent

Returns:
the default component.

setDefaultFocusComponent

public void setDefaultFocusComponent(Component defaultFocusComponent)
Sets the default focus component for the document component. When the dockable frame is activated for the first time, this component will get focus.

See also getDefaultFocusComponent, getLastFocusedComponent, setLastFocusedComponent

Parameters:
defaultFocusComponent - the component which should receive focus if the document is activated for the first time.

getLastFocusedComponent

public Component getLastFocusedComponent()
Gets the last sub-component of the document component which held focus. When the dockable frame is reactivated after being deactivated, this component will get focus returned to it.

See also setLastFocusedComponent, getDefaultFocusComponent, setDefaultFocusComponent

Returns:
the last-focused sub-component

setLastFocusedComponent

protected void setLastFocusedComponent(Component lastFocusedComponent)
Sets the sub-component of the document component which currently has focus. When the dockable frame is reactivated after being deactivated, this component will get focus returned to it.

See also getLastFocusedComponent, getDefaultFocusComponent, setDefaultFocusComponent

Parameters:
lastFocusedComponent - last-focused sub-component

refocusLastFocusedComponent

public void refocusLastFocusedComponent()
Set the last focused component to focus. This method is used when the document component is selected.


addPropertyChangeListener

public void addPropertyChangeListener(PropertyChangeListener listener)
Adds a PropertyChangeListener to the listener list.

Parameters:
listener - the PropertyChangeListener to be added
See Also:
removePropertyChangeListener(java.beans.PropertyChangeListener), getPropertyChangeListeners(), addPropertyChangeListener(java.lang.String, java.beans.PropertyChangeListener)

removePropertyChangeListener

public void removePropertyChangeListener(PropertyChangeListener listener)
Removes a PropertyChangeListener from the listener list. This method should be used to remove PropertyChangeListeners that were registered for all bound properties of this class.

If listener is null, no exception is thrown and no action is performed.

Parameters:
listener - the PropertyChangeListener to be removed
See Also:
addPropertyChangeListener(java.beans.PropertyChangeListener), getPropertyChangeListeners(), removePropertyChangeListener(java.lang.String, java.beans.PropertyChangeListener)

getPropertyChangeListeners

public PropertyChangeListener[] getPropertyChangeListeners()
Returns an array of all the property change listeners registered on this component.

Returns:
all of this component's PropertyChangeListeners or an empty array if no property change listeners are currently registered
Since:
1.4
See Also:
addPropertyChangeListener(java.beans.PropertyChangeListener), removePropertyChangeListener(java.beans.PropertyChangeListener), getPropertyChangeListeners(java.lang.String), PropertyChangeSupport.getPropertyChangeListeners()

addPropertyChangeListener

public void addPropertyChangeListener(String propertyName,
                                      PropertyChangeListener listener)
Adds a PropertyChangeListener to the listener list for a specific property.

Parameters:
propertyName - one of the property names listed above
listener - the PropertyChangeListener to be added
See Also:
removePropertyChangeListener(java.lang.String, java.beans.PropertyChangeListener), getPropertyChangeListeners(java.lang.String), addPropertyChangeListener(java.lang.String, java.beans.PropertyChangeListener)

removePropertyChangeListener

public void removePropertyChangeListener(String propertyName,
                                         PropertyChangeListener listener)
Removes a PropertyChangeListener from the listener list for a specific property. This method should be used to remove PropertyChangeListeners that were registered for a specific bound property.

If listener is null, no exception is thrown and no action is performed.

Parameters:
propertyName - a valid property name
listener - the PropertyChangeListener to be removed
See Also:
addPropertyChangeListener(java.lang.String, java.beans.PropertyChangeListener), getPropertyChangeListeners(java.lang.String), removePropertyChangeListener(java.beans.PropertyChangeListener)

getPropertyChangeListeners

public PropertyChangeListener[] getPropertyChangeListeners(String propertyName)
Returns an array of all the listeners which have been associated with the named property.

Parameters:
propertyName - the property name.
Returns:
all of the PropertyChangeListeners associated with the named property or an empty array if no listeners have been added
See Also:
addPropertyChangeListener(java.lang.String, java.beans.PropertyChangeListener), removePropertyChangeListener(java.lang.String, java.beans.PropertyChangeListener), getPropertyChangeListeners()

firePropertyChange

protected void firePropertyChange(String propertyName,
                                  Object oldValue,
                                  Object newValue)
Support for reporting bound property changes for Object properties. This method can be called when a bound property has changed and it will send the appropriate PropertyChangeEvent to any registered PropertyChangeListeners.

Parameters:
propertyName - the property whose value has changed
oldValue - the property's previous value
newValue - the property's new value

firePropertyChange

protected void firePropertyChange(String propertyName,
                                  boolean oldValue,
                                  boolean newValue)
Support for reporting bound property changes for boolean properties. This method can be called when a bound property has changed and it will send the appropriate PropertyChangeEvent to any registered PropertyChangeListeners.

Parameters:
propertyName - the property whose value has changed
oldValue - the property's previous value
newValue - the property's new value

firePropertyChange

protected void firePropertyChange(String propertyName,
                                  int oldValue,
                                  int newValue)
Support for reporting bound property changes for integer properties. This method can be called when a bound property has changed and it will send the appropriate PropertyChangeEvent to any registered PropertyChangeListeners.

Parameters:
propertyName - the property whose value has changed
oldValue - the property's previous value
newValue - the property's new value

isClosable

public boolean isClosable()
Gets the closable attribute of this DocumentComponent. By default, all DocumentComponents can be closed by clicking on the close button. If this attribute is false, the close button will not be visible if the close button is on tab.

Returns:
true if it can be closed. Otherwise false.

setClosable

public void setClosable(boolean closable)
Sets the closable attribute.

Parameters:
closable - whether the document can be closed.

getDockPreviousState

public com.jidesoft.document.PreviousState getDockPreviousState()

setDockPreviousState

public void setDockPreviousState(com.jidesoft.document.PreviousState dockPreviousState)

getFloatPreviousState

public com.jidesoft.document.PreviousState getFloatPreviousState()

setFloatPreviousState

public void setFloatPreviousState(com.jidesoft.document.PreviousState floatPreviousState)

JIDE 3.5.15