com.microfocus.zserver.zexplorer.ui

## Class ZExplorerEditUtilities

- java.lang.Object
- - com.microfocus.zserver.zexplorer.ui.ZExplorerEditUtilities

-     public class ZExplorerEditUtilities
      extends java.lang.Object

  Utility class containing editor related helper methods.
  Author:
    Ralf Pakosch

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `ZExplorerEditUtilities()`

  - ### Method Summary

    All Methods Static Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `static IExecutionContext` | `getExecutionContext(org.eclipse.ui.IEditorPart pEditorPart)` Attempts to get an `IExecutionContext` from the editor part.
    `static IMvsResource` | `getMVSResource(org.eclipse.ui.IEditorPart pPart)` Attempts to get an MVS resource from an editor part.
    `static ISystemImage` | `getRemoteSystem(org.eclipse.ui.IEditorPart pPart)` Attempts to get the remote system image from an editor part.
    `static ISystemImage` | `getRemoteSystem(org.eclipse.core.resources.IFile pFile)` Attempts to get the remote system image from a file which is potentially opened in an editor.
    `static org.eclipse.ui.IEditorPart` | `openInEditor(IMvsResource pRes, boolean pEdit, org.eclipse.core.runtime.IProgressMonitor pMon)` Opens an `IMvsResource` in an editor.
    `static org.eclipse.ui.IEditorPart` | `openInEditor(IMvsResource pRes, boolean pEdit, org.eclipse.core.runtime.IProgressMonitor pMon, boolean pAllowExternalEditor)` Opens an `IMvsResource` in an editor.
    `static org.eclipse.ui.IEditorPart` | `openInEditor(java.lang.String pDSN, boolean pEdit, ISystemImage pImg, org.eclipse.core.runtime.IProgressMonitor pMon)` Opens an `IMvsResource` in an editor.
    `static org.eclipse.ui.IEditorPart` | `openInEditor(java.lang.String pFileName, java.lang.String pExtension, java.io.InputStream pIs, ISystemImage pImg, boolean pEdit)` Creates a local file resource of the given stream and opens it in an editor (read-only).
    `static void` | `runEditPostProcess(ISavableResource pRes, org.eclipse.core.resources.IFile pFile, boolean isResLock, org.eclipse.core.runtime.IProgressMonitor pMon)` run after edit process (unlock and delete resource)
    `static void` | `showInvalidCharactersMessage(java.lang.String pResourceName)` Pop-up a warning dialog to inform the user for the detection of non displayable characters in the file.

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

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

