Changes for extention support for ogee 

Change-Id: I9b05d441a91bdd32847954937749e01667823b17
Signed-off-by: Joy Bhattacharjee <joy.bhattacharjee@sap.com>
diff --git a/org.eclipse.ogee.designer/META-INF/MANIFEST.MF b/org.eclipse.ogee.designer/META-INF/MANIFEST.MF
index 7a7d2c4..71217b9 100644
--- a/org.eclipse.ogee.designer/META-INF/MANIFEST.MF
+++ b/org.eclipse.ogee.designer/META-INF/MANIFEST.MF
@@ -37,6 +37,7 @@
  org.eclipse.ogee.designer.api,
  org.eclipse.ogee.designer.contextmenu,
  org.eclipse.ogee.designer.layout,
+ org.eclipse.ogee.designer.providers,
  org.eclipse.ogee.designer.utils
 
 
diff --git a/org.eclipse.ogee.designer/plugin.xml b/org.eclipse.ogee.designer/plugin.xml
index 03693e3..1604985 100644
--- a/org.eclipse.ogee.designer/plugin.xml
+++ b/org.eclipse.ogee.designer/plugin.xml
@@ -22,6 +22,7 @@
     	name="%extensionpoint.name"
      	schema="schema/org.eclipse.ogee.designer.layout.exsd"/>
    <extension-point id="org.eclipse.ogee.designer.contextmenu" name="Context Menu" schema="schema/org.eclipse.ogee.designer.contextmenu.exsd"/>
+   <extension-point id="org.eclipse.ogee.designer.bindingcontextmenu" name="BindingContextMenu" schema="schema/org.eclipse.ogee.designer.bindingcontextmenu.exsd"/>
      
    <extension
          point="org.eclipse.graphiti.ui.diagramTypes">
diff --git a/org.eclipse.ogee.designer/schema/org.eclipse.ogee.designer.bindingcontextmenu.exsd b/org.eclipse.ogee.designer/schema/org.eclipse.ogee.designer.bindingcontextmenu.exsd
new file mode 100644
index 0000000..2322bf8
--- /dev/null
+++ b/org.eclipse.ogee.designer/schema/org.eclipse.ogee.designer.bindingcontextmenu.exsd
@@ -0,0 +1,154 @@
+<?xml version='1.0' encoding='UTF-8'?>

+<!-- Schema file written by PDE -->

+<schema targetNamespace="org.eclipse.ogee.designer" xmlns="http://www.w3.org/2001/XMLSchema">

+<annotation>

+      <appinfo>

+         <meta.schema plugin="org.eclipse.ogee.designer" id="org.eclipse.ogee.designer.bindingcontextmenu" name="BindingContextMenu"/>

+      </appinfo>

+      <documentation>

+         This extension needs to be implemented to add an additional  menu item to the already existing context menu items for the specified UI elements in the OData Model Editor and it extends IContextMenu

+      </documentation>

+   </annotation>

+

+   <element name="extension">

+      <annotation>

+         <appinfo>

+            <meta.element />

+         </appinfo>

+      </annotation>

+      <complexType>

+         <choice minOccurs="1" maxOccurs="unbounded">

+            <element ref="bindingcontextmenu"/>

+         </choice>

+         <attribute name="point" type="string" use="required">

+            <annotation>

+               <documentation>

+                  

+               </documentation>

+            </annotation>

+         </attribute>

+         <attribute name="id" type="string">

+            <annotation>

+               <documentation>

+                  

+               </documentation>

+            </annotation>

+         </attribute>

+         <attribute name="name" type="string">

+            <annotation>

+               <documentation>

+                  

+               </documentation>

+               <appinfo>

+                  <meta.attribute translatable="true"/>

+               </appinfo>

+            </annotation>

+         </attribute>

+      </complexType>

+   </element>

+

+   <element name="bindingcontextmenu">

+      <annotation>

+         <documentation>

+            This extention will allow to get handle to the PictogramElement and EObject resource

+         </documentation>

+      </annotation>

+      <complexType>

