1 11 package org.eclipse.ui.ide; 12 13 import org.eclipse.core.resources.IProject; 14 import org.eclipse.core.resources.IncrementalProjectBuilder; 15 import org.eclipse.ui.IWorkbenchWindow; 16 import org.eclipse.ui.actions.ActionFactory; 17 import org.eclipse.ui.actions.GlobalBuildAction; 18 import org.eclipse.ui.actions.NewWizardDropDownAction; 19 import org.eclipse.ui.actions.NewWizardMenu; 20 import org.eclipse.ui.actions.QuickStartAction; 21 import org.eclipse.ui.actions.RetargetAction; 22 import org.eclipse.ui.internal.ide.IDEWorkbenchMessages; 23 import org.eclipse.ui.internal.ide.TipsAndTricksAction; 24 import org.eclipse.ui.internal.ide.actions.BuildCleanAction; 25 import org.eclipse.ui.internal.ide.actions.OpenWorkspaceAction; 26 import org.eclipse.ui.internal.ide.actions.ProjectPropertyDialogAction; 27 import org.eclipse.ui.internal.ide.actions.RetargetActionWithDefault; 28 import org.eclipse.ui.internal.ide.actions.ToggleAutoBuildAction; 29 30 46 public final class IDEActionFactory { 47 48 51 private IDEActionFactory() { 52 } 54 55 60 public static final ActionFactory ADD_TASK = new ActionFactory("addTask") { 62 public IWorkbenchAction create(IWorkbenchWindow window) { 63 if (window == null) { 64 throw new IllegalArgumentException (); 65 } 66 RetargetAction action = new RetargetAction(getId(), IDEWorkbenchMessages.Workbench_addTask); 67 action.setToolTipText(IDEWorkbenchMessages.Workbench_addTaskToolTip); 68 window.getPartService().addPartListener(action); 69 action.setActionDefinitionId("org.eclipse.ui.edit.addTask"); return action; 71 } 72 }; 73 74 79 public static final ActionFactory BOOKMARK = new ActionFactory("bookmark") { 81 public IWorkbenchAction create(IWorkbenchWindow window) { 82 if (window == null) { 83 throw new IllegalArgumentException (); 84 } 85 RetargetAction action = new RetargetAction(getId(), IDEWorkbenchMessages.Workbench_addBookmark); 86 action.setToolTipText(IDEWorkbenchMessages.Workbench_addBookmarkToolTip); 87 window.getPartService().addPartListener(action); 88 action.setActionDefinitionId("org.eclipse.ui.edit.addBookmark"); return action; 90 } 91 }; 92 93 97 public static final ActionFactory BUILD = new ActionFactory("build") { 99 public IWorkbenchAction create(IWorkbenchWindow window) { 100 if (window == null) { 101 throw new IllegalArgumentException (); 102 } 103 return new GlobalBuildAction(window, 104 IncrementalProjectBuilder.INCREMENTAL_BUILD); 105 } 106 }; 107 108 113 public static final ActionFactory BUILD_CLEAN = new ActionFactory( 114 "buildClean") { 116 public IWorkbenchAction create(IWorkbenchWindow window) { 117 if (window == null) { 118 throw new IllegalArgumentException (); 119 } 120 IWorkbenchAction action = new BuildCleanAction(window); 121 action.setId(getId()); 122 return action; 123 } 124 }; 125 126 131 public static final ActionFactory BUILD_AUTOMATICALLY = new ActionFactory( 132 "buildAutomatically") { 134 public IWorkbenchAction create(IWorkbenchWindow window) { 135 if (window == null) { 136 throw new IllegalArgumentException (); 137 } 138 IWorkbenchAction action = new ToggleAutoBuildAction(window); 139 action.setId(getId()); 140 action.setActionDefinitionId("org.eclipse.ui.project.buildAutomatically"); return action; 142 } 143 }; 144 145 150 public static final ActionFactory BUILD_PROJECT = new ActionFactory( 151 "buildProject") { 153 public IWorkbenchAction create(IWorkbenchWindow window) { 154 if (window == null) { 155 throw new IllegalArgumentException (); 156 } 157 RetargetAction action = new RetargetActionWithDefault(getId(), 158 IDEWorkbenchMessages.Workbench_buildProject); 159 action.setToolTipText(IDEWorkbenchMessages.Workbench_buildProjectToolTip); 160 window.getPartService().addPartListener(action); 161 action.setActionDefinitionId("org.eclipse.ui.project.buildProject"); return action; 163 } 164 }; 165 166 171 public static final ActionFactory CLOSE_PROJECT = new ActionFactory( 172 "closeProject") { 174 public IWorkbenchAction create(IWorkbenchWindow window) { 175 if (window == null) { 176 throw new IllegalArgumentException (); 177 } 178 RetargetAction action = new RetargetAction(getId(), IDEWorkbenchMessages.CloseResourceAction_text); 179 action.setToolTipText(IDEWorkbenchMessages.CloseResourceAction_text); 180 window.getPartService().addPartListener(action); 181 action.setActionDefinitionId("org.eclipse.ui.project.closeProject"); return action; 183 } 184 }; 185 186 201 public static final ActionFactory CLOSE_UNRELATED_PROJECTS = new ActionFactory( 202 "closeUnrelatedProjects") { 204 public IWorkbenchAction create(IWorkbenchWindow window) { 205 if (window == null) { 206 throw new IllegalArgumentException (); 207 } 208 RetargetAction action = new RetargetAction(getId(), IDEWorkbenchMessages.CloseUnrelatedProjectsAction_text); 209 action.setToolTipText(IDEWorkbenchMessages.CloseUnrelatedProjectsAction_toolTip); 210 window.getPartService().addPartListener(action); 211 action.setActionDefinitionId("org.eclipse.ui.project.closeUnrelatedProjects"); return action; 213 } 214 }; 215 216 221 public static final ActionFactory NEW_WIZARD_DROP_DOWN = new ActionFactory( 222 "newWizardDropDown") { 224 public IWorkbenchAction create(IWorkbenchWindow window) { 225 if (window == null) { 226 throw new IllegalArgumentException (); 227 } 228 IWorkbenchAction innerAction = ActionFactory.NEW.create(window); 230 NewWizardMenu newWizardMenu = new NewWizardMenu(window); 231 IWorkbenchAction action = new NewWizardDropDownAction(window, 232 innerAction, newWizardMenu); 233 action.setId(getId()); 234 return action; 235 } 236 }; 237 238 243 public static final ActionFactory OPEN_PROJECT = new ActionFactory( 244 "openProject") { 246 public IWorkbenchAction create(IWorkbenchWindow window) { 247 if (window == null) { 248 throw new IllegalArgumentException (); 249 } 250 RetargetAction action = new RetargetAction(getId(), IDEWorkbenchMessages.OpenResourceAction_text); 251 action.setToolTipText(IDEWorkbenchMessages.OpenResourceAction_toolTip); 252 window.getPartService().addPartListener(action); 253 action.setActionDefinitionId("org.eclipse.ui.project.openProject"); return action; 255 } 256 }; 257 258 262 public static final ActionFactory OPEN_WORKSPACE = new ActionFactory( 263 "openWorkspace") { 265 public IWorkbenchAction create(IWorkbenchWindow window) { 266 if (window == null) { 267 throw new IllegalArgumentException (); 268 } 269 IWorkbenchAction action = new OpenWorkspaceAction(window); 270 action.setId(getId()); 271 return action; 272 } 273 }; 274 275 279 public static final ActionFactory OPEN_PROJECT_PROPERTIES = new ActionFactory( 280 "projectProperties") { 282 public IWorkbenchAction create(IWorkbenchWindow window) { 283 if (window == null) { 284 throw new IllegalArgumentException (); 285 } 286 IWorkbenchAction action = new ProjectPropertyDialogAction(window); 287 action.setId(getId()); 288 return action; 289 } 290 }; 291 292 298 public static final ActionFactory QUICK_START = new ActionFactory( 299 "quickStart") { 301 public IWorkbenchAction create(IWorkbenchWindow window) { 302 if (window == null) { 303 throw new IllegalArgumentException (); 304 } 305 IWorkbenchAction action = new QuickStartAction(window); 306 action.setId(getId()); 307 return action; 308 } 309 }; 310 311 317 public static final ActionFactory REBUILD_ALL = new ActionFactory( 318 "rebuildAll") { 320 public IWorkbenchAction create(IWorkbenchWindow window) { 321 if (window == null) { 322 throw new IllegalArgumentException (); 323 } 324 IWorkbenchAction action = new GlobalBuildAction(window, 325 IncrementalProjectBuilder.FULL_BUILD); 326 action.setId(getId()); 327 return action; 328 } 329 }; 330 331 338 public static final ActionFactory REBUILD_PROJECT = new ActionFactory( 339 "rebuildProject") { 341 public IWorkbenchAction create(IWorkbenchWindow window) { 342 if (window == null) { 343 throw new IllegalArgumentException (); 344 } 345 RetargetAction action = new RetargetAction(getId(), IDEWorkbenchMessages.Workbench_rebuildProject); 346 action.setToolTipText(IDEWorkbenchMessages.Workbench_rebuildProjectToolTip); 347 window.getPartService().addPartListener(action); 348 action 349 .setActionDefinitionId("org.eclipse.ui.project.rebuildProject"); return action; 351 } 352 }; 353 354 358 public static final ActionFactory TIPS_AND_TRICKS = new ActionFactory( 359 "tipsAndTricks") { 361 public IWorkbenchAction create(IWorkbenchWindow window) { 362 if (window == null) { 363 throw new IllegalArgumentException (); 364 } 365 IWorkbenchAction action = new TipsAndTricksAction(window); 366 action.setId(getId()); 367 return action; 368 } 369 }; 370 371 } 372 | Popular Tags |