KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > ui > actions > ActionFactory


1 /*******************************************************************************
2  * Copyright (c) 2003, 2007 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11 package org.eclipse.ui.actions;
12
13 import java.util.Map JavaDoc;
14
15 import org.eclipse.core.runtime.IProduct;
16 import org.eclipse.core.runtime.Platform;
17 import org.eclipse.jface.action.IAction;
18 import org.eclipse.osgi.util.NLS;
19 import org.eclipse.ui.ISharedImages;
20 import org.eclipse.ui.IWorkbenchWindow;
21 import org.eclipse.ui.internal.CloseAllPerspectivesAction;
22 import org.eclipse.ui.internal.CloseAllSavedAction;
23 import org.eclipse.ui.internal.ClosePerspectiveAction;
24 import org.eclipse.ui.internal.EditActionSetsAction;
25 import org.eclipse.ui.internal.IWorkbenchGraphicConstants;
26 import org.eclipse.ui.internal.IWorkbenchHelpContextIds;
27 import org.eclipse.ui.internal.IntroAction;
28 import org.eclipse.ui.internal.LockToolBarAction;
29 import org.eclipse.ui.internal.MaximizePartAction;
30 import org.eclipse.ui.internal.MinimizePartAction;
31 import org.eclipse.ui.internal.NavigationHistoryAction;
32 import org.eclipse.ui.internal.OpenPreferencesAction;
33 import org.eclipse.ui.internal.QuickAccessMenu;
34 import org.eclipse.ui.internal.QuitAction;
35 import org.eclipse.ui.internal.ResetPerspectiveAction;
36 import org.eclipse.ui.internal.SaveAction;
37 import org.eclipse.ui.internal.SaveAllAction;
38 import org.eclipse.ui.internal.SaveAsAction;
39 import org.eclipse.ui.internal.SavePerspectiveAction;
40 import org.eclipse.ui.internal.ToggleEditorsVisibilityAction;
41 import org.eclipse.ui.internal.WorkbenchEditorsAction;
42 import org.eclipse.ui.internal.WorkbenchImages;
43 import org.eclipse.ui.internal.WorkbenchMessages;
44 import org.eclipse.ui.internal.WorkbookEditorsAction;
45 import org.eclipse.ui.internal.actions.CommandAction;
46 import org.eclipse.ui.internal.actions.DynamicHelpAction;
47 import org.eclipse.ui.internal.actions.HelpContentsAction;
48 import org.eclipse.ui.internal.actions.HelpSearchAction;
49 import org.eclipse.ui.internal.actions.NewEditorAction;
50 import org.eclipse.ui.internal.actions.OpenPerspectiveDialogAction;
51 import org.eclipse.ui.services.IServiceLocator;
52
53 /**
54  * Access to standard actions provided by the workbench.
55  * <p>
56  * Most of the functionality of this class is provided by static methods and
57  * fields. Example usage:
58  *
59  * <pre>
60  * MenuManager menu = ...;
61  * ActionFactory.IWorkbenchAction closeEditorAction
62  * = ActionFactory.CLOSE.create(window);
63  * menu.add(closeEditorAction);
64  * </pre>
65  * </p>
66  * <p>
67  * Clients may declare other classes that provide additional application-specific
68  * action factories.
69  * </p>
70  *
71  * @since 3.0
72  */

