001package org.vishia.guiBzr;
002
003import java.io.File;
004import java.util.Map;
005import java.util.TreeMap;
006
007import org.vishia.gral.ifc.GralUserAction;
008
009/**This class contains or refers all data of a project.
010 * A project is a software project which contains one or more archives of sources.
011 * Each source-file-bundle with its archive presents a component and 
012 * it is arranged in a sub directory of the project folder.
013 * 
014 * @author Hartmut Schorrig
015 *
016 */
017public class DataProject
018{
019
020  String sPrjPath;
021  
022  /**The project path in the current file system. */
023  File filePrjPath;
024  
025  /**All components in this project. The key is the local path from the project folder
026   * to the folder, where the source archive (.bzr or .git) is arranged.
027   * The key is the same like {@link DataCmpn#sNameCmpn}.
028   */
029  private Map<String, DataCmpn> indexCmpn = new TreeMap<String, DataCmpn>();
030  
031  /**All source components in this project. It will be ascertained while [refresh] button is pressed
032   * on the select panel. See {@link GuiStatusPanel#refreshProjectBzrComponents}
033   */
034  DataCmpn[] data;
035  
036  /**ix while initialize the data. At last number of data -1 (last index). */
037  private int ixDataInit;
038
039  DataProject(String sPrjPath)
040  { this.sPrjPath = sPrjPath;
041    this.filePrjPath = new File(sPrjPath);
042    //assert(filePrjPath.exists() && filePrjPath.isDirectory());
043  }
044  
045  /**Initializes newly. It is called on refresh.
046   * @param nrofSwArchives
047   */
048  void init(int nrofSwArchives)
049  {
050    data = new DataCmpn[nrofSwArchives];
051    indexCmpn.clear();
052    ixDataInit = -1;
053  }
054  
055  /**Creates one component.
056   * @param dirComponent The folder where the source archive (.bzr, .git file) is found.
057   * @return index of current component in {@link #data}
058   */
059  int createComponentsData(File dirComponent)
060  {
061    DataCmpn data1 = new DataCmpn(dirComponent,null, null);
062    indexCmpn.put(data1.sNameCmpn, data1);
063    data[++ixDataInit] = data1;
064    return ixDataInit;
065  }
066  
067  
068  
069  /**Searches a component.
070   * @param sName The local folder path inside the software project to the components folder.
071   * @return null if it isn't found.
072   */
073  DataCmpn selectComponent(String sName)
074  {
075    DataCmpn data = indexCmpn.get(sName);
076    return data;
077  }
078
079}