1 19 20 package org.netbeans.modules.tasklist.usertasks.actions; 21 22 import java.awt.event.ActionEvent ; 23 import java.awt.event.InputEvent ; 24 import java.awt.event.KeyEvent ; 25 import javax.swing.ImageIcon ; 26 import javax.swing.KeyStroke ; 27 import javax.swing.event.ListSelectionEvent ; 28 import javax.swing.tree.TreePath ; 29 import org.netbeans.modules.tasklist.usertasks.model.UserTask; 30 import org.netbeans.modules.tasklist.usertasks.model.UserTaskObjectList; 31 import org.netbeans.modules.tasklist.usertasks.UserTaskView; 32 import org.openide.util.NbBundle; 33 import org.openide.util.Utilities; 34 35 40 public class MoveUpAction extends UTViewAction { 41 46 public MoveUpAction(UserTaskView utv) { 47 super(utv, NbBundle.getMessage(MoveUpAction.class, "MoveUp")); putValue(ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_UP, 49 InputEvent.CTRL_MASK)); 50 putValue(SMALL_ICON, new ImageIcon (Utilities.loadImage( 51 "org/netbeans/modules/tasklist/usertasks/actions/moveUp.gif"))); 52 } 53 54 public void actionPerformed(ActionEvent e) { 55 UserTask ut = getSingleSelectedTask(); 56 Object es = utv.getTreeTable().getExpandedNodesAndSelection(); 57 ut.moveUp(); 58 utv.getTreeTable().setExpandedNodesAndSelection(es); 59 TreePath tp = utv.getTreeTable().findPath(ut); 60 utv.getTreeTable().scrollTo(tp); 61 } 62 63 public void valueChanged(ListSelectionEvent e) { 64 UserTask ut = getSingleSelectedTask(); 65 boolean en = false; 66 if (utv.getTreeTable().getSortingModel().getSortedColumn() == -1 && 67 ut != null) { 68 UserTaskObjectList list; 69 if (ut.getParent() == null) 70 list = ut.getList().getSubtasks(); 71 else 72 list = ut.getParent().getSubtasks(); 73 74 en = list.indexOf(ut) != 0; 75 } 76 setEnabled(en); 77 } 78 } 79 | Popular Tags |