jlanuti | fed82ab | 2005-12-01 22:03:10 +0000 | [diff] [blame] | 1 | /******************************************************************************* |
| 2 | * Copyright (c) 2005 IBM Corporation and others. |
| 3 | * All rights reserved. This program and the accompanying materials |
| 4 | * are made available under the terms of the Eclipse Public License v1.0 |
| 5 | * which accompanies this distribution, and is available at |
| 6 | * http://www.eclipse.org/legal/epl-v10.html |
| 7 | * |
| 8 | * Contributors: |
| 9 | * IBM Corporation - initial API and implementation |
| 10 | *******************************************************************************/ |
cbridgha | 44a17d7 | 2005-04-04 07:05:01 +0000 | [diff] [blame] | 11 | package org.eclipse.wst.common.componentcore.internal.util; |
cbridgha | f654faf | 2005-02-13 16:27:46 +0000 | [diff] [blame] | 12 | |
| 13 | import org.eclipse.emf.ecore.EStructuralFeature; |
cbridgha | 44a17d7 | 2005-04-04 07:05:01 +0000 | [diff] [blame] | 14 | import org.eclipse.wst.common.componentcore.internal.ComponentcorePackage; |
cbridgha | f654faf | 2005-02-13 16:27:46 +0000 | [diff] [blame] | 15 | import org.eclipse.wst.common.internal.emf.resource.GenericTranslator; |
| 16 | import org.eclipse.wst.common.internal.emf.resource.IDTranslator; |
| 17 | import org.eclipse.wst.common.internal.emf.resource.RootTranslator; |
| 18 | import org.eclipse.wst.common.internal.emf.resource.Translator; |
cbridgha | f654faf | 2005-02-13 16:27:46 +0000 | [diff] [blame] | 19 | |
| 20 | |
| 21 | public class WTPModulesTranslator extends RootTranslator implements WTPModulesXmlMapperI{ |
| 22 | public static WTPModulesTranslator INSTANCE = new WTPModulesTranslator(); |
| 23 | private static Translator[] children; |
cbridgha | 44a17d7 | 2005-04-04 07:05:01 +0000 | [diff] [blame] | 24 | private static final ComponentcorePackage MODULE_CORE_PKG = ComponentcorePackage.eINSTANCE; |
cbridgha | f654faf | 2005-02-13 16:27:46 +0000 | [diff] [blame] | 25 | /** |
| 26 | * @param domNameAndPath |
| 27 | * @param eClass |
| 28 | */ |
| 29 | public WTPModulesTranslator() { |
cbridgha | 44a17d7 | 2005-04-04 07:05:01 +0000 | [diff] [blame] | 30 | super(PROJECT_MODULES, ComponentcorePackage.eINSTANCE.getProjectComponents()); |
cbridgha | dc4c1c6 | 2005-04-27 18:48:57 +0000 | [diff] [blame] | 31 | } |
| 32 | |
| 33 | // public void setMOFValue(Notifier owner, Object value, int newIndex) { |
| 34 | // super.setMOFValue(owner, value, newIndex); |
| 35 | // EObject target = ((EObject)value); |
| 36 | // IProject project = ProjectUtilities.getProject(target); |
| 37 | // if(project != null) |
| 38 | // target.eSet(ComponentcorePackage.eINSTANCE.getProjectComponents_ProjectName(), project.getName()); |
| 39 | // } |
cbridgha | f654faf | 2005-02-13 16:27:46 +0000 | [diff] [blame] | 40 | /* (non-Javadoc) |
| 41 | * @see org.eclipse.wst.common.internal.emf.resource.Translator#getChildren(java.lang.Object, int) |
| 42 | */ |
| 43 | public Translator[] getChildren(Object target, int versionID) { |
| 44 | if(children == null) |
| 45 | children = createWTPModulesTranslator(); |
| 46 | return children; |
| 47 | } |
| 48 | |
| 49 | private static Translator[] createWTPModulesTranslator() { |
| 50 | return new Translator[] { |
| 51 | IDTranslator.INSTANCE, |
cbridgha | 5059b8b | 2005-03-15 02:12:30 +0000 | [diff] [blame] | 52 | createWBModuleTranslator(MODULE_CORE_PKG.getProjectComponents_Components()) |
cbridgha | f654faf | 2005-02-13 16:27:46 +0000 | [diff] [blame] | 53 | }; |
| 54 | } |
| 55 | |
| 56 | /** |
| 57 | * @return |
| 58 | */ |
| 59 | private static Translator createWBModuleTranslator(EStructuralFeature afeature) { |
cbridgha | 44a17d7 | 2005-04-04 07:05:01 +0000 | [diff] [blame] | 60 | GenericTranslator result = new GenericTranslator(WORKBENCH_COMPONENT, afeature); |
cbridgha | f654faf | 2005-02-13 16:27:46 +0000 | [diff] [blame] | 61 | result.setChildren(new Translator[] { |
| 62 | IDTranslator.INSTANCE, |
cbridgha | 5059b8b | 2005-03-15 02:12:30 +0000 | [diff] [blame] | 63 | //new Translator(HANDLE, MODULE_CORE_PKG.getWorkbenchComponent_Handle(), DOM_ATTRIBUTE), REMOVED SINCE HANDLE SHOULD NOW BE DERIVED -MDE |
cbridgha | 44a17d7 | 2005-04-04 07:05:01 +0000 | [diff] [blame] | 64 | new Translator(RUNTIME_NAME, MODULE_CORE_PKG.getWorkbenchComponent_Name(), DOM_ATTRIBUTE), |
cbridgha | 5059b8b | 2005-03-15 02:12:30 +0000 | [diff] [blame] | 65 | createModuleTypeTranslator(MODULE_CORE_PKG.getWorkbenchComponent_ComponentType()), |
| 66 | createWBResourceTranslator(MODULE_CORE_PKG.getWorkbenchComponent_Resources()), |
cbridgha | 76161c6 | 2005-10-18 23:02:29 +0000 | [diff] [blame] | 67 | createDependentModuleTranslator(MODULE_CORE_PKG.getWorkbenchComponent_ReferencedComponents()), |
jlanuti | 138b378 | 2005-12-06 21:18:47 +0000 | [diff] [blame] | 68 | new IPathTranslator(META_RESOURCES, MODULE_CORE_PKG.getWorkbenchComponent_MetadataResources()), |
cbridgha | 76161c6 | 2005-10-18 23:02:29 +0000 | [diff] [blame] | 69 | createPropertiesTranslator(MODULE_CORE_PKG.getWorkbenchComponent_Properties()) |
cbridgha | f654faf | 2005-02-13 16:27:46 +0000 | [diff] [blame] | 70 | }); |
| 71 | return result; |
| 72 | } |
| 73 | private static Translator createModuleTypeTranslator(EStructuralFeature afeature) { |
cbridgha | db5438b | 2005-03-02 00:29:55 +0000 | [diff] [blame] | 74 | GenericTranslator result = new GenericTranslator(MODULE_TYPE, afeature); |
cbridgha | f654faf | 2005-02-13 16:27:46 +0000 | [diff] [blame] | 75 | result.setChildren(new Translator[] { |
cbridgha | 44a17d7 | 2005-04-04 07:05:01 +0000 | [diff] [blame] | 76 | new Translator(COMPONENT_TYPE_ID, MODULE_CORE_PKG.getComponentType_ComponentTypeId(), DOM_ATTRIBUTE), |
cbridgha | b390317 | 2005-03-24 16:12:12 +0000 | [diff] [blame] | 77 | new Translator(META_RESOURCES, MODULE_CORE_PKG.getComponentType_MetadataResources()), |
cbridgha | 44a17d7 | 2005-04-04 07:05:01 +0000 | [diff] [blame] | 78 | new Translator(COMPONENT_TYPE_VERSION, MODULE_CORE_PKG.getComponentType_Version()), |
cbridgha | b390317 | 2005-03-24 16:12:12 +0000 | [diff] [blame] | 79 | createPropertiesTranslator(MODULE_CORE_PKG.getComponentType_Properties()) |
| 80 | |
cbridgha | f654faf | 2005-02-13 16:27:46 +0000 | [diff] [blame] | 81 | }); |
| 82 | return result; |
| 83 | } |
| 84 | |
cbridgha | b390317 | 2005-03-24 16:12:12 +0000 | [diff] [blame] | 85 | private static Translator createPropertiesTranslator(EStructuralFeature afeature){ |
| 86 | GenericTranslator result = new GenericTranslator(PROPERTY, afeature); |
| 87 | result.setChildren(new Translator[] { |
| 88 | new Translator(PROPERTY_NAME, MODULE_CORE_PKG.getProperty_Name(), DOM_ATTRIBUTE ), |
| 89 | new Translator(PROPERTY_VALUE, MODULE_CORE_PKG.getProperty_Value(), DOM_ATTRIBUTE ), |
| 90 | |
| 91 | }); |
| 92 | return result; |
| 93 | } |
| 94 | |
| 95 | |
cbridgha | f654faf | 2005-02-13 16:27:46 +0000 | [diff] [blame] | 96 | private static Translator createDependentModuleTranslator(EStructuralFeature afeature) { |
cbridgha | 44a17d7 | 2005-04-04 07:05:01 +0000 | [diff] [blame] | 97 | GenericTranslator result = new GenericTranslator(REFERENCED_COMPONENT, afeature); |
cbridgha | f654faf | 2005-02-13 16:27:46 +0000 | [diff] [blame] | 98 | result.setChildren(new Translator[] { |
cbridgha | 44a17d7 | 2005-04-04 07:05:01 +0000 | [diff] [blame] | 99 | new IPathTranslator(RUNTIME_PATH, MODULE_CORE_PKG.getReferencedComponent_RuntimePath(), DOM_ATTRIBUTE), |
cbridgha | 5059b8b | 2005-03-15 02:12:30 +0000 | [diff] [blame] | 100 | new URITranslator(HANDLE, MODULE_CORE_PKG.getReferencedComponent_Handle(), DOM_ATTRIBUTE), |
cbridgha | be63a8d | 2005-09-12 02:48:39 +0000 | [diff] [blame] | 101 | new HRefTranslator(DEP_OBJECT,MODULE_CORE_PKG.getReferencedComponent_DependentObject()), |
cbridgha | f654faf | 2005-02-13 16:27:46 +0000 | [diff] [blame] | 102 | new DependencyTypeTranslator() |
| 103 | }); |
| 104 | return result; |
| 105 | } |
| 106 | |
cbridgha | be63a8d | 2005-09-12 02:48:39 +0000 | [diff] [blame] | 107 | |
cbridgha | f654faf | 2005-02-13 16:27:46 +0000 | [diff] [blame] | 108 | private static Translator createWBResourceTranslator(EStructuralFeature afeature) { |
cbridgha | 44a17d7 | 2005-04-04 07:05:01 +0000 | [diff] [blame] | 109 | GenericTranslator result = new GenericTranslator(COMPONENT_RESOURCE, afeature); |
cbridgha | f654faf | 2005-02-13 16:27:46 +0000 | [diff] [blame] | 110 | result.setChildren(new Translator[] { |
| 111 | IDTranslator.INSTANCE, |
cbridgha | 44a17d7 | 2005-04-04 07:05:01 +0000 | [diff] [blame] | 112 | new IPathTranslator(SOURCE_PATH, MODULE_CORE_PKG.getComponentResource_SourcePath(), DOM_ATTRIBUTE), |
| 113 | new IPathTranslator(RUNTIME_PATH, MODULE_CORE_PKG.getComponentResource_RuntimePath(), DOM_ATTRIBUTE), |
cbridgha | 63a483d | 2005-04-06 13:24:45 +0000 | [diff] [blame] | 114 | new Translator(RESOURCE_TYPE, MODULE_CORE_PKG.getComponentResource_ResourceType(), DOM_ATTRIBUTE), |
cbridgha | 5059b8b | 2005-03-15 02:12:30 +0000 | [diff] [blame] | 115 | new Translator(EXCLUSIONS, MODULE_CORE_PKG.getComponentResource_Exclusions()) |
cbridgha | f654faf | 2005-02-13 16:27:46 +0000 | [diff] [blame] | 116 | }); |
| 117 | return result; |
| 118 | } |
| 119 | |
| 120 | } |