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

📄 edit.java

📁 The ElectricTM VLSI Design System is an open-source Electronic Design Automation (EDA) system that c
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
                    Editor e = new Editor(cell.describe(false), "NEEDS UPDATE", new Date(), "", "");                    editors.add(e);                }                fieldVariableChanged("editors");            } else {                //System.out.println("Marking for CVS edit: "+args);                CVS.runCVSCommand("edit -a none "+args, "CVS Edit", useDir, System.out);            }            return true;        }        public void terminateOK() {            if (!unedit && checkConflicts) {                // if there are any editors, let the user know.                List<Editor> filteredEditors = new ArrayList<Editor>();                for (Editor e : editors) {                    if (e.getUser().equals(System.getProperty("user.name"))) continue;                    filteredEditors.add(e);                }                editors = filteredEditors;                if (editors.size() > 0) {                    JPanel panel = new JPanel(new GridBagLayout());                    GridBagConstraints constraints = new GridBagConstraints();                    constraints.gridx = 0;                    constraints.gridy = 0;                    constraints.ipady = 20;                    constraints.anchor = GridBagConstraints.WEST;                    JLabel label = new JLabel("Other Users are already Editing the following:");                    panel.add(label, constraints);                    // table of edit conflicts                    String [] headers = {"File", "User"};                    Object [][] data = new Object[editors.size()][2];                    for (int i=0; i<editors.size(); i++) {                        Editor editor = editors.get(i);                        data[i][0] = editor.getAbbrevFile();                        data[i][1] = editor.getUser();                    }                    JTable table = new JTable(data, headers);                    table.getColumnModel().getColumn(0).setPreferredWidth(300);                    table.getColumnModel().getColumn(1).setPreferredWidth(100);                    table.setPreferredScrollableViewportSize(new Dimension(400,100));                    table.setFocusable(false);                    JScrollPane scrollpane = new JScrollPane(table);                    scrollpane.setPreferredSize(new Dimension(400,100));                    Font font = new Font("Courier", Font.PLAIN, 12);                    table.setFont(font);                    constraints = new GridBagConstraints();                    constraints.gridx = 0;                    constraints.gridy = 1;                    panel.add(scrollpane, constraints);                    Object [] options = { "UNDO CHANGES", "CONTINUE ANYWAY" };                    int ret = JOptionPane.showOptionDialog(null, panel, "Edit Conflict!",                            JOptionPane.DEFAULT_OPTION, JOptionPane.WARNING_MESSAGE, null, options, options[0]);                    if (ret == 0) {                        // undo                        Undo.undo();                        return;                    }                }                (new MarkForEditJob(libs, cells, false, unedit)).startJob();            }        }    }    private static class UneditResponder implements Exec.OutputStreamCheckerListener {        List<Library> libs;        List<Cell> cells;        private UneditResponder(List<Library> libs, List<Cell> cells) {            this.libs = libs;            this.cells = cells;        }        public void matchFound(Exec process, String matched) {            process.writeln("n\n");            // set status to modified            String [] parts = matched.split("\\s+");            if (parts[0].endsWith(".jelib")) {                Library lib = Library.findLibrary(parts[0].substring(0, parts[0].length()-6));                if (lib != null) {                    CVSLibrary.setState(lib, State.MODIFIED);                }            } else {                // try delib                Cell cell = CVS.getCellFromPath(parts[0]);                if (cell != null) {                    CVSLibrary.setState(cell, State.MODIFIED);                }            }        }    }    // ---------------------- Edit State Consistency Check ------------------    /**     * Consistency check - a cell that is either modified in Electric,     * or that is CVS modified, should be marked for Edit.  A cell     * that both unmodified in Electric and CVS should not be marked     * for Edit.     */    public static void editConsistencyCheck() {        List<Library> allLibs = new ArrayList<Library>();        for (Iterator<Library> it = Library.getLibraries(); it.hasNext(); ) {            Library lib = it.next();            if (lib.isHidden()) continue;            if (!lib.isFromDisk()) continue;            allLibs.add(lib);        }        editConsistencyCheck(allLibs, new ArrayList<Cell>());    }    public static void editConsistencyCheck(List<Library> libs, List<Cell> cells) {/*        // get jelibs and delib cells in cvs        CVSLibrary.LibsCells incvs = CVSLibrary.getInCVSSorted(libs, cells);        // get unmodified in both Electric and CVS        CVSLibrary.LibsCells unmodified = new CVSLibrary.LibsCells();        for (Library lib : incvs.libs) {            if (!lib.isChanged() && CVSLibrary.getState(lib) == State.NONE)                unmodified.libs.add(lib);        }        for (Cell cell : incvs.cells) {            if (!cell.isModified(false) && CVSLibrary.getState(cell) == State.NONE)                unmodified.cells.add(cell);        }        // make sure unmodified libs/cells are not being edited by me        (new EditConsistencyCheckJob(unmodified.libs, unmodified.cells)).startJob();        // I don't make sure that modified cells are marked Edit,        // as that will be fixed once the user commits and then edits again*/        (new EditConsistencyCheckJob(libs, cells)).startJob();    }    public static class EditConsistencyCheckJob extends Job {        private List<Library> libs;        private List<Cell> cells;        private List<Editor> editors;        public EditConsistencyCheckJob(List<Library> libs, List<Cell> cells) {            super("CVS Editors Check", User.getUserTool(), Job.Type.EXAMINE, null, null, Job.Priority.USER);            this.libs = libs;            this.cells = cells;            this.editors = new ArrayList<Editor>();            if (this.libs == null) this.libs = new ArrayList<Library>();            if (this.cells == null) this.cells = new ArrayList<Cell>();        }        public boolean doIt() {            String useDir = CVS.getUseDir(libs, cells);            StringBuffer libsBuf = CVS.getLibraryFiles(libs, useDir);            StringBuffer cellsBuf = CVS.getCellFiles(cells, useDir);            String args = libsBuf + " " + cellsBuf;            if (args.trim().equals("")) return true;            // get editors            //System.out.println("Checking editors for: "+args);            ByteArrayOutputStream out = new ByteArrayOutputStream();            CVS.runCVSCommand("editors "+args, "Check CVS Editors", useDir, out);            LineNumberReader reader = new LineNumberReader(new InputStreamReader(new ByteArrayInputStream(out.toByteArray())));            editors = parseOutput(reader);            // unmark if marked for edit and unmodified in both electric and cvs            libs.clear();            cells.clear();            for (Editor e : editors) {                if (!e.getUser().equals(System.getProperty("user.name"))) continue;                ElectricObject eobj = e.findObject();                if (eobj == null) continue;                if (eobj instanceof Library) {                    Library lib = (Library)eobj;                    if (!lib.isChanged() && CVSLibrary.getState(lib) == State.NONE)                        libs.add(lib);                }                if (eobj instanceof Cell) {                    Cell cell = (Cell)eobj;                    if (!cell.isModified() && CVSLibrary.getState(cell) == State.NONE)                        cells.add(cell);                }            }            libsBuf = CVS.getLibraryFiles(libs, useDir);            cellsBuf = CVS.getCellFiles(cells, useDir);            args = libsBuf + " " + cellsBuf;            if (args.trim().equals("")) return true;            //System.out.println("Unmarking CVS edit: "+args);            CVS.runCVSCommand("unedit -l "+args, "CVS Unedit", useDir, System.out);            return true;        }    }    // ----------------------- Edit Output Parsing --------------------------    public static List<Editor> parseOutput(LineNumberReader result) {        List<Editor> editors = new ArrayList<Editor>();        for (;;) {            String line;            try {                line = result.readLine();            } catch (IOException e) {                System.out.println(e.getMessage());                break;            }            if (line == null) break;            if (line.equals("")) continue;            Editor editor = Editor.parse(line);            if (editor != null) editors.add(editor);        }        return editors;    }    /**     * See if the specified Editor is referring to me on this host,     * returns true if so, false otherwise.     * @param editor     * @return     */    static boolean isMe(Editor editor) {        if (editor.getUser().equals(getUserName()) && editor.getHostname().equals(getHostName()))            return true;        return false;    }    public static class Editor implements Serializable {        private final String file;        private final String user;        private final Date date;        private final String hostname;        private final String dir;        private final File FD;        private Editor(String file, String user, Date date, String hostname, String dir) {            this.file = file;            this.user = user;            this.date = date;            this.hostname = hostname;            this.dir = dir;            this.FD = new File(dir, file);        }        static Editor parse(String editorResultLine) {            // parse editor command result            if (editorResultLine.startsWith("?")) // running remotely lists unknown files                return null;            String parts[] = editorResultLine.split("\\t");            if (parts.length == 5) {                String abbreviatedFile = parts[0];                String user = parts[1];                DateFormat df = DateFormat.getDateInstance();                Date date;                try {                    date = df.parse(parts[2]);                } catch (java.text.ParseException e) {                    date = new Date(0);                }                String computer = parts[3];                String dir = parts[4];                return new Editor(abbreviatedFile, user, date, computer, dir);            } else {                System.out.println("Bad Editor result line format: "+editorResultLine);            }            return null;        }        public String getAbbrevFile() { return file; }        public String getUser() { return user; }        public Date getDate() { return date; }        public String getHostname() { return hostname; }        public File getFile() { return FD; }        public String getDir() { return dir; }        public ElectricObject findObject() {            String file = getAbbrevFile();            Library lib = findLibraryWithExt(file);            if (lib != null) return lib;            // must be delib cell            String [] parts = file.split("/");            lib = findLibraryWithExt(parts[0]);            if (lib == null) return null;            int ext = parts[1].lastIndexOf('.');            if (ext == -1) return lib.findNodeProto(parts[1]);            String view = parts[1].substring(ext+1);            String cellname = parts[1].substring(0, ext);            cellname = cellname + "{" + view + "}";            return lib.findNodeProto(cellname);        }        private static Library findLibraryWithExt(String libname) {            if (libname.endsWith(".delib") || libname.endsWith(".jelib")) {                return Library.findLibrary(libname.substring(0, libname.length()-6));            }            if (libname.endsWith(".elib")) {                return Library.findLibrary(libname.substring(0, libname.length()-5));            }            return null;        }    }    private static final String hostName;    private static final String userName;    static {        String name = "unknownHost";        try {            InetAddress addr = InetAddress.getLocalHost();            name = addr.getHostName();        } catch (java.net.UnknownHostException e) {        }        hostName = name;        userName = System.getProperty("user.name", "unknownUser");    }    public static final String getHostName() { return hostName; }    public static final String getUserName() { return userName; }}

⌨️ 快捷键说明

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