org.vishia.gitGui

## Class GitGui

- java.lang.Object
- - org.vishia.gitGui.GitGui

-     public class GitGui
      extends java.lang.Object

  A Graphical User Interface for basic working in git with remote repository and preserving time stamp of the files.
  - Show a working tree with remote repository (option -git-dir on any git command call).
  - Lists all changed files from working tree and between any revisions.
  - supports commit: via a text file for the commit text (edit with any standard editor) and commit button. On any commit creates a new "_filelist.lst" via `FileList` which contains the time stamp of all files.
  - restore any file from any older version: select version, select file, right mouse "restore". (git checkout) with restoring the original time stamp.

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `(package private) static class` | `GitGui.RevisionEntry`
    `(package private) static class` | `GitGui.Settings`

  - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `(package private) GralUserAction` | `actionAdd` Action for show the version table for the given file.
    `(package private) GralUserAction` | `actionCommit` Action for do commi.
    `(package private) GralUserAction` | `actionDiffCurrWork` Action for diff view of the current file to the workspace.
    `(package private) GralUserAction` | `actionExecCmd`
    `(package private) GralUserAction` | `actionFileDiffRev` Action for diff view of the current file between revisions.
    `(package private) GralUserAction` | `actionMove` Action for show the version table for the given file.
    `(package private) GralUserAction` | `actionOnCloseWindow`
    `(package private) GralUserAction` | `actionOpenCommitText` Action for open the commit text.
    `(package private) GralUserAction` | `actionRefresh` Action for show the version table for the given file.
    `(package private) GralUserAction` | `actionRestore` Action for mouse double to start view diff.
    `(package private) GralUserAction` | `actionTableFile` Action for mouse double to start view diff.
    `(package private) GralUserAction` | `actionTableFileDiffView` Action for mouse double to start view diff.
    `(package private) GralUserAction` | `actionTableFileLog` Action for show the version table for the given file.
    `(package private) GralUserAction` | `actionTableFileRenMove`
    `(package private) GralUserAction` | `actionTableLineVersion`
    `(package private) boolean` | `bCmdThreadClose` If set to true, the `cmdThread` should be aborted.
    `(package private) java.lang.Thread` | `cmdThread`
    `(package private) GitGui.RevisionEntry` | `cmpEntry` The current entry and the entry before, to the earlier commit.
    `(package private) GralTableLine_ifc<GitGui.RevisionEntry>` | `cmpLine` The current line and the line before, to the earlier commit.
    `(package private) GitGui.RevisionEntry` | `currentEntry` The current entry and the entry before, to the earlier commit.
    `(package private) GralTableLine_ifc<GitGui.RevisionEntry>` | `currentLine` The current line and the line before, to the earlier commit.
    `(package private) java.text.SimpleDateFormat` | `dateFormat` The presentation of the time stamps.
    `(package private) CmdExecuter.ExecuteAfterFinish` | `exec_CommitDone` This code snippet is executed after the 'git diff' command for 2 revisions are executed.
    `(package private) CmdExecuter.ExecuteAfterFinish` | `exec_fillFileTable4Revision` This code snippet is executed after the 'git diff' command for 2 revisions are executed.
    `(package private) CmdExecuter.ExecuteAfterFinish` | `exec_fillRevisionTable` This code snippet is executed after the 'git diff' command for 2 revisions are executed.
    `(package private) CmdExecuter.ExecuteAfterFinish` | `exec_ShowStatus` This code snippet is executed after the 'git diff' command for 2 revisions are executed.
    `(package private) CmdExecuter.ExecuteAfterFinish` | `execShowListOut`
    `(package private) GitGuiPaths` | `exepath` The paths to the executables.
    `(package private) static java.io.File` | `filePathRepository` The only one opened git repository. null if nothing is open or more as one is open.
    `(package private) CmdExecuter` | `gitCmd`
    `(package private) StringPartAppend` | `gitOut` Destination for output of all command line invocations.
    `(package private) GralGraphicTimeOrder` | `initGraphic`
    `(package private) java.util.List<java.lang.Appendable>` | `listOut` The `CmdExecuter.execute(String[], boolean, String, List, List, org.vishia.cmd.CmdExecuter.ExecuteAfterFinish)` needs a list of appendable, that is it.
    `(package private) GitGui.Settings` | `settings`
    `(package private) java.lang.String` | `sFileList`
    `(package private) java.lang.String` | `sGitDir` Stored arguments from `startLog(String, String, String)`.
    `(package private) java.lang.String` | `sLocalFile` If given the file which's log and diff should be shown.
    `(package private) java.lang.String` | `sTypeOfImplementation`
    `java.lang.String` | `sVersion` Version, history and license 2018-10-28 Hartmut new textfield for cmd, shows the last automatically cmd, enables assembled cmd for git and common cmd.
    `(package private) java.lang.String` | `sWorkingDir` Stored arguments from `startLog(String, String, String)`.
    `(package private) GralButton` | `wdgBtnAdd`
    `(package private) GralButton` | `wdgBtnCmd`
    `(package private) GralButton` | `wdgBtnDiffCurrFile`
    `(package private) GralButton` | `wdgBtnDiffCurrWork`
    `(package private) GralButton` | `wdgBtnMove`
    `(package private) GralTextField` | `wdgCmd`
    `(package private) GralButton` | `wdgCommit`
    `(package private) GralButton` | `wdgCommitText`
    `(package private) GralTextBox` | `wdgInfo`
    `(package private) GralButton` | `wdgRefresh`
    `(package private) GralTable<java.lang.String>` | `wdgTableFiles`
    `(package private) GralTable<GitGui.RevisionEntry>` | `wdgTableVersion`
    `(package private) GralWindow` | `window`
    `(package private) java.io.File` | `workingDir`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `GitGui(java.lang.String[] args)`

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `(package private) void` | `addFileFromSelection()`
    `void` | `doSomethinginMainthreadTillCloseWindow()`
    `(package private) void` | `fillFileTable4Revision()` Fills the file table with the gotten output after git diff name-status command.
    `(package private) void` | `fillRevisionTable()` Fills the `wdgTableVersion` with the gotten output after git log command.
    `void` | `finalize()`
    `static java.io.File` | `getFilePathRepository(java.io.File startFileSearchRepository)` Returns the opened repository or repoository linking file or searches the next .git or .gitRepository file in the parent dir.
    `static void` | `guiRepository(GitGuiPaths exepath, JZtxtcmdFilepath repoFile)` Searches the git repository and the root of the working tree and opens the window for the git gui.
    `(package private) void` | `initializeCmd()`
    `static void` | `main(java.lang.String[] args)`
    `(package private) void` | `moveFileListToSelection()`
    `(package private) void` | `openNewFileSelector(java.lang.String sFile, GitGui.RevisionEntry currRev)`
    `(package private) void` | `restoreFile(java.lang.String sFile)`
    `static java.lang.String` | `searchRepository(java.io.File startFile, java.lang.String[] dst, java.util.Map<java.lang.String,DataAccess.Variable<java.lang.Object>> dstMap, java.lang.String nameRepository, java.lang.String nameBasedir, java.lang.String nameLocalFile)` Search the base dir and the repository for a given path/to/file.
    `(package private) void` | `showLog_startRevisionDiff4FileTable(GralTable.TableLineData line)` Starts the command 'git diff' to fill the `wdgTableFiles` for the selected revision.
    `static void` | `showLog(java.io.File srcFile)` Searches the git repository and the root of the working tree and opens the window for the git gui.
    `(package private) void` | `startDiffView(java.lang.String sFile, GitGui.RevisionEntry currRev, GitGui.RevisionEntry cmpRev)` Gets the file from repository and writes to tmp directory, starts diff tool
    `(package private) void` | `startLog(java.lang.String sLocalFile)`
    `void` | `startLog(java.lang.String sGitDir, java.lang.String sWorkingDir, java.lang.String sLocalFile)`

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

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

