1 19 20 28 29 package org.netbeans.modules.xml.schema.refactoring.query.actions; 30 31 import javax.swing.*; 32 33 import org.openide.util.HelpCtx; 34 import org.openide.util.NbBundle; 35 import org.openide.util.actions.NodeAction; 36 import org.openide.util.actions.Presenter; 37 import org.openide.util.actions.SystemAction; 38 39 44 public class QueryAction extends NodeAction { 45 private static final long serialVersionUID = 1L; 46 47 56 public String getName() { 57 return NbBundle.getMessage(QueryAction.class, 58 "LBL_Query"); 59 } 60 61 62 private static final SystemAction[] grouped() { 63 return new SystemAction[] { 64 SystemAction.get(FindUnusedAction.class), 65 SystemAction.get(FindCTDerivationsAction.class), 66 SystemAction.get(FindSubstitutionGroupsAction.class), 67 }; 69 } 70 71 72 public JMenuItem getPopupPresenter() { 73 return new LazyMenu(getName()); 74 } 75 76 public HelpCtx getHelpCtx() { 77 return HelpCtx.DEFAULT_HELP; 78 } 81 82 protected boolean enable(org.openide.nodes.Node[] activatedNodes) { 83 return true; 84 } 85 86 protected void performAction(org.openide.nodes.Node[] activatedNodes) { 87 assert false : "Should never be called: "; 88 } 89 90 91 94 protected class LazyMenu extends JMenu { 95 private final static long serialVersionUID = 1L; 96 97 public LazyMenu(String name) { 98 super(name); 99 } 100 101 public JPopupMenu getPopupMenu() { 102 if (getItemCount() == 0) { 103 SystemAction[] grouped = grouped(); 104 for (int i = 0; i < grouped.length; i++) { 105 SystemAction action = grouped[i]; 106 if (action == null) { 107 addSeparator(); 108 } else if (action instanceof Presenter.Popup) { 109 add(((Presenter.Popup)action).getPopupPresenter()); 110 } else { 111 assert false : "Action had no popup presenter: " + action; 112 } 113 } 114 } 115 return super.getPopupMenu(); 116 } 117 118 } 119 120 121 } 122 | Popular Tags |