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

📄 ganttxmlopen.java

📁 It is all about project scheduling. GanttProject is a tool for creating a project schedule by means
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
    public ParsingContext getContext() {        return myContext;    }    public TagHandler getDefaultTagHandler() {        return new DefaultTagHandler();    }    private class DefaultTagHandler implements TagHandler {        public void startElement(String namespaceURI, String sName,                String qName, Attributes attrs) {            indent += "    ";            String eName = sName; // element name            if ("".equals(eName)) {                eName = qName; // not namespaceAware            }            if (eName.equals("description")) {                myCharacterBuffer = new StringBuffer();                typeChar = 0;            }            if (eName.equals("notes")) {                myCharacterBuffer = new StringBuffer();                typeChar = 1;                // barmeier: we know that this tag has only attibutes no nested                // tags                // we can do we need here.            }            /*             * if (eName.equals("allocation")) { String aName; int taskId = 0;             * int resourceId = 0; int load = 0; for (int i = 0; i <             * attrs.getLength(); i++) { aName = attrs.getQName(i); if             * (aName.equals("task-id")) { taskId = new             * Integer(attrs.getValue(i)).intValue(); } else if             * (aName.equals("resource-id")) { resourceId = new             * Integer(attrs.getValue(i)).intValue(); } else if             * (aName.equals("load")) { load = new             * Integer(attrs.getValue(i)).intValue(); } } // if no load is             * specified I assume 100% load // this should only be the case if             * old files // were loaded. if (load == 0) { load = 100; }             * GanttTask the_task = treePanel.getTask(taskId); HumanResource             * user = peop.getUserByNumber(resourceId - 1); //             * user.setLoad(load+user.getMaximumUnitsPerDay());             * the_task.taskUser(peop.getUserByNumber(resourceId - 1), load); }             */            int task_id = 0;            // GanttTask task = new GanttTask(new String(), new GanttCalendar(),            // 1);            // GanttTask task = myTaskManager.createTask();            // task.setLength(1);            if (attrs != null) {                for (int i = 0; i < attrs.getLength(); i++) {                    String aName = attrs.getLocalName(i); // Attr name                    if ("".equals(aName)) {                        aName = attrs.getQName(i);                        // The project part                    }                    if (eName.equals("project") && myTagStack.size()==1) {                        if (aName.equals("name")) {                            myProjectInfo._sProjectName = attrs.getValue(i);                        } else if (aName.equals("company")) {                            myProjectInfo._sOrganization = attrs.getValue(i);                        } else if (aName.equals("webLink")) {                            myProjectInfo._sWebLink = attrs.getValue(i);                        }                        // TODO: 1.12 repair scrolling to the saved date                        else if (aName.equals("view-date")) {                        	myUIFacade.getScrollingManager().scrollLeft(GanttCalendar.parseXMLDate(attrs.getValue(i)).getTime());                        }                        else if (aName.equals("view-index")) {                            viewIndex = new Integer(attrs.getValue(i))                                    .hashCode();                        } else if (aName.equals("gantt-divider-location")) {                            ganttDividerLocation = new Integer(attrs                                    .getValue(i)).intValue();                        } else if (aName.equals("resource-divider-location")) {                            resourceDividerLocation = new Integer(attrs                                    .getValue(i)).intValue();                        }                    } else if (eName.equals("tasks")) {                        if (aName.equals("color")) {                            area.setProjectLevelTaskColor(determineColor(attrs                                    .getValue(i)));                        }                    }                }            }        }        public void endElement(String namespaceURI, String sName, String qName) {            indent = indent.substring(0, indent.length() - 4);            if ("description".equals(qName)) {                myProjectInfo._sDescription = getCorrectString(myCharacterBuffer                        .toString());            } else if ("notes".equals(qName)) {                Task currentTask = myTaskManager.getTask(getContext()                        .getTaskID());                currentTask.setNotes(getCorrectString(myCharacterBuffer                        .toString()));            }        }        private final Color determineColor(String hexString) {            if (!Pattern.matches("#[0-9abcdefABCDEF]{6}+", hexString)) {                return GanttGraphicArea.taskDefaultColor;            }            int r, g, b;            r = Integer.valueOf(hexString.substring(1, 3), 16).intValue();            g = Integer.valueOf(hexString.substring(3, 5), 16).intValue();            b = Integer.valueOf(hexString.substring(5, 7), 16).intValue();            return new Color(r, g, b);        }    }    private String getCorrectString(String s) {        // return s.replaceAll("\n" + indent, "\n");        s = s.replaceAll("\n" + indent, "\n");        s = s.replaceAll(marge, "");        while (s.startsWith("\n")) {            s = s.substring(1, s.length());        }        while (s.endsWith("\n")) {            s = s.substring(0, s.length() - 1);        }        s = s.replaceAll("&#38;", "&");        s = s.replaceAll("&#60;", "<");        s = s.replaceAll("&#62;", ">");        s = s.replaceAll("&#47;", "/");        s = s.replaceAll("&#34;", "\"");        return s;    }    public void isMerging(boolean b) {        bMerge = b;    }    private StringBuffer myCharacterBuffer = new StringBuffer();    private final Stack myTagStack = new Stack();        class GanttXMLParser extends DefaultHandler {        StringBuffer textBuffer;        // ===========================================================        // SAX DocumentHandler methods        // ===========================================================        public void startDocument() throws SAXException {            super.startDocument();            myTagStack.clear();        }                public void endDocument() throws SAXException {            for (int i = 0; i < myListeners.size(); i++) {                ParsingListener l = (ParsingListener) myListeners.get(i);                l.parsingFinished();            }        }        public void startElement(String namespaceURI, String sName, // simple                // name                String qName, // qualified name                Attributes attrs) throws SAXException {            myTagStack.push(qName);            for (Iterator handlers = myTagHandlers.iterator(); handlers                    .hasNext();) {                TagHandler next = (TagHandler) handlers.next();                try {                    next.startElement(namespaceURI, sName, qName, attrs);                } catch (FileFormatException e) {                    System.err.println(e.getMessage());                }            }        }        public void endElement(String namespaceURI, String sName, String qName)                throws SAXException {            for (Iterator handlers = myTagHandlers.iterator(); handlers                    .hasNext();) {                TagHandler next = (TagHandler) handlers.next();                next.endElement(namespaceURI, sName, qName);            }            myTagStack.pop();        }        public void characters(char buf[], int offset, int len)                throws SAXException {            // len=0;            // for(int i=0;i+offset<buf.length && buf[i+offset]!='<';i++,len++);            String s = new String(buf, offset, len);            if (typeChar >= 0) {                if (IGNORABLE_WHITESPACE.matcher(s).matches()) {                    return;                }                s = s.replaceAll("^\\n\\x20*", "\n");                myCharacterBuffer.append(s);            }        }    }    static Pattern IGNORABLE_WHITESPACE = Pattern.compile("^\\s*$");    // unused code    // public int getViewIndex() {    // return viewIndex;    // }}

⌨️ 快捷键说明

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