| [comment encoding = UTF-8 |
| ******************************************************************************* |
| * Copyright (c) 2008-2009 Obeo. |
| * All rights reserved. This program and the accompanying materials |
| * are made available under the terms of the Eclipse Public License v1.0 |
| * which accompanies this distribution, and is available at |
| * http://www.eclipse.org/legal/epl-v10.html |
| * |
| * Contributors: |
| * Obeo - initial API and implementation |
| ******************************************************************************* |
| /] |
| [module tablecompositionControl('http://www.eclipse.org/emf/2002/Ecore', 'http://www.eclipse.org/emf/eef/components/1.0.0', 'http://www.eclipse.org/emf/eef/views/1.0.0', 'http://www.eclipse.org/emf/eef/mapping/1.0.0', 'http://www.eclipse.org/emf/eef/generation/1.0.0') extends org::eclipse::emf::eef::codegen::widgets::api::widgetControl/] |
| |
| [import org::eclipse::emf::eef::codegen::services::naming /] |
| [import org::eclipse::emf::eef::codegen::services::common /] |
| [import org::eclipse::emf::eef::codegen::services::typeUtils /] |
| [import org::eclipse::emf::eef::codegen::services::filters /] |
| [import org::eclipse::emf::eef::codegen::services::imports /] |
| [import org::eclipse::emf::eef::codegen::services::emfCodeGen /] |
| |
| [comment ===== Case : model = Containment(*) - view = TableComposition or AdvancedTableComposition===== /] |
| [query public validCaseForSimpleReference(editionElement : PropertiesEditionElement) : Boolean = |
| (not editionElement.hasModelNavigation()) |
| and editionElement.model.isContainmentMany() |
| and (editionElement.representationName('TableComposition') or editionElement.representationName('AdvancedTableComposition')) /] |
| |
| [template public additionalComponentField(editionElement : PropertiesEditionElement, view : View, pec : PropertiesEditionComponent) overrides additionalComponentField ? (editionElement.validCaseForSimpleReference())] |
| |
| /** |
| * Settings for [editionElement.name/] ReferencesTable |
| */ |
| protected [include('org.eclipse.emf.eef.runtime.ui.widgets.referencestable.ReferencesTableSettings')/] [editionElement.name.toJavaIdentifier()/]Settings; |
| |
| [/template] |
| |
| [template public declareEObjectUpdater(editionElement : PropertiesEditionElement, view : View, pec : PropertiesEditionComponent) overrides declareEObjectUpdater ? (editionElement.validCaseForSimpleReference())] |
| [editionElement.genericDeclareEObjectUpdater()/] |
| [/template] |
| |
| |
| [template public liveUpdater(editionElement : PropertiesEditionElement, view : View, pec : PropertiesEditionComponent) overrides liveUpdater ? (editionElement.validCaseForSimpleReference())] |
| if ([editionElement.metamodelGetter()/].equals(msg.getFeature()) && isAccessible([editionElement.views->first().editorID()/])) |
| [view.viewIdentifier(pec)/].update[editionElement.views->first().viewPackageSignature()/](); |
| [/template] |
| |
| [template public updater(editionElement : PropertiesEditionElement, view : View, pec : PropertiesEditionComponent) overrides updater ? (editionElement.validCaseForSimpleReference())] |
| if (isAccessible([editionElement.views->first().editorID()/])) { |
| [editionElement.name.toJavaIdentifier()/]Settings = new ReferencesTableSettings([pec.pecModelClass().toJavaIdentifier()/], [editionElement.metamodelGetter()/]); |
| [view.viewIdentifier(pec)/].init[editionElement.views->first().viewPackageSignature()/]([editionElement.name.toJavaIdentifier()/]Settings); |
| } |
| [/template] |
| |
| [template public filterUpdater(editionElement : PropertiesEditionElement, view : View, pec : PropertiesEditionComponent) overrides filterUpdater ? (editionElement.validCaseForSimpleReference())] |
| [editionElement.genericFilterUpdater(view, pec)/] |
| [/template] |
| |
| [comment ===== Case : model = Containment(*) in Simple Navigation - view = TableComposition or AdvancedTableComposition===== /] |
| [query public validCaseForMultipleModelReference(editionElement : PropertiesEditionElement) : Boolean = |
| editionElement.hasModelNavigation() |
| and (editionElement.navigation.oclIsKindOf(navigation::SimpleModelNavigation) and (editionElement.navigation.oclAsType(navigation::SimpleModelNavigation).feature.isContainmentSingle() and editionElement.model.isContainmentMany())) |
| and (editionElement.representationName('TableComposition') or editionElement.representationName('AdvancedTableComposition'))/] |
| |
| [template public additionalComponentField(editionElement : PropertiesEditionElement, view : View, pec : PropertiesEditionComponent) overrides additionalComponentField ? (editionElement.validCaseForMultipleModelReference())] |
| |
| /** |
| * Settings for [editionElement.name/] ReferencesTable |
| */ |
| protected [include('org.eclipse.emf.eef.runtime.ui.widgets.referencestable.ReferencesTableSettings')/] [editionElement.name.toJavaIdentifier()/]Settings; |
| |
| [/template] |
| |
| [template public declareEObjectUpdater(editionElement : PropertiesEditionElement, view : View, pec : PropertiesEditionComponent) overrides declareEObjectUpdater ? (editionElement.validCaseForMultipleModelReference())] |
| [editionElement.genericDeclareEObjectUpdater()/] |
| [/template] |
| |
| [template public liveUpdater(editionElement : PropertiesEditionElement, view : View, pec : PropertiesEditionComponent) overrides liveUpdater ? (editionElement.validCaseForMultipleModelReference())] |
| if ([editionElement.name.toJavaIdentifier()/]Settings.isAffectingFeature((EStructuralFeature)msg.getFeature()) && isAccessible([editionElement.views->first().editorID()/])) |
| [view.viewIdentifier(pec)/].update[editionElement.views->first().viewPackageSignature()/](); |
| [/template] |
| |
| [template public updater(editionElement : PropertiesEditionElement, view : View, pec : PropertiesEditionComponent) overrides updater ? (editionElement.validCaseForMultipleModelReference())] |
| if (isAccessible([editionElement.views->first().editorID()/])) { |
| [editionElement.name.toJavaIdentifier()/]Settings = new ReferencesTableSettings([pec.pecModelClass().toJavaIdentifier()/], [editionElement.navigation.oclAsType(navigation::SimpleModelNavigation).metamodelGetter()/], [editionElement.metamodelGetter()/]); |
| [view.viewIdentifier(pec)/].init[editionElement.views->first().viewPackageSignature()/]([editionElement.name.toJavaIdentifier()/]Settings); |
| } |
| [/template] |
| |
| [template public filterUpdater(editionElement : PropertiesEditionElement, view : View, pec : PropertiesEditionComponent) overrides filterUpdater ? (editionElement.validCaseForMultipleModelReference())] |
| if (isAccessible([editionElement.views->first().editorID()/])) { |
| [view.viewIdentifier(pec)/].addFilterTo[editionElement.views->first().viewPackageSignature()/](new [include('org.eclipse.jface.viewers.ViewerFilter')/]() { |
| |
| /** |
| * {@inheritDoc} |
| * |
| * @see org.eclipse.jface.viewers.ViewerFilter#select(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object) |
| */ |
| public boolean select([include('org.eclipse.jface.viewers.Viewer')/] viewer, Object parentElement, Object element) { |
| [if (editionElement.model.lowerBound = 0)]if (element instanceof String) |
| return element.equals(""); //$NON-NLS-1$ |
| [/if] |
| if (element instanceof [include(editionElement.peeModelQualifiedClass())/]) |
| return true; |
| return element instanceof [include('org.eclipse.emf.ecore.resource.Resource')/]; |
| } |
| |
| }); |
| [for (filter : BindingFilter | editionElement.bindingFilters)] |
| [filter.filterBody(editionElement,view,pec)/] |
| [/for] |
| [if (not editionElement.element.eContainer(PropertiesEditionContext).associatedGenModel().useJMergeForUserCode)] |
| [additionalBusinessFilterProtectedArea(editionElement)/] |
| [/if] |
| } |
| [/template] |
| |
| [comment ===== Case : model = Containment(1) - view = TableComposition or AdvancedTableComposition===== /] |
| [query public validCaseForSingleModelReference(editionElement : PropertiesEditionElement) : Boolean = |
| editionElement.hasModelNavigation() |
| and (editionElement.navigation.oclIsKindOf(navigation::SimpleModelNavigation) and (editionElement.navigation.oclAsType(navigation::SimpleModelNavigation).feature.isContainmentMany() and editionElement.model.isContainmentSingle())) |
| and (editionElement.representationName('TableComposition') or editionElement.representationName('AdvancedTableComposition'))/] |
| |
| [template public additionalComponentField(editionElement : PropertiesEditionElement, view : View, pec : PropertiesEditionComponent) overrides additionalComponentField ? (editionElement.validCaseForSingleModelReference())] |
| |
| /** |
| * Settings for [editionElement.name/] ReferencesTable |
| */ |
| protected [include('org.eclipse.emf.eef.runtime.ui.widgets.referencestable.ReferencesTableSettings')/] [editionElement.name.toJavaIdentifier()/]Settings; |
| |
| [/template] |
| |
| [template public declareEObjectUpdater(editionElement : PropertiesEditionElement, view : View, pec : PropertiesEditionComponent) overrides declareEObjectUpdater ? (editionElement.validCaseForSingleModelReference())] |
| [editionElement.genericDeclareEObjectUpdater()/] |
| [/template] |
| |
| [template public liveUpdater(editionElement : PropertiesEditionElement, view : View, pec : PropertiesEditionComponent) overrides liveUpdater ? (editionElement.validCaseForSingleModelReference())] |
| if ([editionElement.name.toJavaIdentifier()/]Settings.isAffectingFeature((EStructuralFeature)msg.getFeature()) && isAccessible([editionElement.views->first().editorID()/])) |
| [view.viewIdentifier(pec)/].update[editionElement.views->first().viewPackageSignature()/](); |
| [/template] |
| |
| [template public updater(editionElement : PropertiesEditionElement, view : View, pec : PropertiesEditionComponent) overrides updater ? (editionElement.validCaseForSingleModelReference())] |
| if (isAccessible([editionElement.views->first().editorID()/])) { |
| [editionElement.name.toJavaIdentifier()/]Settings = new ReferencesTableSettings([pec.pecModelClass().toJavaIdentifier()/], [editionElement.navigation.oclAsType(navigation::SimpleModelNavigation).metamodelGetter()/], [editionElement.metamodelGetter()/]); |
| [view.viewIdentifier(pec)/].init[editionElement.views->first().viewPackageSignature()/]([editionElement.name.toJavaIdentifier()/]Settings); |
| } |
| [/template] |
| |
| [template public filterUpdater(editionElement : PropertiesEditionElement, view : View, pec : PropertiesEditionComponent) overrides filterUpdater ? (editionElement.validCaseForSingleModelReference())] |
| [editionElement.genericFilterUpdater(view, pec)/] |
| [/template] |
| |
| [template private genericDeclareEObjectUpdater(editionElement : PropertiesEditionElement)] |
| if (event.getKind() == [include('org.eclipse.emf.eef.runtime.impl.notify.PropertiesEditionEvent')/].ADD) { |
| [if (editionElement.model.eType.oclIsTypeOf(EClass))] |
| [include('org.eclipse.emf.eef.runtime.context.impl.EReferencePropertiesEditionContext')/] context = new EReferencePropertiesEditionContext(editingContext, this, [editionElement.name.toJavaIdentifier()/]Settings, editingContext.getAdapterFactory()); |
| [if (editionElement.hasStrictTypingFilter())] |
| [for (eClassifier : EClassifier | editionElement.strictTypingFiltersTypes())] |
| context.addInstanciableTypeFilter(new [include('org.eclipse.emf.eef.runtime.context.impl.EReferencePropertiesEditionContext.InstanciableTypeFilter')/]() { |
| public boolean select([include('org.eclipse.emf.ecore.EClass')/] instanciableType) { |
| return [eClassifier.metamodelGetter()/][addImport(eClassifier.ePackage.qualifiedMetamodelPackage())/] == instanciableType; |
| } |
| }); |
| [/for] |
| [/if] |
| [include('org.eclipse.emf.eef.runtime.providers.PropertiesEditingProvider')/] provider = (PropertiesEditingProvider)editingContext.getAdapterFactory().adapt(semanticObject, PropertiesEditingProvider.class); |
| if (provider != null) { |
| [include('org.eclipse.emf.eef.runtime.policies.PropertiesEditingPolicy')/] policy = provider.getPolicy(context); |
| if (policy instanceof [include('org.eclipse.emf.eef.runtime.policies.impl.CreateEditingPolicy')/]) { |
| policy.execute(); |
| } |
| } |
| [/if] |
| } else if (event.getKind() == PropertiesEditionEvent.EDIT) { |
| [include('org.eclipse.emf.eef.runtime.context.impl.EObjectPropertiesEditionContext')/] context = new EObjectPropertiesEditionContext(editingContext, this, (EObject) event.getNewValue(), editingContext.getAdapterFactory()); |
| [include('org.eclipse.emf.eef.runtime.providers.PropertiesEditingProvider')/] provider = (PropertiesEditingProvider)editingContext.getAdapterFactory().adapt((EObject) event.getNewValue(), PropertiesEditingProvider.class); |
| if (provider != null) { |
| [include('org.eclipse.emf.eef.runtime.policies.PropertiesEditingPolicy')/] editionPolicy = provider.getPolicy(context); |
| if (editionPolicy != null) { |
| editionPolicy.execute(); |
| } |
| } |
| } else if (event.getKind() == PropertiesEditionEvent.REMOVE) { |
| [editionElement.name.toJavaIdentifier()/]Settings.removeFromReference((EObject) event.getNewValue()); |
| } else if (event.getKind() == PropertiesEditionEvent.MOVE) { |
| [editionElement.name.toJavaIdentifier()/]Settings.move(event.getNewIndex(), ([include(editionElement.peeModelQualifiedClass())/]) event.getNewValue()); |
| } |
| [/template] |
| |
| [template private genericFilterUpdater(editionElement : PropertiesEditionElement, view : View, pec : PropertiesEditionComponent)] |
| if (isAccessible([editionElement.views->first().editorID()/])) { |
| [view.viewIdentifier(pec)/].addFilterTo[editionElement.views->first().viewPackageSignature()/](new [include('org.eclipse.jface.viewers.ViewerFilter')/]() { |
| /** |
| * {@inheritDoc} |
| * |
| * @see org.eclipse.jface.viewers.ViewerFilter#select(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object) |
| */ |
| public boolean select([include('org.eclipse.jface.viewers.Viewer')/] viewer, Object parentElement, Object element) { |
| return [if (editionElement.model.lowerBound = 0)](element instanceof String && element.equals("")) || [/if][editionElement.testOnTypes()/];[if (editionElement.model.lowerBound = 0)] //$NON-NLS-1$ [/if] |
| } |
| |
| }); |
| [for (filter : BindingFilter | editionElement.bindingFilters)] |
| [filter.filterBody(editionElement,view,pec)/] |
| [/for] |
| [if (not editionElement.element.eContainer(PropertiesEditionContext).associatedGenModel().useJMergeForUserCode)] |
| [additionalBusinessFilterProtectedArea(editionElement)/] |
| [/if] |
| } |
| [/template] |
| |
| [template private testOnTypes(editionElement : PropertiesEditionElement) post (trim())] |
| [if (editionElement.hasStrictTypingFilter())] |
| [editionElement.strictTypingFiltersTypes().testInstanceOfOnClassifier()->sep(' || ')/] |
| [else] |
| (element instanceof [include(editionElement.peeModelQualifiedClass())/]) |
| [/if] |
| [/template] |
| |
| [template private testInstanceOfOnClassifier(eClassifier : EClassifier) post (trim())] |
| (element instanceof [include(eClassifier.qualifiedName())/]) |
| [/template] |
| |
| [query private hasStrictTypingFilter(editingElement : PropertiesEditionElement) : Boolean = |
| editingElement.bindingFilters->filter(StrictTypingFilter)->notEmpty() |
| /] |
| |
| [query private strictTypingFiltersTypes(editingElement : PropertiesEditionElement) : Sequence(EClassifier) = |
| editingElement.bindingFilters->filter(StrictTypingFilter).type |
| /] |