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;
}
Aggregations