+         <attribute name="class" type="string" use="required">

+            <annotation>

+               <documentation>

+                  The interface class needs to be implement by extention provider

+               </documentation>

+               <appinfo>

+                  <meta.attribute kind="java" basedOn=":org.eclipse.ogee.designer.contextmenu.IBindingContextMenu"/>

+               </appinfo>

+            </annotation>

+         </attribute>

+         <attribute name="name" type="string" use="required">

+            <annotation>

+               <documentation>

+                  The name of the context menu action which will appear.

+               </documentation>

+               <appinfo>

+                  <meta.attribute translatable="true"/>

+               </appinfo>

+            </annotation>

+         </attribute>

+         <attribute name="id" type="string" use="required">

+            <annotation>

+               <documentation>

+                  The id of the binding context menu.

+               </documentation>

+               <appinfo>

+                  <meta.attribute translatable="true"/>

+               </appinfo>

+            </annotation>

+         </attribute>

+         <attribute name="parent_name" type="string">

+            <annotation>

+               <documentation>

+                  If a submenu is required then the name of the parent menu should be provided in this field.

+               </documentation>

+               <appinfo>

+                  <meta.attribute translatable="true"/>

+               </appinfo>

+            </annotation>

+         </attribute>

+         <attribute name="icon" type="string">

+            <annotation>

+               <documentation>

+                  The icon which gets attached and displayed with the binding custom menu.

+               </documentation>

+               <appinfo>

+                  <meta.attribute kind="resource"/>

+               </appinfo>

+            </annotation>

+         </attribute>

+         <attribute name="key_binding" type="string">

+            <annotation>

+               <documentation>

+                  The shortcut command which needs to be binded to the context menu.

+               </documentation>

+            </annotation>

+         </attribute>

+      </complexType>

+   </element>

+

+   <annotation>

+      <appinfo>

+         <meta.section type="since"/>

+      </appinfo>

+      <documentation>

+         [Enter the first release in which this extension point appears.]

+      </documentation>

+   </annotation>

+

+   <annotation>

+      <appinfo>

+         <meta.section type="examples"/>

+      </appinfo>

+      <documentation>

+         [Enter extension point usage example here.]

+      </documentation>

+   </annotation>

+

+   <annotation>

+      <appinfo>

+         <meta.section type="apiinfo"/>

+      </appinfo>

+      <documentation>

+         [Enter API information here.]

+      </documentation>

+   </annotation>

+

+   <annotation>

+      <appinfo>

+         <meta.section type="implementation"/>

+      </appinfo>

+      <documentation>

+         [Enter information about supplied implementation of this extension point.]

+      </documentation>

+   </annotation>

+

+

+</schema>

diff --git a/org.eclipse.ogee.designer/src/org/eclipse/ogee/designer/contextmenu/IBindingContextMenu.java b/org.eclipse.ogee.designer/src/org/eclipse/ogee/designer/contextmenu/IBindingContextMenu.java
new file mode 100644
index 0000000..d96f12f
--- /dev/null
+++ b/org.eclipse.ogee.designer/src/org/eclipse/ogee/designer/contextmenu/IBindingContextMenu.java
@@ -0,0 +1,20 @@
+package org.eclipse.ogee.designer.contextmenu;

+

+import org.eclipse.emf.ecore.EObject;

+import org.eclipse.graphiti.mm.pictograms.PictogramElement;

+

+/**

+ * This extension needs to be implemented to add an additional  menu item to the

+ * already existing context menu items for the specified UI elements in the

+ * OData Model Editor and it extends IContextMenu

+ * 

+ */

+

+public interface IBindingContextMenu extends IContextMenu {

+	

+	//To pass  handle of the PictogramElement to the extension implementing this interface

+	void setPictogramElement(PictogramElement pe);

+	//To pass  handle of the PictogramElement to the extension implementing this interface

+	void setBusinessObject(EObject businessObject);

+

+}

