| 1 |
<%@ jet package="org.eclipse.emf.codegen.ecore.templates.edit" imports="java.util.* org.eclipse.emf.codegen.ecore.genmodel.*" class="Plugin"%> |
| 2 |
<% |
| 3 |
/** |
| 4 |
* Copyright (c) 2002-2010 IBM Corporation and others. |
| 5 |
* All rights reserved. This program and the accompanying materials |
| 6 |
* are made available under the terms of the Eclipse Public License v2.0 |
| 7 |
* which accompanies this distribution, and is available at |
| 8 |
* http://www.eclipse.org/legal/epl-v20.html |
| 9 |
* |
| 10 |
* Contributors: |
| 11 |
* IBM - Initial API and implementation |
| 12 |
*/ |
| 13 |
%> |
| 14 |
<%GenModel genModel = (GenModel)argument; /* Trick to import java.util.* without warnings */Iterator.class.getName();%> |
| 15 |
<%final boolean isJDK50 = genModel.getComplianceLevel().getValue() >= GenJDKLevel.JDK50;%> |
| 16 |
<%@ include file="../Header.javajetinc"%> |
| 17 |
package <%=genModel.getEditPluginPackageName()%>; |
| 18 |
|
| 19 |
<%genModel.addImport("org.eclipse.emf.common.EMFPlugin");%> |
| 20 |
<%genModel.addImport("org.eclipse.emf.common.util.ResourceLocator");%> |
| 21 |
<%genModel.markImportLocation(stringBuffer);%> |
| 22 |
|
| 23 |
/** |
| 24 |
* This is the central singleton for the <%=genModel.getModelName()%> edit plugin. |
| 25 |
* <!-- begin-user-doc --> |
| 26 |
* <!-- end-user-doc --> |
| 27 |
<%if (genModel.hasAPITags()) {%> |
| 28 |
* <%=genModel.getAPITags(genModel.getIndentation(stringBuffer))%> |
| 29 |
<%}%> |
| 30 |
* @generated |
| 31 |
*/ |
| 32 |
<%if (isJDK50 && genModel.hasAPIDeprecatedTag()) {%> |
| 33 |
@Deprecated |
| 34 |
<%}%> |
| 35 |
public final class <%=genModel.getEditPluginClassName()%> extends EMFPlugin |
| 36 |
{ |
| 37 |
<%if (genModel.hasCopyrightField()) {%> |
| 38 |
/** |
| 39 |
* <!-- begin-user-doc --> |
| 40 |
* <!-- end-user-doc --> |
| 41 |
* @generated |
| 42 |
*/ |
| 43 |
public static final <%=genModel.getImportedName("java.lang.String")%> copyright = <%=genModel.getCopyrightFieldLiteral()%>;<%=genModel.getNonNLS()%> |
| 44 |
|
| 45 |
<%}%> |
| 46 |
/** |
| 47 |
* Keep track of the singleton. |
| 48 |
* <!-- begin-user-doc --> |
| 49 |
* <!-- end-user-doc --> |
| 50 |
* @generated |
| 51 |
*/ |
| 52 |
public static final <%=genModel.getEditPluginClassName()%> INSTANCE = new <%=genModel.getEditPluginClassName()%>(); |
| 53 |
|
| 54 |
<%if (genModel.getRuntimePlatform() != GenRuntimePlatform.GWT) {%> |
| 55 |
/** |
| 56 |
* Keep track of the singleton. |
| 57 |
* <!-- begin-user-doc --> |
| 58 |
* <!-- end-user-doc --> |
| 59 |
* @generated |
| 60 |
*/ |
| 61 |
private static Implementation plugin; |
| 62 |
|
| 63 |
<%}%> |
| 64 |
/** |
| 65 |
* Create the instance. |
| 66 |
* <!-- begin-user-doc --> |
| 67 |
* <!-- end-user-doc --> |
| 68 |
* @generated |
| 69 |
*/ |
| 70 |
public <%=genModel.getEditPluginClassName()%>() |
| 71 |
{ |
| 72 |
super |
| 73 |
(new ResourceLocator [] |
| 74 |
{ |
| 75 |
<%for (String pluginClassName : genModel.getEditResourceDelegateImportedPluginClassNames()) {%> |
| 76 |
<%=pluginClassName%>.INSTANCE, |
| 77 |
<%}%> |
| 78 |
}); |
| 79 |
} |
| 80 |
|
| 81 |
/** |
| 82 |
* Returns the singleton instance of the Eclipse plugin. |
| 83 |
* <!-- begin-user-doc --> |
| 84 |
* <!-- end-user-doc --> |
| 85 |
* @return the singleton instance. |
| 86 |
* @generated |
| 87 |
*/ |
| 88 |
<%if (genModel.useClassOverrideAnnotation()) {%> |
| 89 |
@Override |
| 90 |
<%}%> |
| 91 |
public ResourceLocator getPluginResourceLocator() |
| 92 |
{ |
| 93 |
<%if (genModel.getRuntimePlatform() == GenRuntimePlatform.GWT) {%> |
| 94 |
return null; |
| 95 |
<%} else {%> |
| 96 |
return plugin; |
| 97 |
<%}%> |
| 98 |
} |
| 99 |
|
| 100 |
<%if (genModel.getRuntimePlatform() != GenRuntimePlatform.GWT) {%> |
| 101 |
/** |
| 102 |
* Returns the singleton instance of the Eclipse plugin. |
| 103 |
* <!-- begin-user-doc --> |
| 104 |
* <!-- end-user-doc --> |
| 105 |
* @return the singleton instance. |
| 106 |
* @generated |
| 107 |
*/ |
| 108 |
public static Implementation getPlugin() |
| 109 |
{ |
| 110 |
return plugin; |
| 111 |
} |
| 112 |
|
| 113 |
/** |
| 114 |
* The actual implementation of the Eclipse <b>Plugin</b>. |
| 115 |
* <!-- begin-user-doc --> |
| 116 |
* <!-- end-user-doc --> |
| 117 |
* @generated |
| 118 |
*/ |
| 119 |
public static class Implementation extends EclipsePlugin |
| 120 |
{ |
| 121 |
/** |
| 122 |
* Creates an instance. |
| 123 |
* <!-- begin-user-doc --> |
| 124 |
* <!-- end-user-doc --> |
| 125 |
<%if (genModel.needsRuntimeCompatibility()) {%> |
| 126 |
* @param descriptor the description of the plugin. |
| 127 |
<%}%> |
| 128 |
* @generated |
| 129 |
*/ |
| 130 |
public Implementation(<%if (genModel.needsRuntimeCompatibility()) {%><%=genModel.getImportedName("org.eclipse.core.runtime.IPluginDescriptor")%> descriptor<%}%>) |
| 131 |
{ |
| 132 |
super(<%if (genModel.needsRuntimeCompatibility()) {%>descriptor<%}%>); |
| 133 |
|
| 134 |
// Remember the static instance. |
| 135 |
// |
| 136 |
plugin = this; |
| 137 |
} |
| 138 |
<%if (genModel.isOSGiCompatible()) {%> |
| 139 |
|
| 140 |
/** |
| 141 |
* The actual implementation of the purely OSGi-compatible <b>Bundle Activator</b>. |
| 142 |
* <!-- begin-user-doc --> |
| 143 |
* <!-- end-user-doc --> |
| 144 |
* @generated |
| 145 |
*/ |
| 146 |
public static final class Activator extends <%=genModel.getImportedName("org.eclipse.emf.common.EMFPlugin")%>.OSGiDelegatingBundleActivator |
| 147 |
{ |
| 148 |
<%if (genModel.useClassOverrideAnnotation()) {%> |
| 149 |
@Override |
| 150 |
<%}%> |
| 151 |
protected <%=genModel.getImportedName("org.osgi.framework.BundleActivator")%> createBundle() |
| 152 |
{ |
| 153 |
return new Implementation(); |
| 154 |
} |
| 155 |
} |
| 156 |
<%}%> |
| 157 |
} |
| 158 |
|
| 159 |
<%} else {%> |
| 160 |
/** |
| 161 |
* <!-- begin-user-doc --> |
| 162 |
* <!-- end-user-doc --> |
| 163 |
* @generated |
| 164 |
*/ |
| 165 |
protected static final <%=genModel.getImportedName(genModel.getQualifiedEditPluginClassName() + "Properties")%> PROPERTIES = <%=genModel.getImportedName("com.google.gwt.core.client.GWT")%>.create(<%=genModel.getImportedName(genModel.getQualifiedEditPluginClassName() + "Properties")%>.class); |
| 166 |
|
| 167 |
/** |
| 168 |
* <!-- begin-user-doc --> |
| 169 |
* <!-- end-user-doc --> |
| 170 |
* @generated |
| 171 |
*/ |
| 172 |
@Override |
| 173 |
public String getString(String key, boolean translate) |
| 174 |
{ |
| 175 |
<%boolean first = true; for (GenPackage genPackage : genModel.getAllGenAndUsedGenPackagesWithClassifiers()) {%> |
| 176 |
<%if (genPackage.getGenModel() == genModel || !genPackage.getGenModel().hasEditSupport()) { %> |
| 177 |
<%for (GenClass genClass : genPackage.getGenClasses()) {%> |
| 178 |
<%if (first) { first = false; } else {%>else <%}%>if ("_UI_<%=genClass.getName()%>_type".equals(key)) return PROPERTIES.<%=genClass.getUncapName()%>Type(); |
| 179 |
<%}%> |
| 180 |
<%}%> |
| 181 |
<%}%> |
| 182 |
<%if (first) { first = false; } else {%>else <%}%> if ("_UI_Unknown_type".equals(key)) return PROPERTIES.unknownType(); |
| 183 |
else if ("_UI_Unknown_datatype".equals(key)) return PROPERTIES.unknownDatatype(); |
| 184 |
<%for (GenFeature genFeature : genModel.getFilteredAllGenFeatures()) { String description = genFeature.getPropertyDescription();%> |
| 185 |
else if ("_UI_<%=genFeature.getGenClass().getName()%>_<%=genFeature.getName()%>_feature".equals(key)) return PROPERTIES.<%=genFeature.getGenClass().getUncapName()%>_<%=genFeature.getCapName()%>Feature(); |
| 186 |
<%if (description != null && description.length() > 0) {%> |
| 187 |
else if ("_UI_<%=genFeature.getGenClass().getName()%>_<%=genFeature.getName()%>_description".equals(key)) return PROPERTIES.<%=genFeature.getGenClass().getUncapName()%>_<%=genFeature.getCapName()%>Description(); |
| 188 |
<%}%> |
| 189 |
<%}%> |
| 190 |
else if ("_UI_Unknown_feature".equals(key)) return PROPERTIES.unknownFeature(); |
| 191 |
<%for (GenPackage genPackage : genModel.getAllGenAndUsedGenPackagesWithClassifiers()) {%> |
| 192 |
<%if (genPackage.getGenModel() == genModel || !genPackage.getGenModel().hasEditSupport()) {%> |
| 193 |
<%for (GenEnum genEnum : genPackage.getGenEnums()) {%> |
| 194 |
<%for (GenEnumLiteral genEnumLiteral : genEnum.getGenEnumLiterals()) {%> |
| 195 |
else if ("_UI_<%=genEnum.getName()%>_<%=genEnumLiteral.getName()%>_literal".equals(key)) return PROPERTIES.<%=genEnum.getSafeUncapName()%>_<%=genEnumLiteral.getName()%>Literal(); |
| 196 |
<%}%> |
| 197 |
<%}%> |
| 198 |
<%}%> |
| 199 |
<%}%> |
| 200 |
<%for (String category : genModel.getPropertyCategories()) {%> |
| 201 |
<%=genModel.getPropertyCategoryKey(category)%> = <%=category%> |
| 202 |
else if ("<%=genModel.getPropertyCategoryKey(category)%>".equals(key)) return PROPERTIES.<%=genModel.getPropertyCategoryKey(category)%>(); |
| 203 |
<%}%> |
| 204 |
else return key; |
| 205 |
} |
| 206 |
|
| 207 |
/** |
| 208 |
* <!-- begin-user-doc --> |
| 209 |
* <!-- end-user-doc --> |
| 210 |
* @generated |
| 211 |
*/ |
| 212 |
@Override |
| 213 |
public String getString(String key, Object [] substitutions, boolean translate) |
| 214 |
{ |
| 215 |
<%if (genModel.isCreationCommands()) {%> |
| 216 |
if ("_UI_CreateChild_text".equals(key)) return PROPERTIES.createChildText(substitutions[0]); |
| 217 |
else if ("_UI_CreateChild_text2".equals(key)) return PROPERTIES.createChildText2(substitutions[0], substitutions[1]); |
| 218 |
else if ("_UI_CreateChild_text3".equals(key)) return PROPERTIES.createChildText3(substitutions[1]); |
| 219 |
else if ("_UI_CreateChild_tooltip".equals(key)) return PROPERTIES.createChildTooltip(substitutions[0], substitutions[1]); |
| 220 |
else if ("_UI_CreateChild_description".equals(key)) return PROPERTIES.createChildDescripition(substitutions[0], substitutions[1], substitutions[2]); |
| 221 |
else if ("_UI_CreateSibling_description".equals(key)) return PROPERTIES.createSiblingDescription(substitutions[0], substitutions[1], substitutions[2]); |
| 222 |
<%}%> |
| 223 |
<%if (!genModel.isCreationCommands()) {%>else <%}%>if ("_UI_PropertyDescriptor_description".equals(key)) return PROPERTIES.propertyDescriptorDescription(substitutions[0], substitutions[1]); |
| 224 |
else return key; |
| 225 |
} |
| 226 |
|
| 227 |
/** |
| 228 |
* <!-- begin-user-doc --> |
| 229 |
* <!-- end-user-doc --> |
| 230 |
* @generated |
| 231 |
*/ |
| 232 |
protected static final <%=genModel.getImportedName(genModel.getQualifiedEditPluginClassName() + "Images")%> IMAGES = <%=genModel.getImportedName("com.google.gwt.core.client.GWT")%>.create(<%=genModel.getImportedName(genModel.getQualifiedEditPluginClassName() + "Images")%>.class); |
| 233 |
|
| 234 |
/** |
| 235 |
* <!-- begin-user-doc --> |
| 236 |
* <!-- end-user-doc --> |
| 237 |
* @generated |
| 238 |
*/ |
| 239 |
@Override |
| 240 |
public Object getImage(String key) |
| 241 |
{ |
| 242 |
<%first = true; for (GenPackage genPackage : genModel.getAllGenAndUsedGenPackagesWithClassifiers()) {%> |
| 243 |
<%for (GenClass genClass : genPackage.getGenClasses()) {%> |
| 244 |
<%if (genClass.isImage()) { String image = genClass.getItemIconFileName(); image = image.substring(image.lastIndexOf("/icons/") + 7, image.length() - 4); %> |
| 245 |
<%if (first) { first = false; } else {%>else <%}%>if ("<%=image%>".equals(key)) return IMAGES.<%=genClass.getItemIconAccessorName()%>(); |
| 246 |
<%}%> |
| 247 |
<%}%> |
| 248 |
<%}%> |
| 249 |
<%if (first) { first = false; } else {%>else <%}%>return key; |
| 250 |
} |
| 251 |
|
| 252 |
<%}%> |
| 253 |
} |
| 254 |
<%genModel.emitSortedImports();%> |