ilog.views.appframe.swing
Class IlvSwingMainWindow

java.lang.Object
  extended by ilog.views.appframe.docview.IlvAbstractMainWindow
      extended by ilog.views.appframe.swing.IlvSwingMainWindow
All Implemented Interfaces:
IlvMainWindow

public class IlvSwingMainWindow
extends IlvAbstractMainWindow

Defines an IlvMainWindow associated with a Swing component like a JFrame or a Container.
This class may either be directly used as is for specifying an existing frame as a main window to an application or encapsulated and delegated to in order to implement the IlvMainWindow interface; for example, for a subclass of the JFrame class.


Field Summary
static String DEFAULT_SETTINGS_NAME
          Default name for main window within the settings.
static String ICON_ATTRIBUTE
          Name of the settings attribute that provides the icon of the associated JFrame.
static String SHOW_HIDE_STATUS_BAR_CMD
          Action command key for the action that shows or hides the status bar.
static String SHOW_STATUS_BAR_ATTRIBUTE
          Name of the settings attribute that stores the visibility of the status bar.
static String SWING_MAIN_WINDOW_SETTINGS_TYPE
          Type of settings element that provides settings for a Swing main window.
 
Fields inherited from interface ilog.views.appframe.docview.IlvMainWindow
DEFAULT_CONTAINER_TEMPLATE_NAME
 
Constructor Summary
IlvSwingMainWindow(Container container)
          Constructs a new IlvSwingMainWindow associated with the specified container.
IlvSwingMainWindow(Container container, boolean dockingBars, boolean dockingPanes)
          Constructs a new IlvSwingMainWindow associated with the specified container.
IlvSwingMainWindow(JFrame frame)
          Constructs a new IlvSwingMainWindow associated with the specified frame.
IlvSwingMainWindow(JFrame frame, boolean dockingBars, boolean dockingPanes)
          Constructs a new IlvSwingMainWindow associated with the specified frame.
 
Method Summary
static boolean AddViews(IlvViewContainer container, Container clientContainer, IlvDocumentView[] views)
          Default mechanism for adding views to a container.
 void close()
          Close the main frame and its associated application.
 void containerActivated(IlvViewContainer viewContainer)
          Invoked when a view container owned by this main window has been activated.
 IlvViewContainer getActiveViewContainer()
          Returns the active document view container.
 Applet getApplet()
          Returns the applet used to initialize the main window.
 IlvApplication getApplication()
          Returns the application of the main window.
 Container getContainer()
          Returns the main container of the main window.
 IlvDockingArea getDockingArea()
          Returns the docking area associated with this main window.
 IlvDockingBarArea getDockingBarArea()
          Returns the docking bar area associated with this main window.
 URL[] getFileChooserChoices()
          Returns the array of URLs that can be selectable from the applet file chooser.
 URL getFileChooserHTMLPage()
          Returns the URL to the HTML page that is displayed by the main file chooser of the application.
 JFrame getFrame()
          Returns the main JFrame that this main window is linked to - can be null.
 Object[] getMainBars()
          Gets the menu bars and toolbars of the main window that do not depend on a specific document type.
 IlvMDIClient getMDIClient()
          Returns the MDI client of the frame.
 Container getMDIClientParent()
          Returns the container that contains the MDI client component.
 IlvSettings getSettings()
          Returns the settings that initialize the Swing main window.
 IlvSettingsElement getSettingsElement()
          Returns the settings element that provides the settings for this Swing main window.
 String getSettingsName()
          Returns the name that identifies the main window within the settings.
 IlvSettingsQuery getSettingsQuery()
          Returns the query that selects the settings element that provides the settings of this main window.
 String getSettingsType()
          Returns the type of the settings elements that provides the settings for Swing main windows.
 IlvStatusBar getStatusBar()
          Gets the status bar contained within this main panel.
 boolean isStatusBarVisible()
          Determines whether the status bar is shown or hidden.
