KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > emf > codegen > ecore > templates > edit > PluginProperties


1 package org.eclipse.emf.codegen.ecore.templates.edit;
2
3 import java.util.*;
4 import org.eclipse.emf.codegen.ecore.genmodel.*;
5
6 public class PluginProperties
7 {
8   protected static String JavaDoc nl;
9   public static synchronized PluginProperties create(String JavaDoc lineSeparator)
10   {
11     nl = lineSeparator;
12     PluginProperties result = new PluginProperties();
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 = "# <copyright>" + NL + "# </copyright>" + NL + "#" + NL + "# ";
20   protected final String JavaDoc TEXT_3 = "Id";
21   protected final String JavaDoc TEXT_4 = NL + NL + "# ====================================================================" + NL + "# To code developer:" + NL + "# Do NOT change the properties between this line and the" + NL + "# \"%%% END OF TRANSLATED PROPERTIES %%%\" line." + NL + "# Make a new property name, append to the end of the file and change" + NL + "# the code to use the new property." + NL + "# ====================================================================" + NL + "" + NL + "# ====================================================================" + NL + "# %%% END OF TRANSLATED PROPERTIES %%%" + NL + "# ====================================================================" + NL + "" + NL + "pluginName = ";
22   protected final String JavaDoc TEXT_5 = " Edit Support" + NL + "providerName = www.example.org" + NL;
23   protected final String JavaDoc TEXT_6 = NL + "_UI_CreateChild_text = {0}" + NL + "_UI_CreateChild_text2 = {1} {0}" + NL + "_UI_CreateChild_text3 = {1}" + NL + "_UI_CreateChild_tooltip = Create New {0} Under {1} Feature" + NL + "_UI_CreateChild_description = Create a new child of type {0} for the {1} feature of the selected {2}." + NL + "_UI_CreateSibling_description = Create a new sibling of type {0} for the selected {2}, under the {1} feature of their parent." + NL;
24   protected final String JavaDoc TEXT_7 = NL + "_UI_PropertyDescriptor_description = The {0} of the {1}" + NL;
25   protected final String JavaDoc TEXT_8 = NL + "_UI_";
26   protected final String JavaDoc TEXT_9 = "_type = ";
27   protected final String JavaDoc TEXT_10 = NL + "_UI_Unknown_type = Object" + NL + "" + NL + "_UI_Unknown_datatype= Value" + NL;
28   protected final String JavaDoc TEXT_11 = NL + "_UI_";
29   protected final String JavaDoc TEXT_12 = "_";
30   protected final String JavaDoc TEXT_13 = "_feature = ";
31   protected final String JavaDoc TEXT_14 = NL + "_UI_";
32   protected final String JavaDoc TEXT_15 = "_";
33   protected final String JavaDoc TEXT_16 = "_description = ";
34   protected final String JavaDoc TEXT_17 = NL + "_UI_Unknown_feature = Unspecified" + NL;
35   protected final String JavaDoc TEXT_18 = NL + "_UI_";
36   protected final String JavaDoc TEXT_19 = "_";
37   protected final String JavaDoc TEXT_20 = "_literal = ";
38   protected final String JavaDoc TEXT_21 = NL;
39   protected final String JavaDoc TEXT_22 = " = ";
40   protected final String JavaDoc TEXT_23 = NL;
41
42   public String JavaDoc generate(Object JavaDoc argument)
43   {
44     StringBuffer JavaDoc stringBuffer = new StringBuffer JavaDoc();
45     
46 /**
47  * <copyright>
48  *
49  * Copyright (c) 2002-2005 IBM Corporation and others.
50  * All rights reserved. This program and the accompanying materials
51  * are made available under the terms of the Eclipse Public License v1.0
52  * which accompanies this distribution, and is available at
53  * http://www.eclipse.org/legal/epl-v10.html
54  *
55  * Contributors:
56  * IBM - Initial API and implementation
57  *
58  * </copyright>
59  */

60
61     GenModel genModel = (GenModel)argument;
62     stringBuffer.append(TEXT_1);
63     stringBuffer.append(TEXT_2);
64     stringBuffer.append("$");
65     stringBuffer.append(TEXT_3);
66     stringBuffer.append("$");
67     stringBuffer.append(TEXT_4);
68     stringBuffer.append(genModel.getModelName());
69     stringBuffer.append(TEXT_5);
70     if (genModel.isCreationCommands()) {
71     stringBuffer.append(TEXT_6);
72     }
73     stringBuffer.append(TEXT_7);
74     for (Iterator i=genModel.getAllGenAndUsedGenPackagesWithClassifiers().iterator(); i.hasNext();) { GenPackage genPackage = (GenPackage)i.next();
75     if (genPackage.getGenModel() == genModel || !genPackage.getGenModel().hasEditSupport()) {
76     for (Iterator j=genPackage.getGenClasses().iterator(); j.hasNext();) { GenClass genClass = (GenClass)j.next();
77     stringBuffer.append(TEXT_8);
78     stringBuffer.append(genClass.getName());
79     stringBuffer.append(TEXT_9);
80     stringBuffer.append(genClass.getFormattedName());
81     }
82     }
83     }
84     stringBuffer.append(TEXT_10);
85     for (Iterator i=genModel.getFilteredAllGenFeatures().iterator(); i.hasNext();) { GenFeature genFeature = (GenFeature)i.next(); String JavaDoc description = genFeature.getPropertyDescription();
86     stringBuffer.append(TEXT_11);
87     stringBuffer.append(genFeature.getGenClass().getName());
88     stringBuffer.append(TEXT_12);
89     stringBuffer.append(genFeature.getName());
90     stringBuffer.append(TEXT_13);
91     stringBuffer.append(genFeature.getFormattedName());
92     if (description != null && description.length() > 0) {
93     stringBuffer.append(TEXT_14);
94     stringBuffer.append(genFeature.getGenClass().getName());
95     stringBuffer.append(TEXT_15);
96     stringBuffer.append(genFeature.getName());
97     stringBuffer.append(TEXT_16);
98     stringBuffer.append(description);
99     }
100     }
101     stringBuffer.append(TEXT_17);
102     for (Iterator i=genModel.getAllGenAndUsedGenPackagesWithClassifiers().iterator(); i.hasNext();) { GenPackage genPackage = (GenPackage)i.next();
103     if (genPackage.getGenModel() == genModel || !genPackage.getGenModel().hasEditSupport()) {
104     for (Iterator j=genPackage.getGenEnums().iterator(); j.hasNext();) { GenEnum genEnum = (GenEnum)j.next();
105     for (Iterator k=genEnum.getGenEnumLiterals().iterator(); k.hasNext();) { GenEnumLiteral genEnumLiteral = (GenEnumLiteral)k.next();
106     stringBuffer.append(TEXT_18);
107     stringBuffer.append(genEnum.getName());
108     stringBuffer.append(TEXT_19);
109     stringBuffer.append(genEnumLiteral.getName());
110     stringBuffer.append(TEXT_20);
111     stringBuffer.append(genEnumLiteral.getName());
112     }
113     }
114     }
115     }
116     for (Iterator i=genModel.getPropertyCategories().iterator(); i.hasNext();) { String JavaDoc category = (String JavaDoc)i.next();
117     stringBuffer.append(TEXT_21);
118     stringBuffer.append(genModel.getPropertyCategoryKey(category));
119     stringBuffer.append(TEXT_22);
120     stringBuffer.append(category);
121     }
122     stringBuffer.append(TEXT_23);
123     return stringBuffer.toString();
124   }
125 }
126
Popular Tags