Search in sources :

Example 21 with EVTask

use of net.sourceforge.processdash.ev.EVTask in project processdash by dtuma.

the class EVWeekReport method getProjectKeys.

private Set<Integer> getProjectKeys(TableModel tasks, ProjectLocator loc) {
    // scan the tasks in the plan and make a list of the IDs for the
    // team projects they come from
    Set<String> projectIDs = new HashSet();
    for (int i = tasks.getRowCount(); i-- > 0; ) {
        EVTask task = (EVTask) tasks.getValueAt(i, EVTaskList.EVTASK_NODE_COLUMN);
        List<String> taskIds = task.getInheritedTaskIDs();
        if (!taskIds.isEmpty()) {
            // only use the first task ID.  Subsequent IDs will be for
            // master projects, which have no database representation.
            String taskId = taskIds.get(0);
            int colonPos = taskId.indexOf(':');
            if (colonPos != -1)
                projectIDs.add(taskId.substring(0, colonPos));
        }
    }
    // now look up the keys for those projects in the database. The call
    // to look up a project key will block if the project data hasn't
    // been loaded yet, so this step will ensure that data has been loaded
    // for all the projects in question before we proceed
    Set<Integer> result = new HashSet();
    for (String projectID : projectIDs) {
        Integer key = loc.getKeyForProject(projectID, null);
        if (key != null)
            result.add(key);
    }
    return result;
}
Also used : EVTask(net.sourceforge.processdash.ev.EVTask) HashSet(java.util.HashSet)

Example 22 with EVTask

use of net.sourceforge.processdash.ev.EVTask in project processdash by dtuma.

the class TaskDependencyCellEditor method getTableCellEditorComponent.

public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) {
    this.taskName = null;
    this.dependencies = new ArrayList();
    this.madeChange = false;
    JTreeTable jTreeTable = (JTreeTable) table;
    JTree jTree = jTreeTable.getTree();
    TreePath path = jTree.getPathForRow(row);
    EVTask node = null;
    if (path != null) {
        if (path.getLastPathComponent() instanceof EVTask)
            node = (EVTask) path.getLastPathComponent();
        this.taskName = node.getFullName();
    }
    if (value instanceof Collection) {
        for (Iterator i = ((Collection) value).iterator(); i.hasNext(); ) {
            Object obj = i.next();
            if (obj instanceof EVTaskDependency) {
                EVTaskDependency d = (EVTaskDependency) obj;
                // reverse/collab dependencies aren't editable - skip them
                if (!d.isReverse() && !d.isCollab())
                    dependencies.add(d);
            }
        }
    }
    // lookup the cell renderer for this row/column.  It will probably
    // be a task DependencyCellRenderer.  If so, copy the icon it is
    // displaying so we have a similar appearance.
    Component rend = table.getCellRenderer(row, column).getTableCellRendererComponent(table, value, isSelected, false, row, column);
    if (rend instanceof JLabel)
        button.setIcon(((JLabel) rend).getIcon());
    else
        button.setIcon(null);
    SwingUtilities.invokeLater(new Runnable() {

        public void run() {
            button.doClick();
        }
    });
    return button;
}
Also used : JTree(javax.swing.JTree) TreePath(javax.swing.tree.TreePath) JTreeTable(net.sourceforge.processdash.ui.lib.JTreeTable) EVTask(net.sourceforge.processdash.ev.EVTask) EVTaskDependency(net.sourceforge.processdash.ev.EVTaskDependency) ArrayList(java.util.ArrayList) Iterator(java.util.Iterator) Collection(java.util.Collection) JLabel(javax.swing.JLabel) EventObject(java.util.EventObject) Component(java.awt.Component)

Example 23 with EVTask

use of net.sourceforge.processdash.ev.EVTask in project processdash by dtuma.

the class EVReport method createSimpleCsvColumns.