protected  void localeSettingsChanged()
          Invoked when the locale settings of the application have changed.
 void readSettings(IlvSettingsElement settingsElement)
          Reads the settings of the main window.
 void registerActionMethod(String command, String methodName)
          Registers a method to be called when performing the specified action.
 void registerActionStateMethod(String command, String methodName)
          Registers a method to be called when updating the specified action.
 void registerStaticContainer(String name, IlvViewContainer container)
          Registers the specified view container as a static container within the Swing main window.
 void setApplication(IlvApplication application)
          Sets the application associated with the main window.
 void setContainer(Container container)
          Sets the specified container as the main window of an application.
 void setFileChooserChoices(URL[] urls)
          Specifies an array of URLs that can be selected from the applet file chooser.
 void setFileChooserHTMLPage(URL url)
          Specifies a URL to an HTML page that is displayed by the main file chooser of the application for selecting a document file.
 void setFrame(JFrame frame)
          Sets the main JFrame that this main window is linked to - can be null.
 void setMDIClient(IlvMDIClient mdiClient)
          Sets the MDI client of the frame.
 void setMDIClientParent(Container container)
          Specifies the container that will directly contain the MDI client component responsible for managing MDI child windows.
 void setSettings(IlvSettings settings)
          Sets the settings that initialize the Swing main window.
 void setSettingsElement(IlvSettingsElement element)
          Forces the settings of the Swing main window to be read and written from the specified settings element.
 void setSettingsName(String name)
          Sets the name that identifies the main window within the settings.
 void setSettingsQuery(IlvSettingsQuery query)
          Sets the query that selects the settings element that provides the settings for this main window.
 void setSettingsSerializer(IlvSettingsSerializer serializer)
          Replaces the default settings serializer of this Swing main window with the specified settings serializer.
 void setSettingsType(String settingsType)
          Sets the type of the settings elements that provides the settings for Swing main windows.
 void setStatusBarVisible(boolean show)
          Shows or hides a status bar in the associated JFrame.
 boolean unregisterStaticContainer(IlvViewContainer container)
          Unregisters the specified view container from the main window.
 void writeSettings(IlvSettingsElement settingsElement)
          Writes the settings of the main window.
 
Methods inherited from class ilog.views.appframe.docview.IlvAbstractMainWindow
addContainerTemplate, getContainerTemplate, getContainerTemplateName, getContainerTemplates, registerStaticView, removeContainerTemplate, unregisterStaticView
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ICON_ATTRIBUTE

public static final String ICON_ATTRIBUTE
Name of the settings attribute that provides the icon of the associated JFrame.

See Also:
Constant Field Values

SWING_MAIN_WINDOW_SETTINGS_TYPE

public static final String SWING_MAIN_WINDOW_SETTINGS_TYPE
Type of settings element that provides settings for a Swing main window.

See Also:
Constant Field Values

DEFAULT_SETTINGS_NAME

public static final String DEFAULT_SETTINGS_NAME
Default name for main window within the settings.

See Also:
Constant Field Values

SHOW_STATUS_BAR_ATTRIBUTE

public static final String SHOW_STATUS_BAR_ATTRIBUTE
Name of the settings attribute that stores the visibility of the status bar.

See Also:
Constant Field Values

SHOW_HIDE_STATUS_BAR_CMD

public static final String SHOW_HIDE_STATUS_BAR_CMD
Action command key for the action that shows or hides the status bar.

See Also:
Constant Field Values
Constructor Detail

IlvSwingMainWindow

public IlvSwingMainWindow(JFrame frame,
                          boolean dockingBars,
                          boolean dockingPanes)
Constructs a new IlvSwingMainWindow associated with the specified frame.

Parameters:
frame - The frame to be seen as a main window by the application.
dockingBars - If true, the main window will create a new IlvDockingBarArea instance and add it, so that it fits all the content pane of the specified frame; if false, no docking bar area will be created.
dockingPanes - If true, the main window will allow dockable panes; if false, the specified frame will not contain a docking area.
See Also:
setFrame(javax.swing.JFrame), getFrame(), getApplication(), setApplication(ilog.views.appframe.IlvApplication)

IlvSwingMainWindow

public IlvSwingMainWindow(JFrame frame)
Constructs a new IlvSwingMainWindow associated with the specified frame.

Parameters:
frame - The frame to be seen as a main window by the application.
See Also:
setFrame(javax.swing.JFrame), getFrame(), getApplication(), setApplication(ilog.views.appframe.IlvApplication)

IlvSwingMainWindow

public IlvSwingMainWindow(Container container,
                          boolean dockingBars,
                          boolean dockingPanes)
Constructs a new IlvSwingMainWindow associated with the specified container.

Parameters:
container - The container to be seen as a main window by the application.
dockingBars - If true, the main window will create a new IlvDockingBarArea instance and add it, so that it fits all the content pane of the specified frame; if false, no docking bar area will be created.
dockingPanes - If true, the main window will allow dockable panes; if false, the specified frame will not contain a docking area.
See Also:
setContainer(java.awt.Container), getContainer(), getApplication()

