Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpsabeva2012-03-26 10:35:23 -0400
committerpsabeva2012-03-26 10:35:23 -0400
commitb6b980a61465e86a3d5b22ae89f3256d46a289ab (patch)
tree6b28da138628af2a5599518da61449f228fd22d1
parentf51f3f16544fbe0f2f904198d4e6837ec2676d2a (diff)
downloadwebtools.dali-b6b980a61465e86a3d5b22ae89f3256d46a289ab.tar.gz
webtools.dali-b6b980a61465e86a3d5b22ae89f3256d46a289ab.tar.xz
webtools.dali-b6b980a61465e86a3d5b22ae89f3256d46a289ab.zip
[375333] - Enable the missing open diagram menu action item on JPA Content tree node
-rw-r--r--jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/plugin.xml27
-rw-r--r--jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/modelintegration/ui/OpenJpaDiagramActionDelegate.java5
-rw-r--r--jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/propertytester/JpaContentNodeFacetProjectVersionPropertyTester.java28
3 files changed, 59 insertions, 1 deletions
diff --git a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/plugin.xml b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/plugin.xml
index aed3594d4f..a97d25c12e 100644
--- a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/plugin.xml
+++ b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/plugin.xml
@@ -29,6 +29,26 @@
<extension
point="org.eclipse.ui.popupMenus">
+ <objectContribution
+ adaptable="false"
+ id="org.eclipse.jpt.jpadiagrameditor.ui.openDiagramOnJpaContentNode"
+ nameFilter="*"
+ objectClass="org.eclipse.jpt.jpa.ui.JpaRootContextNodeModel">
+
+ <enablement>
+ <test property="org.eclipse.jpt.jpadiagrameditor.ui.jpaContentNodeFacet" value="jpt.jpa"/>
+ </enablement>
+ <menu
+ id="org.eclipse.jpt.jpadiagrameditor.ui.openDiagramJpaContentNodeMenu"
+ label="%diagrameditor.opendiagram.menu.label">
+ </menu>
+ <action
+ class="org.eclipse.jpt.jpadiagrameditor.ui.internal.modelintegration.ui.OpenJpaDiagramActionDelegate"
+ enablesFor="1"
+ id="org.eclipse.jpt.jpadiagrameditor.ui.openDiagramOnJpaContentNodeAction"
+ label="%diagrameditor.opendiagram.action.label">
+ </action>
+ </objectContribution>
<objectContribution
adaptable="false"
id="org.eclipse.jpt.jpadiagrameditor.ui.openDiagramJpa"
@@ -144,6 +164,13 @@
properties="jpaProjectFacet"
class="org.eclipse.jpt.jpadiagrameditor.ui.internal.propertytester.JpaProjectFacetVersionPropertyTester">
</propertyTester>
+ <propertyTester
+ class="org.eclipse.jpt.jpadiagrameditor.ui.internal.propertytester.JpaContentNodeFacetProjectVersionPropertyTester"
+ id="org.eclipse.jpt.jpadiagrameditor.ui.JpaContentNodeFacetVersionPropertyTester"
+ namespace="org.eclipse.jpt.jpadiagrameditor.ui"
+ properties="jpaContentNodeFacet"
+ type="org.eclipse.jpt.jpa.ui.JpaRootContextNodeModel">
+ </propertyTester>
</extension>
</plugin>
diff --git a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/modelintegration/ui/OpenJpaDiagramActionDelegate.java b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/modelintegration/ui/OpenJpaDiagramActionDelegate.java
index ce5aaf00fe..4e41b2c356 100644
--- a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/modelintegration/ui/OpenJpaDiagramActionDelegate.java
+++ b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/modelintegration/ui/OpenJpaDiagramActionDelegate.java
@@ -44,6 +44,7 @@ import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jpt.jpa.core.JpaNode;
import org.eclipse.jpt.jpa.core.JpaProject;
import org.eclipse.jpt.jpa.core.context.persistence.PersistenceUnit;
+import org.eclipse.jpt.jpa.ui.JpaRootContextNodeModel;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.JPADiagramEditor;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.JPADiagramEditorPlugin;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.i18n.JPAEditorMessages;
@@ -175,7 +176,9 @@ public class OpenJpaDiagramActionDelegate implements IObjectActionDelegate {
protected PersistenceUnit obtainJpaProjectAndPersistenceUnit(ISelection selection) throws CoreException {
Object firstElement = ((IStructuredSelection) selection).getFirstElement();
- if (firstElement instanceof JpaNode) {
+ if(firstElement instanceof JpaRootContextNodeModel){
+ jpaProject = JpaArtifactFactory.instance().getJpaProject(((JpaRootContextNodeModel)firstElement).getProject());
+ } else if (firstElement instanceof JpaNode) {
jpaProject = ((JpaNode)firstElement).getJpaProject();
} else if (firstElement instanceof IProject) {
int cnt = 0;
diff --git a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/propertytester/JpaContentNodeFacetProjectVersionPropertyTester.java b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/propertytester/JpaContentNodeFacetProjectVersionPropertyTester.java
new file mode 100644
index 0000000000..6f7b97daa7
--- /dev/null
+++ b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/propertytester/JpaContentNodeFacetProjectVersionPropertyTester.java
@@ -0,0 +1,28 @@
+package org.eclipse.jpt.jpadiagrameditor.ui.internal.propertytester;
+
+import org.eclipse.core.expressions.PropertyTester;
+import org.eclipse.jpt.jpa.ui.JpaRootContextNodeModel;
+import org.eclipse.wst.common.project.facet.core.IProjectFacet;
+import org.eclipse.wst.common.project.facet.core.ProjectFacetsManager;
+
+public class JpaContentNodeFacetProjectVersionPropertyTester extends
+ PropertyTester {
+
+
+ public static final String ID = "jpt.jpa"; //$NON-NLS-1$
+ public static final IProjectFacet FACET = ProjectFacetsManager.getProjectFacet(ID);
+
+ public boolean test(Object receiver, String property, Object[] args,
+ Object value) {
+
+ String[] subValues = ((String) value).split(":"); //$NON-NLS-1$
+ String receiverId = subValues[0];
+
+ if (receiver instanceof JpaRootContextNodeModel) {
+ if(receiverId.equals(ID)){
+ return true;
+ }
+ }
+ return false;
+ }
+}

Back to the top