ilog.cpl.project
Class IlpProject

java.lang.Object
  extended by ilog.cpl.project.IlpProject
Direct Known Subclasses:
IlpTGOProject

public abstract class IlpProject
extends Object

Abstract class for projects.

This class provides support for storing project information:

Note: This project class is able to handle data sources which are either IlpDefaultDataSource or one of its subclasses. If you are interested in using other data source implementations, refer to methods readCustomDataSource(org.w3c.dom.Element, ilog.cpl.datasource.IlpDataSource) and writeCustomDataSource(org.w3c.dom.Element, ilog.cpl.datasource.IlpDataSource).

Since:
JViews 7.5

Field Summary
static String longDescription
          The name of the predefined project property that holds a longer description of the project.
static String shortDescription
          The name of the predefined project property that holds a short description of the project.
 
Constructor Summary
protected IlpProject()
          Creates an empty project with the default application context.
protected IlpProject(IlpContext cxt)
          Creates an empty project.
  IlpProject(IlpContext cxt, URL url)
          Reads a project from an XML file.
  IlpProject(IlpContext cxt, URL url, boolean validate)
          Reads a project from an XML file.
  IlpProject(URL url)
          Reads a project from an XML file.
 
Method Summary
 void addPropertyChangeListener(PropertyChangeListener listener)
          Adds a listener to property changes in this instance.
 void addPropertyChangeListener(String propertyName, PropertyChangeListener listener)
          Adds a listener interested in the given property.
 void addStyleSheet(String styleSheet)
          Adds a cascading style sheet to this project.
 IlpDataSource getDataSource()
          Returns the data source of this project.
protected abstract  String getProjectSuffix()
          Returns the suffix used for project files".
protected abstract  String getProjectTag()
          Returns the project tag in the XML description.
 URL getProjectURL()
          Returns the URL of the XML description file that this project was read from or written to.
 Object getProperty(String key)
          Returns a property of this project for the context Locale.
 Object getProperty(String key, Locale locale)
          Returns a property of this project, such as its description, the author's name, the creation date, etc.
 String getStyleSheet()
          Returns the first style sheet of this project.
 String[] getStyleSheets()
          Returns all the cascaded style sheets of this project.
 void read(URL url)
          Reads the project description from a URL.
protected  void readCustomDataSource(Element dsElement, IlpDataSource ds)
          This method can be overridden to support data sources that are different from the default data source implementation.
 void removePropertyChangeListener(PropertyChangeListener listener)
          Removes a property change listener.
 void removePropertyChangeListener(String propertyName, PropertyChangeListener listener)
          Removes a listener to the given property.
 void removeStyleSheet(String styleSheet)
          Removes a cascading style sheet from this project.
 void setDataSource(IlpDataSource ds)
          Sets the data source of this project.
 void setStyleSheet(String styleSheet)
          Sets the first style sheet of this project, and removes all the other style sheets.
 void setStyleSheets(String[] styles)
          Replaces all style sheets currently set in this project by the given ones.
 void write(URL url)
          Writes the project description to a URL.
protected  void writeCustomDataSource(Element dsElement, IlpDataSource ds)
          This method can be overridden to support data source that are different from the default data source implementation.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

shortDescription

public static final String shortDescription
The name of the predefined project property that holds a short description of the project. The short description is intended to be displayed in a combo box, for example.

See Also:
Constant Field Values

longDescription

public static final String longDescription
The name of the predefined project property that holds a longer description of the project. The long description is intended to be displayed in a multiline text area or label, and can contain HTML text.

See Also:
Constant Field Values
Constructor Detail

IlpProject

protected IlpProject(IlpContext cxt)
Creates an empty project.


IlpProject

protected IlpProject()
Creates an empty project with the default application context.


IlpProject

public IlpProject(URL url)
           throws IOException
Reads a project from an XML file.

Parameters:
url - The URL of the file containing the XML description of the project.
Throws:
IOException - If an exception occurred while reading the project file.

IlpProject

public IlpProject(IlpContext cxt,
                  URL url)
           throws IOException
Reads a project from an XML file.

Parameters:
cxt - Application context
url - The URL of the file containing the XML description of the project.
Throws:
IOException - If an exception occurred while reading the project file.

IlpProject

public IlpProject(IlpContext cxt,
                  URL url,
                  boolean validate)
           throws IOException
Reads a project from an XML file.

Parameters:
cxt - Application context
url - The URL of the file containing the XML description of the project.
validate - Validates the XML document.
Throws:
IOException - If an exception occurred while reading the project file.
Since:
JViews 8.0
Method Detail

