public abstract class IlpProject extends Object
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)
.
Modifier and Type | Field and Description |
---|---|
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.
|
Modifier | Constructor and Description |
---|---|
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.
|
Modifier and Type | Method and Description |
---|---|
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.
|
public static final String shortDescription
public static final String longDescription
protected IlpProject(IlpContext cxt)
protected IlpProject()
public IlpProject(URL url) throws IOException
url
- The URL of the file containing the XML description of the project.IOException
- If an exception occurred while reading the project file.public IlpProject(IlpContext cxt, URL url) throws IOException
cxt
- Application contexturl
- The URL of the file containing the XML description of the project.IOException
- If an exception occurred while reading the project file.public IlpProject(IlpContext cxt, URL url, boolean validate) throws IOException
cxt
- Application contexturl
- The URL of the file containing the XML description of the project.validate
- Validates the XML document.IOException
- If an exception occurred while reading the project file.public void addPropertyChangeListener(PropertyChangeListener listener)
listener
- Property change listenerpublic void addPropertyChangeListener(String propertyName, PropertyChangeListener listener)
propertyName
- Property namelistener
- Listenerpublic void removePropertyChangeListener(PropertyChangeListener listener)
listener
- Property change listenerpublic void removePropertyChangeListener(String propertyName, PropertyChangeListener listener)
propertyName
- Property namelistener
- Property change listenerpublic String getStyleSheet()
public String[] getStyleSheets()
public void setStyleSheet(String styleSheet)
styleSheet
- The new style sheet.public void setStyleSheets(String[] styles)
This is a bound property.
styles
- The new style sheets.public void addStyleSheet(String styleSheet)
styleSheet
- The style sheet to add.public void removeStyleSheet(String styleSheet)
styleSheet
- The style sheet to remove.public IlpDataSource getDataSource()
public void setDataSource(IlpDataSource ds)
This is a bound property.
ds
- The new data source.public Object getProperty(String key, Locale locale)
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[_<locale>].properties
,
where [_<locale>]
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
.
key
- The name of the property to retrieve.locale
- The Locale for which the property is to be retrieved.null
if the property
is not defined or if no property file could be found for this project
and the specified Locale.public Object getProperty(String key)
getProperty(key, Locale.getDefault())
.key
- The name of the property to retrieve.null
if the property
is not defined or if no property file could be found for this project
and the default Locale.public URL getProjectURL()
protected abstract String getProjectTag()
protected abstract String getProjectSuffix()
public void read(URL url) throws IOException
url
- The project URL.IOException
- If an error occurred while reading the project description.public void write(URL url) throws IOException
url
- The project URL.IOException
- If an error occurred while writing the project description.protected void readCustomDataSource(Element dsElement, IlpDataSource ds)
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.
dsElement
- datasource DOM elementds
- Data source that has been created according to the
javaClass attributeprotected void writeCustomDataSource(Element dsElement, IlpDataSource ds)
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.
dsElement
- datasource DOM elementds
- Data source whose configuration will be stored© Copyright Rogue Wave Software, Inc. 1997, 2018. All Rights Reserved.