diff --git a/org.eclipse.ogee.designer/src/org/eclipse/ogee/designer/contextmenu/UIElementType.java b/org.eclipse.ogee.designer/src/org/eclipse/ogee/designer/contextmenu/UIElementType.java
index 6539b17..193fc96 100644
--- a/org.eclipse.ogee.designer/src/org/eclipse/ogee/designer/contextmenu/UIElementType.java
+++ b/org.eclipse.ogee.designer/src/org/eclipse/ogee/designer/contextmenu/UIElementType.java
@@ -23,6 +23,8 @@
 	COMPLEX_TYPE,
 
 	FUNCTION_IMPORT,
+	
+	ENTITY_SET,
 
 	ALL;
 
diff --git a/org.eclipse.ogee.designer/src/org/eclipse/ogee/designer/features/ODataContextMenuFeature.java b/org.eclipse.ogee.designer/src/org/eclipse/ogee/designer/features/ODataContextMenuFeature.java
index a9cc515..7deb1c7 100644
--- a/org.eclipse.ogee.designer/src/org/eclipse/ogee/designer/features/ODataContextMenuFeature.java
+++ b/org.eclipse.ogee.designer/src/org/eclipse/ogee/designer/features/ODataContextMenuFeature.java
@@ -14,9 +14,11 @@
 import java.util.EnumSet;

 

 import org.eclipse.emf.ecore.EObject;

-import org.eclipse.graphiti.features.IFeatureProvider;

 import org.eclipse.graphiti.features.context.ICustomContext;

 import org.eclipse.graphiti.features.custom.AbstractCustomFeature;

+import org.eclipse.graphiti.mm.pictograms.PictogramElement;

+import org.eclipse.graphiti.ui.editor.DiagramEditor;

+import org.eclipse.ogee.designer.contextmenu.IBindingContextMenu;

 import org.eclipse.ogee.designer.contextmenu.IContextMenu;

 import org.eclipse.ogee.designer.contextmenu.UIElementType;

 import org.eclipse.ogee.designer.messages.Messages;

@@ -32,18 +34,21 @@
 	 */

 	private IContextMenu currentContextMenu;

 	private EObject businessObject;

+	private PictogramElement pe ;

 

 	/**

 	 * @param fp

 	 * @param currentContextMenu

 	 */

-	public ODataContextMenuFeature(IFeatureProvider fp,

+	public ODataContextMenuFeature(DiagramEditor editor ,

 			IContextMenu currentContextMenu, EObject businessObject) {

-		super(fp);

+		super(editor.getDiagramTypeProvider().getFeatureProvider());

 		this.currentContextMenu = currentContextMenu;

 		this.businessObject = businessObject;

+		this.pe = editor.getDiagramTypeProvider().getFeatureProvider().getPictogramElementForBusinessObject(businessObject);

 	}

 

+

 	@Override

 	public String getDescription() {

 		return Messages.ODATAEDITOR_CONTEXT_MENU_DESCRIPTION;

@@ -83,6 +88,10 @@
 	@Override

 	public void execute(ICustomContext context) {

 		this.currentContextMenu.menuAction(businessObject);

+		if(currentContextMenu instanceof IBindingContextMenu){

+			((IBindingContextMenu) currentContextMenu).setBusinessObject(this.businessObject);

+			((IBindingContextMenu) currentContextMenu).setPictogramElement(this.pe);

+		}

 	}

 

 }

diff --git a/org.eclipse.ogee.designer/src/org/eclipse/ogee/designer/providers/ODataDiagramContextMenuProvider.java b/org.eclipse.ogee.designer/src/org/eclipse/ogee/designer/providers/ODataDiagramContextMenuProvider.java
index 8abe687..f53697a 100644
--- a/org.eclipse.ogee.designer/src/org/eclipse/ogee/designer/providers/ODataDiagramContextMenuProvider.java
+++ b/org.eclipse.ogee.designer/src/org/eclipse/ogee/designer/providers/ODataDiagramContextMenuProvider.java
@@ -320,11 +320,9 @@
 				plugin_id = contextMenuOptions[i][4];
 				key_binding = contextMenuOptions[i][5];
 
-				contextMenuFeature = new ODataContextMenuFeature(getEditor()
-						.getDiagramTypeProvider().getFeatureProvider(),
-						ODataContextMenuUtil
-								.getCurrentContextMenu(contextMenuId),
-						businessObject);
+				contextMenuFeature = new ODataContextMenuFeature(getEditor(),ODataContextMenuUtil
+						.getCurrentContextMenu(contextMenuId),
+				businessObject);
 				EnumSet<UIElementType> uiElementTypeSet = contextMenuFeature
 						.getElements();
 				// to iterate through each uielement from uielementset
@@ -490,6 +488,14 @@
 									new PictogramElement[] { pe });
 						}
 						break;
