0001: /*******************************************************************************
0002: * Copyright (c) 2003, 2007 IBM Corporation and others.
0003: * All rights reserved. This program and the accompanying materials
0004: * are made available under the terms of the Eclipse Public License v1.0
0005: * which accompanies this distribution, and is available at
0006: * http://www.eclipse.org/legal/epl-v10.html
0007: *
0008: * Contributors:
0009: * IBM Corporation - initial API and implementation
0010: *******************************************************************************/package org.eclipse.ui.actions;
0011:
0012: import java.util.Map;
0013:
0014: import org.eclipse.core.runtime.IProduct;
0015: import org.eclipse.core.runtime.Platform;
0016: import org.eclipse.jface.action.IAction;
0017: import org.eclipse.osgi.util.NLS;
0018: import org.eclipse.ui.ISharedImages;
0019: import org.eclipse.ui.IWorkbenchWindow;
0020: import org.eclipse.ui.internal.CloseAllPerspectivesAction;
0021: import org.eclipse.ui.internal.CloseAllSavedAction;
0022: import org.eclipse.ui.internal.ClosePerspectiveAction;
0023: import org.eclipse.ui.internal.EditActionSetsAction;
0024: import org.eclipse.ui.internal.IWorkbenchGraphicConstants;
0025: import org.eclipse.ui.internal.IWorkbenchHelpContextIds;
0026: import org.eclipse.ui.internal.IntroAction;
0027: import org.eclipse.ui.internal.LockToolBarAction;
0028: import org.eclipse.ui.internal.MaximizePartAction;
0029: import org.eclipse.ui.internal.MinimizePartAction;
0030: import org.eclipse.ui.internal.NavigationHistoryAction;
0031: import org.eclipse.ui.internal.OpenPreferencesAction;
0032: import org.eclipse.ui.internal.QuickAccessMenu;
0033: import org.eclipse.ui.internal.QuitAction;
0034: import org.eclipse.ui.internal.ResetPerspectiveAction;
0035: import org.eclipse.ui.internal.SaveAction;
0036: import org.eclipse.ui.internal.SaveAllAction;
0037: import org.eclipse.ui.internal.SaveAsAction;
0038: import org.eclipse.ui.internal.SavePerspectiveAction;
0039: import org.eclipse.ui.internal.ToggleEditorsVisibilityAction;
0040: import org.eclipse.ui.internal.WorkbenchEditorsAction;
0041: import org.eclipse.ui.internal.WorkbenchImages;
0042: import org.eclipse.ui.internal.WorkbenchMessages;
0043: import org.eclipse.ui.internal.WorkbookEditorsAction;
0044: import org.eclipse.ui.internal.actions.CommandAction;
0045: import org.eclipse.ui.internal.actions.DynamicHelpAction;
0046: import org.eclipse.ui.internal.actions.HelpContentsAction;
0047: import org.eclipse.ui.internal.actions.HelpSearchAction;
0048: import org.eclipse.ui.internal.actions.NewEditorAction;
0049: import org.eclipse.ui.internal.actions.OpenPerspectiveDialogAction;
0050: import org.eclipse.ui.services.IServiceLocator;
0051:
0052: /**
0053: * Access to standard actions provided by the workbench.
0054: * <p>
0055: * Most of the functionality of this class is provided by static methods and
0056: * fields. Example usage:
0057: *
0058: * <pre>
0059: * MenuManager menu = ...;
0060: * ActionFactory.IWorkbenchAction closeEditorAction
0061: * = ActionFactory.CLOSE.create(window);
0062: * menu.add(closeEditorAction);
0063: * </pre>
0064: * </p>
0065: * <p>
0066: * Clients may declare other classes that provide additional application-specific
0067: * action factories.
0068: * </p>
0069: *
0070: * @since 3.0
0071: */
0072: public abstract class ActionFactory {
0073:
0074: /**
0075: * Interface for a workbench action.
0076: */
0077: public interface IWorkbenchAction extends IAction {
0078: /**
0079: * Disposes of this action. Once disposed, this action cannot be used.
0080: * This operation has no effect if the action has already been
0081: * disposed.
0082: */
0083: public void dispose();
0084: }
0085:
0086: private static class WorkbenchCommandAction extends CommandAction
0087: implements IWorkbenchAction {
0088: /**
0089: * @param commandIdIn
0090: * @param window
0091: */
0092: public WorkbenchCommandAction(String commandIdIn,
0093: IWorkbenchWindow window) {
0094: super (window, commandIdIn);
0095: }
0096:
0097: public WorkbenchCommandAction(String commandIdIn,
0098: Map parameterMap, IServiceLocator serviceLocator) {
0099: super (serviceLocator, commandIdIn, parameterMap);
0100: }
0101: }
0102:
0103: /**
0104: * Workbench action: Displays the About dialog. This action maintains its
0105: * enablement state.
0106: */
0107: public static final ActionFactory ABOUT = new ActionFactory("about") { //$NON-NLS-1$
0108:
0109: /*
0110: * (non-Javadoc)
0111: *
0112: * @see org.eclipse.ui.actions.ActionFactory#create(org.eclipse.ui.IWorkbenchWindow)
0113: */
0114: public IWorkbenchAction create(IWorkbenchWindow window) {
0115: if (window == null) {
0116: throw new IllegalArgumentException();
0117: }
0118:
0119: WorkbenchCommandAction action = new WorkbenchCommandAction(
0120: "org.eclipse.ui.help.aboutAction", window); //$NON-NLS-1$
0121:
0122: action.setId(getId());
0123: IProduct product = Platform.getProduct();
0124: String productName = null;
0125: if (product != null) {
0126: productName = product.getName();
0127: }
0128: if (productName == null) {
0129: productName = ""; //$NON-NLS-1$
0130: }
0131:
0132: action.setText(NLS.bind(WorkbenchMessages.AboutAction_text,
0133: productName));
0134: action
0135: .setToolTipText(NLS.bind(
0136: WorkbenchMessages.AboutAction_toolTip,
0137: productName));
0138: window.getWorkbench().getHelpSystem().setHelp(action,
0139: IWorkbenchHelpContextIds.ABOUT_ACTION);
0140: return action;
0141: }
0142: };
0143:
0144: /**
0145: * Workbench action (id "activateEditor"): Activate the most recently used
0146: * editor. This action maintains its enablement state.
0147: */
0148: public static final ActionFactory ACTIVATE_EDITOR = new ActionFactory(
0149: "activateEditor") {//$NON-NLS-1$
0150:
0151: /* (non-Javadoc)
0152: * @see org.eclipse.ui.actions.ActionFactory#create(org.eclipse.ui.IWorkbenchWindow)
0153: */
0154: public IWorkbenchAction create(IWorkbenchWindow window) {
0155: if (window == null) {
0156: throw new IllegalArgumentException();
0157: }
0158: WorkbenchCommandAction action = new WorkbenchCommandAction(
0159: "org.eclipse.ui.window.activateEditor", window); //$NON-NLS-1$
0160: action.setId(getId());
0161: action.setText(WorkbenchMessages.ActivateEditorAction_text);
0162: action
0163: .setToolTipText(WorkbenchMessages.ActivateEditorAction_toolTip);
0164: return action;
0165: }
0166: };
0167:
0168: /**
0169: * Workbench action (id "back"): Back. This action is a
0170: * {@link RetargetAction} with id "back". This action maintains its
0171: * enablement state.
0172: */
0173: public static final ActionFactory BACK = new ActionFactory("back") {//$NON-NLS-1$
0174: /* (non-Javadoc)
0175: * @see org.eclipse.ui.actions.ActionFactory#create(org.eclipse.ui.IWorkbenchWindow)
0176: */
0177: public IWorkbenchAction create(IWorkbenchWindow window) {
0178: if (window == null) {
0179: throw new IllegalArgumentException();
0180: }
0181: RetargetAction action = new LabelRetargetAction(getId(),
0182: WorkbenchMessages.Workbench_back);
0183: action
0184: .setToolTipText(WorkbenchMessages.Workbench_backToolTip);
0185: window.getPartService().addPartListener(action);
0186: action
0187: .setActionDefinitionId("org.eclipse.ui.navigate.back"); //$NON-NLS-1$
0188: return action;
0189: }
0190: };
0191:
0192: /**
0193: * Workbench action (id "backardHistory"): Backward in the navigation
0194: * history. This action maintains its enablement state.
0195: */
0196: public static final ActionFactory BACKWARD_HISTORY = new ActionFactory(
0197: "backardHistory") {//$NON-NLS-1$
0198: /* (non-Javadoc)
0199: * @see org.eclipse.ui.actions.ActionFactory#create(org.eclipse.ui.IWorkbenchWindow)
0200: */
0201: public IWorkbenchAction create(IWorkbenchWindow window) {
0202: if (window == null) {
0203: throw new IllegalArgumentException();
0204: }
0205: IWorkbenchAction action = new NavigationHistoryAction(
0206: window, false);
0207: action.setId(getId());
0208: return action;
0209: }
0210: };
0211:
0212: /**
0213: * Workbench action (id "close"): Close the active editor. This action
0214: * maintains its enablement state.
0215: */
0216: public static final ActionFactory CLOSE = new ActionFactory("close") {//$NON-NLS-1$
0217: /* (non-Javadoc)
0218: * @see org.eclipse.ui.actions.ActionFactory#create(org.eclipse.ui.IWorkbenchWindow)
0219: */
0220: public IWorkbenchAction create(IWorkbenchWindow window) {
0221: if (window == null) {
0222: throw new IllegalArgumentException();
0223: }
0224: WorkbenchCommandAction action = new WorkbenchCommandAction(
0225: "org.eclipse.ui.file.close", window); //$NON-NLS-1$
0226: action.setText(WorkbenchMessages.CloseEditorAction_text);
0227: action
0228: .setToolTipText(WorkbenchMessages.CloseEditorAction_toolTip);
0229: action.setId(getId());
0230: return action;
0231: }
0232: };
0233:
0234: /**
0235: * Workbench action (id "closeAll"): Close all open editors. This action
0236: * maintains its enablement state.
0237: */
0238: public static final ActionFactory CLOSE_ALL = new ActionFactory(
0239: "closeAll") {//$NON-NLS-1$
0240: /* (non-Javadoc)
0241: * @see org.eclipse.ui.actions.ActionFactory#create(org.eclipse.ui.IWorkbenchWindow)
0242: */
0243: public IWorkbenchAction create(IWorkbenchWindow window) {
0244: if (window == null) {
0245: throw new IllegalArgumentException();
0246: }
0247: WorkbenchCommandAction action = new WorkbenchCommandAction(
0248: "org.eclipse.ui.file.closeAll", window); //$NON-NLS-1$
0249: action.setText(WorkbenchMessages.CloseAllAction_text);
0250: action
0251: .setToolTipText(WorkbenchMessages.CloseAllAction_toolTip);
0252: action.setId(getId());
0253: return action;
0254: }
0255: };
0256:
0257: /**
0258: * Workbench action (id "closeOthers"): Close all editors except the one that
0259: * is active. This action maintains its enablement state.
0260: *
0261: * @since 3.2
0262: */
0263: public static final ActionFactory CLOSE_OTHERS = new ActionFactory(
0264: "closeOthers") {//$NON-NLS-1$
0265: /* (non-Javadoc)
0266: * @see org.eclipse.ui.actions.ActionFactory#create(org.eclipse.ui.IWorkbenchWindow)
0267: */
0268: public IWorkbenchAction create(IWorkbenchWindow window) {
0269: if (window == null) {
0270: throw new IllegalArgumentException();
0271: }
0272: WorkbenchCommandAction action = new WorkbenchCommandAction(
0273: "org.eclipse.ui.file.closeOthers", window); //$NON-NLS-1$
0274: action.setText(WorkbenchMessages.CloseOthersAction_text);
0275: action
0276: .setToolTipText(WorkbenchMessages.CloseOthersAction_toolTip);
0277: action.setId(getId());
0278: return action;
0279: }
0280: };
0281:
0282: /**
0283: * Workbench action (id "closeAllPerspectives"): Closes all perspectives.
0284: * This action maintains its enablement state.
0285: */
0286: public static final ActionFactory CLOSE_ALL_PERSPECTIVES = new ActionFactory(
0287: "closeAllPerspectives") {//$NON-NLS-1$
0288: /* (non-Javadoc)
0289: * @see org.eclipse.ui.actions.ActionFactory#create(org.eclipse.ui.IWorkbenchWindow)
0290: */
0291: public IWorkbenchAction create(IWorkbenchWindow window) {
0292: if (window == null) {
0293: throw new IllegalArgumentException();
0294: }
0295: IWorkbenchAction action = new CloseAllPerspectivesAction(
0296: window);
0297: action.setId(getId());
0298: return action;
0299: }
0300: };
0301:
0302: /**
0303: * Workbench action (id "closeAllSaved"): Close all open editors except
0304: * those with unsaved changes. This action maintains its enablement state.
0305: */
0306: public static final ActionFactory CLOSE_ALL_SAVED = new ActionFactory(
0307: "closeAllSaved") {//$NON-NLS-1$
0308: /* (non-Javadoc)
0309: * @see org.eclipse.ui.actions.ActionFactory#create(org.eclipse.ui.IWorkbenchWindow)
0310: */
0311: public IWorkbenchAction create(IWorkbenchWindow window) {
0312: if (window == null) {
0313: throw new IllegalArgumentException();
0314: }
0315: IWorkbenchAction action = new CloseAllSavedAction(window);
0316: action.setId(getId());
0317: return action;
0318: }
0319: };
0320:
0321: /**
0322: * Workbench action (id "closePerspective"): Closes the current
0323: * perspective. This action maintains its enablement state.
0324: */
0325: public static final ActionFactory CLOSE_PERSPECTIVE = new ActionFactory(
0326: "closePerspective") {//$NON-NLS-1$
0327: /* (non-Javadoc)
0328: * @see org.eclipse.ui.actions.ActionFactory#create(org.eclipse.ui.IWorkbenchWindow)
0329: */
0330: public IWorkbenchAction create(IWorkbenchWindow window) {
0331: if (window == null) {
0332: throw new IllegalArgumentException();
0333: }
0334: IWorkbenchAction action = new ClosePerspectiveAction(window);
0335: action.setId(getId());
0336: return action;
0337: }
0338: };
0339:
0340: /**
0341: * Workbench action (id "intro"): Activate the introduction extension.
0342: */
0343: public static final ActionFactory INTRO = new ActionFactory("intro") {//$NON-NLS-1$
0344: /* (non-Javadoc)
0345: * @see org.eclipse.ui.actions.ActionFactory#create(org.eclipse.ui.IWorkbenchWindow)
0346: */
0347: public IWorkbenchAction create(IWorkbenchWindow window) {
0348: if (window == null) {
0349: throw new IllegalArgumentException();
0350: }
0351: IWorkbenchAction action = new IntroAction(window);
0352: action.setId(getId());
0353: return action;
0354: }
0355: };
0356:
0357: /**
0358: * Workbench action (id "copy"): Copy. This action is a
0359: * {@link RetargetAction} with id "copy". This action maintains
0360: * its enablement state.
0361: */
0362: public static final ActionFactory COPY = new ActionFactory("copy") {//$NON-NLS-1$
0363:
0364: /* (non-Javadoc)
0365: * @see org.eclipse.ui.actions.ActionFactory#create(org.eclipse.ui.IWorkbenchWindow)
0366: */
0367: public IWorkbenchAction create(IWorkbenchWindow window) {
0368: if (window == null) {
0369: throw new IllegalArgumentException();
0370: }
0371: RetargetAction action = new RetargetAction(getId(),
0372: WorkbenchMessages.Workbench_copy);
0373: action
0374: .setToolTipText(WorkbenchMessages.Workbench_copyToolTip);
0375: window.getPartService().addPartListener(action);
0376: action.setActionDefinitionId("org.eclipse.ui.edit.copy"); //$NON-NLS-1$
0377: ISharedImages sharedImages = window.getWorkbench()
0378: .getSharedImages();
0379: action.setImageDescriptor(sharedImages
0380: .getImageDescriptor(ISharedImages.IMG_TOOL_COPY));
0381: action
0382: .setDisabledImageDescriptor(sharedImages
0383: .getImageDescriptor(ISharedImages.IMG_TOOL_COPY_DISABLED));
0384: return action;
0385: }
0386: };
0387:
0388: /**
0389: * Workbench action (id "cut"): Cut. This action is a
0390: * {@link RetargetAction} with id "cut". This action maintains
0391: * its enablement state.
0392: */
0393: public static final ActionFactory CUT = new ActionFactory("cut") {//$NON-NLS-1$
0394:
0395: /* (non-Javadoc)
0396: * @see org.eclipse.ui.actions.ActionFactory#create(org.eclipse.ui.IWorkbenchWindow)
0397: */
0398: public IWorkbenchAction create(IWorkbenchWindow window) {
0399: if (window == null) {
0400: throw new IllegalArgumentException();
0401: }
0402: RetargetAction action = new RetargetAction(getId(),
0403: WorkbenchMessages.Workbench_cut);
0404: action
0405: .setToolTipText(WorkbenchMessages.Workbench_cutToolTip);
0406: window.getPartService().addPartListener(action);
0407: action.setActionDefinitionId("org.eclipse.ui.edit.cut"); //$NON-NLS-1$
0408: ISharedImages sharedImages = window.getWorkbench()
0409: .getSharedImages();
0410: action.setImageDescriptor(sharedImages
0411: .getImageDescriptor(ISharedImages.IMG_TOOL_CUT));
0412: action
0413: .setDisabledImageDescriptor(sharedImages
0414: .getImageDescriptor(ISharedImages.IMG_TOOL_CUT_DISABLED));
0415: return action;
0416: }
0417: };
0418:
0419: /**
0420: * Workbench action (id "delete"): Delete. This action is a
0421: * {@link RetargetAction} with id "delete". This action maintains
0422: * its enablement state.
0423: */
0424: public static final ActionFactory DELETE = new ActionFactory(
0425: "delete") {//$NON-NLS-1$
0426:
0427: /* (non-Javadoc)
0428: * @see org.eclipse.ui.actions.ActionFactory#create(org.eclipse.ui.IWorkbenchWindow)
0429: */
0430: public IWorkbenchAction create(IWorkbenchWindow window) {
0431: if (window == null) {
0432: throw new IllegalArgumentException();
0433: }
0434: RetargetAction action = new RetargetAction(getId(),
0435: WorkbenchMessages.Workbench_delete);
0436: action
0437: .setToolTipText(WorkbenchMessages.Workbench_deleteToolTip);
0438: window.getPartService().addPartListener(action);
0439: action.setActionDefinitionId("org.eclipse.ui.edit.delete"); //$NON-NLS-1$
0440: action.enableAccelerator(false);
0441: window.getWorkbench().getHelpSystem().setHelp(action,
0442: IWorkbenchHelpContextIds.DELETE_RETARGET_ACTION);
0443: ISharedImages sharedImages = window.getWorkbench()
0444: .getSharedImages();
0445: action.setImageDescriptor(sharedImages
0446: .getImageDescriptor(ISharedImages.IMG_TOOL_DELETE));
0447: action
0448: .setDisabledImageDescriptor(sharedImages
0449: .getImageDescriptor(ISharedImages.IMG_TOOL_DELETE_DISABLED));
0450: return action;
0451: }
0452: };
0453:
0454: /**
0455: * Workbench action (id "editActionSets"): Edit the action sets. This
0456: * action maintains its enablement state.
0457: */
0458: public static final ActionFactory EDIT_ACTION_SETS = new ActionFactory(
0459: "editActionSets") {//$NON-NLS-1$
0460:
0461: /* (non-Javadoc)
0462: * @see org.eclipse.ui.actions.ActionFactory#create(org.eclipse.ui.IWorkbenchWindow)
0463: */
0464: public IWorkbenchAction create(IWorkbenchWindow window) {
0465: if (window == null) {
0466: throw new IllegalArgumentException();
0467: }
0468: IWorkbenchAction action = new EditActionSetsAction(window);
0469: action.setId(getId());
0470: return action;
0471: }
0472: };
0473:
0474: /**
0475: * Workbench action (id "export"): Opens the export wizard. This action
0476: * maintains its enablement state.
0477: */
0478: public static final ActionFactory EXPORT = new ActionFactory(
0479: "export") {//$NON-NLS-1$
0480:
0481: /* (non-Javadoc)
0482: * @see org.eclipse.ui.actions.ActionFactory#create(org.eclipse.ui.IWorkbenchWindow)
0483: */
0484: public IWorkbenchAction create(IWorkbenchWindow window) {
0485: if (window == null) {
0486: throw new IllegalArgumentException();
0487: }
0488: IWorkbenchAction action = new ExportResourcesAction(window);
0489: action.setId(getId());
0490: return action;
0491: }
0492: };
0493:
0494: /**
0495: * Workbench action (id "find"): Find. This action is a
0496: * {@link RetargetAction} with id "find". This action maintains
0497: * its enablement state.
0498: */
0499: public static final ActionFactory FIND = new ActionFactory("find") {//$NON-NLS-1$
0500:
0501: /* (non-Javadoc)
0502: * @see org.eclipse.ui.actions.ActionFactory#create(org.eclipse.ui.IWorkbenchWindow)
0503: */
0504: public IWorkbenchAction create(IWorkbenchWindow window) {
0505: if (window == null) {
0506: throw new IllegalArgumentException();
0507: }
0508: RetargetAction action = new RetargetAction(getId(),
0509: WorkbenchMessages.Workbench_findReplace);
0510: action
0511: .setToolTipText(WorkbenchMessages.Workbench_findReplaceToolTip);
0512: window.getPartService().addPartListener(action);
0513: action
0514: .setActionDefinitionId("org.eclipse.ui.edit.findReplace"); //$NON-NLS-1$
0515: // Find's images are commented out due to a conflict with Search.
0516: // See bug 16412.
0517: // action.setImageDescriptor(WorkbenchImages.getImageDescriptor(IWorkbenchGraphicConstants.IMG_ETOOL_SEARCH_SRC));
0518: // action.setDisabledImageDescriptor(WorkbenchImages.getImageDescriptor(IWorkbenchGraphicConstants.IMG_ETOOL_SEARCH_SRC_DISABLED));
0519: return action;
0520: }
0521: };
0522:
0523: /**
0524: * Workbench action (id "forward"): Forward. This action is a
0525: * {@link RetargetAction} with id "forward". This action
0526: * maintains its enablement state.
0527: */
0528: public static final ActionFactory FORWARD = new ActionFactory(
0529: "forward") {//$NON-NLS-1$
0530:
0531: /* (non-Javadoc)
0532: * @see org.eclipse.ui.actions.ActionFactory#create(org.eclipse.ui.IWorkbenchWindow)
0533: */
0534: public IWorkbenchAction create(IWorkbenchWindow window) {
0535: if (window == null) {
0536: throw new IllegalArgumentException();
0537: }
0538: RetargetAction action = new LabelRetargetAction(getId(),
0539: WorkbenchMessages.Workbench_forward);
0540: action
0541: .setToolTipText(WorkbenchMessages.Workbench_forwardToolTip);
0542: window.getPartService().addPartListener(action);
0543: action
0544: .setActionDefinitionId("org.eclipse.ui.navigate.forward"); //$NON-NLS-1$
0545: return action;
0546: }
0547: };
0548:
0549: /**
0550: * Workbench action (id "forwardHistory"): Forward in the navigation
0551: * history. This action maintains its enablement state.
0552: */
0553: public static final ActionFactory FORWARD_HISTORY = new ActionFactory(
0554: "forwardHistory") {//$NON-NLS-1$
0555:
0556: /* (non-Javadoc)
0557: * @see org.eclipse.ui.actions.ActionFactory#create(org.eclipse.ui.IWorkbenchWindow)
0558: */
0559: public IWorkbenchAction create(IWorkbenchWindow window) {
0560: if (window == null) {
0561: throw new IllegalArgumentException();
0562: }
0563: IWorkbenchAction action = new NavigationHistoryAction(
0564: window, true);
0565: action.setId(getId());
0566: return action;
0567: }
0568: };
0569:
0570: /**
0571: * Workbench action (id "goInto"): Go Into. This action is a
0572: * {@link RetargetAction} with id "goInto". This action maintains
0573: * its enablement state.
0574: */
0575: public static final ActionFactory GO_INTO = new ActionFactory(
0576: "goInto") {//$NON-NLS-1$
0577:
0578: /* (non-Javadoc)
0579: * @see org.eclipse.ui.actions.ActionFactory#create(org.eclipse.ui.IWorkbenchWindow)
0580: */
0581: public IWorkbenchAction create(IWorkbenchWindow window) {
0582: if (window == null) {
0583: throw new IllegalArgumentException();
0584: }
0585: RetargetAction action = new LabelRetargetAction(getId(),
0586: WorkbenchMessages.Workbench_goInto);
0587: action
0588: .setToolTipText(WorkbenchMessages.Workbench_goIntoToolTip);
0589: window.getPartService().addPartListener(action);
0590: action
0591: .setActionDefinitionId("org.eclipse.ui.navigate.goInto"); //$NON-NLS-1$
0592: return action;
0593: }
0594: };
0595:
0596: /**
0597: * Workbench action (id "import"): Opens the import wizard. This action
0598: * maintains its enablement state.
0599: */
0600: public static final ActionFactory IMPORT = new ActionFactory(
0601: "import") {//$NON-NLS-1$
0602:
0603: /* (non-Javadoc)
0604: * @see org.eclipse.ui.actions.ActionFactory#create(org.eclipse.ui.IWorkbenchWindow)
0605: */
0606: public IWorkbenchAction create(IWorkbenchWindow window) {
0607: if (window == null) {
0608: throw new IllegalArgumentException();
0609: }
0610: IWorkbenchAction action = new ImportResourcesAction(window);
0611: action.setId(getId());
0612: return action;
0613: }
0614: };
0615:
0616: /**
0617: * Workbench action (id "lockToolBar"): Lock/unlock the workbench window
0618: * tool bar. This action maintains its enablement state.
0619: */
0620: public static final ActionFactory LOCK_TOOL_BAR = new ActionFactory(
0621: "lockToolBar") {//$NON-NLS-1$
0622:
0623: /* (non-Javadoc)
0624: * @see org.eclipse.ui.actions.ActionFactory#create(org.eclipse.ui.IWorkbenchWindow)
0625: */
0626: public IWorkbenchAction create(IWorkbenchWindow window) {
0627: if (window == null) {
0628: throw new IllegalArgumentException();
0629: }
0630: IWorkbenchAction action = new LockToolBarAction(window);
0631: action.setId(getId());
0632: return action;
0633: }
0634: };
0635:
0636: /**
0637: * Workbench action (id "maximize"): Maximize/restore the active part. This
0638: * action maintains its enablement state.
0639: */
0640: public static final ActionFactory MAXIMIZE = new ActionFactory(
0641: "maximize") {//$NON-NLS-1$
0642:
0643: /* (non-Javadoc)
0644: * @see org.eclipse.ui.actions.ActionFactory#create(org.eclipse.ui.IWorkbenchWindow)
0645: */
0646: public IWorkbenchAction create(IWorkbenchWindow window) {
0647: if (window == null) {
0648: throw new IllegalArgumentException();
0649: }
0650: IWorkbenchAction action = new MaximizePartAction(window);
0651: action.setId(getId());
0652: return action;
0653: }
0654: };
0655:
0656: /**
0657: * Workbench action (id "minimize"): Minimizes the active part. This
0658: * action maintains its enablement state.
0659: *
0660: * @since 3.1
0661: */
0662: public static final ActionFactory MINIMIZE = new ActionFactory(
0663: "minimize") {//$NON-NLS-1$
0664:
0665: /* (non-Javadoc)
0666: * @see org.eclipse.ui.actions.ActionFactory#create(org.eclipse.ui.IWorkbenchWindow)
0667: */
0668: public IWorkbenchAction create(IWorkbenchWindow window) {
0669: if (window == null) {
0670: throw new IllegalArgumentException();
0671: }
0672: IWorkbenchAction action = new MinimizePartAction(window);
0673: action.setId(getId());
0674: return action;
0675: }
0676: };
0677:
0678: /**
0679: * Workbench action (id "move"): Move. This action is a
0680: * {@link RetargetAction} with id "move". This action maintains
0681: * its enablement state.
0682: */
0683: public static final ActionFactory MOVE = new ActionFactory("move") {//$NON-NLS-1$
0684:
0685: /* (non-Javadoc)
0686: * @see org.eclipse.ui.actions.ActionFactory#create(org.eclipse.ui.IWorkbenchWindow)
0687: */
0688: public IWorkbenchAction create(IWorkbenchWindow window) {
0689: if (window == null) {
0690: throw new IllegalArgumentException();
0691: }
0692: RetargetAction action = new RetargetAction(getId(),
0693: WorkbenchMessages.Workbench_move);
0694: action
0695: .setToolTipText(WorkbenchMessages.Workbench_moveToolTip);
0696: window.getPartService().addPartListener(action);
0697: action.setActionDefinitionId("org.eclipse.ui.edit.move"); //$NON-NLS-1$
0698: return action;
0699: }
0700: };
0701:
0702: /**
0703: * Workbench action (id "new"): Opens the new wizard dialog. This action maintains
0704: * its enablement state.
0705: */
0706: public static final ActionFactory NEW = new ActionFactory("new") {//$NON-NLS-1$
0707:
0708: /* (non-Javadoc)
0709: * @see org.eclipse.ui.actions.ActionFactory#create(org.eclipse.ui.IWorkbenchWindow)
0710: */
0711: public IWorkbenchAction create(IWorkbenchWindow window) {
0712: if (window == null) {
0713: throw new IllegalArgumentException();
0714: }
0715: IWorkbenchAction action = new NewWizardAction(window);
0716: action.setId(getId());
0717: return action;
0718: }
0719: };
0720:
0721: /**
0722: * Workbench action (id "newWizardDropDown"): Drop-down action which shows shows the new wizard drop down,
0723: * or opens the new wizard dialog when pressed. For use in the toolbar.
0724: * This action maintains its enablement state.
0725: *
0726: * @since 3.1
0727: */
0728: public static final ActionFactory NEW_WIZARD_DROP_DOWN = new ActionFactory(
0729: "newWizardDropDown") { //$NON-NLS-1$
0730:
0731: /* (non-Javadoc)
0732: * @see org.eclipse.ui.actions.ActionFactory#create(org.eclipse.ui.IWorkbenchWindow)
0733: */
0734: public IWorkbenchAction create(IWorkbenchWindow window) {
0735: if (window == null) {
0736: throw new IllegalArgumentException();
0737: }
0738: IWorkbenchAction action = new NewWizardDropDownAction(
0739: window);
0740: action.setId(getId());
0741: return action;
0742: }
0743: };
0744:
0745: /**
0746: * Workbench action (id "next"): Next. This action is a
0747: * {@link RetargetAction} with id "next". This action maintains
0748: * its enablement state.
0749: */
0750: public static final ActionFactory NEXT = new ActionFactory("next") {//$NON-NLS-1$
0751:
0752: /* (non-Javadoc)
0753: * @see org.eclipse.ui.actions.ActionFactory#create(org.eclipse.ui.IWorkbenchWindow)
0754: */
0755: public IWorkbenchAction create(IWorkbenchWindow window) {
0756: if (window == null) {
0757: throw new IllegalArgumentException();
0758: }
0759: WorkbenchCommandAction action = new WorkbenchCommandAction(
0760: "org.eclipse.ui.navigate.next", window); //$NON-NLS-1$
0761: action.setText(WorkbenchMessages.Workbench_next);
0762: action.setId(getId());
0763: action
0764: .setToolTipText(WorkbenchMessages.Workbench_nextToolTip);
0765: return action;
0766: }
0767: };
0768:
0769: /**
0770: * Workbench action (id "nextEditor"): Next editor. This action maintains
0771: * its enablement state.
0772: * <p>
0773: * <code>NEXT_EDITOR</code> and <code>PREVIOUS_EDITOR</code> form a
0774: * cycle action pair. For a given window, use
0775: * {@link ActionFactory#linkCycleActionPair
0776: * ActionFactory.linkCycleActionPair</code>} to connect the two.
0777: * </p>
0778: */
0779: public static final ActionFactory NEXT_EDITOR = new ActionFactory(
0780: "nextEditor") {//$NON-NLS-1$
0781:
0782: /* (non-Javadoc)
0783: * @see org.eclipse.ui.actions.ActionFactory#create(org.eclipse.ui.IWorkbenchWindow)
0784: */
0785: public IWorkbenchAction create(IWorkbenchWindow window) {
0786: if (window == null) {
0787: throw new IllegalArgumentException();
0788: }
0789: IWorkbenchAction action = new WorkbenchCommandAction(
0790: "org.eclipse.ui.window.nextEditor", //$NON-NLS-1$
0791: window);
0792:
0793: action
0794: .setText(WorkbenchMessages.CycleEditorAction_next_text);
0795: action
0796: .setToolTipText(WorkbenchMessages.CycleEditorAction_next_toolTip);
0797: // @issue missing action ids
0798: window
0799: .getWorkbench()
0800: .getHelpSystem()
0801: .setHelp(
0802: action,
0803: IWorkbenchHelpContextIds.CYCLE_EDITOR_FORWARD_ACTION);
0804:
0805: action.setId(getId());
0806: return action;
0807: }
0808: };
0809:
0810: /**
0811: * Workbench action (id "nextPart"): Next part. This action maintains its
0812: * enablement state.
0813: * <p>
0814: * <code>NEXT_PART</code> and <code>PREVIOUS_PART</code> form a cycle
0815: * action pair. For a given window, use
0816: * {@link ActionFactory#linkCycleActionPair
0817: * ActionFactory.linkCycleActionPair</code>} to connect the two.
0818: * </p>
0819: */
0820: public static final ActionFactory NEXT_PART = new ActionFactory(
0821: "nextPart") {//$NON-NLS-1$
0822:
0823: /* (non-Javadoc)
0824: * @see org.eclipse.ui.actions.ActionFactory#create(org.eclipse.ui.IWorkbenchWindow)
0825: */
0826: public IWorkbenchAction create(IWorkbenchWindow window) {
0827: if (window == null) {
0828: throw new IllegalArgumentException();
0829: }
0830: WorkbenchCommandAction action = new WorkbenchCommandAction(
0831: "org.eclipse.ui.window.nextView", window); //$NON-NLS-1$
0832: action.setText(WorkbenchMessages.CyclePartAction_next_text);
0833: action
0834: .setToolTipText(WorkbenchMessages.CyclePartAction_next_toolTip);
0835: // @issue missing action ids
0836: window.getWorkbench().getHelpSystem().setHelp(action,
0837: IWorkbenchHelpContextIds.CYCLE_PART_FORWARD_ACTION);
0838: action.setId(getId());
0839: return action;
0840: }
0841: };
0842:
0843: /**
0844: * Workbench action (id "nextPerspective"): Next perspective. This action
0845: * maintains its enablement state.
0846: * <p>
0847: * <code>NEXT_PERSPECTIVE</code> and <code>PREVIOUS_PERSPECTIVE</code>
0848: * form a cycle action pair. For a given window, use
0849: * {@link ActionFactory#linkCycleActionPair
0850: * ActionFactory.linkCycleActionPair</code>} to connect the two.
0851: * </p>
0852: */
0853: public static final ActionFactory NEXT_PERSPECTIVE = new ActionFactory(
0854: "nextPerspective") {//$NON-NLS-1$
0855:
0856: /* (non-Javadoc)
0857: * @see org.eclipse.ui.actions.ActionFactory#create(org.eclipse.ui.IWorkbenchWindow)
0858: */
0859: public IWorkbenchAction create(IWorkbenchWindow window) {
0860: if (window == null) {
0861: throw new IllegalArgumentException();
0862: }
0863: WorkbenchCommandAction action = new WorkbenchCommandAction(
0864: "org.eclipse.ui.window.nextPerspective", window); //$NON-NLS-1$
0865: action
0866: .setText(WorkbenchMessages.CyclePerspectiveAction_next_text);
0867: action
0868: .setToolTipText(WorkbenchMessages.CyclePerspectiveAction_next_toolTip);
0869: // @issue missing action ids
0870: window
0871: .getWorkbench()
0872: .getHelpSystem()
0873: .setHelp(
0874: action,
0875: IWorkbenchHelpContextIds.CYCLE_PERSPECTIVE_FORWARD_ACTION);
0876: action.setId(getId());
0877: return action;
0878: }
0879: };
0880:
0881: /**
0882: * Workbench action (id "openNewWindow"): Open a new workbench window. This
0883: * action maintains its enablement state.
0884: */
0885: public static final ActionFactory OPEN_NEW_WINDOW = new ActionFactory(
0886: "openNewWindow") {//$NON-NLS-1$
0887:
0888: /* (non-Javadoc)
0889: * @see org.eclipse.ui.actions.ActionFactory#create(org.eclipse.ui.IWorkbenchWindow)
0890: */
0891: public IWorkbenchAction create(IWorkbenchWindow window) {
0892: if (window == null) {
0893: throw new IllegalArgumentException();
0894: }
0895: IWorkbenchAction action = new OpenInNewWindowAction(window);
0896: action.setId(getId());
0897: return action;
0898: }
0899: };
0900:
0901: /**
0902: * Workbench action (id "paste"): Paste. This action is a
0903: * {@link RetargetAction} with id "paste". This action maintains
0904: * its enablement state.
0905: */
0906: public static final ActionFactory PASTE = new ActionFactory("paste") {//$NON-NLS-1$
0907:
0908: /* (non-Javadoc)
0909: * @see org.eclipse.ui.actions.ActionFactory#create(org.eclipse.ui.IWorkbenchWindow)
0910: */
0911: public IWorkbenchAction create(IWorkbenchWindow window) {
0912: if (window == null) {
0913: throw new IllegalArgumentException();
0914: }
0915: RetargetAction action = new RetargetAction(getId(),
0916: WorkbenchMessages.Workbench_paste);
0917: action
0918: .setToolTipText(WorkbenchMessages.Workbench_pasteToolTip);
0919: window.getPartService().addPartListener(action);
0920: action.setActionDefinitionId("org.eclipse.ui.edit.paste"); //$NON-NLS-1$
0921: ISharedImages sharedImages = window.getWorkbench()
0922: .getSharedImages();
0923: action.setImageDescriptor(sharedImages
0924: .getImageDescriptor(ISharedImages.IMG_TOOL_PASTE));
0925: action
0926: .setDisabledImageDescriptor(sharedImages
0927: .getImageDescriptor(ISharedImages.IMG_TOOL_PASTE_DISABLED));
0928: return action;
0929: }
0930: };
0931:
0932: /**
0933: * Workbench action (id "preferences"): Displays the Preferences dialog.
0934: * This action maintains its enablement state.
0935: */
0936: public static final ActionFactory PREFERENCES = new ActionFactory(
0937: "preferences") {//$NON-NLS-1$
0938:
0939: /* (non-Javadoc)
0940: * @see org.eclipse.ui.actions.ActionFactory#create(org.eclipse.ui.IWorkbenchWindow)
0941: */
0942: public IWorkbenchAction create(IWorkbenchWindow window) {
0943: if (window == null) {
0944: throw new IllegalArgumentException();
0945: }
0946: IWorkbenchAction action = new OpenPreferencesAction(window);
0947: action.setId(getId());
0948: return action;
0949: }
0950: };
0951:
0952: /**
0953: * Workbench action (id "previous"): Previous. This action is a
0954: * {@link RetargetAction} with id "previous". This action
0955: * maintains its enablement state.
0956: */
0957: public static final ActionFactory PREVIOUS = new ActionFactory(
0958: "previous") {//$NON-NLS-1$
0959:
0960: /* (non-Javadoc)
0961: * @see org.eclipse.ui.actions.ActionFactory#create(org.eclipse.ui.IWorkbenchWindow)
0962: */
0963: public IWorkbenchAction create(IWorkbenchWindow window) {
0964: if (window == null) {
0965: throw new IllegalArgumentException();
0966: }
0967: WorkbenchCommandAction action = new WorkbenchCommandAction(
0968: "org.eclipse.ui.navigate.previous", window); //$NON-NLS-1$
0969: action.setText(WorkbenchMessages.Workbench_previous);
0970: action.setId(getId());
0971: action
0972: .setToolTipText(WorkbenchMessages.Workbench_previousToolTip);
0973: return action;
0974: }
0975: };
0976:
0977: /**
0978: * Workbench action (id "previousEditor"): Previous editor. This action
0979: * maintains its enablement state.
0980: * <p>
0981: * <code>NEXT_EDITOR</code> and <code>PREVIOUS_EDITOR</code> form a
0982: * cycle action pair. For a given window, use
0983: * {@link ActionFactory#linkCycleActionPair
0984: * ActionFactory.linkCycleActionPair</code>} to connect the two.
0985: * </p>
0986: */
0987: public static final ActionFactory PREVIOUS_EDITOR = new ActionFactory(
0988: "previousEditor") {//$NON-NLS-1$
0989:
0990: /* (non-Javadoc)
0991: * @see org.eclipse.ui.actions.ActionFactory#create(org.eclipse.ui.IWorkbenchWindow)
0992: */
0993: public IWorkbenchAction create(IWorkbenchWindow window) {
0994: if (window == null) {
0995: throw new IllegalArgumentException();
0996: }
0997: IWorkbenchAction action = new WorkbenchCommandAction(
0998: "org.eclipse.ui.window.previousEditor", //$NON-NLS-1$
0999: window);
1000: action
1001: .setText(WorkbenchMessages.CycleEditorAction_prev_text);
1002: action
1003: .setToolTipText(WorkbenchMessages.CycleEditorAction_prev_toolTip);
1004: // @issue missing action ids
1005: window
1006: .getWorkbench()
1007: .getHelpSystem()
1008: .setHelp(
1009: action,
1010: IWorkbenchHelpContextIds.CYCLE_EDITOR_BACKWARD_ACTION);
1011:
1012: action.setId(getId());
1013: return action;
1014: }
1015: };
1016:
1017: /**
1018: * Workbench action (id "previousPart"): Previous part. This action
1019: * maintains its enablement state.
1020: * <p>
1021: * <code>NEXT_PART</code> and <code>PREVIOUS_PART</code> form a cycle
1022: * action pair. For a given window, use
1023: * {@link ActionFactory#linkCycleActionPair
1024: * ActionFactory.linkCycleActionPair</code>} to connect the two.
1025: * </p>
1026: */
1027: public static final ActionFactory PREVIOUS_PART = new ActionFactory(
1028: "previousPart") {//$NON-NLS-1$
1029:
1030: /* (non-Javadoc)
1031: * @see org.eclipse.ui.actions.ActionFactory#create(org.eclipse.ui.IWorkbenchWindow)
1032: */
1033: public IWorkbenchAction create(IWorkbenchWindow window) {
1034: if (window == null) {
1035: throw new IllegalArgumentException();
1036: }
1037: WorkbenchCommandAction action = new WorkbenchCommandAction(
1038: "org.eclipse.ui.window.previousView", window); //$NON-NLS-1$
1039: action.setText(WorkbenchMessages.CyclePartAction_prev_text);
1040: action
1041: .setToolTipText(WorkbenchMessages.CyclePartAction_prev_toolTip);
1042: // @issue missing action ids
1043: window
1044: .getWorkbench()
1045: .getHelpSystem()
1046: .setHelp(
1047: action,
1048: IWorkbenchHelpContextIds.CYCLE_PART_BACKWARD_ACTION);
1049: action.setId(getId());
1050: return action;
1051: }
1052: };
1053:
1054: /**
1055: * Workbench action (id "previousPerspective"): Previous perspective. This
1056: * action maintains its enablement state.
1057: * <p>
1058: * <code>NEXT_PERSPECTIVE</code> and <code>PREVIOUS_PERSPECTIVE</code>
1059: * form a cycle action pair. For a given window, use
1060: * {@link ActionFactory#linkCycleActionPair
1061: * ActionFactory.linkCycleActionPair</code>} to connect the two.
1062: * </p>
1063: */
1064: public static final ActionFactory PREVIOUS_PERSPECTIVE = new ActionFactory(
1065: "previousPerspective") {//$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();
1073: }
1074: WorkbenchCommandAction action = new WorkbenchCommandAction(
1075: "org.eclipse.ui.window.previousPerspective", window); //$NON-NLS-1$
1076: action
1077: .setText(WorkbenchMessages.CyclePerspectiveAction_prev_text);
1078: action
1079: .setToolTipText(WorkbenchMessages.CyclePerspectiveAction_prev_toolTip);
1080: // @issue missing action ids
1081: window
1082: .getWorkbench()
1083: .getHelpSystem()
1084: .setHelp(
1085: action,
1086: IWorkbenchHelpContextIds.CYCLE_PERSPECTIVE_BACKWARD_ACTION);
1087: action.setId(getId());
1088: return action;
1089: }
1090: };
1091:
1092: /**
1093: * Workbench action (id "print"): Print. This action is a
1094: * {@link RetargetAction} with id "print". This action maintains
1095: * its enablement state.
1096: */
1097: public static final ActionFactory PRINT = new ActionFactory("print") {//$NON-NLS-1$
1098:
1099: /* (non-Javadoc)
1100: * @see org.eclipse.ui.actions.ActionFactory#create(org.eclipse.ui.IWorkbenchWindow)
1101: */
1102: public IWorkbenchAction create(IWorkbenchWindow window) {
1103: if (window == null) {
1104: throw new IllegalArgumentException();
1105: }
1106: RetargetAction action = new RetargetAction(getId(),
1107: WorkbenchMessages.Workbench_print);
1108: action
1109: .setToolTipText(WorkbenchMessages.Workbench_printToolTip);
1110: window.getPartService().addPartListener(action);
1111: action.setActionDefinitionId("org.eclipse.ui.file.print"); //$NON-NLS-1$
1112: action
1113: .setImageDescriptor(WorkbenchImages
1114: .getImageDescriptor(IWorkbenchGraphicConstants.IMG_ETOOL_PRINT_EDIT));
1115: action
1116: .setDisabledImageDescriptor(WorkbenchImages
1117: .getImageDescriptor(IWorkbenchGraphicConstants.IMG_ETOOL_PRINT_EDIT_DISABLED));
1118: return action;
1119: }
1120: };
1121:
1122: /**
1123: * Workbench action (id "properties"): Properties. This action is a
1124: * {@link RetargetAction} with id "properties". This action
1125: * maintains its enablement state.
1126: */
1127: public static final ActionFactory PROPERTIES = new ActionFactory(
1128: "properties") {//$NON-NLS-1$
1129:
1130: /* (non-Javadoc)
1131: * @see org.eclipse.ui.actions.ActionFactory#create(org.eclipse.ui.IWorkbenchWindow)
1132: */
1133: public IWorkbenchAction create(IWorkbenchWindow window) {
1134: if (window == null) {
1135: throw new IllegalArgumentException();
1136: }
1137: RetargetAction action = new RetargetAction(getId(),
1138: WorkbenchMessages.Workbench_properties);
1139: action
1140: .setToolTipText(WorkbenchMessages.Workbench_propertiesToolTip);
1141: window.getPartService().addPartListener(action);
1142: action
1143: .setActionDefinitionId("org.eclipse.ui.file.properties"); //$NON-NLS-1$
1144: return action;
1145: }
1146: };
1147:
1148: /**
1149: * Workbench action (id "quit"): Quit (close the workbench). This action
1150: * maintains its enablement state.
1151: */
1152: public static final ActionFactory QUIT = new ActionFactory("quit") {//$NON-NLS-1$
1153:
1154: /* (non-Javadoc)
1155: * @see org.eclipse.ui.actions.ActionFactory#create(org.eclipse.ui.IWorkbenchWindow)
1156: */
1157: public IWorkbenchAction create(IWorkbenchWindow window) {
1158: if (window == null) {
1159: throw new IllegalArgumentException();
1160: }
1161: IWorkbenchAction action = new QuitAction(window);
1162: action.setId(getId());
1163: return action;
1164: }
1165: };
1166:
1167: /**
1168: * Workbench action (id "redo"): Redo. This action is a
1169: * {@link RetargetAction} with id "redo". This action maintains
1170: * its enablement state.
1171: */
1172: public static final ActionFactory REDO = new ActionFactory("redo") {//$NON-NLS-1$
1173:
1174: /* (non-Javadoc)
1175: * @see org.eclipse.ui.actions.ActionFactory#create(org.eclipse.ui.IWorkbenchWindow)
1176: */
1177: public IWorkbenchAction create(IWorkbenchWindow window) {
1178: if (window == null) {
1179: throw new IllegalArgumentException();
1180: }
1181: LabelRetargetAction action = new LabelRetargetAction(
1182: getId(), WorkbenchMessages.Workbench_redo);
1183: action
1184: .setToolTipText(WorkbenchMessages.Workbench_redoToolTip);
1185: window.getPartService().addPartListener(action);
1186: action.setActionDefinitionId("org.eclipse.ui.edit.redo"); //$NON-NLS-1$
1187: ISharedImages sharedImages = window.getWorkbench()
1188: .getSharedImages();
1189: action.setImageDescriptor(sharedImages
1190: .getImageDescriptor(ISharedImages.IMG_TOOL_REDO));
1191: action
1192: .setDisabledImageDescriptor(sharedImages
1193: .getImageDescriptor(ISharedImages.IMG_TOOL_REDO_DISABLED));
1194: return action;
1195: }
1196: };
1197:
1198: /**
1199: * Workbench action (id "refresh"): Refresh. This action is a
1200: * {@link RetargetAction} with id "refresh". This action
1201: * maintains its enablement state.
1202: */
1203: public static final ActionFactory REFRESH = new ActionFactory(
1204: "refresh") {//$NON-NLS-1$
1205:
1206: /* (non-Javadoc)
1207: * @see org.eclipse.ui.actions.ActionFactory#create(org.eclipse.ui.IWorkbenchWindow)
1208: */
1209: public IWorkbenchAction create(IWorkbenchWindow window) {
1210: if (window == null) {
1211: throw new IllegalArgumentException();
1212: }
1213: RetargetAction action = new RetargetAction(getId(),
1214: WorkbenchMessages.Workbench_refresh);
1215: action
1216: .setToolTipText(WorkbenchMessages.Workbench_refreshToolTip);
1217: window.getPartService().addPartListener(action);
1218: action.setActionDefinitionId("org.eclipse.ui.file.refresh"); //$NON-NLS-1$
1219: return action;
1220: }
1221: };
1222:
1223: /**
1224: * Workbench action (id "rename"): Rename. This action is a
1225: * {@link RetargetAction} with id "rename". This action maintains
1226: * its enablement state.
1227: */
1228: public static final ActionFactory RENAME = new ActionFactory(
1229: "rename") {//$NON-NLS-1$
1230:
1231: /* (non-Javadoc)
1232: * @see org.eclipse.ui.actions.ActionFactory#create(org.eclipse.ui.IWorkbenchWindow)
1233: */
1234: public IWorkbenchAction create(IWorkbenchWindow window) {
1235: if (window == null) {
1236: throw new IllegalArgumentException();
1237: }
1238: RetargetAction action = new RetargetAction(getId(),
1239: WorkbenchMessages.Workbench_rename);
1240: action
1241: .setToolTipText(WorkbenchMessages.Workbench_renameToolTip);
1242: window.getPartService().addPartListener(action);
1243: action.setActionDefinitionId("org.eclipse.ui.edit.rename"); //$NON-NLS-1$
1244: return action;
1245: }
1246: };
1247:
1248: /**
1249: * Workbench action (id "resetPerspective"): Resets the current
1250: * perspective. This action maintains its enablement state.
1251: */
1252: public static final ActionFactory RESET_PERSPECTIVE = new ActionFactory(
1253: "resetPerspective") {//$NON-NLS-1$
1254:
1255: /* (non-Javadoc)
1256: * @see org.eclipse.ui.actions.ActionFactory#create(org.eclipse.ui.IWorkbenchWindow)
1257: */
1258: public IWorkbenchAction create(IWorkbenchWindow window) {
1259: if (window == null) {
1260: throw new IllegalArgumentException();
1261: }
1262: IWorkbenchAction action = new ResetPerspectiveAction(window);
1263: action.setId(getId());
1264: return action;
1265: }
1266: };
1267:
1268: /**
1269: * Workbench action (id "revert"): Revert. This action is a
1270: * {@link RetargetAction} with id "revert". This action maintains
1271: * its enablement state.
1272: */
1273: public static final ActionFactory REVERT = new ActionFactory(
1274: "revert") {//$NON-NLS-1$
1275:
1276: /* (non-Javadoc)
1277: * @see org.eclipse.ui.actions.ActionFactory#create(org.eclipse.ui.IWorkbenchWindow)
1278: */
1279: public IWorkbenchAction create(IWorkbenchWindow window) {
1280: if (window == null) {
1281: throw new IllegalArgumentException();
1282: }
1283: RetargetAction action = new RetargetAction(getId(),
1284: WorkbenchMessages.Workbench_revert);
1285: action
1286: .setToolTipText(WorkbenchMessages.Workbench_revertToolTip);
1287: window.getPartService().addPartListener(action);
1288: action.setActionDefinitionId("org.eclipse.ui.file.revert"); //$NON-NLS-1$
1289: return action;
1290: }
1291: };
1292:
1293: /**
1294: * Workbench action (id "save"): Save the active editor. This action
1295: * maintains its enablement state.
1296: */
1297: public static final ActionFactory SAVE = new ActionFactory("save") {//$NON-NLS-1$
1298:
1299: /* (non-Javadoc)
1300: * @see org.eclipse.ui.actions.ActionFactory#create(org.eclipse.ui.IWorkbenchWindow)
1301: */
1302: public IWorkbenchAction create(IWorkbenchWindow window) {
1303: if (window == null) {
1304: throw new IllegalArgumentException();
1305: }
1306: IWorkbenchAction action = new SaveAction(window);
1307: action.setId(getId());
1308: return action;
1309: }
1310: };
1311:
1312: /**
1313: * Workbench action (id "saveAll"): Save all open editors with unsaved
1314: * changes. This action maintains its enablement state.
1315: */
1316: public static final ActionFactory SAVE_ALL = new ActionFactory(
1317: "saveAll") {//$NON-NLS-1$
1318:
1319: /* (non-Javadoc)
1320: * @see org.eclipse.ui.actions.ActionFactory#create(org.eclipse.ui.IWorkbenchWindow)
1321: */
1322: public IWorkbenchAction create(IWorkbenchWindow window) {
1323: if (window == null) {
1324: throw new IllegalArgumentException();
1325: }
1326: IWorkbenchAction action = new SaveAllAction(window);
1327: action.setId(getId());
1328: return action;
1329: }
1330: };
1331:
1332: /**
1333: * Workbench action (id "saveAs"): Save As for the active editor. This
1334: * action maintains its enablement state.
1335: */
1336: public static final ActionFactory SAVE_AS = new ActionFactory(
1337: "saveAs") {//$NON-NLS-1$
1338:
1339: /* (non-Javadoc)
1340: * @see org.eclipse.ui.actions.ActionFactory#create(org.eclipse.ui.IWorkbenchWindow)
1341: */
1342: public IWorkbenchAction create(IWorkbenchWindow window) {
1343: if (window == null) {
1344: throw new IllegalArgumentException();
1345: }
1346: IWorkbenchAction action = new SaveAsAction(window);
1347: action.setId(getId());
1348: return action;
1349: }
1350: };
1351:
1352: /**
1353: * Workbench action (id "savePerspective"): Save the current perspective.
1354: * This action maintains its enablement state.
1355: */
1356: public static final ActionFactory SAVE_PERSPECTIVE = new ActionFactory(
1357: "savePerspective") {//$NON-NLS-1$
1358:
1359: /* (non-Javadoc)
1360: * @see org.eclipse.ui.actions.ActionFactory#create(org.eclipse.ui.IWorkbenchWindow)
1361: */
1362: public IWorkbenchAction create(IWorkbenchWindow window) {
1363: if (window == null) {
1364: throw new IllegalArgumentException();
1365: }
1366: IWorkbenchAction action = new SavePerspectiveAction(window);
1367: action.setId(getId());
1368: return action;
1369: }
1370: };
1371:
1372: /**
1373: * Workbench action (id "selectAll"): Select All. This action is a
1374: * {@link RetargetAction} with id "selectAll". This action
1375: * maintains its enablement state.
1376: */
1377: public static final ActionFactory SELECT_ALL = new ActionFactory(
1378: "selectAll") {//$NON-NLS-1$
1379:
1380: /* (non-Javadoc)
1381: * @see org.eclipse.ui.actions.ActionFactory#create(org.eclipse.ui.IWorkbenchWindow)
1382: */
1383: public IWorkbenchAction create(IWorkbenchWindow window) {
1384: if (window == null) {
1385: throw new IllegalArgumentException();
1386: }
1387: RetargetAction action = new RetargetAction(getId(),
1388: WorkbenchMessages.Workbench_selectAll);
1389: action
1390: .setToolTipText(WorkbenchMessages.Workbench_selectAllToolTip);
1391: window.getPartService().addPartListener(action);
1392: action
1393: .setActionDefinitionId("org.eclipse.ui.edit.selectAll"); //$NON-NLS-1$
1394: return action;
1395: }
1396: };
1397:
1398: /**
1399: * Workbench action (id "showEditor"): Show/hide the editor area. This
1400: * action maintains its enablement state.
1401: */
1402: public static final ActionFactory SHOW_EDITOR = new ActionFactory(
1403: "showEditor") {//$NON-NLS-1$
1404:
1405: /* (non-Javadoc)
1406: * @see org.eclipse.ui.actions.ActionFactory#create(org.eclipse.ui.IWorkbenchWindow)
1407: */
1408: public IWorkbenchAction create(IWorkbenchWindow window) {
1409: if (window == null) {
1410: throw new IllegalArgumentException();
1411: }
1412: IWorkbenchAction action = new ToggleEditorsVisibilityAction(
1413: window);
1414: action.setId(getId());
1415: return action;
1416: }
1417: };
1418:
1419: /**
1420: * Workbench action (id "showOpenEditors"): Show a list of open (and
1421: * recently closed) editors. This action maintains its enablement state.
1422: */
1423: public static final ActionFactory SHOW_OPEN_EDITORS = new ActionFactory(
1424: "showOpenEditors") {//$NON-NLS-1$
1425:
1426: /* (non-Javadoc)
1427: * @see org.eclipse.ui.actions.ActionFactory#create(org.eclipse.ui.IWorkbenchWindow)
1428: */
1429: public IWorkbenchAction create(IWorkbenchWindow window) {
1430: if (window == null) {
1431: throw new IllegalArgumentException();
1432: }
1433: IWorkbenchAction action = new WorkbenchEditorsAction(window);
1434: action.setId(getId());
1435: return action;
1436: }
1437: };
1438:
1439: /**
1440: * Workbench action (id "showWorkbookEditors"): Shows a list of open editors
1441: * in the current or last active workbook.
1442: */
1443: public static final ActionFactory SHOW_WORKBOOK_EDITORS = new ActionFactory(
1444: "showWorkBookEditors") {//$NON-NLS-1$
1445:
1446: /* (non-Javadoc)
1447: * @see org.eclipse.ui.actions.ActionFactory#create(org.eclipse.ui.IWorkbenchWindow)
1448: */
1449: public IWorkbenchAction create(IWorkbenchWindow window) {
1450: if (window == null) {
1451: throw new IllegalArgumentException();
1452: }
1453: IWorkbenchAction action = new WorkbookEditorsAction(window);
1454: action.setId(getId());
1455: return action;
1456: }
1457: };
1458:
1459: /**
1460: * Workbench action (id "showQuickAccess"): Shows a list of UI elements like editors, views, perspectives etc.
1461: * @since 3.3
1462: */
1463: public static final ActionFactory SHOW_QUICK_ACCESS = new ActionFactory(
1464: "showQuickAccess") { //$NON-NLS-1$
1465:
1466: /* (non-Javadoc)
1467: * @see org.eclipse.ui.actions.ActionFactory#create(org.eclipse.ui.IWorkbenchWindow)
1468: */
1469: public IWorkbenchAction create(IWorkbenchWindow window) {
1470: IWorkbenchAction action = new QuickAccessMenu(window);
1471: action.setId(getId());
1472: return action;
1473: }
1474:
1475: };
1476:
1477: /**
1478: * Workbench action (id "showPartPaneMenu"): Show the part pane menu. This
1479: * action maintains its enablement state.
1480: */
1481: public static final ActionFactory SHOW_PART_PANE_MENU = new ActionFactory(
1482: "showPartPaneMenu") {//$NON-NLS-1$
1483:
1484: /* (non-Javadoc)
1485: * @see org.eclipse.ui.actions.ActionFactory#create(org.eclipse.ui.IWorkbenchWindow)
1486: */
1487: public IWorkbenchAction create(IWorkbenchWindow window) {
1488: if (window == null) {
1489: throw new IllegalArgumentException();
1490: }
1491: WorkbenchCommandAction action = new WorkbenchCommandAction(
1492: "org.eclipse.ui.window.showSystemMenu", window); //$NON-NLS-1$
1493: action
1494: .setText(WorkbenchMessages.ShowPartPaneMenuAction_text);
1495: action
1496: .setToolTipText(WorkbenchMessages.ShowPartPaneMenuAction_toolTip);
1497: action.setId(getId());
1498: return action;
1499: }
1500: };
1501:
1502: /**
1503: * Workbench action (id "showViewMenu"): Show the view menu. This action
1504: * maintains its enablement state.
1505: */
1506: public static final ActionFactory SHOW_VIEW_MENU = new ActionFactory(
1507: "showViewMenu") {//$NON-NLS-1$
1508:
1509: /* (non-Javadoc)
1510: * @see org.eclipse.ui.actions.ActionFactory#create(org.eclipse.ui.IWorkbenchWindow)
1511: */
1512: public IWorkbenchAction create(IWorkbenchWindow window) {
1513: if (window == null) {
1514: throw new IllegalArgumentException();
1515: }
1516: WorkbenchCommandAction action = new WorkbenchCommandAction(
1517: "org.eclipse.ui.window.showViewMenu", window); //$NON-NLS-1$
1518: action.setText(WorkbenchMessages.ShowViewMenuAction_text);
1519: action
1520: .setToolTipText(WorkbenchMessages.ShowViewMenuAction_toolTip);
1521: action.setId(getId());
1522: return action;
1523: }
1524: };
1525:
1526: /**
1527: * Workbench action (id "undo"): Undo. This action is a
1528: * {@link RetargetAction} with id "undo". This action maintains
1529: * its enablement state.
1530: */
1531: public static final ActionFactory UNDO = new ActionFactory("undo") {//$NON-NLS-1$
1532:
1533: /* (non-Javadoc)
1534: * @see org.eclipse.ui.actions.ActionFactory#create(org.eclipse.ui.IWorkbenchWindow)
1535: */
1536: public IWorkbenchAction create(IWorkbenchWindow window) {
1537: if (window == null) {
1538: throw new IllegalArgumentException();
1539: }
1540: LabelRetargetAction action = new LabelRetargetAction(
1541: getId(), WorkbenchMessages.Workbench_undo);
1542: action
1543: .setToolTipText(WorkbenchMessages.Workbench_undoToolTip);
1544: window.getPartService().addPartListener(action);
1545: action.setActionDefinitionId("org.eclipse.ui.edit.undo"); //$NON-NLS-1$
1546: ISharedImages sharedImages = window.getWorkbench()
1547: .getSharedImages();
1548: action.setImageDescriptor(sharedImages
1549: .getImageDescriptor(ISharedImages.IMG_TOOL_UNDO));
1550: action
1551: .setDisabledImageDescriptor(sharedImages
1552: .getImageDescriptor(ISharedImages.IMG_TOOL_UNDO_DISABLED));
1553: return action;
1554: }
1555: };
1556:
1557: /**
1558: * Workbench action (id "up"): Up. This action is a
1559: * {@link RetargetAction} with id "up". This action maintains its
1560: * enablement state.
1561: */
1562: public static final ActionFactory UP = new ActionFactory("up") {//$NON-NLS-1$
1563:
1564: /* (non-Javadoc)
1565: * @see org.eclipse.ui.actions.ActionFactory#create(org.eclipse.ui.IWorkbenchWindow)
1566: */
1567: public IWorkbenchAction create(IWorkbenchWindow window) {
1568: if (window == null) {
1569: throw new IllegalArgumentException();
1570: }
1571: RetargetAction action = new LabelRetargetAction(getId(),
1572: WorkbenchMessages.Workbench_up);
1573: action
1574: .setToolTipText(WorkbenchMessages.Workbench_upToolTip);
1575: window.getPartService().addPartListener(action);
1576: action.setActionDefinitionId("org.eclipse.ui.navigate.up"); //$NON-NLS-1$
1577: return action;
1578: }
1579: };
1580:
1581: /**
1582: * Workbench action (id "helpContents"): Open the help contents. This action
1583: * is always enabled.
1584: */
1585: public static final ActionFactory HELP_CONTENTS = new ActionFactory(
1586: "helpContents") {//$NON-NLS-1$
1587:
1588: /* (non-Javadoc)
1589: * @see org.eclipse.ui.actions.ActionFactory#create(org.eclipse.ui.IWorkbenchWindow)
1590: */
1591: public IWorkbenchAction create(IWorkbenchWindow window) {
1592: if (window == null) {
1593: throw new IllegalArgumentException();
1594: }
1595: IWorkbenchAction action = new HelpContentsAction(window);
1596: action.setId(getId());
1597: return action;
1598: }
1599: };
1600:
1601: /**
1602: * Workbench action (id "helpSearch"): Open the help search. This action
1603: * is always enabled.
1604: *
1605: * @since 3.1
1606: */
1607: public static final ActionFactory HELP_SEARCH = new ActionFactory(
1608: "helpSearch") {//$NON-NLS-1$
1609:
1610: /* (non-Javadoc)
1611: * @see org.eclipse.ui.actions.ActionFactory#create(org.eclipse.ui.IWorkbenchWindow)
1612: */
1613: public IWorkbenchAction create(IWorkbenchWindow window) {
1614: if (window == null) {
1615: throw new IllegalArgumentException();
1616: }
1617: IWorkbenchAction action = new HelpSearchAction(window);
1618: action.setId(getId());
1619: return action;
1620: }
1621: };
1622:
1623: /**
1624: * Workbench action (id "dynamicHelp"): Open the dynamic help. This action
1625: * is always enabled.
1626: *
1627: * @since 3.1
1628: */
1629: public static final ActionFactory DYNAMIC_HELP = new ActionFactory(
1630: "dynamicHelp") {//$NON-NLS-1$
1631:
1632: /* (non-Javadoc)
1633: * @see org.eclipse.ui.actions.ActionFactory#create(org.eclipse.ui.IWorkbenchWindow)
1634: */
1635: public IWorkbenchAction create(IWorkbenchWindow window) {
1636: if (window == null) {
1637: throw new IllegalArgumentException();
1638: }
1639: IWorkbenchAction action = new DynamicHelpAction(window);
1640: action.setId(getId());
1641: return action;
1642: }
1643: };
1644:
1645: /**
1646: * Workbench action (id "openPerspectiveDialog"): Open the Open Perspective dialog. This action
1647: * is always enabled.
1648: *
1649: * @since 3.1
1650: */
1651: public static final ActionFactory OPEN_PERSPECTIVE_DIALOG = new ActionFactory(
1652: "openPerspectiveDialog") {//$NON-NLS-1$
1653:
1654: /* (non-Javadoc)
1655: * @see org.eclipse.ui.actions.ActionFactory#create(org.eclipse.ui.IWorkbenchWindow)
1656: */
1657: public IWorkbenchAction create(IWorkbenchWindow window) {
1658: if (window == null) {
1659: throw new IllegalArgumentException();
1660: }
1661: IWorkbenchAction action = new OpenPerspectiveDialogAction(
1662: window);
1663: action.setId(getId());
1664: return action;
1665: }
1666: };
1667:
1668: /**
1669: * Workbench action (id "newEditor"): Open a new editor on the active editor's input.
1670: * This action maintains its enablement state.
1671: *
1672: * @since 3.1
1673: */
1674: public static final ActionFactory NEW_EDITOR = new ActionFactory(
1675: "newEditor") {//$NON-NLS-1$
1676:
1677: /* (non-Javadoc)
1678: * @see org.eclipse.ui.actions.ActionFactory#create(org.eclipse.ui.IWorkbenchWindow)
1679: */
1680: public IWorkbenchAction create(IWorkbenchWindow window) {
1681: if (window == null) {
1682: throw new IllegalArgumentException();
1683: }
1684: IWorkbenchAction action = new NewEditorAction(window);
1685: action.setId(getId());
1686: return action;
1687: }
1688: };
1689:
1690: /**
1691: * Workbench action (id "toggleCoolbar"): Toggle the visibility of the
1692: * coolbar and perspective switcher. This will only enable visibility of the
1693: * coolbar and perspective bar if the window advisor creating the window
1694: * allowed for their visibility initially.
1695: *
1696: * @since 3.3
1697: */
1698: public static final ActionFactory TOGGLE_COOLBAR = new ActionFactory(
1699: "toggleCoolbar") { //$NON-NLS-1$
1700:
1701: public IWorkbenchAction create(IWorkbenchWindow window) {
1702: if (window == null) {
1703: throw new IllegalArgumentException();
1704: }
1705: WorkbenchCommandAction action = new WorkbenchCommandAction(
1706: "org.eclipse.ui.ToggleCoolbarAction", window); //$NON-NLS-1$
1707: // set the default text - this will be updated by the handler
1708: action
1709: .setText(WorkbenchMessages.ToggleCoolbarVisibilityAction_hide_text);
1710: action
1711: .setToolTipText(WorkbenchMessages.ToggleCoolbarVisibilityAction_toolTip);
1712: action.setId(getId());
1713: return action;
1714: }
1715: };
1716:
1717: /**
1718: * Establishes bi-direction connections between the forward and backward
1719: * actions of a cycle pair.
1720: * <p>
1721: * Example usage:
1722: *
1723: * <pre>
1724: * ActionFactory.IWorkbenchAction nextEditorAction = ActionFactory.NEXT_EDITOR
1725: * .create(window);
1726: * ActionFactory.IWorkbenchAction previousEditorAction = ActionFactory.PREVIOUS_EDITOR
1727: * .create(window);
1728: * ActionFactory.linkCycleActionPair(nextEditorAction, previousEditorAction);
1729: * </pre>
1730: *
1731: * </p>
1732: *
1733: * @param next
1734: * the action that moves forward
1735: * @param previous
1736: * the action that moves backward
1737: */
1738: public static void linkCycleActionPair(IWorkbenchAction next,
1739: IWorkbenchAction previous) {
1740: }
1741:
1742: /**
1743: * Id of actions created by this action factory.
1744: */
1745: private final String actionId;
1746:
1747: /**
1748: * Creates a new workbench action factory with the given id.
1749: *
1750: * @param actionId
1751: * the id of actions created by this action factory
1752: */
1753: protected ActionFactory(String actionId) {
1754: this .actionId = actionId;
1755: }
1756:
1757: /**
1758: * Creates a new standard action for the given workbench window. The action
1759: * has an id as specified by the particular factory.
1760: * <p>
1761: * Actions automatically register listeners against the workbench window so
1762: * that they can keep their enablement state up to date. Ordinarily, the
1763: * window's references to these listeners will be dropped automatically
1764: * when the window closes. However, if the client needs to get rid of an
1765: * action while the window is still open, the client must call
1766: * {@link IWorkbenchAction#dispose dispose}to give the action an
1767: * opportunity to deregister its listeners and to perform any other
1768: * cleanup.
1769: * </p>
1770: *
1771: * @param window
1772: * the workbench window
1773: * @return the workbench action
1774: */
1775: public abstract IWorkbenchAction create(IWorkbenchWindow window);
1776:
1777: /**
1778: * Returns the id of this action factory.
1779: *
1780: * @return the id of actions created by this action factory
1781: */
1782: public String getId() {
1783: return actionId;
1784: }
1785:
1786: }
|