1 11 package org.eclipse.ui.actions; 12 13 import org.eclipse.jface.action.IContributionItem; 14 import org.eclipse.ui.IWorkbenchWindow; 15 import org.eclipse.ui.internal.ChangeToPerspectiveMenu; 16 import org.eclipse.ui.internal.PinEditorAction; 17 import org.eclipse.ui.internal.ReopenEditorMenu; 18 import org.eclipse.ui.internal.ShowInMenu; 19 import org.eclipse.ui.internal.ShowViewMenu; 20 import org.eclipse.ui.internal.SwitchToWindowMenu; 21 import org.eclipse.ui.internal.actions.HelpSearchContributionItem; 22 import org.eclipse.ui.internal.actions.PinEditorContributionItem; 23 24 44 public abstract class ContributionItemFactory { 45 46 49 private final String contributionItemId; 50 51 56 protected ContributionItemFactory(String contributionItemId) { 57 this.contributionItemId = contributionItemId; 58 } 59 60 75 public abstract IContributionItem create(IWorkbenchWindow window); 76 77 82 public String getId() { 83 return contributionItemId; 84 } 85 86 90 public static final ContributionItemFactory PIN_EDITOR = new ContributionItemFactory( 91 "pinEditor") { 93 public IContributionItem create(IWorkbenchWindow window) { 94 if (window == null) { 95 throw new IllegalArgumentException (); 96 } 97 PinEditorAction action = new PinEditorAction(window); 98 action.setId(getId()); 99 return new PinEditorContributionItem(action, window); 100 } 101 }; 102 103 109 public static final ContributionItemFactory OPEN_WINDOWS = new ContributionItemFactory( 110 "openWindows") { 112 public IContributionItem create(IWorkbenchWindow window) { 113 if (window == null) { 114 throw new IllegalArgumentException (); 115 } 116 return new SwitchToWindowMenu(window, getId(), true); 117 } 118 }; 119 120 127 public static final ContributionItemFactory VIEWS_SHORTLIST = new ContributionItemFactory( 128 "viewsShortlist") { 130 public IContributionItem create(IWorkbenchWindow window) { 131 if (window == null) { 132 throw new IllegalArgumentException (); 133 } 134 return new ShowViewMenu(window, getId()); 135 } 136 }; 137 138 145 public static final ContributionItemFactory VIEWS_SHOW_IN = new ContributionItemFactory( 146 "viewsShowIn") { 148 public IContributionItem create(IWorkbenchWindow window) { 149 if (window == null) { 150 throw new IllegalArgumentException (); 151 } 152 return new ShowInMenu(window, getId()); 153 } 154 }; 155 156 162 public static final ContributionItemFactory REOPEN_EDITORS = new ContributionItemFactory( 163 "reopenEditors") { 165 public IContributionItem create(IWorkbenchWindow window) { 166 if (window == null) { 167 throw new IllegalArgumentException (); 168 } 169 return new ReopenEditorMenu(window, getId(), true); 170 } 171 }; 172 173 182 public static final ContributionItemFactory PERSPECTIVES_SHORTLIST = new ContributionItemFactory( 183 "perspectivesShortlist") { 185 public IContributionItem create(IWorkbenchWindow window) { 186 if (window == null) { 187 throw new IllegalArgumentException (); 188 } 189 return new ChangeToPerspectiveMenu(window, getId()); 190 } 191 }; 192 193 201 public static final ContributionItemFactory NEW_WIZARD_SHORTLIST = new ContributionItemFactory( 202 "newWizardShortlist") { 204 public IContributionItem create(IWorkbenchWindow window) { 205 if (window == null) { 206 throw new IllegalArgumentException (); 207 } 208 return new BaseNewWizardMenu(window, getId()); 209 } 210 }; 211 212 217 public static final ContributionItemFactory HELP_SEARCH = new ContributionItemFactory( 218 "helpSearch") { public IContributionItem create(IWorkbenchWindow window) { 220 if (window == null) { 221 throw new IllegalArgumentException (); 222 } 223 return new HelpSearchContributionItem(window, getId()); 224 } 225 }; 226 227 228 } 229 | Popular Tags |