    001package org.vishia.guiBzr;
    002
    003import java.io.File;
    004
    005import org.vishia.gral.base.GralWidget;
    006import org.vishia.gral.ifc.GralMngBuild_ifc;
    007import org.vishia.gral.ifc.GralUserAction;
    008import org.vishia.mainCmd.Report;
    009import org.vishia.util.FileSystem;
    010
    011public class GuiCommitPanel
    012{
    013
    014  /**Aggregation to the main data of the GUI. */
    015  final MainData mainData;
    016
    017  /**Aggregation to the build interface of the manager where the panel is member of. */
    018  final GralMngBuild_ifc panelBuildifc;
    019
    020  final StringBuilder uCommitOut =  new StringBuilder();
    021
    022  GralWidget widgdCommitText; // = new GralWidget("commitText", 'T');
    023
    024  public GuiCommitPanel(MainData mainData, GralMngBuild_ifc panelBuildifc)
    025  {
    026    this.panelBuildifc = panelBuildifc;
    027    this.mainData = mainData;
    028  }
    029
    030  /**Initializes the graphic.
    031   * It will be called in the GUI-Thread.
    032   */
    033  void initGui()
    034  { panelBuildifc.selectPanel("Commit");
    035    panelBuildifc.setPositionSize(2,0, 30, 70, 'r');
    036    widgdCommitText = panelBuildifc.addTextBox("commitText", true, null, ' '); // "commit Text", 't');
    037
    038    panelBuildifc.setPositionSize(33,0, 3, 10, 'r');
    039    panelBuildifc.addButton("commit", actionCommit, "commit", null, "commit");
    040
    041  }
    042
    043
    044
    045
    046  private final GralUserAction actionCommit = new GralUserAction()
    047  {
    048    @Override
    049    public boolean userActionGui(String sCmdGui, GralWidget widgetInfos, Object... values)
    050    {
    051      File fileCommitText = mainData.mainAction.getContentofCommitText();
    052      StringBuilder sCmdCommit = new StringBuilder(mainData.cfg.indexCmds.get("commit"));
    053      int posFile = sCmdCommit.indexOf("$CommitDescrFile");
    054      if(posFile >=0){
    055        sCmdCommit.replace(posFile, 16, fileCommitText.getAbsolutePath());
    056      } else {
    057        //what todo
    058      }
    059      //String sCmd = "bzr commit -F " + fileCommitText.getAbsolutePath();
    060      mainData.cmdExec.setCurrentDir(mainData.currCmpn.dirWorkingtree);
    061      String sCmdStatus = mainData.cfg.indexCmds.get("status");
    062      mainData.cmdExec.execute(sCmdStatus, null, uCommitOut, uCommitOut);
    063      uCommitOut.setLength(0);
    064      mainData.cmdExec.execute(sCmdCommit.toString(), null, uCommitOut, uCommitOut);
    065      stop();
    066      return true;
    067    }
    068  };
    069
    070
    071  void stop(){}
    072
    073}