private List createSimpleCsvColumns() {
    List result = new LinkedList();
    result.add(new CsvColumn("Outline_Level") {

        public void write(EVTask node, int depth) {
            out.print(depth);
        }
    });
    result.add(new CsvColumn("Name") {

        public void write(EVTask node, int depth) {
            writeStringCsvField(node.getName());
        }
    });
    result.add(new CsvDateColumn("Finish_Date") {

        public Date getNodeDate(EVTask node) {
            Date result = node.getActualDate();
            if (result == null)
                result = node.getPlanDate();
            return result;
        }
    });
    result.add(new CsvHoursColumn("Duration") {

        public double getNodeMinutes(EVTask node) {
            return node.getPlanValue();
        }
    });
    result.add(new CsvColumn("Resource_Names") {

        public void writeNode(EVTask node, int depth) {
            writeStringCsvField("");
        }

        public void writeLeaf(EVTask node, int depth) {
            writeStringCsvField(node.getAssignedToText());
        }
    });
    result.add(new CsvHoursColumn("Actual_Duration") {

        public double getNodeMinutes(EVTask node) {
            return node.getActualDirectTime();
        }
    });
    result.add(new CsvColumn("Percent_Complete") {

        public void writeNode(EVTask node, int depth) {
            out.print("0");
        }

        public void writeLeaf(EVTask node, int depth) {
            out.print(cleanupPercentComplete(node.getPercentCompleteText()));
        }
    });
    return result;
}
Also used : EVTask(net.sourceforge.processdash.ev.EVTask) List(java.util.List) ArrayList(java.util.ArrayList) MilestoneList(net.sourceforge.processdash.ev.MilestoneList) LinkedList(java.util.LinkedList) EVTaskList(net.sourceforge.processdash.ev.EVTaskList) LinkedList(java.util.LinkedList) Date(java.util.Date)

Example 24 with EVTask

use of net.sourceforge.processdash.ev.EVTask in project processdash by dtuma.

the class MSProjectXmlWriter method assignTaskUid.

private void assignTaskUid(EVTask task) {
    if (!tasksByObject.containsKey(task)) {
        boolean shouldRegisterTaskIDs = false;
        String taskKey;
        List<String> taskIDs = task.getTaskIDs();
        if (taskIDs != null && !taskIDs.isEmpty()) {
            taskKey = taskIDs.get(0);
            shouldRegisterTaskIDs = true;
        } else {
            taskKey = task.getFullName();
        }
        String keyToUse = taskKey;
        EVTask other = tasksByKey.get(taskKey);
        if (other != null) {
            shouldRegisterTaskIDs = false;
            if (other == task.getParent()) {
                String who = task.getAssignedToText();
                int personId = personUidMapper.getIdNoCreate(who);
                if (personId > 0) {
                    keyToUse = taskKey = taskKey + ";" + personId;
                    other = tasksByKey.get(taskKey);
                }
            }
            int num = 2;
            while (other != null) {
                keyToUse = taskKey + "#" + num++;
                other = tasksByKey.get(keyToUse);
            }
        }
        int id = taskUidMapper.getId(keyToUse);
        tasksByObject.put(task, id);
        tasksByKey.put(keyToUse, task);
        if (shouldRegisterTaskIDs)
            registerTaskIds(task, id);
    }
}
Also used : EVTask(net.sourceforge.processdash.ev.EVTask)

Aggregations

EVTask (net.sourceforge.processdash.ev.EVTask)24 TreePath (javax.swing.tree.TreePath)12 EVTaskList (net.sourceforge.processdash.ev.EVTaskList)8 Point (java.awt.Point)6 ArrayList (java.util.ArrayList)6 Iterator (java.util.Iterator)4 LinkedList (java.util.LinkedList)3 List (java.util.List)3 MilestoneList (net.sourceforge.processdash.ev.MilestoneList)3 Date (java.util.Date)2 HashMap (java.util.HashMap)2 EVTaskDependency (net.sourceforge.processdash.ev.EVTaskDependency)2 Component (java.awt.Component)1 Collection (java.util.Collection)1 EventObject (java.util.EventObject)1 HashSet (java.util.HashSet)1 Map (java.util.Map)1 TreeMap (java.util.TreeMap)1 JLabel (javax.swing.JLabel)1 JTree (javax.swing.JTree)1