KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > emf > codegen > ecore > templates > model > Plugin


1 package org.eclipse.emf.codegen.ecore.templates.model;
2
3 import org.eclipse.emf.codegen.ecore.genmodel.*;
4
5 public class Plugin
6 {
7   protected static String JavaDoc nl;
8   public static synchronized Plugin create(String JavaDoc lineSeparator)
9   {
10     nl = lineSeparator;
11     Plugin result = new Plugin();
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 central singleton for the ";
23   protected final String JavaDoc TEXT_7 = " model plugin." + NL + " * <!-- begin-user-doc -->" + NL + " * <!-- end-user-doc -->" + NL + " * @generated" + NL + " */" + NL + "public final class ";
24   protected final String JavaDoc TEXT_8 = " extends EMFPlugin" + NL + "{";
25   protected final String JavaDoc TEXT_9 = NL + "\t/**" + NL + "\t * <!-- begin-user-doc -->" + NL + "\t * <!-- end-user-doc -->" + NL + "\t * @generated" + NL + "\t */" + NL + "\tpublic static final ";
26   protected final String JavaDoc TEXT_10 = " copyright = \"";
27   protected final String JavaDoc TEXT_11 = "\";";
28   protected final String JavaDoc TEXT_12 = NL;
29   protected final String JavaDoc TEXT_13 = NL + "\t/**" + NL + "\t * Keep track of the singleton." + NL + "\t * <!-- begin-user-doc -->" + NL + "\t * <!-- end-user-doc -->" + NL + "\t * @generated" + NL + "\t */" + NL + "\tpublic static final ";
30   protected final String JavaDoc TEXT_14 = " INSTANCE = new ";
31   protected final String JavaDoc TEXT_15 = "();" + NL + "" + NL + "\t/**" + NL + "\t * Keep track of the singleton." + NL + "\t * <!-- begin-user-doc -->" + NL + "\t * <!-- end-user-doc -->" + NL + "\t * @generated" + NL + "\t */" + NL + "\tprivate static Implementation plugin;" + NL + "" + NL + "\t/**" + NL + "\t * Create the instance." + NL + "\t * <!-- begin-user-doc -->" + NL + "\t * <!-- end-user-doc -->" + NL + "\t * @generated" + NL + "\t */" + NL + "\tpublic ";
32   protected final String JavaDoc TEXT_16 = "()" + NL + "\t{" + NL + "\t\tsuper(new ResourceLocator [] {});" + NL + "\t}" + NL + "" + NL + "\t/**" + NL + "\t * Returns the singleton instance of the Eclipse plugin." + NL + "\t * <!-- begin-user-doc -->" + NL + "\t * <!-- end-user-doc -->" + NL + "\t * @return the singleton instance." + NL + "\t * @generated" + NL + "\t */" + NL + "\tpublic ResourceLocator getPluginResourceLocator()" + NL + "\t{" + NL + "\t\treturn plugin;" + NL + "\t}" + NL + "" + NL + "\t/**" + NL + "\t * Returns the singleton instance of the Eclipse plugin." + NL + "\t * <!-- begin-user-doc -->" + NL + "\t * <!-- end-user-doc -->" + NL + "\t * @return the singleton instance." + NL + "\t * @generated" + NL + "\t */" + NL + "\tpublic static Implementation getPlugin()" + NL + "\t{" + NL + "\t\treturn plugin;" + NL + "\t}" + NL + "" + NL + "\t/**" + NL + "\t * The actual implementation of the Eclipse <b>Plugin</b>." + NL + "\t * <!-- begin-user-doc -->" + NL + "\t * <!-- end-user-doc -->" + NL + "\t * @generated" + NL + "\t */" + NL + "\tpublic static class Implementation extends EclipsePlugin" + NL + "\t{" + NL + "\t\t/**" + NL + "\t\t * Creates an instance." + NL + "\t\t * <!-- begin-user-doc -->" + NL + "\t\t * <!-- end-user-doc -->";
33   protected final String JavaDoc TEXT_17 = NL + "\t\t * @param descriptor the description of the plugin.";
34   protected final String JavaDoc TEXT_18 = NL + "\t\t * @generated" + NL + "\t\t */" + NL + "\t\tpublic Implementation(";
35   protected final String JavaDoc TEXT_19 = " descriptor";
36   protected final String JavaDoc TEXT_20 = ")" + NL + "\t\t{" + NL + "\t\t\tsuper(";
37   protected final String JavaDoc TEXT_21 = "descriptor";
38   protected final String JavaDoc TEXT_22 = ");" + NL + "" + NL + "\t\t\t// Remember the static instance." + NL + "\t\t\t//" + NL + "\t\t\tplugin = this;" + NL + "\t\t}" + NL + "\t}" + NL + "" + NL + "}";
39   protected final String JavaDoc TEXT_23 = NL;
40
41   public String JavaDoc generate(Object JavaDoc argument)
42   {
43     StringBuffer JavaDoc stringBuffer = new StringBuffer JavaDoc();
44     
45 /**
46  * <copyright>
47  *
48  * Copyright (c) 2002-2004 IBM Corporation and others.
49  * All rights reserved. This program and the accompanying materials
50  * are made available under the terms of the Eclipse Public License v1.0
51  * which accompanies this distribution, and is available at
52  * http://www.eclipse.org/legal/epl-v10.html
53  *
54  * Contributors:
55  * IBM - Initial API and implementation
56  *
57  * </copyright>
58  */

59
60     GenModel genModel = (GenModel)argument;
61     stringBuffer.append(TEXT_1);
62     stringBuffer.append(TEXT_2);
63     stringBuffer.append("$");
64     stringBuffer.append(TEXT_3);
65     stringBuffer.append("$");
66     stringBuffer.append(TEXT_4);
67     stringBuffer.append(genModel.getModelPluginPackageName());
68     stringBuffer.append(TEXT_5);
69     genModel.addImport("org.eclipse.emf.common.EMFPlugin");
70     genModel.addImport("org.eclipse.emf.common.util.ResourceLocator");
71     genModel.markImportLocation(stringBuffer);
72     stringBuffer.append(TEXT_6);
73     stringBuffer.append(genModel.getModelName());
74     stringBuffer.append(TEXT_7);
75     stringBuffer.append(genModel.getModelPluginClassName());
76     stringBuffer.append(TEXT_8);
77     if (genModel.getCopyrightText() != null) {
78     stringBuffer.append(TEXT_9);
79     stringBuffer.append(genModel.getImportedName("java.lang.String"));
80     stringBuffer.append(TEXT_10);
81     stringBuffer.append(genModel.getCopyrightText());
82     stringBuffer.append(TEXT_11);
83     stringBuffer.append(genModel.getNonNLS());
84     stringBuffer.append(TEXT_12);
85     }
86     stringBuffer.append(TEXT_13);
87     stringBuffer.append(genModel.getModelPluginClassName());
88     stringBuffer.append(TEXT_14);
89     stringBuffer.append(genModel.getModelPluginClassName());
90     stringBuffer.append(TEXT_15);
91     stringBuffer.append(genModel.getModelPluginClassName());
92     stringBuffer.append(TEXT_16);
93     if (genModel.needsRuntimeCompatibility()) {
94     stringBuffer.append(TEXT_17);
95     }
96     stringBuffer.append(TEXT_18);
97     if (genModel.needsRuntimeCompatibility()) {
98     stringBuffer.append(genModel.getImportedName("org.eclipse.core.runtime.IPluginDescriptor"));
99     stringBuffer.append(TEXT_19);
100     }
101     stringBuffer.append(TEXT_20);
102     if (genModel.needsRuntimeCompatibility()) {
103     stringBuffer.append(TEXT_21);
104     }
105     stringBuffer.append(TEXT_22);
106     genModel.emitSortedImports();
107     stringBuffer.append(TEXT_23);
108     return stringBuffer.toString();
109   }
110 }
111
Popular Tags