1 19 package org.openide.explorer; 20 21 import org.openide.nodes.*; 22 import org.openide.util.*; 23 24 import javax.swing.Action ; 25 import javax.swing.ActionMap ; 26 27 111 public final class ExplorerUtils extends Object { 112 114 ExplorerUtils() { 115 } 116 117 121 125 public static Action actionCopy(ExplorerManager em) { 126 return ExplorerManager.findExplorerActionsImpl(em).copyAction(); 127 } 128 129 133 public static Action actionCut(ExplorerManager em) { 134 return ExplorerManager.findExplorerActionsImpl(em).cutAction(); 135 } 136 137 142 public static Action actionDelete(ExplorerManager em, boolean confirm) { 143 ExplorerActionsImpl impl = ExplorerManager.findExplorerActionsImpl(em); 144 145 return impl.deleteAction(confirm); 146 } 147 148 152 public static Action actionPaste(ExplorerManager em) { 153 return ExplorerManager.findExplorerActionsImpl(em).pasteAction(); 154 } 155 156 168 public static void activateActions(ExplorerManager em, boolean enable) { 169 if (enable) { 170 ExplorerManager.findExplorerActionsImpl(em).attach(em); 171 } else { 172 ExplorerManager.findExplorerActionsImpl(em).detach(); 173 } 174 } 175 176 182 public static Lookup createLookup(ExplorerManager em, ActionMap map) { 183 return new DefaultEMLookup(em, map); 184 } 185 186 196 public static HelpCtx getHelpCtx(Node[] sel, HelpCtx def) { 197 HelpCtx result = null; 198 199 for (int i = 0; i < sel.length; i++) { 200 HelpCtx attempt = sel[i].getHelpCtx(); 201 202 if ((attempt != null) && !attempt.equals(HelpCtx.DEFAULT_HELP)) { 203 if ((result == null) || result.equals(attempt)) { 204 result = attempt; 205 } else { 206 result = null; 208 209 break; 210 } 211 } 212 } 213 214 return (result != null) ? result : def; 215 } 216 } 217 | Popular Tags |