1 19 20 package org.netbeans.modules.tasklist.usertasks.actions; 21 22 import java.awt.Dialog ; 23 import java.awt.Dimension ; 24 import java.awt.event.ActionEvent ; 25 import javax.swing.event.ListSelectionEvent ; 26 27 import org.netbeans.modules.tasklist.usertasks.EditTaskPanel; 28 import org.netbeans.modules.tasklist.usertasks.UserTaskView; 29 import org.netbeans.modules.tasklist.usertasks.util.UTUtils; 30 import org.netbeans.modules.tasklist.usertasks.model.UserTask; 31 import org.openide.DialogDescriptor; 32 import org.openide.DialogDisplayer; 33 import org.openide.NotifyDescriptor; 34 import org.openide.nodes.Node; 35 import org.openide.text.Line; 36 import org.openide.util.HelpCtx; 37 import org.openide.util.NbBundle; 38 39 46 public class ShowTaskAction extends UTViewAction { 47 private static final long serialVersionUID = 2; 48 49 54 public ShowTaskAction(UserTaskView utv) { 55 super(utv, NbBundle.getMessage(ShowTaskAction.class, "LBL_ShowTodo")); 56 } 57 58 public void actionPerformed(ActionEvent ae) { 59 UserTask item = getSingleSelectedTask(); 61 62 EditTaskPanel panel = new EditTaskPanel(true); 63 panel.setPreferredSize(new Dimension (600, 500)); 64 panel.fillPanel(item); 65 66 if (item.getUrl() == null) { 68 Line cursor = UTUtils.findCursorPosition(null); 69 if (cursor == null) { 70 Node[] editorNodes = UTUtils.getEditorNodes(); 71 if (editorNodes != null) 72 cursor = UTUtils.findCursorPosition(editorNodes); 73 } 74 if (cursor == null) { 75 panel.setUrl(null); 76 panel.setLineNumber(0); 77 } else { 78 panel.setUrl(UTUtils.getExternalURLForLine(cursor)); 79 panel.setLineNumber(cursor.getLineNumber()); 80 } 81 } 82 83 DialogDescriptor d = new DialogDescriptor(panel, 84 NbBundle.getMessage(ShowTaskAction.class, "TITLE_edit_todo")); d.setModal(true); 86 d.setHelpCtx(new HelpCtx("org.netbeans.modules.tasklist.usertasks.NewTaskDialog")); d.setMessageType(NotifyDescriptor.PLAIN_MESSAGE); 88 d.setOptionType(NotifyDescriptor.OK_CANCEL_OPTION); 89 Dialog dlg = DialogDisplayer.getDefault().createDialog(d); 90 dlg.pack(); 91 dlg.setVisible(true); 92 93 if (d.getValue() == NotifyDescriptor.OK_OPTION) { 94 panel.fillObject(item); 95 } 96 } 97 98 public void valueChanged(ListSelectionEvent e) { 99 setEnabled(getSingleSelectedTask() != null); 100 } 101 } 102 | Popular Tags |