1 19 20 package org.netbeans.modules.project.ui.actions; 21 22 import java.awt.event.ActionEvent ; 23 import java.awt.event.KeyEvent ; 24 import java.beans.PropertyChangeEvent ; 25 import java.beans.PropertyChangeListener ; 26 import javax.swing.Action ; 27 import javax.swing.Icon ; 28 import javax.swing.ImageIcon ; 29 import javax.swing.KeyStroke ; 30 import org.netbeans.modules.project.uiapi.ActionsFactory; 31 import org.netbeans.spi.project.ActionProvider; 32 import org.netbeans.spi.project.ui.support.ProjectActionPerformer; 33 import org.openide.actions.DeleteAction; 34 import org.openide.nodes.Node; 35 import org.openide.util.ContextAwareAction; 36 import org.openide.util.HelpCtx; 37 import org.openide.util.Lookup; 38 import org.openide.util.NbBundle; 39 import org.openide.util.Utilities; 40 import org.openide.util.actions.CallableSystemAction; 41 import org.openide.util.actions.NodeAction; 42 import org.openide.util.actions.SystemAction; 43 44 47 public class Actions implements ActionsFactory { 48 49 51 public Actions() {} 52 53 54 56 private static Action SET_AS_MAIN_PROJECT; 57 private static Action CUSTOMIZE_PROJECT; 58 private static Action OPEN_SUBPROJECTS; 59 private static Action CLOSE_PROJECT; 60 private static Action NEW_FILE; 61 private static Action COPY_PROJECT; 62 private static Action MOVE_PROJECT; 63 private static Action RENAME_PROJECT; 64 65 public synchronized Action setAsMainProjectAction() { 66 if ( SET_AS_MAIN_PROJECT == null ) { 67 SET_AS_MAIN_PROJECT = new SetMainProject(); 68 } 69 return SET_AS_MAIN_PROJECT; 70 } 71 72 public synchronized Action customizeProjectAction() { 73 if ( CUSTOMIZE_PROJECT == null ) { 74 CUSTOMIZE_PROJECT = new CustomizeProject(); 75 } 76 return CUSTOMIZE_PROJECT; 77 } 78 79 public synchronized Action openSubprojectsAction() { 80 if ( OPEN_SUBPROJECTS == null ) { 81 OPEN_SUBPROJECTS = new OpenSubprojects(); 82 } 83 return OPEN_SUBPROJECTS; 84 } 85 86 public synchronized Action closeProjectAction() { 87 if ( CLOSE_PROJECT == null ) { 88 CLOSE_PROJECT = new CloseProject(); 89 } 90 return CLOSE_PROJECT; 91 } 92 93 public synchronized Action newFileAction() { 94 if ( NEW_FILE == null ) { 95 NEW_FILE = new NewFile.WithSubMenu(); 96 } 97 return NEW_FILE; 98 } 99 100 public Action deleteProjectAction() { 101 return deleteProject(); 102 } 103 104 public Action copyProjectAction() { 105 return copyProject(); 106 } 107 108 public Action moveProjectAction() { 109 return moveProject(); 110 } 111 112 public Action renameProjectAction() { 113 return renameProject(); 114 } 115 116 public synchronized Action newProjectAction() { 117 return new NewProject(); 118 } 119 120 public Action projectCommandAction(String command, String namePattern, Icon icon ) { 121 return new ProjectAction( command, namePattern, icon, null ); 122 } 123 124 public Action projectSensitiveAction( ProjectActionPerformer performer, String namePattern, Icon icon ) { 125 return new ProjectAction( performer, namePattern, icon, null ); 126 } 127 128 public Action mainProjectCommandAction(String command, String name, Icon icon) { 129 return new MainProjectAction( command, name, icon ); 130 } 131 132 public Action mainProjectSensitiveAction(ProjectActionPerformer performer, String name, Icon icon) { 133 return new MainProjectAction( performer, name, icon ); 134 } 135 136 137 public Action fileCommandAction(String command, String name, Icon icon) { 138 return new FileCommandAction( command, name, icon, null ); 139 } 140 141 143 public static Action javadocProject() { 144 return new ProjectAction ( 145 "javadoc", NbBundle.getMessage(Actions.class, "LBL_JavadocProjectAction_Name" ), null, 148 null ); 149 } 150 151 public static Action testProject() { 152 Action a = new ProjectAction ( 153 "test", NbBundle.getMessage(Actions.class, "LBL_TestProjectAction_Name" ), new ImageIcon ( Utilities.loadImage( "org/netbeans/modules/project/ui/resources/testProject.png" ) ), null ); 157 a.putValue("iconBase","org/netbeans/modules/project/ui/resources/testProject.png"); a.putValue("noIconInMenu", Boolean.TRUE); return a; 160 } 161 162 163 public static Action buildProject() { 164 Action a = new ProjectAction ( 165 ActionProvider.COMMAND_BUILD, 166 NbBundle.getMessage(Actions.class, "LBL_BuildProjectAction_Name" ), new ImageIcon ( Utilities.loadImage( "org/netbeans/modules/project/ui/resources/buildCurrentProject.gif" ) ), null ); 169 a.putValue("iconBase","org/netbeans/modules/project/ui/resources/buildCurrentProject.gif"); return a; 171 } 172 173 public static Action cleanProject() { 174 Action a = new ProjectAction( 175 ActionProvider.COMMAND_CLEAN, 176 NbBundle.getMessage(Actions.class, "LBL_CleanProjectAction_Name" ), new ImageIcon ( Utilities.loadImage( "org/netbeans/modules/project/ui/resources/cleanCurrentProject.gif" ) ), null ); 179 a.putValue("iconBase","org/netbeans/modules/project/ui/resources/cleanCurrentProject.gif"); return a; 181 } 182 183 public static Action rebuildProject() { 184 Action a = new ProjectAction( 185 ActionProvider.COMMAND_REBUILD, 186 NbBundle.getMessage(Actions.class, "LBL_RebuildProjectAction_Name"), new ImageIcon ( Utilities.loadImage( "org/netbeans/modules/project/ui/resources/rebuildCurrentProject.gif" ) ), null ); 189 a.putValue("iconBase","org/netbeans/modules/project/ui/resources/rebuildCurrentProject.gif"); return a; 191 } 192 193 public static Action runProject() { 194 Action a = new ProjectAction( 195 ActionProvider.COMMAND_RUN, 196 NbBundle.getMessage(Actions.class, "LBL_RunProjectAction_Name"), new ImageIcon ( Utilities.loadImage( "org/netbeans/modules/project/ui/resources/runCurrentProject.gif" ) ), null ); 199 a.putValue("iconBase","org/netbeans/modules/project/ui/resources/runCurrentProject.gif"); return a; 201 } 202 203 public static synchronized Action deleteProject() { 204 Action a = new ProjectAction( 205 ActionProvider.COMMAND_DELETE, 206 NbBundle.getMessage(Actions.class, "LBL_DeleteProjectAction_Name"), 207 null, 208 null ); 209 210 a.putValue(Action.ACCELERATOR_KEY, DeleteAction.get(DeleteAction.class).getValue(Action.ACCELERATOR_KEY)); 211 212 return a; 213 } 214 215 public static synchronized Action copyProject() { 216 if (COPY_PROJECT == null) { 217 Action a = new ProjectAction( 218 ActionProvider.COMMAND_COPY, 219 NbBundle.getMessage(Actions.class, "LBL_CopyProjectAction_Name"), 220 null, null ); 222 COPY_PROJECT = a; 223 } 224 225 return COPY_PROJECT; 226 } 227 228 public static synchronized Action moveProject() { 229 if (MOVE_PROJECT == null) { 230 Action a = new ProjectAction( 231 ActionProvider.COMMAND_MOVE, 232 NbBundle.getMessage(Actions.class, "LBL_MoveProjectAction_Name"), 233 null, null ); 235 MOVE_PROJECT = a; 236 } 237 238 return MOVE_PROJECT; 239 } 240 241 public static synchronized Action renameProject() { 242 if (RENAME_PROJECT == null) { 243 Action a = new ProjectAction( 244 ActionProvider.COMMAND_RENAME, 245 NbBundle.getMessage(Actions.class, "LBL_RenameProjectAction_Name"), 246 null, null ); 248 RENAME_PROJECT = a; 249 } 250 251 return RENAME_PROJECT; 252 } 253 254 256 public static Action compileSingle() { 257 Action a = new FileCommandAction ( 258 "compile.single", NbBundle.getMessage(Actions.class, "LBL_CompileSingleAction_Name" ), new ImageIcon ( Utilities.loadImage( "org/netbeans/modules/project/ui/resources/compileSingle.png" ) ), null ); a.putValue("iconBase","org/netbeans/modules/project/ui/resources/compileSingle.png"); a.putValue("noIconInMenu", Boolean.TRUE); return a; 265 } 266 267 public static Action runSingle() { 268 Action a = new FileCommandAction ( 269 "run.single", NbBundle.getMessage(Actions.class, "LBL_RunSingleAction_Name"), new ImageIcon ( Utilities.loadImage( "org/netbeans/modules/project/ui/resources/runSingle.png" ) ), null); 273 a.putValue("iconBase","org/netbeans/modules/project/ui/resources/runSingle.png"); a.putValue("noIconInMenu", Boolean.TRUE); return a; 276 } 277 278 public static Action debugSingle() { 279 Action a = new FileCommandAction ( 280 "debug.single", NbBundle.getMessage(Actions.class, "LBL_DebugSingleAction_Name"), new ImageIcon ( Utilities.loadImage( "org/netbeans/modules/project/ui/resources/debugSingle.png" ) ), null); 284 a.putValue("iconBase","org/netbeans/modules/project/ui/resources/debugSingle.png"); a.putValue("noIconInMenu", Boolean.TRUE); return a; 287 } 288 289 public static Action testSingle() { 290 Action a = new FileCommandAction ( 291 "test.single", NbBundle.getMessage(Actions.class, "LBL_TestSingleAction_Name" ), new ImageIcon ( Utilities.loadImage( "org/netbeans/modules/project/ui/resources/testSingle.png" ) ), null ); a.putValue("iconBase","org/netbeans/modules/project/ui/resources/testSingle.png"); a.putValue("noIconInMenu", Boolean.TRUE); return a; 298 } 299 300 public static Action debugTestSingle() { 301 Action a = new FileCommandAction ( 302 "debug.test.single", NbBundle.getMessage(Actions.class, "LBL_DebugTestSingleAction_Name" ), new ImageIcon ( Utilities.loadImage( "org/netbeans/modules/project/ui/resources/debugTestSingle.png" ) ), null ); a.putValue("iconBase","org/netbeans/modules/project/ui/resources/debugTestSingle.png"); a.putValue("noIconInMenu", Boolean.TRUE); return a; 309 } 310 311 313 314 public static Action buildMainProject() { 315 Action a = new MainProjectAction ( 316 ActionProvider.COMMAND_BUILD, 317 NbBundle.getMessage(Actions.class, "LBL_BuildMainProjectAction_Name" ), 318 new ImageIcon ( Utilities.loadImage( "org/netbeans/modules/project/ui/resources/buildProject.gif" ) ) ); a.putValue("iconBase","org/netbeans/modules/project/ui/resources/buildProject.gif"); return a; 321 } 322 323 public static Action cleanMainProject() { 324 Action a = new MainProjectAction( 325 ActionProvider.COMMAND_CLEAN, 326 NbBundle.getMessage(Actions.class, "LBL_CleanMainProjectAction_Name" ), 327 new ImageIcon ( Utilities.loadImage( "org/netbeans/modules/project/ui/resources/cleanProject.gif" ) ) ); a.putValue("iconBase","org/netbeans/modules/project/ui/resources/cleanProject.gif"); return a; 330 } 331 332 public static Action rebuildMainProject() { 333 Action a = new MainProjectAction( 334 ActionProvider.COMMAND_REBUILD, 335 NbBundle.getMessage(Actions.class, "LBL_RebuildMainProjectAction_Name"), new ImageIcon ( Utilities.loadImage( "org/netbeans/modules/project/ui/resources/rebuildProject.gif" ) ) ); a.putValue("iconBase","org/netbeans/modules/project/ui/resources/rebuildProject.gif"); return a; 339 } 340 341 public static Action runMainProject() { 342 Action a = new MainProjectAction( 343 ActionProvider.COMMAND_RUN, 344 NbBundle.getMessage(Actions.class, "LBL_RunMainProjectAction_Name"), new ImageIcon ( Utilities.loadImage( "org/netbeans/modules/project/ui/resources/runProject.gif" ) ) ); a.putValue("iconBase","org/netbeans/modules/project/ui/resources/runProject.gif"); return a; 348 } 349 350 public static Action debugMainProject() { 351 Action a = new MainProjectAction( 352 ActionProvider.COMMAND_DEBUG, 353 NbBundle.getMessage(Actions.class, "LBL_DebugMainProjectAction_Name" ), new ImageIcon ( Utilities.loadImage( "org/netbeans/modules/project/ui/resources/debugProject.gif" ) ) ); a.putValue("iconBase","org/netbeans/modules/project/ui/resources/debugProject.gif"); return a; 357 } 358 359 public Action setProjectConfigurationAction() { 360 return SystemAction.get(ActiveConfigAction.class); 361 } 362 363 } 364 | Popular Tags |