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 nl; 9 public static synchronized Plugin create(String lineSeparator) 10 { 11 nl = lineSeparator; 12 Plugin result = new Plugin(); 13 nl = null; 14 return result; 15 } 16 17 protected final String NL = nl == null ? (System.getProperties().getProperty("line.separator")) : nl; 18 protected final String TEXT_1 = ""; 19 protected final String TEXT_2 = "/**" + NL + " * <copyright>" + NL + " * </copyright>" + NL + " *" + NL + " * "; 20 protected final String TEXT_3 = "Id"; 21 protected final String TEXT_4 = NL + " */" + NL + "package "; 22 protected final String TEXT_5 = ";" + NL; 23 protected final String TEXT_6 = NL + NL + "/**" + NL + " * This is the central singleton for the "; 24 protected final String TEXT_7 = " editor plugin." + NL + " * <!-- begin-user-doc -->" + NL + " * <!-- end-user-doc -->" + NL + " * @generated" + NL + " */" + NL + "public final class "; 25 protected final String TEXT_8 = " extends EMFPlugin" + NL + "{"; 26 protected final String 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 TEXT_10 = " copyright = \""; 28 protected final String TEXT_11 = "\";"; 29 protected final String TEXT_12 = NL; 30 protected final String 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 TEXT_14 = " INSTANCE = new "; 32 protected final String 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 TEXT_16 = "()" + NL + "\t{" + NL + "\t\tsuper" + NL + "\t\t (new ResourceLocator [] " + NL + "\t\t {"; 34 protected final String TEXT_17 = NL + "\t\t "; 35 protected final String TEXT_18 = ".INSTANCE,"; 36 protected final String 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 TEXT_20 = NL + "\t\t * @param descriptor the description of the plugin."; 38 protected final String TEXT_21 = NL + "\t\t * @generated" + NL + "\t\t */" + NL + "\t\tpublic Implementation("; 39 protected final String TEXT_22 = " descriptor"; 40 protected final String TEXT_23 = ")" + NL + "\t\t{" + NL + "\t\t\tsuper("; 41 protected final String TEXT_24 = "descriptor"; 42 protected final String 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 TEXT_26 = NL; 44 45 public String generate(Object argument) 46 { 47 StringBuffer stringBuffer = new StringBuffer (); 48 49 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 pluginClassName = (String )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 |