org.vishia.commander

## Class FcmdCopyCmprDel

- java.lang.Object
- - org.vishia.commander.FcmdFileActionBase
  - - org.vishia.commander.FcmdCopyCmprDel

-     public final class FcmdCopyCmprDel
      extends FcmdFileActionBase

  This class contains all functionality to execute copy, move, compare and delete for The.file.Commander. The same class is used for three instances with a different view. See constructor-argument.

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `private class` | `FcmdCopyCmprDel.Actions` Will be initialized if the main.gralMng is available.
    `(package private) static class` | `FcmdCopyCmprDel.Ecmd`
    `(package private) static class` | `FcmdCopyCmprDel.Estate`

  - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `(package private) FcmdCopyCmprDel.Actions` | `action`
    `protected GralUserAction` | `actionButtonAbort`
    `(package private) GralUserAction` | `actionButtonCmprDelMove` Opens the confirm-copy window, prepares the list of src files.
    `protected GralUserAction` | `actionButtonOk` Action for any button of the confirm-copy window.
    `protected GralUserAction` | `actionButtonSkipDir` This action is used to skip over the current showed file while copying.
    `protected GralUserAction` | `actionButtonSkipFile` This action is used to skip over the current showed file while copying.
    `(package private) GralUserAction` | `actionCheck` Opens the confirm-copy window, prepares the list of src files.
    `protected GralUserAction` | `actionChgModeDst`
    `(package private) GralUserAction` | `actionConfirmCopy` Opens the confirm-copy window, prepares the list of src files.
    `(package private) GralUserAction` | `actionCreateCopy`
    `protected GralUserAction` | `actionEnterTextInDst`
    `(package private) GralUserAction` | `actionOverwrDate`
    `protected GralUserAction` | `actionOverwriteFile` This action is used to skip over the current showed file while copying.
    `(package private) GralUserAction` | `actionOverwrReadonly`
    `protected GralUserAction` | `actionSelectMask`
    `protected GralUserAction` | `actionSetDst`
    `(package private) GralUserAction` | `actionShowState` Shows the state of FileRemote, especially for debug and problems.
    `(package private) boolean` | `bDstChanged` If true then the `widgInputDst` was changed for this session.
    `protected boolean` | `bFineSelect` If true then not all files are selected below the shown source directory.
    `(package private) boolean` | `bFirstSelect`
    `(package private) java.lang.StringBuilder` | `bufferDstChars`
    `(package private) FileRemoteCallback` | `callbackFromFilesCheck`
    `(package private) FileRemoteCallback` | `callbackFromFilesExec`
    `protected FcmdCopyCmprDel.Ecmd` | `cmd` Selected handling command.
    `(package private) GralColor` | `colorChangedText`
    `(package private) GralColor` | `colorGrayed`
    `(package private) GralColor` | `colorNoChangedText`
    `(package private) FileRemote` | `dirDst` The destination selected directory and file as destination for compare and move or second tree for comparison.
    `(package private) FileRemote` | `dirProcessed`
    `(package private) FileRemote.CallbackEvent` | `evCallback` This event instance with back event and a possible command event as opponent is generally used for invoke and callback to routines for file handling.
    `(package private) EventConsumer` | `evConsumerCallbackFromFileMachine` Instance of an event consumer which is used for all callback actions from the FileRemote machine.
    `(package private) FileRemote.CallbackEvent` | `evCurrentFile` This reference is set with the callback of operation cmd.
    `(package private) EventSource` | `evSrc` Last files which are in copy process.
    `(package private) FcmdFileCard` | `fileCardDst` The file card where the directory content is shown where the files will be copied to, the destination.
    `(package private) FcmdFileCard` | `fileCardSrc` The file card where the directory content is shown where the files will be copied to, the destination.
    `(package private) FileRemote` | `fileDst` The destination selected directory and file as destination for compare and move or second tree for comparison.
    `(package private) FileRemote` | `fileProcessed`
    `(package private) java.util.List<FileRemote>` | `filesToCopy` Current files which are in copy process.
    `(package private) StringFormatter` | `formatShow`
    `(package private) java.util.List<FileRemote.CallbackEvent>` | `listEvCheck` This list is filled with some callback Events for files which are checked before copying.
    `(package private) java.util.List<FileRemote.CallbackEvent>` | `listEvCopy`
    `protected Fcmd` | `main`
    `(package private) int` | `modeCreateCopy` Mode create new file while copying.
    `(package private) int` | `modeOverwrDate` Mode overwrite with timestamp.
    `(package private) int` | `modeOverwrReadonly` Mode overwrite readonly. '?'
    `(package private) int` | `nrofFilesCheck`
    `(package private) GralPos` | `posWindConfirmCopy`
    `(package private) java.lang.CharSequence` | `sFileDstCopy` Name of the file for dst.
    `(package private) java.lang.String` | `sFilesSrc` If more as one files are selected to copy, the names are contained here separated with ' : '.
    `(package private) FileRemote` | `srcDir` The source file to copy.
    `(package private) FileRemote` | `srcFile` The source file to copy.
    `(package private) boolean` | `srcSomeFiles`
    `protected FcmdCopyCmprDel.Estate` | `state` State of the handling.
    `(package private) java.lang.String` | `sTextExecuteForFile`
    `static int` | `version` Version and History 2015-01-03 Hartmut refactory 2013-02-03 Hartmut chg: set the destination only if it is not set on button setSrc 2013-02-03 Hartmut chg: `execMove()` with files 2013-02-03 Hartmut new: Copy exception (on file open to write) cases a message, the key `widgOverwrFile` works together with the Ask state.
    `(package private) GralButton` | `widgBtnPause`
    `(package private) GralButton` | `widgButtonCheck`
    `(package private) GralButton` | `widgButtonClearSel`
    `(package private) GralButton` | `widgButtonEsc`
    `(package private) GralButton` | `widgButtonModeDst`
    `(package private) GralButton` | `widgButtonMove`
    `(package private) GralButton` | `widgButtonOk`
    `(package private) GralButton` | `widgButtonSetDst`
    `(package private) GralButton` | `widgButtonSetSrc`
    `(package private) GralButton` | `widgButtonShowDst`
    `(package private) GralButton` | `widgButtonShowResult`
    `(package private) GralButton` | `widgButtonShowSrc`
    `(package private) GralTextField` | `widgCopyDirDst`
    `(package private) GralTextField` | `widgCopyNameDst`
    `(package private) GralTextField` | `widgCopyState`
    `(package private) GralButton` | `widgdChoiceCreateNew`
    `(package private) GralButton` | `widgdChoiceOverwrExists`
    `(package private) GralButton` | `widgdChoiceOverwrReadOnly`
    `(package private) GralTextField` | `widgFromConditions`
    `(package private) GralTextField` | `widgInputDst`
    `(package private) GralButton` | `widgOverwrFile`
    `(package private) GralValueBar` | `widgProgressAll`
    `(package private) GralValueBar` | `widgProgressFile`
    `(package private) GralTextField` | `widgShowSrc`
    `(package private) GralButton` | `widgSkipDir`
    `(package private) GralButton` | `widgSkipFile`
    `(package private) GralButton` | `widgState`
    `(package private) GralWindow` | `windConfirmCopy`
    `(package private) long` | `zBytes` Content from the input fields while copy is pending.
    `(package private) int` | `zFiles`

    - ### Fields inherited from class org.vishia.commander.FcmdFileActionBase

      `cmdWind, helpPrefix`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `FcmdCopyCmprDel(Fcmd main, FcmdCopyCmprDel.Ecmd cmdArg)`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected void` | `abortCopy()`
    `(package private) void` | `actionConfirmCopy()`
    `(package private) void` | `buildWindowConfirmCopy(java.lang.String sTitle)` Builds the content of the confirm-copy window.
    `protected void` | `closeWindow()`
    `private void` | `eventConsumed(java.util.EventObject evp, boolean ok)`
    `protected void` | `execCompare()` Starts the execution of compare in another thread.
    `protected void` | `execCopy()` Starts the execution of copy in another thread.
    `protected void` | `execDel()`
    `(package private) void` | `execMark()` Starts the execution of mark in another thread.
    `protected void` | `execMove()`
    `private int` | `modeCopy()` All mode bits of the 3 variables.
    `(package private) void` | `setTexts(FcmdCopyCmprDel.Estate newState)` Set the texts to any widgets depending on the state of execution and the activated switch key.
    `(package private) void` | `setTextSrcDst()` Sets the source and destination depending on the cmd and given `srcFile`, `dirDst` The `widgInputDst` will be not changed if `bDstChanged` is set.
    `(package private) void` | `showCurrentProcessedFileAndDir(FileRemoteProgressTimeOrder order)` Invoked with a time order.
    `(package private) void` | `showFinishState(java.lang.CharSequence start, SortedTreeWalkerCallback.Counters cnt)`
    `(package private) void` | `stop()`

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

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

- - ### Field Detail

    - #### version

          public static final int version

      Version and History
      - 2015-01-03 Hartmut refactory
      - 2013-02-03 Hartmut chg: set the destination only if it is not set on button setSrc
      - 2013-02-03 Hartmut chg: `execMove()` with files
      - 2013-02-03 Hartmut new: Copy exception (on file open to write) cases a message, the key `widgOverwrFile` works together with the Ask state.
      - 2012-11-16 Hartmut chg: Copy: The `filesToCopy` will be filled after callback of check. The files which are used are read only from the input fields of the GUI. The user can change it.
      - 2012-02-26 Hartmut chg: Strategy for button texts and abort behavior improved. Problem was: The 'check' phase needs some calculation time for a slow network connection.
      - 2012-02-04 Hartmut new: If a file was copied and a comparison result exists, it is set to equal. That helps to handle with comparison.
      See Also:
        Constant Field Values

    - #### sTextExecuteForFile

          java.lang.String sTextExecuteForFile

    - #### main

          protected final Fcmd main

    - #### windConfirmCopy

          GralWindow windConfirmCopy

    - #### posWindConfirmCopy

          GralPos posWindConfirmCopy

    - #### widgShowSrc

          GralTextField widgShowSrc

    - #### widgFromConditions

          GralTextField widgFromConditions

    - #### widgButtonModeDst

          GralButton widgButtonModeDst

    - #### widgInputDst

          GralTextField widgInputDst

    - #### widgCopyState

          GralTextField widgCopyState

    - #### widgCopyDirDst

          GralTextField widgCopyDirDst

    - #### widgCopyNameDst

          GralTextField widgCopyNameDst

    - #### widgdChoiceCreateNew

          GralButton widgdChoiceCreateNew

    - #### widgdChoiceOverwrExists

          GralButton widgdChoiceOverwrExists

    - #### widgdChoiceOverwrReadOnly

          GralButton widgdChoiceOverwrReadOnly

    - #### widgOverwrFile

          GralButton widgOverwrFile

    - #### widgSkipFile

          GralButton widgSkipFile

    - #### widgSkipDir

          GralButton widgSkipDir

    - #### widgBtnPause

          GralButton widgBtnPause

    - #### widgState

          GralButton widgState

    - #### widgButtonSetSrc

          GralButton widgButtonSetSrc

    - #### widgButtonSetDst

          GralButton widgButtonSetDst

    - #### widgButtonCheck

          GralButton widgButtonCheck

    - #### widgButtonMove

          GralButton widgButtonMove

    - #### widgButtonOk

          GralButton widgButtonOk

    - #### widgButtonClearSel

          GralButton widgButtonClearSel

    - #### widgButtonShowSrc

          GralButton widgButtonShowSrc

    - #### widgButtonShowDst

          GralButton widgButtonShowDst

    - #### widgButtonShowResult

          GralButton widgButtonShowResult

    - #### widgProgressFile

          GralValueBar widgProgressFile

    - #### widgProgressAll

          GralValueBar widgProgressAll

    - #### widgButtonEsc

          GralButton widgButtonEsc

    - #### colorNoChangedText

          GralColor colorNoChangedText

    - #### colorChangedText

          GralColor colorChangedText

    - #### colorGrayed

          GralColor colorGrayed

    - #### modeOverwrReadonly

          int modeOverwrReadonly

      Mode overwrite readonly. '?'-ask, y-overwrite n-skip, don't ask

    - #### modeOverwrDate

          int modeOverwrDate

      Mode overwrite with timestamp. 'w'-newer, o-older, n-never, ?-ask.

    - #### modeCreateCopy

          int modeCreateCopy

      Mode create new file while copying. 'n'-no, y-yes, a-ask.

    - #### fileCardSrc

          FcmdFileCard fileCardSrc

      The file card where the directory content is shown where the files will be copied to, the destination.

    - #### fileCardDst

          FcmdFileCard fileCardDst

      The file card where the directory content is shown where the files will be copied to, the destination.

    - #### srcDir

          FileRemote srcDir

      The source file to copy. It is set in the `actionConfirmCopy()`. Either dirSrc == fileSrc and the `sFilesSrc` contains some file names, or dirSrc is the directory of fileSrc, fileSrc is the only one file to copy (maybe a directory) and sFilesSrc is empty.

    - #### srcFile

          FileRemote srcFile

      The source file to copy. It is set in the `actionConfirmCopy()`. Either dirSrc == fileSrc and the `sFilesSrc` contains some file names, or dirSrc is the directory of fileSrc, fileSrc is the only one file to copy (maybe a directory) and sFilesSrc is empty.

    - #### srcSomeFiles

          boolean srcSomeFiles

    - #### sFilesSrc

          java.lang.String sFilesSrc

      If more as one files are selected to copy, the names are contained here separated with ' : '. Elsewhere it is "*".

    - #### fileDst

          FileRemote fileDst

      The destination selected directory and file as destination for compare and move or second tree for comparison. The fileDst is build with the name of the source file for copy and move and with the real dst file for compare

    - #### dirDst

          FileRemote dirDst

      The destination selected directory and file as destination for compare and move or second tree for comparison. The fileDst is build with the name of the source file for copy and move and with the real dst file for compare

    - #### sFileDstCopy

          java.lang.CharSequence sFileDstCopy

      Name of the file for dst.

    - #### bufferDstChars

          java.lang.StringBuilder bufferDstChars

    - #### formatShow

          StringFormatter formatShow

    - #### bDstChanged

          boolean bDstChanged

      If true then the `widgInputDst` was changed for this session. Not automatically change the content.

    - #### bFirstSelect

          boolean bFirstSelect

    - #### zBytes

          long zBytes

      Content from the input fields while copy is pending.

    - #### zFiles

          int zFiles

    - #### fileProcessed

          FileRemote fileProcessed

    - #### dirProcessed

          FileRemote dirProcessed

    - #### listEvCheck

          final java.util.List<FileRemote.CallbackEvent> listEvCheck

      This list is filled with some callback Events for files which are checked before copying. If the callback of the check process occurs, the events will be removed from this list. Only events which are found in this list are considered to build the list of files to copy. This list is definitive cleared if the "abort" button is pressing. A current running check process cannot be aborted because it runs in another unknown thread. But the usage of the callback is prevented then.

    - #### nrofFilesCheck

          int nrofFilesCheck

    - #### state

          protected FcmdCopyCmprDel.Estate state

      State of the handling.

    - #### cmd

          protected FcmdCopyCmprDel.Ecmd cmd

      Selected handling command.

    - #### bFineSelect

          protected boolean bFineSelect

      If true then not all files are selected below the shown source directory. Then move and delete should work in fine steps.

    - #### listEvCopy

          final java.util.List<FileRemote.CallbackEvent> listEvCopy

    - #### filesToCopy

          final java.util.List<FileRemote> filesToCopy

      Current files which are in copy process. Typical contains one file only. This list will be filled in `actionConfirmCopy`. If the copy process is finished, this list will be empty.

    - #### evSrc

          EventSource evSrc

      Last files which are in copy process. Typical contains one file only. This list will be filled in `#actionButtonCopy` if the copy process will be started. It is used in `#actionLastSrc` to fill the `filesToCopy`. This list remains after copy process to supply "last files".

    - #### evCurrentFile

          FileRemote.CallbackEvent evCurrentFile

      This reference is set with the callback of operation cmd. The event can be used to affect the copying process.

    - #### action

          FcmdCopyCmprDel.Actions action

    - #### actionShowState

          GralUserAction actionShowState

      Shows the state of FileRemote, especially for debug and problems.

    - #### actionConfirmCopy

          GralUserAction actionConfirmCopy

      Opens the confirm-copy window, prepares the list of src files.

    - #### actionCheck

          GralUserAction actionCheck

      Opens the confirm-copy window, prepares the list of src files. It is Key F5 for copy command from the classic NortonCommander. The OK-key is designated to "check". On button pressed the `#actionButtonCopy` is called, with the "check" case.

    - #### actionSetDst

          protected GralUserAction actionSetDst

    - #### actionChgModeDst

          protected GralUserAction actionChgModeDst

    - #### actionEnterTextInDst

          protected GralUserAction actionEnterTextInDst

    - #### actionOverwrReadonly

          GralUserAction actionOverwrReadonly

    - #### actionOverwrDate

          GralUserAction actionOverwrDate

    - #### actionCreateCopy

          GralUserAction actionCreateCopy

    - #### actionButtonCmprDelMove

          GralUserAction actionButtonCmprDelMove

      Opens the confirm-copy window, prepares the list of src files. It is Key F5 for copy command from the classic NortonCommander. The OK-key is designated to "check". On button pressed the `#actionButtonCopy` is called, with the "check" case.

    - #### actionButtonOk

          protected GralUserAction actionButtonOk

      Action for any button of the confirm-copy window. in a loop FileRemote.copyTo(dst) is called for any selected file. It may be one file, or more files in more selected lines. The copy process itself is executed in an own thread in management of the FileRemote implementation, see `FileRemoteAccessorLocalFile` for local files. The copy process can be executed in an remote device without copying of data between this device (PC) and the remote device, if the commission is organized in the remote device itself.
      To notify for success or progression of the copy process some events are used. See the `#success` `EventConsumer` in this class. The event instance is given to the `FileRemote#copyTo(FileRemote, EventCmdPingPongType)` invocation. It is used to callback either from the thread which copies local or from the thread which receives the copy response telegrams for remote communication.
      All Events which are created are stored in the `listEvCopy`. If the callback occurs, the event will be removed from the list. The list is only used to check whether the copy action is succeeded respectively to check whether all copy actions are succeeded. If a copy success callback is not received, for example because a remote device hangs or the communication fails, the copy process hasn't no progression. The operator on this machine sees this situation because the progression bar stands. The operator can abort the copy process to preset to a default empty state.

    - #### actionButtonAbort

          protected GralUserAction actionButtonAbort

    - #### actionOverwriteFile

          protected GralUserAction actionOverwriteFile

      This action is used to skip over the current showed file while copying. Copying of the selected file should be aborted and that file should be deleted.

    - #### actionButtonSkipFile

          protected GralUserAction actionButtonSkipFile

      This action is used to skip over the current showed file while copying. Copying of the selected file should be aborted and that file should be deleted.

    - #### actionButtonSkipDir

          protected GralUserAction actionButtonSkipDir

      This action is used to skip over the current showed file while copying. Copying of the selected file should be aborted and that file should be deleted.

    - #### actionSelectMask

          protected GralUserAction actionSelectMask

    - #### evConsumerCallbackFromFileMachine

          EventConsumer evConsumerCallbackFromFileMachine

      Instance of an event consumer which is used for all callback actions from the FileRemote machine. The given event contains a command which depends on the action which is done by the file state machine or the file process. Especially
      - `FileRemote.CallbackCmd#nrofFilesAndBytes`: shows the progress of the action.

    - #### evCallback

          FileRemote.CallbackEvent evCallback

      This event instance with back event and a possible command event as opponent is generally used for invoke and callback to routines for file handling. That methods should be execute in another thread. Only one process can be run for one of this window for mark, move, copy, compare and delete. Therefore only one event instance is necessary which is reused. For hanging processes there is an "abort" button which sends the abort event at last. Usual the hanging is forced by an Exception while handling files or while communication with an device. In that cases the exception had terminate the other process already, so the abort command for this event is not used and not necessary. But if the process does not hang and it should be aborted that event is essential.
      If the event will be reused the "abort" was send for a longer time (at least 1 second for manual handling, pressing buttons). Therefore it can be occupied usual without waiting, at least with thread switch to finish execution of the event. See `EventCmdPingPongType#occupyRecall(int, EventSource, EventConsumer, org.vishia.event.EventThread, boolean)`

    - #### callbackFromFilesCheck

          FileRemoteCallback callbackFromFilesCheck

    - #### callbackFromFilesExec

          FileRemoteCallback callbackFromFilesExec

  - ### Constructor Detail

    - #### FcmdCopyCmprDel

          FcmdCopyCmprDel(Fcmd main,
                          FcmdCopyCmprDel.Ecmd cmdArg)

  - ### Method Detail

    - #### buildWindowConfirmCopy

          void buildWindowConfirmCopy(java.lang.String sTitle)

      Builds the content of the confirm-copy window. The window is created static. It is shown whenever it is used.

    - #### closeWindow

          protected void closeWindow()

    - #### modeCopy

          private int modeCopy()

      All mode bits of the 3 variables.

    - #### execMark

          final void execMark()

      Starts the execution of mark in another thread. Note that the mark works with the walk-file algorithm and refreshes the files therewith. The #action.showFilesProcessing is used as callback. See `FileRemote#refreshAndMark(int, boolean, String, int, int, FileRemoteCallback)`.

    - #### execDel

          protected final void execDel()

    - #### execMove

          protected final void execMove()

    - #### execCopy

          protected final void execCopy()

      Starts the execution of copy in another thread. Note that the compy works with a state machine which uses the found files in the `FileRemote.children()` tree. See `FileRemote#copyChecked(String, String, int, org.vishia.fileRemote.FileRemote.CallbackEvent)`.

    - #### execCompare

          protected final void execCompare()

      Starts the execution of compare in another thread. Note that the compare works with the walk-file algorithm and refreshes the files therewith. See `FileRemote#refreshAndCompare(FileRemote, int, String, int, org.vishia.fileRemote.FileRemote.CallbackEvent)`.

    - #### abortCopy

          protected final void abortCopy()

    - #### setTextSrcDst

          final void setTextSrcDst()

      Sets the source and destination depending on the cmd and given `srcFile`, `dirDst` The `widgInputDst` will be not changed if `bDstChanged` is set.

    - #### setTexts

          void setTexts(FcmdCopyCmprDel.Estate newState)

      Set the texts to any widgets depending on the state of execution and the activated switch key.
      Parameters:
        `newState` -

    - #### showCurrentProcessedFileAndDir

          void showCurrentProcessedFileAndDir(FileRemoteProgressTimeOrder order)

      Invoked with a time order.

    - #### showFinishState

          void showFinishState(java.lang.CharSequence start,
                               SortedTreeWalkerCallback.Counters cnt)

    - #### actionConfirmCopy

          void actionConfirmCopy()

    - #### eventConsumed

          private void eventConsumed(java.util.EventObject evp,
                                     boolean ok)

    - #### stop

          void stop()