com.microfocus.awm.control

## Class EditUtilities

- java.lang.Object
- - com.microfocus.awm.control.EditUtilities

-     public class EditUtilities
      extends java.lang.Object

  Helper methods related to editing files.

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static java.lang.String` | `REMOTEFILE` Name of the "remote files" cache folder

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `EditUtilities()`

  - ### Method Summary

    All Methods Static Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `static void` | `cleanUpEdit(IResource pRes, FileDescriptor pFile2Delete, IExecutionContext pContext)` Deletes a local file.
    `static void` | `createLocalFile(FileDescriptor pFileDescr, IElement pElement, IExecutionContext pContext, org.eclipse.core.runtime.IProgressMonitor pMon)` Creates a local IFile in the internal TAURUS project and maintains the internal maps for local edit.
    `static FileDescriptor` | `createTempFile(FileDescriptor pFDSource, java.lang.String pFileName, IElement pElement, IExecutionContext pContext, boolean pReadOnly)` Creates a temporary local file within the TAURUS file system.
    `static void` | `doLocalSyntaxCheck(IElement pElement, FileDescriptor pFd)` Perform the local syntax check to a local IFile in the internal TAURUS project.
    `static org.eclipse.core.resources.IFolder` | `getCacheFolder(FileDescriptor pFD, IExecutionContext pContext)` Creates and gets the folder where the file corresponding to the given file descriptor will be cached.
    `static java.lang.String` | `getConfiguredCompareSuffix(ToolDescriptor pTd, IExecutionContext pContext)`
    `static IElement` | `getElementFromContext(IExecutionContext pContext)` Gets the element from the context.
    `static java.lang.String` | `getFileName(FileDescriptor pFD)` Gets the filename from the file descriptor's physical name.
    `static java.lang.String` | `getFileName(java.lang.String pPhysicalName, IExecutionContext pContext)` Gets a file name for the given context.
    `static org.eclipse.core.resources.IFile` | `getLocalFile(IElement pElement)` Uses the element's ID definition to get the persistent workspace path of the given element.
    `static org.eclipse.core.resources.IFile` | `openFile(FileDescriptor pFD, IExecutionContext pContext, boolean pReadOnly, java.lang.String pSuffix, int pLine, org.eclipse.core.runtime.IProgressMonitor pMon)` Opens the given Content in the default editor for the given file extension.The MF background parsing is turn off.
    `static void` | `setReadOnlyFlag(org.eclipse.core.resources.IFile pFile)` Sets the read only flag of the given file and refreshes it in the workspace.
    `static void` | `uploadFile(FileDescriptor pSource, FileDescriptor pTarget, IExecutionContext pContext, EExistingResourceHandling pExistingResourceHandling, org.eclipse.core.runtime.IProgressMonitor pMon)` Uploads the contents of a File Descriptor.
    `static void` | `uploadFile(FileDescriptor pSource, FileDescriptor pTarget, IExecutionContext pContext, org.eclipse.core.runtime.IProgressMonitor pMon)` Uploads the contents of a File Descriptor.
    `static void` | `uploadFile(java.util.List<FileDescriptor> pSources, java.util.List<FileDescriptor> pTargets, IExecutionContext pContext, EExistingResourceHandling pExistingResourceHandling, org.eclipse.core.runtime.IProgressMonitor pMon)` Uploads the contents of File Descriptors.
    `static void` | `uploadFile(java.util.List<FileDescriptor> pSources, java.util.List<FileDescriptor> pTargets, IExecutionContext pContext, org.eclipse.core.runtime.IProgressMonitor pMon)` Uploads the contents of File Descriptors.

    - ### Methods inherited from class java.lang.Object

      `equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### REMOTEFILE

          public static final java.lang.String REMOTEFILE

      Name of the "remote files" cache folder
      See Also:
        Constant Field Values

  - ### Constructor Detail

    - #### EditUtilities

          public EditUtilities()

  - ### Method Detail

    - #### createLocalFile

          public static void createLocalFile(FileDescriptor pFileDescr,
                                             IElement pElement,
                                             IExecutionContext pContext,
                                             org.eclipse.core.runtime.IProgressMonitor pMon)
                                      throws TaurusCoreException,
                                             java.io.IOException,
                                             TaurusToolException

      Creates a local IFile in the internal TAURUS project and maintains the internal maps for local edit.
      Parameters:
        `pFileDescr` - file descriptor pointing to the file
        `pElement` - element to which the file belongs
        `pContext` - execution context of the edit action
        `pMon` - a progress monitor
      Throws:
        `TaurusCoreException` - if the file could not be created
        `java.io.IOException` - if reading the file contents fails
        `TaurusToolException` - if associating a property group to the file fails

    - #### setReadOnlyFlag

          public static void setReadOnlyFlag(org.eclipse.core.resources.IFile pFile)
                                      throws org.eclipse.core.runtime.CoreException

      Sets the read only flag of the given file and refreshes it in the workspace.
      Parameters:
        `pFile` - the file
      Throws:
        `org.eclipse.core.runtime.CoreException` - if setting the flag or refreshing the file fails

    - #### createTempFile

          public static FileDescriptor createTempFile(FileDescriptor pFDSource,
                                                      java.lang.String pFileName,
                                                      IElement pElement,
                                                      IExecutionContext pContext,
                                                      boolean pReadOnly)
                                               throws TaurusToolException,
                                                      TaurusCoreException

      Creates a temporary local file within the TAURUS file system.
      Parameters:
        `pFDSource` - a `FileDescriptor` of the source file
        `pFileName` - the new file name
        `pElement` - The Element to which the created file belongs to or `null`, since this is only needed for a future local syntax check
        `pContext` - actual execution context
        `pReadOnly` - whether the file should be created read-only
      Returns:
        the newly created local file in the internal TAURUS project
      Throws:
        `TaurusCoreException` - if the file could not be created
        `TaurusToolException` - if the file could not be created

    - #### doLocalSyntaxCheck

          public static void doLocalSyntaxCheck(IElement pElement,
                                                FileDescriptor pFd)
                                         throws TaurusException

      Perform the local syntax check to a local IFile in the internal TAURUS project.
      Parameters:
        `pElement` - element to which the file belongs
        `pFd` - the file descriptor of the local file
      Throws:
        `TaurusException` - if the syntax check fails

    - #### getLocalFile

          public static org.eclipse.core.resources.IFile getLocalFile(IElement pElement)
                                                               throws TaurusCoreException

      Uses the element's ID definition to get the persistent workspace path of the given element. The file may not exist.
      Parameters:
        `pElement` - the element
      Returns:
        the persistent file location of the element
      Throws:
        `TaurusCoreException` - if the application folder could not be created/located
      See Also:
        `EIntegratedTools.LOCAL_FILE_CREATOR`, `EIntegratedTools.LOCAL_FILE_LOCATOR`

    - #### uploadFile

          public static void uploadFile(FileDescriptor pSource,
                                        FileDescriptor pTarget,
                                        IExecutionContext pContext,
                                        org.eclipse.core.runtime.IProgressMonitor pMon)
                                 throws TaurusCoreException

      Uploads the contents of a File Descriptor.

      Same as calling `uploadFile(FileDescriptor, FileDescriptor, IExecutionContext, EExistingResourceHandling, IProgressMonitor)` with existing resource handling `EExistingResourceHandling.REPLACE`.

      Parameters:
        `pSource` - the source file, which contents should be uploaded
        `pTarget` - the destination file
        `pContext` - execution context of the upload action
        `pMon` - progress monitor
      Throws:
        `TaurusCoreException` - if an exception occurs while reading the source file or setting contents of the target file

    - #### uploadFile

          public static void uploadFile(FileDescriptor pSource,
                                        FileDescriptor pTarget,
                                        IExecutionContext pContext,
                                        EExistingResourceHandling pExistingResourceHandling,
                                        org.eclipse.core.runtime.IProgressMonitor pMon)
                                 throws TaurusCoreException

      Uploads the contents of a File Descriptor.
      Parameters:
        `pSource` - the source file, which contents should be uploaded
        `pTarget` - the destination file
        `pContext` - execution context of the upload action
        `pExistingResourceHandling` - what to do if the target file already exists
        `pMon` - progress monitor
      Throws:
        `TaurusCoreException` - if an exception occurs while reading the source file or setting contents of the target file

    - #### uploadFile

          public static void uploadFile(java.util.List<FileDescriptor> pSources,
                                        java.util.List<FileDescriptor> pTargets,
                                        IExecutionContext pContext,
                                        org.eclipse.core.runtime.IProgressMonitor pMon)
                                 throws TaurusCoreException

      Uploads the contents of File Descriptors.

      Same as calling `uploadFile(List, List, IExecutionContext, EExistingResourceHandling, IProgressMonitor)` with existing resource handling `EExistingResourceHandling.REPLACE`.

      Parameters:
        `pSources` - the source files, which contents should be uploaded
        `pTargets` - the destination files
        `pContext` - execution context of the upload action
        `pMon` - progress monitor
      Throws:
        `TaurusCoreException` - if an exception occurs while reading the source file or setting contents of the target file

    - #### uploadFile

          public static void uploadFile(java.util.List<FileDescriptor> pSources,
                                        java.util.List<FileDescriptor> pTargets,
                                        IExecutionContext pContext,
                                        EExistingResourceHandling pExistingResourceHandling,
                                        org.eclipse.core.runtime.IProgressMonitor pMon)
                                 throws TaurusCoreException

      Uploads the contents of File Descriptors.
      Parameters:
        `pSources` - the source files, which contents should be uploaded
        `pTargets` - the destination files
        `pContext` - execution context of the upload action
        `pExistingResourceHandling` - what to do if the target file already exists
        `pMon` - progress monitor
      Throws:
        `TaurusCoreException` - if an exception occurs while reading the source file or setting contents of the target file

    - #### cleanUpEdit

          public static void cleanUpEdit(IResource pRes,
                                         FileDescriptor pFile2Delete,
                                         IExecutionContext pContext)
                                  throws TaurusCoreException

      Deletes a local file.
      Parameters:
        `pRes` - the corresponding resource
        `pFile2Delete` - the file that shall be deleted
        `pContext` - the execution context
      Throws:
        `TaurusCoreException` - if an exception occurs while deleting the file or removing its property group

    - #### getElementFromContext

          public static IElement getElementFromContext(IExecutionContext pContext)

      Gets the element from the context. Returns `null` if the context resource is not an element or element list entry.
      Parameters:
        `pContext` - the context
      Returns:
        an element or `null`

    - #### getFileName

          public static java.lang.String getFileName(java.lang.String pPhysicalName,
                                                     IExecutionContext pContext)

      Gets a file name for the given context. If the context resource is an element (or element list entry) which contains an "element name property", its value will be returned. Otherwise the given physical name parameter will be returned.
      Parameters:
        `pPhysicalName` - the physical file name
        `pContext` - the execution context
      Returns:
        value of the "element name property" of the element from the context or the physical name parameter
      See Also:
        `getElementFromContext(IExecutionContext)`, `RElementProperty.isElementName()`

    - #### getConfiguredCompareSuffix

          public static java.lang.String getConfiguredCompareSuffix(ToolDescriptor pTd,
                                                                    IExecutionContext pContext)
                                                             throws TaurusToolException

      Parameters:
        `pTd` - the tool descriptor
        `pContext` - the context
      Returns:
        the suffix value configured as 2. input parameter or if it is not configured
      Throws:
        `TaurusToolException` - if an exception occurs during finding out parameter value.

    - #### getFileName

          public static java.lang.String getFileName(FileDescriptor pFD)

      Gets the filename from the file descriptor's physical name.
      Parameters:
        `pFD` - the file descriptor
      Returns:
        the filename of the file descriptor's physical name

    - #### getCacheFolder

          public static org.eclipse.core.resources.IFolder getCacheFolder(FileDescriptor pFD,
                                                                          IExecutionContext pContext)
                                                                   throws org.eclipse.core.runtime.CoreException,
                                                                          TaurusCoreException

      Creates and gets the folder where the file corresponding to the given file descriptor will be cached.
      Parameters:
        `pFD` - the file description
        `pContext` - the execution context
      Returns:
        for file description of type `EFileTypes.MVSPO_MEMBER`, `EFileTypes.MVSSEQ`, `EFileTypes.USS_FILE` and `EFileTypes.LOCAL_FILE` the folder where the file description's file will be cached.. Otherwise return the AWM internal file cache folder .
      Throws:
        `org.eclipse.core.runtime.CoreException` - if errors occurred during the creation of folders
        `TaurusCoreException` - if errors occurred by creation of the AWM internal file cache folder

    - #### openFile

          public static org.eclipse.core.resources.IFile openFile(FileDescriptor pFD,
                                                                  IExecutionContext pContext,
                                                                  boolean pReadOnly,
                                                                  java.lang.String pSuffix,
                                                                  int pLine,
                                                                  org.eclipse.core.runtime.IProgressMonitor pMon)
                                                           throws TaurusCoreException

      Opens the given Content in the default editor for the given file extension.The MF background parsing is turn off.
      Parameters:
        `pContext` - the execution context
        `pFD` - the file descriptor for the file to open
        `pSuffix` - can be `null` if the file name contains a file extension. If no file extension is given, TAURUS will try to find a suffix.
        `pReadOnly` - if `true` the file is opened in read only modus
        `pLine` - the line number that should be selected after the editor is opened (can be `0`)
        `pMon` - progress monitor
      Returns:
        the temporary copy of the file that has been opened in the editor or `null` if no UI is available to open the file.
      Throws:
        `TaurusCoreException` - if an Exception of any kind occurs

Copyright © 2015 Micro Focus GmbH. All rights reserved.