Class SessionHandle
java.lang.Object
org.eclipse.birt.report.model.api.SessionHandle
Represents the design state -- a session for a user. In the Eclipse
environment, this represents the set of open designs. In the web environment,
this represents open designs and locale for the session. A session has a set
of default values for style properties and a default unit. The session also
has methods to create and open designs.
A session can also provides the mechanism for specified file searching
algorithm. After get an new instance of SessionHandle, an algorithm of how to
search a file should be set by calling
if the default
resource locator is not the expected one.
setResourceLocator(IResourceLocator)
The default resource locator will search in the folder where the design file is located.
- See Also:
-
ResourceLocatorImpl
DesignSession
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected org.eclipse.birt.report.model.core.DesignSession
The implementation of the design session. -
Constructor Summary
ConstructorsConstructorDescriptionSessionHandle
(com.ibm.icu.util.ULocale locale) Constructs a handle for the session with the given locale.SessionHandle
(Locale locale) Deprecated.to use ICU4J, this method is replaced by: SessionHandle(ULocale locale) -
Method Summary
Modifier and TypeMethodDescriptionvoid
activate()
Activates this session within a thread.void
Adds one resource change listener.void
closeAll
(boolean save) Closes all open designs and libraires.Creates a new empty design.createDesign
(String fileName) Creates a new design based on a file name.createDesign
(String fileName, ModuleOption options) Creates a new design based on the file name and the module options.createDesignFromTemplate
(String templateDesignName) Creates a new design based on a template file.createDesignFromTemplate
(String templateDesignName, InputStream is) Creates a new design based a given template file name and input stream.Creates a new empty library.createLibraryFromTemplate
(String templateLibraryName) Creates a new library based on a template file.void
Informs this session some resources is changed.Returns the current session (application) units.static String
Gets resource path.int
Returns the current application rgb color display preference.getDefaultTOCStyle
(String name) Gets default TOC Style.Heading 1 -> Heading 10.getDefaultValue
(String propName) Gets the default value of the specified style property.Deprecated.to use ICU4J, replaced by: public ULocale getLocale()Returns the provider instance which provides the absolute dimension value of predefined font size choice.Gets the resource folder set in this session.Returns the installed resource locator.com.ibm.icu.util.ULocale
Returns the locale of the current session.openDesign
(String fileName) Opens a design with the given the file name.openDesign
(String fileName, InputStream is) Opens a design given a stream to the design and the the file name of the design.openDesign
(String fileName, InputStream is, ModuleOption options) Opens a design given a stream to the design and the the file name of the design.openDesign
(String fileName, ModuleOption options) Opens a design with the given the file name.openDesign
(URL systemId, InputStream is) Opens a design given a stream to the design and the the file name of the design.openDesign
(URL systemId, InputStream is, ModuleOption options) Opens a design given a stream to the design and the the file name of the design.openLibrary
(String fileName) Opens a library with the given the file name.openLibrary
(String fileName, InputStream is) Opens a library given a stream to the design and the the file name of the design.openLibrary
(String fileName, InputStream is, ModuleOption options) Opens a library given a stream to the design and the the file name of the design.openLibrary
(String fileName, ModuleOption options) Opens a library with the given the file name.openLibrary
(URL systemId, InputStream is) Opens a library with the given the file name.openLibrary
(URL systemId, InputStream is, ModuleOption options) Opens a library with the given the file name.openModule
(String fileName) Opens a module regardless of the module type(library or report design).openModule
(String fileName, InputStream is) Opens a module regardless of the module type(library or report design).openModule
(String fileName, InputStream is, ModuleOption options) Opens a module regardless of the module type(library or report design).openModule
(String fileName, ModuleOption options) Opens a module regardless of the module type(library or report design).boolean
Removes one resource change listener.void
saveAll()
Saves all designs and librariesthat need a save.void
setApplicationUnits
(String units) Sets the units to be used by the application.static void
setBirtResourcePath
(String resourcePath) Sets resource path.void
setColorFormat
(int rgbFormat) Sets the rgb color display preference to be used by the application.void
setDefaultValue
(String propName, Object value) Sets the specified default value of style property.void
setResourceFolder
(String resourceFolder) Sets the resource folder for this session.void
setResourceLocator
(IResourceLocator locator) Sets the resource locator for the specified file searching algorithm.
-
Field Details
-
session
protected org.eclipse.birt.report.model.core.DesignSession sessionThe implementation of the design session.
-
-
Constructor Details
-
SessionHandle
Deprecated.to use ICU4J, this method is replaced by: SessionHandle(ULocale locale)Constructs a handle for the session with the given locale.- Parameters:
locale
- the user's locale. If null, then the system locale is assumed.
-
SessionHandle
public SessionHandle(com.ibm.icu.util.ULocale locale) Constructs a handle for the session with the given locale.- Parameters:
locale
- the user's locale which isULocale
. If null, then the system locale is assumed.
-
-
Method Details
-
setBirtResourcePath
Sets resource path.- Parameters:
resourcePath
- the resource path to set. It must be an absolute path based on file system and must present a dictory.
-
getBirtResourcePath
Gets resource path.setBirtResourcePath(String)
- Returns:
- the resource path set in the session
-
activate
public void activate()Activates this session within a thread. Used in the web environment to associate this session with a message thread or that the client user startup a new thread. Required to allow the thread to access localized messages. -
openModule
Opens a module regardless of the module type(library or report design). design.- Parameters:
fileName
- name of the file to open.is
- stream to read the design- Returns:
- handle to the report design
- Throws:
DesignFileException
- If the file is not found, or the file contains fatal errors.
-
openModule
public ModuleHandle openModule(String fileName, InputStream is, ModuleOption options) throws DesignFileException Opens a module regardless of the module type(library or report design). design.- Parameters:
fileName
- name of the file to open.is
- stream to read the designoptions
- the options set for this module- Returns:
- handle to the report design
- Throws:
DesignFileException
- If the file is not found, or the file contains fatal errors.
-
openModule
Opens a module regardless of the module type(library or report design). design.- Parameters:
fileName
- name of the file to open.- Returns:
- handle to the report design
- Throws:
DesignFileException
- If the file is not found, or the file contains fatal errors.
-
openModule
Opens a module regardless of the module type(library or report design). design.- Parameters:
fileName
- name of the file to open.options
- the options set for this module- Returns:
- handle to the report design
- Throws:
DesignFileException
- If the file is not found, or the file contains fatal errors.
-
openDesign
Opens a design with the given the file name.- Parameters:
fileName
- name of the file to open. It may contain the relative/absolute path information. This name must include the file name with the filename extension.- Returns:
- handle to the report design
- Throws:
DesignFileException
- if the file is not found, or the file contains fatal errors.
-
openDesign
public ReportDesignHandle openDesign(String fileName, ModuleOption options) throws DesignFileException Opens a design with the given the file name.- Parameters:
fileName
- name of the file to open. It may contain the relative/absolute path information. This name must include the file name with the filename extension.options
- the options set for this module- Returns:
- handle to the report design
- Throws:
DesignFileException
- if the file is not found, or the file contains fatal errors.
-
openDesign
Opens a design given a stream to the design and the the file name of the design.- Parameters:
fileName
- name of the file to open. Ifnull
, the design will be treated as a new design, and will be saved to a different file. If notnull
, it may contain the relative/absolute path information. This name must include the file name with the filename extension.is
- stream to read the design- Returns:
- handle to the report design
- Throws:
DesignFileException
- If the file is not found, or the file contains fatal errors.
-
openDesign
public ReportDesignHandle openDesign(String fileName, InputStream is, ModuleOption options) throws DesignFileException Opens a design given a stream to the design and the the file name of the design.- Parameters:
fileName
- name of the file to open. Ifnull
, the design will be treated as a new design, and will be saved to a different file. If notnull
, it may contain the relative/absolute path information. This name must include the file name with the filename extension.is
- stream to read the designoptions
- options set for this module- Returns:
- handle to the report design
- Throws:
DesignFileException
- If the file is not found, or the file contains fatal errors.
-
openDesign
Opens a design given a stream to the design and the the file name of the design. *- Parameters:
systemId
- the uri where to find the relative sources for the report. This url is treated as an absolute directory.is
- the input stream to read the design- Returns:
- handle to the report design
- Throws:
DesignFileException
- If the file is not found, or the file contains fatal errors.
-
openDesign
public ReportDesignHandle openDesign(URL systemId, InputStream is, ModuleOption options) throws DesignFileException Opens a design given a stream to the design and the the file name of the design. *- Parameters:
systemId
- the uri where to find the relative sources for the report. This url is treated as an absolute directory.is
- the input stream to read the designoptions
- the options set for this module- Returns:
- handle to the report design
- Throws:
DesignFileException
- If the file is not found, or the file contains fatal errors.
-
openLibrary
Opens a library with the given the file name.- Parameters:
fileName
- name of the file to open. This name must include the file name with the filename extension.- Returns:
- handle to the library
- Throws:
DesignFileException
- if the file is not found, or the file contains fatal errors.
-
openLibrary
Opens a library with the given the file name.- Parameters:
fileName
- name of the file to open. This name must include the file name with the filename extension.options
- the options set for this module- Returns:
- handle to the library
- Throws:
DesignFileException
- if the file is not found, or the file contains fatal errors.
-
openLibrary
Opens a library given a stream to the design and the the file name of the design.- Parameters:
fileName
- name of the file to open. Ifnull
, the library will be treated as a new library, and will be saved to a different file. If notnull
, it may contain the relative/absolute path information. This name must include the file name with the filename extension.is
- the stream to read the library- Returns:
- the library instance
- Throws:
DesignFileException
- If the file is not found, or the file contains fatal errors.
-
openLibrary
public LibraryHandle openLibrary(String fileName, InputStream is, ModuleOption options) throws DesignFileException Opens a library given a stream to the design and the the file name of the design.- Parameters:
fileName
- name of the file to open. Ifnull
, the library will be treated as a new library, and will be saved to a different file. If notnull
, it may contain the relative/absolute path information. This name must include the file name with the filename extension.is
- the stream to read the libraryoptions
- the options set for this module- Returns:
- the library instance
- Throws:
DesignFileException
- If the file is not found, or the file contains fatal errors.
-
openLibrary
Opens a library with the given the file name.- Parameters:
systemId
- the uri where to find the relative sources for the library. This url is treated as an absolute directory.is
- the input stream- Returns:
- handle to the library
- Throws:
DesignFileException
- if the file is not found, or the file contains fatal errors.
-
openLibrary
public LibraryHandle openLibrary(URL systemId, InputStream is, ModuleOption options) throws DesignFileException Opens a library with the given the file name.- Parameters:
systemId
- the uri where to find the relative sources for the library. This url is treated as an absolute directory.is
- the input streamoptions
- the options set for this module- Returns:
- handle to the library
- Throws:
DesignFileException
- if the file is not found, or the file contains fatal errors.
-
createDesign
Creates a new design based on a file name.- Parameters:
fileName
- file name.- Returns:
- A handle to the report design.
-
createDesign
Creates a new design based on the file name and the module options.- Parameters:
fileName
-options
-- Returns:
- new report design handle.
-
createDesignFromTemplate
public ReportDesignHandle createDesignFromTemplate(String templateDesignName) throws DesignFileException Creates a new design based on a template file.- Parameters:
templateDesignName
- The name of the template for the design.- Returns:
- A handle to the report design.
- Throws:
DesignFileException
- If the file is not found, or the file contains fatal errors.
-
createDesignFromTemplate
public ReportDesignHandle createDesignFromTemplate(String templateDesignName, InputStream is) throws DesignFileException Creates a new design based a given template file name and input stream.- Parameters:
templateDesignName
- The name of the template for the design.- Returns:
- A handle to the report design.
- Throws:
DesignFileException
- If the file is not found, or the file contains fatal errors.
-
createLibraryFromTemplate
public LibraryHandle createLibraryFromTemplate(String templateLibraryName) throws DesignFileException Creates a new library based on a template file.- Parameters:
templateLibraryName
- The name of the template for the library.- Returns:
- A handle to the report library.
- Throws:
DesignFileException
- If the file is not found, or the file contains fatal errors.
-
createDesign
Creates a new empty design. This new design is not based on a template.- Returns:
- the handle of the new report design.
-
createLibrary
Creates a new empty library.- Returns:
- the handle of the new library.
-
saveAll
Saves all designs and librariesthat need a save.- Throws:
IOException
- if a save error occurs
-
closeAll
Closes all open designs and libraires.- Parameters:
save
-true
if designs are to be saved before closing- Throws:
IOException
- if a save error occurs
-
setApplicationUnits
Sets the units to be used by the application. These units are independent of those set for the design. The application and design can use the same units, or different units. The application units are those used when getting and setting dimension properties using double (float) values. The possible values are defined inDesignChoiceConstants
and can be one of:UNITS_IN
UNITS_CM
UNITS_MM
UNITS_PT
UNITS_PC
- Parameters:
units
- the units to set for the session -- application- Throws:
PropertyValueException
- ifunits
is not one of the above- See Also:
-
getApplicationUnits
Returns the current session (application) units. The return values are defined inDesignChoiceConstants
and is one of:UNITS_IN
UNITS_CM
UNITS_MM
UNITS_PT
UNITS_PC
- Returns:
- the application units
- See Also:
-
setColorFormat
Sets the rgb color display preference to be used by the application. If the preference is not set the application will use default CSS_ABSOLUTE_FORMAT like "RGB(255,0,0)" for a rgb color display value. The rgbFormat argument is an integer value that may be the following constants defined inColorUtil
:INT_FORMAT
HTML_FORMAT
JAVA_FORMAT
CSS_ABSOLUTE_FORMAT
CSS_RELATIVE_FORMAT
- Parameters:
rgbFormat
- the rgb color display preference to set.- Throws:
PropertyValueException
- ifrgbFormat
is not one of the above.- See Also:
-
ColorPropertyType
-
getColorFormat
public int getColorFormat()Returns the current application rgb color display preference. The return is one of the following constants defined inColorUtil
:INT_FORMAT
HTML_FORMAT
JAVA_FORMAT
CSS_ABSOLUTE_FORMAT
CSS_RELATIVE_FORMAT
- Returns:
- application rgb color display preference
- See Also:
-
setDefaultValue
Sets the specified default value of style property.- Parameters:
propName
- style property namevalue
- default value to set- Throws:
PropertyValueException
- if value is invalid.
-
getDefaultValue
Gets the default value of the specified style property.- Parameters:
propName
- style property name- Returns:
- The default value of this style property. If the default value is not
set, return
null
.
-
setResourceLocator
Sets the resource locator for the specified file searching algorithm.- Parameters:
locator
- the resource locator to be set.
-
getResourceLocator
Returns the installed resource locator.- Returns:
- the resource locator.
-
getLocale
Deprecated.to use ICU4J, replaced by: public ULocale getLocale()Returns the locale of the current session.- Returns:
- the locale of the current session
-
getULocale
public com.ibm.icu.util.ULocale getULocale()Returns the locale of the current session.- Returns:
- the locale of the current session, the return value is of
ULocale
.
-
fireResourceChange
Informs this session some resources is changed. Session will check all opened mudules, all interfered modules will be informed of the changes.Current, only changes of library is supported.
- Parameters:
ev
- the resource change event to fire
-
addResourceChangeListener
Adds one resource change listener. The duplicate listener will not be added.- Parameters:
listener
- the resource change listener to add
-
removeResourceChangeListener
Removes one resource change listener. If the listener not registered, then the request is silently ignored.- Parameters:
listener
- the resource change listener to remove- Returns:
true
iflistener
is successfully removed. Otherwisefalse
.
-
setResourceFolder
Sets the resource folder for this session.- Parameters:
resourceFolder
- the folder to set
-
getResourceFolder
Gets the resource folder set in this session.- Returns:
- the resource folder set in this session
-
getDefaultTOCStyle
Gets default TOC Style.Heading 1 -> Heading 10.- Parameters:
name
- style name- Returns:
- style handle which is read only.
-
getPredefinedFontSizeProvider
Returns the provider instance which provides the absolute dimension value of predefined font size choice.FONT_SIZE_XX_SMALL
FONT_SIZE_X_SMALL
FONT_SIZE_SMALL
FONT_SIZE_MEDIUM
FONT_SIZE_LARGE
FONT_SIZE_X_LARGE
FONT_SIZE_XX_LARGE
- Returns:
- the instance of
IAbsoluteFontSizeValueProvider
-