addPropertyChangeListener

public void addPropertyChangeListener(PropertyChangeListener listener)
Adds a listener to property changes in this instance.

Parameters:
listener - Property change listener

addPropertyChangeListener

public void addPropertyChangeListener(String propertyName,
                                      PropertyChangeListener listener)
Adds a listener interested in the given property.

Parameters:
propertyName - Property name
listener - Listener

removePropertyChangeListener

public void removePropertyChangeListener(PropertyChangeListener listener)
Removes a property change listener.

Parameters:
listener - Property change listener

removePropertyChangeListener

public void removePropertyChangeListener(String propertyName,
                                         PropertyChangeListener listener)
Removes a listener to the given property.

Parameters:
propertyName - Property name
listener - Property change listener

getStyleSheet

public String getStyleSheet()
Returns the first style sheet of this project.


getStyleSheets

public String[] getStyleSheets()
Returns all the cascaded style sheets of this project.


setStyleSheet

public void setStyleSheet(String styleSheet)
Sets the first style sheet of this project, and removes all the other style sheets.

Parameters:
styleSheet - The new style sheet.

setStyleSheets

public void setStyleSheets(String[] styles)
Replaces all style sheets currently set in this project by the given ones.

This is a bound property.

Parameters:
styles - The new style sheets.

addStyleSheet

public void addStyleSheet(String styleSheet)
Adds a cascading style sheet to this project.

Parameters:
styleSheet - The style sheet to add.

removeStyleSheet

public void removeStyleSheet(String styleSheet)
Removes a cascading style sheet from this project.

Parameters:
styleSheet - The style sheet to remove.

getDataSource

public IlpDataSource getDataSource()
Returns the data source of this project.


setDataSource

public void setDataSource(IlpDataSource ds)
Sets the data source of this project.

This is a bound property.

Parameters:
ds - The new data source.

getProperty

public Object getProperty(String key,
                          Locale locale)
Returns a property of this project, such as its description, the author's name, the creation date, etc.

Properties are localized, and are retrieved from property files located "next to" the project file. For example, a project saved in the description file file:/somewhere/exampleProject.xml will read its properties from the property files file:/somewhere/exampleProject[_].properties, where [_] is the suffix for the specified Locale, as explained in java.util.ResourceBundle. So, with a French locale, the property file would be file:/somewhere/exampleProject_fr.properties or file:/somewhere/exampleProject_fr_FR.properties. The default property file would be file:/somewhere/exampleProject.properties.

Parameters:
key - The name of the property to retrieve.
locale - The Locale for which the property is to be retrieved.
Returns:
The value of the property, or null if the property is not defined or if no property file could be found for this project and the specified Locale.

getProperty

public Object getProperty(String key)
Returns a property of this project for the context Locale. This method simply calls getProperty(key, Locale.getDefault()).

Parameters:
key - The name of the property to retrieve.
Returns:
The value of the property, or null if the property is not defined or if no property file could be found for this project and the default Locale.

getProjectURL

public URL getProjectURL()
Returns the URL of the XML description file that this project was read from or written to.


getProjectTag

protected abstract String getProjectTag()
Returns the project tag in the XML description.

Returns:
Project tag

getProjectSuffix

protected abstract String getProjectSuffix()
Returns the suffix used for project files".

Returns:
Project suffix

read

public void read(URL url)
          throws IOException
Reads the project description from a URL.

Parameters:
url - The project URL.
Throws:
IOException - If an error occurred while reading the project description.

write

public void write(URL url)
           throws IOException
Writes the project description to a URL.

Parameters:
url - The project URL.
Throws:
IOException - If an error occurred while writing the project description.

readCustomDataSource

protected void readCustomDataSource(Element dsElement,
                                    IlpDataSource ds)
This method can be overridden to support data sources that are different from the default data source implementation.

By default, projects are able to create datasources that are either an IlpDefaultDataSource or one of its subclasses. If you are interested in supporting other types of datasources in your project file, extend this class to read and write the appropriate data source information.

Parameters:
dsElement - datasource DOM element
ds - Data source that has been created according to the javaClass attribute

writeCustomDataSource

protected void writeCustomDataSource(Element dsElement,
                                     IlpDataSource ds)
This method can be overridden to support data source that are different from the default data source implementation.

By default, projects are able to create datasources that are either an IlpDefaultDataSource or one of its subclasses. If you are interested in supporting other types of datasources in your project file, extend this class to read and write the appropriate data source information.

Parameters:
dsElement - datasource DOM element
ds - Data source whose configuration will be stored


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