Class SessionHandle
- java.lang.Object
-
- org.eclipse.birt.report.model.api.SessionHandle
-
public class SessionHandle extends java.lang.ObjectRepresents 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
Fields Modifier and Type Field Description protected org.eclipse.birt.report.model.core.DesignSessionsessionThe implementation of the design session.
-
Constructor Summary
Constructors Constructor Description SessionHandle(com.ibm.icu.util.ULocale locale)Constructs a handle for the session with the given locale.SessionHandle(java.util.Locale locale)Deprecated.to use ICU4J, this method is replaced by: SessionHandle(ULocale locale)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description voidactivate()Activates this session within a thread.voidaddResourceChangeListener(IResourceChangeListener listener)Adds one resource change listener.voidcloseAll(boolean save)Closes all open designs and libraires.ReportDesignHandlecreateDesign()Creates a new empty design.ReportDesignHandlecreateDesign(java.lang.String fileName)Creates a new design based on a file name.ReportDesignHandlecreateDesign(java.lang.String fileName, ModuleOption options)Creates a new design based on the file name and the module options.ReportDesignHandlecreateDesignFromTemplate(java.lang.String templateDesignName)Creates a new design based on a template file.ReportDesignHandlecreateDesignFromTemplate(java.lang.String templateDesignName, java.io.InputStream is)Creates a new design based a given template file name and input stream.LibraryHandlecreateLibrary()Creates a new empty library.LibraryHandlecreateLibraryFromTemplate(java.lang.String templateLibraryName)Creates a new library based on a template file.voidfireResourceChange(ResourceChangeEvent ev)Informs this session some resources is changed.java.lang.StringgetApplicationUnits()Returns the current session (application) units.static java.lang.StringgetBirtResourcePath()Gets resource path.intgetColorFormat()Returns the current application rgb color display preference.StyleHandlegetDefaultTOCStyle(java.lang.String name)Gets default TOC Style.Heading 1 -> Heading 10.java.lang.ObjectgetDefaultValue(java.lang.String propName)Gets the default value of the specified style property.java.util.LocalegetLocale()Deprecated.to use ICU4J, replaced by: public ULocale getLocale()IAbsoluteFontSizeValueProvidergetPredefinedFontSizeProvider()Returns the provider instance which provides the absolute dimension value of predefined font size choice.java.lang.StringgetResourceFolder()Gets the resource folder set in this session.IResourceLocatorgetResourceLocator()Returns the installed resource locator.com.ibm.icu.util.ULocalegetULocale()Returns the locale of the current session.ReportDesignHandleopenDesign(java.lang.String fileName)Opens a design with the given the file name.ReportDesignHandleopenDesign(java.lang.String fileName, java.io.InputStream is)Opens a design given a stream to the design and the the file name of the design.ReportDesignHandleopenDesign(java.lang.String fileName, java.io.InputStream is, ModuleOption options)Opens a design given a stream to the design and the the file name of the design.ReportDesignHandleopenDesign(java.lang.String fileName, ModuleOption options)Opens a design with the given the file name.ReportDesignHandleopenDesign(java.net.URL systemId, java.io.InputStream is)Opens a design given a stream to the design and the the file name of the design.ReportDesignHandleopenDesign(java.net.URL systemId, java.io.InputStream is, ModuleOption options)Opens a design given a stream to the design and the the file name of the design.LibraryHandleopenLibrary(java.lang.String fileName)Opens a library with the given the file name.LibraryHandleopenLibrary(java.lang.String fileName, java.io.InputStream is)Opens a library given a stream to the design and the the file name of the design.LibraryHandleopenLibrary(java.lang.String fileName, java.io.InputStream is, ModuleOption options)Opens a library given a stream to the design and the the file name of the design.LibraryHandleopenLibrary(java.lang.String fileName, ModuleOption options)Opens a library with the given the file name.LibraryHandleopenLibrary(java.net.URL systemId, java.io.InputStream is)Opens a library with the given the file name.LibraryHandleopenLibrary(java.net.URL systemId, java.io.InputStream is, ModuleOption options)Opens a library with the given the file name.ModuleHandleopenModule(java.lang.String fileName)Opens a module regardless of the module type(library or report design).ModuleHandleopenModule(java.lang.String fileName, java.io.InputStream is)Opens a module regardless of the module type(library or report design).ModuleHandleopenModule(java.lang.String fileName, java.io.InputStream is, ModuleOption options)Opens a module regardless of the module type(library or report design).ModuleHandleopenModule(java.lang.String fileName, ModuleOption options)Opens a module regardless of the module type(library or report design).booleanremoveResourceChangeListener(IResourceChangeListener listener)Removes one resource change listener.voidsaveAll()Saves all designs and librariesthat need a save.voidsetApplicationUnits(java.lang.String units)Sets the units to be used by the application.static voidsetBirtResourcePath(java.lang.String resourcePath)Sets resource path.voidsetColorFormat(int rgbFormat)Sets the rgb color display preference to be used by the application.voidsetDefaultValue(java.lang.String propName, java.lang.Object value)Sets the specified default value of style property.voidsetResourceFolder(java.lang.String resourceFolder)Sets the resource folder for this session.voidsetResourceLocator(IResourceLocator locator)Sets the resource locator for the specified file searching algorithm.
-
-
-
Constructor Detail
-
SessionHandle
@Deprecated public SessionHandle(java.util.Locale locale)
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 Detail
-
setBirtResourcePath
public static void setBirtResourcePath(java.lang.String resourcePath)
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
public static java.lang.String 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
public ModuleHandle openModule(java.lang.String fileName, java.io.InputStream is) 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 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(java.lang.String fileName, java.io.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
public ModuleHandle openModule(java.lang.String fileName) throws DesignFileException
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
public ModuleHandle openModule(java.lang.String fileName, 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.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
public ReportDesignHandle openDesign(java.lang.String fileName) 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.- Returns:
- handle to the report design
- Throws:
DesignFileException- if the file is not found, or the file contains fatal errors.
-
openDesign
public ReportDesignHandle openDesign(java.lang.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
public ReportDesignHandle openDesign(java.lang.String fileName, java.io.InputStream is) 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 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(java.lang.String fileName, java.io.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
public ReportDesignHandle openDesign(java.net.URL systemId, java.io.InputStream is) 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 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(java.net.URL systemId, java.io.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
public LibraryHandle openLibrary(java.lang.String fileName) throws DesignFileException
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
public LibraryHandle openLibrary(java.lang.String fileName, ModuleOption options) throws DesignFileException
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
public LibraryHandle openLibrary(java.lang.String fileName, java.io.InputStream is) 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 library- Returns:
- the library instance
- Throws:
DesignFileException- If the file is not found, or the file contains fatal errors.
-
openLibrary
public LibraryHandle openLibrary(java.lang.String fileName, java.io.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
public LibraryHandle openLibrary(java.net.URL systemId, java.io.InputStream is) 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 stream- Returns:
- handle to the library
- Throws:
DesignFileException- if the file is not found, or the file contains fatal errors.
-
openLibrary
public LibraryHandle openLibrary(java.net.URL systemId, java.io.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
public ReportDesignHandle createDesign(java.lang.String fileName)
Creates a new design based on a file name.- Parameters:
fileName- file name.- Returns:
- A handle to the report design.
-
createDesign
public ReportDesignHandle createDesign(java.lang.String fileName, ModuleOption options)
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(java.lang.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(java.lang.String templateDesignName, java.io.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(java.lang.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
public ReportDesignHandle createDesign()
Creates a new empty design. This new design is not based on a template.- Returns:
- the handle of the new report design.
-
createLibrary
public LibraryHandle createLibrary()
Creates a new empty library.- Returns:
- the handle of the new library.
-
saveAll
public void saveAll() throws java.io.IOExceptionSaves all designs and librariesthat need a save.- Throws:
java.io.IOException- if a save error occurs
-
closeAll
public void closeAll(boolean save) throws java.io.IOExceptionCloses all open designs and libraires.- Parameters:
save-trueif designs are to be saved before closing- Throws:
java.io.IOException- if a save error occurs
-
setApplicationUnits
public void setApplicationUnits(java.lang.String units) throws PropertyValueExceptionSets 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 inDesignChoiceConstantsand can be one of:UNITS_INUNITS_CMUNITS_MMUNITS_PTUNITS_PC
- Parameters:
units- the units to set for the session -- application- Throws:
PropertyValueException- ifunitsis not one of the above- See Also:
DimensionValue
-
getApplicationUnits
public java.lang.String getApplicationUnits()
Returns the current session (application) units. The return values are defined inDesignChoiceConstantsand is one of:UNITS_INUNITS_CMUNITS_MMUNITS_PTUNITS_PC
- Returns:
- the application units
- See Also:
setApplicationUnits(java.lang.String)
-
setColorFormat
public void setColorFormat(int rgbFormat) throws PropertyValueExceptionSets 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_FORMATHTML_FORMATJAVA_FORMATCSS_ABSOLUTE_FORMATCSS_RELATIVE_FORMAT
- Parameters:
rgbFormat- the rgb color display preference to set.- Throws:
PropertyValueException- ifrgbFormatis 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_FORMATHTML_FORMATJAVA_FORMATCSS_ABSOLUTE_FORMATCSS_RELATIVE_FORMAT
- Returns:
- application rgb color display preference
- See Also:
setColorFormat(int)
-
setDefaultValue
public void setDefaultValue(java.lang.String propName, java.lang.Object value) throws PropertyValueExceptionSets the specified default value of style property.- Parameters:
propName- style property namevalue- default value to set- Throws:
PropertyValueException- if value is invalid.
-
getDefaultValue
public java.lang.Object getDefaultValue(java.lang.String propName)
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
public void setResourceLocator(IResourceLocator locator)
Sets the resource locator for the specified file searching algorithm.- Parameters:
locator- the resource locator to be set.
-
getResourceLocator
public IResourceLocator getResourceLocator()
Returns the installed resource locator.- Returns:
- the resource locator.
-
getLocale
@Deprecated public java.util.Locale 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
public void fireResourceChange(ResourceChangeEvent ev)
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
public void addResourceChangeListener(IResourceChangeListener listener)
Adds one resource change listener. The duplicate listener will not be added.- Parameters:
listener- the resource change listener to add
-
removeResourceChangeListener
public boolean removeResourceChangeListener(IResourceChangeListener listener)
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:
trueiflisteneris successfully removed. Otherwisefalse.
-
setResourceFolder
public void setResourceFolder(java.lang.String resourceFolder)
Sets the resource folder for this session.- Parameters:
resourceFolder- the folder to set
-
getResourceFolder
public java.lang.String getResourceFolder()
Gets the resource folder set in this session.- Returns:
- the resource folder set in this session
-
getDefaultTOCStyle
public StyleHandle getDefaultTOCStyle(java.lang.String name)
Gets default TOC Style.Heading 1 -> Heading 10.- Parameters:
name- style name- Returns:
- style handle which is read only.
-
getPredefinedFontSizeProvider
public IAbsoluteFontSizeValueProvider getPredefinedFontSizeProvider()
Returns the provider instance which provides the absolute dimension value of predefined font size choice.FONT_SIZE_XX_SMALLFONT_SIZE_X_SMALLFONT_SIZE_SMALLFONT_SIZE_MEDIUMFONT_SIZE_LARGEFONT_SIZE_X_LARGEFONT_SIZE_XX_LARGE
- Returns:
- the instance of
IAbsoluteFontSizeValueProvider
-
-