IlvSwingMainWindow

public IlvSwingMainWindow(Container container)
Constructs a new IlvSwingMainWindow associated with the specified container.

Parameters:
container - The container to be seen as a main window by the application.
See Also:
setContainer(java.awt.Container), getContainer(), getApplication()
Method Detail

getFrame

public JFrame getFrame()
Returns the main JFrame that this main window is linked to - can be null.

See Also:
setFrame(javax.swing.JFrame)

setFrame

public void setFrame(JFrame frame)
Sets the main JFrame that this main window is linked to - can be null. The content pane of the frame is set as the main container of this main window and is the parent of the MDI client component.

Parameters:
frame - The main frame linked to this main window.

setContainer

public void setContainer(Container container)
Sets the specified container as the main window of an application.

Parameters:
container - The container to be seen as a main window by an application.
See Also:
setFrame(javax.swing.JFrame)

getContainer

public Container getContainer()
Returns the main container of the main window.


getApplication

public IlvApplication getApplication()
Returns the application of the main window.

Specified by:
getApplication in interface IlvMainWindow
Specified by:
getApplication in class IlvAbstractMainWindow
Returns:
The application.
See Also:
IlvAbstractMainWindow.setApplication(ilog.views.appframe.IlvApplication)

close

public void close()
Close the main frame and its associated application.


registerStaticContainer

public void registerStaticContainer(String name,
                                    IlvViewContainer container)
Registers the specified view container as a static container within the Swing main window.

This view container is not created when a document is created, but has been created with the main window itself. Typically, it can be defined at design time in an IDE when designing the main frame by inserting an instance of a view container within the main frame.

When a document becomes active, for example, if a container containing one of its view(s) becomes active, the views of the specified container are set the new active document by setting the ilog.views.appframe.docview.IlvDocumentView#DOCUMENT_PROPERTY} of the view to this document and its method IlvDocumentView.initializeView(ilog.views.appframe.docview.IlvDocument) is called with the new active document as the parameter.

Specified by:
registerStaticContainer in interface IlvMainWindow
Overrides:
registerStaticContainer in class IlvAbstractMainWindow
Parameters:
name - The name that identifies this view and that must be used if calling the method IlvAbstractMainWindow.unregisterStaticView(ilog.views.appframe.docview.IlvDocumentView). This name also identifies a single container template created for this view and must then be unique among all the container templates added to this main window.
container - The static container to register.
See Also:
unregisterStaticContainer(ilog.views.appframe.docview.IlvViewContainer)

unregisterStaticContainer

public boolean unregisterStaticContainer(IlvViewContainer container)
Unregisters the specified view container from the main window.

Specified by:
unregisterStaticContainer in interface IlvMainWindow
Overrides:
unregisterStaticContainer in class IlvAbstractMainWindow
Parameters:
container - The static container to unregister.
Returns:
true if the specified container was previously registered to this main window; false otherwise.
See Also:
registerStaticContainer(java.lang.String, ilog.views.appframe.docview.IlvViewContainer)

containerActivated

public void containerActivated(IlvViewContainer viewContainer)
Invoked when a view container owned by this main window has been activated.

By default, the first focusable component of the active view of the view container is set the focus.

This method can be overridden for managing its own focus strategy.

Specified by:
containerActivated in interface IlvMainWindow
Overrides:
containerActivated in class IlvAbstractMainWindow
Parameters:
viewContainer - the view container that has been activated.

setMDIClientParent

public void setMDIClientParent(Container container)
Specifies the container that will directly contain the MDI client component responsible for managing MDI child windows. By default, this container is the content pane of the frame specified with the setFrame method.

Parameters:
container - The container that will contain the MDI client component.
See Also:
getMDIClientParent(), getMDIClient(), setMDIClient(ilog.views.appframe.swing.mdi.IlvMDIClient)

getMDIClientParent

public Container getMDIClientParent()
Returns the container that contains the MDI client component. By default, the MDI client container is the content pane of the frame specified with the setMainFrame method.

See Also:
setMDIClient(ilog.views.appframe.swing.mdi.IlvMDIClient)

setMDIClient

public void setMDIClient(IlvMDIClient mdiClient)
Sets the MDI client of the frame.


getMDIClient

public IlvMDIClient getMDIClient()
Returns the MDI client of the frame.


getActiveViewContainer

