Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNathalie Lepine2013-06-27 14:47:41 +0000
committerNathalie Lepine2013-06-27 14:47:41 +0000
commitc586d4d8b78faee0bae48e3cd7263f73d390b267 (patch)
tree4f7644b27aed5c23099528e34cdd2c19df22e845 /plugins
parent805d9de625737bb742ace45fb0ed03612f7f11b3 (diff)
downloadorg.eclipse.eef-c586d4d8b78faee0bae48e3cd7263f73d390b267.tar.gz
org.eclipse.eef-c586d4d8b78faee0bae48e3cd7263f73d390b267.tar.xz
org.eclipse.eef-c586d4d8b78faee0bae48e3cd7263f73d390b267.zip
add new widget LinkEObjetFlatComboViewer
Diffstat (limited to 'plugins')
-rw-r--r--plugins/org.eclipse.emf.eef.codegen/src/org/eclipse/emf/eef/codegen/services/common.mtl6
-rw-r--r--plugins/org.eclipse.emf.eef.codegen/src/org/eclipse/emf/eef/codegen/widgets/impl/eobjectflatcomboviewer/eobjectflatcomboviewerFormImpl.mtl4
-rw-r--r--plugins/org.eclipse.emf.eef.codegen/src/org/eclipse/emf/eef/codegen/widgets/impl/eobjectflatcomboviewer/eobjectflatcomboviewerSWTImpl.mtl4
-rw-r--r--plugins/org.eclipse.emf.eef.codegen/src/org/eclipse/emf/eef/codegen/widgets/impl/linkeobjectflatcomboviewer/linkeobjectflatcomboviewerControl.mtl239
-rw-r--r--plugins/org.eclipse.emf.eef.codegen/src/org/eclipse/emf/eef/codegen/widgets/impl/linkeobjectflatcomboviewer/linkeobjectflatcomboviewerFormImpl.mtl81
-rw-r--r--plugins/org.eclipse.emf.eef.codegen/src/org/eclipse/emf/eef/codegen/widgets/impl/linkeobjectflatcomboviewer/linkeobjectflatcomboviewerGettersSetters.mtl141
-rw-r--r--plugins/org.eclipse.emf.eef.codegen/src/org/eclipse/emf/eef/codegen/widgets/impl/linkeobjectflatcomboviewer/linkeobjectflatcomboviewerSWTImpl.mtl79
-rw-r--r--plugins/org.eclipse.emf.eef.runtime/src/org/eclipse/emf/eef/runtime/ui/widgets/AbstractAdvancedEObjectFlatComboViewer.java392
-rw-r--r--plugins/org.eclipse.emf.eef.runtime/src/org/eclipse/emf/eef/runtime/ui/widgets/AdvancedEObjectFlatComboViewer.java324
-rw-r--r--plugins/org.eclipse.emf.eef.runtime/src/org/eclipse/emf/eef/runtime/ui/widgets/LinkEObjectFlatComboViewer.java175
-rw-r--r--plugins/org.eclipse.emf.eef.runtime/src/org/eclipse/emf/eef/runtime/ui/widgets/LinkReferencesTable.java920
-rw-r--r--plugins/org.eclipse.emf.eef.views/std/EMFProperties.toolkits2
12 files changed, 2047 insertions, 320 deletions
diff --git a/plugins/org.eclipse.emf.eef.codegen/src/org/eclipse/emf/eef/codegen/services/common.mtl b/plugins/org.eclipse.emf.eef.codegen/src/org/eclipse/emf/eef/codegen/services/common.mtl
index 795a43141..9f9a4a547 100644
--- a/plugins/org.eclipse.emf.eef.codegen/src/org/eclipse/emf/eef/codegen/services/common.mtl
+++ b/plugins/org.eclipse.emf.eef.codegen/src/org/eclipse/emf/eef/codegen/services/common.mtl
@@ -226,8 +226,8 @@
or (pee.navigation.oclAsType(navigation::SimpleModelNavigation).feature.isContainmentSingle() and pee.model.isReferenceMany() and (pee.representationName('ReferencesTable') or pee.representationName('AdvancedReferencesTable')))
or (pee.navigation.oclAsType(navigation::SimpleModelNavigation).feature.isContainmentSingle() and pee.model.isContainmentMany() and (pee.representationName('TableComposition') or pee.representationName('AdvancedTableComposition')))
or (pee.navigation.oclAsType(navigation::SimpleModelNavigation).feature.isContainmentMany() and pee.model.isContainmentSingle() and (pee.representationName('TableComposition') or pee.representationName('AdvancedTableComposition')))
- or (pee.navigation.oclAsType(navigation::SimpleModelNavigation).feature.isContainmentSingle() and pee.model.isReferenceSingle() and (pee.representationName('EObjectFlatComboViewer') or pee.representationName('AdvancedEObjectFlatComboViewer')))
- ))) or (pee.model.isContainmentSingle() and (pee.representationName('EObjectFlatComboViewer') or pee.representationName('AdvancedEObjectFlatComboViewer'))))/]
+ or (pee.navigation.oclAsType(navigation::SimpleModelNavigation).feature.isContainmentSingle() and pee.model.isReferenceSingle() and (pee.representationName('EObjectFlatComboViewer') or pee.representationName('AdvancedEObjectFlatComboViewer') or pee.representationName('LinkEObjectFlatComboViewer')))
+ ))) or (pee.model.isContainmentSingle() and (pee.representationName('EObjectFlatComboViewer') or pee.representationName('AdvancedEObjectFlatComboViewer') or pee.representationName('LinkEObjectFlatComboViewer'))))/]
[comment --------------- Common templates --------------- /]
@@ -323,7 +323,7 @@ String
[include('org.eclipse.emf.common.util.Enumerator')/]
[elseif (view.representationName('MultiValuedEditor'))]
[include('org.eclipse.emf.common.util.EList')/]
-[elseif (view.representationName('EObjectFlatComboViewer') or view.representationName('AdvancedEObjectFlatComboViewer') or view.representationName('SingleCompositionViewer') or view.representationName('SingleCompositionEditor'))]
+[elseif (view.representationName('EObjectFlatComboViewer') or view.representationName('LinkEObjectFlatComboViewer') or view.representationName('AdvancedEObjectFlatComboViewer') or view.representationName('SingleCompositionViewer') or view.representationName('SingleCompositionEditor'))]
[include('org.eclipse.emf.ecore.EObject')/]
[elseif (view.representationName('ReferencesTable') or view.representationName('AdvancedReferencesTable') or view.representationName('FlatReferencesTable') or view.representationName('TableComposition') or view.representationName('AdvancedTableComposition'))]
[include('java.util.List')/]
diff --git a/plugins/org.eclipse.emf.eef.codegen/src/org/eclipse/emf/eef/codegen/widgets/impl/eobjectflatcomboviewer/eobjectflatcomboviewerFormImpl.mtl b/plugins/org.eclipse.emf.eef.codegen/src/org/eclipse/emf/eef/codegen/widgets/impl/eobjectflatcomboviewer/eobjectflatcomboviewerFormImpl.mtl
index b035eca1a..66e3f1c4b 100644
--- a/plugins/org.eclipse.emf.eef.codegen/src/org/eclipse/emf/eef/codegen/widgets/impl/eobjectflatcomboviewer/eobjectflatcomboviewerFormImpl.mtl
+++ b/plugins/org.eclipse.emf.eef.codegen/src/org/eclipse/emf/eef/codegen/widgets/impl/eobjectflatcomboviewer/eobjectflatcomboviewerFormImpl.mtl
@@ -122,6 +122,10 @@ return create[editor.name.toJavaClassifier()/]FlatComboViewer(parent, widgetFact
return null;
}
+ public void handleEdit(EObject element) {
+ propertiesEditionComponent.firePropertiesChanged(new PropertiesEditionEvent([editor.editionPart()/].this, [editor.editorID()/], PropertiesEditionEvent.COMMIT, PropertiesEditionEvent.EDIT, null, element));
+ }
+
};
//create widget
[editor.elementEditorName()/] = new AdvancedEObjectFlatComboViewer([editor.owningViewsRepository().messagesProvider()/].[editor.editorKey(editor.owningView())/], resourceSet, [editor.elementEditorName()/]Filter, propertiesEditionComponent.getEditingContext().getAdapterFactory(), listener);
diff --git a/plugins/org.eclipse.emf.eef.codegen/src/org/eclipse/emf/eef/codegen/widgets/impl/eobjectflatcomboviewer/eobjectflatcomboviewerSWTImpl.mtl b/plugins/org.eclipse.emf.eef.codegen/src/org/eclipse/emf/eef/codegen/widgets/impl/eobjectflatcomboviewer/eobjectflatcomboviewerSWTImpl.mtl
index 41c9db768..f4d8a87b6 100644
--- a/plugins/org.eclipse.emf.eef.codegen/src/org/eclipse/emf/eef/codegen/widgets/impl/eobjectflatcomboviewer/eobjectflatcomboviewerSWTImpl.mtl
+++ b/plugins/org.eclipse.emf.eef.codegen/src/org/eclipse/emf/eef/codegen/widgets/impl/eobjectflatcomboviewer/eobjectflatcomboviewerSWTImpl.mtl
@@ -112,6 +112,10 @@ return create[editor.name.toJavaClassifier()/]AdvancedFlatComboViewer(parent);
propertiesEditionComponent.firePropertiesChanged(new PropertiesEditionEvent([editor.editionPart()/].this, [editor.editorID()/], PropertiesEditionEvent.COMMIT, PropertiesEditionEvent.ADD, null, null));
return null;
}
+
+ public void handleEdit(EObject element) {
+ propertiesEditionComponent.firePropertiesChanged(new PropertiesEditionEvent([editor.editionPart()/].this, [editor.editorID()/], PropertiesEditionEvent.COMMIT, PropertiesEditionEvent.EDIT, null, element));
+ }
};
//create widget
[editor.elementEditorName()/] = new AdvancedEObjectFlatComboViewer(getDescription([editor.editorID()/], [editor.owningViewsRepository().messagesProvider()/].[editor.editorKey(editor.owningView())/]), resourceSet, [editor.elementEditorName()/]Filter, propertiesEditionComponent.getEditingContext().getAdapterFactory(), listener);
diff --git a/plugins/org.eclipse.emf.eef.codegen/src/org/eclipse/emf/eef/codegen/widgets/impl/linkeobjectflatcomboviewer/linkeobjectflatcomboviewerControl.mtl b/plugins/org.eclipse.emf.eef.codegen/src/org/eclipse/emf/eef/codegen/widgets/impl/linkeobjectflatcomboviewer/linkeobjectflatcomboviewerControl.mtl
new file mode 100644
index 000000000..17be18431
--- /dev/null
+++ b/plugins/org.eclipse.emf.eef.codegen/src/org/eclipse/emf/eef/codegen/widgets/impl/linkeobjectflatcomboviewer/linkeobjectflatcomboviewerControl.mtl
@@ -0,0 +1,239 @@
+[comment encoding = UTF-8
+ *******************************************************************************
+ * Copyright (c) 2008-2013 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 linkeobjectflatcomboviewerControl('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/]
+
+[comment ===== Case : model = Reference(1) - view = LinkEObjectFlatComboViewer ===== /]
+[query public validCaseForSingleReference(editionElement : PropertiesEditionElement) : Boolean =
+ (not editionElement.hasModelNavigation())
+ and editionElement.model.isReferenceSingle()
+ and (editionElement.representationName('LinkEObjectFlatComboViewer'))/]
+
+[template public additionalComponentField(editionElement : PropertiesEditionElement, view : View, pec : PropertiesEditionComponent) overrides additionalComponentField ? (editionElement.validCaseForSingleReference())]
+
+/**
+ * Settings for [editionElement.name/] LinkEObjectFlatComboViewer
+ */
+private [include('org.eclipse.emf.eef.runtime.ui.widgets.eobjflatcombo.EObjectFlatComboSettings')/] [editionElement.name.toJavaIdentifier()/]Settings;
+
+[/template]
+
+[template public declareEObjectUpdater(editionElement : PropertiesEditionElement, view : View, pec : PropertiesEditionComponent) overrides declareEObjectUpdater ? (editionElement.validCaseForSingleReference())]
+if (event.getKind() == [include('org.eclipse.emf.eef.runtime.impl.notify.PropertiesEditionEvent')/].SET) {
+ [editionElement.name.toJavaIdentifier()/]Settings.setToReference(([include(editionElement.peeModelQualifiedClass())/])event.getNewValue());
+} else if (event.getKind() == PropertiesEditionEvent.EDIT) {
+ EObjectPropertiesEditionContext context = new EObjectPropertiesEditionContext(editingContext, this, (EObject) event.getNewValue(), editingContext.getAdapterFactory());
+ PropertiesEditingProvider provider = (PropertiesEditingProvider)editingContext.getAdapterFactory().adapt((EObject) event.getNewValue(), PropertiesEditingProvider.class);
+ if (provider != null) {
+ PropertiesEditingPolicy editionPolicy = provider.getPolicy(context);
+ if (editionPolicy != null) {
+ editionPolicy.execute();
+ }
+ }
+} else if (event.getKind() == PropertiesEditionEvent.ADD) {
+ [if (editionElement.model.eType.oclIsTypeOf(EClass))]
+ [if (not editionElement.model.eType.oclAsType(EClass).abstract)]
+ [include(editionElement.peeModelQualifiedClass())/] eObject = [editionElement.factoryCreator()/];
+ [include('org.eclipse.emf.eef.runtime.context.impl.EObjectPropertiesEditionContext')/] context = new EObjectPropertiesEditionContext(editingContext, this, eObject, editingContext.getAdapterFactory());
+ [include('org.eclipse.emf.eef.runtime.providers.PropertiesEditingProvider')/] provider = (PropertiesEditingProvider)editingContext.getAdapterFactory().adapt(eObject, PropertiesEditingProvider.class);
+ if (provider != null) {
+ [include('org.eclipse.emf.eef.runtime.policies.PropertiesEditingPolicy')/] policy = provider.getPolicy(context);
+ if (policy != null) {
+ policy.execute();
+ }
+ }
+ [editionElement.name.toJavaIdentifier()/]Settings.setToReference(eObject);
+ [else]
+ [include('org.eclipse.emf.eef.runtime.context.impl.EReferencePropertiesEditionContext')/] context = new EReferencePropertiesEditionContext(editingContext, this, [editionElement.name.toJavaIdentifier()/]Settings, editingContext.getAdapterFactory());
+ [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]
+ [/if]
+}
+[/template]
+
+[template public liveUpdater(editionElement : PropertiesEditionElement, view : View, pec : PropertiesEditionComponent) overrides liveUpdater ? (editionElement.validCaseForSingleReference())]
+if ([editionElement.metamodelGetter()/].equals(msg.getFeature()) && [view.viewIdentifier(pec)/] != null && isAccessible([editionElement.views->first().editorID()/]))
+ [view.viewIdentifier(pec)/].[editionElement.views->first().viewPackageSetter()/](([editionElement.views->first().toJavaType().trim()/])msg.getNewValue());
+[/template]
+
+[template public updater(editionElement : PropertiesEditionElement, view : View, pec : PropertiesEditionComponent) overrides updater ? (editionElement.validCaseForSingleReference()) ]
+if (isAccessible([editionElement.views->first().editorID()/])) {
+ // init part
+ [editionElement.name.toJavaIdentifier()/]Settings = new EObjectFlatComboSettings([pec.pecModelClass().toJavaIdentifier()/], [editionElement.metamodelGetter()/]);
+ [view.viewIdentifier(pec)/].init[editionElement.views->first().viewPackageSignature()/]([editionElement.name.toJavaIdentifier()/]Settings);
+ // set the button mode
+ [view.viewIdentifier(pec)/].[editionElement.views->first().viewPackageSetter()/]ButtonMode([include('org.eclipse.emf.eef.runtime.ui.widgets.ButtonsModeEnum')/].BROWSE);
+}
+[/template]
+
+[template public filterUpdater(editionElement : PropertiesEditionElement, view : View, pec : PropertiesEditionComponent) overrides filterUpdater ? (not editionElement.hasModelNavigation() and editionElement.model.isReferenceSingle() and (editionElement.representationName('LinkEObjectFlatComboViewer')))]
+[/template]
+
+[comment ===== Case : model = Simple Navigation A (0-1) -> B (0-1) -> C - view = LinkEObjectFlatComboViewer ===== /]
+[query public validCaseForContainmentNavigation(editionElement : PropertiesEditionElement) : Boolean =
+ editionElement.hasModelNavigation()
+ and (editionElement.navigation.oclIsKindOf(navigation::SimpleModelNavigation) and (editionElement.navigation.oclAsType(navigation::SimpleModelNavigation).feature.isContainmentSingle() and editionElement.model.isReferenceSingle()))
+ and (editionElement.representationName('LinkEObjectFlatComboViewer')) /]
+
+[template public additionalComponentField(editionElement : PropertiesEditionElement, view : View, pec : PropertiesEditionComponent) overrides additionalComponentField ? (editionElement.validCaseForContainmentNavigation())]
+
+/**
+ * Settings for [editionElement.name/] LinkEObjectFlatComboViewer
+ */
+private [include('org.eclipse.emf.eef.runtime.ui.widgets.eobjflatcombo.EObjectFlatComboSettings')/] [editionElement.name.toJavaIdentifier()/]Settings;
+
+[/template]
+
+[template public declareEObjectUpdater(editionElement : PropertiesEditionElement, view : View, pec : PropertiesEditionComponent) overrides declareEObjectUpdater ? (editionElement.validCaseForContainmentNavigation())]
+if (event.getKind() == [include('org.eclipse.emf.eef.runtime.impl.notify.PropertiesEditionEvent')/].SET) {
+ [editionElement.name.toJavaIdentifier()/]Settings.setToReference(([include(editionElement.peeModelQualifiedClass())/])event.getNewValue());
+} else if (event.getKind() == PropertiesEditionEvent.EDIT) {
+ EObjectPropertiesEditionContext context = new EObjectPropertiesEditionContext(editingContext, this, (EObject) event.getNewValue(), editingContext.getAdapterFactory());
+ PropertiesEditingProvider provider = (PropertiesEditingProvider)editingContext.getAdapterFactory().adapt((EObject) event.getNewValue(), PropertiesEditingProvider.class);
+ if (provider != null) {
+ PropertiesEditingPolicy editionPolicy = provider.getPolicy(context);
+ if (editionPolicy != null) {
+ editionPolicy.execute();
+ }
+ }
+} else if (event.getKind() == PropertiesEditionEvent.ADD) {
+ [if (editionElement.model.eType.oclIsTypeOf(EClass))]
+ [if (not editionElement.model.eType.oclAsType(EClass).abstract)]
+ [include(editionElement.peeModelQualifiedClass())/] eObject = [editionElement.factoryCreator()/];
+ [include('org.eclipse.emf.eef.runtime.context.impl.EObjectPropertiesEditionContext')/] context = new EObjectPropertiesEditionContext(editingContext, this, eObject, editingContext.getAdapterFactory());
+ [include('org.eclipse.emf.eef.runtime.providers.PropertiesEditingProvider')/] provider = (PropertiesEditingProvider)editingContext.getAdapterFactory().adapt(eObject, PropertiesEditingProvider.class);
+ if (provider != null) {
+ [include('org.eclipse.emf.eef.runtime.policies.PropertiesEditingPolicy')/] policy = provider.getPolicy(context);
+ if (policy != null) {
+ policy.execute();
+ }
+ }
+ [editionElement.name.toJavaIdentifier()/]Settings.setToReference(eObject);
+ [else]
+ [include('org.eclipse.emf.eef.runtime.context.impl.EReferencePropertiesEditionContext')/] context = new EReferencePropertiesEditionContext(editingContext, this, [editionElement.name.toJavaIdentifier()/]Settings, editingContext.getAdapterFactory());
+ [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]
+ [/if]
+}
+[/template]
+
+[template public liveUpdater(editionElement : PropertiesEditionElement, view : View, pec : PropertiesEditionComponent) overrides liveUpdater ? (editionElement.validCaseForContainmentNavigation())]
+if ([editionElement.metamodelGetter()/].equals(msg.getFeature()) && [view.viewIdentifier(pec)/] != null && isAccessible([editionElement.views->first().editorID()/]))
+ [view.viewIdentifier(pec)/].[editionElement.views->first().viewPackageSetter()/](([editionElement.views->first().toJavaType().trim()/])msg.getNewValue());
+[/template]
+
+[template public updater(editionElement : PropertiesEditionElement, view : View, pec : PropertiesEditionComponent) overrides updater ? (editionElement.validCaseForContainmentNavigation())]
+if (isAccessible([editionElement.views->first().editorID()/])) {
+ // init part
+ [editionElement.name.toJavaIdentifier()/]Settings = new EObjectFlatComboSettings([pec.pecModelClass().toJavaIdentifier()/], [editionElement.navigation.oclAsType(navigation::SimpleModelNavigation).metamodelGetter()/], [editionElement.metamodelGetter()/]);
+ [view.viewIdentifier(pec)/].init[editionElement.views->first().viewPackageSignature()/]([editionElement.name.toJavaIdentifier()/]Settings);
+ // set the button mode
+ [view.viewIdentifier(pec)/].[editionElement.views->first().viewPackageSetter()/]ButtonMode([include('org.eclipse.emf.eef.runtime.ui.widgets.ButtonsModeEnum')/].BROWSE);
+}
+[/template]
+
+[template public filterUpdater(editionElement : PropertiesEditionElement, view : View, pec : PropertiesEditionComponent) overrides filterUpdater ? (editionElement.hasModelNavigation() and editionElement.navigation.oclIsKindOf(navigation::SimpleModelNavigation) and (editionElement.navigation.oclAsType(navigation::SimpleModelNavigation).feature.isContainmentSingle() and editionElement.model.isReferenceSingle() and (editionElement.representationName('LinkEObjectFlatComboViewer'))))]
+if (isAccessible([editionElement.views->first().editorID()/])) {
+ [view.viewIdentifier(pec)/].addFilterTo[editionElement.views->first().viewPackageSignature()/](new [include('org.eclipse.emf.eef.runtime.impl.filters.EObjectFilter')/]([editionElement.metamodelTypeGetter()/]));
+}
+[/template]
+
+[comment ===== Case : model = Containment(1), Simple navigation or not - view = LinkEObjectFlatComboViewer ===== /]
+[query public validCaseForContainment(editionElement : PropertiesEditionElement) : Boolean =
+ editionElement.model.isContainmentSingle()
+ and (editionElement.representationName('LinkEObjectFlatComboViewer')) /]
+
+[template public additionalComponentField(editionElement : PropertiesEditionElement, view : View, pec : PropertiesEditionComponent) overrides additionalComponentField ? (editionElement.validCaseForContainment())]
+
+/**
+ * Settings for [editionElement.name/] EObjectFlatComboViewer
+ */
+private [include('org.eclipse.emf.eef.runtime.ui.widgets.eobjflatcombo.EObjectFlatComboSettings')/] [editionElement.name.toJavaIdentifier()/]Settings;
+
+[/template]
+
+[template public declareEObjectUpdater(editionElement : PropertiesEditionElement, view : View, pec : PropertiesEditionComponent) overrides declareEObjectUpdater ? (editionElement.validCaseForContainment())]
+if (event.getKind() == [include('org.eclipse.emf.eef.runtime.impl.notify.PropertiesEditionEvent')/].SET) {
+ [editionElement.name.toJavaIdentifier()/]Settings.setToReference(([include(editionElement.peeModelQualifiedClass())/])event.getNewValue());
+} else if (event.getKind() == PropertiesEditionEvent.EDIT) {
+ EObjectPropertiesEditionContext context = new EObjectPropertiesEditionContext(editingContext, this, (EObject) event.getNewValue(), editingContext.getAdapterFactory());
+ PropertiesEditingProvider provider = (PropertiesEditingProvider)editingContext.getAdapterFactory().adapt((EObject) event.getNewValue(), PropertiesEditingProvider.class);
+ if (provider != null) {
+ PropertiesEditingPolicy editionPolicy = provider.getPolicy(context);
+ if (editionPolicy != null) {
+ editionPolicy.execute();
+ }
+ }
+} else if (event.getKind() == PropertiesEditionEvent.ADD) {
+ [if (editionElement.model.eType.oclIsTypeOf(EClass))]
+ [if (not editionElement.model.eType.oclAsType(EClass).abstract)]
+ [include(editionElement.peeModelQualifiedClass())/] eObject = [editionElement.factoryCreator()/];
+ [include('org.eclipse.emf.eef.runtime.context.impl.EObjectPropertiesEditionContext')/] context = new EObjectPropertiesEditionContext(editingContext, this, eObject, editingContext.getAdapterFactory());
+ [include('org.eclipse.emf.eef.runtime.providers.PropertiesEditingProvider')/] provider = (PropertiesEditingProvider)editingContext.getAdapterFactory().adapt(eObject, PropertiesEditingProvider.class);
+ if (provider != null) {
+ [include('org.eclipse.emf.eef.runtime.policies.PropertiesEditingPolicy')/] policy = provider.getPolicy(context);
+ if (policy != null) {
+ policy.execute();
+ }
+ }
+ [editionElement.name.toJavaIdentifier()/]Settings.setToReference(eObject);
+ [else]
+ [include('org.eclipse.emf.eef.runtime.context.impl.EReferencePropertiesEditionContext')/] context = new EReferencePropertiesEditionContext(editingContext, this, [editionElement.name.toJavaIdentifier()/]Settings, editingContext.getAdapterFactory());
+ [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]
+ [/if]
+}
+[/template]
+
+[template public liveUpdater(editionElement : PropertiesEditionElement, view : View, pec : PropertiesEditionComponent) overrides liveUpdater ? (editionElement.validCaseForContainment())]
+if ([editionElement.metamodelGetter()/].equals(msg.getFeature()) && [view.viewIdentifier(pec)/] != null && isAccessible([editionElement.views->first().editorID()/]))
+ [view.viewIdentifier(pec)/].[editionElement.views->first().viewPackageSetter()/](([editionElement.views->first().toJavaType().trim()/])msg.getNewValue());
+[/template]
+
+
+[template public updater(editionElement : PropertiesEditionElement, view : View, pec : PropertiesEditionComponent) overrides updater ? (editionElement.validCaseForContainment() and not editionElement.hasModelNavigation())]
+if (isAccessible([editionElement.views->first().editorID()/])) {
+ // init part
+ [editionElement.name.toJavaIdentifier()/]Settings = new EObjectFlatComboSettings([pec.pecModelClass().toJavaIdentifier()/], [editionElement.metamodelGetter()/]);
+ [view.viewIdentifier(pec)/].init[editionElement.views->first().viewPackageSignature()/]([editionElement.name.toJavaIdentifier()/]Settings);
+ // set the button mode
+ [view.viewIdentifier(pec)/].[editionElement.views->first().viewPackageSetter()/]ButtonMode([include('org.eclipse.emf.eef.runtime.ui.widgets.ButtonsModeEnum')/].CREATE);
+}
+[/template]
+
+[template public filterUpdater(editionElement : PropertiesEditionElement, view : View, pec : PropertiesEditionComponent) overrides filterUpdater ? (editionElement.validCaseForContainment())]
+[comment no filters on creation/]
+[/template]
diff --git a/plugins/org.eclipse.emf.eef.codegen/src/org/eclipse/emf/eef/codegen/widgets/impl/linkeobjectflatcomboviewer/linkeobjectflatcomboviewerFormImpl.mtl b/plugins/org.eclipse.emf.eef.codegen/src/org/eclipse/emf/eef/codegen/widgets/impl/linkeobjectflatcomboviewer/linkeobjectflatcomboviewerFormImpl.mtl
new file mode 100644
index 000000000..3a0b76f5f
--- /dev/null
+++ b/plugins/org.eclipse.emf.eef.codegen/src/org/eclipse/emf/eef/codegen/widgets/impl/linkeobjectflatcomboviewer/linkeobjectflatcomboviewerFormImpl.mtl
@@ -0,0 +1,81 @@
+[comment encoding = UTF-8
+ *******************************************************************************
+ * Copyright (c) 2008-2013 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 linkeobjectflatcomboviewerFormImpl('http://www.eclipse.org/emf/eef/views/1.0.0', 'http://www.eclipse.org/emf/eef/components/1.0.0', 'http://www.eclipse.org/emf/2002/Ecore', 'http://www.eclipse.org/emf/eef/generation/1.0.0') extends org::eclipse::emf::eef::codegen::widgets::api::widgetFormImpl/]
+
+[import org::eclipse::emf::eef::codegen::services::common /]
+[import org::eclipse::emf::eef::codegen::services::naming /]
+[import org::eclipse::emf::eef::codegen::services::viewCommon /]
+[import org::eclipse::emf::eef::codegen::services::imports/]
+
+[comment ===== Case Widget = AdvancedEObjectFlatComboViewer ===== /]
+[template public manageImports(widget : Widget, pec : PropertiesEditionComponent, view : View, basePackage : String) overrides manageImports ? (widget.name = 'LinkEObjectFlatComboViewer')]
+[pec.addImports(Sequence{
+ 'org.eclipse.swt.widgets.Composite',
+ 'org.eclipse.emf.ecore.EObject',
+ 'org.eclipse.emf.eef.runtime.impl.notify.PropertiesEditionEvent',
+ 'org.eclipse.emf.eef.runtime.ui.widgets.LinkEObjectFlatComboViewer.EObjectFlatComboViewerListener',
+ 'org.eclipse.emf.eef.runtime.ui.widgets.FormUtils',
+ 'org.eclipse.swt.layout.GridData'})/]
+[/template]
+
+[template public widgetDeclaration(editor : ElementEditor) overrides widgetDeclaration ? (editor.representation.name = 'LinkEObjectFlatComboViewer')]
+ protected [include('org.eclipse.emf.eef.runtime.ui.widgets.LinkEObjectFlatComboViewer')/] [editor.elementEditorName()/];
+ protected [include('org.eclipse.jface.viewers.ViewerFilter')/] [editor.elementEditorName()/]Filter;
+[/template]
+
+[template public implementation(editor : ElementEditor) overrides implementation ? (editor.representation.name = 'LinkEObjectFlatComboViewer')]
+return create[editor.name.toJavaClassifier()/]TypeFlatComboViewer(parent, widgetFactory);
+[/template]
+
+[template public additionalImplementation(editor : ElementEditor, pec : PropertiesEditionComponent, inputPEC: PropertiesEditionComponent) overrides additionalImplementation ? (editor.representation.name = 'LinkEObjectFlatComboViewer')]
+ /**
+ * @param parent the parent composite
+ * @param widgetFactory factory to use to instanciante widget of the form
+ * [editor.owningViewsRepository().associatedGenModel().generationMark()/]
+ */
+ protected Composite create[editor.name.toJavaClassifier()/]TypeFlatComboViewer(Composite parent, FormToolkit widgetFactory) {
+ [if (editor.nameAsLabel)]
+ FormUtils.createPartLabel(widgetFactory, parent, [include(editor.owningViewsRepository().qualifiedMessagesProvider())/].[editor.editorKey(editor.owningView())/], propertiesEditionComponent.isRequired([editor.editorID()/], [editor.owningViewsRepository().vrClass()/].FORM_KIND));
+ [else]
+ createDescription(parent, [editor.editorID()/], [include(editor.owningViewsRepository().qualifiedMessagesProvider())/].[editor.editorKey(editor.owningView())/]);
+ [/if]
+ // create callback listener
+ EObjectFlatComboViewerListener listener = new EObjectFlatComboViewerListener(){
+ public void handleSet(EObject element){
+ propertiesEditionComponent.firePropertiesChanged(new PropertiesEditionEvent([editor.editionPart()/].this, [editor.editorID()/], PropertiesEditionEvent.COMMIT, PropertiesEditionEvent.SET, null, element));
+ }
+ public void navigateTo(EObject element){ }
+
+ public EObject handleCreate() {
+ propertiesEditionComponent.firePropertiesChanged(new PropertiesEditionEvent([editor.editionPart()/].this, [editor.editorID()/], PropertiesEditionEvent.COMMIT, PropertiesEditionEvent.ADD, null, null));
+ return null;
+ }
+
+ public void handleEdit(EObject element) {
+ propertiesEditionComponent.firePropertiesChanged(new PropertiesEditionEvent([editor.editionPart()/].this, [editor.editorID()/], PropertiesEditionEvent.COMMIT, PropertiesEditionEvent.EDIT, null, element));
+ }
+ };
+ //create widget
+ [editor.elementEditorName()/] = new LinkEObjectFlatComboViewer([editor.owningViewsRepository().messagesProvider()/].[editor.editorKey(editor.owningView())/], resourceSet, [editor.elementEditorName()/]Filter, propertiesEditionComponent.getEditingContext().getAdapterFactory(), listener);
+ [editor.elementEditorName()/].createControls(parent, widgetFactory);
+ GridData [editor.elementEditorName()/]Data = new GridData(GridData.FILL_HORIZONTAL);
+ [editor.elementEditorName()/].setLayoutData([editor.elementEditorName()/]Data);
+ [editor.elementEditorName()/].setID([editor.editorID()/]);
+ FormUtils.createHelpButton(widgetFactory, parent, propertiesEditionComponent.getHelpContent([editor.editorID()/], [editor.owningViewsRepository().vrClass()/].FORM_KIND), null); //$NON-NLS-1$
+ // [protected ('for create'.concat(editor.name.toJavaClassifier()).concat('TypeFlatComboViewer'))]
+
+ // [/protected]
+ return parent;
+ }
+
+[/template]
diff --git a/plugins/org.eclipse.emf.eef.codegen/src/org/eclipse/emf/eef/codegen/widgets/impl/linkeobjectflatcomboviewer/linkeobjectflatcomboviewerGettersSetters.mtl b/plugins/org.eclipse.emf.eef.codegen/src/org/eclipse/emf/eef/codegen/widgets/impl/linkeobjectflatcomboviewer/linkeobjectflatcomboviewerGettersSetters.mtl
new file mode 100644
index 000000000..76ad60d94
--- /dev/null
+++ b/plugins/org.eclipse.emf.eef.codegen/src/org/eclipse/emf/eef/codegen/widgets/impl/linkeobjectflatcomboviewer/linkeobjectflatcomboviewerGettersSetters.mtl
@@ -0,0 +1,141 @@
+[comment encoding = UTF-8
+ *******************************************************************************
+ * Copyright (c) 2008-2013 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 linkeobjectflatcomboviewerGettersSetters('http://www.eclipse.org/emf/eef/views/1.0.0') extends org::eclipse::emf::eef::codegen::widgets::api::widgetGettersSetters/]
+
+[import org::eclipse::emf::eef::codegen::services::common /]
+[import org::eclipse::emf::eef::codegen::services::naming /]
+[import org::eclipse::emf::eef::codegen::widgets::api::widgetGettersSetters /]
+[import org::eclipse::emf::eef::codegen::services::imports /]
+
+[template public setterDeclaration(elementEditor : ElementEditor) overrides setterDeclaration ? (elementEditor.representationName('LinkEObjectFlatComboViewer'))]
+[elementEditor.initSignatureDocumentation()/]
+[elementEditor.initSignature()/];
+
+[elementEditor.setterSignatureDocumentation()/]
+[elementEditor.setterSignature()/];
+
+[elementEditor.setterButtonModeSignatureDocumentation()/]
+[elementEditor.setterButtonModeSignature()/];
+
+[elementEditor.addFilterSignatureDocumentation()/]
+[elementEditor.addFilterSignature()/];
+
+[elementEditor.addBusinessFilterSignatureDocumentation()/]
+[elementEditor.addBusinessFilterSignature()/];
+[/template]
+
+[template public initSignatureDocumentation(elementEditor : ElementEditor) overrides initSignatureDocumentation ? (elementEditor.representationName('TypeAdvancedEObjectFlatComboViewer'))]
+ /**
+ * Init the [elementEditor.name/]
+ * @param settings the combo setting
+ */
+[/template]
+
+[template public initSignature(elementEditor : ElementEditor) overrides initSignature ? (elementEditor.representationName('LinkEObjectFlatComboViewer'))]
+ public void init[elementEditor.viewPackageSignature()/]([include('org.eclipse.emf.eef.runtime.ui.widgets.eobjflatcombo.EObjectFlatComboSettings')/] settings)
+[/template]
+
+[template public getterSignatureImplementation(elementEditor : ElementEditor) overrides getterSignatureImplementation ? (elementEditor.representationName('LinkEObjectFlatComboViewer'))]
+[elementEditor.getterSignature()/] {
+ return [elementEditor.elementEditorName()/].getSelection();
+ }
+[/template]
+
+[template public setterImplementation(elementEditor : ElementEditor, fullInterfacePath : String) overrides setterImplementation ? (elementEditor.representationName('LinkEObjectFlatComboViewer'))]
+[initSignatureDocumentationImplementation(elementEditor, fullInterfacePath)/]
+[elementEditor.initSignatureImplementation()/]
+
+[setterSignatureDocumentationImplementation(elementEditor, fullInterfacePath)/]
+[elementEditor.setterSignatureImplementation()/]
+
+[setterButtonModeSignatureDocumentationImplementation(elementEditor, fullInterfacePath)/]
+[elementEditor.setterButtonModeSignatureImplementation()/]
+
+[addFilterSignatureDocumentationImplementation(elementEditor, fullInterfacePath)/]
+[elementEditor.addFilterSignatureImplementation()/]
+
+[addBusinessFilterSignatureDocumentationImplementation(elementEditor, fullInterfacePath)/]
+[elementEditor.addBusinessFilterSignatureImplementation()/]
+[/template]
+
+[template public setterImplementationDelegate(elementEditor : ElementEditor, fullInterfacePath : String, referencedView : View) overrides setterImplementationDelegate ? (elementEditor.representationName('LinkEObjectFlatComboViewer'))]
+[initSignatureDocumentationImplementation(elementEditor, fullInterfacePath)/]
+[elementEditor.initSignature()/] {
+ [referencedView.name.toJavaIdentifier()/]PropertiesEditionPart.init[elementEditor.viewPackageSignature()/](settings);
+ }
+
+[setterSignatureDocumentationImplementation(elementEditor, fullInterfacePath)/]
+[elementEditor.setterSignature()/] {
+ [referencedView.name.toJavaIdentifier()/]PropertiesEditionPart.[elementEditor.viewPackageSetter()/](newValue);
+ }
+
+[setterButtonModeSignatureDocumentationImplementation(elementEditor, fullInterfacePath)/]
+[elementEditor.setterButtonModeSignature()/] {
+ [referencedView.name.toJavaIdentifier()/]PropertiesEditionPart.[elementEditor.viewPackageSetter()/]ButtonMode(newValue);
+ }
+
+[addFilterSignatureDocumentationImplementation(elementEditor, fullInterfacePath)/]
+[elementEditor.addFilterSignature()/] {
+ [referencedView.name.toJavaIdentifier()/]PropertiesEditionPart.addFilterTo[elementEditor.viewPackageSignature()/](filter);
+ }
+
+[addBusinessFilterSignatureDocumentationImplementation(elementEditor, fullInterfacePath)/]
+[elementEditor.addBusinessFilterSignature()/] {
+ [referencedView.name.toJavaIdentifier()/]PropertiesEditionPart.addBusinessFilterTo[elementEditor.viewPackageSignature()/](filter);
+ }
+
+[/template]
+
+[template public setterSignatureImplementation(elementEditor : ElementEditor) overrides setterSignatureImplementation ? (elementEditor.representationName('LinkEObjectFlatComboViewer'))]
+[elementEditor.setterSignature()/] {
+ if (newValue != null) {
+ [elementEditor.elementEditorName()/].setSelection(new [include('org.eclipse.jface.viewers.StructuredSelection')/](newValue));
+ } else {
+ [elementEditor.elementEditorName()/].setSelection(new StructuredSelection()); //$NON-NLS-1$
+ }
+ [elementEditor.readOnly()/]
+ }
+[/template]
+
+[template public setterButtonModeSignatureDocumentationImplementation(elementEditor : ElementEditor, fullInterfacePath : String) ? (elementEditor.representationName('LinkEObjectFlatComboViewer'))]
+ /**
+ * {@inheritDoc}
+ *
+ * @see [fullInterfacePath/]#[elementEditor.viewPackageSetter()/]ButtonMode(ButtonsModeEnum newValue)
+ */
+[/template]
+
+[template public initSignatureDocumentationImplementation(elementEditor : ElementEditor, fullInterfacePath : String) ? (elementEditor.representationName('LinkEObjectFlatComboViewer'))]
+ /**
+ * {@inheritDoc}
+ *
+ * @see [fullInterfacePath/]#init[elementEditor.viewPackageSignature()/](EObjectFlatComboSettings)
+ */
+[/template]
+
+[template public initSignatureImplementation(elementEditor : ElementEditor) overrides initSignatureImplementation ? (elementEditor.representationName('LinkEObjectFlatComboViewer'))]
+[elementEditor.initSignature()/] {
+ [elementEditor.elementEditorName()/].setInput(settings);
+ if (current != null) {
+ [elementEditor.elementEditorName()/].setSelection(new [include('org.eclipse.jface.viewers.StructuredSelection')/](settings.getValue()));
+ }
+ [elementEditor.readOnly()/]
+ }
+[/template]
+
+[template public addBusinessFilterSignatureImplementation(elementEditor : ElementEditor) ? (elementEditor.representationName('LinkEObjectFlatComboViewer'))]
+[elementEditor.addBusinessFilterSignature()/] {
+ [elementEditor.elementEditorName()/].addBusinessRuleFilter(filter);
+ }
+[/template]
+
diff --git a/plugins/org.eclipse.emf.eef.codegen/src/org/eclipse/emf/eef/codegen/widgets/impl/linkeobjectflatcomboviewer/linkeobjectflatcomboviewerSWTImpl.mtl b/plugins/org.eclipse.emf.eef.codegen/src/org/eclipse/emf/eef/codegen/widgets/impl/linkeobjectflatcomboviewer/linkeobjectflatcomboviewerSWTImpl.mtl
new file mode 100644
index 000000000..b32695946
--- /dev/null
+++ b/plugins/org.eclipse.emf.eef.codegen/src/org/eclipse/emf/eef/codegen/widgets/impl/linkeobjectflatcomboviewer/linkeobjectflatcomboviewerSWTImpl.mtl
@@ -0,0 +1,79 @@
+[comment encoding = UTF-8
+ *******************************************************************************
+ * Copyright (c) 2008-2013 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 linkeobjectflatcomboviewerSWTImpl('http://www.eclipse.org/emf/eef/views/1.0.0', 'http://www.eclipse.org/emf/eef/components/1.0.0', 'http://www.eclipse.org/emf/2002/Ecore', 'http://www.eclipse.org/emf/eef/generation/1.0.0') extends org::eclipse::emf::eef::codegen::widgets::api::widgetSWTImpl/]
+
+[import org::eclipse::emf::eef::codegen::services::common /]
+[import org::eclipse::emf::eef::codegen::services::naming /]
+[import org::eclipse::emf::eef::codegen::services::viewCommon /]
+[import org::eclipse::emf::eef::codegen::services::imports/]
+
+[comment ===== Case Widget = LinkEObjectFlatComboViewer ===== /]
+[template public manageImports(widget : Widget, pec : PropertiesEditionComponent, view : View, basePackage : String) overrides manageImports ? (widget.name = 'LinkEObjectFlatComboViewer')]
+[pec.addImports(Sequence{
+ 'org.eclipse.swt.widgets.Composite',
+ 'org.eclipse.emf.ecore.EObject',
+ 'org.eclipse.emf.eef.runtime.impl.notify.PropertiesEditionEvent',
+ 'org.eclipse.emf.eef.runtime.ui.widgets.LinkEObjectFlatComboViewer.EObjectFlatComboViewerListener',
+ 'org.eclipse.emf.eef.runtime.ui.widgets.SWTUtils',
+ 'org.eclipse.swt.layout.GridData'})/]
+[/template]
+
+[template public widgetDeclaration(editor : ElementEditor) overrides widgetDeclaration ? (editor.representation.name = 'LinkEObjectFlatComboViewer')]
+ private [include('org.eclipse.emf.eef.runtime.ui.widgets.LinkEObjectFlatComboViewer')/] [editor.elementEditorName()/];
+ protected [include('org.eclipse.jface.viewers.ViewerFilter')/] [editor.elementEditorName()/]Filter;
+[/template]
+
+[template public implementation(editor : ElementEditor) overrides implementation ? (editor.representation.name = 'LinkEObjectFlatComboViewer')]
+return create[editor.name.toJavaClassifier()/]TypeFlatComboViewer(parent);
+[/template]
+
+[template public additionalImplementation(editor : ElementEditor, pec : PropertiesEditionComponent, inputPEC: PropertiesEditionComponent) overrides additionalImplementation ? (editor.representation.name = 'LinkEObjectFlatComboViewer')]
+ /**
+ * @param parent the parent composite
+ * [editor.owningViewsRepository().associatedGenModel().generationMark()/]
+ */
+ protected Composite create[editor.name.toJavaClassifier()/]TypeFlatComboViewer(Composite parent) {
+ [if (editor.nameAsLabel)]
+ SWTUtils.createPartLabel(parent, [include(editor.owningViewsRepository().qualifiedMessagesProvider())/].[editor.editorKey(editor.owningView())/], propertiesEditionComponent.isRequired([editor.editorID()/], [editor.owningViewsRepository().vrClass()/].SWT_KIND));
+ [else]
+ createDescription(parent, [editor.editorID()/], [include(editor.owningViewsRepository().qualifiedMessagesProvider())/].[editor.editorKey(editor.owningView())/]);
+ [/if]
+ // create callback listener
+ EObjectFlatComboViewerListener listener = new EObjectFlatComboViewerListener(){
+ public void handleSet(EObject element){
+ propertiesEditionComponent.firePropertiesChanged(new PropertiesEditionEvent([editor.editionPart()/].this, [editor.editorID()/], PropertiesEditionEvent.COMMIT, PropertiesEditionEvent.SET, null, element));
+ }
+ public void navigateTo(EObject element){ }
+
+ public EObject handleCreate() {
+ propertiesEditionComponent.firePropertiesChanged(new PropertiesEditionEvent([editor.editionPart()/].this, [editor.editorID()/], PropertiesEditionEvent.COMMIT, PropertiesEditionEvent.ADD, null, null));
+ return null;
+ }
+
+ public void handleEdit(EObject element) {
+ propertiesEditionComponent.firePropertiesChanged(new PropertiesEditionEvent([editor.editionPart()/].this, [editor.editorID()/], PropertiesEditionEvent.COMMIT, PropertiesEditionEvent.EDIT, null, element));
+ }
+ };
+ //create widget
+ [editor.elementEditorName()/] = new LinkEObjectFlatComboViewer(getDescription([editor.editorID()/], [editor.owningViewsRepository().messagesProvider()/].[editor.editorKey(editor.owningView())/]), resourceSet, [editor.elementEditorName()/]Filter, propertiesEditionComponent.getEditingContext().getAdapterFactory(), listener);
+ [editor.elementEditorName()/].createControls(parent);
+ GridData [editor.elementEditorName()/]Data = new GridData(GridData.FILL_HORIZONTAL);
+ [editor.elementEditorName()/].setLayoutData([editor.elementEditorName()/]Data);
+ [editor.elementEditorName()/].setID([editor.editorID()/]);
+ SWTUtils.createHelpButton(parent, propertiesEditionComponent.getHelpContent([editor.editorID()/], [editor.owningViewsRepository().vrClass()/].SWT_KIND), null); //$NON-NLS-1$
+ // [protected ('for create'.concat(editor.name.toJavaClassifier()).concat('TypeFlatComboViewer'))]
+
+ // [/protected]
+ return parent;
+ }
+[/template]
diff --git a/plugins/org.eclipse.emf.eef.runtime/src/org/eclipse/emf/eef/runtime/ui/widgets/AbstractAdvancedEObjectFlatComboViewer.java b/plugins/org.eclipse.emf.eef.runtime/src/org/eclipse/emf/eef/runtime/ui/widgets/AbstractAdvancedEObjectFlatComboViewer.java
new file mode 100644
index 000000000..0a4816c73
--- /dev/null
+++ b/plugins/org.eclipse.emf.eef.runtime/src/org/eclipse/emf/eef/runtime/ui/widgets/AbstractAdvancedEObjectFlatComboViewer.java
@@ -0,0 +1,392 @@
+/*******************************************************************************
+ * Copyright (c) 2008, 2011 CEA LIST and others.
+ * 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:
+ * Patrick Tessier (CEA LIST) Patrick.tessier@cea.fr - Initial API and implementation
+ * Obeo - Some improvements
+ *******************************************************************************/
+package org.eclipse.emf.eef.runtime.ui.widgets;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.emf.common.notify.AdapterFactory;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.emf.edit.ui.provider.AdapterFactoryLabelProvider;
+import org.eclipse.emf.eef.runtime.EEFRuntimePlugin;
+import org.eclipse.emf.eef.runtime.ui.utils.EEFRuntimeUIMessages;
+import org.eclipse.emf.eef.runtime.ui.utils.EditingUtils;
+import org.eclipse.emf.eef.runtime.ui.widgets.settings.EEFEditorSettings;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jface.viewers.ViewerFilter;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.MouseAdapter;
+import org.eclipse.swt.events.MouseEvent;
+import org.eclipse.swt.layout.FormAttachment;
+import org.eclipse.swt.layout.FormData;
+import org.eclipse.swt.layout.FormLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.ui.forms.widgets.ExpandableComposite;
+import org.eclipse.ui.forms.widgets.FormToolkit;
+
+/**
+ * This is an Abstract class use to display a label with the referenced named
+ * Element For example type of a property
+ *
+ * @author Patrick Tessier
+ * @author <a href="mailto:jerome.benois@obeo.fr">Jerome Benois</a>
+ * @author <a href="mailto:stephane.bouchet@obeo.fr">Stephane Bouchet</a>
+ */
+public abstract class AbstractAdvancedEObjectFlatComboViewer implements
+ IPropertiesFilteredWidget {
+
+ /** Image for the remove button */
+ protected final org.eclipse.swt.graphics.Image deleteImage = EEFRuntimePlugin
+ .getImage(EEFRuntimePlugin.ICONS_16x16 + "Delete_16x16.gif"); //$NON-NLS-1$
+
+ /** Image for the add button */
+ protected final org.eclipse.swt.graphics.Image addImage = EEFRuntimePlugin
+ .getImage(EEFRuntimePlugin.ICONS_16x16 + "Add_16x16.gif"); //$NON-NLS-1$
+
+ protected static final String UNDEFINED_VALUE = "<UNDEFINED>"; //$NON-NLS-1$
+
+ /**
+ * the dialog title
+ */
+ private String dialogTitle = ""; //$NON-NLS-1$
+
+ /** The parent Composite */
+ protected Composite parent;
+
+ protected EObject selection;
+
+ protected Object input;
+
+ protected Button browseButton;
+
+ protected EObjectFlatComboViewerListener callback;
+
+ /**
+ * The main composite
+ */
+ protected Composite composite;
+
+ /**
+ * The adapter factory.
+ */
+ protected AdapterFactory adapterFactory;
+
+ protected AdapterFactoryLabelProvider labelProvider;
+
+ protected List<ViewerFilter> filters;
+
+ protected List<ViewerFilter> brFilters;
+
+ protected FormToolkit widgetFactory;
+
+ protected ButtonsModeEnum button_mode = ButtonsModeEnum.BROWSE;
+
+ private Resource mainResource;
+
+ private Button removeButton;
+
+ protected Text field;
+
+ /**
+ * the constructor of this display
+ *
+ * @param labeltoDisplay
+ * use to display the name is the label
+ * @param filter
+ * use to look for the good element
+ */
+ public AbstractAdvancedEObjectFlatComboViewer(String dialogTitle, Object input,
+ ViewerFilter filter, AdapterFactory adapterFactory,
+ EObjectFlatComboViewerListener callback) {
+ this.dialogTitle = dialogTitle;
+ this.input = input;
+ this.callback = callback;
+ this.labelProvider = new AdapterFactoryLabelProvider(adapterFactory);
+ this.filters = new ArrayList<ViewerFilter>();
+ this.brFilters = new ArrayList<ViewerFilter>();
+ this.adapterFactory = adapterFactory;
+ }
+
+ public void createControls(Composite parent, FormToolkit widgetFactory) {
+ this.widgetFactory = widgetFactory;
+ createControls(parent);
+ }
+
+ public void createControls(Composite parent) {
+
+ this.composite = createComposite(parent);
+ this.parent = parent;
+ if (parent instanceof ExpandableComposite) {
+ ((ExpandableComposite) parent).setClient(composite);
+ }
+
+ FormLayout layout = new FormLayout();
+ layout.marginWidth = 1;// 7;
+ layout.marginHeight = 1;// 4;
+ layout.spacing = 7;
+ // layout.marginTop = 7;
+ composite.setLayout(layout);
+
+ // browse and remove Buttons
+ createButtons(composite);
+ // display and value labels
+ createLabels(composite);
+
+ }
+
+ private void createButtons(Composite parent) {
+ removeButton = createButton(parent, "", SWT.PUSH);
+ removeButton.setImage(deleteImage);
+ FormData data = new FormData();
+ data.right = new FormAttachment(100, -5);
+ data.top = new FormAttachment(0, -2);
+ removeButton.setLayoutData(data);
+ removeButton
+ .setToolTipText(EEFRuntimeUIMessages.AdvancedEObjectFlatComboViewer_remove_tooltip);
+ EditingUtils.setEEFtype(removeButton,
+ "eef::AdvancedEObjectFlatComboViewer::removebutton");
+
+ this.browseButton = createButton(parent, "", SWT.PUSH); //$NON-NLS-1$
+ browseButton.setImage(addImage);
+ data = new FormData();
+ data.right = new FormAttachment(removeButton, 2);
+ data.top = new FormAttachment(0, -2);
+ browseButton.setLayoutData(data);
+ browseButton.setToolTipText(EEFRuntimeUIMessages.AdvancedEObjectFlatComboViewer_set_tooltip);
+ EditingUtils.setEEFtype(browseButton, "eef::AdvancedEObjectFlatComboViewer::browsebutton");
+
+ // listeners setting
+ removeButton.addMouseListener(new MouseAdapter() {
+ @Override
+ public void mouseUp(MouseEvent e) {
+ // reset value
+ handleSelection(null);
+ }
+ });
+ browseButton.addMouseListener(new MouseAdapter() {
+ @Override
+ public void mouseUp(MouseEvent e) {
+ browseButtonPressed();
+ }
+ });
+ }
+
+ public void setInput(Object input) {
+ this.input = input;
+ }
+
+ /**
+ * Sets the given ID to the EObjectFlatComboViewer
+ *
+ * @param id
+ * the id of the widget
+ */
+ public void setID(Object id) {
+ EditingUtils.setID(field, id);
+ EditingUtils.setID(removeButton, id);
+ EditingUtils.setID(browseButton, id);
+ }
+
+ /**
+ * @return the ID of the EObjectFlatComboViewer
+ */
+ public Object getID() {
+ return EditingUtils.getID(field);
+ }
+
+ protected abstract void createLabels(Composite parent);
+
+ private Composite createComposite(Composite parent) {
+ Composite composite;
+ if (widgetFactory == null) {
+ composite = new Composite(parent, SWT.NONE);
+ } else {
+ composite = widgetFactory.createComposite(parent);
+ }
+ return composite;
+ }
+
+ private Button createButton(Composite parent, String text, int style) {
+ Button button;
+ if (widgetFactory == null) {
+ button = new Button(parent, style);
+ button.setText(text);
+ } else {
+ button = widgetFactory.createButton(parent, text, style);
+ }
+ return button;
+ }
+
+ public abstract void setSelection(ISelection selection);
+
+ public abstract void setSelection(EObject selection);
+
+ public EObject getSelection() {
+ return selection;
+ }
+
+ /**
+ * Behavior executed when browse button is pressed.
+ */
+ protected void browseButtonPressed() {
+ switch (button_mode) {
+ case BROWSE:
+ TabElementTreeSelectionDialog dialog = new TabElementTreeSelectionDialog(
+ input, filters, brFilters, dialogTitle, adapterFactory,
+ getMainResource()) {
+ @Override
+ public void process(IStructuredSelection selection) {
+ if (selection != null && !selection.isEmpty()) {
+ handleSelection((EObject) selection.getFirstElement());
+ }
+ }
+ };
+ // Select the actual element in dialog
+ if (selection != null) {
+ dialog.setSelection(new StructuredSelection(selection));
+ }
+ dialog.open();
+ break;
+ case CREATE:
+ handleCreate();
+ break;
+ default:
+ break;
+ }
+ }
+
+ public void handleSelection(EObject selectedElement) {
+ setSelection(selectedElement);
+ callback.handleSet(selectedElement);
+ }
+
+ public void handleCreate() {
+ setSelection(callback.handleCreate());
+ }
+
+ public void handleEdit(EObject element) {
+ callback.handleEdit(element);
+ // refresh the text;
+ setSelection(element);
+ }
+
+ public interface EObjectFlatComboViewerListener {
+ public void handleSet(EObject element);
+
+ public void navigateTo(EObject element);
+
+ public EObject handleCreate();
+
+ public void handleEdit(EObject element);
+ }
+
+ /**
+ * @param layoutData
+ * the layoutData to set
+ */
+ public void setLayoutData(Object layoutData) {
+ composite.setLayoutData(layoutData);
+ }
+
+ public void addFilter(ViewerFilter filter) {
+ filters.add(filter);
+ }
+
+ public void addBusinessRuleFilter(ViewerFilter filter) {
+ brFilters.add(filter);
+ }
+
+ public void removeBusinessRuleFilter(ViewerFilter filter) {
+ brFilters.remove(filter);
+ }
+
+ public void removeFilter(ViewerFilter filter) {
+ filters.remove(filter);
+ }
+
+ public void setButtonMode(ButtonsModeEnum button_mode) {
+ this.button_mode = button_mode;
+ }
+
+ /**
+ * Returns the main resource.
+ *
+ * @return the main resource.
+ */
+
+ public Resource getMainResource() {
+ if (this.mainResource == null && this.input instanceof EEFEditorSettings) {
+ Resource mainResourceFromSettings = null;
+
+ // Gets the mainResource from the settings.
+ EEFEditorSettings settings = (EEFEditorSettings) this.input;
+ if (settings.getSource() != null) {
+ // The default mainResource is the resource of the edited
+ // object.
+ mainResourceFromSettings = settings.getSource().eResource();
+ if (settings.getValue() instanceof EObject && ((EObject) settings.getValue()).eResource() != null) {
+
+ // The mainResource is the resource of the value.
+ mainResourceFromSettings = ((EObject) settings.getValue()).eResource();
+ }
+ }
+ if (mainResourceFromSettings != null) {
+ return mainResourceFromSettings;
+ }
+ }
+
+ //
+
+ // Client has specified a main resource. Let's use it !
+
+ return this.mainResource;
+
+ }
+
+ public void setMainResource(Resource mainResource) {
+ this.mainResource = mainResource;
+ }
+
+ /**
+ * Sets the viewer readonly
+ *
+ * @param enabled
+ * sets the viewer read only or not.
+ */
+ public void setEnabled(boolean enabled) {
+ browseButton.setEnabled(enabled);
+ removeButton.setEnabled(enabled);
+ }
+
+ /**
+ * @return if the table is enabled
+ */
+ public boolean isEnabled() {
+ return true;
+ }
+
+ /**
+ * Sets the tooltip text on the viewer
+ *
+ * @param tooltip
+ * the tooltip text
+ */
+ public void setToolTipText(String tooltip) {
+ browseButton.setToolTipText(tooltip);
+ }
+
+}
diff --git a/plugins/org.eclipse.emf.eef.runtime/src/org/eclipse/emf/eef/runtime/ui/widgets/AdvancedEObjectFlatComboViewer.java b/plugins/org.eclipse.emf.eef.runtime/src/org/eclipse/emf/eef/runtime/ui/widgets/AdvancedEObjectFlatComboViewer.java
index f3124b995..39d01fb2c 100644
--- a/plugins/org.eclipse.emf.eef.runtime/src/org/eclipse/emf/eef/runtime/ui/widgets/AdvancedEObjectFlatComboViewer.java
+++ b/plugins/org.eclipse.emf.eef.runtime/src/org/eclipse/emf/eef/runtime/ui/widgets/AdvancedEObjectFlatComboViewer.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2008, 2011 CEA LIST and others.
+ * Copyright (c) 2008, 2013 CEA LIST and others.
* 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
@@ -11,19 +11,10 @@
*******************************************************************************/
package org.eclipse.emf.eef.runtime.ui.widgets;
-import java.util.ArrayList;
-import java.util.List;
-
import org.eclipse.emf.common.notify.AdapterFactory;
import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.resource.Resource;
-import org.eclipse.emf.edit.ui.provider.AdapterFactoryLabelProvider;
-import org.eclipse.emf.eef.runtime.EEFRuntimePlugin;
-import org.eclipse.emf.eef.runtime.ui.utils.EEFRuntimeUIMessages;
import org.eclipse.emf.eef.runtime.ui.utils.EditingUtils;
-import org.eclipse.emf.eef.runtime.ui.widgets.settings.EEFEditorSettings;
import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.jface.viewers.ViewerFilter;
import org.eclipse.swt.SWT;
@@ -31,12 +22,8 @@ import org.eclipse.swt.events.MouseAdapter;
import org.eclipse.swt.events.MouseEvent;
import org.eclipse.swt.layout.FormAttachment;
import org.eclipse.swt.layout.FormData;
-import org.eclipse.swt.layout.FormLayout;
-import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Text;
-import org.eclipse.ui.forms.widgets.ExpandableComposite;
-import org.eclipse.ui.forms.widgets.FormToolkit;
/**
* This is an Abstract class use to display a label with the referenced named
@@ -46,64 +33,11 @@ import org.eclipse.ui.forms.widgets.FormToolkit;
* @author <a href="mailto:jerome.benois@obeo.fr">Jerome Benois</a>
* @author <a href="mailto:stephane.bouchet@obeo.fr">Stephane Bouchet</a>
*/
-public class AdvancedEObjectFlatComboViewer implements
- IPropertiesFilteredWidget {
-
- /** Image for the remove button */
- protected final org.eclipse.swt.graphics.Image deleteImage = EEFRuntimePlugin
- .getImage(EEFRuntimePlugin.ICONS_16x16 + "Delete_16x16.gif"); //$NON-NLS-1$
-
- /** Image for the add button */
- protected final org.eclipse.swt.graphics.Image addImage = EEFRuntimePlugin
- .getImage(EEFRuntimePlugin.ICONS_16x16 + "Add_16x16.gif"); //$NON-NLS-1$
-
- private static final String UNDEFINED_VALUE = "<UNDEFINED>"; //$NON-NLS-1$
-
- /**
- * the dialog title
- */
- private String dialogTitle = ""; //$NON-NLS-1$
+public class AdvancedEObjectFlatComboViewer extends AbstractAdvancedEObjectFlatComboViewer {
/** Associated text */
protected Text valueText;
- /** The parent Composite */
- protected Composite parent;
-
- protected EObject selection;
-
- protected Object input;
-
- protected Button browseButton;
-
- protected EObjectFlatComboViewerListener callback;
-
- /**
- * The main composite
- */
- protected Composite composite;
-
- /**
- * The adapter factory.
- */
- protected AdapterFactory adapterFactory;
-
- protected AdapterFactoryLabelProvider labelProvider;
-
- protected List<ViewerFilter> filters;
-
- protected List<ViewerFilter> brFilters;
-
- protected FormToolkit widgetFactory;
-
- protected ButtonsModeEnum button_mode = ButtonsModeEnum.BROWSE;
-
- private Resource mainResource;
-
- private Button removeButton;
-
- private Text field;
-
/**
* the constructor of this display
*
@@ -115,103 +49,10 @@ public class AdvancedEObjectFlatComboViewer implements
public AdvancedEObjectFlatComboViewer(String dialogTitle, Object input,
ViewerFilter filter, AdapterFactory adapterFactory,
EObjectFlatComboViewerListener callback) {
- this.dialogTitle = dialogTitle;
- this.input = input;
- this.callback = callback;
- this.labelProvider = new AdapterFactoryLabelProvider(adapterFactory);
- this.filters = new ArrayList<ViewerFilter>();
- this.brFilters = new ArrayList<ViewerFilter>();
- this.adapterFactory = adapterFactory;
- }
-
- public void createControls(Composite parent, FormToolkit widgetFactory) {
- this.widgetFactory = widgetFactory;
- createControls(parent);
- }
-
- public void createControls(Composite parent) {
-
- this.composite = createComposite(parent);
- this.parent = parent;
- if (parent instanceof ExpandableComposite) {
- ((ExpandableComposite) parent).setClient(composite);
- }
-
- FormLayout layout = new FormLayout();
- layout.marginWidth = 1;// 7;
- layout.marginHeight = 1;// 4;
- layout.spacing = 7;
- // layout.marginTop = 7;
- composite.setLayout(layout);
-
- // browse and remove Buttons
- createButtons(composite);
- // display and value labels
- createLabels(composite);
-
+ super(dialogTitle, input, filter, adapterFactory, callback);
}
- private void createButtons(Composite parent) {
- removeButton = createButton(parent, "", SWT.PUSH);
- removeButton.setImage(deleteImage);
- FormData data = new FormData();
- data.right = new FormAttachment(100, -5);
- data.top = new FormAttachment(0, -2);
- removeButton.setLayoutData(data);
- removeButton
- .setToolTipText(EEFRuntimeUIMessages.AdvancedEObjectFlatComboViewer_remove_tooltip);
- EditingUtils.setEEFtype(removeButton,
- "eef::AdvancedEObjectFlatComboViewer::removebutton");
-
- this.browseButton = createButton(parent, "", SWT.PUSH); //$NON-NLS-1$
- browseButton.setImage(addImage);
- data = new FormData();
- data.right = new FormAttachment(removeButton, 2);
- data.top = new FormAttachment(0, -2);
- browseButton.setLayoutData(data);
- browseButton.setToolTipText(EEFRuntimeUIMessages.AdvancedEObjectFlatComboViewer_set_tooltip);
- EditingUtils.setEEFtype(browseButton, "eef::AdvancedEObjectFlatComboViewer::browsebutton");
-
- // listeners setting
- removeButton.addMouseListener(new MouseAdapter() {
- @Override
- public void mouseUp(MouseEvent e) {
- // reset value
- handleSelection(null);
- }
- });
- browseButton.addMouseListener(new MouseAdapter() {
- @Override
- public void mouseUp(MouseEvent e) {
- browseButtonPressed();
- }
- });
- }
-
- public void setInput(Object input) {
- this.input = input;
- }
-
- /**
- * Sets the given ID to the EObjectFlatComboViewer
- *
- * @param id
- * the id of the widget
- */
- public void setID(Object id) {
- EditingUtils.setID(field, id);
- EditingUtils.setID(removeButton, id);
- EditingUtils.setID(browseButton, id);
- }
-
- /**
- * @return the ID of the EObjectFlatComboViewer
- */
- public Object getID() {
- return EditingUtils.getID(field);
- }
-
- private void createLabels(Composite parent) {
+ protected void createLabels(Composite parent) {
// Display label
// final Label displayLabel = createLabel(parent, dialogTitle,
// SWT.NONE);
@@ -244,38 +85,6 @@ public class AdvancedEObjectFlatComboViewer implements
});
}
- private Composite createComposite(Composite parent) {
- Composite composite;
- if (widgetFactory == null) {
- composite = new Composite(parent, SWT.NONE);
- } else {
- composite = widgetFactory.createComposite(parent);
- }
- return composite;
- }
-
- private Button createButton(Composite parent, String text, int style) {
- Button button;
- if (widgetFactory == null) {
- button = new Button(parent, style);
- button.setText(text);
- } else {
- button = widgetFactory.createButton(parent, text, style);
- }
- return button;
- }
-
- // private Label createLabel(Composite parent, String text, int style) {
- // Label label;
- // if (widgetFactory == null) {
- // label = new Label(parent, SWT.PUSH);
- // label.setText(text);
- // } else {
- // label = widgetFactory.createLabel(parent, text, style);
- // }
- // return label;
- // }
-
private Text createText(Composite parent, String value, int style) {
if (widgetFactory == null) {
field = new Text(parent, SWT.PUSH);
@@ -311,124 +120,6 @@ public class AdvancedEObjectFlatComboViewer implements
// this.parent.pack();
}
- public EObject getSelection() {
- return selection;
- }
-
- /**
- * Behavior executed when browse button is pressed.
- */
- protected void browseButtonPressed() {
- switch (button_mode) {
- case BROWSE:
- TabElementTreeSelectionDialog dialog = new TabElementTreeSelectionDialog(
- input, filters, brFilters, dialogTitle, adapterFactory,
- getMainResource()) {
- @Override
- public void process(IStructuredSelection selection) {
- if (selection != null && !selection.isEmpty()) {
- handleSelection((EObject) selection.getFirstElement());
- }
- }
- };
- // Select the actual element in dialog
- if (selection != null) {
- dialog.setSelection(new StructuredSelection(selection));
- }
- dialog.open();
- break;
- case CREATE:
- handleCreate();
- break;
- default:
- break;
- }
- }
-
- public void handleSelection(EObject selectedElement) {
- setSelection(selectedElement);
- callback.handleSet(selectedElement);
- }
-
- public void handleCreate() {
- setSelection(callback.handleCreate());
- }
-
- public interface EObjectFlatComboViewerListener {
- public void handleSet(EObject element);
-
- public void navigateTo(EObject element);
-
- public EObject handleCreate();
- }
-
- /**
- * @param layoutData
- * the layoutData to set
- */
- public void setLayoutData(Object layoutData) {
- composite.setLayoutData(layoutData);
- }
-
- public void addFilter(ViewerFilter filter) {
- filters.add(filter);
- }
-
- public void addBusinessRuleFilter(ViewerFilter filter) {
- brFilters.add(filter);
- }
-
- public void removeBusinessRuleFilter(ViewerFilter filter) {
- brFilters.remove(filter);
- }
-
- public void removeFilter(ViewerFilter filter) {
- filters.remove(filter);
- }
-
- public void setButtonMode(ButtonsModeEnum button_mode) {
- this.button_mode = button_mode;
- }
-
- /**
- * Returns the main resource.
- *
- * @return the main resource.
- */
-
- public Resource getMainResource() {
- if (this.mainResource == null && this.input instanceof EEFEditorSettings) {
- Resource mainResourceFromSettings = null;
-
- // Gets the mainResource from the settings.
- EEFEditorSettings settings = (EEFEditorSettings) this.input;
- if (settings.getSource() != null) {
- // The default mainResource is the resource of the edited
- // object.
- mainResourceFromSettings = settings.getSource().eResource();
- if (settings.getValue() instanceof EObject && ((EObject) settings.getValue()).eResource() != null) {
-
- // The mainResource is the resource of the value.
- mainResourceFromSettings = ((EObject) settings.getValue()).eResource();
- }
- }
- if (mainResourceFromSettings != null) {
- return mainResourceFromSettings;
- }
- }
-
- //
-
- // Client has specified a main resource. Let's use it !
-
- return this.mainResource;
-
- }
-
- public void setMainResource(Resource mainResource) {
- this.mainResource = mainResource;
- }
-
/**
* Sets the viewer readonly
*
@@ -436,16 +127,15 @@ public class AdvancedEObjectFlatComboViewer implements
* sets the viewer read only or not.
*/
public void setEnabled(boolean enabled) {
- browseButton.setEnabled(enabled);
+ super.setEnabled(enabled);
valueText.setEnabled(enabled);
- removeButton.setEnabled(enabled);
}
/**
* @return if the table is enabled
*/
public boolean isEnabled() {
- return valueText.isEnabled();
+ return super.isEnabled() && valueText.isEnabled();
}
/**
@@ -455,7 +145,7 @@ public class AdvancedEObjectFlatComboViewer implements
* the tooltip text
*/
public void setToolTipText(String tooltip) {
- browseButton.setToolTipText(tooltip);
+ super.setToolTipText(tooltip);
valueText.setToolTipText(tooltip);
}
diff --git a/plugins/org.eclipse.emf.eef.runtime/src/org/eclipse/emf/eef/runtime/ui/widgets/LinkEObjectFlatComboViewer.java b/plugins/org.eclipse.emf.eef.runtime/src/org/eclipse/emf/eef/runtime/ui/widgets/LinkEObjectFlatComboViewer.java
new file mode 100644
index 000000000..92ab8bd02
--- /dev/null
+++ b/plugins/org.eclipse.emf.eef.runtime/src/org/eclipse/emf/eef/runtime/ui/widgets/LinkEObjectFlatComboViewer.java
@@ -0,0 +1,175 @@
+/*******************************************************************************
+ * Copyright (c) 2008, 2013 CEA LIST and others.
+ * 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:
+ * Patrick Tessier (CEA LIST) Patrick.tessier@cea.fr - Initial API and implementation
+ * Obeo - Some improvements
+ *******************************************************************************/
+package org.eclipse.emf.eef.runtime.ui.widgets;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.emf.common.notify.AdapterFactory;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.emf.edit.ui.provider.AdapterFactoryLabelProvider;
+import org.eclipse.emf.eef.runtime.EEFRuntimePlugin;
+import org.eclipse.emf.eef.runtime.ui.utils.EEFRuntimeUIMessages;
+import org.eclipse.emf.eef.runtime.ui.utils.EditingUtils;
+import org.eclipse.emf.eef.runtime.ui.widgets.eobjflatcombo.EObjectFlatComboSettings;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jface.viewers.ViewerFilter;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.MouseAdapter;
+import org.eclipse.swt.events.MouseEvent;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.layout.FormAttachment;
+import org.eclipse.swt.layout.FormData;
+import org.eclipse.swt.layout.FormLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Link;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.ui.forms.widgets.ExpandableComposite;
+import org.eclipse.ui.forms.widgets.FormToolkit;
+
+/**
+ * This is an Abstract class use to display a label with the referenced named
+ * Element For example type of a property
+ *
+ * @author Patrick Tessier
+ * @author <a href="mailto:jerome.benois@obeo.fr">Jerome Benois</a>
+ * @author <a href="mailto:stephane.bouchet@obeo.fr">Stephane Bouchet</a>
+ */
+public class LinkEObjectFlatComboViewer extends AbstractAdvancedEObjectFlatComboViewer {
+
+
+ /** Associated link. */
+ protected Link valueLink;
+
+ /**
+ * the constructor of this display
+ *
+ * @param labeltoDisplay
+ * use to display the name is the label
+ * @param filter
+ * use to look for the good element
+ */
+ public LinkEObjectFlatComboViewer(String dialogTitle, Object input,
+ ViewerFilter filter, AdapterFactory adapterFactory,
+ EObjectFlatComboViewerListener callback) {
+ super(dialogTitle, input, filter, adapterFactory, callback);
+ }
+
+ protected void createLabels(Composite parent) {
+ // Display label
+ // final Label displayLabel = createLabel(parent, dialogTitle,
+ // SWT.NONE);
+ // FormData data = new FormData();
+ // data.left = new FormAttachment(0, 0);
+ // data.top = new FormAttachment(0, 0);
+ // displayLabel.setLayoutData(data);
+
+ // Value Label
+ String value = UNDEFINED_VALUE;
+ if (selection != null) {
+ value = labelProvider.getText(selection);
+ }
+ this.valueLink = createLink(parent, value, SWT.NONE);
+ // valueText.setEditable(false);
+ // TODO set background color and dispose!
+ // valueText.setEnabled(false);
+ // valueText.setBackground(...);
+ FormData data = new FormData();
+ // data.left = new FormAttachment(displayLabel, 5);
+ data.left = new FormAttachment(0, 0);
+ data.right = new FormAttachment(browseButton, 0);
+ data.top = new FormAttachment(0, 1);
+ valueLink.setLayoutData(data);
+ // valueText.addMouseListener(new MouseAdapter() {
+ // @Override
+ // public void mouseDoubleClick(MouseEvent e) {
+ // callback.navigateTo(selection);
+ // }
+ // });
+ valueLink.addSelectionListener(new SelectionAdapter() {
+ @SuppressWarnings("unchecked")
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ EObject editedElement = getSelection();
+ handleEdit(editedElement);
+ }
+ });
+ }
+
+ private Link createLink(Composite parent, String value, int style) {
+ Link link = new Link(parent, style);
+ link.setText(value);
+ EditingUtils.setEEFtype(field,
+ "eef::LinkEObjectFlatComboViewer::link");
+ return link;
+ }
+
+ @SuppressWarnings("unchecked")
+ public void setSelection(ISelection selection) {
+ if (selection instanceof StructuredSelection) {
+ StructuredSelection structuredSelection = (StructuredSelection) selection;
+ if (!structuredSelection.isEmpty()
+ && !"".equals(structuredSelection.getFirstElement())) {
+ setSelection((EObject) structuredSelection.getFirstElement());
+ } else {
+ this.valueLink.setText(UNDEFINED_VALUE);
+ // this.parent.pack();
+ }
+ }
+ }
+
+ public void setSelection(EObject selection) {
+ this.selection = selection;
+ String text = labelProvider.getText(selection);
+ if ("".equals(text)) //$NON-NLS-1$
+ this.valueLink.setText(UNDEFINED_VALUE);
+ else
+ this.valueLink.setText("<a>" + text + "</a>");
+ // this.parent.pack();
+ }
+
+ /**
+ * Sets the viewer readonly
+ *
+ * @param enabled
+ * sets the viewer read only or not.
+ */
+ public void setEnabled(boolean enabled) {
+ super.setEnabled(enabled);
+ valueLink.setEnabled(enabled);
+ }
+
+ /**
+ * @return if the table is enabled
+ */
+ public boolean isEnabled() {
+ return super.isEnabled() && valueLink.isEnabled();
+ }
+
+ /**
+ * Sets the tooltip text on the viewer
+ *
+ * @param tooltip
+ * the tooltip text
+ */
+ public void setToolTipText(String tooltip) {
+ super.setToolTipText(tooltip);
+ valueLink.setToolTipText(tooltip);
+ }
+
+
+}
diff --git a/plugins/org.eclipse.emf.eef.runtime/src/org/eclipse/emf/eef/runtime/ui/widgets/LinkReferencesTable.java b/plugins/org.eclipse.emf.eef.runtime/src/org/eclipse/emf/eef/runtime/ui/widgets/LinkReferencesTable.java
new file mode 100644
index 000000000..402a2e4bb
--- /dev/null
+++ b/plugins/org.eclipse.emf.eef.runtime/src/org/eclipse/emf/eef/runtime/ui/widgets/LinkReferencesTable.java
@@ -0,0 +1,920 @@
+/*******************************************************************************
+ * Copyright (c) 2008, 2013 CEA LIST and others.
+ * 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:
+ * Patrick Tessier (CEA LIST) Patrick.tessier@cea.fr - Initial API and implementation
+ * Obeo - Some improvements
+ *******************************************************************************/
+package org.eclipse.emf.eef.runtime.ui.widgets;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.emf.common.notify.AdapterFactory;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.edit.provider.ComposedAdapterFactory;
+import org.eclipse.emf.edit.ui.provider.AdapterFactoryLabelProvider;
+import org.eclipse.emf.eef.runtime.EEFRuntimePlugin;
+import org.eclipse.emf.eef.runtime.ui.utils.EEFRuntimeUIMessages;
+import org.eclipse.emf.eef.runtime.ui.utils.EditingUtils;
+import org.eclipse.jface.viewers.IStructuredContentProvider;
+import org.eclipse.jface.viewers.TableViewer;
+import org.eclipse.jface.viewers.ViewerFilter;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.MouseEvent;
+import org.eclipse.swt.events.MouseListener;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.layout.FormAttachment;
+import org.eclipse.swt.layout.FormData;
+import org.eclipse.swt.layout.FormLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Listener;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.swt.widgets.TableItem;
+import org.eclipse.ui.forms.widgets.ExpandableComposite;
+import org.eclipse.ui.forms.widgets.FormToolkit;
+import org.eclipse.ui.views.properties.tabbed.ITabbedPropertyConstants;
+
+/**
+ * Base class for a complex section composite. This composite has a label, a
+ * table that describes a tree structure, and four buttons on the side of the
+ * table to add an element into the table, remove selected element(s), move up
+ * or down the selected element.
+ *
+ * @author Remi SCHNEKENBURGER
+ * @author Patrick Tessier
+ * @author <a href="mailto:jerome.benois@obeo.fr">Jerome Benois</a>
+ * @author <a href="mailto:goulwen.lefur@obeo.fr">Goulwen Le Fur</a>
+ * @author <a href="mailto:stephane.bouchet@obeo.fr">Stephane Bouchet</a>
+ */
+public class LinkReferencesTable implements IPropertiesFilteredWidget {
+
+ /**
+ * Image for the add element button.
+ */
+ final protected static Image NEW_ELEMENT_IMG = EEFRuntimePlugin
+ .getImage(EEFRuntimePlugin.ICONS_16x16 + "Add_16x16.gif"); //$NON-NLS-1$
+
+ /**
+ * Image for the delete element button.
+ */
+ final protected static Image DELETE_ELEMENT_IMG = EEFRuntimePlugin
+ .getImage(EEFRuntimePlugin.ICONS_16x16 + "Delete_16x16.gif"); //$NON-NLS-1$
+
+ /**
+ * Image for the up button.
+ */
+ final protected static Image UP_ELEMENT_IMG = EEFRuntimePlugin
+ .getImage(EEFRuntimePlugin.ICONS_16x16 + "ArrowUp_16x16.gif"); //$NON-NLS-1$
+
+ /**
+ * Image for the down button.
+ */
+ final protected static Image DOWN_ELEMENT_IMG = EEFRuntimePlugin
+ .getImage(EEFRuntimePlugin.ICONS_16x16 + "ArrowDown_16x16.gif"); //$NON-NLS-1$
+
+ /** list of element that we want to display * */
+ private Object input;
+
+ /**
+ * Label above the table.
+ */
+ private Label label;
+
+ /**
+ * Table that displays a property for the current element.
+ */
+ private Table table;
+
+ /** the table viewer to associate the label provider * */
+ private TableViewer tableViewer;
+
+ /**
+ * Button that adds an element.
+ */
+ private Button addButton;
+
+ /**
+ * Button that removes an element.
+ */
+ private Button removeButton;
+
+ /**
+ * button that moves the element up.
+ */
+ private Button upButton;
+
+ /**
+ * button that moves the element down.
+ */
+ private Button downButton;
+
+ /**
+ * Listener for the add button.
+ */
+ private MouseListener addButtonlistener;
+
+ /**
+ * Listener for the delete button.
+ */
+ private MouseListener removeButtonlistener;
+
+ /**
+ * Listener for the up button.
+ */
+ private MouseListener upButtonlistener;
+
+ /**
+ * Listener for the down button.
+ */
+ private MouseListener downButtonlistener;
+
+ private Listener tableListener;
+
+ private int upperBound = -1;
+
+ private int lowerBound = 0;
+
+ /**
+ * The listener used by the client to handle business events (Add, Remove,
+ * Move, NavigateTo)
+ */
+ private ReferencesTableListener referencesTableListener;
+
+ private String labelToDisplay;
+
+ /**
+ * The Form tool kit use to use this widget in an Eclipse Forms compliant
+ * mode
+ */
+ private FormToolkit widgetFactory;
+
+ /**
+ * The main composite
+ */
+ private Composite composite;
+
+ /**
+ * The adapter factory.
+ */
+ protected AdapterFactory adapterFactory = new ComposedAdapterFactory(
+ ComposedAdapterFactory.Descriptor.Registry.INSTANCE);
+
+ /**
+ * The help text
+ */
+ private String helpText;
+
+ /** The business rules filters. */
+ protected List<ViewerFilter> bpFilters;
+
+ /** The filters. */
+ protected List<ViewerFilter> filters;
+
+ /**
+ * ContentProvider of the table
+ */
+ private IStructuredContentProvider contentProvider;
+
+ /**
+ * the constructor
+ *
+ * @param labeltoDisplay
+ * the label to display
+ * @param the
+ * listener to handle Add, Remove, Move and NavigateTo events
+ */
+ public LinkReferencesTable(String labeltoDisplay,
+ ReferencesTableListener referenceListener) {
+ this.labelToDisplay = labeltoDisplay;
+ this.addButtonlistener = new AddButtonlistener();
+ this.removeButtonlistener = new RemoveButtonlistener();
+ this.upButtonlistener = new UpButtonlistener();
+ this.downButtonlistener = new DownButtonlistener();
+ bpFilters = new ArrayList<ViewerFilter>();
+ filters = new ArrayList<ViewerFilter>();
+ addTableReferenceListener(referenceListener);
+ }
+
+ public void addTableReferenceListener(
+ ReferencesTableListener referenceListener) {
+ this.referencesTableListener = referenceListener;
+ }
+
+ public void addSelectionListener(SelectionListener selectionListener) {
+ this.table.addSelectionListener(selectionListener);
+ }
+
+ public void createControls(Composite parent, FormToolkit widgetFactory) {
+ this.widgetFactory = widgetFactory;
+ createControls(parent);
+ }
+
+ private Composite createComposite(Composite parent) {
+ Composite composite;
+ if (widgetFactory == null) {
+ composite = new Composite(parent, SWT.NONE);
+ } else {
+ composite = widgetFactory.createComposite(parent);
+ }
+ return composite;
+ }
+
+ private Button createButton(Composite parent, String text, int style) {
+ Button button;
+ if (widgetFactory == null) {
+ button = new Button(parent, style);
+ button.setText(text);
+ } else {
+ button = widgetFactory.createButton(parent, text, style);
+ }
+ return button;
+ }
+
+ private Label createLabel(Composite parent, String text, int style) {
+ Label label;
+ if (widgetFactory == null) {
+ label = new Label(parent, SWT.PUSH);
+ label.setText(text);
+ } else {
+ label = widgetFactory.createLabel(parent, text, style);
+ }
+ return label;
+ }
+
+ private Table createTable(Composite parent, int style) {
+ Table table;
+ if (widgetFactory == null) {
+ table = new Table(parent, style);
+ } else {
+ table = widgetFactory.createTable(parent, style);
+ }
+ return table;
+ }
+
+ public void createControls(Composite parent) {
+ composite = createComposite(parent);
+ if (parent instanceof ExpandableComposite) {
+ ((ExpandableComposite) parent).setClient(composite);
+ }
+ FormLayout formLayout = new FormLayout();
+ formLayout.marginTop = 7;
+ composite.setLayout(formLayout);
+
+ FormData data;
+
+ // Create Help Button
+ data = new FormData();
+ data.top = new FormAttachment(-2, 0);
+ data.right = new FormAttachment(100, -ITabbedPropertyConstants.HSPACE);
+ Control helpButton = null;
+ if (helpText != null) {
+ if (widgetFactory != null) {
+ helpButton = FormUtils.createHelpButton(widgetFactory,
+ composite, helpText, null);
+ } else {
+ helpButton = SWTUtils.createHelpButton(composite, helpText,
+ null);
+ }
+ helpButton.setLayoutData(data);
+ }
+
+ // ///////////////////////////////////////////////////////////////////////////
+ // Create and place button vertically on the left side
+ // Button : Add Element
+ // Button Delete Element
+ removeButton = createButton(composite, "", SWT.PUSH); //$NON-NLS-1$
+ removeButton.setVisible(true);
+ removeButton.setImage(DELETE_ELEMENT_IMG);
+ removeButton
+ .setToolTipText(EEFRuntimeUIMessages.ReferencesTable_remove_tooltip);
+ data = new FormData();
+ // data.top = new FormAttachment(addButton,
+ // ITabbedPropertyConstants.HSPACE);
+ data.top = new FormAttachment(-6, 0);
+ if (helpText != null) {
+ data.right = new FormAttachment(helpButton,
+ -ITabbedPropertyConstants.HSPACE);
+ } else {
+ data.right = new FormAttachment(100,
+ -ITabbedPropertyConstants.HSPACE);
+ }
+ removeButton.setLayoutData(data);
+ removeButton.addMouseListener(removeButtonlistener);
+
+ addButton = createButton(composite, "", SWT.PUSH); //$NON-NLS-1$
+ addButton.setVisible(true);
+ addButton.setImage(NEW_ELEMENT_IMG);
+ addButton
+ .setToolTipText(EEFRuntimeUIMessages.ReferencesTable_add_tooltip);
+
+ data = new FormData();
+ // data.top = new FormAttachment(label,
+ // ITabbedPropertyConstants.HSPACE);
+ data.top = new FormAttachment(-6, 0);
+ data.right = new FormAttachment(removeButton,
+ -ITabbedPropertyConstants.HSPACE);
+ addButton.setLayoutData(data);
+ addButton.addMouseListener(addButtonlistener);
+
+ // Button Up
+ upButton = createButton(composite, "", SWT.PUSH); //$NON-NLS-1$
+ upButton.setVisible(true);
+ upButton.setImage(UP_ELEMENT_IMG);
+ upButton
+ .setToolTipText(EEFRuntimeUIMessages.ReferencesTable_up_tooltip);
+
+ data = new FormData();
+ // data.top = new FormAttachment(removeButton,
+ // ITabbedPropertyConstants.HSPACE);
+ data.top = new FormAttachment(-6, 0);
+ data.right = new FormAttachment(addButton,
+ -ITabbedPropertyConstants.HSPACE);
+ upButton.setLayoutData(data);
+ upButton.addMouseListener(upButtonlistener);
+
+ // Button Down
+ downButton = createButton(composite, "", SWT.PUSH); //$NON-NLS-1$
+ downButton.setVisible(true);
+ downButton.setImage(DOWN_ELEMENT_IMG);
+ downButton
+ .setToolTipText(EEFRuntimeUIMessages.ReferencesTable_down_tooltip);
+
+ data = new FormData();
+ // data.top = new FormAttachment(upButton,
+ // ITabbedPropertyConstants.HSPACE);
+ data.top = new FormAttachment(-6, 0);
+ data.right = new FormAttachment(upButton,
+ -ITabbedPropertyConstants.HSPACE);
+ downButton.setLayoutData(data);
+ downButton.addMouseListener(downButtonlistener);
+
+ // Create label
+ label = createLabel(composite, labelToDisplay, SWT.NONE);
+ // label.setLayout(new FormLayout());
+ data = new FormData();
+ data.left = new FormAttachment(2, 0);
+ data.right = new FormAttachment(downButton,
+ -ITabbedPropertyConstants.HSPACE - 5/* 50 */);
+ data.top = new FormAttachment(0, 0);
+ label.setLayoutData(data);
+
+ // ///////////////////////////////////////////////////////////////////////////
+ // Create and place Table
+ table = createTable(composite, SWT.MULTI | SWT.H_SCROLL | SWT.BORDER);
+ table.setLayout(new FormLayout());
+ table.setVisible(true);
+ table.addListener(SWT.MouseDoubleClick,
+ tableListener = new EditItemListener());
+ // createTable
+ tableViewer = new TableViewer(table);
+
+ // The filters.
+
+ data = new FormData();
+ data.height = 100;
+ data.top = new FormAttachment(label,
+ ITabbedPropertyConstants.VSPACE + 4);
+ data.left = new FormAttachment(0, ITabbedPropertyConstants.HSPACE);
+ data.right = new FormAttachment(100, -ITabbedPropertyConstants.HSPACE);
+
+ table.setLayoutData(data);
+ table.addMouseListener(new MouseListener() {
+
+ @SuppressWarnings("unchecked")
+ public void mouseDoubleClick(MouseEvent e) {
+ if (table.getSelection() != null
+ && table.getSelectionCount() != 0
+ && table.getSelection()[0].getData() instanceof EObject) {
+ // Navigate
+ referencesTableListener.navigateTo((EObject) table
+ .getSelection()[0].getData());
+ }
+ }
+
+ public void mouseDown(MouseEvent e) {
+ }
+
+ public void mouseUp(MouseEvent e) {
+ }
+ });
+ // tableViewer.refresh();
+ // table.pack();
+ }
+
+ /**
+ * @param layoutData
+ * the layoutData to set
+ */
+ public void setLayoutData(Object layoutData) {
+ composite.setLayoutData(layoutData);
+ }
+
+ /**
+ * @param contentProvider
+ * contentProvider to use in the Table
+ */
+ public void setContentProvider(IStructuredContentProvider contentProvider) {
+ this.contentProvider = contentProvider;
+ }
+
+ public void setUpperBound(int value) {
+ if (value < 0)
+ this.upperBound = -1;
+ else
+ this.upperBound = value;
+ }
+
+ public int getUpperBound() {
+ return this.upperBound;
+ }
+
+ public void setLowerBound(int value) {
+ if (value <= 0)
+ this.lowerBound = 0;
+ else
+ this.lowerBound = value;
+ }
+
+ public int getLowerBound() {
+ return this.lowerBound;
+ }
+
+ private int getSize() {
+ if (contentProvider != null && input != null)
+ return contentProvider.getElements(input).length;
+ return -1;
+ }
+
+ private int indexOf(Object elem) {
+ Object[] elements = contentProvider.getElements(input);
+ for (int i = 0; i < elements.length; i++) {
+ Object next = elements[i];
+ if (next.equals(elem))
+ return i;
+
+ }
+ return -1;
+ }
+
+ /**
+ * Sets the given ID to the EMFComboViewer
+ *
+ * @param id
+ * the ID to give
+ */
+ public void setID(Object id) {
+ EditingUtils.setID(table, id);
+ EditingUtils.setID(addButton, id);
+ EditingUtils.setID(removeButton, id);
+ EditingUtils.setID(upButton, id);
+ EditingUtils.setID(downButton, id);
+ }
+
+ /**
+ * Defines the type of reference table
+ *
+ * @param id
+ * the type to give
+ */
+ public void setEEFType(String type) {
+ EditingUtils.setEEFtype(table, type + "::field");
+ EditingUtils.setEEFtype(addButton, type + "::addbutton");
+ EditingUtils.setEEFtype(removeButton, type + "::removebutton");
+ EditingUtils.setEEFtype(upButton, type + "::upbutton");
+ EditingUtils.setEEFtype(downButton, type + "::downbutton");
+ }
+
+ /**
+ * @return the ID of the EObjectFlatComboViewer
+ */
+ public Object getID() {
+ return EditingUtils.getID(table);
+ }
+
+ /**
+ * @param helpText
+ */
+ public void setHelpText(String helpText) {
+ this.helpText = helpText;
+ }
+
+ public void refresh() {
+ tableViewer.refresh();
+ computeAddButtonStatus();
+ computeRemoveButtonStatus();
+ }
+
+ private void computeRemoveButtonStatus() {
+ if (getSize() > this.lowerBound)
+ removeButton.setEnabled(true);
+ else
+ removeButton.setEnabled(false);
+
+ }
+
+ private void computeAddButtonStatus() {
+ if (this.upperBound < 0 || getSize() < this.upperBound)
+ addButton.setEnabled(true);
+ else
+ addButton.setEnabled(false);
+ }
+
+ /**
+ * display the content of the table
+ */
+ public void initLabelProvider() {
+ if (!table.isDisposed()) {
+ // set the label provider
+ tableViewer.setLabelProvider(getLabelProvider());
+ }
+ }
+
+ /**
+ * Returns the label provider for the composite
+ *
+ * @return the label provider or <code>null</code>
+ */
+ public AdapterFactoryLabelProvider getLabelProvider() {
+ return new AdapterFactoryLabelProvider(adapterFactory);
+ }
+
+ /**
+ * Disable Move capability (Hide Up and Down buttons)
+ */
+ public void disableMove() {
+ upButton.setVisible(false);
+ downButton.setVisible(false);
+ }
+
+ /**
+ * Listener for the Add Button Specific behavior is implemented in
+ * {@link ReferencesTable#addButtonPressed()}.
+ *
+ * @author Remi SCHNEKENBURGER
+ */
+ private class AddButtonlistener implements MouseListener {
+
+ /**
+ * {@inheritDoc}
+ */
+ public void mouseDoubleClick(MouseEvent e) {
+ // do nothing
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void mouseDown(MouseEvent e) {
+ // do nothing
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void mouseUp(MouseEvent e) {
+ referencesTableListener.handleAdd();
+
+ }
+ }
+
+ /**
+ * Listener for the Remove Button Specific behavior is implemented in
+ * {@link ReferencesTable#removeButtonPressed()}.
+ *
+ * @author Remi SCHNEKENBURGER
+ */
+ private class RemoveButtonlistener implements MouseListener {
+
+ /**
+ * {@inheritDoc}
+ */
+ public void mouseDoubleClick(MouseEvent e) {
+ // do nothing
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void mouseDown(MouseEvent e) {
+ // do nothing
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @SuppressWarnings("unchecked")
+ public void mouseUp(MouseEvent e) {
+ // Keep selection
+ TableItem[] tableItems = table.getSelection();
+
+ for (int i = (tableItems.length - 1); i >= 0; i--) {
+ // Remove
+ referencesTableListener.handleRemove((EObject) tableItems[i]
+ .getData());
+ }
+ }
+ }
+
+ /**
+ * Listener for the Up Button Specific behavior is implemented in
+ * {@link ReferencesTable#upButtonPressed()}.
+ *
+ * @author Remi SCHNEKENBURGER
+ */
+ private class UpButtonlistener implements MouseListener {
+
+ /**
+ * {@inheritDoc}
+ */
+ public void mouseDoubleClick(MouseEvent e) {
+ // do nothing
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void mouseDown(MouseEvent e) {
+ // do nothing
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @SuppressWarnings("unchecked")
+ public void mouseUp(MouseEvent e) {
+ // Keep selection
+ TableItem[] tableItems = table.getSelection();
+
+ for (int i = 0; i < tableItems.length; i++) {
+ int indexInTable = indexInTable(tableItems[i]);
+ if (indexInTable == 1) {
+ //
+ // Go first
+ referencesTableListener.handleMove((EObject) tableItems[i]
+ .getData(), -1, 0);
+ } else if (indexInTable > 1) {
+ // get previous table item.
+ TableItem previousTableItem = getPreviousTableItem(tableItems[i]);
+ int newIndex = indexOf(previousTableItem.getData());
+ referencesTableListener.handleMove((EObject) tableItems[i]
+ .getData(), -1, newIndex);
+ }
+ }
+
+ }
+ }
+
+ /**
+ * Listener for the Down Button Specific behavior is implemented in
+ * {@link ReferencesTable#downButtonPressed()}.
+ *
+ * @author Remi SCHNEKENBURGER
+ */
+ private class DownButtonlistener implements MouseListener {
+
+ /**
+ * {@inheritDoc}
+ */
+ public void mouseDoubleClick(MouseEvent e) {
+ // do nothing
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void mouseDown(MouseEvent e) {
+ // do nothing
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @SuppressWarnings("unchecked")
+ public void mouseUp(MouseEvent e) {
+ TableItem[] tableItems = table.getSelection();
+ for (int i = (tableItems.length - 1); i >= 0; i--) {
+ int indexInTable = indexInTable(tableItems[i]);
+ if (indexInTable == table.getItemCount() - 2) {
+ //
+ // Go last
+ referencesTableListener.handleMove((EObject) tableItems[i]
+ .getData(), -1,
+ contentProvider.getElements(input).length - 1);
+ } else if (indexInTable < table.getItemCount() - 2) {
+ // get next table item.
+ TableItem nextTableItem = getNextTableItem(tableItems[i]);
+ int newIndex = indexOf(nextTableItem.getData());
+ referencesTableListener.handleMove((EObject) tableItems[i]
+ .getData(), -1, newIndex);
+ }
+ }
+ }
+ }
+
+ /**
+ *
+ */
+ private class EditItemListener implements Listener {
+
+ /** @{inheritDoc */
+ @SuppressWarnings("unchecked")
+ public void handleEvent(Event event) {
+ if (table.getSelection().length > 0) {
+ TableItem item = table.getSelection()[0];
+ // Edit
+ referencesTableListener.handleEdit((EObject) item.getData());
+ }
+ }
+ }
+
+ /**
+ * removes listeners from buttons.
+ */
+ public void dispose() {
+ if (addButton != null && !addButton.isDisposed())
+ addButton.removeMouseListener(addButtonlistener);
+ if (removeButton != null && !removeButton.isDisposed())
+ removeButton.removeMouseListener(removeButtonlistener);
+ if (upButton != null && !upButton.isDisposed())
+ upButton.removeMouseListener(upButtonlistener);
+ if (downButton != null && !downButton.isDisposed())
+ downButton.removeMouseListener(downButtonlistener);
+ if (table != null && !table.isDisposed())
+ table.removeListener(SWT.MouseDoubleClick, tableListener);
+ if (filters != null) {
+ filters.clear();
+ filters = null;
+ }
+ if (bpFilters != null) {
+ bpFilters.clear();
+ bpFilters = null;
+ }
+ }
+
+ private int indexInTable(TableItem tableItem) {
+ for (int i = 0; i < table.getItemCount(); i++) {
+ if (table.getItem(i) == tableItem)
+ return i;
+ }
+ return -1;
+ }
+
+ private TableItem getPreviousTableItem(TableItem tableItem) {
+ int indexInTable = indexInTable(tableItem);
+ return table.getItem(indexInTable - 1);
+ }
+
+ private TableItem getNextTableItem(TableItem tableItem) {
+ int indexInTable = indexInTable(tableItem);
+ return table.getItem(indexInTable + 1);
+ }
+
+ /**
+ * input of viewer
+ *
+ * @param input
+ */
+ public void setInput(Object input) {
+ this.input = input;
+ initLabelProvider();
+ tableViewer.setContentProvider(contentProvider);
+ tableViewer.setInput(input);
+ for (ViewerFilter filter : filters) {
+ this.tableViewer.addFilter(filter);
+ }
+ for (ViewerFilter filter : bpFilters) {
+ this.tableViewer.addFilter(filter);
+ }
+ computeAddButtonStatus();
+ computeRemoveButtonStatus();
+ }
+
+ /**
+ * @return the input of the viewer
+ */
+ public Object getInput() {
+ return input;
+ }
+
+ public interface ReferencesTableListener {
+
+ void handleAdd();
+
+ void handleRemove(EObject element);
+
+ void handleMove(EObject element, int oldIndex, int newIndex);
+
+ void handleEdit(EObject element);
+
+ void navigateTo(EObject element);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @seeorg.eclipse.emf.eef.runtime.ui.widgets.IPropertiesFilteredWidget#
+ * addBusinessRuleFilter(org.eclipse. jface.viewers.ViewerFilter)
+ */
+ public void addBusinessRuleFilter(ViewerFilter filter) {
+ this.bpFilters.add(filter);
+ if (this.tableViewer != null) {
+ this.tableViewer.addFilter(filter);
+ this.tableViewer.refresh();
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.emf.eef.runtime.ui.widgets.IPropertiesFilteredWidget#addFilter
+ * (org.eclipse.jface.viewers .ViewerFilter)
+ */
+ public void addFilter(ViewerFilter filter) {
+ this.filters.add(filter);
+ if (this.tableViewer != null) {
+ this.tableViewer.addFilter(filter);
+ this.tableViewer.refresh();
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @seeorg.eclipse.emf.eef.runtime.ui.widgets.IPropertiesFilteredWidget#
+ * removeBusinessRuleFilter(org.eclipse .jface.viewers.ViewerFilter)
+ */
+ public void removeBusinessRuleFilter(ViewerFilter filter) {
+ this.bpFilters.remove(filter);
+ if (this.tableViewer != null) {
+ this.tableViewer.removeFilter(filter);
+ this.tableViewer.refresh();
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.emf.eef.runtime.ui.widgets.IPropertiesFilteredWidget#removeFilter
+ * (org.eclipse.jface.viewers .ViewerFilter)
+ */
+ public void removeFilter(ViewerFilter filter) {
+ this.filters.remove(filter);
+ if (this.tableViewer != null) {
+ this.tableViewer.removeFilter(filter);
+ this.tableViewer.refresh();
+ }
+ }
+
+ protected void refreshFilters() {
+ }
+
+ /**
+ * Sets the tables readonly or not
+ *
+ * @param enabled
+ * to set the table readonly or not
+ */
+ public void setEnabled(boolean enabled) {
+ addButton.setEnabled(enabled);
+ downButton.setEnabled(enabled);
+ removeButton.setEnabled(enabled);
+ table.setEnabled(enabled);
+ upButton.setEnabled(enabled);
+ }
+
+ /**
+ * Sets the tooltip text for the viewer
+ *
+ * @param tooltip
+ * the tooltip text
+ */
+ public void setToolTipText(String tooltip) {
+ addButton.setToolTipText(tooltip);
+ downButton.setToolTipText(tooltip);
+ removeButton.setToolTipText(tooltip);
+ table.setToolTipText(tooltip);
+ upButton.setToolTipText(tooltip);
+ }
+
+ /**
+ * Returns the table.
+ *
+ * @return the table.
+ */
+ public Table getTable() {
+ return table;
+ }
+
+}
diff --git a/plugins/org.eclipse.emf.eef.views/std/EMFProperties.toolkits b/plugins/org.eclipse.emf.eef.views/std/EMFProperties.toolkits
index bfe221c88..49fcea924 100644
--- a/plugins/org.eclipse.emf.eef.views/std/EMFProperties.toolkits
+++ b/plugins/org.eclipse.emf.eef.views/std/EMFProperties.toolkits
@@ -15,4 +15,6 @@
<widgets name="SingleCompositionViewer"/>
<widgets name="SelectionDialog"/>
<widgets name="SingleCompositionEditor" implementation=""/>
+ <widgets name="LinkEObjectFlatComboViewer"/>
+ <widgets name="LinkReferencesTable"/>
</eef-views:Toolkit>

Back to the top