Class PackagePropertiesModel


  • public class PackagePropertiesModel
    extends java.lang.Object
    • Constructor Summary

      Constructors 
      Constructor Description
      PackagePropertiesModel​(org.eclipse.core.resources.IFile pFile)
      Create a new package.properties model for a given file.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void addBasicLibrary​(org.eclipse.core.resources.IFolder pLibFolder)
      Adds a Basic library folder to the package.
      void addChangeListener​(IModelChangedListener pListener)
      Add a listener notified of the model changes.
      void addContent​(org.eclipse.core.resources.IResource pRes)
      Adds a file or directory to the package properties.
      void addDescriptionFile​(org.eclipse.core.resources.IFile pDescription, java.util.Locale pLocale)
      Adds a localized package description file.
      void addDialogLibrary​(org.eclipse.core.resources.IFolder pLibFolder)
      Adds a basic dialog library folder to the package.
      void clearBasicLibraries()
      Removes all the basic libraries from the package properties.
      void clearContents()
      Removes all the file and directories from the package properties that has been added using addContent(IResource).
      void clearDescriptions()
      Removes all the description files from the package properties.
      void clearDialogLibraries()
      Removes all the dialog libraries from the package properties.
      void firePackageChanged()
      Notify that the package properties model has changed.
      void firePackageSaved()
      Notify that the package properties model has been saved.
      java.util.List<org.eclipse.core.resources.IFolder> getBasicLibraries()  
      java.util.List<org.eclipse.core.resources.IResource> getContents()  
      java.util.Map<java.util.Locale,​org.eclipse.core.resources.IFile> getDescriptionFiles()  
      java.util.List<org.eclipse.core.resources.IFolder> getDialogLibraries()  
      boolean isDirty()  
      void reloadFromString​(java.lang.String pContent)
      Clears all the content of the package properties and replace it by a string as if it would have been the properties file content.
      void removeChangedListener​(IModelChangedListener pListener)
      Removes a class listening the model changes.
      void setQuiet​(boolean pQuiet)
      Set whether the changes should be notified to the listeners or not.
      void write()
      Writes the Package properties to the file.
      java.lang.String writeToString()  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • PackagePropertiesModel

        public PackagePropertiesModel​(org.eclipse.core.resources.IFile pFile)
                               throws java.lang.IllegalArgumentException
        Create a new package.properties model for a given file. If the file can be read, the existing properties will be imported.
        Parameters:
        pFile - the package.properties file represented by the object.
        Throws:
        java.lang.IllegalArgumentException - if the file is null
    • Method Detail

      • setQuiet

        public void setQuiet​(boolean pQuiet)
        Set whether the changes should be notified to the listeners or not.
        Parameters:
        pQuiet - true if the changes should be notified, false otherwise.
      • addChangeListener

        public void addChangeListener​(IModelChangedListener pListener)
        Add a listener notified of the model changes.
        Parameters:
        pListener - the listener to add.
      • removeChangedListener

        public void removeChangedListener​(IModelChangedListener pListener)
        Removes a class listening the model changes.
        Parameters:
        pListener - the listener to remove
      • firePackageSaved

        public void firePackageSaved()
        Notify that the package properties model has been saved.
      • firePackageChanged

        public void firePackageChanged()
        Notify that the package properties model has changed.
      • isDirty

        public boolean isDirty()
        Returns:
        true if the properties model has changed but isn't saved, false otherwise.
      • write

        public void write()
                   throws java.lang.Exception
        Writes the Package properties to the file.
        Throws:
        java.lang.Exception - if the data can't be written
      • reloadFromString

        public void reloadFromString​(java.lang.String pContent)
        Clears all the content of the package properties and replace it by a string as if it would have been the properties file content.
        Parameters:
        pContent - the string describing the data
      • writeToString

        public java.lang.String writeToString()
        Returns:
        the content of the package properties under the form of a string as it would have been written to the file.
      • addBasicLibrary

        public void addBasicLibrary​(org.eclipse.core.resources.IFolder pLibFolder)
                             throws java.lang.IllegalArgumentException
        Adds a Basic library folder to the package.
        Parameters:
        pLibFolder - the library folder to add
        Throws:
        java.lang.IllegalArgumentException - is thrown if the argument is null
      • addDialogLibrary

        public void addDialogLibrary​(org.eclipse.core.resources.IFolder pLibFolder)
                              throws java.lang.IllegalArgumentException
        Adds a basic dialog library folder to the package.
        Parameters:
        pLibFolder - the library folder to add
        Throws:
        java.lang.IllegalArgumentException - is thrown if the argument is null
      • getDialogLibraries

        public java.util.List<org.eclipse.core.resources.IFolder> getDialogLibraries()
        Returns:
        the list of the dialog libraries addedd to the package properties
      • getBasicLibraries

        public java.util.List<org.eclipse.core.resources.IFolder> getBasicLibraries()
        Returns:
        the list of the basic libraries addedd to the package properties
      • clearBasicLibraries

        public void clearBasicLibraries()
        Removes all the basic libraries from the package properties.
      • clearDialogLibraries

        public void clearDialogLibraries()
        Removes all the dialog libraries from the package properties.
      • addContent

        public void addContent​(org.eclipse.core.resources.IResource pRes)
                        throws java.lang.IllegalArgumentException
        Adds a file or directory to the package properties.

        Do not add dialog or basic libraries or package descriptions using this method: use the appropriate method.

        Parameters:
        pRes - the resource to add
        Throws:
        java.lang.IllegalArgumentException - is thrown if the argument is null
      • getContents

        public java.util.List<org.eclipse.core.resources.IResource> getContents()
        Returns:
        the list of the the files and directories added to the package properties that are not dialog or basic libraries or package descriptions
      • clearContents

        public void clearContents()
        Removes all the file and directories from the package properties that has been added using addContent(IResource).
      • addDescriptionFile

        public void addDescriptionFile​(org.eclipse.core.resources.IFile pDescription,
                                       java.util.Locale pLocale)
                                throws java.lang.IllegalArgumentException
        Adds a localized package description file. The description file has to exist and the locale can't be null.
        Parameters:
        pDescription - the description file
        pLocale - the file locale.
        Throws:
        java.lang.IllegalArgumentException - is thrown if the file is null or doesn't exists or if the locale is null.
      • getDescriptionFiles

        public java.util.Map<java.util.Locale,​org.eclipse.core.resources.IFile> getDescriptionFiles()
        Returns:
        a map of the description files accessed by their locale. There is no support of a default locale.
      • clearDescriptions

        public void clearDescriptions()
        Removes all the description files from the package properties.