KickJava   Java API By Example, From Geeks To Geeks.

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


1 package org.eclipse.emf.codegen.ecore.templates.editor;
2
3 import java.util.*;
4 import org.eclipse.emf.codegen.ecore.genmodel.*;
5
6 public class PluginXML
7 {
8   protected static String JavaDoc nl;
9   public static synchronized PluginXML create(String JavaDoc lineSeparator)
10   {
11     nl = lineSeparator;
12     PluginXML result = new PluginXML();
13     nl = null;
14     return result;
15   }
16
17   protected final String JavaDoc NL = nl == null ? (System.getProperties().getProperty("line.separator")) : nl;
18   protected final String JavaDoc TEXT_1 = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + NL + "<?eclipse version=\"3.0\"?>" + NL;
19   protected final String JavaDoc TEXT_2 = NL;
20   protected final String JavaDoc TEXT_3 = "<!--" + NL + " <copyright>" + NL + " </copyright>" + NL;
21   protected final String JavaDoc TEXT_4 = NL + " ";
22   protected final String JavaDoc TEXT_5 = "Id";
23   protected final String JavaDoc TEXT_6 = NL + "-->" + NL + "" + NL + "<plugin";
24   protected final String JavaDoc TEXT_7 = ">";
25   protected final String JavaDoc TEXT_8 = NL + " name = \"%pluginName\"" + NL + " id = \"";
26   protected final String JavaDoc TEXT_9 = "\"" + NL + " version = \"1.0.0\"" + NL + " provider-name = \"%providerName\"" + NL + " class = \"";
27   protected final String JavaDoc TEXT_10 = "$Implementation\">" + NL + "" + NL + " <requires>";
28   protected final String JavaDoc TEXT_11 = NL + " <import plugin=\"";
29   protected final String JavaDoc TEXT_12 = "\" ";
30   protected final String JavaDoc TEXT_13 = "export=\"true\"";
31   protected final String JavaDoc TEXT_14 = "/>";
32   protected final String JavaDoc TEXT_15 = NL + " </requires>" + NL + "" + NL + " <runtime>";
33   protected final String JavaDoc TEXT_16 = NL + " <library name=\"";
34   protected final String JavaDoc TEXT_17 = ".jar\">";
35   protected final String JavaDoc TEXT_18 = NL + " <library name=\".\">";
36   protected final String JavaDoc TEXT_19 = NL + " <export name=\"*\"/>" + NL + " </library>" + NL + " </runtime>";
37   protected final String JavaDoc TEXT_20 = NL;
38   protected final String JavaDoc TEXT_21 = NL + " <extension point=\"org.eclipse.emf.edit.itemProviderAdapterFactories\">" + NL + " <factory " + NL + " uri = \"";
39   protected final String JavaDoc TEXT_22 = "\" " + NL + " class = \"";
40   protected final String JavaDoc TEXT_23 = "\"" + NL + " supportedTypes = ";
41   protected final String JavaDoc TEXT_24 = NL + " ";
42   protected final String JavaDoc TEXT_25 = " />" + NL + " </extension>" + NL + " ";
43   protected final String JavaDoc TEXT_26 = NL + " <extension point=\"org.eclipse.emf.ecore.generated_package\">" + NL + " <package" + NL + " uri = \"";
44   protected final String JavaDoc TEXT_27 = "\"" + NL + " class = \"";
45   protected final String JavaDoc TEXT_28 = "\"";
46   protected final String JavaDoc TEXT_29 = " />";
47   protected final String JavaDoc TEXT_30 = NL + " genModel = \"";
48   protected final String JavaDoc TEXT_31 = "\" /> ";
49   protected final String JavaDoc TEXT_32 = NL + " </extension>";
50   protected final String JavaDoc TEXT_33 = NL + NL + " <extension point=\"org.eclipse.emf.ecore.extension_parser\">" + NL + " <parser" + NL + " type=\"";
51   protected final String JavaDoc TEXT_34 = "\"" + NL + " class=\"";
52   protected final String JavaDoc TEXT_35 = "\" />" + NL + " </extension>";
53   protected final String JavaDoc TEXT_36 = NL;
54   protected final String JavaDoc TEXT_37 = NL + " <extension" + NL + " point=\"org.eclipse.core.runtime.applications\"" + NL + " id=\"";
55   protected final String JavaDoc TEXT_38 = "Application\">" + NL + " <application>" + NL + " <run" + NL + " class=\"";
56   protected final String JavaDoc TEXT_39 = "$Application\">" + NL + " </run>" + NL + " </application>" + NL + " </extension>" + NL + "" + NL + " <extension" + NL + " point=\"org.eclipse.ui.perspectives\">" + NL + " <perspective" + NL + " name=\"%_UI_Perspective_label\"" + NL + " class=\"";
57   protected final String JavaDoc TEXT_40 = "$Perspective\"" + NL + " id=\"";
58   protected final String JavaDoc TEXT_41 = "Perspective\">" + NL + " </perspective>" + NL + " </extension>" + NL + "" + NL + " <extension" + NL + " point=\"org.eclipse.ui.commands\">" + NL + " <command" + NL + " name=\"%_UI_Menu_OpenURI_label\"" + NL + " description=\"%_UI_Menu_OpenURI_description\"" + NL + " categoryId=\"org.eclipse.ui.category.file\"" + NL + " id=\"";
59   protected final String JavaDoc TEXT_42 = "OpenURICommand\" /> " + NL + " <command" + NL + " name=\"%_UI_Menu_Open_label\"" + NL + " description=\"%_UI_Menu_Open_description\"" + NL + " categoryId=\"org.eclipse.ui.category.file\"" + NL + " id=\"";
60   protected final String JavaDoc TEXT_43 = "OpenCommand\" /> " + NL + " </extension>" + NL + " " + NL + " <extension" + NL + " point=\"org.eclipse.ui.bindings\">" + NL + " <key" + NL + " commandId=\"";
61   protected final String JavaDoc TEXT_44 = "OpenURICommand\"" + NL + " sequence=\"M1+U\"" + NL + " schemeId=\"org.eclipse.ui.defaultAcceleratorConfiguration\" />" + NL + " <key" + NL + " commandId=\"";
62   protected final String JavaDoc TEXT_45 = "OpenCommand\"" + NL + " sequence=\"M1+O\"" + NL + " schemeId=\"org.eclipse.ui.defaultAcceleratorConfiguration\" />" + NL + " </extension>" + NL + "" + NL + " <extension" + NL + " point=\"org.eclipse.ui.actionSets\">" + NL + " <actionSet" + NL + " label=\"%_UI_";
63   protected final String JavaDoc TEXT_46 = "_ActionSet_label\"" + NL + " visible=\"true\"" + NL + " id=\"";
64   protected final String JavaDoc TEXT_47 = "ActionSet\">" + NL + " <action" + NL + " label=\"%_UI_Menu_About_label\"" + NL + " class=\"";
65   protected final String JavaDoc TEXT_48 = "$AboutAction\"" + NL + " menubarPath=\"help/additions\"" + NL + " id=\"";
66   protected final String JavaDoc TEXT_49 = "AboutAction\">" + NL + " </action>" + NL + " <action" + NL + " label=\"%_UI_Menu_OpenURI_label\"" + NL + " definitionId=\"";
67   protected final String JavaDoc TEXT_50 = "OpenURICommand\"" + NL + " class=\"";
68   protected final String JavaDoc TEXT_51 = "$OpenURIAction\"" + NL + " menubarPath=\"file/additions\"" + NL + " id=\"";
69   protected final String JavaDoc TEXT_52 = "OpenURIAction\">" + NL + " </action>" + NL + " <action" + NL + " label=\"%_UI_Menu_Open_label\"" + NL + " definitionId=\"";
70   protected final String JavaDoc TEXT_53 = "OpenCommand\"" + NL + " class=\"";
71   protected final String JavaDoc TEXT_54 = "$OpenAction\"" + NL + " menubarPath=\"file/additions\"" + NL + " id=\"";
72   protected final String JavaDoc TEXT_55 = "OpenAction\">" + NL + " </action>" + NL + " </actionSet>" + NL + " </extension>" + NL + " ";
73   protected final String JavaDoc TEXT_56 = NL;
74   protected final String JavaDoc TEXT_57 = NL + " <extension" + NL + " point=\"org.eclipse.ui.actionSets\">" + NL + " <actionSet" + NL + " label=\"%_UI_";
75   protected final String JavaDoc TEXT_58 = "_ActionSet_label\"" + NL + " visible=\"true\"" + NL + " id=\"";
76   protected final String JavaDoc TEXT_59 = "ActionSet\">" + NL + " <action" + NL + " label=\"%_UI_";
77   protected final String JavaDoc TEXT_60 = "_label\"" + NL + " class=\"";
78   protected final String JavaDoc TEXT_61 = "$NewAction\"" + NL + " menubarPath=\"file/new/additions\"" + NL + " id=\"";
79   protected final String JavaDoc TEXT_62 = "NewAction\">" + NL + " </action>" + NL + " </actionSet>" + NL + " </extension> ";
80   protected final String JavaDoc TEXT_63 = NL + " <extension" + NL + " point = \"org.eclipse.ui.newWizards\">" + NL + " <category" + NL + " id = \"org.eclipse.emf.ecore.Wizard.category.ID\"" + NL + " name=\"%_UI_Wizard_category\">" + NL + " </category>" + NL + " <wizard" + NL + " id = \"";
81   protected final String JavaDoc TEXT_64 = "ID\"" + NL + " name = \"%_UI_";
82   protected final String JavaDoc TEXT_65 = "_label\"" + NL + " class = \"";
83   protected final String JavaDoc TEXT_66 = "\"" + NL + " category = \"org.eclipse.emf.ecore.Wizard.category.ID\"" + NL + " icon = \"icons/full/obj16/";
84   protected final String JavaDoc TEXT_67 = "ModelFile.gif\">" + NL + " <description>%_UI_";
85   protected final String JavaDoc TEXT_68 = "_description</description>" + NL + " <selection class = \"org.eclipse.core.resources.IResource\" />" + NL + " </wizard>" + NL + " </extension>";
86   protected final String JavaDoc TEXT_69 = NL + NL + " <extension point = \"org.eclipse.ui.editors\">" + NL + " <editor" + NL + " id = \"";
87   protected final String JavaDoc TEXT_70 = "ID\"" + NL + " name = \"%_UI_";
88   protected final String JavaDoc TEXT_71 = "_label\"" + NL + " icon = \"icons/full/obj16/";
89   protected final String JavaDoc TEXT_72 = "ModelFile.gif\"" + NL + " extensions = \"";
90   protected final String JavaDoc TEXT_73 = "\"" + NL + " class = \"";
91   protected final String JavaDoc TEXT_74 = "\" " + NL + " contributorClass=\"";
92   protected final String JavaDoc TEXT_75 = "\" >" + NL + " </editor>" + NL + " </extension> ";
93   protected final String JavaDoc TEXT_76 = NL + "</plugin>";
94   protected final String JavaDoc TEXT_77 = NL;
95
96   public String JavaDoc generate(Object JavaDoc argument)
97   {
98     StringBuffer JavaDoc stringBuffer = new StringBuffer JavaDoc();
99     
100 /**
101  * <copyright>
102  *
103  * Copyright (c) 2002-2005 IBM Corporation and others.
104  * All rights reserved. This program and the accompanying materials
105  * are made available under the terms of the Eclipse Public License v1.0
106  * which accompanies this distribution, and is available at
107  * http://www.eclipse.org/legal/epl-v10.html
108  *
109  * Contributors:
110  * IBM - Initial API and implementation
111  *
112  * </copyright>
113  */

114
115     GenModel genModel = (GenModel)argument;
116     stringBuffer.append(TEXT_1);
117     stringBuffer.append(TEXT_2);
118     stringBuffer.append(TEXT_3);
119     stringBuffer.append(TEXT_4);
120     stringBuffer.append("$");
121     stringBuffer.append(TEXT_5);
122     stringBuffer.append("$");
123     stringBuffer.append(TEXT_6);
124     if (genModel.isBundleManifest()) {
125     stringBuffer.append(TEXT_7);
126     } else {
127     stringBuffer.append(TEXT_8);
128     stringBuffer.append(genModel.getEditorPluginID());
129     stringBuffer.append(TEXT_9);
130     stringBuffer.append(genModel.getQualifiedEditorPluginClassName());
131     stringBuffer.append(TEXT_10);
132     for (Iterator j=genModel.getEditorRequiredPlugins().iterator(); j.hasNext();) { String JavaDoc pluginID = (String JavaDoc)j.next();
133     stringBuffer.append(TEXT_11);
134     stringBuffer.append(pluginID);
135     stringBuffer.append(TEXT_12);
136     if (!pluginID.startsWith("org.eclipse.core.runtime")) {
137     stringBuffer.append(TEXT_13);
138     }
139     stringBuffer.append(TEXT_14);
140     }
141     stringBuffer.append(TEXT_15);
142     if (genModel.isRuntimeJar()) {
143     stringBuffer.append(TEXT_16);
144     stringBuffer.append(genModel.getEditorPluginID());
145     stringBuffer.append(TEXT_17);
146     } else {
147     stringBuffer.append(TEXT_18);
148     }
149     stringBuffer.append(TEXT_19);
150     }
151     stringBuffer.append(TEXT_20);
152     if (genModel.sameEditEditorProject()) {
153      for (Iterator i = genModel.getAllGenPackagesWithClassifiers().iterator(); i.hasNext(); ) { GenPackage genPackage = (GenPackage)i.next();
154     stringBuffer.append(TEXT_21);
155     stringBuffer.append(genPackage.getNSURI());
156     stringBuffer.append(TEXT_22);
157     stringBuffer.append(genPackage.getQualifiedItemProviderAdapterFactoryClassName());
158     stringBuffer.append(TEXT_23);
159     for (ListIterator j = genPackage.getProviderSupportedTypes().listIterator(); j.hasNext(); ) {
160     stringBuffer.append(TEXT_24);
161     stringBuffer.append((j.hasPrevious()? " " : "\"") + j.next() + (j.hasNext() ? "" : "\""));
162     }
163     stringBuffer.append(TEXT_25);
164     }
165     }
166     if (genModel.sameModelEditorProject()) {
167      for (Iterator i = genModel.getAllGenPackagesWithClassifiers().iterator(); i.hasNext(); ) { GenPackage genPackage = (GenPackage)i.next();
168     stringBuffer.append(TEXT_26);
169     stringBuffer.append(genPackage.getNSURI());
170     stringBuffer.append(TEXT_27);
171     stringBuffer.append(genPackage.getQualifiedPackageInterfaceName());
172     stringBuffer.append(TEXT_28);
173     if (!genModel.hasLocalGenModel()) {
174     stringBuffer.append(TEXT_29);
175     } else {
176     stringBuffer.append(TEXT_30);
177     stringBuffer.append(genModel.getRelativeGenModelLocation());
178     stringBuffer.append(TEXT_31);
179     }
180     stringBuffer.append(TEXT_32);
181     if (genPackage.getResource() != GenResourceKind.NONE_LITERAL) {
182     stringBuffer.append(TEXT_33);
183     stringBuffer.append(genPackage.getPrefix().toLowerCase());
184     stringBuffer.append(TEXT_34);
185     stringBuffer.append(genPackage.getQualifiedResourceFactoryClassName());
186     stringBuffer.append(TEXT_35);
187     }
188     stringBuffer.append(TEXT_36);
189     }
190     }
191     if (genModel.isRichClientPlatform()) {
192     stringBuffer.append(TEXT_37);
193     stringBuffer.append(genModel.getEditorAdvisorClassName());
194     stringBuffer.append(TEXT_38);
195     stringBuffer.append(genModel.getQualifiedEditorAdvisorClassName());
196     stringBuffer.append(TEXT_39);
197     stringBuffer.append(genModel.getQualifiedEditorAdvisorClassName());
198     stringBuffer.append(TEXT_40);
199     stringBuffer.append(genModel.getQualifiedEditorAdvisorClassName());
200     stringBuffer.append(TEXT_41);
201     stringBuffer.append(genModel.getQualifiedEditorAdvisorClassName());
202     stringBuffer.append(TEXT_42);
203     stringBuffer.append(genModel.getQualifiedEditorAdvisorClassName());
204     stringBuffer.append(TEXT_43);
205     stringBuffer.append(genModel.getQualifiedEditorAdvisorClassName());
206     stringBuffer.append(TEXT_44);
207     stringBuffer.append(genModel.getQualifiedEditorAdvisorClassName());
208     stringBuffer.append(TEXT_45);
209     stringBuffer.append(genModel.getEditorAdvisorClassName());
210     stringBuffer.append(TEXT_46);
211     stringBuffer.append(genModel.getEditorAdvisorClassName());
212     stringBuffer.append(TEXT_47);
213     stringBuffer.append(genModel.getQualifiedEditorAdvisorClassName());
214     stringBuffer.append(TEXT_48);
215     stringBuffer.append(genModel.getQualifiedEditorAdvisorClassName());
216     stringBuffer.append(TEXT_49);
217     stringBuffer.append(genModel.getQualifiedEditorAdvisorClassName());
218     stringBuffer.append(TEXT_50);
219     stringBuffer.append(genModel.getQualifiedEditorAdvisorClassName());
220     stringBuffer.append(TEXT_51);
221     stringBuffer.append(genModel.getQualifiedEditorAdvisorClassName());
222     stringBuffer.append(TEXT_52);
223     stringBuffer.append(genModel.getQualifiedEditorAdvisorClassName());
224     stringBuffer.append(TEXT_53);
225     stringBuffer.append(genModel.getQualifiedEditorAdvisorClassName());
226     stringBuffer.append(TEXT_54);
227     stringBuffer.append(genModel.getQualifiedEditorAdvisorClassName());
228     stringBuffer.append(TEXT_55);
229     }
230     for (Iterator i = genModel.getAllGenPackagesWithClassifiers().iterator(); i.hasNext(); ) { GenPackage genPackage = (GenPackage)i.next(); if (genPackage.hasConcreteClasses()){
231     stringBuffer.append(TEXT_56);
232     if (genModel.isRichClientPlatform()) {
233     stringBuffer.append(TEXT_57);
234     stringBuffer.append(genPackage.getModelWizardClassName());
235     stringBuffer.append(TEXT_58);
236     stringBuffer.append(genPackage.getQualifiedActionBarContributorClassName());
237     stringBuffer.append(TEXT_59);
238     stringBuffer.append(genPackage.getModelWizardClassName());
239     stringBuffer.append(TEXT_60);
240     stringBuffer.append(genPackage.getQualifiedActionBarContributorClassName());
241     stringBuffer.append(TEXT_61);
242     stringBuffer.append(genPackage.getQualifiedActionBarContributorClassName());
243     stringBuffer.append(TEXT_62);
244     } else {
245     stringBuffer.append(TEXT_63);
246     stringBuffer.append(genPackage.getQualifiedModelWizardClassName());
247     stringBuffer.append(TEXT_64);
248     stringBuffer.append(genPackage.getModelWizardClassName());
249     stringBuffer.append(TEXT_65);
250     stringBuffer.append(genPackage.getQualifiedModelWizardClassName());
251     stringBuffer.append(TEXT_66);
252     stringBuffer.append(genPackage.getPrefix());
253     stringBuffer.append(TEXT_67);
254     stringBuffer.append(genPackage.getModelWizardClassName());
255     stringBuffer.append(TEXT_68);
256     }
257     stringBuffer.append(TEXT_69);
258     stringBuffer.append(genPackage.getQualifiedEditorClassName());
259     stringBuffer.append(TEXT_70);
260     stringBuffer.append(genPackage.getEditorClassName());
261     stringBuffer.append(TEXT_71);
262     stringBuffer.append(genPackage.getPrefix());
263     stringBuffer.append(TEXT_72);
264     stringBuffer.append(genPackage.getPrefix().toLowerCase());
265     stringBuffer.append(TEXT_73);
266     stringBuffer.append(genPackage.getQualifiedEditorClassName());
267     stringBuffer.append(TEXT_74);
268     stringBuffer.append(genPackage.getQualifiedActionBarContributorClassName());
269     stringBuffer.append(TEXT_75);
270     }}
271     stringBuffer.append(TEXT_76);
272     stringBuffer.append(TEXT_77);
273     return stringBuffer.toString();
274   }
275 }
276
Popular Tags