+					case ENTITY_SET:
+						if (ArtifactUtil.isEntitySet(businessObject)
+								) {
+							pe = ODataShapeUtil.getTopContainer(pe);
+							contextMenuContext = new CustomContext(
+									new PictogramElement[] { pe });
+						}
+						break;
 					default:
 						break;
 					}
diff --git a/org.eclipse.ogee.designer/src/org/eclipse/ogee/designer/utils/IODataEditorConstants.java b/org.eclipse.ogee.designer/src/org/eclipse/ogee/designer/utils/IODataEditorConstants.java
index 70d2bea..46348e0 100644
--- a/org.eclipse.ogee.designer/src/org/eclipse/ogee/designer/utils/IODataEditorConstants.java
+++ b/org.eclipse.ogee.designer/src/org/eclipse/ogee/designer/utils/IODataEditorConstants.java
@@ -310,6 +310,12 @@
 			+ ".contextmenu"; //$NON-NLS-1$
 	
 	/**
+	 * String Constant for Extension Menu Extension Point ID
+	 */
+	public static final String CONTEXT_MENU_BINDING_EXTENSIONPOINT_ID = Activator.PLUGIN_ID
+			+ ".bindingcontextmenu"; //$NON-NLS-1$
+	
+	/**
 	 * String Constant for Context Menu Extension Attribute "name"
 	 */
 	public static final String CONTEXT_MENU_ATTRIBUTE_NAME = "name"; //$NON-NLS-1$
diff --git a/org.eclipse.ogee.designer/src/org/eclipse/ogee/designer/utils/ODataContextMenuUtil.java b/org.eclipse.ogee.designer/src/org/eclipse/ogee/designer/utils/ODataContextMenuUtil.java
index 0d40ac4..0b4c64d 100644
--- a/org.eclipse.ogee.designer/src/org/eclipse/ogee/designer/utils/ODataContextMenuUtil.java
+++ b/org.eclipse.ogee.designer/src/org/eclipse/ogee/designer/utils/ODataContextMenuUtil.java
@@ -36,8 +36,22 @@
 		IConfigurationElement[] extensionMenuConfigElems = Platform

 				.getExtensionRegistry().getConfigurationElementsFor(

 						IODataEditorConstants.CONTEXT_MENU_EXTENSIONPOINT_ID);

-

-		return extensionMenuConfigElems;

+		

+		IConfigurationElement[] extensionBindingMenuConfigElems = Platform

+				.getExtensionRegistry().getConfigurationElementsFor(

+						IODataEditorConstants.CONTEXT_MENU_BINDING_EXTENSIONPOINT_ID);

+		

+		int arrLen = extensionMenuConfigElems.length + extensionBindingMenuConfigElems.length;

+		IConfigurationElement[] extensionTotalMenuConfigElems = new IConfigurationElement[arrLen];

+		

+		for( int index = 0 ; index < extensionMenuConfigElems.length ; index++){

+			extensionTotalMenuConfigElems[index] = extensionMenuConfigElems[index];

+		}

+		for( int index = 0 ; index < extensionBindingMenuConfigElems.length ; index++){

+			extensionTotalMenuConfigElems[extensionMenuConfigElems.length + index] = extensionBindingMenuConfigElems[index];

+		}

+		

+		return extensionTotalMenuConfigElems;

 	}

 

 	/**