- - ### Constructor Detail

    - #### ZExplorerEditUtilities

          public ZExplorerEditUtilities()

  - ### Method Detail

    - #### openInEditor

          public static org.eclipse.ui.IEditorPart openInEditor(java.lang.String pDSN,
                                                                boolean pEdit,
                                                                ISystemImage pImg,
                                                                org.eclipse.core.runtime.IProgressMonitor pMon)
                                                         throws ZExplorerException

      Opens an `IMvsResource` in an editor.
      Parameters:
        `pDSN` - a full qualified MVS data set or member name
        `pEdit` - whether the resource shall be opened in edit mode. `true` will set an exclusive access for the file on the remote system.
        `pImg` - the remote system image. Currently only z/Server system images are allowed
        `pMon` - the progress monitor
      Returns:
        the editor part to the opened file
      Throws:
        `ZExplorerException` - if exception occurred during creation or opening the file

    - #### openInEditor

          public static org.eclipse.ui.IEditorPart openInEditor(IMvsResource pRes,
                                                                boolean pEdit,
                                                                org.eclipse.core.runtime.IProgressMonitor pMon)
                                                         throws ZExplorerException

      Opens an `IMvsResource` in an editor.
      Parameters:
        `pRes` - the resource that shall be opened
        `pEdit` - whether the resource shall be opened in edit mode. `true` will set an exclusive access for the file on the remote system.
        `pMon` - the progress monitor
      Returns:
        the opened editor
      Throws:
        `ZExplorerException` -
        - If an exception occurs during creation or opening the file.
        - If an external editor was opened or opening the editor was canceled.
      See Also:
        `ZServerFileUtilities#getContents(ISystemImage, String, boolean, ERecallMethod, org.eclipse.core.runtime.IProgressMonitor)`

    - #### openInEditor

          public static org.eclipse.ui.IEditorPart openInEditor(IMvsResource pRes,
                                                                boolean pEdit,
                                                                org.eclipse.core.runtime.IProgressMonitor pMon,
                                                                boolean pAllowExternalEditor)
                                                         throws ZExplorerException

      Opens an `IMvsResource` in an editor.
      Parameters:
        `pRes` - the resource that shall be opened
        `pEdit` - whether the resource shall be opened in edit mode. `true` will set an exclusive access for the file on the remote system.
        `pMon` - the progress monitor
        `pAllowExternalEditor` - whether to allow an external editor to be used. If `true`, `null` will be returned and AWM will not be able to save, dequeue or remove the cached file properly. When set to `false` and an external editor was opened (or opening the editor was canceled), an exception will be thrown
      Returns:
        the opened editor or `null` if an external editor was opened or if opening was canceled
      Throws:
        `ZExplorerException` - if exception occurred during creation or opening the file, or if an external editor was opened but `pAllowExternalEditor` was set to `false`
      See Also:
        `ZServerFileUtilities#getContents(ISystemImage, String, boolean, ERecallMethod, org.eclipse.core.runtime.IProgressMonitor)`

    - #### showInvalidCharactersMessage

          public static void showInvalidCharactersMessage(java.lang.String pResourceName)

      Pop-up a warning dialog to inform the user for the detection of non displayable characters in the file.
      Parameters:
        `pResourceName` - the file name

    - #### openInEditor

          public static org.eclipse.ui.IEditorPart openInEditor(java.lang.String pFileName,
                                                                java.lang.String pExtension,
                                                                java.io.InputStream pIs,
                                                                ISystemImage pImg,
                                                                boolean pEdit)
                                                         throws TaurusCoreException

      Creates a local file resource of the given stream and opens it in an editor (read-only).

      The local resource will be removed after the editor is closed.

      Parameters:
        `pFileName` - the name of the file that should be created
        `pExtension` - a file extension (without '.')
        `pIs` - the content of the file
        `pImg` - the system image
        `pEdit` - read only flag
      Returns:
        the `EditorPart` of the editor that has been opened
      Throws:
        `TaurusCoreException` - if exception occurred during creation or opening the file

    - #### runEditPostProcess

          public static void runEditPostProcess(ISavableResource pRes,
                                                org.eclipse.core.resources.IFile pFile,
                                                boolean isResLock,
                                                org.eclipse.core.runtime.IProgressMonitor pMon)

      run after edit process (unlock and delete resource)
      Parameters:
        `pRes` - resource to be unlock
        `pFile` - file to be delete
        `isResLock` - whether the resource should be unlock
        `pMon` - progress monitor

    - #### getRemoteSystem

          public static ISystemImage getRemoteSystem(org.eclipse.core.resources.IFile pFile)

      Attempts to get the remote system image from a file which is potentially opened in an editor.
      Parameters:
        `pFile` - a file
      Returns:
        an `ISystemImage` or `null` if none can be found or the associated system image is a `LocalSystemImage`

    - #### getRemoteSystem

          public static ISystemImage getRemoteSystem(org.eclipse.ui.IEditorPart pPart)

      Attempts to get the remote system image from an editor part.
      Parameters:
        `pPart` - an editor part
      Returns:
        an `ISystemImage` or `null` if none can be found or the associated system image is a `LocalSystemImage`

    - #### getMVSResource

          public static IMvsResource getMVSResource(org.eclipse.ui.IEditorPart pPart)

      Attempts to get an MVS resource from an editor part. This can only succeed, if:
      - The editor has been opened from the z/Explorer, or
      - The editor has been opened from a linked MVS element type.
      Parameters:
        `pPart` - an editor part
      Returns:
        the identified MVS resource or `null`

    - #### getExecutionContext

          public static IExecutionContext getExecutionContext(org.eclipse.ui.IEditorPart pEditorPart)

      Attempts to get an `IExecutionContext` from the editor part. Only works, if the editor part has been opened via a modeled AWM action.

      Note that a context can be returned even for non-remote edit sessions.

      Parameters:
        `pEditorPart` - an editor part
      Returns:
        the found execution context or `null`

Copyright © 2015 Micro Focus GmbH. All rights reserved.