73 public abstract class ActionFactory {
74
75     /**
76      * Interface for a workbench action.
77      */

78     public interface IWorkbenchAction extends IAction {
79         /**
80          * Disposes of this action. Once disposed, this action cannot be used.
81          * This operation has no effect if the action has already been
82          * disposed.
83          */

84         public void dispose();
85     }
86     
87     private static class WorkbenchCommandAction extends CommandAction implements
88             IWorkbenchAction {
89         /**
90          * @param commandIdIn
91          * @param window
92          */

93         public WorkbenchCommandAction(String JavaDoc commandIdIn,
94                 IWorkbenchWindow window) {
95             super(window, commandIdIn);
96         }
97         
98         public WorkbenchCommandAction(String JavaDoc commandIdIn, Map JavaDoc parameterMap,
99                 IServiceLocator serviceLocator) {
100             super(serviceLocator, commandIdIn, parameterMap);
101         }
102     }
103
104     /**
105      * Workbench action: Displays the About dialog. This action maintains its
106      * enablement state.
107      */

108     public static final ActionFactory ABOUT = new ActionFactory("about") { //$NON-NLS-1$
109

110         /*
111          * (non-Javadoc)
112          *
113          * @see org.eclipse.ui.actions.ActionFactory#create(org.eclipse.ui.IWorkbenchWindow)
114          */

115         public IWorkbenchAction create(IWorkbenchWindow window) {
116             if (window == null) {
117                 throw new IllegalArgumentException JavaDoc();
118             }
119
120             WorkbenchCommandAction action = new WorkbenchCommandAction(
121                     "org.eclipse.ui.help.aboutAction", window); //$NON-NLS-1$
122

123             action.setId(getId());
124             IProduct product = Platform.getProduct();
125             String JavaDoc productName = null;
126             if (product != null) {
127                 productName = product.getName();
128             }
129             if (productName == null) {
130                 productName = ""; //$NON-NLS-1$
131
}
132
133             action.setText(NLS.bind(WorkbenchMessages.AboutAction_text,
134                     productName));
135             action.setToolTipText(NLS.bind(
136                     WorkbenchMessages.AboutAction_toolTip, productName));
137             window.getWorkbench().getHelpSystem().setHelp(action,
138                     IWorkbenchHelpContextIds.ABOUT_ACTION);
139             return action;
140         }
141     };
142
143     /**
144      * Workbench action (id "activateEditor"): Activate the most recently used
145      * editor. This action maintains its enablement state.
146      */

147     public static final ActionFactory ACTIVATE_EDITOR = new ActionFactory(
148             "activateEditor") {//$NON-NLS-1$
149

150         /* (non-Javadoc)
151          * @see org.eclipse.ui.actions.ActionFactory#create(org.eclipse.ui.IWorkbenchWindow)
152          */

153         public IWorkbenchAction create(IWorkbenchWindow window) {
154             if (window == null) {
155                 throw new IllegalArgumentException JavaDoc();
156             }
157             WorkbenchCommandAction action = new WorkbenchCommandAction(
158                     "org.eclipse.ui.window.activateEditor", window); //$NON-NLS-1$
159
action.setId(getId());
160             action.setText(WorkbenchMessages.ActivateEditorAction_text);
161             action
162                     .setToolTipText(WorkbenchMessages.ActivateEditorAction_toolTip);
163             return action;
164         }
165     };
166
167     /**
168      * Workbench action (id "back"): Back. This action is a
169      * {@link RetargetAction} with id "back". This action maintains its
170      * enablement state.
171      */

172     public static final ActionFactory BACK = new ActionFactory("back") {//$NON-NLS-1$
173
/* (non-Javadoc)
174          * @see org.eclipse.ui.actions.ActionFactory#create(org.eclipse.ui.IWorkbenchWindow)
175          */

176         public IWorkbenchAction create(IWorkbenchWindow window) {
177             if (window == null) {
178                 throw new IllegalArgumentException JavaDoc();
179             }
180             RetargetAction action = new LabelRetargetAction(getId(), WorkbenchMessages.Workbench_back);
181             action.setToolTipText(WorkbenchMessages.Workbench_backToolTip);
182             window.getPartService().addPartListener(action);
183             action.setActionDefinitionId("org.eclipse.ui.navigate.back"); //$NON-NLS-1$
184
return action;
185         }
186     };
187
188     /**
189      * Workbench action (id "backardHistory"): Backward in the navigation
190      * history. This action maintains its enablement state.
191      */

192     public static final ActionFactory BACKWARD_HISTORY = new ActionFactory(
193             "backardHistory") {//$NON-NLS-1$
194
/* (non-Javadoc)
195          * @see org.eclipse.ui.actions.ActionFactory#create(org.eclipse.ui.IWorkbenchWindow)
196          */

197         public IWorkbenchAction create(IWorkbenchWindow window) {
198             if (window == null) {
199                 throw new IllegalArgumentException JavaDoc();
200             }
201             IWorkbenchAction action = new NavigationHistoryAction(window, false);
202             action.setId(getId());
203             return action;
204         }
205     };
206
207     /**
208      * Workbench action (id "close"): Close the active editor. This action
209      * maintains its enablement state.
210      */

211     public static final ActionFactory CLOSE = new ActionFactory("close") {//$NON-NLS-1$
212
/* (non-Javadoc)
213          * @see org.eclipse.ui.actions.ActionFactory#create(org.eclipse.ui.IWorkbenchWindow)
214          */

215         public IWorkbenchAction create(IWorkbenchWindow window) {
216             if (window == null) {
217                 throw new IllegalArgumentException JavaDoc();
218             }
219             WorkbenchCommandAction action=new WorkbenchCommandAction("org.eclipse.ui.file.close",window); //$NON-NLS-1$
220
action.setText(WorkbenchMessages.CloseEditorAction_text);
221             action.setToolTipText(WorkbenchMessages.CloseEditorAction_toolTip);
222             action.setId(getId());
223             return action;
224         }
225     };
226
227     /**
228      * Workbench action (id "closeAll"): Close all open editors. This action
229      * maintains its enablement state.
230      */

231     public static final ActionFactory CLOSE_ALL = new ActionFactory("closeAll") {//$NON-NLS-1$
232
/* (non-Javadoc)
233          * @see org.eclipse.ui.actions.ActionFactory#create(org.eclipse.ui.IWorkbenchWindow)
234          */

235         public IWorkbenchAction create(IWorkbenchWindow window) {
236             if (window == null) {
237                 throw new IllegalArgumentException JavaDoc();
238             }
239             WorkbenchCommandAction action=new WorkbenchCommandAction("org.eclipse.ui.file.closeAll",window); //$NON-NLS-1$
240
action.setText(WorkbenchMessages.CloseAllAction_text);
241             action.setToolTipText(WorkbenchMessages.CloseAllAction_toolTip);
242             action.setId(getId());
243             return action;
244         }
245     };
246     
247     /**
248      * Workbench action (id "closeOthers"): Close all editors except the one that
249      * is active. This action maintains its enablement state.
250      *
251      * @since 3.2
252      */

253     public static final ActionFactory CLOSE_OTHERS = new ActionFactory("closeOthers") {//$NON-NLS-1$
254
/* (non-Javadoc)
255          * @see org.eclipse.ui.actions.ActionFactory#create(org.eclipse.ui.IWorkbenchWindow)
256          */

257         public IWorkbenchAction create(IWorkbenchWindow window) {
258             if (window == null) {
259                 throw new IllegalArgumentException JavaDoc();
260             }
261             WorkbenchCommandAction action = new WorkbenchCommandAction(
262                     "org.eclipse.ui.file.closeOthers", window); //$NON-NLS-1$
263
action.setText(WorkbenchMessages.CloseOthersAction_text);
264             action.setToolTipText(WorkbenchMessages.CloseOthersAction_toolTip);
265             action.setId(getId());
266             return action;
267         }
268     };
269
270     /**
271      * Workbench action (id "closeAllPerspectives"): Closes all perspectives.
272      * This action maintains its enablement state.
273      */

274     public static final ActionFactory CLOSE_ALL_PERSPECTIVES = new ActionFactory(
275             "closeAllPerspectives") {//$NON-NLS-1$
276
/* (non-Javadoc)
277          * @see org.eclipse.ui.actions.ActionFactory#create(org.eclipse.ui.IWorkbenchWindow)
278          */

279         public IWorkbenchAction create(IWorkbenchWindow window) {
280             if (window == null) {
281                 throw new IllegalArgumentException JavaDoc();
282             }
283             IWorkbenchAction action = new CloseAllPerspectivesAction(window);
284             action.setId(getId());
285             return action;
286         }
287     };
288
289     /**
290      * Workbench action (id "closeAllSaved"): Close all open editors except
291      * those with unsaved changes. This action maintains its enablement state.
292      */

293     public static final ActionFactory CLOSE_ALL_SAVED = new ActionFactory(
294             "closeAllSaved") {//$NON-NLS-1$
295
/* (non-Javadoc)
296          * @see org.eclipse.ui.actions.ActionFactory#create(org.eclipse.ui.IWorkbenchWindow)
297          */

298         public IWorkbenchAction create(IWorkbenchWindow window) {
299             if (window == null) {
300                 throw new IllegalArgumentException JavaDoc();
301             }
302             IWorkbenchAction action = new CloseAllSavedAction(window);
303             action.setId(getId());
304             return action;
305         }
306     };
307
308     /**
309      * Workbench action (id "closePerspective"): Closes the current
310      * perspective. This action maintains its enablement state.
311      */

312     public static final ActionFactory CLOSE_PERSPECTIVE = new ActionFactory(
313             "closePerspective") {//$NON-NLS-1$
314
/* (non-Javadoc)
315          * @see org.eclipse.ui.actions.ActionFactory#create(org.eclipse.ui.IWorkbenchWindow)
316          */

317         public IWorkbenchAction create(IWorkbenchWindow window) {
318             if (window == null) {
319                 throw new IllegalArgumentException JavaDoc();
320             }
321             IWorkbenchAction action = new ClosePerspectiveAction(window);
322             action.setId(getId());
323             return action;
324         }
325     };
326
327     /**
328      * Workbench action (id "intro"): Activate the introduction extension.
329      */

330     public static final ActionFactory INTRO = new ActionFactory("intro") {//$NON-NLS-1$
331
/* (non-Javadoc)
332          * @see org.eclipse.ui.actions.ActionFactory#create(org.eclipse.ui.IWorkbenchWindow)
333          */

334         public IWorkbenchAction create(IWorkbenchWindow window) {
335             if (window == null) {
336                 throw new IllegalArgumentException JavaDoc();
337             }
338             IWorkbenchAction action = new IntroAction(window);
339             action.setId(getId());
340             return action;
341         }
342     };
343
344     /**
345      * Workbench action (id "copy"): Copy. This action is a
346      * {@link RetargetAction} with id "copy". This action maintains
347      * its enablement state.
348      */

349     public static final ActionFactory COPY = new ActionFactory("copy") {//$NON-NLS-1$
350

351         /* (non-Javadoc)
352          * @see org.eclipse.ui.actions.ActionFactory#create(org.eclipse.ui.IWorkbenchWindow)
353          */

354         public IWorkbenchAction create(IWorkbenchWindow window) {
355             if (window == null) {
356                 throw new IllegalArgumentException JavaDoc();
357             }
358             RetargetAction action = new RetargetAction(getId(),WorkbenchMessages.Workbench_copy);
359             action.setToolTipText(WorkbenchMessages.Workbench_copyToolTip);
360             window.getPartService().addPartListener(action);
361             action.setActionDefinitionId("org.eclipse.ui.edit.copy"); //$NON-NLS-1$
362
ISharedImages sharedImages = window.getWorkbench()
363                     .getSharedImages();
364             action.setImageDescriptor(sharedImages
365                     .getImageDescriptor(ISharedImages.IMG_TOOL_COPY));
366             action.setDisabledImageDescriptor(sharedImages
367                     .getImageDescriptor(ISharedImages.IMG_TOOL_COPY_DISABLED));
368             return action;
369         }
370     };
371
372     /**
373      * Workbench action (id "cut"): Cut. This action is a
374      * {@link RetargetAction} with id "cut". This action maintains
375      * its enablement state.
376      */

377     public static final ActionFactory CUT = new ActionFactory("cut") {//$NON-NLS-1$
378

379         /* (non-Javadoc)
380          * @see org.eclipse.ui.actions.ActionFactory#create(org.eclipse.ui.IWorkbenchWindow)
381          */

382         public IWorkbenchAction create(IWorkbenchWindow window) {
383             if (window == null) {
384                 throw new IllegalArgumentException JavaDoc();
385             }
386             RetargetAction action = new RetargetAction(getId(),WorkbenchMessages.Workbench_cut);
387             action.setToolTipText(WorkbenchMessages.Workbench_cutToolTip);
388             window.getPartService().addPartListener(action);
389             action.setActionDefinitionId("org.eclipse.ui.edit.cut"); //$NON-NLS-1$
390
ISharedImages sharedImages = window.getWorkbench()
391                     .getSharedImages();
392             action.setImageDescriptor(sharedImages
393                     .getImageDescriptor(ISharedImages.IMG_TOOL_CUT));
394             action.setDisabledImageDescriptor(sharedImages
395                     .getImageDescriptor(ISharedImages.IMG_TOOL_CUT_DISABLED));
396             return action;
397         }
398     };
399
400     /**
401      * Workbench action (id "delete"): Delete. This action is a
402      * {@link RetargetAction} with id "delete". This action maintains
403      * its enablement state.
404      */

405     public static final ActionFactory DELETE = new ActionFactory("delete") {//$NON-NLS-1$
406

407         /* (non-Javadoc)
408          * @see org.eclipse.ui.actions.ActionFactory#create(org.eclipse.ui.IWorkbenchWindow)
409          */

410         public IWorkbenchAction create(IWorkbenchWindow window) {
411             if (window == null) {
412                 throw new IllegalArgumentException JavaDoc();
413             }
414             RetargetAction action = new RetargetAction(getId(),WorkbenchMessages.Workbench_delete);
415             action.setToolTipText(WorkbenchMessages.Workbench_deleteToolTip);
416             window.getPartService().addPartListener(action);
417             action.setActionDefinitionId("org.eclipse.ui.edit.delete"); //$NON-NLS-1$
418
action.enableAccelerator(false);
419             window.getWorkbench().getHelpSystem().setHelp(action,
420                     IWorkbenchHelpContextIds.DELETE_RETARGET_ACTION);
421             ISharedImages sharedImages = window.getWorkbench()
422                     .getSharedImages();
423             action.setImageDescriptor(sharedImages
424                     .getImageDescriptor(ISharedImages.IMG_TOOL_DELETE));
425             action
426                     .setDisabledImageDescriptor(sharedImages
427                             .getImageDescriptor(ISharedImages.IMG_TOOL_DELETE_DISABLED));
428             return action;
429         }
430     };
431
432     /**
433      * Workbench action (id "editActionSets"): Edit the action sets. This
434      * action maintains its enablement state.
435      */

436     public static final ActionFactory EDIT_ACTION_SETS = new ActionFactory(
437             "editActionSets") {//$NON-NLS-1$
438

439         /* (non-Javadoc)
440          * @see org.eclipse.ui.actions.ActionFactory#create(org.eclipse.ui.IWorkbenchWindow)
441          */

442         public IWorkbenchAction create(IWorkbenchWindow window) {
443             if (window == null) {
444                 throw new IllegalArgumentException JavaDoc();
445             }
446             IWorkbenchAction action = new EditActionSetsAction(window);
447             action.setId(getId());
448             return action;
449         }
450     };
451
452     /**
453      * Workbench action (id "export"): Opens the export wizard. This action
454      * maintains its enablement state.
455      */

456     public static final ActionFactory EXPORT = new ActionFactory("export") {//$NON-NLS-1$
457

458         /* (non-Javadoc)
459          * @see org.eclipse.ui.actions.ActionFactory#create(org.eclipse.ui.IWorkbenchWindow)
460          */

461         public IWorkbenchAction create(IWorkbenchWindow window) {
462             if (window == null) {
463                 throw new IllegalArgumentException JavaDoc();
464             }
465             IWorkbenchAction action = new ExportResourcesAction(window);
466             action.setId(getId());
467             return action;
468         }
469     };
470
471     /**
472      * Workbench action (id "find"): Find. This action is a
473      * {@link RetargetAction} with id "find". This action maintains
474      * its enablement state.
475      */

476     public static final ActionFactory FIND = new ActionFactory("find") {//$NON-NLS-1$
477

478         /* (non-Javadoc)
479          * @see org.eclipse.ui.actions.ActionFactory#create(org.eclipse.ui.IWorkbenchWindow)
480          */

481         public IWorkbenchAction create(IWorkbenchWindow window) {
482             if (window == null) {
483                 throw new IllegalArgumentException JavaDoc();
484             }
485             RetargetAction action = new RetargetAction(getId(),WorkbenchMessages.Workbench_findReplace);
486             action.setToolTipText(WorkbenchMessages.Workbench_findReplaceToolTip);
487             window.getPartService().addPartListener(action);
488             action.setActionDefinitionId("org.eclipse.ui.edit.findReplace"); //$NON-NLS-1$
489
// Find's images are commented out due to a conflict with Search.
490
// See bug 16412.
491
// action.setImageDescriptor(WorkbenchImages.getImageDescriptor(IWorkbenchGraphicConstants.IMG_ETOOL_SEARCH_SRC));
492
// action.setDisabledImageDescriptor(WorkbenchImages.getImageDescriptor(IWorkbenchGraphicConstants.IMG_ETOOL_SEARCH_SRC_DISABLED));
493
return action;
494         }
495     };
496
497     /**
498      * Workbench action (id "forward"): Forward. This action is a
499      * {@link RetargetAction} with id "forward". This action
500      * maintains its enablement state.
501      */

502     public static final ActionFactory FORWARD = new ActionFactory("forward") {//$NON-NLS-1$
503

504         /* (non-Javadoc)
505          * @see org.eclipse.ui.actions.ActionFactory#create(org.eclipse.ui.IWorkbenchWindow)
506          */

507         public IWorkbenchAction create(IWorkbenchWindow window) {
508             if (window == null) {
509                 throw new IllegalArgumentException JavaDoc();
510             }
511             RetargetAction action = new LabelRetargetAction(getId(),WorkbenchMessages.Workbench_forward);
512             action.setToolTipText(WorkbenchMessages.Workbench_forwardToolTip);
513             window.getPartService().addPartListener(action);
514             action.setActionDefinitionId("org.eclipse.ui.navigate.forward"); //$NON-NLS-1$
515
return action;
516         }
517     };
518
519     /**
520      * Workbench action (id "forwardHistory"): Forward in the navigation
521      * history. This action maintains its enablement state.
522      */

523     public static final ActionFactory FORWARD_HISTORY = new ActionFactory(
524             "forwardHistory") {//$NON-NLS-1$
525

526         /* (non-Javadoc)
527          * @see org.eclipse.ui.actions.ActionFactory#create(org.eclipse.ui.IWorkbenchWindow)
528          */

529         public IWorkbenchAction create(IWorkbenchWindow window) {
530             if (window == null) {
531                 throw new IllegalArgumentException JavaDoc();
532             }
533             IWorkbenchAction action = new NavigationHistoryAction(window, true);
534             action.setId(getId());
535             return action;
536         }
537     };
538
539     /**
540      * Workbench action (id "goInto"): Go Into. This action is a
541      * {@link RetargetAction} with id "goInto". This action maintains
542      * its enablement state.
543      */

544     public static final ActionFactory GO_INTO = new ActionFactory("goInto") {//$NON-NLS-1$
545

546         /* (non-Javadoc)
547          * @see org.eclipse.ui.actions.ActionFactory#create(org.eclipse.ui.IWorkbenchWindow)
548          */

549         public IWorkbenchAction create(IWorkbenchWindow window) {
550             if (window == null) {
551                 throw new IllegalArgumentException JavaDoc();
552             }
553             RetargetAction action = new LabelRetargetAction(getId(),WorkbenchMessages.Workbench_goInto);
554             action.setToolTipText(WorkbenchMessages.Workbench_goIntoToolTip);
555             window.getPartService().addPartListener(action);
556             action.setActionDefinitionId("org.eclipse.ui.navigate.goInto"); //$NON-NLS-1$
557
return action;
558         }
559     };
560
561     /**
562      * Workbench action (id "import"): Opens the import wizard. This action
563      * maintains its enablement state.
564      */

565     public static final ActionFactory IMPORT = new ActionFactory("import") {//$NON-NLS-1$
566

567         /* (non-Javadoc)
568          * @see org.eclipse.ui.actions.ActionFactory#create(org.eclipse.ui.IWorkbenchWindow)
569          */

570         public IWorkbenchAction create(IWorkbenchWindow window) {
571             if (window == null) {
572                 throw new IllegalArgumentException JavaDoc();
573             }
574             IWorkbenchAction action = new ImportResourcesAction(window);
575             action.setId(getId());
576             return action;
577         }
578     };
579
580     /**
581      * Workbench action (id "lockToolBar"): Lock/unlock the workbench window
582      * tool bar. This action maintains its enablement state.
583      */

584     public static final ActionFactory LOCK_TOOL_BAR = new ActionFactory(
585             "lockToolBar") {//$NON-NLS-1$
586

587         /* (non-Javadoc)
588          * @see org.eclipse.ui.actions.ActionFactory#create(org.eclipse.ui.IWorkbenchWindow)
589          */

590         public IWorkbenchAction create(IWorkbenchWindow window) {
591             if (window == null) {
592                 throw new IllegalArgumentException JavaDoc();
593             }
594             IWorkbenchAction action = new LockToolBarAction(window);
595             action.setId(getId());
596             return action;
597         }
598     };
599
600     /**
601      * Workbench action (id "maximize"): Maximize/restore the active part. This
602      * action maintains its enablement state.
603      */

604     public static final ActionFactory MAXIMIZE = new ActionFactory("maximize") {//$NON-NLS-1$
605

606         /* (non-Javadoc)
607          * @see org.eclipse.ui.actions.ActionFactory#create(org.eclipse.ui.IWorkbenchWindow)
608          */

609         public IWorkbenchAction create(IWorkbenchWindow window) {
610             if (window == null) {
611                 throw new IllegalArgumentException JavaDoc();
612             }
613             IWorkbenchAction action = new MaximizePartAction(window);
614             action.setId(getId());
615             return action;
616         }
617     };
618
619     /**
620      * Workbench action (id "minimize"): Minimizes the active part. This
621      * action maintains its enablement state.
622      *
623      * @since 3.1
624      */

625     public static final ActionFactory MINIMIZE = new ActionFactory("minimize") {//$NON-NLS-1$
626

627         /* (non-Javadoc)
628          * @see org.eclipse.ui.actions.ActionFactory#create(org.eclipse.ui.IWorkbenchWindow)
629          */

630         public IWorkbenchAction create(IWorkbenchWindow window) {
631             if (window == null) {
632                 throw new IllegalArgumentException JavaDoc();
633             }
634             IWorkbenchAction action = new MinimizePartAction(window);
635             action.setId(getId());
636             return action;
637         }
638     };
639     
640     /**
641      * Workbench action (id "move"): Move. This action is a
642      * {@link RetargetAction} with id "move". This action maintains
643      * its enablement state.
644      */

645     public static final ActionFactory MOVE = new ActionFactory("move") {//$NON-NLS-1$
646

647         /* (non-Javadoc)
648          * @see org.eclipse.ui.actions.ActionFactory#create(org.eclipse.ui.IWorkbenchWindow)
649          */

650         public IWorkbenchAction create(IWorkbenchWindow window) {
651             if (window == null) {
652                 throw new IllegalArgumentException JavaDoc();
653             }
654             RetargetAction action = new RetargetAction(getId(),WorkbenchMessages.Workbench_move);
655             action.setToolTipText(WorkbenchMessages.Workbench_moveToolTip);
656             window.getPartService().addPartListener(action);
657             action.setActionDefinitionId("org.eclipse.ui.edit.move"); //$NON-NLS-1$
658
return action;
659         }
660     };
661
662     /**
663      * Workbench action (id "new"): Opens the new wizard dialog. This action maintains
664      * its enablement state.
665      */

666     public static final ActionFactory NEW = new ActionFactory("new") {//$NON-NLS-1$
667

668         /* (non-Javadoc)
669          * @see org.eclipse.ui.actions.ActionFactory#create(org.eclipse.ui.IWorkbenchWindow)
670          */

671         public IWorkbenchAction create(IWorkbenchWindow window) {
672             if (window == null) {
673                 throw new IllegalArgumentException JavaDoc();
674             }
675             IWorkbenchAction action = new NewWizardAction(window);
676             action.setId(getId());
677             return action;
678         }
679     };
680
681     /**
682      * Workbench action (id "newWizardDropDown"): Drop-down action which shows shows the new wizard drop down,
683      * or opens the new wizard dialog when pressed. For use in the toolbar.
684      * This action maintains its enablement state.
685      *
686      * @since 3.1
687      */

688     public static final ActionFactory NEW_WIZARD_DROP_DOWN = new ActionFactory(
689             "newWizardDropDown") { //$NON-NLS-1$
690

691         /* (non-Javadoc)
692          * @see org.eclipse.ui.actions.ActionFactory#create(org.eclipse.ui.IWorkbenchWindow)
693          */

694         public IWorkbenchAction create(IWorkbenchWindow window) {
695             if (window == null) {
696                 throw new IllegalArgumentException JavaDoc();
697             }
698             IWorkbenchAction action = new NewWizardDropDownAction(window);
699             action.setId(getId());
700             return action;
701         }
702     };
703
704     /**
705      * Workbench action (id "next"): Next. This action is a
706      * {@link RetargetAction} with id "next". This action maintains
707      * its enablement state.
708      */

709     public static final ActionFactory NEXT = new ActionFactory("next") {//$NON-NLS-1$
710

711         /* (non-Javadoc)
712          * @see org.eclipse.ui.actions.ActionFactory#create(org.eclipse.ui.IWorkbenchWindow)
713          */

714         public IWorkbenchAction create(IWorkbenchWindow window) {
715             if (window == null) {
716                 throw new IllegalArgumentException JavaDoc();
717             }
718             WorkbenchCommandAction action = new WorkbenchCommandAction(
719                     "org.eclipse.ui.navigate.next", window); //$NON-NLS-1$
720
action.setText(WorkbenchMessages.Workbench_next);
721             action.setId(getId());
722             action.setToolTipText(WorkbenchMessages.Workbench_nextToolTip);
723             return action;
724         }
725     };
726
727     /**
728      * Workbench action (id "nextEditor"): Next editor. This action maintains
729      * its enablement state.
730      * <p>
731      * <code>NEXT_EDITOR</code> and <code>PREVIOUS_EDITOR</code> form a
732      * cycle action pair. For a given window, use
733      * {@link ActionFactory#linkCycleActionPair
734      * ActionFactory.linkCycleActionPair</code>} to connect the two.
735      * </p>
736      */

737     public static final ActionFactory NEXT_EDITOR = new ActionFactory(
738             "nextEditor") {//$NON-NLS-1$
739

740         /* (non-Javadoc)
741          * @see org.eclipse.ui.actions.ActionFactory#create(org.eclipse.ui.IWorkbenchWindow)
742          */

743         public IWorkbenchAction create(IWorkbenchWindow window) {
744             if (window == null) {
745                 throw new IllegalArgumentException JavaDoc();
746             }
747             IWorkbenchAction action = new WorkbenchCommandAction(
748                     "org.eclipse.ui.window.nextEditor", //$NON-NLS-1$
749
window);
750
751             action.setText(WorkbenchMessages.CycleEditorAction_next_text);
752             action.setToolTipText(WorkbenchMessages.CycleEditorAction_next_toolTip);
753             // @issue missing action ids
754
window.getWorkbench().getHelpSystem().setHelp(action,
755                     IWorkbenchHelpContextIds.CYCLE_EDITOR_FORWARD_ACTION);
756             
757             action.setId(getId());
758             return action;
759         }
760     };
761
762     /**
763      * Workbench action (id "nextPart"): Next part. This action maintains its
764      * enablement state.
765      * <p>
766      * <code>NEXT_PART</code> and <code>PREVIOUS_PART</code> form a cycle
767      * action pair. For a given window, use
768      * {@link ActionFactory#linkCycleActionPair
769      * ActionFactory.linkCycleActionPair</code>} to connect the two.
770      * </p>
771      */

772     public static final ActionFactory NEXT_PART = new ActionFactory("nextPart") {//$NON-NLS-1$
773

774         /* (non-Javadoc)
775          * @see org.eclipse.ui.actions.ActionFactory#create(org.eclipse.ui.IWorkbenchWindow)
776          */

777         public IWorkbenchAction create(IWorkbenchWindow window) {
778             if (window == null) {
779                 throw new IllegalArgumentException JavaDoc();
780             }
781             WorkbenchCommandAction action=new WorkbenchCommandAction("org.eclipse.ui.window.nextView",window); //$NON-NLS-1$
782
action.setText(WorkbenchMessages.CyclePartAction_next_text);
783             action.setToolTipText(WorkbenchMessages.CyclePartAction_next_toolTip);
784             // @issue missing action ids
785
window.getWorkbench().getHelpSystem().setHelp(action,
786                     IWorkbenchHelpContextIds.CYCLE_PART_FORWARD_ACTION);
787             action.setId(getId());
788             return action;
789         }
790     };
791
792     /**
793      * Workbench action (id "nextPerspective"): Next perspective. This action
794      * maintains its enablement state.
795      * <p>
796      * <code>NEXT_PERSPECTIVE</code> and <code>PREVIOUS_PERSPECTIVE</code>
797      * form a cycle action pair. For a given window, use
798      * {@link ActionFactory#linkCycleActionPair
799      * ActionFactory.linkCycleActionPair</code>} to connect the two.
800      * </p>
801      */

802     public static final ActionFactory NEXT_PERSPECTIVE = new ActionFactory(
803             "nextPerspective") {//$NON-NLS-1$
804

805         /* (non-Javadoc)
806          * @see org.eclipse.ui.actions.ActionFactory#create(org.eclipse.ui.IWorkbenchWindow)
807          */

808         public IWorkbenchAction create(IWorkbenchWindow window) {
809             if (window == null) {
810                 throw new IllegalArgumentException JavaDoc();
811             }
812             WorkbenchCommandAction action=new WorkbenchCommandAction("org.eclipse.ui.window.nextPerspective",window); //$NON-NLS-1$
813
action.setText(WorkbenchMessages.CyclePerspectiveAction_next_text);
814             action.setToolTipText(WorkbenchMessages.CyclePerspectiveAction_next_toolTip);
815             // @issue missing action ids
816
window.getWorkbench().getHelpSystem().setHelp(action,
817                     IWorkbenchHelpContextIds.CYCLE_PERSPECTIVE_FORWARD_ACTION);
818             action.setId(getId());
819             return action;
820         }
821     };
822
823     /**
824      * Workbench action (id "openNewWindow"): Open a new workbench window. This
825      * action maintains its enablement state.
826      */

827     public static final ActionFactory OPEN_NEW_WINDOW = new ActionFactory(
828             "openNewWindow") {//$NON-NLS-1$
829

830         /* (non-Javadoc)
831          * @see org.eclipse.ui.actions.ActionFactory#create(org.eclipse.ui.IWorkbenchWindow)
832          */

833         public IWorkbenchAction create(IWorkbenchWindow window) {
834             if (window == null) {
835                 throw new IllegalArgumentException JavaDoc();
836             }
837             IWorkbenchAction action = new OpenInNewWindowAction(window);
838             action.setId(getId());
839             return action;
840         }
841     };
842
843     /**
844      * Workbench action (id "paste"): Paste. This action is a
845      * {@link RetargetAction} with id "paste". This action maintains
846      * its enablement state.
847      */

848     public static final ActionFactory PASTE = new ActionFactory("paste") {//$NON-NLS-1$
849

850         /* (non-Javadoc)
851          * @see org.eclipse.ui.actions.ActionFactory#create(org.eclipse.ui.IWorkbenchWindow)
852          */

853         public IWorkbenchAction create(IWorkbenchWindow window) {
854             if (window == null) {
855                 throw new IllegalArgumentException JavaDoc();
856             }
857             RetargetAction action = new RetargetAction(getId(),WorkbenchMessages.Workbench_paste);
858             action.setToolTipText(WorkbenchMessages.Workbench_pasteToolTip);
859             window.getPartService().addPartListener(action);
860             action.setActionDefinitionId("org.eclipse.ui.edit.paste"); //$NON-NLS-1$
861
ISharedImages sharedImages = window.getWorkbench()
862                     .getSharedImages();
863             action.setImageDescriptor(sharedImages
864                     .getImageDescriptor(ISharedImages.IMG_TOOL_PASTE));
865             action.setDisabledImageDescriptor(sharedImages
866                     .getImageDescriptor(ISharedImages.IMG_TOOL_PASTE_DISABLED));
867             return action;
868         }
869     };
870
871     /**
872      * Workbench action (id "preferences"): Displays the Preferences dialog.
873      * This action maintains its enablement state.
874      */

875     public static final ActionFactory PREFERENCES = new ActionFactory(
876             "preferences") {//$NON-NLS-1$
877

878         /* (non-Javadoc)
879          * @see org.eclipse.ui.actions.ActionFactory#create(org.eclipse.ui.IWorkbenchWindow)
880          */

881         public IWorkbenchAction create(IWorkbenchWindow window) {
882             if (window == null) {
883                 throw new IllegalArgumentException JavaDoc();
884             }
885             IWorkbenchAction action = new OpenPreferencesAction(window);
886             action.setId(getId());
887             return action;
888         }
889     };
890
891     /**
892      * Workbench action (id "previous"): Previous. This action is a
893      * {@link RetargetAction} with id "previous". This action
894      * maintains its enablement state.
895      */

896     public static final ActionFactory PREVIOUS = new ActionFactory("previous") {//$NON-NLS-1$
897

898         /* (non-Javadoc)
899          * @see org.eclipse.ui.actions.ActionFactory#create(org.eclipse.ui.IWorkbenchWindow)
900          */

901         public IWorkbenchAction create(IWorkbenchWindow window) {
902             if (window == null) {
903                 throw new IllegalArgumentException JavaDoc();
904             }
905             WorkbenchCommandAction action = new WorkbenchCommandAction(
906                     "org.eclipse.ui.navigate.previous", window); //$NON-NLS-1$
907
action.setText(WorkbenchMessages.Workbench_previous);
908             action.setId(getId());
909             action.setToolTipText(WorkbenchMessages.Workbench_previousToolTip);
910             return action;
911         }
912     };
913
914     /**
915      * Workbench action (id "previousEditor"): Previous editor. This action
916      * maintains its enablement state.
917      * <p>
918      * <code>NEXT_EDITOR</code> and <code>PREVIOUS_EDITOR</code> form a
919      * cycle action pair. For a given window, use
920      * {@link ActionFactory#linkCycleActionPair
921      * ActionFactory.linkCycleActionPair</code>} to connect the two.
922      * </p>
923      */

924     public static final ActionFactory PREVIOUS_EDITOR = new ActionFactory(
925             "previousEditor") {//$NON-NLS-1$
926

927         /* (non-Javadoc)
928          * @see org.eclipse.ui.actions.ActionFactory#create(org.eclipse.ui.IWorkbenchWindow)
929          */

930         public IWorkbenchAction create(IWorkbenchWindow window) {
931             if (window == null) {
932                 throw new IllegalArgumentException JavaDoc();
933             }
934             IWorkbenchAction action = new WorkbenchCommandAction(
935                     "org.eclipse.ui.window.previousEditor", //$NON-NLS-1$
936
window);
937             action.setText(WorkbenchMessages.CycleEditorAction_prev_text);
938             action.setToolTipText(WorkbenchMessages.CycleEditorAction_prev_toolTip);
939             // @issue missing action ids
940
window.getWorkbench().getHelpSystem().setHelp(action,
941                     IWorkbenchHelpContextIds.CYCLE_EDITOR_BACKWARD_ACTION);
942
943             action.setId(getId());
944             return action;
945         }
946     };
947
948     /**
949      * Workbench action (id "previousPart"): Previous part. This action
950      * maintains its enablement state.
951      * <p>
952      * <code>NEXT_PART</code> and <code>PREVIOUS_PART</code> form a cycle
953      * action pair. For a given window, use
954      * {@link ActionFactory#linkCycleActionPair
955      * ActionFactory.linkCycleActionPair</code>} to connect the two.
956      * </p>
957      */

958     public static final ActionFactory PREVIOUS_PART = new ActionFactory(
959             "previousPart") {//$NON-NLS-1$
960

961         /* (non-Javadoc)
962          * @see org.eclipse.ui.actions.ActionFactory#create(org.eclipse.ui.IWorkbenchWindow)
963          */

964         public IWorkbenchAction create(IWorkbenchWindow window) {
965             if (window == null) {
966                 throw new IllegalArgumentException JavaDoc();
967             }
968             WorkbenchCommandAction action=new WorkbenchCommandAction("org.eclipse.ui.window.previousView",window); //$NON-NLS-1$
969
action.setText(WorkbenchMessages.CyclePartAction_prev_text);
970             action.setToolTipText(WorkbenchMessages.CyclePartAction_prev_toolTip);
971             // @issue missing action ids
972
window.getWorkbench().getHelpSystem().setHelp(action,
973                     IWorkbenchHelpContextIds.CYCLE_PART_BACKWARD_ACTION);
974             action.setId(getId());
975             return action;
976         }
977     };
978
979     /**
980      * Workbench action (id "previousPerspective"): Previous perspective. This
981      * action maintains its enablement state.
982      * <p>
983      * <code>NEXT_PERSPECTIVE</code> and <code>PREVIOUS_PERSPECTIVE</code>
984      * form a cycle action pair. For a given window, use
985      * {@link ActionFactory#linkCycleActionPair
986      * ActionFactory.linkCycleActionPair</code>} to connect the two.
987      * </p>
988      */

989     public static final ActionFactory PREVIOUS_PERSPECTIVE = new ActionFactory(
990             "previousPerspective") {//$NON-NLS-1$
991

992         /* (non-Javadoc)
993          * @see org.eclipse.ui.actions.ActionFactory#create(org.eclipse.ui.IWorkbenchWindow)
994          */

995         public IWorkbenchAction create(IWorkbenchWindow window) {
996             if (window == null) {
997                 throw new IllegalArgumentException JavaDoc();
998             }
999             WorkbenchCommandAction action=new WorkbenchCommandAction("org.eclipse.ui.window.previousPerspective",window); //$NON-NLS-1$
1000
action.setText(WorkbenchMessages.CyclePerspectiveAction_prev_text);
1001            action.setToolTipText(WorkbenchMessages.CyclePerspectiveAction_prev_toolTip);
1002            // @issue missing action ids
1003
window.getWorkbench().getHelpSystem().setHelp(action,
1004                    IWorkbenchHelpContextIds.CYCLE_PERSPECTIVE_BACKWARD_ACTION);
1005            action.setId(getId());
1006            return action;
1007        }
1008    };
1009
1010    /**
1011     * Workbench action (id "print"): Print. This action is a
1012     * {@link RetargetAction} with id "print". This action maintains
1013     * its enablement state.
1014     */

1015    public static final ActionFactory PRINT = new ActionFactory("print") {//$NON-NLS-1$
1016

1017        /* (non-Javadoc)
1018         * @see org.eclipse.ui.actions.ActionFactory#create(org.eclipse.ui.IWorkbenchWindow)
1019         */

1020        public IWorkbenchAction create(IWorkbenchWindow window) {
1021            if (window == null) {
1022                throw new IllegalArgumentException JavaDoc();
1023            }
1024            RetargetAction action = new RetargetAction(getId(),WorkbenchMessages.Workbench_print);
1025            action.setToolTipText(WorkbenchMessages.Workbench_printToolTip);
1026            window.getPartService().addPartListener(action);
1027            action.setActionDefinitionId("org.eclipse.ui.file.print"); //$NON-NLS-1$
1028
action
1029                    .setImageDescriptor(WorkbenchImages
1030                            .getImageDescriptor(IWorkbenchGraphicConstants.IMG_ETOOL_PRINT_EDIT));
1031            action
1032                    .setDisabledImageDescriptor(WorkbenchImages
1033                            .getImageDescriptor(IWorkbenchGraphicConstants.IMG_ETOOL_PRINT_EDIT_DISABLED));
1034            return action;
1035        }
1036    };
1037
1038    /**
1039     * Workbench action (id "properties"): Properties. This action is a
1040     * {@link RetargetAction} with id "properties". This action
1041     * maintains its enablement state.
1042     */

1043    public static final ActionFactory PROPERTIES = new ActionFactory(
1044            "properties") {//$NON-NLS-1$
1045

1046        /* (non-Javadoc)
1047         * @see org.eclipse.ui.actions.ActionFactory#create(org.eclipse.ui.IWorkbenchWindow)
1048         */

1049        public IWorkbenchAction create(IWorkbenchWindow window) {
1050            if (window == null) {
1051                throw new IllegalArgumentException JavaDoc();
1052            }
1053            RetargetAction action = new RetargetAction(getId(),WorkbenchMessages.Workbench_properties);
1054            action.setToolTipText(WorkbenchMessages.Workbench_propertiesToolTip);
1055            window.getPartService().addPartListener(action);
1056            action.setActionDefinitionId("org.eclipse.ui.file.properties"); //$NON-NLS-1$
1057
return action;
1058        }
1059    };
1060
1061    /**
1062     * Workbench action (id "quit"): Quit (close the workbench). This action
1063     * maintains its enablement state.
1064     */

1065    public static final ActionFactory QUIT = new ActionFactory("quit") {//$NON-NLS-1$
1066

1067        /* (non-Javadoc)
1068         * @see org.eclipse.ui.actions.ActionFactory#create(org.eclipse.ui.IWorkbenchWindow)
1069         */

1070        public IWorkbenchAction create(IWorkbenchWindow window) {
1071            if (window == null) {
1072                throw new IllegalArgumentException JavaDoc();
1073            }
1074            IWorkbenchAction action = new QuitAction(window);
1075            action.setId(getId());
1076            return action;
1077        }
1078    };
1079
1080    /**
1081     * Workbench action (id "redo"): Redo. This action is a
1082     * {@link RetargetAction} with id "redo". This action maintains
1083     * its enablement state.
1084     */

1085    public static final ActionFactory REDO = new ActionFactory("redo") {//$NON-NLS-1$
1086

1087        /* (non-Javadoc)
1088         * @see org.eclipse.ui.actions.ActionFactory#create(org.eclipse.ui.IWorkbenchWindow)
1089         */

1090        public IWorkbenchAction create(IWorkbenchWindow window) {
1091            if (window == null) {
1092                throw new IllegalArgumentException JavaDoc();
1093            }
1094            LabelRetargetAction action = new LabelRetargetAction(getId(),WorkbenchMessages.Workbench_redo);
1095            action.setToolTipText(WorkbenchMessages.Workbench_redoToolTip);
1096            window.getPartService().addPartListener(action);
1097            action.setActionDefinitionId("org.eclipse.ui.edit.redo"); //$NON-NLS-1$
1098
ISharedImages sharedImages = window.getWorkbench()
1099                    .getSharedImages();
1100            action.setImageDescriptor(sharedImages
1101                    .getImageDescriptor(ISharedImages.IMG_TOOL_REDO));
1102            action.setDisabledImageDescriptor(sharedImages
1103                    .getImageDescriptor(ISharedImages.IMG_TOOL_REDO_DISABLED));
1104            return action;
1105        }
1106    };
1107
1108    /**
1109     * Workbench action (id "refresh"): Refresh. This action is a
1110     * {@link RetargetAction} with id "refresh". This action
1111     * maintains its enablement state.
1112     */

1113    public static final ActionFactory REFRESH = new ActionFactory("refresh") {//$NON-NLS-1$
1114

1115        /* (non-Javadoc)
1116         * @see org.eclipse.ui.actions.ActionFactory#create(org.eclipse.ui.IWorkbenchWindow)
1117         */

1118        public IWorkbenchAction create(IWorkbenchWindow window) {
1119            if (window == null) {
1120                throw new IllegalArgumentException JavaDoc();
1121            }
1122            RetargetAction action = new RetargetAction(getId(),WorkbenchMessages.Workbench_refresh);
1123            action.setToolTipText(WorkbenchMessages.Workbench_refreshToolTip);
1124            window.getPartService().addPartListener(action);
1125            action.setActionDefinitionId("org.eclipse.ui.file.refresh"); //$NON-NLS-1$
1126
return action;
1127        }
1128    };
1129
1130    /**
1131     * Workbench action (id "rename"): Rename. This action is a
1132     * {@link RetargetAction} with id "rename". This action maintains
1133     * its enablement state.
1134     */

1135    public static final ActionFactory RENAME = new ActionFactory("rename") {//$NON-NLS-1$
1136

1137        /* (non-Javadoc)
1138         * @see org.eclipse.ui.actions.ActionFactory#create(org.eclipse.ui.IWorkbenchWindow)
1139         */

1140        public IWorkbenchAction create(IWorkbenchWindow window) {
1141            if (window == null) {
1142                throw new IllegalArgumentException JavaDoc();
1143            }
1144            RetargetAction action = new RetargetAction(getId(),WorkbenchMessages.Workbench_rename);
1145            action.setToolTipText(WorkbenchMessages.Workbench_renameToolTip);
1146            window.getPartService().addPartListener(action);
1147            action.setActionDefinitionId("org.eclipse.ui.edit.rename"); //$NON-NLS-1$
1148
return action;
1149        }
1150    };
1151
1152    /**
1153     * Workbench action (id "resetPerspective"): Resets the current
1154     * perspective. This action maintains its enablement state.
1155     */

1156    public static final ActionFactory RESET_PERSPECTIVE = new ActionFactory(
1157            "resetPerspective") {//$NON-NLS-1$
1158

1159        /* (non-Javadoc)
1160         * @see org.eclipse.ui.actions.ActionFactory#create(org.eclipse.ui.IWorkbenchWindow)
1161         */

1162        public IWorkbenchAction create(IWorkbenchWindow window) {
1163            if (window == null) {
1164                throw new IllegalArgumentException JavaDoc();
1165            }
1166            IWorkbenchAction action = new ResetPerspectiveAction(window);
1167            action.setId(getId());
1168            return action;
1169        }
1170    };
1171
1172    /**
1173     * Workbench action (id "revert"): Revert. This action is a
1174     * {@link RetargetAction} with id "revert". This action maintains
1175     * its enablement state.
1176     */

1177    public static final ActionFactory REVERT = new ActionFactory("revert") {//$NON-NLS-1$
1178

1179        /* (non-Javadoc)
1180         * @see org.eclipse.ui.actions.ActionFactory#create(org.eclipse.ui.IWorkbenchWindow)
1181         */

1182        public IWorkbenchAction create(IWorkbenchWindow window) {
1183            if (window == null) {
1184                throw new IllegalArgumentException JavaDoc();
1185            }
1186            RetargetAction action = new RetargetAction(getId(),WorkbenchMessages.Workbench_revert);
1187            action.setToolTipText(WorkbenchMessages.Workbench_revertToolTip);
1188            window.getPartService().addPartListener(action);
1189            action.setActionDefinitionId("org.eclipse.ui.file.revert"); //$NON-NLS-1$
1190
return action;
1191        }
1192    };
1193
1194    /**
1195     * Workbench action (id "save"): Save the active editor. This action
1196     * maintains its enablement state.
1197     */

1198    public static final ActionFactory SAVE = new ActionFactory("save") {//$NON-NLS-1$
1199

1200        /* (non-Javadoc)
1201         * @see org.eclipse.ui.actions.ActionFactory#create(org.eclipse.ui.IWorkbenchWindow)
1202         */

1203        public IWorkbenchAction create(IWorkbenchWindow window) {
1204            if (window == null) {
1205                throw new IllegalArgumentException JavaDoc();
1206            }
1207            IWorkbenchAction action = new SaveAction(window);
1208            action.setId(getId());
1209            return action;
1210        }
1211    };
1212
1213    /**
1214     * Workbench action (id "saveAll"): Save all open editors with unsaved
1215     * changes. This action maintains its enablement state.
1216     */

1217    public static final ActionFactory SAVE_ALL = new ActionFactory("saveAll") {//$NON-NLS-1$
1218

1219        /* (non-Javadoc)
1220         * @see org.eclipse.ui.actions.ActionFactory#create(org.eclipse.ui.IWorkbenchWindow)
1221         */

1222        public IWorkbenchAction create(IWorkbenchWindow window) {
1223            if (window == null) {
1224                throw new IllegalArgumentException JavaDoc();
1225            }
1226            IWorkbenchAction action = new SaveAllAction(window);
1227            action.setId(getId());
1228            return action;
1229        }
1230    };
1231
1232    /**
1233     * Workbench action (id "saveAs"): Save As for the active editor. This
1234     * action maintains its enablement state.
1235     */

1236    public static final ActionFactory SAVE_AS = new ActionFactory("saveAs") {//$NON-NLS-1$
1237

1238        /* (non-Javadoc)
1239         * @see org.eclipse.ui.actions.ActionFactory#create(org.eclipse.ui.IWorkbenchWindow)
1240         */

1241        public IWorkbenchAction create(IWorkbenchWindow window) {
1242            if (window == null) {
1243                throw new IllegalArgumentException JavaDoc();
1244            }
1245            IWorkbenchAction action = new SaveAsAction(window);
1246            action.setId(getId());
1247            return action;
1248        }
1249    };
1250
1251    /**
1252     * Workbench action (id "savePerspective"): Save the current perspective.
1253     * This action maintains its enablement state.
1254     */

1255    public static final ActionFactory SAVE_PERSPECTIVE = new ActionFactory(
1256            "savePerspective") {//$NON-NLS-1$
1257

1258        /* (non-Javadoc)
1259         * @see org.eclipse.ui.actions.ActionFactory#create(org.eclipse.ui.IWorkbenchWindow)
1260         */

1261        public IWorkbenchAction create(IWorkbenchWindow window) {
1262            if (window == null) {
1263                throw new IllegalArgumentException JavaDoc();
1264            }
1265            IWorkbenchAction action = new SavePerspectiveAction(window);
1266            action.setId(getId());
1267            return action;
1268        }
1269    };
1270
1271    /**
1272     * Workbench action (id "selectAll"): Select All. This action is a
1273     * {@link RetargetAction} with id "selectAll". This action
1274     * maintains its enablement state.
1275     */

1276    public static final ActionFactory SELECT_ALL = new ActionFactory(
1277            "selectAll") {//$NON-NLS-1$
1278

1279        /* (non-Javadoc)
1280         * @see org.eclipse.ui.actions.ActionFactory#create(org.eclipse.ui.IWorkbenchWindow)
1281         */

1282        public IWorkbenchAction create(IWorkbenchWindow window) {
1283            if (window == null) {
1284                throw new IllegalArgumentException JavaDoc();
1285            }
1286            RetargetAction action = new RetargetAction(getId(),WorkbenchMessages.Workbench_selectAll);
1287            action.setToolTipText(WorkbenchMessages.Workbench_selectAllToolTip);
1288            window.getPartService().addPartListener(action);
1289            action.setActionDefinitionId("org.eclipse.ui.edit.selectAll"); //$NON-NLS-1$
1290
return action;
1291        }
1292    };
1293
1294    /**
1295     * Workbench action (id "showEditor"): Show/hide the editor area. This
1296     * action maintains its enablement state.
1297     */

1298    public static final ActionFactory SHOW_EDITOR = new ActionFactory(
1299            "showEditor") {//$NON-NLS-1$
1300

1301        /* (non-Javadoc)
1302         * @see org.eclipse.ui.actions.ActionFactory#create(org.eclipse.ui.IWorkbenchWindow)
1303         */

1304        public IWorkbenchAction create(IWorkbenchWindow window) {
1305            if (window == null) {
1306                throw new IllegalArgumentException JavaDoc();
1307            }
1308            IWorkbenchAction action = new ToggleEditorsVisibilityAction(window);
1309            action.setId(getId());
1310            return action;
1311        }
1312    };
1313
1314    /**
1315     * Workbench action (id "showOpenEditors"): Show a list of open (and
1316     * recently closed) editors. This action maintains its enablement state.
1317     */

1318    public static final ActionFactory SHOW_OPEN_EDITORS = new ActionFactory(
1319            "showOpenEditors") {//$NON-NLS-1$
1320

1321        /* (non-Javadoc)
1322         * @see org.eclipse.ui.actions.ActionFactory#create(org.eclipse.ui.IWorkbenchWindow)
1323         */

1324        public IWorkbenchAction create(IWorkbenchWindow window) {
1325            if (window == null) {
1326                throw new IllegalArgumentException JavaDoc();
1327            }
1328            IWorkbenchAction action = new WorkbenchEditorsAction(window);
1329            action.setId(getId());
1330            return action;
1331        }
1332    };
1333
1334    /**
1335     * Workbench action (id "showWorkbookEditors"): Shows a list of open editors
1336     * in the current or last active workbook.
1337     */

1338    public static final ActionFactory SHOW_WORKBOOK_EDITORS = new ActionFactory(
1339            "showWorkBookEditors") {//$NON-NLS-1$
1340

1341        /* (non-Javadoc)
1342         * @see org.eclipse.ui.actions.ActionFactory#create(org.eclipse.ui.IWorkbenchWindow)
1343         */

1344        public IWorkbenchAction create(IWorkbenchWindow window) {
1345            if (window == null) {
1346                throw new IllegalArgumentException JavaDoc();
1347            }
1348            IWorkbenchAction action = new WorkbookEditorsAction(window);
1349            action.setId(getId());
1350            return action;
1351        }
1352    };
1353    
1354    /**
1355     * Workbench action (id "showQuickAccess"): Shows a list of UI elements like editors, views, perspectives etc.
1356     * @since 3.3
1357     */

1358    public static final ActionFactory SHOW_QUICK_ACCESS = new ActionFactory(
1359            "showQuickAccess") { //$NON-NLS-1$
1360

1361                /* (non-Javadoc)
1362                 * @see org.eclipse.ui.actions.ActionFactory#create(org.eclipse.ui.IWorkbenchWindow)
1363                 */

1364                public IWorkbenchAction create(IWorkbenchWindow window) {
1365                    IWorkbenchAction action = new QuickAccessMenu(window);
1366                    action.setId(getId());
1367                    return action;
1368                }
1369        
1370    };
1371
1372    /**
1373     * Workbench action (id "showPartPaneMenu"): Show the part pane menu. This
1374     * action maintains its enablement state.
1375     */

1376    public static final ActionFactory SHOW_PART_PANE_MENU = new ActionFactory(
1377            "showPartPaneMenu") {//$NON-NLS-1$
1378

1379        /* (non-Javadoc)
1380         * @see org.eclipse.ui.actions.ActionFactory#create(org.eclipse.ui.IWorkbenchWindow)
1381         */

1382        public IWorkbenchAction create(IWorkbenchWindow window) {
1383            if (window == null) {
1384                throw new IllegalArgumentException JavaDoc();
1385            }
1386            WorkbenchCommandAction action=new WorkbenchCommandAction("org.eclipse.ui.window.showSystemMenu",window); //$NON-NLS-1$
1387
action.setText(WorkbenchMessages.ShowPartPaneMenuAction_text);
1388            action.setToolTipText(WorkbenchMessages.ShowPartPaneMenuAction_toolTip);
1389            action.setId(getId());
1390            return action;
1391        }
1392    };
1393
1394    /**
1395     * Workbench action (id "showViewMenu"): Show the view menu. This action
1396     * maintains its enablement state.
1397     */

1398    public static final ActionFactory SHOW_VIEW_MENU = new ActionFactory(
1399            "showViewMenu") {//$NON-NLS-1$
1400

1401        /* (non-Javadoc)
1402         * @see org.eclipse.ui.actions.ActionFactory#create(org.eclipse.ui.IWorkbenchWindow)
1403         */

1404        public IWorkbenchAction create(IWorkbenchWindow window) {
1405            if (window == null) {
1406                throw new IllegalArgumentException JavaDoc();
1407            }
1408            WorkbenchCommandAction action=new WorkbenchCommandAction("org.eclipse.ui.window.showViewMenu",window); //$NON-NLS-1$
1409
action.setText(WorkbenchMessages.ShowViewMenuAction_text);
1410            action.setToolTipText(WorkbenchMessages.ShowViewMenuAction_toolTip);
1411            action.setId(getId());
1412            return action;
1413        }
1414    };
1415
1416    /**
1417     * Workbench action (id "undo"): Undo. This action is a
1418     * {@link RetargetAction} with id "undo". This action maintains
1419     * its enablement state.
1420     */

1421    public static final ActionFactory UNDO = new ActionFactory("undo") {//$NON-NLS-1$
1422

1423        /* (non-Javadoc)
1424         * @see org.eclipse.ui.actions.ActionFactory#create(org.eclipse.ui.IWorkbenchWindow)
1425         */

1426        public IWorkbenchAction create(IWorkbenchWindow window) {
1427            if (window == null) {
1428                throw new IllegalArgumentException JavaDoc();
1429            }
1430            LabelRetargetAction action = new LabelRetargetAction(getId(),WorkbenchMessages.Workbench_undo);
1431            action.setToolTipText(WorkbenchMessages.Workbench_undoToolTip);
1432            window.getPartService().addPartListener(action);
1433            action.setActionDefinitionId("org.eclipse.ui.edit.undo"); //$NON-NLS-1$
1434
ISharedImages sharedImages = window.getWorkbench()
1435                    .getSharedImages();
1436            action.setImageDescriptor(sharedImages
1437                    .getImageDescriptor(ISharedImages.IMG_TOOL_UNDO));
1438            action.setDisabledImageDescriptor(sharedImages
1439                    .getImageDescriptor(ISharedImages.IMG_TOOL_UNDO_DISABLED));
1440            return action;
1441        }
1442    };
1443
1444    /**
1445     * Workbench action (id "up"): Up. This action is a
1446     * {@link RetargetAction} with id "up". This action maintains its
1447     * enablement state.
1448     */

1449    public static final ActionFactory UP = new ActionFactory("up") {//$NON-NLS-1$
1450

1451        /* (non-Javadoc)
1452         * @see org.eclipse.ui.actions.ActionFactory#create(org.eclipse.ui.IWorkbenchWindow)
1453         */

1454        public IWorkbenchAction create(IWorkbenchWindow window) {
1455            if (window == null) {
1456                throw new IllegalArgumentException JavaDoc();
1457            }
1458            RetargetAction action = new LabelRetargetAction(getId(),WorkbenchMessages.Workbench_up);
1459            action.setToolTipText(WorkbenchMessages.Workbench_upToolTip);
1460            window.getPartService().addPartListener(action);
1461            action.setActionDefinitionId("org.eclipse.ui.navigate.up"); //$NON-NLS-1$
1462
return action;
1463        }
1464    };
1465
1466    /**
1467     * Workbench action (id "helpContents"): Open the help contents. This action
1468     * is always enabled.
1469     */

1470    public static final ActionFactory HELP_CONTENTS = new ActionFactory(
1471            "helpContents") {//$NON-NLS-1$
1472

1473        /* (non-Javadoc)
1474         * @see org.eclipse.ui.actions.ActionFactory#create(org.eclipse.ui.IWorkbenchWindow)
1475         */

1476        public IWorkbenchAction create(IWorkbenchWindow window) {
1477            if (window == null) {
1478                throw new IllegalArgumentException JavaDoc();
1479            }
1480            IWorkbenchAction action = new HelpContentsAction(window);
1481            action.setId(getId());
1482            return action;
1483        }
1484    };
1485    
1486    /**
1487     * Workbench action (id "helpSearch"): Open the help search. This action
1488     * is always enabled.
1489     *
1490     * @since 3.1
1491     */

1492    public static final ActionFactory HELP_SEARCH = new ActionFactory(
1493            "helpSearch") {//$NON-NLS-1$
1494

1495        /* (non-Javadoc)
1496         * @see org.eclipse.ui.actions.ActionFactory#create(org.eclipse.ui.IWorkbenchWindow)
1497         */

1498        public IWorkbenchAction create(IWorkbenchWindow window) {
1499            if (window == null) {
1500                throw new IllegalArgumentException JavaDoc();
1501            }
1502            IWorkbenchAction action = new HelpSearchAction(window);
1503            action.setId(getId());
1504            return action;
1505        }
1506    };
1507    
1508    /**
1509     * Workbench action (id "dynamicHelp"): Open the dynamic help. This action
1510     * is always enabled.
1511     *
1512     * @since 3.1
1513     */

1514    public static final ActionFactory DYNAMIC_HELP = new ActionFactory(
1515            "dynamicHelp") {//$NON-NLS-1$
1516

1517        /* (non-Javadoc)
1518         * @see org.eclipse.ui.actions.ActionFactory#create(org.eclipse.ui.IWorkbenchWindow)
1519         */

1520        public IWorkbenchAction create(IWorkbenchWindow window) {
1521            if (window == null) {
1522                throw new IllegalArgumentException JavaDoc();
1523            }
1524            IWorkbenchAction action = new DynamicHelpAction(window);
1525            action.setId(getId());
1526            return action;
1527        }
1528    };
1529    
1530    /**
1531     * Workbench action (id "openPerspectiveDialog"): Open the Open Perspective dialog. This action
1532     * is always enabled.
1533     *
1534     * @since 3.1
1535     */

1536    public static final ActionFactory OPEN_PERSPECTIVE_DIALOG = new ActionFactory(
1537            "openPerspectiveDialog") {//$NON-NLS-1$
1538

1539        /* (non-Javadoc)
1540         * @see org.eclipse.ui.actions.ActionFactory#create(org.eclipse.ui.IWorkbenchWindow)
1541         */

1542        public IWorkbenchAction create(IWorkbenchWindow window) {
1543            if (window == null) {
1544                throw new IllegalArgumentException JavaDoc();
1545            }
1546            IWorkbenchAction action = new OpenPerspectiveDialogAction(window);
1547            action.setId(getId());
1548            return action;
1549        }
1550    };
1551    
1552    /**
1553     * Workbench action (id "newEditor"): Open a new editor on the active editor's input.
1554     * This action maintains its enablement state.
1555     *
1556     * @since 3.1
1557     */

1558    public static final ActionFactory NEW_EDITOR = new ActionFactory(
1559            "newEditor") {//$NON-NLS-1$
1560

1561        /* (non-Javadoc)
1562         * @see org.eclipse.ui.actions.ActionFactory#create(org.eclipse.ui.IWorkbenchWindow)
1563         */

1564        public IWorkbenchAction create(IWorkbenchWindow window) {
1565            if (window == null) {
1566                throw new IllegalArgumentException JavaDoc();
1567            }
1568            IWorkbenchAction action = new NewEditorAction(window);
1569            action.setId(getId());
1570            return action;
1571        }
1572    };
1573    
1574    /**
1575     * Workbench action (id "toggleCoolbar"): Toggle the visibility of the
1576     * coolbar and perspective switcher. This will only enable visibility of the
1577     * coolbar and perspective bar if the window advisor creating the window
1578     * allowed for their visibility initially.
1579     *
1580     * @since 3.3
1581     */

1582    public static final ActionFactory TOGGLE_COOLBAR = new ActionFactory(
1583            "toggleCoolbar") { //$NON-NLS-1$
1584

1585        public IWorkbenchAction create(IWorkbenchWindow window) {
1586            if (window == null) {
1587                throw new IllegalArgumentException JavaDoc();
1588            }
1589            WorkbenchCommandAction action = new WorkbenchCommandAction(
1590                    "org.eclipse.ui.ToggleCoolbarAction", window); //$NON-NLS-1$
1591
// set the default text - this will be updated by the handler
1592
action.setText(WorkbenchMessages.ToggleCoolbarVisibilityAction_hide_text);
1593            action.setToolTipText(WorkbenchMessages.ToggleCoolbarVisibilityAction_toolTip);
1594            action.setId(getId());
1595            return action;
1596        }
1597    };
1598    
1599    /**
1600     * Establishes bi-direction connections between the forward and backward
1601     * actions of a cycle pair.
1602     * <p>
1603     * Example usage:
1604     *
1605     * <pre>
1606     * ActionFactory.IWorkbenchAction nextEditorAction = ActionFactory.NEXT_EDITOR
1607     * .create(window);
1608     * ActionFactory.IWorkbenchAction previousEditorAction = ActionFactory.PREVIOUS_EDITOR
1609     * .create(window);
1610     * ActionFactory.linkCycleActionPair(nextEditorAction, previousEditorAction);
1611     * </pre>
1612     *
1613     * </p>
1614     *
1615     * @param next
1616     * the action that moves forward
1617     * @param previous
1618     * the action that moves backward
1619     */

1620    public static void linkCycleActionPair(IWorkbenchAction next,
1621            IWorkbenchAction previous) {
1622    }
1623
1624    /**
1625     * Id of actions created by this action factory.
1626     */

1627    private final String JavaDoc actionId;
1628
1629    /**
1630     * Creates a new workbench action factory with the given id.
1631     *
1632     * @param actionId
1633     * the id of actions created by this action factory
1634     */

1635    protected ActionFactory(String JavaDoc actionId) {
1636        this.actionId = actionId;
1637    }
1638
1639    /**
1640     * Creates a new standard action for the given workbench window. The action
1641     * has an id as specified by the particular factory.
1642     * <p>
1643     * Actions automatically register listeners against the workbench window so
1644     * that they can keep their enablement state up to date. Ordinarily, the
1645     * window's references to these listeners will be dropped automatically
1646     * when the window closes. However, if the client needs to get rid of an
1647     * action while the window is still open, the client must call
1648     * {@link IWorkbenchAction#dispose dispose}to give the action an
1649     * opportunity to deregister its listeners and to perform any other
1650     * cleanup.
1651     * </p>
1652     *
1653     * @param window
1654     * the workbench window
1655     * @return the workbench action
1656     */

1657    public abstract IWorkbenchAction create(IWorkbenchWindow window);
1658
1659    /**
1660     * Returns the id of this action factory.
1661     *
1662     * @return the id of actions created by this action factory
1663     */

1664    public String JavaDoc getId() {
1665        return actionId;
1666    }
1667
1668}
1669
Popular Tags