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