KickJava   Java API By Example, From Geeks To Geeks.

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


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 Plugin
7 {
8   protected static String JavaDoc nl;
9   public static synchronized Plugin create(String JavaDoc lineSeparator)
10   {
11     nl = lineSeparator;
12     Plugin result = new Plugin();
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 = "";
19   protected final String JavaDoc TEXT_2 = "/**" + NL + " * <copyright>" + NL + " * </copyright>" + NL + " *" + NL + " * ";
20   protected final String JavaDoc TEXT_3 = "Id";
21   protected final String JavaDoc TEXT_4 = NL + " */" + NL + "package ";
22   protected final String JavaDoc TEXT_5 = ";" + NL;
23   protected final String JavaDoc TEXT_6 = NL + NL + "/**" + NL + " * This is the central singleton for the ";
24   protected final String JavaDoc TEXT_7 = " editor plugin." + NL + " * <!-- begin-user-doc -->" + NL + " * <!-- end-user-doc -->" + NL + " * @generated" + NL + " */" + NL + "public final class ";
25   protected final String JavaDoc TEXT_8 = " extends EMFPlugin" + NL + "{";
26   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 ";
27   protected final String JavaDoc TEXT_10 = " copyright = \"";
28   protected final String JavaDoc TEXT_11 = "\";";
29   protected final String JavaDoc TEXT_12 = NL;
30   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 ";
31   protected final String JavaDoc TEXT_14 = " INSTANCE = new ";
32   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 ";
33   protected final String JavaDoc TEXT_16 = "()" + NL + "\t{" + NL + "\t\tsuper" + NL + "\t\t (new ResourceLocator [] " + NL + "\t\t {";
34   protected final String JavaDoc TEXT_17 = NL + "\t\t ";
35   protected final String JavaDoc TEXT_18 = ".INSTANCE,";
36   protected final String JavaDoc TEXT_19 = NL + "\t\t });" + 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 -->";
37   protected final String JavaDoc TEXT_20 = NL + "\t\t * @param descriptor the description of the plugin.";
38   protected final String JavaDoc TEXT_21 = NL + "\t\t * @generated" + NL + "\t\t */" + NL + "\t\tpublic Implementation(";
39   protected final String JavaDoc TEXT_22 = " descriptor";
40   protected final String JavaDoc TEXT_23 = ")" + NL + "\t\t{" + NL + "\t\t\tsuper(";
41   protected final String JavaDoc TEXT_24 = "descriptor";
42   protected final String JavaDoc TEXT_25 = ");" + 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 + "}";
43   protected final String JavaDoc TEXT_26 = NL;
44
45   public String JavaDoc generate(Object JavaDoc argument)
46   {
47     StringBuffer JavaDoc stringBuffer = new StringBuffer JavaDoc();
48     
49 /**
50  * <copyright>
51  *
52  * Copyright (c) 2002-2004 IBM Corporation and others.
53  * All rights reserved. This program and the accompanying materials
54  * are made available under the terms of the Eclipse Public License v1.0
55  * which accompanies this distribution, and is available at
56  * http://www.eclipse.org/legal/epl-v10.html
57  *
58  * Contributors:
59  * IBM - Initial API and implementation
60  *
61  * </copyright>
62  */

63
64     GenModel genModel = (GenModel)argument;
65     stringBuffer.append(TEXT_1);
66     stringBuffer.append(TEXT_2);
67     stringBuffer.append("$");
68     stringBuffer.append(TEXT_3);
69     stringBuffer.append("$");
70     stringBuffer.append(TEXT_4);
71     stringBuffer.append(genModel.getEditorPluginPackageName());
72     stringBuffer.append(TEXT_5);
73     genModel.addImport("org.eclipse.emf.common.EMFPlugin");
74     genModel.addImport("org.eclipse.emf.common.util.ResourceLocator");
75     genModel.markImportLocation(stringBuffer);
76     stringBuffer.append(TEXT_6);
77     stringBuffer.append(genModel.getModelName());
78     stringBuffer.append(TEXT_7);
79     stringBuffer.append(genModel.getEditorPluginClassName());
80     stringBuffer.append(TEXT_8);
81     if (genModel.getCopyrightText() != null) {
82     stringBuffer.append(TEXT_9);
83     stringBuffer.append(genModel.getImportedName("java.lang.String"));
84     stringBuffer.append(TEXT_10);
85     stringBuffer.append(genModel.getCopyrightText());
86     stringBuffer.append(TEXT_11);
87     stringBuffer.append(genModel.getNonNLS());
88     stringBuffer.append(TEXT_12);
89     }
90     stringBuffer.append(TEXT_13);
91     stringBuffer.append(genModel.getEditorPluginClassName());
92     stringBuffer.append(TEXT_14);
93     stringBuffer.append(genModel.getEditorPluginClassName());
94     stringBuffer.append(TEXT_15);
95     stringBuffer.append(genModel.getEditorPluginClassName());
96     stringBuffer.append(TEXT_16);
97     for (Iterator i = genModel.getEditResourceDelegateImportedPluginClassNames().iterator(); i.hasNext(); ) { String JavaDoc pluginClassName = (String JavaDoc)i.next();
98     stringBuffer.append(TEXT_17);
99     stringBuffer.append(pluginClassName);
100     stringBuffer.append(TEXT_18);
101     }
102     stringBuffer.append(TEXT_19);
103     if (genModel.needsRuntimeCompatibility()) {
104     stringBuffer.append(TEXT_20);
105     }
106     stringBuffer.append(TEXT_21);
107     if (genModel.needsRuntimeCompatibility()) {
108     stringBuffer.append(genModel.getImportedName("org.eclipse.core.runtime.IPluginDescriptor"));
109     stringBuffer.append(TEXT_22);
110     }
111     stringBuffer.append(TEXT_23);
112     if (genModel.needsRuntimeCompatibility()) {
113     stringBuffer.append(TEXT_24);
114     }
115     stringBuffer.append(TEXT_25);
116     genModel.emitSortedImports();
117     stringBuffer.append(TEXT_26);
118     return stringBuffer.toString();
119   }
120 }
121
Popular Tags