1 19 20 package org.netbeans.core; 21 22 import java.awt.datatransfer.Transferable ; 23 import java.util.List ; 24 25 import org.openide.nodes.*; 26 import org.openide.actions.*; 27 import org.openide.loaders.DataFolder; 28 import org.openide.util.datatransfer.NewType; 29 import org.openide.util.actions.SystemAction; 30 import org.openide.util.HelpCtx; 31 import org.openide.util.NbBundle; 32 33 39 public final class ActionsPoolNode extends DataFolder.FolderNode { 40 41 42 static SystemAction[] topStaticActions; 43 44 private static final Node.PropertySet[] NO_PROPERTIES = new Node.PropertySet[0]; 45 46 public ActionsPoolNode () { 47 this (NbPlaces.getDefault().actions ()); 48 } 49 50 52 ActionsPoolNode (DataFolder folder) { 53 folder.super(new ActionsPoolChildren(folder)); 54 super.setShortDescription(NbBundle.getBundle (ActionsPoolNode.class).getString("CTL_Actions_hint")); 56 57 super.setIconBaseWithExtension ("org/netbeans/core/resources/actions.gif"); } 59 60 public HelpCtx getHelpCtx () { 61 return new HelpCtx (ActionsPoolNode.class); 62 } 63 64 67 public NewType[] getNewTypes () { 68 return new NewType[0]; 69 } 70 71 protected void createPasteTypes (Transferable t, List s) { 72 s.clear (); 73 } 74 75 78 public SystemAction[] getActions () { 79 if (topStaticActions == null) 80 topStaticActions = new SystemAction [] { 81 SystemAction.get (FileSystemAction.class), 82 null, 83 SystemAction.get(ToolsAction.class), 84 SystemAction.get(PropertiesAction.class), 85 }; 86 return topStaticActions; 87 } 88 89 90 public Node.PropertySet[] getPropertySets () { 91 return NO_PROPERTIES; 92 } 93 94 public boolean canDestroy () { 95 return false; 96 } 97 98 public boolean canCut () { 99 return false; 100 } 101 102 public boolean canRename () { 103 return false; 104 } 105 106 109 static final class ActionsPoolChildren extends FilterNode.Children { 110 111 112 public ActionsPoolChildren (DataFolder folder) { 113 super(folder.getNodeDelegate ()); 114 } 115 116 121 protected Node copyNode (Node node) { 122 DataFolder df = (DataFolder)node.getCookie(DataFolder.class); 123 if (df != null) { 124 return new ActionsPoolNode(df); 125 } 126 return new ActionItemNode(node); 127 } 128 129 } 130 131 static final class ActionItemNode extends FilterNode { 132 133 134 static SystemAction[] staticActions; 135 136 137 ActionItemNode (Node filter) { 138 super(filter, Children.LEAF); 139 } 140 141 144 public SystemAction[] getActions () { 145 if (staticActions == null) { 146 staticActions = new SystemAction [] { 147 SystemAction.get(CopyAction.class), 148 null, 149 SystemAction.get(ToolsAction.class), 150 SystemAction.get(PropertiesAction.class), 151 }; 152 } 153 return staticActions; 154 } 155 156 158 public boolean canRename () { 159 return false; 160 } 161 162 public boolean canDestroy () { 163 return false; 164 } 165 166 public boolean canCut () { 167 return false; 168 } 169 170 171 public Node.PropertySet[] getPropertySets () { 172 185 return new Node.PropertySet[] { }; 186 } 187 188 } 190 } 191 | Popular Tags |