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

📄 gantttreetable.java

📁 It is all about project scheduling. GanttProject is a tool for creating a project schedule by means
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
                break;            }        }    }    // public void changeDefaultValue(String name, Object newDefaultValue)    // {    // // this.displayColumn(name);    // }    /**     * @param facade     *            TaskContainmentHierarchyFacade ot retrive nested tasks.     * @param root     *            Root task to start with.     * @param colName     *            Name of the new custom column to add to the tasks.     * @param value     *            Value for this new custom column.     */    private void setCustomColumnValueToAllNestedTask(            TaskContainmentHierarchyFacade facade, Task root, String colName,            Object value) {        try {            root.getCustomValues().setValue(colName, value);        } catch (CustomColumnsException e) {            e.printStackTrace();        }        Task[] tt = facade.getNestedTasks(root);        for (int i = 0; i < tt.length; i++) {            try {                tt[i].getCustomValues().setValue(colName, value);            } catch (CustomColumnsException e1) {                e1.printStackTrace();            }            setCustomColumnValueToAllNestedTask(facade, tt[i], colName, value);        }    }    /**     * Remove permanetly the custom column for the task <code>root</code> and     * all its children.     *      * @param facade     *            TaskContainmentHierarchyFacade ot retrive nested tasks.     * @param root     *            Root task to start with.     * @param colName     *            Name of the custom column to remove.     */    private void removeCustomColumnToAllNestedTask(            TaskContainmentHierarchyFacade facade, Task root, String colName) {        // root.getCustomValues().removeCustomColumn(colName);        Task[] tt = facade.getNestedTasks(root);        for (int i = 0; i < tt.length; i++) {            tt[i].getCustomValues().removeCustomColumn(colName);            removeCustomColumnToAllNestedTask(facade, tt[i], colName);        }    }    private void renameCustomColumnForAllNestedTask(            TaskContainmentHierarchyFacade facade, Task root, String oldName,            String newName) {        // root.getCustomValues().renameCustomColumn(oldName,newName);        Task[] tt = facade.getNestedTasks(root);        for (int i = 0; i < tt.length; i++) {            tt[i].getCustomValues().renameCustomColumn(oldName, newName);            renameCustomColumnForAllNestedTask(facade, tt[i], oldName, newName);        }    }    /**     * Changes the language. The table headers change and also the menu items.     * For the moment when the user changes the language every columns are     * redisplayed (even if they were hidden).     *      * @param ganttLanguage     */    public void languageChanged(GanttLanguage.Event changeEvent) {        TableColumnModel tcm = this.getTable().getColumnModel();        reloadColumns();        // this.createPopupMenu();        // Component tcomp[] = popupMenu.getComponents();        //        // // The following is to check in popup menu those columns which were        // checked        // // before language change        // for (int i = 0; i < tcomp.length; i++) {        // if (tcomp[i] instanceof JCheckBoxMenuItem) {        // JCheckBoxMenuItem c = (JCheckBoxMenuItem) tcomp[i];        // // The following isn't well done...        // // catching an exception to set the menu slected or not is        // // ugly...        // // TODO make this more beautiful        // try {        // c        // .setSelected(((ColumnKeeper) mapTableColumnColumnKeeper        // .get(tcm.getColumn(tcm.getColumnIndex(c        // .getText())))).isShown);        // } catch (IllegalArgumentException e) {        // c.setSelected(false);        // }        // }        // }    }    String getIdForName(String colName) {        String id = null;        if (colName.equals(GanttTreeTableModel.strColType))            id = "tpd0";        else if (colName.equals(GanttTreeTableModel.strColPriority))            id = "tpd1";        else if (colName.equals(GanttTreeTableModel.strColInfo))            id = "tpd2";        else if (colName.equals(GanttTreeTableModel.strColName))            id = "tpd3";        else if (colName.equals(GanttTreeTableModel.strColBegDate))            id = "tpd4";        else if (colName.equals(GanttTreeTableModel.strColEndDate))            id = "tpd5";        else if (colName.equals(GanttTreeTableModel.strColDuration))            id = "tpd6";        else if (colName.equals(GanttTreeTableModel.strColCompletion))            id = "tpd7";        else if (colName.equals(GanttTreeTableModel.strColCoordinator))            id = "tpd8";        else if (colName.equals(GanttTreeTableModel.strColPredecessors))            id = "tpd9";        else if (colName.equals(GanttTreeTableModel.strColID))            id = "tpd10";        else if (colName.equals(GanttTreeTableModel.strAssignments))            id = "tpd11";        else if (colName.equals(GanttTreeTableModel.strColLineNumber))            id = "tpd12";        else            id = Mediator.getCustomColumnsStorage().getIdFromName(colName);        return id;    }    private String getNameForId(String id) {        String name = null;        if (id.equals("tpd0"))            name = GanttTreeTableModel.strColType;        else if (id.equals("tpd1"))            name = GanttTreeTableModel.strColPriority;        else if (id.equals("tpd2"))            name = GanttTreeTableModel.strColInfo;        else if (id.equals("tpd3"))            name = GanttTreeTableModel.strColName;        else if (id.equals("tpd4"))            name = GanttTreeTableModel.strColBegDate;        else if (id.equals("tpd5"))            name = GanttTreeTableModel.strColEndDate;        else if (id.equals("tpd6"))            name = GanttTreeTableModel.strColDuration;        else if (id.equals("tpd7"))            name = GanttTreeTableModel.strColCompletion;        else if (id.equals("tpd8"))            name = GanttTreeTableModel.strColCoordinator;        else if (id.equals("tpd9"))            name = GanttTreeTableModel.strColPredecessors;        else if (id.equals("tpd10"))            name = GanttTreeTableModel.strColID;        else if (id.equals("tpd11"))            name = GanttTreeTableModel.strAssignments;        else if (id.equals("tpd12"))            name = GanttTreeTableModel.strColLineNumber;        else            name = Mediator.getCustomColumnsStorage().getNameFromId(id);        return name;    }    /**     * Returns the JTree used in the treetable.     *      * @return The JTree used in the treetable.     */    public JTree getTree() {        return this.getTreeTable().getTree();    }    /**     * Returns the vertical scrollbar.     *      * @return The vertical scrollbar.     */    public JScrollBar getVerticalScrollBar() {        return scrollPane.getVerticalScrollBar();    }    public JScrollPane getScrollPane() {        return scrollPane;    }    /**     *      * @inheritDoc     *///    public void requestFocus() {//        if (getDisplayColumns().isDisplayed(GanttTreeTableModel.strColName)) {//            int c = getTable().convertColumnIndexToView(//                    getColumn(GanttTreeTableModel.strColName).getModelIndex());//            NameCellEditor ed = (NameCellEditor) getTable()//                    .getCellEditor(-1, c);//            ed.requestFocus();//        }//    }    public void centerViewOnSelectedCell() {        int row = getTable().getSelectedRow();        int col = getTable().getEditingColumn();        if (col == -1)            col = getTable().getSelectedColumn();        Rectangle rect = getTable().getCellRect(row, col, true);        scrollPane.getHorizontalScrollBar().scrollRectToVisible(rect);        scrollPane.getViewport().scrollRectToVisible(rect);    }    public void addMouseListener(MouseListener mouseListener) {        super.addMouseListener(mouseListener);        getTable().addMouseListener(mouseListener);        getTree().addMouseListener(mouseListener);        this.getTreeTable().getParent().addMouseListener(mouseListener);    }    /**     * Adds the key listener to the Table, the tree and this.     */    public void addKeyListener(KeyListener keyListener) {        super.addKeyListener(keyListener);        getTable().addKeyListener(keyListener);        getTree().addKeyListener(keyListener);    }    void setDelay(TaskNode taskNode, Delay delay) {        try {            int indexInfo = getTable().getColumnModel().getColumnIndex(                    GanttTreeTableModel.strColInfo);            indexInfo = getTable().convertColumnIndexToModel(indexInfo);            ttModel.setValueAt(delay, taskNode, indexInfo);        } catch (IllegalArgumentException e) {        }    }    /*     * ----- INNER CLASSES -----     */    public class DisplayedColumnsList extends ArrayList {        public DisplayedColumnsList() {            super();        }        /**         * Returns <code>true</code> if the column name <code>name</code> is         * displayed, <code>false</code> otherwise.         *          * @param name         *            Name of the column to check the display.         * @return <code>true</code> if the column name <code>name</code> is         *         displayed, <code>false</code> otherwise.         */        public boolean isDisplayed(String name) {            Iterator it = this.iterator();            while (it.hasNext()) {                DisplayedColumn dc = (DisplayedColumn) it.next();                if (getNameForId(dc.getID()).equals(name))                    return dc.isDisplayed();            }            return false;        }        public int getOrderForName(String name) {            Iterator it = this.iterator();            while (it.hasNext()) {                DisplayedColumn dc = (DisplayedColumn) it.next();                if (getNameForId(dc.getID()).equals(name))                    return dc.getOrder();            }            return -1;        }        public String getNameForOrder(int order) {            Iterator it = this.iterator();            while (it.hasNext()) {                DisplayedColumn dc = (DisplayedColumn) it.next();                if (dc.getOrder() == order)                    return getNameForId(dc.getID());            }            return null;        }        public boolean add(Object o) {            if (o instanceof DisplayedColumn) {                DisplayedColumn dc1 = (DisplayedColumn) o;                Iterator it = this.iterator();                while (it.hasNext()) {                    DisplayedColumn dc = (DisplayedColumn) it.next();                    if (dc.getID().equals(dc1.getID())) {                        this.remove(dc);                        return super.add(dc1);                    }                }                return super.add(dc1);            }            return false;        }        public Object clone() {            DisplayedColumnsList l = new DisplayedColumnsList();            Iterator it = this.iterator();            while (it.hasNext())                l.add(((DisplayedColumn) it.next()).clone());            return l;        }    }    public class DisplayedColumn implements Comparable {        private String id = null;        private boolean displayed = false;        private int order = -1;        private int width = 0;        public DisplayedColumn(String id) {            this.id = id;        }

⌨️ 快捷键说明

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