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

📄 cvs.java

📁 The ElectricTM VLSI Design System is an open-source Electronic Design Automation (EDA) system that c
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
    /**     * This checks the CVS Entries file to see if the cell is in cvs.     * If the cell belongs to a delib, it checks the cell file. Otherwise,     * it checks the library file for jelib/elibs.     * @param cell     * @return true if the cell is in cvs, false otherwise     */    public static boolean isInCVS(Cell cell) {        if (!isDELIB(cell.getLibrary())) return isInCVS(cell.getLibrary());        // delibs have separate cell files        File cellFile = getCellFile(cell);        return isFileInCVS(cellFile);    }    /**     * Used by commands that require the library to be in sync with the disk.     * @param cell     * @param dialog true to pop up a dialog to tell the user, false to not do so.     * @return true if not modified, false if modified     */    public static boolean assertNotModified(Cell cell, String cmd, boolean dialog) {        if (cell.isModified()) {            if (dialog) {                Job.getUserInterface().showErrorMessage("Cell "+cell.getName()+" must be saved to run CVS "+cmd, "CVS "+cmd);            } else {                System.out.println("Cell "+cell.getName()+" must be saved to run CVS "+cmd);            }            return false;        }        return true;    }    /**     * Returns true if the library is in CVS, otherwise generates an error message.     * @param lib the library to check     * @param cmd the CVS command (for error message display)     * @param dialog true to show a modal dialog, false to write error to message window     * @return true if it is in cvs, false otherwise     */    public static boolean assertInCVS(Library lib, String cmd, boolean dialog) {        File libFile = new File(lib.getLibFile().getPath());        if (!CVS.isFileInCVS(libFile)) {            if (libFile.getPath().matches(".*?com.*?sun.*?electric.*?lib.*?spiceparts.*")) return false;            //if (libFile.getPath().indexOf("com/sun/electric/lib/spiceparts") != -1) return false;            String message = "Library "+lib.getName()+" is not part of CVS repository.\n" +                        "Use 'CVS Add' to add to current repository.";            if (dialog) {                Job.getUserInterface().showErrorMessage(message, "CVS "+cmd+" Failed");            } else {                System.out.println(message+" CVS "+cmd+" Failed");            }            return false;        }        return true;    }    /**     * Returns true if the Cell is in CVS, otherwise generates an error message.     * @param cell the cell to check     * @param cmd the CVS command (for error message display)     * @param dialog true to show a modal dialog, false to write error to message window     * @return true if it is in cvs, false otherwise     */    public static boolean assertInCVS(Cell cell, String cmd, boolean dialog) {        File cellFile = getCellFile(cell);        if (cellFile == null) {            String message = "Cell "+cell.libDescribe()+" is not part of CVS repository.\n" +                        "Use 'CVS Add' to add to current repository.";            if (dialog) {                Job.getUserInterface().showErrorMessage(message, "CVS "+cmd+" Failed");            } else {                System.out.println(message+" CVS "+cmd+" Failed");            }            return false;        }        return true;    }    /**     * Issue an error message     * @param message     * @param title     * @param badLibs     * @param badCells     */    public static void showError(String message, String title,                                  List<Library> badLibs, List<Cell> badCells) {        StringBuffer msg = new StringBuffer();        msg.append(message);        for (Library lib : badLibs) msg.append("\n  Library "+lib.getName());        for (Cell cell : badCells) msg.append("\n  Cell "+cell.noLibDescribe());        Job.getUserInterface().showErrorMessage(msg.toString(), title);    }    public static int askForChoice(String message, String title,                                  List<Library> badLibs, List<Cell> badCells,                                  String [] choices, String defaultChoice) {        StringBuffer msg = new StringBuffer();        msg.append(message);        for (Library lib : badLibs) msg.append("\n  Library "+lib.getName());        for (Cell cell : badCells) msg.append("\n  Cell "+cell.noLibDescribe());        return Job.getUserInterface().askForChoice(msg.toString(), title, choices, defaultChoice);    }    /**     * Get a command directory in which to run a CVS command on the given     * libraries and cells.  This just picks the parent dir of     * the first library found.     * @param libs     * @param cells     * @return     */    static String getUseDir(List<Library> libs, List<Cell> cells) {        if (libs != null) {            for (Library lib : libs) {                if (lib.isHidden()) continue;                if (!lib.isFromDisk()) continue;                File libFile = TextUtils.getFile(lib.getLibFile());                if (libFile == null) continue;                return libFile.getParent();            }        }        if (cells != null) {            for (Cell cell : cells) {                Library lib = cell.getLibrary();                if (lib.isHidden()) continue;                if (!lib.isFromDisk()) continue;                File libFile = TextUtils.getFile(lib.getLibFile());                if (libFile == null) continue;                return libFile.getParent();            }        }        return User.getWorkingDirectory();    }    /**     * Get a String of filenames for the associated libraries, to pass as the     * 'files' argument to a CVS command.  Any files in 'useDir' will     * be relative names, otherwise they will be absolute file names.     * @param libs     * @return     */    static StringBuffer getLibraryFiles(List<Library> libs, String useDir) {        StringBuffer libsBuf = new StringBuffer();        if (libs == null) return libsBuf;        for (Library lib : libs) {            File libFile = TextUtils.getFile(lib.getLibFile());            if (libFile == null) continue;            String file = libFile.getPath();            if (file.startsWith(useDir)) {                file = file.substring(useDir.length()+1, file.length());            }            libsBuf.append(file+" ");        }        return libsBuf;    }    /**     * Get header files for any cells that are in a delib, but     * whose delibs are not being committed.     * @param libs     * @param cells     * @param useDir     * @return     */    static StringBuffer getHeaderFilesForCommit(List<Library> libs, List<Cell> cells, String useDir) {        if (libs == null) libs = new ArrayList<Library>();        if (cells == null) cells = new ArrayList<Cell>();        StringBuffer buf = new StringBuffer();        for (Cell cell : cells) {            if (libs.contains(cell.getLibrary())) continue;            if (!isDELIB(cell.getLibrary())) continue;            File libFile = TextUtils.getFile(cell.getLibrary().getLibFile());            if (libFile == null) continue;            String file = libFile.getPath();            if (file.startsWith(useDir)) {                file = file.substring(useDir.length()+1, file.length());            }            buf.append(file+File.separator+DELIB.getHeaderFile()+" ");        }        return buf;    }    /**     * Get a String of filenames for the associated cells, to pass as the     * 'files' argument to a CVS command.  Any files in 'useDir' will     * be relative names, otherwise they will be absolute file names.     * @param cells     * @return     */    static StringBuffer getCellFiles(List<Cell> cells, String useDir) {        StringBuffer cellsBuf = new StringBuffer();        if (cells == null) return cellsBuf;        for (Cell cell : cells) {            String file = getCellFile(cell).getPath();            if (file.startsWith(useDir)) {                file = file.substring(useDir.length()+1, file.length());            }            cellsBuf.append(file+" ");        }        return cellsBuf;    }    /**     * Get the Cell for the given path. The path is to be of the format     * .../libraryName.delib/cellname.view. Returns null if     * not of the correct format, if the library cannot be found, or     * if the cell cannot be found.     * @param path     * @return     */    static Cell getCellFromPath(String path) {        int delibExt = path.toLowerCase().indexOf(".delib"+File.separator);        if (delibExt ==- 1) {            // try the unix file separator, since even on windows, the            // cvs command returns file paths with the unxi separator            delibExt = path.toLowerCase().indexOf(".delib/");        }        if (delibExt == -1) return null;        // get the library        String libpath = path.substring(0, delibExt);        File libFile = new File(libpath);        String libName = libFile.getName();        Library lib = Library.findLibrary(libName);        if (lib == null) return null;        // get cell file        File file = new File(path);        String cellFile = file.getName();        int ext = cellFile.lastIndexOf('.');        if (ext == -1) return null;        String cellName = cellFile.substring(0, ext);        String view = cellFile.substring(ext+1);        View realView = View.findView(view);        if (realView == null) return null;        Cell cell = lib.findNodeProto(cellName+"{"+view+"}");        return cell;    }    /**     * Get the library for the given header file plus path.     * This string should be of the format .../libraryName.delib/header.     * Returns null if not of the correct format,     * or if the library cannot be found.     * @param headerPath     * @return     */    static Library getLibraryFromHeader(String headerPath) {        int delibExt = headerPath.toLowerCase().indexOf(".delib"+File.separator);        if (delibExt ==- 1) {            // try the unix file separator, since even on windows, the            // cvs command returns file paths with the unxi separator            delibExt = headerPath.toLowerCase().indexOf(".delib/");        }        if (delibExt == -1) return null;        // get the library        String libpath = headerPath.substring(0, delibExt);        File libFile = new File(libpath);        String filename = headerPath.substring(delibExt+7);        if (!filename.equals(DELIB.getHeaderFile()))            return null;        String libName = libFile.getName();        Library lib = Library.findLibrary(libName);        return lib;    }    /**     * Reloading libraries has the side affect that any EditWindows     * containing cells that were reloaded now point to old, unlinked     * cells instead of the new ones. This method checks for this state     * and fixes it.     */    public static void fixStaleCellReferences(List<Library> libs) {        if (libs == null) return;        for (Library lib : libs) {            State state = CVSLibrary.getState(lib);            if (state == State.CONFLICT) {                Job.getUserInterface().showErrorMessage("Conflicts updating Library "+lib.getName()+", not reloading library", "CVS Update had Conflicts");                continue;            }            fixStaleCellReferences(lib);        }    }    /**     * Reloading libraries has the side affect that any EditWindows     * containing cells that were reloaded now point to old, unlinked     * cells instead of the new ones. This method checks for this state     * and fixes it.     */    public static void fixStaleCellReferences(Library reloadedLib) {        if (reloadedLib == null) return;        for (Iterator<WindowFrame> it = WindowFrame.getWindows(); it.hasNext(); ) {            WindowFrame frame = it.next();            if (frame.getContent() instanceof EditWindow) {                EditWindow wnd = (EditWindow)frame.getContent();                Cell cell = wnd.getCell();                if (cell == null) continue;                if (!cell.isLinked()) {                    Library newLib = Library.findLibrary(cell.getLibrary().getName());                    if (newLib == null) return;                    Cell newCell = newLib.findNodeProto(cell.noLibDescribe());                    if (newCell == null) return;                    wnd.setCell(newCell, VarContext.globalContext, null);                }            }        }    }    // ------------------- Preferences --------------------    /**     * Get the repository.  In the future, there may be some     * dialog to let the user choose between multiple respositories.     * @return     */    private static String getRepository() {        return getCVSRepository();    }    private static Pref cacheCVSEnabled = Pref.makeBooleanPref("CVS Enabled", User.getUserTool().prefs, false);    public static boolean isEnabled() { return cacheCVSEnabled.getBoolean(); }    public static void setEnabled(boolean b) { cacheCVSEnabled.setBoolean(b); }    public static boolean isFactoryEnabled() { return cacheCVSEnabled.getBooleanFactoryValue(); }    private static Pref cacheCVSProgram = Pref.makeStringPref("CVS Program", User.getUserTool().prefs, "cvs");    public static String getCVSProgram() { return cacheCVSProgram.getString(); }    public static void setCVSProgram(String s) { cacheCVSProgram.setString(s); }    public static String getFactoryCVSProgram() { return cacheCVSProgram.getStringFactoryValue(); }    private static Pref cacheCVSRepository = Pref.makeStringPref("CVS Repository", User.getUserTool().prefs, "");    public static String getCVSRepository() { return cacheCVSRepository.getString(); }    public static void setCVSRepository(String s) { cacheCVSRepository.setString(s); }    public static String getFactoryCVSRepository() { return cacheCVSRepository.getStringFactoryValue(); }    private static Pref cacheCVSLastCommitMessage = Pref.makeStringPref("CVS Last Commit Message", User.getUserTool().prefs, "");    public static String getCVSLastCommitMessage() { return cacheCVSLastCommitMessage.getString(); }    public static void setCVSLastCommitMessage(String s) { cacheCVSLastCommitMessage.setString(s); }}

⌨️ 快捷键说明

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