public IlvViewContainer getActiveViewContainer()
Returns the active document view container.

Returns:
The active document view container.

getMainBars

public Object[] getMainBars()
Gets the menu bars and toolbars of the main window that do not depend on a specific document type. The implementation of this method returns the menu bar of the window (accessed with the getJMenuBar and setJMenuBar methods) if it exists, plus all the toolbars that are docked or floating in this frame.

Returns:
An array of components, each component being either a JToolBar instance or a JMenuBar instance.

setApplication

public void setApplication(IlvApplication application)
Sets the application associated with the main window.

Specified by:
setApplication in interface IlvMainWindow
Overrides:
setApplication in class IlvAbstractMainWindow
Parameters:
application - The application of the window.
See Also:
IlvAbstractMainWindow.getApplication()

getSettingsType

public String getSettingsType()
Returns the type of the settings elements that provides the settings for Swing main windows.

Returns:
The SWING_MAIN_WINDOW_SETTINGS_TYPE string if no settings type has been specified with the method setSettingsType(java.lang.String).
See Also:
readSettings(ilog.views.appframe.settings.IlvSettingsElement), setSettingsType(java.lang.String)

setSettingsType

public void setSettingsType(String settingsType)
Sets the type of the settings elements that provides the settings for Swing main windows.

Parameters:
settingsType - The new settings type.
See Also:
readSettings(ilog.views.appframe.settings.IlvSettingsElement), getSettingsType(), getSettingsQuery()

getSettingsName

public String getSettingsName()
Returns the name that identifies the main window within the settings. It corresponds to the value of the name attribute of the settings element that provides the settings for the associated object. If no name has been specified using the method setSettingsName(java.lang.String), null will be returned.

Returns:
The settings name.
See Also:
setSettingsName(java.lang.String), getSettingsElement(), getSettingsQuery()

setSettingsName

public void setSettingsName(String name)
Sets the name that identifies the main window within the settings.

Parameters:
name - The new settings name.

setSettingsQuery

public void setSettingsQuery(IlvSettingsQuery query)
Sets the query that selects the settings element that provides the settings for this main window.

Parameters:
query - The new settings query.
See Also:
getSettingsQuery()

getSettingsQuery

public IlvSettingsQuery getSettingsQuery()
Returns the query that selects the settings element that provides the settings of this main window.

If a query has been specified with the method setSettingsQuery(ilog.views.appframe.settings.IlvSettingsQuery), it will be returned. Otherwise, a query is built for selecting a settings root element with the type returned by getSettingsType() and the value of the name attribute equal to the name returned by getSettingsName(). If getSettingsName() returns null, the query selects the first root element it finds with the settings type given by the method getSettingsType().

Returns:
The settings query.
See Also:
setSettingsQuery(ilog.views.appframe.settings.IlvSettingsQuery), #see #getSettingsType

setSettingsElement

public void setSettingsElement(IlvSettingsElement element)
Forces the settings of the Swing main window to be read and written from the specified settings element. This method overrides the settings element that is selected by default within the settings of the application with the query getSettingsQuery().

Parameters:
element - The settings element that provides the settings for the Swing main window.
See Also:
getSettingsElement()

getSettingsElement

public IlvSettingsElement getSettingsElement()
Returns the settings element that provides the settings for this Swing main window. If a settings element has been specified with the setSettingsElement(ilog.views.appframe.settings.IlvSettingsElement) method, it will be returned. Otherwise, the settings element is selected from the settings given by the application with the query returned by getSettingsQuery().

Returns:
The settings element or null if no settings element could be found.
See Also:
setSettingsElement(ilog.views.appframe.settings.IlvSettingsElement), getSettingsQuery()

getSettings

public IlvSettings getSettings()
Returns the settings that initialize the Swing main window.

Returns:
The settings of the Swing main window.
See Also:
setSettings(ilog.views.appframe.settings.IlvSettings)

setSettings

public void setSettings(IlvSettings settings)
Sets the settings that initialize the Swing main window.

Parameters:
settings - The new settings of the Swing main window.
See Also:
getSettings()

readSettings

public void readSettings(IlvSettingsElement settingsElement)
Reads the settings of the main window. Preferences for the associated frame are read.

Parameters:
settingsElement - The root settings element that contains the preference settings for this main window.

writeSettings

public void writeSettings(IlvSettingsElement settingsElement)
Writes the settings of the main window. Preferences for the associated frame are written.

Parameters:
settingsElement - The root settings element to write the settings to.

