1 19 package org.netbeans.modules.tasklist.usertasks.actions; 20 21 import java.awt.event.ActionEvent ; 22 import java.beans.PropertyChangeEvent ; 23 import java.beans.PropertyChangeListener ; 24 import java.net.MalformedURLException ; 25 import java.net.URL ; 26 import javax.swing.ImageIcon ; 27 import javax.swing.event.ListSelectionEvent ; 28 import javax.swing.tree.TreePath ; 29 import org.netbeans.modules.tasklist.usertasks.UserTaskTreeTableNode; 30 import org.netbeans.modules.tasklist.usertasks.UserTaskView; 31 import org.netbeans.modules.tasklist.usertasks.model.UserTask; 32 import org.openide.awt.HtmlBrowser; 33 import org.openide.text.Line; 34 import org.openide.util.NbBundle; 35 import org.openide.util.Utilities; 36 import org.openide.util.WeakListeners; 37 38 39 46 public class GoToUserTaskAction extends UTViewAction 47 implements PropertyChangeListener { 48 private UserTask last; 49 50 55 public GoToUserTaskAction(UserTaskView utv) { 56 super(utv, NbBundle.getMessage(GoToUserTaskAction.class, 57 "LBL_Goto")); putValue(SMALL_ICON, new ImageIcon (Utilities.loadImage( 59 "org/netbeans/modules/tasklist/usertasks/actions/" + "gotosource.png"))); } 62 63 public void actionPerformed(ActionEvent e) { 64 UserTask ut = getSingleSelectedTask(); 65 if (ut.getLine() != null) 66 ut.getLine().show(Line.SHOW_GOTO); 67 else 68 HtmlBrowser.URLDisplayer.getDefault().showURL(ut.getUrl()); 69 } 70 71 public void valueChanged(ListSelectionEvent e) { 72 if (last != null) 73 last.removePropertyChangeListener(this); 74 UserTask ut = getSingleSelectedTask(); 75 setEnabled(ut != null && 76 (ut.getLine() != null || ut.getUrl() != null)); 77 last = ut; 78 if (last != null) 79 last.addPropertyChangeListener(this); 80 } 81 82 public void propertyChange(PropertyChangeEvent evt) { 83 if (evt.getPropertyName() == UserTask.PROP_URL || 84 evt.getPropertyName() == UserTask.PROP_LINE_NUMBER || 85 evt.getPropertyName() == UserTask.PROP_LINE) { 86 UserTask ut = getSingleSelectedTask(); 87 setEnabled(ut != null && 88 (ut.getLine() != null || ut.getUrl() != null)); 89 } 90 } 91 } 92 | Popular Tags |