KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > emf > codegen > ecore > templates > editor > ActionBarContributor


1 package org.eclipse.emf.codegen.ecore.templates.editor;
2
3 import org.eclipse.emf.codegen.ecore.genmodel.*;
4
5 public class ActionBarContributor
6 {
7   protected static String JavaDoc nl;
8   public static synchronized ActionBarContributor create(String JavaDoc lineSeparator)
9   {
10     nl = lineSeparator;
11     ActionBarContributor result = new ActionBarContributor();
12     nl = null;
13     return result;
14   }
15
16   protected final String JavaDoc NL = nl == null ? (System.getProperties().getProperty("line.separator")) : nl;
17   protected final String JavaDoc TEXT_1 = "";
18   protected final String JavaDoc TEXT_2 = "/**" + NL + " * <copyright>" + NL + " * </copyright>" + NL + " *" + NL + " * ";
19   protected final String JavaDoc TEXT_3 = "Id";
20   protected final String JavaDoc TEXT_4 = NL + " */" + NL + "package ";
21   protected final String JavaDoc TEXT_5 = ";" + NL;
22   protected final String JavaDoc TEXT_6 = NL + NL + "/**" + NL + " * This is the action bar contributor for the ";
23   protected final String JavaDoc TEXT_7 = " model editor." + NL + " * <!-- begin-user-doc -->" + NL + " * <!-- end-user-doc -->" + NL + " * @generated" + NL + " */" + NL + "public class ";
24   protected final String JavaDoc TEXT_8 = NL + "\textends ";
25   protected final String JavaDoc TEXT_9 = NL + "\timplements ";
26   protected final String JavaDoc TEXT_10 = NL + "{";
27   protected final String JavaDoc TEXT_11 = NL + "\t/**" + NL + "\t * <!-- begin-user-doc -->" + NL + "\t * <!-- end-user-doc -->" + NL + "\t * @generated" + NL + "\t */" + NL + "\tpublic static final String copyright = \"";
28   protected final String JavaDoc TEXT_12 = "\";";
29   protected final String JavaDoc TEXT_13 = NL;
30   protected final String JavaDoc TEXT_14 = NL + "\t/**" + NL + "\t * Action to create objects from the ";
31   protected final String JavaDoc TEXT_15 = " model." + NL + "\t * <!-- begin-user-doc -->" + NL + "\t * <!-- end-user-doc -->" + NL + "\t * @generated" + NL + "\t */" + NL + "\tpublic static class NewAction extends ";
32   protected final String JavaDoc TEXT_16 = NL + "\t{" + NL + "\t\t/**" + NL + "\t\t * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction)" + NL + "\t\t * <!-- begin-user-doc -->" + NL + "\t\t * <!-- end-user-doc -->" + NL + "\t\t * @generated" + NL + "\t\t */" + NL + "\t\tpublic void run(";
33   protected final String JavaDoc TEXT_17 = " action)" + NL + "\t\t{" + NL + "\t\t\t";
34   protected final String JavaDoc TEXT_18 = " wizard = new ";
35   protected final String JavaDoc TEXT_19 = "();" + NL + "\t\t\twizard.init(getWindow().getWorkbench(), ";
36   protected final String JavaDoc TEXT_20 = ".EMPTY);" + NL + "\t\t\t";
37   protected final String JavaDoc TEXT_21 = " wizardDialog = new ";
38   protected final String JavaDoc TEXT_22 = "(getWindow().getShell(), wizard);" + NL + "\t\t\twizardDialog.open();" + NL + "\t\t}" + NL + "\t}" + NL;
39   protected final String JavaDoc TEXT_23 = NL + "\t/**" + NL + "\t * This keeps track of the active editor." + NL + "\t * <!-- begin-user-doc -->" + NL + "\t * <!-- end-user-doc -->" + NL + "\t * @generated" + NL + "\t */" + NL + "\tprotected ";
40   protected final String JavaDoc TEXT_24 = " activeEditorPart;" + NL + "" + NL + "\t/**" + NL + "\t * This keeps track of the current selection provider." + NL + "\t * <!-- begin-user-doc -->" + NL + "\t * <!-- end-user-doc -->" + NL + "\t * @generated" + NL + "\t */" + NL + "\tprotected ";
41   protected final String JavaDoc TEXT_25 = " selectionProvider;" + NL + "" + NL + "\t/**" + NL + "\t * This action opens the Properties view." + NL + "\t * <!-- begin-user-doc -->" + NL + "\t * <!-- end-user-doc -->" + NL + "\t * @generated" + NL + "\t */" + NL + "\tprotected ";
42   protected final String JavaDoc TEXT_26 = " showPropertiesViewAction =" + NL + "\t\tnew ";
43   protected final String JavaDoc TEXT_27 = "(";
44   protected final String JavaDoc TEXT_28 = ".INSTANCE.getString(\"_UI_ShowPropertiesView_menu_item\"))";
45   protected final String JavaDoc TEXT_29 = NL + "\t\t{" + NL + "\t\t\tpublic void run()" + NL + "\t\t\t{" + NL + "\t\t\t\ttry" + NL + "\t\t\t\t{" + NL + "\t\t\t\t\tgetPage().showView(\"org.eclipse.ui.views.PropertySheet\");";
46   protected final String JavaDoc TEXT_30 = NL + "\t\t\t\t}" + NL + "\t\t\t\tcatch (";
47   protected final String JavaDoc TEXT_31 = " exception)" + NL + "\t\t\t\t{" + NL + "\t\t\t\t\t";
48   protected final String JavaDoc TEXT_32 = ".INSTANCE.log(exception);" + NL + "\t\t\t\t}" + NL + "\t\t\t}" + NL + "\t\t};" + NL + "" + NL + "\t/**" + NL + "\t * This action refreshes the viewer of the current editor if the editor" + NL + "\t * implements {@link org.eclipse.emf.common.ui.viewer.IViewerProvider}." + NL + "\t * <!-- begin-user-doc -->" + NL + "\t * <!-- end-user-doc -->" + NL + "\t * @generated" + NL + "\t */" + NL + "\tprotected ";
49   protected final String JavaDoc TEXT_33 = " refreshViewerAction =" + NL + "\t\tnew ";
50   protected final String JavaDoc TEXT_34 = "(";
51   protected final String JavaDoc TEXT_35 = ".INSTANCE.getString(\"_UI_RefreshViewer_menu_item\"))";
52   protected final String JavaDoc TEXT_36 = NL + "\t\t{" + NL + "\t\t\tpublic boolean isEnabled()" + NL + "\t\t\t{" + NL + "\t\t\t\treturn activeEditorPart instanceof ";
53   protected final String JavaDoc TEXT_37 = ";" + NL + "\t\t\t}" + NL + "" + NL + "\t\t\tpublic void run()" + NL + "\t\t\t{" + NL + "\t\t\t\tif (activeEditorPart instanceof ";
54   protected final String JavaDoc TEXT_38 = ")" + NL + "\t\t\t\t{" + NL + "\t\t\t\t\t";
55   protected final String JavaDoc TEXT_39 = " viewer = ((";
56   protected final String JavaDoc TEXT_40 = ")activeEditorPart).getViewer();" + NL + "\t\t\t\t\tif (viewer != null)" + NL + "\t\t\t\t\t{" + NL + "\t\t\t\t\t\tviewer.refresh();" + NL + "\t\t\t\t\t}" + NL + "\t\t\t\t}" + NL + "\t\t\t}" + NL + "\t\t};" + NL;
57   protected final String JavaDoc TEXT_41 = NL + "\t/**" + NL + "\t * This will contain one {@link org.eclipse.emf.edit.ui.action.CreateChildAction} corresponding to each descriptor" + NL + "\t * generated for the current selection by the item provider." + NL + "\t * <!-- begin-user-doc -->" + NL + "\t * <!-- end-user-doc -->" + NL + "\t * @generated" + NL + "\t */" + NL + "\tprotected ";
58   protected final String JavaDoc TEXT_42 = " createChildActions;" + NL + "" + NL + "\t/**" + NL + "\t * This is the menu manager into which menu contribution items should be added for CreateChild actions." + NL + "\t * <!-- begin-user-doc -->" + NL + "\t * <!-- end-user-doc -->" + NL + "\t * @generated" + NL + "\t */" + NL + "\tprotected ";
59   protected final String JavaDoc TEXT_43 = " createChildMenuManager;" + NL + "" + NL + "\t/**" + NL + "\t * This will contain one {@link org.eclipse.emf.edit.ui.action.CreateSiblingAction} corresponding to each descriptor" + NL + "\t * generated for the current selection by the item provider." + NL + "\t * <!-- begin-user-doc -->" + NL + "\t * <!-- end-user-doc -->" + NL + "\t * @generated" + NL + "\t */" + NL + "\tprotected ";
60   protected final String JavaDoc TEXT_44 = " createSiblingActions;" + NL + "" + NL + "\t/**" + NL + "\t * This is the menu manager into which menu contribution items should be added for CreateSibling actions." + NL + "\t * <!-- begin-user-doc -->" + NL + "\t * <!-- end-user-doc -->" + NL + "\t * @generated" + NL + "\t */" + NL + "\tprotected ";
61   protected final String JavaDoc TEXT_45 = " createSiblingMenuManager;" + NL;
62   protected final String JavaDoc TEXT_46 = NL + "\t/**" + NL + "\t * This creates an instance of the contributor." + NL + "\t * <!-- begin-user-doc -->" + NL + "\t * <!-- end-user-doc -->" + NL + "\t * @generated" + NL + "\t */" + NL + "\tpublic ";
63   protected final String JavaDoc TEXT_47 = "()" + NL + "\t{" + NL + "\t\tloadResourceAction = new ";
64   protected final String JavaDoc TEXT_48 = "();" + NL + "\t\tvalidateAction = new ";
65   protected final String JavaDoc TEXT_49 = "();" + NL + "\t}" + NL + "" + NL + "\t/**" + NL + "\t * This adds Separators for editor additions to the tool bar." + NL + "\t * <!-- begin-user-doc -->" + NL + "\t * <!-- end-user-doc -->" + NL + "\t * @generated" + NL + "\t */" + NL + "\tpublic void contributeToToolBar(";
66   protected final String JavaDoc TEXT_50 = " toolBarManager)" + NL + "\t{" + NL + "\t\ttoolBarManager.add(new ";
67   protected final String JavaDoc TEXT_51 = "(\"";
68   protected final String JavaDoc TEXT_52 = "-settings\"));";
69   protected final String JavaDoc TEXT_53 = NL + "\t\ttoolBarManager.add(new ";
70   protected final String JavaDoc TEXT_54 = "(\"";
71   protected final String JavaDoc TEXT_55 = "-additions\"));";
72   protected final String JavaDoc TEXT_56 = NL + "\t}" + NL + "" + NL + "\t/**" + NL + "\t * This adds to the menu bar a menu and some separators for editor additions," + NL + "\t * as well as the sub-menus for object creation items." + NL + "\t * <!-- begin-user-doc -->" + NL + "\t * <!-- end-user-doc -->" + NL + "\t * @generated" + NL + "\t */" + NL + "\tpublic void contributeToMenu(";
73   protected final String JavaDoc TEXT_57 = " menuManager)" + NL + "\t{" + NL + "\t\tsuper.contributeToMenu(menuManager);" + NL + "" + NL + "\t\t";
74   protected final String JavaDoc TEXT_58 = " submenuManager = new ";
75   protected final String JavaDoc TEXT_59 = "(";
76   protected final String JavaDoc TEXT_60 = ".INSTANCE.getString(\"_UI_";
77   protected final String JavaDoc TEXT_61 = "_menu\"), \"";
78   protected final String JavaDoc TEXT_62 = "MenuID\");";
79   protected final String JavaDoc TEXT_63 = NL + "\t\tmenuManager.insertAfter(\"additions\", submenuManager);";
80   protected final String JavaDoc TEXT_64 = NL + "\t\tsubmenuManager.add(new ";
81   protected final String JavaDoc TEXT_65 = "(\"settings\"));";
82   protected final String JavaDoc TEXT_66 = NL + "\t\tsubmenuManager.add(new ";
83   protected final String JavaDoc TEXT_67 = "(\"actions\"));";
84   protected final String JavaDoc TEXT_68 = NL + "\t\tsubmenuManager.add(new ";
85   protected final String JavaDoc TEXT_69 = "(\"additions\"));";
86   protected final String JavaDoc TEXT_70 = NL + "\t\tsubmenuManager.add(new ";
87   protected final String JavaDoc TEXT_71 = "(\"additions-end\"));";
88   protected final String JavaDoc TEXT_72 = NL;
89   protected final String JavaDoc TEXT_73 = NL + "\t\t// Prepare for CreateChild item addition or removal." + NL + "\t\t//" + NL + "\t\tcreateChildMenuManager = new ";
90   protected final String JavaDoc TEXT_74 = "(";
91   protected final String JavaDoc TEXT_75 = ".INSTANCE.getString(\"_UI_CreateChild_menu_item\"));";
92   protected final String JavaDoc TEXT_76 = NL + "\t\tsubmenuManager.insertBefore(\"additions\", createChildMenuManager);";
93   protected final String JavaDoc TEXT_77 = NL + NL + "\t\t// Prepare for CreateSibling item addition or removal." + NL + "\t\t//" + NL + "\t\tcreateSiblingMenuManager = new ";
94   protected final String JavaDoc TEXT_78 = "(";
95   protected final String JavaDoc TEXT_79 = ".INSTANCE.getString(\"_UI_CreateSibling_menu_item\"));";
96   protected final String JavaDoc TEXT_80 = NL + "\t\tsubmenuManager.insertBefore(\"additions\", createSiblingMenuManager);";
97   protected final String JavaDoc TEXT_81 = NL + NL + "\t\t// Force an update because Eclipse hides empty menus now." + NL + "\t\t//" + NL + "\t\tsubmenuManager.addMenuListener" + NL + "\t\t\t(new ";
98   protected final String JavaDoc TEXT_82 = "()" + NL + "\t\t\t {" + NL + "\t\t\t\t public void menuAboutToShow(";
99   protected final String JavaDoc TEXT_83 = " menuManager)" + NL + "\t\t\t\t {" + NL + "\t\t\t\t\t menuManager.updateAll(true);" + NL + "\t\t\t\t }" + NL + "\t\t\t });" + NL;
100   protected final String JavaDoc TEXT_84 = NL + "\t\t// Add your contributions." + NL + "\t\t// Ensure that you remove @generated or mark it @generated NOT" + NL;
101   protected final String JavaDoc TEXT_85 = NL + "\t\taddGlobalActions(submenuManager);" + NL + "\t}" + NL + "" + NL + "\t/**" + NL + "\t * When the active editor changes, this remembers the change and registers with it as a selection provider." + NL + "\t * <!-- begin-user-doc -->" + NL + "\t * <!-- end-user-doc -->" + NL + "\t * @generated" + NL + "\t */" + NL + "\tpublic void setActiveEditor(";
102   protected final String JavaDoc TEXT_86 = " part)" + NL + "\t{" + NL + "\t\tsuper.setActiveEditor(part);" + NL + "\t\tactiveEditorPart = part;" + NL + "" + NL + "\t\t// Switch to the new selection provider." + NL + "\t\t//" + NL + "\t\tif (selectionProvider != null)" + NL + "\t\t{" + NL + "\t\t\tselectionProvider.removeSelectionChangedListener(this);" + NL + "\t\t}" + NL + "\t\tif (part == null)" + NL + "\t\t{" + NL + "\t\t\tselectionProvider = null;" + NL + "\t\t}" + NL + "\t\telse" + NL + "\t\t{" + NL + "\t\t\tselectionProvider = part.getSite().getSelectionProvider();" + NL + "\t\t\tselectionProvider.addSelectionChangedListener(this);" + NL + "" + NL + "\t\t\t// Fake a selection changed event to update the menus." + NL + "\t\t\t//" + NL + "\t\t\tif (selectionProvider.getSelection() != null)" + NL + "\t\t\t{" + NL + "\t\t\t\tselectionChanged(new ";
103   protected final String JavaDoc TEXT_87 = "(selectionProvider, selectionProvider.getSelection()));" + NL + "\t\t\t}" + NL + "\t\t}" + NL + "\t}" + NL + "" + NL + "\t/**" + NL + "\t * This implements {@link org.eclipse.jface.viewers.ISelectionChangedListener}," + NL + "\t * handling {@link org.eclipse.jface.viewers.SelectionChangedEvent}s by querying for the children and siblings" + NL + "\t * that can be added to the selected object and updating the menus accordingly." + NL + "\t * <!-- begin-user-doc -->" + NL + "\t * <!-- end-user-doc -->" + NL + "\t * @generated" + NL + "\t */" + NL + "\tpublic void selectionChanged(";
104   protected final String JavaDoc TEXT_88 = " event)" + NL + "\t{";
105   protected final String JavaDoc TEXT_89 = NL + "\t\t// Remove any menu items for old selection." + NL + "\t\t//" + NL + "\t\tif (createChildMenuManager != null)" + NL + "\t\t{" + NL + "\t\t\tdepopulateManager(createChildMenuManager, createChildActions);" + NL + "\t\t}" + NL + "\t\tif (createSiblingMenuManager != null)" + NL + "\t\t{" + NL + "\t\t\tdepopulateManager(createSiblingMenuManager, createSiblingActions);" + NL + "\t\t}" + NL + "" + NL + "\t\t// Query the new selection for appropriate new child/sibling descriptors" + NL + "\t\t//" + NL + "\t\t";
106   protected final String JavaDoc TEXT_90 = " newChildDescriptors = null;" + NL + "\t\t";
107   protected final String JavaDoc TEXT_91 = " newSiblingDescriptors = null;" + NL + "" + NL + "\t\t";
108   protected final String JavaDoc TEXT_92 = " selection = event.getSelection();" + NL + "\t\tif (selection instanceof ";
109   protected final String JavaDoc TEXT_93 = " && ((IStructuredSelection)selection).size() == 1)" + NL + "\t\t{" + NL + "\t\t\tObject object = ((";
110   protected final String JavaDoc TEXT_94 = ")selection).getFirstElement();" + NL + "" + NL + "\t\t\t";
111   protected final String JavaDoc TEXT_95 = " domain = ((";
112   protected final String JavaDoc TEXT_96 = ")activeEditorPart).getEditingDomain();" + NL + "" + NL + "\t\t\tnewChildDescriptors = domain.getNewChildDescriptors(object, null);" + NL + "\t\t\tnewSiblingDescriptors = domain.getNewChildDescriptors(null, object);" + NL + "\t\t}" + NL + "" + NL + "\t\t// Generate actions for selection; populate and redraw the menus." + NL + "\t\t//" + NL + "\t\tcreateChildActions = generateCreateChildActions(newChildDescriptors, selection);" + NL + "\t\tcreateSiblingActions = generateCreateSiblingActions(newSiblingDescriptors, selection);" + NL + "" + NL + "\t\tif (createChildMenuManager != null)" + NL + "\t\t{" + NL + "\t\t\tpopulateManager(createChildMenuManager, createChildActions, null);" + NL + "\t\t\tcreateChildMenuManager.update(true);" + NL + "\t\t}" + NL + "\t\tif (createSiblingMenuManager != null)" + NL + "\t\t{" + NL + "\t\t\tpopulateManager(createSiblingMenuManager, createSiblingActions, null);" + NL + "\t\t\tcreateSiblingMenuManager.update(true);" + NL + "\t\t}";
113   protected final String JavaDoc TEXT_97 = NL + "\t\t// Add your contributions." + NL + "\t\t// Ensure that you remove @generated or mark it @generated NOT";
114   protected final String JavaDoc TEXT_98 = NL + "\t}" + NL;
115   protected final String JavaDoc TEXT_99 = NL + "\t/**" + NL + "\t * This generates a {@link org.eclipse.emf.edit.ui.action.CreateChildAction} for each object in <code>descriptors</code>," + NL + "\t * and returns the collection of these actions." + NL + "\t * <!-- begin-user-doc -->" + NL + "\t * <!-- end-user-doc -->" + NL + "\t * @generated" + NL + "\t */" + NL + "\tprotected ";
116   protected final String JavaDoc TEXT_100 = " generateCreateChildActions(Collection descriptors, ";
117   protected final String JavaDoc TEXT_101 = " selection)" + NL + "\t{" + NL + "\t\t";
118   protected final String JavaDoc TEXT_102 = " actions = new ";
119   protected final String JavaDoc TEXT_103 = "();" + NL + "\t\tif (descriptors != null)" + NL + "\t\t{" + NL + "\t\t\tfor (";
120   protected final String JavaDoc TEXT_104 = " i = descriptors.iterator(); i.hasNext(); )" + NL + "\t\t\t{" + NL + "\t\t\t\tactions.add(new ";
121   protected final String JavaDoc TEXT_105 = "(activeEditorPart, selection, i.next()));" + NL + "\t\t\t}" + NL + "\t\t}" + NL + "\t\treturn actions;" + NL + "\t}" + NL + "" + NL + "\t/**" + NL + "\t * This generates a {@link org.eclipse.emf.edit.ui.action.CreateSiblingAction} for each object in <code>descriptors</code>," + NL + "\t * and returns the collection of these actions." + NL + "\t * <!-- begin-user-doc -->" + NL + "\t * <!-- end-user-doc -->" + NL + "\t * @generated" + NL + "\t */" + NL + "\tprotected ";
122   protected final String JavaDoc TEXT_106 = " generateCreateSiblingActions(Collection descriptors, ";
123   protected final String JavaDoc TEXT_107 = " selection)" + NL + "\t{" + NL + "\t\t";
124   protected final String JavaDoc TEXT_108 = " actions = new ";
125   protected final String JavaDoc TEXT_109 = "();" + NL + "\t\tif (descriptors != null)" + NL + "\t\t{" + NL + "\t\t\tfor (";
126   protected final String JavaDoc TEXT_110 = " i = descriptors.iterator(); i.hasNext(); )" + NL + "\t\t\t{" + NL + "\t\t\t\tactions.add(new ";
127   protected final String JavaDoc TEXT_111 = "(activeEditorPart, selection, i.next()));" + NL + "\t\t\t}" + NL + "\t\t}" + NL + "\t\treturn actions;" + NL + "\t}" + NL + "" + NL + "\t/**" + NL + "\t * This populates the specified <code>manager</code> with {@link org.eclipse.jface.action.ActionContributionItem}s" + NL + "\t * based on the {@link org.eclipse.jface.action.IAction}s contained in the <code>actions</code> collection," + NL + "\t * by inserting them before the specified contribution item <code>contributionID</code>." + NL + "\t * If <code>ID</code> is <code>null</code>, they are simply added." + NL + "\t * <!-- begin-user-doc -->" + NL + "\t * <!-- end-user-doc -->" + NL + "\t * @generated" + NL + "\t */" + NL + "\tprotected void populateManager(";
128   protected final String JavaDoc TEXT_112 = " manager, ";
129   protected final String JavaDoc TEXT_113 = " actions, String contributionID)" + NL + "\t{" + NL + "\t\tif (actions != null)" + NL + "\t\t{" + NL + "\t\t\tfor (";
130   protected final String JavaDoc TEXT_114 = " i = actions.iterator(); i.hasNext(); )" + NL + "\t\t\t{" + NL + "\t\t\t\t";
131   protected final String JavaDoc TEXT_115 = " action = (IAction)i.next();" + NL + "\t\t\t\tif (contributionID != null)" + NL + "\t\t\t\t{" + NL + "\t\t\t\t\tmanager.insertBefore(contributionID, action);" + NL + "\t\t\t\t}" + NL + "\t\t\t\telse" + NL + "\t\t\t\t{" + NL + "\t\t\t\t\tmanager.add(action);" + NL + "\t\t\t\t}" + NL + "\t\t\t}" + NL + "\t\t}" + NL + "\t}" + NL + "\t\t" + NL + "\t/**" + NL + "\t * This removes from the specified <code>manager</code> all {@link org.eclipse.jface.action.ActionContributionItem}s" + NL + "\t * based on the {@link org.eclipse.jface.action.IAction}s contained in the <code>actions</code> collection." + NL + "\t * <!-- begin-user-doc -->" + NL + "\t * <!-- end-user-doc -->" + NL + "\t * @generated" + NL + "\t */" + NL + "\tprotected void depopulateManager(";
132   protected final String JavaDoc TEXT_116 = " manager, ";
133   protected final String JavaDoc TEXT_117 = " actions)" + NL + "\t{" + NL + "\t\tif (actions != null)" + NL + "\t\t{" + NL + "\t\t\t";
134   protected final String JavaDoc TEXT_118 = "[] items = manager.getItems();" + NL + "\t\t\tfor (int i = 0; i < items.length; i++)" + NL + "\t\t\t{" + NL + "\t\t\t\t// Look into SubContributionItems" + NL + "\t\t\t\t//" + NL + "\t\t\t\t";
135   protected final String JavaDoc TEXT_119 = " contributionItem = items[i];" + NL + "\t\t\t\twhile (contributionItem instanceof ";
136   protected final String JavaDoc TEXT_120 = ")" + NL + "\t\t\t\t{" + NL + "\t\t\t\t\tcontributionItem = ((";
137   protected final String JavaDoc TEXT_121 = ")contributionItem).getInnerItem();" + NL + "\t\t\t\t}" + NL + "" + NL + "\t\t\t\t// Delete the ActionContributionItems with matching action." + NL + "\t\t\t\t//" + NL + "\t\t\t\tif (contributionItem instanceof ";
138   protected final String JavaDoc TEXT_122 = ")" + NL + "\t\t\t\t{" + NL + "\t\t\t\t\t";
139   protected final String JavaDoc TEXT_123 = " action = ((";
140   protected final String JavaDoc TEXT_124 = ")contributionItem).getAction();" + NL + "\t\t\t\t\tif (actions.contains(action))" + NL + "\t\t\t\t\t{" + NL + "\t\t\t\t\t\tmanager.remove(contributionItem);" + NL + "\t\t\t\t\t}" + NL + "\t\t\t\t}" + NL + "\t\t\t}" + NL + "\t\t}" + NL + "\t}" + NL;
141   protected final String JavaDoc TEXT_125 = NL + "\t/**" + NL + "\t * This populates the pop-up menu before it appears." + NL + "\t * <!-- begin-user-doc -->" + NL + "\t * <!-- end-user-doc -->" + NL + "\t * @generated" + NL + "\t */" + NL + "\tpublic void menuAboutToShow(";
142   protected final String JavaDoc TEXT_126 = " menuManager)" + NL + "\t{" + NL + "\t\tsuper.menuAboutToShow(menuManager);";
143   protected final String JavaDoc TEXT_127 = NL + "\t\t";
144   protected final String JavaDoc TEXT_128 = " submenuManager = null;" + NL + "" + NL + "\t\tsubmenuManager = new ";
145   protected final String JavaDoc TEXT_129 = "(";
146   protected final String JavaDoc TEXT_130 = ".INSTANCE.getString(\"_UI_CreateChild_menu_item\"));";
147   protected final String JavaDoc TEXT_131 = NL + "\t\tpopulateManager(submenuManager, createChildActions, null);" + NL + "\t\tmenuManager.insertBefore(\"additions\", submenuManager);";
148   protected final String JavaDoc TEXT_132 = NL + NL + "\t\tsubmenuManager = new ";
149   protected final String JavaDoc TEXT_133 = "(";
150   protected final String JavaDoc TEXT_134 = ".INSTANCE.getString(\"_UI_CreateSibling_menu_item\"));";
151   protected final String JavaDoc TEXT_135 = NL + "\t\tpopulateManager(submenuManager, createSiblingActions, null);" + NL + "\t\tmenuManager.insertBefore(\"additions\", submenuManager);";
152   protected final String JavaDoc TEXT_136 = NL + "\t}" + NL + "" + NL + "\t/**" + NL + "\t * This inserts global actions before the \"additions-end\" separator." + NL + "\t * <!-- begin-user-doc -->" + NL + "\t * <!-- end-user-doc -->" + NL + "\t * @generated" + NL + "\t */" + NL + "\tprotected void addGlobalActions(";
153   protected final String JavaDoc TEXT_137 = " menuManager)" + NL + "\t{" + NL + "\t\tmenuManager.insertAfter(\"additions-end\", new ";
154   protected final String JavaDoc TEXT_138 = "(\"ui-actions\"));";
155   protected final String JavaDoc TEXT_139 = NL + "\t\tmenuManager.insertAfter(\"ui-actions\", showPropertiesViewAction);";
156   protected final String JavaDoc TEXT_140 = NL + NL + "\t\trefreshViewerAction.setEnabled(refreshViewerAction.isEnabled());\t\t" + NL + "\t\tmenuManager.insertAfter(\"ui-actions\", refreshViewerAction);";
157   protected final String JavaDoc TEXT_141 = NL + NL + "\t\tsuper.addGlobalActions(menuManager);" + NL + "\t}" + NL + "" + NL + "}";
158   protected final String JavaDoc TEXT_142 = NL;
159
160   public String JavaDoc generate(Object JavaDoc argument)
161   {
162     StringBuffer JavaDoc stringBuffer = new StringBuffer JavaDoc();
163     
164 /**
165  * <copyright>
166  *
167  * Copyright (c) 2002-2005 IBM Corporation and others.
168  * All rights reserved. This program and the accompanying materials
169  * are made available under the terms of the Eclipse Public License v1.0
170  * which accompanies this distribution, and is available at
171  * http://www.eclipse.org/legal/epl-v10.html
172  *
173  * Contributors:
174  * IBM - Initial API and implementation
175  *
176  * </copyright>
177  */

178
179     GenPackage genPackage = (GenPackage)argument; GenModel genModel=genPackage.getGenModel();
180     stringBuffer.append(TEXT_1);
181     stringBuffer.append(TEXT_2);
182     stringBuffer.append("$");
183     stringBuffer.append(TEXT_3);
184     stringBuffer.append("$");
185     stringBuffer.append(TEXT_4);
186     stringBuffer.append(genPackage.getPresentationPackageName());
187     stringBuffer.append(TEXT_5);
188     genModel.markImportLocation(stringBuffer);
189     stringBuffer.append(TEXT_6);
190     stringBuffer.append(genPackage.getPrefix());
191     stringBuffer.append(TEXT_7);
192     stringBuffer.append(genPackage.getActionBarContributorClassName());
193     stringBuffer.append(TEXT_8);
194     stringBuffer.append(genModel.getImportedName("org.eclipse.emf.edit.ui.action.EditingDomainActionBarContributor"));
195     stringBuffer.append(TEXT_9);
196     stringBuffer.append(genModel.getImportedName("org.eclipse.jface.viewers.ISelectionChangedListener"));
197     stringBuffer.append(TEXT_10);
198     if (genModel.getCopyrightText() != null) {
199     stringBuffer.append(TEXT_11);
200     stringBuffer.append(genModel.getCopyrightText());
201     stringBuffer.append(TEXT_12);
202     stringBuffer.append(genModel.getNonNLS());
203     stringBuffer.append(TEXT_13);
204     }
205     if (genModel.isRichClientPlatform()) {
206     stringBuffer.append(TEXT_14);
207     stringBuffer.append(genPackage.getPrefix());
208     stringBuffer.append(TEXT_15);
209     stringBuffer.append(genModel.getImportedName("org.eclipse.emf.common.ui.action.WorkbenchWindowActionDelegate"));
210     stringBuffer.append(TEXT_16);
211     stringBuffer.append(genModel.getImportedName("org.eclipse.jface.action.IAction"));
212     stringBuffer.append(TEXT_17);
213     stringBuffer.append(genPackage.getModelWizardClassName());
214     stringBuffer.append(TEXT_18);
215     stringBuffer.append(genPackage.getModelWizardClassName());
216     stringBuffer.append(TEXT_19);
217     stringBuffer.append(genModel.getImportedName("org.eclipse.jface.viewers.StructuredSelection"));
218     stringBuffer.append(TEXT_20);
219     stringBuffer.append(genModel.getImportedName("org.eclipse.jface.wizard.WizardDialog"));
220     stringBuffer.append(TEXT_21);
221     stringBuffer.append(genModel.getImportedName("org.eclipse.jface.wizard.WizardDialog"));
222     stringBuffer.append(TEXT_22);
223     }
224     stringBuffer.append(TEXT_23);
225     stringBuffer.append(genModel.getImportedName("org.eclipse.ui.IEditorPart"));
226     stringBuffer.append(TEXT_24);
227     stringBuffer.append(genModel.getImportedName("org.eclipse.jface.viewers.ISelectionProvider"));
228     stringBuffer.append(TEXT_25);
229     stringBuffer.append(genModel.getImportedName("org.eclipse.jface.action.IAction"));
230     stringBuffer.append(TEXT_26);
231     stringBuffer.append(genModel.getImportedName("org.eclipse.jface.action.Action"));
232     stringBuffer.append(TEXT_27);
233     stringBuffer.append(genPackage.getImportedEditorPluginClassName());
234     stringBuffer.append(TEXT_28);
235     stringBuffer.append(genModel.getNonNLS());
236     stringBuffer.append(TEXT_29);
237     stringBuffer.append(genModel.getNonNLS());
238     stringBuffer.append(TEXT_30);
239     stringBuffer.append(genModel.getImportedName("org.eclipse.ui.PartInitException"));
240     stringBuffer.append(TEXT_31);
241     stringBuffer.append(genPackage.getImportedEditorPluginClassName());
242     stringBuffer.append(TEXT_32);
243     stringBuffer.append(genModel.getImportedName("org.eclipse.jface.action.IAction"));
244     stringBuffer.append(TEXT_33);
245     stringBuffer.append(genModel.getImportedName("org.eclipse.jface.action.Action"));
246     stringBuffer.append(TEXT_34);
247     stringBuffer.append(genPackage.getImportedEditorPluginClassName());
248     stringBuffer.append(TEXT_35);
249     stringBuffer.append(genModel.getNonNLS());
250     stringBuffer.append(TEXT_36);
251     stringBuffer.append(genModel.getImportedName("org.eclipse.emf.common.ui.viewer.IViewerProvider"));
252     stringBuffer.append(TEXT_37);
253     stringBuffer.append(genModel.getImportedName("org.eclipse.emf.common.ui.viewer.IViewerProvider"));
254     stringBuffer.append(TEXT_38);
255     stringBuffer.append(genModel.getImportedName("org.eclipse.jface.viewers.Viewer"));
256     stringBuffer.append(TEXT_39);
257     stringBuffer.append(genModel.getImportedName("org.eclipse.emf.common.ui.viewer.IViewerProvider"));
258     stringBuffer.append(TEXT_40);
259     if (genModel.isCreationCommands()) {
260     stringBuffer.append(TEXT_41);
261     stringBuffer.append(genModel.getImportedName("java.util.Collection"));
262     stringBuffer.append(TEXT_42);
263     stringBuffer.append(genModel.getImportedName("org.eclipse.jface.action.IMenuManager"));
264     stringBuffer.append(TEXT_43);
265     stringBuffer.append(genModel.getImportedName("java.util.Collection"));
266     stringBuffer.append(TEXT_44);
267     stringBuffer.append(genModel.getImportedName("org.eclipse.jface.action.IMenuManager"));
268     stringBuffer.append(TEXT_45);
269     }
270     stringBuffer.append(TEXT_46);
271     stringBuffer.append(genPackage.getActionBarContributorClassName());
272     stringBuffer.append(TEXT_47);
273     stringBuffer.append(genModel.getImportedName("org.eclipse.emf.edit.ui.action.LoadResourceAction"));
274     stringBuffer.append(TEXT_48);
275     stringBuffer.append(genModel.getImportedName("org.eclipse.emf.edit.ui.action.ValidateAction"));
276     stringBuffer.append(TEXT_49);
277     stringBuffer.append(genModel.getImportedName("org.eclipse.jface.action.IToolBarManager"));
278     stringBuffer.append(TEXT_50);
279     stringBuffer.append(genModel.getImportedName("org.eclipse.jface.action.Separator"));
280     stringBuffer.append(TEXT_51);
281     stringBuffer.append(genPackage.getPrefix().toLowerCase());
282     stringBuffer.append(TEXT_52);
283     stringBuffer.append(genModel.getNonNLS());
284     stringBuffer.append(TEXT_53);
285     stringBuffer.append(genModel.getImportedName("org.eclipse.jface.action.Separator"));
286     stringBuffer.append(TEXT_54);
287     stringBuffer.append(genPackage.getPrefix().toLowerCase());
288     stringBuffer.append(TEXT_55);
289     stringBuffer.append(genModel.getNonNLS());
290     stringBuffer.append(TEXT_56);
291     stringBuffer.append(genModel.getImportedName("org.eclipse.jface.action.IMenuManager"));
292     stringBuffer.append(TEXT_57);
293     stringBuffer.append(genModel.getImportedName("org.eclipse.jface.action.IMenuManager"));
294     stringBuffer.append(TEXT_58);
295     stringBuffer.append(genModel.getImportedName("org.eclipse.jface.action.MenuManager"));
296     stringBuffer.append(TEXT_59);
297     stringBuffer.append(genPackage.getImportedEditorPluginClassName());
298     stringBuffer.append(TEXT_60);
299     stringBuffer.append(genPackage.getEditorClassName());
300     stringBuffer.append(TEXT_61);
301     stringBuffer.append(genPackage.getInterfacePackageName());
302     stringBuffer.append(TEXT_62);
303     stringBuffer.append(genModel.getNonNLS());
304     stringBuffer.append(genModel.getNonNLS(2));
305     stringBuffer.append(TEXT_63);
306     stringBuffer.append(genModel.getNonNLS());
307     stringBuffer.append(TEXT_64);
308     stringBuffer.append(genModel.getImportedName("org.eclipse.jface.action.Separator"));
309     stringBuffer.append(TEXT_65);
310     stringBuffer.append(genModel.getNonNLS());
311     stringBuffer.append(TEXT_66);
312     stringBuffer.append(genModel.getImportedName("org.eclipse.jface.action.Separator"));
313     stringBuffer.append(TEXT_67);
314     stringBuffer.append(genModel.getNonNLS());
315     stringBuffer.append(TEXT_68);
316     stringBuffer.append(genModel.getImportedName("org.eclipse.jface.action.Separator"));
317     stringBuffer.append(TEXT_69);
318     stringBuffer.append(genModel.getNonNLS());
319     stringBuffer.append(TEXT_70);
320     stringBuffer.append(genModel.getImportedName("org.eclipse.jface.action.Separator"));
321     stringBuffer.append(TEXT_71);
322     stringBuffer.append(genModel.getNonNLS());
323     stringBuffer.append(TEXT_72);
324     if (genModel.isCreationCommands()) {
325     stringBuffer.append(TEXT_73);
326     stringBuffer.append(genModel.getImportedName("org.eclipse.jface.action.MenuManager"));
327     stringBuffer.append(TEXT_74);
328     stringBuffer.append(genPackage.getImportedEditorPluginClassName());
329     stringBuffer.append(TEXT_75);
330     stringBuffer.append(genModel.getNonNLS());
331     stringBuffer.append(TEXT_76);
332     stringBuffer.append(genModel.getNonNLS());
333     stringBuffer.append(TEXT_77);
334     stringBuffer.append(genModel.getImportedName("org.eclipse.jface.action.MenuManager"));
335     stringBuffer.append(TEXT_78);
336     stringBuffer.append(genPackage.getImportedEditorPluginClassName());
337     stringBuffer.append(TEXT_79);
338     stringBuffer.append(genModel.getNonNLS());
339     stringBuffer.append(TEXT_80);
340     stringBuffer.append(genModel.getNonNLS());
341     stringBuffer.append(TEXT_81);
342     stringBuffer.append(genModel.getImportedName("org.eclipse.jface.action.IMenuListener"));
343     stringBuffer.append(TEXT_82);
344     stringBuffer.append(genModel.getImportedName("org.eclipse.jface.action.IMenuManager"));
345     stringBuffer.append(TEXT_83);
346     } else {
347     stringBuffer.append(TEXT_84);
348     }
349     stringBuffer.append(TEXT_85);
350     stringBuffer.append(genModel.getImportedName("org.eclipse.ui.IEditorPart"));
351     stringBuffer.append(TEXT_86);
352     stringBuffer.append(genModel.getImportedName("org.eclipse.jface.viewers.SelectionChangedEvent"));
353     stringBuffer.append(TEXT_87);
354     stringBuffer.append(genModel.getImportedName("org.eclipse.jface.viewers.SelectionChangedEvent"));
355     stringBuffer.append(TEXT_88);
356     if (genModel.isCreationCommands()) {
357     stringBuffer.append(TEXT_89);
358     stringBuffer.append(genModel.getImportedName("java.util.Collection"));
359     stringBuffer.append(TEXT_90);
360     stringBuffer.append(genModel.getImportedName("java.util.Collection"));
361     stringBuffer.append(TEXT_91);
362     stringBuffer.append(genModel.getImportedName("org.eclipse.jface.viewers.ISelection"));
363     stringBuffer.append(TEXT_92);
364     stringBuffer.append(genModel.getImportedName("org.eclipse.jface.viewers.IStructuredSelection"));
365     stringBuffer.append(TEXT_93);
366     stringBuffer.append(genModel.getImportedName("org.eclipse.jface.viewers.IStructuredSelection"));
367     stringBuffer.append(TEXT_94);
368     stringBuffer.append(genModel.getImportedName("org.eclipse.emf.edit.domain.EditingDomain"));
369     stringBuffer.append(TEXT_95);
370     stringBuffer.append(genModel.getImportedName("org.eclipse.emf.edit.domain.IEditingDomainProvider"));
371     stringBuffer.append(TEXT_96);
372     } else {
373     stringBuffer.append(TEXT_97);
374     }
375     stringBuffer.append(TEXT_98);
376     if (genModel.isCreationCommands()) {
377     stringBuffer.append(TEXT_99);
378     stringBuffer.append(genModel.getImportedName("java.util.Collection"));
379     stringBuffer.append(TEXT_100);
380     stringBuffer.append(genModel.getImportedName("org.eclipse.jface.viewers.ISelection"));
381     stringBuffer.append(TEXT_101);
382     stringBuffer.append(genModel.getImportedName("java.util.Collection"));
383     stringBuffer.append(TEXT_102);
384     stringBuffer.append(genModel.getImportedName("java.util.ArrayList"));
385     stringBuffer.append(TEXT_103);
386     stringBuffer.append(genModel.getImportedName("java.util.Iterator"));
387     stringBuffer.append(TEXT_104);
388     stringBuffer.append(genModel.getImportedName("org.eclipse.emf.edit.ui.action.CreateChildAction"));
389     stringBuffer.append(TEXT_105);
390     stringBuffer.append(genModel.getImportedName("java.util.Collection"));
391     stringBuffer.append(TEXT_106);
392     stringBuffer.append(genModel.getImportedName("org.eclipse.jface.viewers.ISelection"));
393     stringBuffer.append(TEXT_107);
394     stringBuffer.append(genModel.getImportedName("java.util.Collection"));
395     stringBuffer.append(TEXT_108);
396     stringBuffer.append(genModel.getImportedName("java.util.ArrayList"));
397     stringBuffer.append(TEXT_109);
398     stringBuffer.append(genModel.getImportedName("java.util.Iterator"));
399     stringBuffer.append(TEXT_110);
400     stringBuffer.append(genModel.getImportedName("org.eclipse.emf.edit.ui.action.CreateSiblingAction"));
401     stringBuffer.append(TEXT_111);
402     stringBuffer.append(genModel.getImportedName("org.eclipse.jface.action.IContributionManager"));
403     stringBuffer.append(TEXT_112);
404     stringBuffer.append(genModel.getImportedName("java.util.Collection"));
405     stringBuffer.append(TEXT_113);
406     stringBuffer.append(genModel.getImportedName("java.util.Iterator"));
407     stringBuffer.append(TEXT_114);
408     stringBuffer.append(genModel.getImportedName("org.eclipse.jface.action.IAction"));
409     stringBuffer.append(TEXT_115);
410     stringBuffer.append(genModel.getImportedName("org.eclipse.jface.action.IContributionManager"));
411     stringBuffer.append(TEXT_116);
412     stringBuffer.append(genModel.getImportedName("java.util.Collection"));
413     stringBuffer.append(TEXT_117);
414     stringBuffer.append(genModel.getImportedName("org.eclipse.jface.action.IContributionItem"));
415     stringBuffer.append(TEXT_118);
416     stringBuffer.append(genModel.getImportedName("org.eclipse.jface.action.IContributionItem"));
417     stringBuffer.append(TEXT_119);
418     stringBuffer.append(genModel.getImportedName("org.eclipse.jface.action.SubContributionItem"));
419     stringBuffer.append(TEXT_120);
420     stringBuffer.append(genModel.getImportedName("org.eclipse.jface.action.SubContributionItem"));
421     stringBuffer.append(TEXT_121);
422     stringBuffer.append(genModel.getImportedName("org.eclipse.jface.action.ActionContributionItem"));
423     stringBuffer.append(TEXT_122);
424     stringBuffer.append(genModel.getImportedName("org.eclipse.jface.action.IAction"));
425     stringBuffer.append(TEXT_123);
426     stringBuffer.append(genModel.getImportedName("org.eclipse.jface.action.ActionContributionItem"));
427     stringBuffer.append(TEXT_124);
428     }
429     stringBuffer.append(TEXT_125);
430     stringBuffer.append(genModel.getImportedName("org.eclipse.jface.action.IMenuManager"));
431     stringBuffer.append(TEXT_126);
432     if (genModel.isCreationCommands()) {
433     stringBuffer.append(TEXT_127);
434     stringBuffer.append(genModel.getImportedName("org.eclipse.jface.action.MenuManager"));
435     stringBuffer.append(TEXT_128);
436     stringBuffer.append(genModel.getImportedName("org.eclipse.jface.action.MenuManager"));
437     stringBuffer.append(TEXT_129);
438     stringBuffer.append(genPackage.getImportedEditorPluginClassName());
439     stringBuffer.append(TEXT_130);
440     stringBuffer.append(genModel.getNonNLS());
441     stringBuffer.append(TEXT_131);
442     stringBuffer.append(genModel.getNonNLS());
443     stringBuffer.append(TEXT_132);
444     stringBuffer.append(genModel.getImportedName("org.eclipse.jface.action.MenuManager"));
445     stringBuffer.append(TEXT_133);
446     stringBuffer.append(genPackage.getImportedEditorPluginClassName());
447     stringBuffer.append(TEXT_134);
448     stringBuffer.append(genModel.getNonNLS());
449     stringBuffer.append(TEXT_135);
450     stringBuffer.append(genModel.getNonNLS());
451     }
452     stringBuffer.append(TEXT_136);
453     stringBuffer.append(genModel.getImportedName("org.eclipse.jface.action.IMenuManager"));
454     stringBuffer.append(TEXT_137);
455     stringBuffer.append(genModel.getImportedName("org.eclipse.jface.action.Separator"));
456     stringBuffer.append(TEXT_138);
457     stringBuffer.append(genModel.getNonNLS());
458     stringBuffer.append(genModel.getNonNLS(2));
459     stringBuffer.append(TEXT_139);
460     stringBuffer.append(genModel.getNonNLS());
461     stringBuffer.append(TEXT_140);
462     stringBuffer.append(genModel.getNonNLS());
463     stringBuffer.append(TEXT_141);
464     genModel.emitSortedImports();
465     stringBuffer.append(TEXT_142);
466     return stringBuffer.toString();
467   }
468 }
469
Popular Tags