- - ### Field Detail

    - #### sVersion

          public final java.lang.String sVersion

      Version, history and license
      - 2018-10-28 Hartmut new textfield for cmd, shows the last automatically cmd, enables assembled cmd for git and common cmd.
      - 2018-10-27 Hartmut new `openNewFileSelector(String, RevisionEntry)` not ready yet.
      - 2018-10-27 Hartmut chg uses `diff --name-status instead `diff --name-only to build the input for the #wdgTableFiles to show different files. The table has an additional left row for the kind of difference adequate the output of `diff --name-status.```
      - 2018-10-10 Hartmut new `#guiRepository(JZtxtcmdFilepath)` as start operation. It checks whether "name.gitRepository" is given and copies "name.gitignore" to ".gitignore" and uses "name.filelist" as filelist. It supports more as one component on one working dir.
      - 2018-10-10 Hartmut new `getFilePathRepository(File)`. It is invoked in jzTc to get the opened repository by this GUI for add command.
      - 2017-05-10 Hartmut bugfix `CmdExecuter.setCharsetForOutput(String)` to UTF-8 because git outputs cmd output in UTF-8
      - 2016-12-02 Hartmut chg GitGui some improvements.
      - 2016-09-23 Hartmut GitGui: ContextMenu in file table
      - 2016-08-18 Hartmut this version is able to use to view the repository versions, the changed files per version, the changed file to the working tree. It supports view diff with invocation of an external tool. It is the first productive version. But yet with some specific settings yet now. TODO: read a config. Document it. Show the git command line for any action.
      - 2016-08-24 Hartmut created
      Copyright/Copyleft: For this source the LGPL Lesser General Public License, published by the Free Software Foundation is valid. It means:
      1. You can use this source without any restriction for any desired purpose.
      2. You can redistribute copies of this source to everybody.
      3. Every user of this source, also the user of redistribute copies with or without payment, must accept this license for further using.
      4. But the LPGL is not appropriate for a whole software product, if this source is only a part of them. It means, the user must publish this part of source, but don't need to publish the whole source of the own product.
      5. You can study and modify (improve) this source for own using or for redistribution, but you have to license the modified sources likewise under this LGPL Lesser General Public License. You mustn't delete this Copyright/Copyleft inscription in this source file.
      If you are intent to use this sources without publishing its usage, you can get a second license subscribing a special contract with the author.
      See Also:
        Constant Field Values

    - #### actionOpenCommitText

          GralUserAction actionOpenCommitText

      Action for open the commit text.

    - #### exec_CommitDone

          CmdExecuter.ExecuteAfterFinish exec_CommitDone

      This code snippet is executed after the 'git diff' command for 2 revisions are executed. It is used as last argument of `CmdExecuter.execute(String[], boolean, String, List, List, org.vishia.cmd.CmdExecuter.ExecuteAfterFinish)` and prepares the `wdgTableFiles`.

    - #### actionCommit

          GralUserAction actionCommit

      Action for do commi.

    - #### actionRefresh

          GralUserAction actionRefresh

      Action for show the version table for the given file.

    - #### actionTableLineVersion

          GralUserAction actionTableLineVersion

    - #### exec_fillRevisionTable

          CmdExecuter.ExecuteAfterFinish exec_fillRevisionTable

      This code snippet is executed after the 'git diff' command for 2 revisions are executed. It is used as last argument of `CmdExecuter.execute(String[], boolean, String, List, List, org.vishia.cmd.CmdExecuter.ExecuteAfterFinish)` and prepares the `wdgTableFiles`.

    - #### exec_fillFileTable4Revision

          CmdExecuter.ExecuteAfterFinish exec_fillFileTable4Revision

      This code snippet is executed after the 'git diff' command for 2 revisions are executed. It is used as last argument of `CmdExecuter.execute(String[], boolean, String, List, List, org.vishia.cmd.CmdExecuter.ExecuteAfterFinish)` and prepares the `wdgTableFiles`.

    - #### exec_ShowStatus

          CmdExecuter.ExecuteAfterFinish exec_ShowStatus

      This code snippet is executed after the 'git diff' command for 2 revisions are executed. It is used as last argument of `CmdExecuter.execute(String[], boolean, String, List, List, org.vishia.cmd.CmdExecuter.ExecuteAfterFinish)` and prepares the `wdgTableFiles`.

    - #### actionTableFile

          GralUserAction actionTableFile

      Action for mouse double to start view diff.

    - #### actionRestore

          GralUserAction actionRestore

      Action for mouse double to start view diff.

    - #### actionTableFileDiffView

          GralUserAction actionTableFileDiffView

      Action for mouse double to start view diff.

    - #### actionTableFileRenMove

          GralUserAction actionTableFileRenMove

    - #### actionDiffCurrWork

          GralUserAction actionDiffCurrWork

      Action for diff view of the current file to the workspace.

    - #### actionFileDiffRev

          GralUserAction actionFileDiffRev

      Action for diff view of the current file between revisions.

    - #### actionTableFileLog

          GralUserAction actionTableFileLog

      Action for show the version table for the given file.

    - #### actionExecCmd

          GralUserAction actionExecCmd

    - #### actionAdd

          GralUserAction actionAdd

      Action for show the version table for the given file.

    - #### actionMove

          GralUserAction actionMove

      Action for show the version table for the given file.

    - #### execShowListOut

          CmdExecuter.ExecuteAfterFinish execShowListOut

    - #### exepath

          GitGuiPaths exepath

      The paths to the executables.

    - #### filePathRepository

          static java.io.File filePathRepository

      The only one opened git repository. null if nothing is open or more as one is open.

    - #### settings

          GitGui.Settings settings

    - #### sTypeOfImplementation

          java.lang.String sTypeOfImplementation

    - #### window

          GralWindow window

    - #### wdgCmd

          GralTextField wdgCmd

    - #### wdgBtnCmd

          GralButton wdgBtnCmd

    - #### wdgTableVersion

          GralTable<GitGui.RevisionEntry> wdgTableVersion

    - #### wdgTableFiles

          GralTable<java.lang.String> wdgTableFiles

    - #### wdgInfo

          GralTextBox wdgInfo

    - #### wdgBtnDiffCurrWork

          GralButton wdgBtnDiffCurrWork

    - #### wdgBtnDiffCurrFile

          GralButton wdgBtnDiffCurrFile

    - #### wdgBtnAdd

          GralButton wdgBtnAdd

    - #### wdgBtnMove

          GralButton wdgBtnMove

    - #### wdgRefresh

          GralButton wdgRefresh

    - #### wdgCommitText

          GralButton wdgCommitText

    - #### wdgCommit

          GralButton wdgCommit

    - #### bCmdThreadClose

          boolean bCmdThreadClose

      If set to true, the `cmdThread` should be aborted.

    - #### gitCmd

          CmdExecuter gitCmd

    - #### gitOut

          StringPartAppend gitOut

      Destination for output of all command line invocations. This buffer will be cleared and filled with the git command, and then parsed to present the result.

    - #### listOut

          java.util.List<java.lang.Appendable> listOut

      The `CmdExecuter.execute(String[], boolean, String, List, List, org.vishia.cmd.CmdExecuter.ExecuteAfterFinish)` needs a list of appendable, that is it.

    - #### sGitDir

          java.lang.String sGitDir

      Stored arguments from `startLog(String, String, String)`.

    - #### sWorkingDir

          java.lang.String sWorkingDir

      Stored arguments from `startLog(String, String, String)`.

    - #### workingDir

          java.io.File workingDir

    - #### sFileList

          java.lang.String sFileList

    - #### sLocalFile

          java.lang.String sLocalFile

      If given the file which's log and diff should be shown. Elsewhere null. set in `startLog(String)`

    - #### dateFormat

          java.text.SimpleDateFormat dateFormat

      The presentation of the time stamps.

    - #### currentLine

          GralTableLine_ifc<GitGui.RevisionEntry> currentLine

      The current line and the line before, to the earlier commit. The Predecessor is not the parent in any case, not on branch and merge points.

    - #### cmpLine

          GralTableLine_ifc<GitGui.RevisionEntry> cmpLine

      The current line and the line before, to the earlier commit. The Predecessor is not the parent in any case, not on branch and merge points.

    - #### currentEntry

          GitGui.RevisionEntry currentEntry

      The current entry and the entry before, to the earlier commit. The Predecessor is not the parent in any case, not on branch and merge points.

    - #### cmpEntry

          GitGui.RevisionEntry cmpEntry

      The current entry and the entry before, to the earlier commit. The Predecessor is not the parent in any case, not on branch and merge points.

    - #### initGraphic

          GralGraphicTimeOrder initGraphic

    - #### actionOnCloseWindow

          GralUserAction actionOnCloseWindow

    - #### cmdThread

          java.lang.Thread cmdThread

  - ### Constructor Detail

    - #### GitGui

          public GitGui(java.lang.String[] args)

  - ### Method Detail

    - #### main

          public static void main(java.lang.String[] args)

    - #### finalize

          public void finalize()

      Overrides:
        `finalize` in class `java.lang.Object`

    - #### initializeCmd

          void initializeCmd()

    - #### doSomethinginMainthreadTillCloseWindow

          public void doSomethinginMainthreadTillCloseWindow()

    - #### searchRepository

          public static java.lang.String searchRepository(java.io.File startFile,
                                                          java.lang.String[] dst,
                                                          java.util.Map<java.lang.String,DataAccess.Variable<java.lang.Object>> dstMap,
                                                          java.lang.String nameRepository,
                                                          java.lang.String nameBasedir,
                                                          java.lang.String nameLocalFile)

      Search the base dir and the repository for a given path/to/file.
      Parameters:
        `startFile` - Any file path. Especially a ".git" directory or ".gitRepository*" file. In that case the local file path will be set to null, because the whole repository is given. A ".gitRepository*" file contains the path to the extern .git directory.
        `dst` - maybe null, elsewhere new String[2]. dst[0] will be filled with the absolute path of the .git directory. dst[1] will be filled with the absolute path to the basic directory for the working tree where .git or .gitRepository were found. dst[2] will be filled with the local file path or null if the .git or .gitRepositiory is the startFile.
        `dstMap` - maybe null, if not null it is a container maybe from JZcmd variables or an empty Map.
        `nameRepository` - if dstMap !=null, the name of the key (variable) for the repository path.
        `nameBasedir` - if dstMap !=null, the name of the key (variable) for the base directory.
        `nameLocalFile` - if dstMap !=null, the name of the key (variable) for the local file. That variables will be set. nameLocalFile will be set to null if .git or .gitRepository is the startFile.
      Returns:
        null on success or an error message

    - #### getFilePathRepository

          public static java.io.File getFilePathRepository(java.io.File startFileSearchRepository)

      Returns the opened repository or repoository linking file or searches the next .git or .gitRepository file in the parent dir. It is to return the correct repository linking file for the opened GUI to add something with Fcmd and jzTc
      Parameters:
        `dir` - The dir where a file should be handled.
      Returns:
        The opened filePathRepository only if the dir is in the same file tree. Elsewhere it searches .git or .gitRepository in this dir and parents.

    - #### guiRepository

          public static void guiRepository(GitGuiPaths exepath,
                                           JZtxtcmdFilepath repoFile)

      Searches the git repository and the root of the working tree and opens the window for the git gui. This routine can be invoked from any Java program without additional conditions.
      Parameters:
        `srcFile` - Any file to start searching the root of the working tree and the git repository inside this tree. If it is a directory and that directory contains either ".git" or ".gitRepository", it is the root of the working tree. Elsewhere the root will be searched backward to the root of the file system. It means you can start this routine with any srcFile inside the working tree. This file will be used as additional argument for example to show the history of that file.

    - #### showLog

          public static void showLog(java.io.File srcFile)

      Searches the git repository and the root of the working tree and opens the window for the git gui. This routine can be invoked from any Java program without additional conditions.
      Parameters:
        `srcFile` - Any file to start searching the root of the working tree and the git repository inside this tree. If it is a directory and that directory contains either ".git" or ".gitRepository", it is the root of the working tree. Elsewhere the root will be searched backward to the root of the file system. It means you can start this routine with any srcFile inside the working tree. This file will be used as additional argument for example to show the history of that file.

    - #### startLog

          public void startLog(java.lang.String sGitDir,
                               java.lang.String sWorkingDir,
                               java.lang.String sLocalFile)

    - #### startLog

          void startLog(java.lang.String sLocalFile)

      Parameters:
        `sLocalFile` - "*" for all files, else "path/in/loacal/tree/file.ext"

    - #### fillRevisionTable

          void fillRevisionTable()

      Fills the `wdgTableVersion` with the gotten output after git log command. This routine is invoked as `#execAfterCmdLog`.

    - #### showLog_startRevisionDiff4FileTable

          void showLog_startRevisionDiff4FileTable(GralTable.TableLineData line)

      Starts the command 'git diff' to fill the `wdgTableFiles` for the selected revision.
      Parameters:
        `line` -

    - #### restoreFile

          void restoreFile(java.lang.String sFile)

    - #### addFileFromSelection

          void addFileFromSelection()

    - #### moveFileListToSelection

          void moveFileListToSelection()

    - #### startDiffView

          void startDiffView(java.lang.String sFile,
                             GitGui.RevisionEntry currRev,
                             GitGui.RevisionEntry cmpRev)

      Gets the file from repository and writes to tmp directory, starts diff tool
      Parameters:
        `sFile` - The local path of the file
        `currRev` - maybe null, then compare with working tree, elsewhere a selected revision
        `cmpRev` - the selected revision to compare.

    - #### openNewFileSelector

          void openNewFileSelector(java.lang.String sFile,
                                   GitGui.RevisionEntry currRev)

    - #### fillFileTable4Revision

          void fillFileTable4Revision()

      Fills the file table with the gotten output after git diff name-status command. This routine is invoked as `exec_fillFileTable4Revision`.