Class FilePropCnr

All Implemented Interfaces:
IPropDesigner, ISynchronizeEclipseMarkers, EventListener, IGProp<GProp<?>[]>, IPropCnr, ISynchronizeMarkers, Cloneable, Runnable, IAdaptable

public class FilePropCnr extends FileURIPropCnr implements IPropDesigner, Runnable, ISynchronizeEclipseMarkers
A PropCnr that can refer to an IFile object can be loaded and saved as well as checked for modification from last time. An exception can also be set for load errors.
Author:
Christopher Mindus
  • Constructor Details

    • FilePropCnr

      public FilePropCnr()
      Creates a FilePropCnr for the designer with the specified name with a null value. This constructor is only used by the factory to check validity, and nothing else. Never instantiate this class.
    • FilePropCnr

      public FilePropCnr(Atom propertyAtom, IFile file)
      Creates a FilePropCnr for the designer with the specified name with a null value.
      Parameters:
      propertyAtom - the property atom.
      file - the file.
  • Method Details

    • fromProperty

      public static FilePropCnr fromProperty(GProp<?> property)
      Gets a FilePropCnr from a property that should be the FilePropCnr itself or a child.
      Parameters:
      property - The property.
      Returns:
      The FilePropCnr of the property, null if not found.
    • getDataContainer

      public PropCnr getDataContainer()
      Gets the data property container for the file.
      Returns:
      The data property container (Atom.DATA_CONTAINER), or null for none.
    • getSaveable

      public FilePropSaveable getSaveable()
      Gets the Saveable instance for this file.
      Returns:
      The Saveable instance, null when file hasn't been loaded yet (thus this call is too early and this shouldn't happen, otherwise the Editor requesting the Saveable has a problem with it's delayed start-up when projects are loaded or workbench started).
    • onCompletedLoading

      public void onCompletedLoading(PropCnr dataContainerToBe)
      Called when the file completed its loading from the Module model.
      Parameters:
      dataContainerToBe - The FilePropCnr data container to-be, not yet added, null for default.
    • onPropDispose

      protected void onPropDispose()
      Called when a property is disposed of by delete/remove in a container, or by the dispose method.

      This call is done just at the end of the delete/remove routine in the container, without synchronization.

      During this call, whatever components that e.g. the client needs to disposed of is done.

      Subclasses needing to perform some intelligent operations upon deletion should do it by overloading this method and always call the super.onPropDispose() method.

      Overrides:
      onPropDispose in class PropCnr
    • attachEditor

      public void attachEditor(PropEditorPart editor)
      Attaches an Editor to this file.
    • detachEditor

      public void detachEditor(PropEditorPart editor)
      Detaches an Editor from this file.
    • hasActiveEditors

      public boolean hasActiveEditors()
      Checks for active editors.
    • getAttachedEditors

      public PropEditorPart[] getAttachedEditors()
      Gets the attached editors.
    • getActiveEditor

      public PropEditorPart getActiveEditor()
      Gets the active or topmost attached editor.
      Returns:
      The editor part, or null for none.
    • getURL

      public URL getURL()
      Gets the file name URL for this property.
      Overrides:
      getURL in class FileURIPropCnr
      Returns:
      The URL or null for none.
    • getFile

      public File getFile()
      Gets the file for this property.
      Overrides:
      getFile in class FileURIPropCnr
      Returns:
      null if not found.
    • getModificationStamp

      public long getModificationStamp()
      Gets the file modification stamp of the resource if found.
      Returns:
      -1 if not found.
    • getIFile

      public IFile getIFile()
      Gets the file.
      Returns:
      The file resource or null if not found.
    • getFileName

      public String getFileName()
      Gets the file name (full path name) for this property.
    • getDesigner

      public ResourceDesignerProp getDesigner()
      Gets the Designer Extension for Properties.
      Specified by:
      getDesigner in interface IPropDesigner
      Returns:
      The instance of the Designer Extension.
    • isAssetFile

      public boolean isAssetFile()
      Checks if this file is located in the Assets directory. This is only handled in the Editor.
      Overrides:
      isAssetFile in class FileURIPropCnr
      Returns:
      Always true in the Server or Client.
    • clone

      public FilePropCnr clone() throws CloneNotSupportedException
      Clone must be overridden.
      Overrides:
      clone in class FileURIPropCnr
      Throws:
      CloneNotSupportedException - If a subclass doesn't allow cloning, e.g. the client properties.
    • onEventSelf

      public void onEventSelf(GEvent event)
      Called when a property event is send to this property.

      A subclass can override this method to perform appropriate processing and is not required to call super.onEventSelf(e).

      Specified by:
      onEventSelf in interface IGProp<GProp<?>[]>
      Overrides:
      onEventSelf in class GProp<GProp<?>[]>
      Parameters:
      event - The property event.
    • run

      public void run()
      Invoked to check for dirty flag.
      Specified by:
      run in interface Runnable
    • saveFile

      public void saveFile(IProgressMonitor monitor) throws CoreException
      Saves the file if a Shell is not available.
      Parameters:
      monitor - The progress monitor.
      Throws:
      CoreException - For file errors.
    • getSize

      public long getSize()
      Returns the size of the resource in bytes.
      Overrides:
      getSize in class FileURIPropCnr
      Returns:
      The size, or -1 if resource is not found.
    • getModificationTime

      public long getModificationTime()
      Returns the modification time of the resource.
      Overrides:
      getModificationTime in class FileURIPropCnr
      Returns:
      The modification time, or zero if resource is not found.
    • paramString

      protected String paramString(boolean includeFullProperties)
      Returns the parameter string representing the state of this event. This string is useful for debugging. Subclasses adds extra information to the string by preceding it with a comma followed by the extra information.
      Overrides:
      paramString in class FileURIPropCnr
      Parameters:
      includeFullProperties - Flag to include full properties or not.
      Returns:
      the parameter string of this event.