Search in sources :

Example 1 with JTreeTable

use of net.sourceforge.processdash.ui.lib.JTreeTable 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)

Aggregations

Component (java.awt.Component)1 ArrayList (java.util.ArrayList)1 Collection (java.util.Collection)1 EventObject (java.util.EventObject)1 Iterator (java.util.Iterator)1 JLabel (javax.swing.JLabel)1 JTree (javax.swing.JTree)1 TreePath (javax.swing.tree.TreePath)1 EVTask (net.sourceforge.processdash.ev.EVTask)1 EVTaskDependency (net.sourceforge.processdash.ev.EVTaskDependency)1 JTreeTable (net.sourceforge.processdash.ui.lib.JTreeTable)1