001package org.vishia.commander;
002
003import java.io.File;
004
005import org.vishia.gral.base.GralButton;
006import org.vishia.gral.base.GralPos;
007import org.vishia.gral.base.GralWidget;
008import org.vishia.gral.base.GralWindow;
009import org.vishia.gral.ifc.GralColor;
010import org.vishia.gral.ifc.GralTextField_ifc;
011import org.vishia.gral.ifc.GralUserAction;
012import org.vishia.gral.ifc.GralWidget_ifc;
013import org.vishia.gral.ifc.GralWindow_ifc;
014import org.vishia.util.KeyCode;
015
016public class FcmdStatus
017{
018  /**Version, history and license
019   * <ul>
020   * <li>2012-10-27 Hartmut created
021   * </ul>
022   * 
023   * 
024   * <b>Copyright/Copyleft</b>:
025   * For this source the LGPL Lesser General Public License,
026   * published by the Free Software Foundation is valid.
027   * It means:
028   * <ol>
029   * <li> You can use this source without any restriction for any desired purpose.
030   * <li> You can redistribute copies of this source to everybody.
031   * <li> Every user of this source, also the user of redistribute copies
032   *    with or without payment, must accept this license for further using.
033   * <li> But the LPGL ist not appropriate for a whole software product,
034   *    if this source is only a part of them. It means, the user
035   *    must publish this part of source,
036   *    but don't need to publish the whole source of the own product.
037   * <li> You can study and modify (improve) this source
038   *    for own using or for redistribution, but you have to license the
039   *    modified sources likewise under this LGPL Lesser General Public License.
040   *    You mustn't delete this Copyright/Copyleft inscription in this source file.
041   * </ol>
042   * If you are intent to use this sources without publishing its usage, you can get
043   * a second license subscribing a special contract with the author. 
044   * 
045   * @author Hartmut Schorrig = hartmut.schorrig@vishia.de
046   * 
047   * 
048   */
049  public static final int version = 20121027;
050  
051  protected final Fcmd main;
052
053  
054  GralWindow_ifc windStatus;
055  
056  GralButton widgCopy, widgEsc;
057  
058  
059  public FcmdStatus(Fcmd main)
060  { this.main = main;
061  }
062
063
064  
065  /**Builds the content of the file property window. The window is created static. It is shown
066   * whenever it is used.  */
067  void buildWindow()
068  { main._gralMng.selectPanel("primaryWindow");
069    main._gralMng.setPosition(-30, 0, -47, 0, 1, 'r'); //right buttom, about half less display width and hight.
070    int windProps = GralWindow.windConcurrently;
071    GralWindow window =  main._gralMng.createWindow("windStatus", "Status - The.file.Commander", windProps);
072    windStatus = window; 
073    main._gralMng.setPosition(3.5f, GralPos.size -3, 1, GralPos.size +5, 0, 'd');
074    widgCopy = main._gralMng.addButton("sCopy", main.copyCmd.actionConfirmCopy, "copy");
075    widgEsc = main._gralMng.addButton("dirBytes", actionButton, "esc");
076  }
077
078  /**Opens the view window and fills its content.
079   * @param src The path which is selected as source. It may be a directory or a file.
080   */
081  void openDialog()
082  {
083    if(main.copyCmd.listEvCopy.size() >0){
084      widgCopy.setBackColor(GralColor.getColor("rd"), 0);
085    } else {
086      widgCopy.setBackColor(GralColor.getColor("wh"), 0);
087    }
088    
089    windStatus.setFocus(); //setWindowVisible(true);
090
091  }
092  
093  
094  /**Action for OK. 
095   */
096  GralUserAction actionButton = new GralUserAction("actionButton")
097  {
098    @Override public boolean exec(int keyCode, GralWidget_ifc widg, Object... params)
099    { if(KeyCode.isControlFunctionMouseUpOrMenu(keyCode)){
100        if(widg == widgEsc){
101          windStatus.closeWindow();
102        }
103      }
104      return true;
105  } };
106
107  
108  /**Action for Key F2 for view command. 
109   */
110  GralUserAction actionOpenDialog = new GralUserAction("actionOpenDialog")
111  {
112    @Override public boolean userActionGui(int keyCode, GralWidget infos, Object... params){ 
113      if(KeyCode.isControlFunctionMouseUpOrMenu(keyCode)){
114        openDialog();
115      }
116      return true;
117    }
118  };
119
120
121  
122}