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 MoveDownAction extends UTViewAction { 41 46 public MoveDownAction(UserTaskView utv) { 47 super(utv, NbBundle.getMessage(MoveDownAction.class, "MoveDown")); putValue(ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_DOWN, 49 InputEvent.CTRL_MASK)); 50 putValue(SMALL_ICON, new ImageIcon (Utilities.loadImage( 51 "org/netbeans/modules/tasklist/usertasks/actions/moveDown.gif"))); } 53 54 public void actionPerformed(ActionEvent e) { 55 UserTask ut = getSingleSelectedTask(); 56 Object es = utv.getTreeTable().getExpandedNodesAndSelection(); 57 ut.moveDown(); 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) != list.size() - 1; 75 } 76 setEnabled(en); 77 } 78 } 79 | Popular Tags |