1 9 10 package org.netbeans.modules.web.jsf.navigation.graph.actions; 11 12 import java.awt.Point ; 13 import java.awt.event.ActionEvent ; 14 import java.awt.event.ActionListener ; 15 import java.lang.ref.WeakReference ; 16 import javax.swing.JMenuItem ; 17 import javax.swing.JPopupMenu ; 18 import org.netbeans.api.visual.action.PopupMenuProvider; 19 import org.netbeans.api.visual.widget.Widget; 20 import org.netbeans.modules.web.jsf.navigation.graph.PageFlowScene; 21 import org.openide.util.Lookup; 22 import org.openide.util.NbBundle; 23 import org.openide.util.Utilities; 24 import org.openide.util.lookup.AbstractLookup; 25 import org.openide.util.lookup.InstanceContent; 26 27 31 public class PageFlowPopupProvider implements PopupMenuProvider { 32 33 PageFlowScene graphScene; 34 35 private JMenuItem miAddWebPage; 36 private JPopupMenu graphPopup; 37 38 private String addPage = NbBundle.getMessage(GraphPopupProvider.class, "MSG_AddPage"); 39 40 44 public PageFlowPopupProvider(PageFlowScene graphScene) { 45 46 this.graphScene = graphScene; 47 initialize(); 48 } 49 50 51 private static final String PATH_PAGEFLOW_ACTIONS = "PageFlowEditor/PopupActions"; private void initialize() { 55 graphPopup = Utilities.actionsToPopup( 56 SystemFileSystemSupport.getActions(PATH_PAGEFLOW_ACTIONS), 57 getLookup()); 58 } 66 67 68 69 public JPopupMenu getPopupMenu(Widget widget, Point point){ 70 return graphPopup; 71 } 72 73 74 75 private WeakReference lookupWRef = new WeakReference (null); 76 77 79 private Lookup getLookup() { 80 Lookup lookup = (Lookup)lookupWRef.get(); 81 82 if (lookup == null) { 83 InstanceContent ic = new InstanceContent(); 84 ic.add(graphScene); 86 lookup = new AbstractLookup(ic); 87 lookupWRef = new WeakReference (lookup); 88 } 89 90 return lookup; 91 } 92 93 } 94 | Popular Tags |