/** * Add or Remove libs and cells from CVS. * * @param libs * @param cells * @param add true to add to cvs, false to remove from cvs * @param undo true to undo add/remove (boolean add ignored in this case). */ public static void addremove(List<Library> libs, List<Cell> cells, boolean add, boolean undo) { if (libs == null) libs = new ArrayList<Library>(); if (cells == null) cells = new ArrayList<Cell>(); // make sure cells are part of a DELIB CVSLibrary.LibsCells bad = CVSLibrary.notFromDELIB(cells); if (bad.cells.size() > 0) { CVS.showError( "Error: the following Cells are not part of a DELIB library and cannot be acted upon individually", "CVS Add/Remove Error", bad.libs, bad.cells); return; } bad = CVSLibrary.getModified(libs, cells); if (bad.libs.size() > 0 || bad.cells.size() > 0) { CVS.showError( "Error: the following Libraries or Cells must be saved first", "CVS " + (add ? "Add" : "Remove") + " Error", bad.libs, bad.cells); return; } // delib cells must have library added first List<Library> assertLibsInCVS = new ArrayList<Library>(); for (Cell cell : cells) { Library lib = cell.getLibrary(); if (libs.contains(lib) || assertLibsInCVS.contains(lib)) continue; assertLibsInCVS.add(lib); } bad = CVSLibrary.getNotInCVS(assertLibsInCVS, null); if (bad.libs.size() > 0) { CVS.showError( "Error: cannot add DELIB cells if cell's DELIB library is not in cvs", "CVS " + (add ? "Add" : "Remove") + " Error", bad.libs, bad.cells); return; } // optimize a little, remove cells from cells list if cell's lib in libs list CVSLibrary.LibsCells good = CVSLibrary.consolidate(libs, cells); if (!undo) { // when job generates files to add/remove, it will do the check to see if they are in // cvs or not. Don't do it here because we may specify lib to add unadded cells. /* if (add) { good = CVSLibrary.getNotInCVS(libs, cells); } else { good = CVSLibrary.getInCVS(libs, cells); } */ // issue final warning for Remove if (!add) { StringBuffer list = new StringBuffer( "Warning! CVS Remove will delete disk files for these Libraries and Cells!!!"); for (Library lib : good.libs) list.append("\n " + lib.getName()); for (Cell cell : good.cells) list.append("\n " + cell.libDescribe()); if (!Job.getUserInterface().confirmMessage(list.toString())) return; } (new AddRemoveJob(good.libs, good.cells, add)).startJob(); } else { (new UndoAddRemoveJob(good.libs, good.cells)).startJob(); } }