getStatusBar

public IlvStatusBar getStatusBar()
Gets the status bar contained within this main panel.

Returns:
The status bar.

localeSettingsChanged

protected void localeSettingsChanged()
Invoked when the locale settings of the application have changed. The title of the associated frame is updated.


setSettingsSerializer

public void setSettingsSerializer(IlvSettingsSerializer serializer)
Replaces the default settings serializer of this Swing main window with the specified settings serializer.

As the default serializer calls the readSettings(ilog.views.appframe.settings.IlvSettingsElement) and writeSettings(ilog.views.appframe.settings.IlvSettingsElement) methods for respectively reading and writing the settings of the main window, this method should not be used by classes that subclass the IlvSwingMainWindow. Instead, the methods readSettings(ilog.views.appframe.settings.IlvSettingsElement) and writeSettings(ilog.views.appframe.settings.IlvSettingsElement) should be overridden.

If this main window instance is used as a support for implementing the IlvMainWindow interface, this method should be called to specify a new settings serializer that typically invokes serialization methods of the implementing class. To keep the default settings serialization, those serialization methods should invoke the readSettings(ilog.views.appframe.settings.IlvSettingsElement) and writeSettings(ilog.views.appframe.settings.IlvSettingsElement) methods of this class.


setStatusBarVisible

public void setStatusBarVisible(boolean show)
Shows or hides a status bar in the associated JFrame.

Parameters:
show - If true, the status bar will be shown. If false, the status bar will be hidden.

isStatusBarVisible

public boolean isStatusBarVisible()
Determines whether the status bar is shown or hidden.

Returns:
true if the status bar is visible; false otherwise.

AddViews

public static boolean AddViews(IlvViewContainer container,
                               Container clientContainer,
                               IlvDocumentView[] views)
Default mechanism for adding views to a container. If the specified array of views contains one view, the content container of the specified container is set a border layout and the view is added to this container with the BorderLayout.CENTER constraint.

Parameters:
container - The container to add views to.
clientContainer - The client container.
views - The array of views to add to the container.
Returns:
true if the specified views could be added to the specified container.

registerActionMethod

public void registerActionMethod(String command,
                                 String methodName)
Registers a method to be called when performing the specified action.

The specified method must have been defined with the following signature:

 public void methodName(ActionEvent e) {
 ...
 }
 

Parameters:
command - The command key of the action to be associated with the specified method.
methodName - The name of the method to associate with the action.

registerActionStateMethod

public void registerActionStateMethod(String command,
                                      String methodName)
Registers a method to be called when updating the specified action.

The specified method must have been defined with the following signature:

 public boolean methodName(Action action) {
 ...
 }
 

Parameters:
command - The command key of the action to be updated.
methodName - The name of the method to associate with the action with the specified command key.

setFileChooserHTMLPage

public void setFileChooserHTMLPage(URL url)
Specifies a URL to an HTML page that is displayed by the main file chooser of the application for selecting a document file.
There are two ways for the specified HTML page to have selectable document files:

Parameters:
url - the URL to the HTML page.
See Also:
getFileChooserHTMLPage()

getFileChooserHTMLPage

public URL getFileChooserHTMLPage()
Returns the URL to the HTML page that is displayed by the main file chooser of the application.

Returns:
The URL of the HTML page.
See Also:
setFileChooserHTMLPage(java.net.URL)

setFileChooserChoices

public void setFileChooserChoices(URL[] urls)
Specifies an array of URLs that can be selected from the applet file chooser. The specified URLs are inserted into the browser HTML page as an HTML array, replacing the first pair of tr tags encountered in the file chooser HTML page template (see setFileChooserHTMLPage(java.net.URL)).

Parameters:
urls - The array of document file URLs that are selectable from the applet file chooser.
See Also:
getFileChooserChoices(), setFileChooserHTMLPage(java.net.URL)

getFileChooserChoices

public URL[] getFileChooserChoices()
Returns the array of URLs that can be selectable from the applet file chooser.

See Also:
setFileChooserChoices(java.net.URL[])

getDockingArea

public IlvDockingArea getDockingArea()
Returns the docking area associated with this main window.


getDockingBarArea

public IlvDockingBarArea getDockingBarArea()
Returns the docking bar area associated with this main window.


getApplet

public Applet getApplet()
Returns the applet used to initialize the main window.

Returns:
The applet.


Copyright © 1996-2007 ILOG S.A. All rights reserved.   Documentation homepage.