1 19 20 package org.netbeans.modules.xml.nbprefuse; 21 22 23 import java.awt.event.MouseEvent ; 24 import javax.swing.Action ; 25 import javax.swing.JPopupMenu ; 26 import prefuse.controls.ControlAdapter; 27 import prefuse.visual.NodeItem; 28 import prefuse.visual.VisualItem; 29 30 38 public final class PopupMouseControl extends ControlAdapter { 39 40 private VisualItem vItem; 41 42 public void itemReleased(VisualItem gi, MouseEvent e) { 43 44 super.itemReleased(gi, e); 45 vItem = gi; 46 maybeShowPopup(e); 47 } 48 49 public void itemPressed(VisualItem gi, MouseEvent e) { 50 51 super.itemPressed(gi, e); 52 vItem = gi; 53 maybeShowPopup(e); 54 } 55 56 private void maybeShowPopup(MouseEvent e) { 57 if (e.isPopupTrigger()) { 58 if (vItem instanceof NodeItem){ 59 if ((vItem.canGetBoolean(AnalysisConstants.IS_PRIMITIVE) && 60 vItem.getBoolean(AnalysisConstants.IS_PRIMITIVE) == false) 61 && 62 (hasActions()) 63 ){ 64 65 createPopup().show(e.getComponent(), 66 e.getX(), e.getY()); 67 68 } 69 } 70 } 71 } 72 73 private boolean hasActions(){ 74 85 return false; 86 } 87 88 private JPopupMenu createPopup() { 89 JPopupMenu menu = null; 90 99 return menu == null ? new JPopupMenu () : menu; 100 } 101 102 } 103 | Popular Tags |