1 11 package org.eclipse.ui.actions; 12 13 import java.util.Map ; 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 73 public abstract class ActionFactory { 74 75 78 public interface IWorkbenchAction extends IAction { 79 84 public void dispose(); 85 } 86 87 private static class WorkbenchCommandAction extends CommandAction implements 88 IWorkbenchAction { 89 93 public WorkbenchCommandAction(String commandIdIn, 94 IWorkbenchWindow window) { 95 super(window, commandIdIn); 96 } 97 98 public WorkbenchCommandAction(String commandIdIn, Map parameterMap, 99 IServiceLocator serviceLocator) { 100 super(serviceLocator, commandIdIn, parameterMap); 101 } 102 } 103 104 108 public static final ActionFactory ABOUT = new ActionFactory("about") { 110 115 public IWorkbenchAction create(IWorkbenchWindow window) { 116 if (window == null) { 117 throw new IllegalArgumentException (); 118 } 119 120 WorkbenchCommandAction action = new WorkbenchCommandAction( 121 "org.eclipse.ui.help.aboutAction", window); 123 action.setId(getId()); 124 IProduct product = Platform.getProduct(); 125 String productName = null; 126 if (product != null) { 127 productName = product.getName(); 128 } 129 if (productName == null) { 130 productName = ""; } 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 147 public static final ActionFactory ACTIVATE_EDITOR = new ActionFactory( 148 "activateEditor") { 150 153 public IWorkbenchAction create(IWorkbenchWindow window) { 154 if (window == null) { 155 throw new IllegalArgumentException (); 156 } 157 WorkbenchCommandAction action = new WorkbenchCommandAction( 158 "org.eclipse.ui.window.activateEditor", window); action.setId(getId()); 160 action.setText(WorkbenchMessages.ActivateEditorAction_text); 161 action 162 .setToolTipText(WorkbenchMessages.ActivateEditorAction_toolTip); 163 return action; 164 } 165 }; 166 167 172 public static final ActionFactory BACK = new ActionFactory("back") { 176 public IWorkbenchAction create(IWorkbenchWindow window) { 177 if (window == null) { 178 throw new IllegalArgumentException (); 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"); return action; 185 } 186 }; 187 188 192 public static final ActionFactory BACKWARD_HISTORY = new ActionFactory( 193 "backardHistory") { 197 public IWorkbenchAction create(IWorkbenchWindow window) { 198 if (window == null) { 199 throw new IllegalArgumentException (); 200 } 201 IWorkbenchAction action = new NavigationHistoryAction(window, false); 202 action.setId(getId()); 203 return action; 204 } 205 }; 206 207 211 public static final ActionFactory CLOSE = new ActionFactory("close") { 215 public IWorkbenchAction create(IWorkbenchWindow window) { 216 if (window == null) { 217 throw new IllegalArgumentException (); 218 } 219 WorkbenchCommandAction action=new WorkbenchCommandAction("org.eclipse.ui.file.close",window); action.setText(WorkbenchMessages.CloseEditorAction_text); 221 action.setToolTipText(WorkbenchMessages.CloseEditorAction_toolTip); 222 action.setId(getId()); 223 return action; 224 } 225 }; 226 227 231 public static final ActionFactory CLOSE_ALL = new ActionFactory("closeAll") { 235 public IWorkbenchAction create(IWorkbenchWindow window) { 236 if (window == null) { 237 throw new IllegalArgumentException (); 238 } 239 WorkbenchCommandAction action=new WorkbenchCommandAction("org.eclipse.ui.file.closeAll",window); action.setText(WorkbenchMessages.CloseAllAction_text); 241 action.setToolTipText(WorkbenchMessages.CloseAllAction_toolTip); 242 action.setId(getId()); 243 return action; 244 } 245 }; 246 247 253 public static final ActionFactory CLOSE_OTHERS = new ActionFactory("closeOthers") { 257 public IWorkbenchAction create(IWorkbenchWindow window) { 258 if (window == null) { 259 throw new IllegalArgumentException (); 260 } 261 WorkbenchCommandAction action = new WorkbenchCommandAction( 262 "org.eclipse.ui.file.closeOthers", window); action.setText(WorkbenchMessages.CloseOthersAction_text); 264 action.setToolTipText(WorkbenchMessages.CloseOthersAction_toolTip); 265 action.setId(getId()); 266 return action; 267 } 268 }; 269 270 274 public static final ActionFactory CLOSE_ALL_PERSPECTIVES = new ActionFactory( 275 "closeAllPerspectives") { 279 public IWorkbenchAction create(IWorkbenchWindow window) { 280 if (window == null) { 281 throw new IllegalArgumentException (); 282 } 283 IWorkbenchAction action = new CloseAllPerspectivesAction(window); 284 action.setId(getId()); 285 return action; 286 } 287 }; 288 289 293 public static final ActionFactory CLOSE_ALL_SAVED = new ActionFactory( 294 "closeAllSaved") { 298 public IWorkbenchAction create(IWorkbenchWindow window) { 299 if (window == null) { 300 throw new IllegalArgumentException (); 301 } 302 IWorkbenchAction action = new CloseAllSavedAction(window); 303 action.setId(getId()); 304 return action; 305 } 306 }; 307 308 312 public static final ActionFactory CLOSE_PERSPECTIVE = new ActionFactory( 313 "closePerspective") { 317 public IWorkbenchAction create(IWorkbenchWindow window) { 318 if (window == null) { 319 throw new IllegalArgumentException (); 320 } 321 IWorkbenchAction action = new ClosePerspectiveAction(window); 322 action.setId(getId()); 323 return action; 324 } 325 }; 326 327 330 public static final ActionFactory INTRO = new ActionFactory("intro") { 334 public IWorkbenchAction create(IWorkbenchWindow window) { 335 if (window == null) { 336 throw new IllegalArgumentException (); 337 } 338 IWorkbenchAction action = new IntroAction(window); 339 action.setId(getId()); 340 return action; 341 } 342 }; 343 344 349 public static final ActionFactory COPY = new ActionFactory("copy") { 351 354 public IWorkbenchAction create(IWorkbenchWindow window) { 355 if (window == null) { 356 throw new IllegalArgumentException (); 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"); 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 377 public static final ActionFactory CUT = new ActionFactory("cut") { 379 382 public IWorkbenchAction create(IWorkbenchWindow window) { 383 if (window == null) { 384 throw new IllegalArgumentException (); 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"); 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 405 public static final ActionFactory DELETE = new ActionFactory("delete") { 407 410 public IWorkbenchAction create(IWorkbenchWindow window) { 411 if (window == null) { 412 throw new IllegalArgumentException (); 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"); 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 436 public static final ActionFactory EDIT_ACTION_SETS = new ActionFactory( 437 "editActionSets") { 439 442 public IWorkbenchAction create(IWorkbenchWindow window) { 443 if (window == null) { 444 throw new IllegalArgumentException (); 445 } 446 IWorkbenchAction action = new EditActionSetsAction(window); 447 action.setId(getId()); 448 return action; 449 } 450 }; 451 452 456 public static final ActionFactory EXPORT = new ActionFactory("export") { 458 461 public IWorkbenchAction create(IWorkbenchWindow window) { 462 if (window == null) { 463 throw new IllegalArgumentException (); 464 } 465 IWorkbenchAction action = new ExportResourcesAction(window); 466 action.setId(getId()); 467 return action; 468 } 469 }; 470 471 476 public static final ActionFactory FIND = new ActionFactory("find") { 478 481 public IWorkbenchAction create(IWorkbenchWindow window) { 482 if (window == null) { 483 throw new IllegalArgumentException (); 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"); return action; 494 } 495 }; 496 497 502 public static final ActionFactory FORWARD = new ActionFactory("forward") { 504 507 public IWorkbenchAction create(IWorkbenchWindow window) { 508 if (window == null) { 509 throw new IllegalArgumentException (); 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"); return action; 516 } 517 }; 518 519 523 public static final ActionFactory FORWARD_HISTORY = new ActionFactory( 524 "forwardHistory") { 526 529 public IWorkbenchAction create(IWorkbenchWindow window) { 530 if (window == null) { 531 throw new IllegalArgumentException (); 532 } 533 IWorkbenchAction action = new NavigationHistoryAction(window, true); 534 action.setId(getId()); 535 return action; 536 } 537 }; 538 539 544 public static final ActionFactory GO_INTO = new ActionFactory("goInto") { 546 549 public IWorkbenchAction create(IWorkbenchWindow window) { 550 if (window == null) { 551 throw new IllegalArgumentException (); 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"); return action; 558 } 559 }; 560 561 565 public static final ActionFactory IMPORT = new ActionFactory("import") { 567 570 public IWorkbenchAction create(IWorkbenchWindow window) { 571 if (window == null) { 572 throw new IllegalArgumentException (); 573 } 574 IWorkbenchAction action = new ImportResourcesAction(window); 575 action.setId(getId()); 576 return action; 577 } 578 }; 579 580 584 public static final ActionFactory LOCK_TOOL_BAR = new ActionFactory( 585 "lockToolBar") { 587 590 public IWorkbenchAction create(IWorkbenchWindow window) { 591 if (window == null) { 592 throw new IllegalArgumentException (); 593 } 594 IWorkbenchAction action = new LockToolBarAction(window); 595 action.setId(getId()); 596 return action; 597 } 598 }; 599 600 604 public static final ActionFactory MAXIMIZE = new ActionFactory("maximize") { 606 609 public IWorkbenchAction create(IWorkbenchWindow window) { 610 if (window == null) { 611 throw new IllegalArgumentException (); 612 } 613 IWorkbenchAction action = new MaximizePartAction(window); 614 action.setId(getId()); 615 return action; 616 } 617 }; 618 619 625 public static final ActionFactory MINIMIZE = new ActionFactory("minimize") { 627 630 public IWorkbenchAction create(IWorkbenchWindow window) { 631 if (window == null) { 632 throw new IllegalArgumentException (); 633 } 634 IWorkbenchAction action = new MinimizePartAction(window); 635 action.setId(getId()); 636 return action; 637 } 638 }; 639 640 645 public static final ActionFactory MOVE = new ActionFactory("move") { 647 650 public IWorkbenchAction create(IWorkbenchWindow window) { 651 if (window == null) { 652 throw new IllegalArgumentException (); 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"); return action; 659 } 660 }; 661 662 666 public static final ActionFactory NEW = new ActionFactory("new") { 668 671 public IWorkbenchAction create(IWorkbenchWindow window) { 672 if (window == null) { 673 throw new IllegalArgumentException (); 674 } 675 IWorkbenchAction action = new NewWizardAction(window); 676 action.setId(getId()); 677 return action; 678 } 679 }; 680 681 688 public static final ActionFactory NEW_WIZARD_DROP_DOWN = new ActionFactory( 689 "newWizardDropDown") { 691 694 public IWorkbenchAction create(IWorkbenchWindow window) { 695 if (window == null) { 696 throw new IllegalArgumentException (); 697 } 698 IWorkbenchAction action = new NewWizardDropDownAction(window); 699 action.setId(getId()); 700 return action; 701 } 702 }; 703 704 709 public static final ActionFactory NEXT = new ActionFactory("next") { 711 714 public IWorkbenchAction create(IWorkbenchWindow window) { 715 if (window == null) { 716 throw new IllegalArgumentException (); 717 } 718 WorkbenchCommandAction action = new WorkbenchCommandAction( 719 "org.eclipse.ui.navigate.next", window); action.setText(WorkbenchMessages.Workbench_next); 721 action.setId(getId()); 722 action.setToolTipText(WorkbenchMessages.Workbench_nextToolTip); 723 return action; 724 } 725 }; 726 727 737 public static final ActionFactory NEXT_EDITOR = new ActionFactory( 738 "nextEditor") { 740 743 public IWorkbenchAction create(IWorkbenchWindow window) { 744 if (window == null) { 745 throw new IllegalArgumentException (); 746 } 747 IWorkbenchAction action = new WorkbenchCommandAction( 748 "org.eclipse.ui.window.nextEditor", window); 750 751 action.setText(WorkbenchMessages.CycleEditorAction_next_text); 752 action.setToolTipText(WorkbenchMessages.CycleEditorAction_next_toolTip); 753 window.getWorkbench().getHelpSystem().setHelp(action, 755 IWorkbenchHelpContextIds.CYCLE_EDITOR_FORWARD_ACTION); 756 757 action.setId(getId()); 758 return action; 759 } 760 }; 761 762 772 public static final ActionFactory NEXT_PART = new ActionFactory("nextPart") { 774 777 public IWorkbenchAction create(IWorkbenchWindow window) { 778 if (window == null) { 779 throw new IllegalArgumentException (); 780 } 781 WorkbenchCommandAction action=new WorkbenchCommandAction("org.eclipse.ui.window.nextView",window); action.setText(WorkbenchMessages.CyclePartAction_next_text); 783 action.setToolTipText(WorkbenchMessages.CyclePartAction_next_toolTip); 784 window.getWorkbench().getHelpSystem().setHelp(action, 786 IWorkbenchHelpContextIds.CYCLE_PART_FORWARD_ACTION); 787 action.setId(getId()); 788 return action; 789 } 790 }; 791 792 802 public static final ActionFactory NEXT_PERSPECTIVE = new ActionFactory( 803 "nextPerspective") { 805 808 public IWorkbenchAction create(IWorkbenchWindow window) { 809 if (window == null) { 810 throw new IllegalArgumentException (); 811 } 812 WorkbenchCommandAction action=new WorkbenchCommandAction("org.eclipse.ui.window.nextPerspective",window); action.setText(WorkbenchMessages.CyclePerspectiveAction_next_text); 814 action.setToolTipText(WorkbenchMessages.CyclePerspectiveAction_next_toolTip); 815 window.getWorkbench().getHelpSystem().setHelp(action, 817 IWorkbenchHelpContextIds.CYCLE_PERSPECTIVE_FORWARD_ACTION); 818 action.setId(getId()); 819 return action; 820 } 821 }; 822 823 827 public static final ActionFactory OPEN_NEW_WINDOW = new ActionFactory( 828 "openNewWindow") { 830 833 public IWorkbenchAction create(IWorkbenchWindow window) { 834 if (window == null) { 835 throw new IllegalArgumentException (); 836 } 837 IWorkbenchAction action = new OpenInNewWindowAction(window); 838 action.setId(getId()); 839 return action; 840 } 841 }; 842 843 848 public static final ActionFactory PASTE = new ActionFactory("paste") { 850 853 public IWorkbenchAction create(IWorkbenchWindow window) { 854 if (window == null) { 855 throw new IllegalArgumentException (); 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"); 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 875 public static final ActionFactory PREFERENCES = new ActionFactory( 876 "preferences") { 878 881 public IWorkbenchAction create(IWorkbenchWindow window) { 882 if (window == null) { 883 throw new IllegalArgumentException (); 884 } 885 IWorkbenchAction action = new OpenPreferencesAction(window); 886 action.setId(getId()); 887 return action; 888 } 889 }; 890 891 896 public static final ActionFactory PREVIOUS = new ActionFactory("previous") { 898 901 public IWorkbenchAction create(IWorkbenchWindow window) { 902 if (window == null) { 903 throw new IllegalArgumentException (); 904 } 905 WorkbenchCommandAction action = new WorkbenchCommandAction( 906 "org.eclipse.ui.navigate.previous", window); action.setText(WorkbenchMessages.Workbench_previous); 908 action.setId(getId()); 909 action.setToolTipText(WorkbenchMessages.Workbench_previousToolTip); 910 return action; 911 } 912 }; 913 914 924 public static final ActionFactory PREVIOUS_EDITOR = new ActionFactory( 925 "previousEditor") { 927 930 public IWorkbenchAction create(IWorkbenchWindow window) { 931 if (window == null) { 932 throw new IllegalArgumentException (); 933 } 934 IWorkbenchAction action = new WorkbenchCommandAction( 935 "org.eclipse.ui.window.previousEditor", window); 937 action.setText(WorkbenchMessages.CycleEditorAction_prev_text); 938 action.setToolTipText(WorkbenchMessages.CycleEditorAction_prev_toolTip); 939 window.getWorkbench().getHelpSystem().setHelp(action, 941 IWorkbenchHelpContextIds.CYCLE_EDITOR_BACKWARD_ACTION); 942 943 action.setId(getId()); 944 return action; 945 } 946 }; 947 948 958 public static final ActionFactory PREVIOUS_PART = new ActionFactory( 959 "previousPart") { 961 964 public IWorkbenchAction create(IWorkbenchWindow window) { 965 if (window == null) { 966 throw new IllegalArgumentException (); 967 } 968 WorkbenchCommandAction action=new WorkbenchCommandAction("org.eclipse.ui.window.previousView",window); action.setText(WorkbenchMessages.CyclePartAction_prev_text); 970 action.setToolTipText(WorkbenchMessages.CyclePartAction_prev_toolTip); 971 window.getWorkbench().getHelpSystem().setHelp(action, 973 IWorkbenchHelpContextIds.CYCLE_PART_BACKWARD_ACTION); 974 action.setId(getId()); 975 return action; 976 } 977 }; 978 979 989 public static final ActionFactory PREVIOUS_PERSPECTIVE = new ActionFactory( 990 "previousPerspective") { 992 995 public IWorkbenchAction create(IWorkbenchWindow window) { 996 if (window == null) { 997 throw new IllegalArgumentException (); 998 } 999 WorkbenchCommandAction action=new WorkbenchCommandAction("org.eclipse.ui.window.previousPerspective",window); action.setText(WorkbenchMessages.CyclePerspectiveAction_prev_text); 1001 action.setToolTipText(WorkbenchMessages.CyclePerspectiveAction_prev_toolTip); 1002 window.getWorkbench().getHelpSystem().setHelp(action, 1004 IWorkbenchHelpContextIds.CYCLE_PERSPECTIVE_BACKWARD_ACTION); 1005 action.setId(getId()); 1006 return action; 1007 } 1008 }; 1009 1010 1015 public static final ActionFactory PRINT = new ActionFactory("print") { 1017 1020 public IWorkbenchAction create(IWorkbenchWindow window) { 1021 if (window == null) { 1022 throw new IllegalArgumentException (); 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"); 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 1043 public static final ActionFactory PROPERTIES = new ActionFactory( 1044 "properties") { 1046 1049 public IWorkbenchAction create(IWorkbenchWindow window) { 1050 if (window == null) { 1051 throw new IllegalArgumentException (); 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"); return action; 1058 } 1059 }; 1060 1061 1065 public static final ActionFactory QUIT = new ActionFactory("quit") { 1067 1070 public IWorkbenchAction create(IWorkbenchWindow window) { 1071 if (window == null) { 1072 throw new IllegalArgumentException (); 1073 } 1074 IWorkbenchAction action = new QuitAction(window); 1075 action.setId(getId()); 1076 return action; 1077 } 1078 }; 1079 1080 1085 public static final ActionFactory REDO = new ActionFactory("redo") { 1087 1090 public IWorkbenchAction create(IWorkbenchWindow window) { 1091 if (window == null) { 1092 throw new IllegalArgumentException (); 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"); 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 1113 public static final ActionFactory REFRESH = new ActionFactory("refresh") { 1115 1118 public IWorkbenchAction create(IWorkbenchWindow window) { 1119 if (window == null) { 1120 throw new IllegalArgumentException (); 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"); return action; 1127 } 1128 }; 1129 1130 1135 public static final ActionFactory RENAME = new ActionFactory("rename") { 1137 1140 public IWorkbenchAction create(IWorkbenchWindow window) { 1141 if (window == null) { 1142 throw new IllegalArgumentException (); 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"); return action; 1149 } 1150 }; 1151 1152 1156 public static final ActionFactory RESET_PERSPECTIVE = new ActionFactory( 1157 "resetPerspective") { 1159 1162 public IWorkbenchAction create(IWorkbenchWindow window) { 1163 if (window == null) { 1164 throw new IllegalArgumentException (); 1165 } 1166 IWorkbenchAction action = new ResetPerspectiveAction(window); 1167 action.setId(getId()); 1168 return action; 1169 } 1170 }; 1171 1172 1177 public static final ActionFactory REVERT = new ActionFactory("revert") { 1179 1182 public IWorkbenchAction create(IWorkbenchWindow window) { 1183 if (window == null) { 1184 throw new IllegalArgumentException (); 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"); return action; 1191 } 1192 }; 1193 1194 1198 public static final ActionFactory SAVE = new ActionFactory("save") { 1200 1203 public IWorkbenchAction create(IWorkbenchWindow window) { 1204 if (window == null) { 1205 throw new IllegalArgumentException (); 1206 } 1207 IWorkbenchAction action = new SaveAction(window); 1208 action.setId(getId()); 1209 return action; 1210 } 1211 }; 1212 1213 1217 public static final ActionFactory SAVE_ALL = new ActionFactory("saveAll") { 1219 1222 public IWorkbenchAction create(IWorkbenchWindow window) { 1223 if (window == null) { 1224 throw new IllegalArgumentException (); 1225 } 1226 IWorkbenchAction action = new SaveAllAction(window); 1227 action.setId(getId()); 1228 return action; 1229 } 1230 }; 1231 1232 1236 public static final ActionFactory SAVE_AS = new ActionFactory("saveAs") { 1238 1241 public IWorkbenchAction create(IWorkbenchWindow window) { 1242 if (window == null) { 1243 throw new IllegalArgumentException (); 1244 } 1245 IWorkbenchAction action = new SaveAsAction(window); 1246 action.setId(getId()); 1247 return action; 1248 } 1249 }; 1250 1251 1255 public static final ActionFactory SAVE_PERSPECTIVE = new ActionFactory( 1256 "savePerspective") { 1258 1261 public IWorkbenchAction create(IWorkbenchWindow window) { 1262 if (window == null) { 1263 throw new IllegalArgumentException (); 1264 } 1265 IWorkbenchAction action = new SavePerspectiveAction(window); 1266 action.setId(getId()); 1267 return action; 1268 } 1269 }; 1270 1271 1276 public static final ActionFactory SELECT_ALL = new ActionFactory( 1277 "selectAll") { 1279 1282 public IWorkbenchAction create(IWorkbenchWindow window) { 1283 if (window == null) { 1284 throw new IllegalArgumentException (); 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"); return action; 1291 } 1292 }; 1293 1294 1298 public static final ActionFactory SHOW_EDITOR = new ActionFactory( 1299 "showEditor") { 1301 1304 public IWorkbenchAction create(IWorkbenchWindow window) { 1305 if (window == null) { 1306 throw new IllegalArgumentException (); 1307 } 1308 IWorkbenchAction action = new ToggleEditorsVisibilityAction(window); 1309 action.setId(getId()); 1310 return action; 1311 } 1312 }; 1313 1314 1318 public static final ActionFactory SHOW_OPEN_EDITORS = new ActionFactory( 1319 "showOpenEditors") { 1321 1324 public IWorkbenchAction create(IWorkbenchWindow window) { 1325 if (window == null) { 1326 throw new IllegalArgumentException (); 1327 } 1328 IWorkbenchAction action = new WorkbenchEditorsAction(window); 1329 action.setId(getId()); 1330 return action; 1331 } 1332 }; 1333 1334 1338 public static final ActionFactory SHOW_WORKBOOK_EDITORS = new ActionFactory( 1339 "showWorkBookEditors") { 1341 1344 public IWorkbenchAction create(IWorkbenchWindow window) { 1345 if (window == null) { 1346 throw new IllegalArgumentException (); 1347 } 1348 IWorkbenchAction action = new WorkbookEditorsAction(window); 1349 action.setId(getId()); 1350 return action; 1351 } 1352 }; 1353 1354 1358 public static final ActionFactory SHOW_QUICK_ACCESS = new ActionFactory( 1359 "showQuickAccess") { 1361 1364 public IWorkbenchAction create(IWorkbenchWindow window) { 1365 IWorkbenchAction action = new QuickAccessMenu(window); 1366 action.setId(getId()); 1367 return action; 1368 } 1369 1370 }; 1371 1372 1376 public static final ActionFactory SHOW_PART_PANE_MENU = new ActionFactory( 1377 "showPartPaneMenu") { 1379 1382 public IWorkbenchAction create(IWorkbenchWindow window) { 1383 if (window == null) { 1384 throw new IllegalArgumentException (); 1385 } 1386 WorkbenchCommandAction action=new WorkbenchCommandAction("org.eclipse.ui.window.showSystemMenu",window); action.setText(WorkbenchMessages.ShowPartPaneMenuAction_text); 1388 action.setToolTipText(WorkbenchMessages.ShowPartPaneMenuAction_toolTip); 1389 action.setId(getId()); 1390 return action; 1391 } 1392 }; 1393 1394 1398 public static final ActionFactory SHOW_VIEW_MENU = new ActionFactory( 1399 "showViewMenu") { 1401 1404 public IWorkbenchAction create(IWorkbenchWindow window) { 1405 if (window == null) { 1406 throw new IllegalArgumentException (); 1407 } 1408 WorkbenchCommandAction action=new WorkbenchCommandAction("org.eclipse.ui.window.showViewMenu",window); action.setText(WorkbenchMessages.ShowViewMenuAction_text); 1410 action.setToolTipText(WorkbenchMessages.ShowViewMenuAction_toolTip); 1411 action.setId(getId()); 1412 return action; 1413 } 1414 }; 1415 1416 1421 public static final ActionFactory UNDO = new ActionFactory("undo") { 1423 1426 public IWorkbenchAction create(IWorkbenchWindow window) { 1427 if (window == null) { 1428 throw new IllegalArgumentException (); 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"); 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 1449 public static final ActionFactory UP = new ActionFactory("up") { 1451 1454 public IWorkbenchAction create(IWorkbenchWindow window) { 1455 if (window == null) { 1456 throw new IllegalArgumentException (); 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"); return action; 1463 } 1464 }; 1465 1466 1470 public static final ActionFactory HELP_CONTENTS = new ActionFactory( 1471 "helpContents") { 1473 1476 public IWorkbenchAction create(IWorkbenchWindow window) { 1477 if (window == null) { 1478 throw new IllegalArgumentException (); 1479 } 1480 IWorkbenchAction action = new HelpContentsAction(window); 1481 action.setId(getId()); 1482 return action; 1483 } 1484 }; 1485 1486 1492 public static final ActionFactory HELP_SEARCH = new ActionFactory( 1493 "helpSearch") { 1495 1498 public IWorkbenchAction create(IWorkbenchWindow window) { 1499 if (window == null) { 1500 throw new IllegalArgumentException (); 1501 } 1502 IWorkbenchAction action = new HelpSearchAction(window); 1503 action.setId(getId()); 1504 return action; 1505 } 1506 }; 1507 1508 1514 public static final ActionFactory DYNAMIC_HELP = new ActionFactory( 1515 "dynamicHelp") { 1517 1520 public IWorkbenchAction create(IWorkbenchWindow window) { 1521 if (window == null) { 1522 throw new IllegalArgumentException (); 1523 } 1524 IWorkbenchAction action = new DynamicHelpAction(window); 1525 action.setId(getId()); 1526 return action; 1527 } 1528 }; 1529 1530 1536 public static final ActionFactory OPEN_PERSPECTIVE_DIALOG = new ActionFactory( 1537 "openPerspectiveDialog") { 1539 1542 public IWorkbenchAction create(IWorkbenchWindow window) { 1543 if (window == null) { 1544 throw new IllegalArgumentException (); 1545 } 1546 IWorkbenchAction action = new OpenPerspectiveDialogAction(window); 1547 action.setId(getId()); 1548 return action; 1549 } 1550 }; 1551 1552 1558 public static final ActionFactory NEW_EDITOR = new ActionFactory( 1559 "newEditor") { 1561 1564 public IWorkbenchAction create(IWorkbenchWindow window) { 1565 if (window == null) { 1566 throw new IllegalArgumentException (); 1567 } 1568 IWorkbenchAction action = new NewEditorAction(window); 1569 action.setId(getId()); 1570 return action; 1571 } 1572 }; 1573 1574 1582 public static final ActionFactory TOGGLE_COOLBAR = new ActionFactory( 1583 "toggleCoolbar") { 1585 public IWorkbenchAction create(IWorkbenchWindow window) { 1586 if (window == null) { 1587 throw new IllegalArgumentException (); 1588 } 1589 WorkbenchCommandAction action = new WorkbenchCommandAction( 1590 "org.eclipse.ui.ToggleCoolbarAction", window); action.setText(WorkbenchMessages.ToggleCoolbarVisibilityAction_hide_text); 1593 action.setToolTipText(WorkbenchMessages.ToggleCoolbarVisibilityAction_toolTip); 1594 action.setId(getId()); 1595 return action; 1596 } 1597 }; 1598 1599 1620 public static void linkCycleActionPair(IWorkbenchAction next, 1621 IWorkbenchAction previous) { 1622 } 1623 1624 1627 private final String actionId; 1628 1629 1635 protected ActionFactory(String actionId) { 1636 this.actionId = actionId; 1637 } 1638 1639 1657 public abstract IWorkbenchAction create(IWorkbenchWindow window); 1658 1659 1664 public String getId() { 1665 return actionId; 1666 } 1667 1668} 1669 | Popular Tags |