1 19 20 package org.netbeans.modules.tasklist.usertasks.actions; 21 22 import javax.swing.AbstractAction ; 23 import javax.swing.event.ListSelectionListener ; 24 import javax.swing.tree.TreePath ; 25 import org.netbeans.modules.tasklist.usertasks.UserTaskTreeTableNode; 26 import org.netbeans.modules.tasklist.usertasks.UserTaskView; 27 import org.netbeans.modules.tasklist.usertasks.model.UserTask; 28 29 34 public abstract class UTViewAction extends AbstractAction implements 35 ListSelectionListener { 36 37 protected UserTaskView utv; 38 39 45 public UTViewAction(UserTaskView utv, String name) { 46 super(name); 47 putValue(AbstractAction.SHORT_DESCRIPTION, name); 48 this.utv = utv; 49 utv.getTreeTable().getSelectionModel().addListSelectionListener(this); 50 this.valueChanged(null); 51 } 52 53 58 protected UserTask getSingleSelectedTask() { 59 TreePath [] tp = utv.getTreeTable().getSelectedPaths(); 60 61 if (tp.length == 1 && tp[0] != null) { 63 Object last = tp[0].getLastPathComponent(); 64 if (last instanceof UserTaskTreeTableNode) { 65 return ((UserTaskTreeTableNode) last).getUserTask(); 66 } 67 } 68 return null; 69 } 70 } 71 72 | Popular Tags |