Class LibraryHandle

  • All Implemented Interfaces:
    IModuleModel, org.eclipse.birt.report.model.elements.interfaces.IDesignElementModel, org.eclipse.birt.report.model.elements.interfaces.IInternalLibraryModel, org.eclipse.birt.report.model.elements.interfaces.ILibraryModel

    public class LibraryHandle
    extends LibraryHandleImpl
    implements org.eclipse.birt.report.model.elements.interfaces.ILibraryModel
    Represents the handle of library element. The library contains the resuable element components.
    Content Item Description
    Code Modules Global scripts that apply to the report as a whole.
    Parameters A list of Parameter elements that describe the data that the user can enter when running the report.
    Data Sources The connections used by the report.
    Data Sets Data sets defined in the design.
    Color Palette A set of custom color names as part of the design.
    Styles User-defined styles used to format elements in the report. Each style must have a unique name within the set of styles for this report.
    Page Setup The layout of the master pages within the report.
    Components Reusable report items defined in this design. Report items can extend these items. Defines a "private library" for this design.
    Translations The list of externalized messages specifically for this report.
    Images A list of images embedded in this report.

    There are two cases that this library handle represents:

    • the library file that user opens directly
      In this case, user can take operations as same as design file.
    • the library file that is included in one design file
      User can not take operations, because the included library file is read-only. Any operation on the library file of this type will throw runtime exception.
    • Constructor Detail

      • LibraryHandle

        public LibraryHandle​(org.eclipse.birt.report.model.elements.Library library)
        Constructs one library handle with the given library element.
        Parameters:
        library - library element
    • Method Detail

      • addTranslation

        public void addTranslation​(java.lang.String resourceKey,
                                   java.lang.String locale,
                                   java.lang.String text)
                            throws CustomMsgException
        Description copied from class: ModuleHandleImpl
        Adds a new translation to the design.
        Overrides:
        addTranslation in class ModuleHandleImpl
        Parameters:
        resourceKey - resource key for the message
        locale - the string value of a locale for the translation. Locale should be in java-defined format( en, en-US, zh_CN, etc.)
        text - translated text for the locale
        Throws:
        CustomMsgException - if the resource key is duplicate or missing, or locale is not a valid format.
        See Also:
        ModuleHandleImpl.getTranslation(String, String)
      • dropImage

        public void dropImage​(java.util.List images)
                       throws SemanticException
        Description copied from class: ModuleHandleImpl
        Drops an embedded image handle list from the design. Each one in the list is the instance of EmbeddedImageHandle.
        Overrides:
        dropImage in class ModuleHandleImpl
        Parameters:
        images - the image handle list to remove
        Throws:
        SemanticException - if any image in the list is not found.
      • getComponents

        public SlotHandle getComponents()
        Description copied from class: ModuleHandleImpl
        Returns a slot handle to work with the top-level components within the report.
        Overrides:
        getComponents in class ModuleHandleImpl
        Returns:
        A handle for working with the components.
      • getDataSets

        public SlotHandle getDataSets()
        Description copied from class: ModuleHandleImpl
        Returns a slot handle to work with the data sets within the report. Note that the order of the data sets within the slot is unimportant.
        Overrides:
        getDataSets in class ModuleHandleImpl
        Returns:
        A handle for working with the data sets.
      • getDataSources

        public SlotHandle getDataSources()
        Description copied from class: ModuleHandleImpl
        Returns a slot handle to work with the data sources within the report. Note that the order of the data sources within the slot is unimportant.
        Overrides:
        getDataSources in class ModuleHandleImpl
        Returns:
        A handle for working with the data sources.
      • getFlattenParameters

        public java.util.List getFlattenParameters()
        Description copied from class: ModuleHandleImpl
        Returns the flatten Parameters/ParameterGroups of the design. This method put all Parameters and ParameterGroups into a list then return it. The return list is sorted by on the display name of the parameters.
        Overrides:
        getFlattenParameters in class ModuleHandleImpl
        Returns:
        the sorted, flatten parameters and parameter groups.
      • getMasterPages

        public SlotHandle getMasterPages()
        Description copied from class: ModuleHandleImpl
        Returns a slot handle to work with the master pages within the report. Note that the order of the master pages within the slot is unimportant.
        Overrides:
        getMasterPages in class ModuleHandleImpl
        Returns:
        A handle for working with the master pages.
      • getParameters

        public SlotHandle getParameters()
        Description copied from class: ModuleHandleImpl
        Returns a slot handle to work with the top-level parameters and parameter groups within the report. The order that the items appear within the slot determines the order in which they appear in the "requester" UI.
        Overrides:
        getParameters in class ModuleHandleImpl
        Returns:
        A handle for working with the parameters and parameter groups.
      • imagesIterator

        public java.util.Iterator imagesIterator()
        Description copied from class: ModuleHandleImpl
        Returns the iterator over all embedded images of this module instance. Each one is the instance of EmbeddedImageHandle
        Overrides:
        imagesIterator in class ModuleHandleImpl
        Returns:
        the iterator over all embedded images.
        See Also:
        EmbeddedImageHandle
      • getAllStyles

        public java.util.List getAllStyles()
        Description copied from class: ModuleHandleImpl
        Returns all style element handles that this modules and the included modules contain.
        Overrides:
        getAllStyles in class ModuleHandleImpl
        Returns:
        all style element handles that this modules and the included modules contain.
      • getVisibleThemes

        public java.util.List getVisibleThemes​(int level)
        Description copied from class: ModuleHandleImpl
        Returns theme handles according the input level.
        Overrides:
        getVisibleThemes in class ModuleHandleImpl
        Parameters:
        level - an int value, which should be the one defined in IVisibleLevelControl.
        Returns:
        theme handles according the input level
      • getVisibleReportItemThemes

        public java.util.List<ReportItemThemeHandle> getVisibleReportItemThemes​(int level,
                                                                                java.lang.String type)
        Description copied from class: ModuleHandleImpl
        Returns report item theme handles according the input level.
        Overrides:
        getVisibleReportItemThemes in class ModuleHandleImpl
        Parameters:
        level - an int value, which should be the one defined in IVisibleLevelControl.
        Returns:
        theme handles according the input level
      • getParametersAndParameterGroups

        public java.util.List getParametersAndParameterGroups()
        Description copied from class: ModuleHandleImpl
        Returns parameters and parameter groups on the module. Those parameters included in the parameter groups are not included in the return list.
        Overrides:
        getParametersAndParameterGroups in class ModuleHandleImpl
        Returns:
        parameters and parameter groups
      • getAllPages

        public java.util.List getAllPages()
        Description copied from class: ModuleHandleImpl
        Returns all page handles that this modules and the included modules contain.
        Overrides:
        getAllPages in class ModuleHandleImpl
        Returns:
        all page handles that this modules and the included modules contain.
      • shiftLibrary

        public void shiftLibrary​(LibraryHandle library,
                                 int toPosn)
                          throws SemanticException
        Description copied from class: ModuleHandleImpl
        Shifts the library to new position. This method might affect the style reference, because the library order is changed.
        Overrides:
        shiftLibrary in class ModuleHandleImpl
        Parameters:
        library - the library to shift
        toPosn - the new position
        Throws:
        SemanticException - if error is encountered when shifting
      • includeLibrary

        public void includeLibrary​(java.lang.String libraryFileName,
                                   java.lang.String namespace)
                            throws DesignFileException,
                                   SemanticException
        Description copied from class: ModuleHandleImpl
        Includes one library with the given library file name. The new library will be appended to the library list.
        Overrides:
        includeLibrary in class ModuleHandleImpl
        Parameters:
        libraryFileName - library file name
        namespace - library namespace
        Throws:
        DesignFileException - if the library file is not found, or has fatal error.
        SemanticException - if error is encountered when handling IncludeLibrary structure list.
      • dropLibrary

        public void dropLibrary​(LibraryHandle library)
                         throws SemanticException
        Description copied from class: ModuleHandleImpl
        Drops the given library from the included libraries of this design file.
        Overrides:
        dropLibrary in class ModuleHandleImpl
        Parameters:
        library - the library to drop
        Throws:
        SemanticException - if error is encountered when handling IncludeLibrary structure list. Or it maybe because that the given library is not found in the design. Or that the library has descedents in the current module
      • reloadLibrary

        public void reloadLibrary​(LibraryHandle libraryToReload)
                           throws SemanticException,
                                  DesignFileException
        Description copied from class: ModuleHandleImpl
        Reloads the library with the given library file path. If the library already is included directly, reload it. If the library is not included, exception will be thrown.

        Call this method cautiously ONLY on the condition that the library file is REALLY changed outside. After reload successfully, the command stack is cleared.

        Overrides:
        reloadLibrary in class ModuleHandleImpl
        Parameters:
        libraryToReload - the library instance
        Throws:
        SemanticException - if error is encountered when handling IncludeLibrary structure list. Or it maybe because that the given library is not found in the design. Or that the library has descedents in the current module
        DesignFileException - if the library file is not found, or has fatal error.
      • reloadLibrary

        public void reloadLibrary​(java.lang.String reloadPath)
                           throws SemanticException,
                                  DesignFileException
        Description copied from class: ModuleHandleImpl
        Reloads the library with the given library file path. If the library already is included directly or indirectly(that is, the reload path could be the path of grandson of this module), reload it. If the library is not included, exception will be thrown.

        Call this method cautiously ONLY on the condition that the library file is REALLY changed outside. After reload successfully, the command stack is cleared.

        Overrides:
        reloadLibrary in class ModuleHandleImpl
        Parameters:
        reloadPath - this is supposed to be an absolute path, not in url form.
        Throws:
        SemanticException - if error is encountered when handling IncludeLibrary structure list. Or it maybe because that the given library is not found in the design. Or that the library has descedents in the current module
        DesignFileException - if the library file is not found, or has fatal error.
      • dropLibraryAndBreakExtends

        public void dropLibraryAndBreakExtends​(LibraryHandle library)
                                        throws SemanticException
        Description copied from class: ModuleHandleImpl
        Drops the given library from the design and break all the parent/child relationships. All child element will be localized in the module.
        Overrides:
        dropLibraryAndBreakExtends in class ModuleHandleImpl
        Parameters:
        library - the given library to drop
        Throws:
        SemanticException - if errors occured when drop the library.It may be because that the library is not found in the design or that some elements can not be localized properly.
      • openCssStyleSheet

        public CssStyleSheetHandle openCssStyleSheet​(java.lang.String fileName)
                                              throws StyleSheetException
        Description copied from class: ModuleHandleImpl
        Gets the result style sheet with given file name of an external CSS2 resource.
        Overrides:
        openCssStyleSheet in class ModuleHandleImpl
        Parameters:
        fileName - the file name of the external CSS resource
        Returns:
        the CssStyleSheetHandle if the external resource is successfully loaded
        Throws:
        StyleSheetException - thrown if the resource is not found, or there are syntax errors in the resource
      • openCssStyleSheet

        public CssStyleSheetHandle openCssStyleSheet​(java.io.InputStream is)
                                              throws StyleSheetException
        Description copied from class: ModuleHandleImpl
        Gets the result style sheet with given file name of an external CSS2 resource.
        Overrides:
        openCssStyleSheet in class ModuleHandleImpl
        Parameters:
        is - the input stream of the resource
        Returns:
        the CssStyleSheetHandle if the external resource is successfully loaded
        Throws:
        StyleSheetException - thrown if the resource is not found, or there are syntax errors in the resource