⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 cvslibrary.java

📁 The ElectricTM VLSI Design System is an open-source Electronic Design Automation (EDA) system that c
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
/* -*- tab-width: 4 -*- * * Electric(tm) VLSI Design System * * File: CVSLibrary.java * * Copyright (c) 2003 Sun Microsystems and Static Free Software * * Electric(tm) is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * * Electric(tm) is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with Electric(tm); see the file COPYING.  If not, write to * the Free Software Foundation, Inc., 59 Temple Place, Suite 330, * Boston, Mass 02111-1307, USA. */package com.sun.electric.tool.cvspm;import com.sun.electric.database.hierarchy.Library;import com.sun.electric.database.hierarchy.Cell;import com.sun.electric.tool.io.FileType;import com.sun.electric.tool.user.dialogs.OpenFile;import java.util.*;import java.io.File;import java.awt.Color;import java.net.URL;/** * Track the state of a library that has been checked into CVS. * User: gainsley * Date: Mar 16, 2006 */public class CVSLibrary {//    private Library lib;    private FileType type;    private State libState;                 // only used for non-DELIB file types    private Map<Cell,State> cellStates;    private Map<Cell,Cell> editing;         // list of cells I am editing    private boolean libEditing;                 // true if library is being edited (only for JELIB, ELIB)    private static Map<Library,CVSLibrary> CVSLibraries = new HashMap<Library,CVSLibrary>();    private CVSLibrary(Library lib) {//        this.lib = lib;        String libFile = lib.getLibFile().getPath();        type = OpenFile.getOpenFileType(libFile, FileType.JELIB);        libState = State.NONE;        libEditing = false;        cellStates = new HashMap<Cell,State>();        for (Iterator<Cell> it = lib.getCells(); it.hasNext(); ) {            Cell cell = it.next();            cellStates.put(cell, State.NONE);            if (CVS.isDELIB(lib)) {                if (!CVS.isFileInCVS(CVS.getCellFile(cell))) cellStates.put(cell, State.UNKNOWN);            }        }        editing = new HashMap<Cell,Cell>();    }    /**     * Add a library to the list of CVS libraries, that will maintain     * the known state of the library with respect to CVS.  The known     * state specifies the color mapping of libraries and cells in     * the explorer tree.     * @param lib     */    public static void addLibrary(Library lib) {        addLibrary(lib, false);    }    private static void addLibrary(Library lib, boolean added) {        if (lib.isHidden()) return;        if (!lib.isFromDisk()) return;        String libFile = lib.getLibFile().getPath();        if (!added && !CVS.isFileInCVS(new File(libFile))) {            return;        }        CVSLibrary cvslib = new CVSLibrary(lib);        CVSLibraries.put(lib,cvslib);    }    /**     * Remove a library from the list of CVS libraries.     * @param lib     */    public static void removeLibrary(Library lib) {        CVSLibraries.remove(lib);    }    protected static class LibsCells {        public List<Library> libs = new ArrayList<Library>();        public List<Cell> cells = new ArrayList<Cell>();    }    /**     * Check the specified libraries and cells are in cvs.     * Return any libs and cells that are not in cvs     * @param libs a List of Libraries to check.     * @param cells a List of Cells to check.     * @return Libraries and Cells that are not in CVS.     */    public static LibsCells getNotInCVS(List<Library> libs, List<Cell> cells) {        if (libs == null) libs = new ArrayList<Library>();        if (cells == null) cells = new ArrayList<Cell>();        LibsCells bad = new LibsCells();        for (Library lib : libs) {            if (!CVS.isInCVS(lib)) bad.libs.add(lib);        }        for (Cell cell : cells) {            if (!CVS.isInCVS(cell)) bad.cells.add(cell);        }        return bad;    }    public static LibsCells getInCVS(List<Library> libs, List<Cell> cells) {        if (libs == null) libs = new ArrayList<Library>();        if (cells == null) cells = new ArrayList<Cell>();        LibsCells bad = new LibsCells();        for (Library lib : libs) {            if (CVS.isInCVS(lib)) bad.libs.add(lib);        }        for (Cell cell : cells) {            if (CVS.isInCVS(cell)) bad.cells.add(cell);        }        return bad;    }    public static LibsCells getModified(List<Library> libs, List<Cell> cells) {        if (libs == null) libs = new ArrayList<Library>();        if (cells == null) cells = new ArrayList<Cell>();        LibsCells bad = new LibsCells();        for (Library lib : libs) {            if (lib.isChanged()) bad.libs.add(lib);        }        for (Cell cell : cells) {            if (cell.isModified()) bad.cells.add(cell);        }        return bad;    }    /**     * Remove cells from cell list if they are part of any library in libs list.     * Return the consolidated list of libs and cells.     * @param libs the List of Libraries to consolidate.     * @param cells the List of Cells to consolidate.     * @return a LibsCells with the all desired Libraries and Cells.     */    public static LibsCells consolidate(List<Library> libs, List<Cell> cells) {        LibsCells consolidated = new LibsCells();        consolidated.libs.addAll(libs);        for (Cell cell : cells) {            if (!libs.contains(cell.getLibrary())) consolidated.cells.add(cell);        }        return consolidated;    }    /**     * Get cells from passed in list of cells that are not from DELIB libraries.     * @param cells a List of Cells to examine.     * @return LibsCells of cells that are not from DELIB libraries.     */    public static LibsCells notFromDELIB(List<Cell> cells) {        if (cells == null) cells = new ArrayList<Cell>();        LibsCells bad = new LibsCells();        for (Cell cell : cells) {            if (!CVS.isDELIB(cell.getLibrary())) bad.cells.add(cell);        }        return bad;    }    /**     * Get a list of libraries and cells that are in CVS.  This is sorted     * in the sense that the libraries returned will be JELIBS, and the     * cells returned are cells from DELIBS that are part of the original     * set of libs and cells.     * @param libs a list of Libraries     * @param cells a list of Cells     * @return a LibsCells with JELIBS libraries and DELIB cells that are in CVS.     */    public static LibsCells getInCVSSorted(List<Library> libs, List<Cell> cells) {        List<Cell> delibCells = new ArrayList<Cell>();        List<Library> jelibs = new ArrayList<Library>();        for (Library lib : libs) {            if (CVS.isDELIB(lib)) {                for (Iterator<Cell> it = lib.getCells(); it.hasNext(); ) {                    cells.add(it.next());                }            }            else if (!jelibs.contains(lib))                jelibs.add(lib);        }        for (Cell c : cells) {            if (CVS.isDELIB(c.getLibrary()))                delibCells.add(c);            else if (!jelibs.contains(c.getLibrary()))                jelibs.add(c.getLibrary());        }        return getInCVS(jelibs, delibCells);    }    /**     * Only for DELIBs, check if there are any cells in     * library that have state "UNKNOWN", and need to be added to CVS.     * @param lib the Library to examine.     * @return true if such cells exist.     */    public static boolean hasUnknownCells(Library lib) {        CVSLibrary cvslib = CVSLibraries.get(lib);        if (cvslib == null) return false;        if (cvslib.type != FileType.DELIB) return false;        for (Iterator<Cell> it = lib.getCells(); it.hasNext(); ) {            Cell cell = it.next();            State state = cvslib.cellStates.get(cell);            if (state == null) return true;            if (state == State.UNKNOWN) return true;        }        return false;    }    // --------------------- State recording ---------------------    /**     * Set state of a Cell     * @param cell     * @param state     */    public static void setState(Cell cell, State state) {        CVSLibrary cvslib = CVSLibraries.get(cell.getLibrary());        if (cvslib == null && state == State.ADDED) {            // if state is added, CVSLibrary should be created            addLibrary(cell.getLibrary(), true);            cvslib = CVSLibraries.get(cell.getLibrary());        }        if (cvslib == null) return;        if (state == null)            return;        if (!CVS.isDELIB(cell.getLibrary())) {            cvslib.libState = state;        } else {            cvslib.cellStates.put(cell, state);        }    }    /**     * Set state of all Cells in a library     * @param lib

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -