001package org.vishia.commander;
002
003import java.io.File;
004
005import org.vishia.fileRemote.FileRemote;
006import org.vishia.gral.base.GralMenu;
007import org.vishia.gral.base.GralPanelContent;
008import org.vishia.gral.base.GralWidget;
009import org.vishia.gral.base.GralMng;
010import org.vishia.gral.ifc.GralColor;
011import org.vishia.gral.ifc.GralTableLine_ifc;
012import org.vishia.gral.ifc.GralTextField_ifc;
013import org.vishia.gral.ifc.GralUserAction;
014import org.vishia.gral.ifc.GralWidget_ifc;
015import org.vishia.gral.widget.GralFileSelector;
016import org.vishia.gral.widget.GralHorizontalSelector;
017import org.vishia.util.Assert;
018import org.vishia.util.FileCompare;
019import org.vishia.util.KeyCode;
020
021/**This is one file table in the the.File.commander. Each main panel (left, middle, right)
022 * has maybe more as one tabs, each tab has exactly one file table. The file table is reused
023 * for the several tabs of the main panel, and they are reused too if the directory is changed.
024 * <br><br>
025 * <b>Synchronization of 2 file cards</b>:<br>
026 * If the synchronization is switch on with {@link FcmdFavorPathSelector#bSyncMidRight} then 
027 * {@link #syncWithSecondPanel(String)} is called with the filename. Therewith the same file 
028 * in the second panel (middle or right) will be selected if it exists. If an existing directory
029 * is selected, the other file card follows it if it exists. So the user can walk through two file trees
030 * which have the same structure, but maybe some different content. It is proper for comparison.  
031 * <br><br>
032 * <br><br>
033 * 
034 * @author Hartmut Schorrig
035 *
036 */
037public class FcmdFileCard extends GralFileSelector
038{
039  /**Version, history and license
040   * <ul>
041   * <li>2012-03-09 Hartmut new: Now the synchronization between 2 panels works independent of
042   *   the comparison with a improved algorithm. 
043   * <li>2012-02-04 Hartmut new: {@link #searchCompareResult(File)} supports working with
044   *   comparison result, used to set equal if a file was copied.
045   * </ul>
046   * 
047   * 
048   * <b>Copyright/Copyleft</b>:
049   * For this source the LGPL Lesser General Public License,
050   * published by the Free Software Foundation is valid.
051   * It means:
052   * <ol>
053   * <li> You can use this source without any restriction for any desired purpose.
054   * <li> You can redistribute copies of this source to everybody.
055   * <li> Every user of this source, also the user of redistribute copies
056   *    with or without payment, must accept this license for further using.
057   * <li> But the LPGL ist not appropriate for a whole software product,
058   *    if this source is only a part of them. It means, the user
059   *    must publish this part of source,
060   *    but don't need to publish the whole source of the own product.
061   * <li> You can study and modify (improve) this source
062   *    for own using or for redistribution, but you have to license the
063   *    modified sources likewise under this LGPL Lesser General Public License.
064   *    You mustn't delete this Copyright/Copyleft inscription in this source file.
065   * </ol>
066   * If you are intent to use this sources without publishing its usage, you can get
067   * a second license subscribing a special contract with the author. 
068   * 
069   * @author Hartmut Schorrig = hartmut.schorrig@vishia.de
070   * 
071   * 
072   */
073  @SuppressWarnings("hiding")
074  public static final int version = 0x20120626;
075  
076  /**Table widget for the select table of the file tab.*/
077  FcmdFavorCard favorCard;
078
079  /**The component */
080  final Fcmd main;
081  
082  /**The left, mid or right main panel where this tabbed file table is associated. */
083  final FcmdLeftMidRightPanel mainPanel;
084  
085  GralColor[] colorSelectFocused123 = new GralColor[3];
086  
087  /**The organization unit for this FileSelector. */
088  //final LeftMidRightPanel.FileTabs fileTabs;
089  
090  /**The search-name of the tabbed file panel where this Table is placed on. 
091   * It is the visible label of the tab, following by ".1" till ".3" for the three panels. */
092  final String nameFilePanel;
093  
094  /**The label which is written in the line of favor file after l:label m:label r:label
095   * It is the label on the tab.
096   */
097  final String label;
098  
099  //final GralTextField_ifc widgLabel; /// 
100  
101  final GralHorizontalSelector<Object> wdgCardSelector;
102  
103  /**Association to the current used favor path selection.
104   * Note that this instance is re-used for more as one selection.
105   */
106  FcmdFavorPathSelector.FavorPath favorPathInfo;
107  
108  /**The last selected file and its directory. */
109  //FileRemote currentFile, currentDir;
110  
111  /**If not null, then should synchronize with this file card. Used in */
112  FcmdFileCard otherFileCardtoSync; 
113  
114  
115  /**If not null, then it is the base dir for synchronization with the {@link #otherFileCardtoSync}. 
116   * It will be set in {@link FcmdFilesCp#setDirs()}. */
117  String sDirSync;
118  
119  /**length of sDirSync or -1
120   * It will be set in {@link FcmdFilesCp#setDirs()}. */
121  int zDirSync;
122  
123  String sLocalpath, sLocaldir;
124  
125  
126  /**Creates the cards with tabs for the files and for the favorite paths.
127   * This ctor will be called in the graphic thread. Therefore it can initialize the graphic 
128   * for the fileCard and for the associated favor card in this code.
129   * @param mainPanelP The left, mid or right panel where this cards are assigned to
130   * @param label The label of the tab, it builds the name of all widgets.
131   */
132  FcmdFileCard(FcmdLeftMidRightPanel mainPanelP, String label){
133    super(null, 50, new int[]{2,0,-6,-12}, null);
134    this.label = label;
135    this.main = mainPanelP.main;
136    this.mainPanel = mainPanelP;
137    this.nameFilePanel = label+ "." + mainPanelP.cNr;
138    this.colorSelectFocused123[0] = GralColor.getColor("lgn");
139    this.colorSelectFocused123[1] = GralColor.getColor("lbl");
140    this.colorSelectFocused123[2] = GralColor.getColor("lgr");
141    String namePanelFile = FcmdWidgetNames.tableFile + nameFilePanel;
142    
143    this.setNameWidget(namePanelFile);
144    main.idxFileSelector.put(namePanelFile, this); //it is WidgetNames.tableFile + label +.123, see super(...) 
145    GralMng mng = main._gralMng;
146    //
147    //The favorite paths card
148    String nameTableSelection = FcmdWidgetNames.tableFavorites + nameFilePanel;
149    favorCard = new FcmdFavorCard(main, nameTableSelection, this, mainPanel);
150    GralPanelContent panelFavors = mainPanel.tabbedPanelFavorCards.addGridPanel(FcmdWidgetNames.tabFavorites + nameFilePanel, label,1,1,10,10);
151    mng.setPosition(0, 0, 0, -0, 1, 'd');  
152    favorCard.createImplWidget_Gthread();
153    favorCard.wdgdTable.setHtmlHelp(main.cargs.dirHtmlHelp + "/Fcmd.html#Topic.FcmdHelp.favorpath.favorSelect.");
154    panelFavors.setPrimaryWidget(favorCard.wdgdTable);
155    //
156    //The files card
157    GralPanelContent panelFiles = mainPanel.tabbedPanelFileCards.addGridPanel(FcmdWidgetNames.tabFile + nameFilePanel, label,1,1,10,10);
158    //to show the properties of the selected file in the info line:
159    //
160    //sets this Widget to the selected panel, it is the grid panel which was created even yet.
161    /*
162    mng.setPosition(0, 2, 0, 20, 1, 'd');
163    String nameWidgLabel = FcmdWidgetNames.labelWidgFile + nameFilePanel;
164    widgLabel = mng.addTextField(nameWidgLabel, false, null, null);
165    */
166    mng.setPosition(0, 2, 0, 0, 1, 'd');
167    wdgCardSelector = new GralHorizontalSelector<Object>("cards", actionSetFromTabSelection);
168    wdgCardSelector.setToPanel(mng);
169    //mng.addHorizontalSelector(wdgCardSelector);
170
171    mng.setPosition(2, 0, 0, 0, 1, 'd');
172    //set the base class GralFileSelector to the panel. It contains the path and the table for file selection.
173    setToPanel(mng);
174    //GralPos.Coordinate[] columns = new GralPos.Coordinate[4];
175    //Sets the columns for the table.
176    //super.selectList.wdgdTable.setColumnWidth(50, new int[]{2,0,-6,-11});
177    super.selectList.wdgdTable.setHtmlHelp(main.cargs.dirHtmlHelp + "/Fcmd.html#Topic.FcmdHelp.fileSelect.");
178    GralMenu menuFolder = super.widgdPathDir.getContextMenu();
179    menuFolder.addMenuItem("contextfolder-setOrigin", main.idents.menuContextSetOriginDir, main.favorPathSelector.actionSetDirOrigin);
180    menuFolder.addMenuItem("menuContextCreateFavor", main.idents.menuContextCreateFavor, main.favorPathSelector.actionCreateFavor);
181    menuFolder.addMenuItem("context-filescp", main.idents.menuFilesCpContext, main.filesCp.actionConfirmCp);
182    menuFolder.addMenuItem("contextfolder-create", main.idents.menuConfirmMkDirFileContext, main.mkCmd.actionOpenDialog);
183    menuFolder.addMenuItem("contextfolder-search", main.idents.menuContextSearchFiles, main.favorPathSelector.actionSearchFiles);
184    menuFolder.addMenuItem("contextfolder-refresh", main.idents.menuFileNaviRefreshContext, main.favorPathSelector.actionRefreshFileTable);
185    panelFiles.setPrimaryWidget(super.selectList.wdgdTable);
186    //
187    //sets the action for a simple table: what to do on line selected: Show file names. 
188    this.specifyActionOnFileSelected(actionOnFileSelection);
189    selectList.wdgdTable.setActionFocused(actionFocused);
190    //Note: some menu entries are set in the super class already.
191    selectList.wdgdTable.addContextMenuEntryGthread(1, "test", main.idents.menuFilePropsContext, main.filePropsCmd.actionOpenDialog);
192    selectList.wdgdTable.addContextMenuEntryGthread(1, "test", main.idents.menuFileViewContext, main.viewCmd.actionOpenView);
193    selectList.wdgdTable.addContextMenuEntryGthread(1, "test", main.idents.menuContextEditIntern, main.editWind.actionOpenEdit);
194    selectList.wdgdTable.addContextMenuEntryGthread(1, "test", main.idents.menuFileEditContext, main.actionEdit);
195    selectList.wdgdTable.addContextMenuEntryGthread(1, "test", main.idents.menuConfirmCopyContext, main.copyCmd.actionConfirmCopy);
196    selectList.wdgdTable.addContextMenuEntryGthread(1, "test", main.idents.menuConfirmFileDelContext, main.deleteCmd.actionConfirmDelete);
197    selectList.wdgdTable.addContextMenuEntryGthread(1, "test", main.idents.menuExecuteContext, main.executer.actionExecuteFileByExtension);
198    selectList.wdgdTable.addContextMenuEntryGthread(1, "test", main.idents.menuExecuteCmdContext, main.executer.cmdSelector.actionExecCmdWithFiles);
199    //selectList.wdgdTable.addContextMenuEntryGthread(1, "deSelDir", main.idents.deselectRecursFiles.menuContext, main.favorPathSelector.actionDeselectDirtree);
200    favorCard.wdgdTable.specifyActionOnLineSelected(favorCard.actionFavorSelected);
201    //
202    //sets the action for Select a file: open the execute menu
203    setActionOnEnterFile(main.executer.actionOnEnterFile);
204    setActionSetFileLineAttrib(actionSetFileLineAttrib);
205  }
206
207  
208  private void buildGraphic(){
209    //see ctor
210  }
211  
212  
213  /**Sets a new content for this file table because another favor or tab is selected
214   * @param favorPathInfoP
215   * @param dir
216   * @param mode 0 no tab, 1 -temporary tab, 2 - new tab
217   */
218  void setNewContent(FcmdFavorPathSelector.FavorPath favorPathInfoP, FileRemote dir){
219    favorPathInfo = favorPathInfoP;
220    if(favorCard == null){
221      System.err.println("FcmdFileCard.setNewContent - favorCard is null; " + favorPathInfo);
222    } else {
223      favorCard.add(favorPathInfo);  //only it is a new one, it will be checked.
224      setOriginDir(favorPathInfo.getOriginDir());
225      //widgLabel.setText(favorPathInfo.selectName);
226      fillIn(dir, false);
227      setFocus();
228    }
229  }
230  
231  void setFocusFavorOrFile(){
232    if(mainPanel.bFavorCardHasFocus){
233      favorCard.setFocus();
234    } else {
235      this.setFocus();
236    }
237  }
238  
239
240  
241  
242  /**Overrides the {@link GralFileSelector#setFocus()} and calls him, before that sets the color
243   * of the current line of table of all 3 current file panels to the 3-stage color
244   * to see which table has the focus. 
245   */
246  @Override public void setFocus(){ 
247    mainPanel.bFavorCardHasFocus = false;
248    mainPanel.bFavorThemeCardHasFocus = false;
249    setActFilePanel_setColorCurrLine();
250    super.setFocus(); 
251  }
252  
253  
254  
255  
256  
257  /**Removes this file card with its widgets and data. It is 'close tab'. */
258  @Override public boolean remove(){
259    if(favorCard !=null) {
260      favorCard.remove();
261    }
262    favorCard = null;
263    favorPathInfo = null;
264    return super.remove();
265  }
266 
267  
268  
269  /**Searches whether the given file has a comparison result in this file card.
270   * That method is used to present the file in the table with comparison result information
271   * and to change the comparison result if the file was copied.
272   * @param file The file, usual selected in the file table
273   * @return null a comparison result is not existed, elsewhere the result.
274   */
275  FileCompare.Result searchCompareResult(File file){
276    ///
277    final FileCompare.Result result;
278    if(sDirSync !=null){
279      zDirSync = sDirSync.length();
280      String sPath = file.getAbsolutePath();
281      if(sPath.startsWith(sDirSync) && sPath.length() > zDirSync){
282        String sLocalPath = sPath.substring(sDirSync.length()+1);
283        result = main.filesCp.idxFilepath4Result.get(sLocalPath);
284      } else {
285        result = null;  //outside of sDirSync
286      }
287    } else {
288      zDirSync = -1;
289      result = null;  //no comparison active
290    }
291    return result;
292  }
293  
294  
295  
296  
297  @Override public boolean actionUserKey(int keyCode, Object oData, GralTableLine_ifc line)
298  { boolean ret = true;
299    //FileRemote data = (FileRemote)oData;
300    switch(keyCode){
301    //case KeyCode.alt + KeyCode.F + '7': FileSystem.searchInFiles(new File[]{data}, "ordersBackground"); break;
302    default: ret = false;
303    }
304    /*
305    if (keyCode == main.keyActions.keyCreateFavorite){
306      main.favorPathSelector.windAddFavorite.panelInvocation = mainPanel;
307      main.favorPathSelector.windAddFavorite.widgLabel.setText(nameFilePanel);
308      main.favorPathSelector.windAddFavorite.widgShortName.setText("alias");
309      FileRemote lastSelectedFile = getSelectedFile();
310      //String pathDir = FileSystem.getCanonicalPath(lastSelectedFile.getParentFile());
311      main.favorPathSelector.windAddFavorite.widgPath.setText(lastSelectedFile.getParent());
312      main.favorPathSelector.windAddFavorite.window.setWindowVisible(true);
313    } else*/ 
314    if (keyCode == main.keyActions.keyPanelSelection){
315      //focuses the panel which is the selection panel for this file table.
316      GralWidget tableSelection = main._gralMng.getWidget(FcmdWidgetNames.tableFavorites + nameFilePanel);
317      tableSelection.setFocus();
318    /*
319    } else if (keyCode == main.keyActions.keyPanelLeft){
320      //sets focus to left
321      FcmdFileCard fileTableLeft = null;
322      boolean found = false;
323      for(FcmdFileCard fileTable: mainPanel.listTabs){
324        if(fileTable == this){ found = true;  break;}
325        fileTableLeft = fileTable;  //save this table as table left, use if found.
326      }
327      if(found){
328        if(fileTableLeft !=null){
329          fileTableLeft.setFocus();
330        } else {  //left from first is the selectAllTable of this panel.
331          //panel.selectTableAll.wdgdTable.setFocus();
332        }
333      }
334    } else if (keyCode == main.keyActions.keyPanelRight){
335      //sets focus to right
336      FcmdFileCard fileTableRight = null;
337      boolean found = false; //(mainPanel.selectTableAll == this);
338      for(FcmdFileCard fileTable: mainPanel.listTabs){
339        if(found){ fileTableRight = fileTable; break; }  //use this next table if found before.
340        if(fileTable == this) { found = true; }
341      }
342      if(fileTableRight !=null){
343        fileTableRight.setFocus();
344      }
345      
346    } else if (keyCode == main.keyActions.keyMainPanelLeft){
347      FcmdLeftMidRightPanel dstPanel = mainPanel == main.favorPathSelector.panelRight ?
348          main.favorPathSelector.panelMid : main.favorPathSelector.panelLeft;
349      if(dstPanel.actFileCard !=null){ dstPanel.actFileCard.setFocus(); }
350    } else if (keyCode == main.keyActions.keyMainPanelRight){
351      FcmdLeftMidRightPanel dstPanel = mainPanel == main.favorPathSelector.panelLeft ?
352          main.favorPathSelector.panelMid : main.favorPathSelector.panelRight;
353      if(dstPanel.actFileCard !=null){ dstPanel.actFileCard.setFocus(); }
354    */
355    } else {
356      ret = false;
357    }
358    return ret;
359  }
360
361  
362  
363  /**This routine is invoked from {@link #actionOnFileSelection} action listener whenever a file in any file card
364   * will be selected (key up, down, mouse click etc.).
365   * The routine writes infos about the file and may synchronize with another file card.
366   * @param file The currently selected file.
367   * @param sFileName Text in the cell, especially ".." for the parent dir entry.
368   */
369  protected void actionOnFileSelection(FileRemote file, String sFileName){
370    //note the file, able to use for some actions.
371    main.selectedFiles123[mainPanel.ixMainPanel] = file;
372    
373    if(mainPanel.orderMainPanel == 1){
374      //only if it is the focused panel:
375      //note the file card in order of usage.
376      
377      main.lastFavorCard = favorCard;
378      main.currentFileCard = this;
379      mainPanel.actFileCard = this;
380      main.statusLine.setFileInfo(file);
381      
382      String sPath = file.getAbsolutePath();
383      if(  main.favorPathSelector.bSyncMidRight 
384        && mainPanel.actFileCard == this    //from actFileCard to the second one!
385        && mainPanel.orderMainPanel == 1
386      ){
387        try{ syncWithSecondPanel(sFileName); }
388        catch(Exception exc){ 
389          CharSequence msg = Assert.exceptionInfo("Fcmd.actionOnFileSelection.syncWithSecondPanel() - exception, ", exc, 0, 20);
390          System.out.append(msg);
391        }
392        System.out.println("FcmdFileCard - syncWithSecondPanel; " + toString());
393      }
394      /*
395      else {
396        
397        boolean bSync = main.filesCp.widgSyncWalk.isOn()
398          && sDirSync !=null && sPath.length() >= zDirSync;
399        if(bSync){
400          sLocalpath = sPath.substring(zDirSync);
401          String sDir = getCurrentDirPath();
402          bSync = sDir.length() >= zDirSync;
403          if(bSync){
404            sLocaldir = sDir.substring(zDirSync);
405            String sDirOtherSet = otherFileCardtoSync.sDirSync + sLocaldir;
406            String sDirOtherAct = otherFileCardtoSync.getCurrentDirPath();
407            if(!sDirOtherSet.equals(sDirOtherAct)){
408              //bSync = false;
409              otherFileCardtoSync.fillIn(new FileRemote(sDirOtherSet));
410            }
411            String fileName = file.getName();
412            if(fileName.endsWith(".~1~")){
413              fileName = fileName.substring(0, fileName.length() -4);
414            }
415            otherFileCardtoSync.selectFile(fileName);
416          }
417        }
418      }
419      */
420    }
421  }
422  
423  
424  
425  void syncWithSecondPanel(String sFileName){
426    //String fileName = currentFile.getName();
427    System.out.println("FcmdFileCard -SyncWithSecondPanel;" + mainPanel.cc + ";" + sFileName);
428    FcmdFileCard otherFileCard;
429    boolean bFillInReq = false;
430    if(mainPanel.cc == 'm'){ otherFileCard = main.favorPathSelector.panelRight.actFileCard; }
431    else if(mainPanel.cc == 'r'){ otherFileCard = main.favorPathSelector.panelMid.actFileCard;  }
432    else if(mainPanel.cc == 'l'){ otherFileCard = main.favorPathSelector.panelMid.actFileCard;  }
433    else { otherFileCard = null; }
434    if(otherFileCard !=null){  //NOTE: though mid and right is selected, the otherFileCard may be null because no tab is open.
435      String sDirName = getCurrentDir().getName();
436      //check whether the other file card contains a entry with this directory name
437      GralTableLine_ifc<FileRemote> line = otherFileCard.selectList.wdgdTable.getLine(sDirName);
438      if(line !=null){
439        FileRemote dir = line.getUserData();
440        bFillInReq = true;
441        otherFileCard.fillIn(dir, false);    //use that directory.
442      }
443      boolean bSameFile = otherFileCard.selectFile(sFileName);  //".." also
444      if(!bSameFile){
445        //check whether the file is a directory and it is the directory of the other panel:
446        boolean bToRoot = false;
447        if(currentFile.isDirectory()){
448          FileRemote otherDir = otherFileCard.getCurrentDir();
449          if(otherDir != null){
450            String sDirPath = otherDir.getName();
451            bToRoot = sDirPath.equals(sFileName);
452            if(bToRoot){
453              //the directory of other is the current selected dir of this:
454              FileRemote otherParent = otherDir.getParentFile();
455              if(!bFillInReq){
456                otherFileCard.fillIn(otherParent, false);
457                otherFileCard.selectFile(sFileName);
458                bFillInReq = true;
459              }
460            }
461          }
462        }
463        if(!bToRoot && otherFileCard !=null && otherFileCard.currentFile !=null){
464          //check whether a sub dir is selected:
465          String sOtherSelectedFile = otherFileCard.currentFile.getName();
466          if(sOtherSelectedFile.equals(sDirName) && !bFillInReq){
467            otherFileCard.fillIn(otherFileCard.currentFile,false);
468            otherFileCard.selectFile(sFileName);
469          }
470        }
471      }
472    }
473    
474  }
475  
476  
477  
478  
479  /**Sets the panel which contains this File card as actual, adjust the order of actual file panels
480   * and sets the color of the current line of table of all 3 current file panels to the 3-stage color
481   * to see which table has the focus. 
482   * Sets {@link Fcmd#lastFavorCard}, {@link FcmdLeftMidRightPanel#actFileCard}, 
483   * {@link Fcmd#lastFilePanels}. 
484   */
485  private void setActFilePanel_setColorCurrLine(){
486    main.lastFavorCard = favorCard;
487    main.currentFileCard = this;
488    mainPanel.actFileCard = FcmdFileCard.this;
489    main.setLastSelectedPanel(mainPanel);
490    System.out.println(Assert.stackInfo("FcmdFileCard - setActFilePanel_setColorLine;",10));
491    int ixMainPanel = -1;
492    for(FcmdLeftMidRightPanel panel: main.lastFilePanels){
493      if(ixMainPanel >=2) {
494        break;
495      }
496      if(panel.actFileCard !=null){
497        panel.actFileCard.selectList.wdgdTable.setColorBackSelectedLine(colorSelectFocused123[++ixMainPanel]);
498        panel.orderMainPanel = ixMainPanel +1;   //order in list 1, 2, 3
499      } else {
500        panel.orderMainPanel = 0; //not used.
501      }
502    }
503  }
504  
505  
506  /**Action to show the file properties in the info line. This action is called anytime if a line
507   * was changed in the file view table. */
508  GralUserAction actionOnFileSelection = new GralUserAction("FcmdFileCard-actionOnFileSelection"){
509    /**The action called from {@link GralTable}.
510     * @param params [0] is the Table line. The content of table cells are known here,
511     *   because it is the file table itself. The {@link GralTableLine_ifc#getUserData()}
512     *   returns the {@link FileRemote} file Object.
513     * @see org.vishia.gral.ifc.GralUserAction#userActionGui(int, org.vishia.gral.base.GralWidget, java.lang.Object[])
514     */
515    @Override public boolean userActionGui(int actionCode, GralWidget widgd, Object... params) {
516      mainPanel.bFavorCardHasFocus = false;
517      mainPanel.bFavorThemeCardHasFocus = false;
518      GralTableLine_ifc line = (GralTableLine_ifc) params[0];
519      String sFileCell = line.getCellText(GralFileSelector.kColFilename);
520      Object oData = line.getUserData();
521      if(oData instanceof File){
522        actionOnFileSelection((FileRemote)oData, sFileCell);
523      }
524      return true;
525    }
526  };
527  
528  
529  /**Sets the color of the table line adequate to the select state of the file. */
530  GralUserAction actionSetFileLineAttrib = new GralUserAction("actionSetFileLineAttrib"){
531    /**@param params [0] the table line. It contains the file.
532     * @see org.vishia.gral.ifc.GralUserAction#exec(int, org.vishia.gral.ifc.GralWidget_ifc, java.lang.Object[])
533     */
534    @Override public boolean exec(int actionCode, GralWidget_ifc widgd, Object... params) {
535      //check whether any of the 2 compare directories are base for the current file:
536      try{
537        GralTableLine_ifc line = (GralTableLine_ifc)(params[0]);
538        File file = (File)line.getUserData();
539        if(file instanceof FileRemote){
540          if(file.getName().equals("exe"))
541            Assert.stop();
542          if(file.getName().equals("Fcmd.jar"))
543            Assert.stop();
544          FileRemote file2 = (FileRemote)file;
545          int flags = file2.getFlags();
546          if(file2.isMarked(0xffff)){
547            line.setMarked(1, null);
548            //line.setBackColor(GralColor.getColor("pbl"), 1);
549            line.setLineColor(GralColor.getColor("rd"), 1);
550          } else {
551            //line.setBackColor(GralColor.getColor("wh"), 1);
552            line.setLineColor(GralColor.getColor("bk"), 1);
553          }
554        }
555        FileCompare.Result result = searchCompareResult(file);
556        if(result !=null){
557          if(!result.equal){ line.setCellText("#", 0); }
558          else if(result.alone){ line.setCellText("+", 0); }
559          else if(result.missingFiles){ line.setCellText("-", 0); }
560        }
561      } catch(Exception exc){
562        main._gralMng.log.sendMsg(0, "Exception in FcmdFileCard.actionSetFileLineAttrib"); 
563      }
564      return true;
565  } };  
566  
567  
568  /**This action is bound in the File selection table. If it is focused, the current file tables
569   * of the other file panels will gotten the {@link #colorSelectNonFocused} to show that are not
570   * the first one. The file table of this is set with the {@link #colorSelectFocused}.
571   * Twice the {@link Fcmd#lastFilePanels} list is ordered with this panel as first one. 
572   * 
573   */
574  GralUserAction actionFocused = new GralUserAction("actionFocused"){
575    @SuppressWarnings("synthetic-access") @Override public boolean userActionGui(int actionCode, GralWidget widgd, Object... params) {
576      if(actionCode == KeyCode.focusGained){
577        setActFilePanel_setColorCurrLine();
578      }
579      return true;      
580  } };
581  
582
583  GralUserAction actionSetFromTabSelection = new GralUserAction("actionSetFromTabSelection"){
584    @Override public boolean exec(int actionCode, GralWidget_ifc widgd, Object... params) {
585      FcmdFavorPathSelector.FavorPath favorPathNew = (FcmdFavorPathSelector.FavorPath)params[0];
586      //before changing the content of this fileTable, store the current directory
587      //to restore if this favor respectively selection is used ones more.
588      FileRemote dir = null;
589      String sCurrentDir;
590      if(favorPathInfo !=null){
591        dir = getCurrentDir();
592        if(dir != null){
593          sCurrentDir = dir.getAbsolutePath();
594          if(sCurrentDir !=null){
595            mainPanel.indexActualDir.put(favorPathInfo.selectName, sCurrentDir);
596      } } }
597      main.favorPathSelector.actFavorPathInfo = favorPathNew; //The last used selection (independent of tab left, middle, right)
598      if(favorPathNew == null){
599        //TODO clear filecard
600      } else {
601        sCurrentDir  = mainPanel.indexActualDir.get(favorPathNew.selectName);
602        if(sCurrentDir == null){
603          sCurrentDir = favorPathNew.path;
604        }
605        //dir = new FileRemote(currentDir);  
606        dir = main.fileCluster.getFile(sCurrentDir, null);
607        FcmdFileCard.this.setNewContent(favorPathNew, dir);
608      }
609      return true;      
610  } };
611
612
613  
614  @Override public String toString(){ return label + "/" + nameFilePanel; }
615  
616  
617}