geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bjr...@apache.org
Subject svn commit: r705002 - in /geronimo/devtools/eclipse-plugin/trunk/plugins: org.apache.geronimo.st.core/src/main/java/org/apache/geronimo/st/core/jaxb/ org.apache.geronimo.st.ui/src/main/java/org/apache/geronimo/st/ui/internal/ org.apache.geronimo.st.v21...
Date Wed, 15 Oct 2008 19:34:28 GMT
Author: bjreed
Date: Wed Oct 15 12:34:27 2008
New Revision: 705002

URL: http://svn.apache.org/viewvc?rev=705002&view=rev
Log:
GERONIMODEVTOOLS-384 adding EJB Relation section to the naming page

Added:
    geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v21.ui/src/main/java/org/apache/geronimo/st/v21/ui/sections/EjbRelationSection.java
  (with props)
    geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v21.ui/src/main/java/org/apache/geronimo/st/v21/ui/wizards/EjbRelationWizard.java
  (with props)
Modified:
    geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.core/src/main/java/org/apache/geronimo/st/core/jaxb/MarshallerListener.java
    geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.ui/src/main/java/org/apache/geronimo/st/ui/internal/Messages.java
    geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.ui/src/main/java/org/apache/geronimo/st/ui/internal/Messages.properties
    geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v21.core/src/main/java/org/apache/geronimo/st/v21/core/jaxb/JAXBModelUtils.java
    geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v21.core/src/main/java/org/apache/geronimo/st/v21/core/jaxb/JAXBObjectFactoryImpl.java
    geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v21.ui/src/main/java/org/apache/geronimo/st/v21/ui/pages/NamingFormPage.java

Modified: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.core/src/main/java/org/apache/geronimo/st/core/jaxb/MarshallerListener.java
URL: http://svn.apache.org/viewvc/geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.core/src/main/java/org/apache/geronimo/st/core/jaxb/MarshallerListener.java?rev=705002&r1=705001&r2=705002&view=diff
==============================================================================
--- geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.core/src/main/java/org/apache/geronimo/st/core/jaxb/MarshallerListener.java
(original)
+++ geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.core/src/main/java/org/apache/geronimo/st/core/jaxb/MarshallerListener.java
Wed Oct 15 12:34:27 2008
@@ -22,7 +22,9 @@
 import org.apache.geronimo.jee.naming.Pattern;
 import org.apache.geronimo.jee.naming.PersistenceContextRef;
 import org.apache.geronimo.jee.naming.ResourceLocator;
+import org.apache.geronimo.jee.openejb.EjbRelationshipRole;
 import org.apache.geronimo.jee.openejb.OpenejbJar;
+import org.apache.geronimo.jee.openejb.Relationships;
 import org.apache.geronimo.jee.security.Security;
 import org.apache.geronimo.jee.web.WebApp;
 
@@ -47,11 +49,20 @@
             if (locator != null && isEmpty(locator.getResourceLink()) &&
isEmpty(locator.getUrl()) && isEmpty(locator.getPattern())) {
                 openejb.setCmpConnectionFactory(null);
             }
+            Relationships relationships = openejb.getRelationships();
+            if (relationships != null && relationships.getEjbRelation().size() ==
0) {
+                openejb.setRelationships(null);
+            }
         } else if (source instanceof PersistenceContextRef) {
             PersistenceContextRef contextRef = (PersistenceContextRef)source;
             if (contextRef.getPattern() != null && isEmpty(contextRef.getPattern()))
{
                 contextRef.setPattern(null);
             }
+        } else if (source instanceof EjbRelationshipRole) {
+            EjbRelationshipRole role = (EjbRelationshipRole)source;
+            if (role.getRoleMapping() != null && role.getRoleMapping().getCmrFieldMapping().size()
== 0) {
+                role.setRoleMapping(null);
+            }
         }
     }
         

Modified: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.ui/src/main/java/org/apache/geronimo/st/ui/internal/Messages.java
URL: http://svn.apache.org/viewvc/geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.ui/src/main/java/org/apache/geronimo/st/ui/internal/Messages.java?rev=705002&r1=705001&r2=705002&view=diff
==============================================================================
--- geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.ui/src/main/java/org/apache/geronimo/st/ui/internal/Messages.java
(original)
+++ geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.ui/src/main/java/org/apache/geronimo/st/ui/internal/Messages.java
Wed Oct 15 12:34:27 2008
@@ -211,6 +211,8 @@
     //
     public static String editorEjbRefDescription;
     public static String editorEjbRefTitle;
+    public static String editorEjbRelationDescription;
+    public static String editorEjbRelationTitle;
     // Buttons
     public static String add;
     public static String remove;
@@ -246,6 +248,11 @@
     public static String wizardPageTitle_EjbRef;
     public static String wizardPageDescription_EjbRef;
     //
+    public static String wizardNewTitle_EjbRelation;
+    public static String wizardEditTitle_EjbRelation;
+    public static String wizardPageTitle_EjbRelation;
+    public static String wizardPageDescription_EjbRelation;
+    //
     public static String wizardNewTitle_EjbLocalRef;
     public static String wizardEditTitle_EjbLocalRef;
     public static String wizardPageTitle_EjbLocalRef;
@@ -287,6 +294,11 @@
     public static String contextName;
     public static String unitRefName;
     public static String unitName;
+    public static String mtmTableName;
+    public static String ejbSourceName;
+    public static String cmrFieldName;
+    public static String keyColumn;
+    public static String foreignKeyColumn;
     //
     public static String wizardNewTitle_Import;
     public static String wizardEditTitle_Import;

Modified: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.ui/src/main/java/org/apache/geronimo/st/ui/internal/Messages.properties
URL: http://svn.apache.org/viewvc/geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.ui/src/main/java/org/apache/geronimo/st/ui/internal/Messages.properties?rev=705002&r1=705001&r2=705002&view=diff
==============================================================================
--- geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.ui/src/main/java/org/apache/geronimo/st/ui/internal/Messages.properties
(original)
+++ geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.ui/src/main/java/org/apache/geronimo/st/ui/internal/Messages.properties
Wed Oct 15 12:34:27 2008
@@ -145,6 +145,8 @@
 
 editorEjbLocalRefDescription=The following ejb local refererencs are defined:
 editorEjbLocalRefTitle=EJB Local References
+editorEjbRelationDescription = The following ejb relations are defined:
+editorEjbRelationTitle = EJB Relations
 
 add=Add
 remove=Remove
@@ -165,6 +167,11 @@
 wizardPageTitle_EjbRef=EJB Reference Details
 wizardPageDescription_EjbRef=Provide details for this ejb reference.
 
+wizardNewTitle_EjbRelation=New EJB Relation
+wizardEditTitle_EjbRelation=Edit EJB Relation
+wizardPageTitle_EjbRelation=EJB Relation Details
+wizardPageDescription_EjbRelation=Provide details for this EJB Relation.
+
 wizardNewTitle_ServiceRef=New Service Reference
 wizardEditTitle_ServiceRef=Edit Service Reference
 wizardPageTitle_ServiceRef=Service Reference Details
@@ -265,6 +272,11 @@
 contextName=Context Name
 unitRefName=Unit Ref Name
 unitName=Unit Name
+mtmTableName=MTM Table Name
+ejbSourceName=EJB Source Name
+cmrFieldName=CMR Field Name
+keyColumn=Key Column
+foreignKeyColumn=Foreign Key Column
 
 messageDestinationName=Message Destination Name
 adminModule=Admin Module

Modified: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v21.core/src/main/java/org/apache/geronimo/st/v21/core/jaxb/JAXBModelUtils.java
URL: http://svn.apache.org/viewvc/geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v21.core/src/main/java/org/apache/geronimo/st/v21/core/jaxb/JAXBModelUtils.java?rev=705002&r1=705001&r2=705002&view=diff
==============================================================================
--- geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v21.core/src/main/java/org/apache/geronimo/st/v21/core/jaxb/JAXBModelUtils.java
(original)
+++ geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v21.core/src/main/java/org/apache/geronimo/st/v21/core/jaxb/JAXBModelUtils.java
Wed Oct 15 12:34:27 2008
@@ -25,6 +25,7 @@
 import org.apache.geronimo.jee.connector.Connector;
 import org.apache.geronimo.jee.deployment.Environment;
 import org.apache.geronimo.jee.openejb.OpenejbJar;
+import org.apache.geronimo.jee.openejb.Relationships;
 import org.apache.geronimo.jee.security.Security;
 import org.apache.geronimo.jee.web.WebApp;
 
@@ -178,6 +179,21 @@
         return null;
     }
 
+    public static List getEjbRelationships (JAXBElement element) {
+        Object plan = element.getValue();
+        if (OpenejbJar.class.isInstance (plan)) {
+            return ((OpenejbJar)plan).getRelationships() == null ? null : ((OpenejbJar)plan).getRelationships().getEjbRelation();
+        }
+        return null;
+    }
+    
+    public static void setEjbRelationships (JAXBElement element, Relationships relationships
) {
+        Object plan = element.getValue();
+        if (OpenejbJar.class.isInstance (plan)) {
+            ((OpenejbJar)plan).setRelationships(relationships);
+        }
+    }
+    
     public static List getMessageDestinations (JAXBElement element) {
         Object plan = element.getValue();
         if (WebApp.class.isInstance (plan)) {

Modified: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v21.core/src/main/java/org/apache/geronimo/st/v21/core/jaxb/JAXBObjectFactoryImpl.java
URL: http://svn.apache.org/viewvc/geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v21.core/src/main/java/org/apache/geronimo/st/v21/core/jaxb/JAXBObjectFactoryImpl.java?rev=705002&r1=705001&r2=705002&view=diff
==============================================================================
--- geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v21.core/src/main/java/org/apache/geronimo/st/v21/core/jaxb/JAXBObjectFactoryImpl.java
(original)
+++ geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v21.core/src/main/java/org/apache/geronimo/st/v21/core/jaxb/JAXBObjectFactoryImpl.java
Wed Oct 15 12:34:27 2008
@@ -41,6 +41,9 @@
 import org.apache.geronimo.jee.naming.ResourceEnvRef;
 import org.apache.geronimo.jee.naming.ResourceRef;
 import org.apache.geronimo.jee.naming.ServiceRef;
+import org.apache.geronimo.jee.openejb.EjbRelation;
+import org.apache.geronimo.jee.openejb.EjbRelationshipRole;
+import org.apache.geronimo.jee.openejb.Relationships;
 import org.apache.geronimo.jee.security.Description;
 import org.apache.geronimo.jee.security.DistinguishedName;
 import org.apache.geronimo.jee.security.LoginDomainPrincipal;
@@ -134,6 +137,20 @@
             return (new org.apache.geronimo.jee.application.ObjectFactory()).createModule();
         } else if ( type.equals( Path.class ) ) {
             return (new org.apache.geronimo.jee.application.ObjectFactory()).createPath();
+        } else if ( type.equals( EjbRelation.class ) ) {
+            return (new org.apache.geronimo.jee.openejb.ObjectFactory()).createEjbRelation();
+        } else if ( type.equals( EjbRelationshipRole.class ) ) {
+            return (new org.apache.geronimo.jee.openejb.ObjectFactory()).createEjbRelationshipRole();
+        } else if ( type.equals( EjbRelationshipRole.RelationshipRoleSource.class ) ) {
+            return (new org.apache.geronimo.jee.openejb.ObjectFactory()).createEjbRelationshipRoleRelationshipRoleSource();
+        } else if ( type.equals( EjbRelationshipRole.CmrField.class ) ) {
+            return (new org.apache.geronimo.jee.openejb.ObjectFactory()).createEjbRelationshipRoleCmrField();
+        } else if ( type.equals( EjbRelationshipRole.RoleMapping.CmrFieldMapping.class )
) {
+            return (new org.apache.geronimo.jee.openejb.ObjectFactory()).createEjbRelationshipRoleRoleMappingCmrFieldMapping();
+        } else if ( type.equals( EjbRelationshipRole.RoleMapping.class ) ) {
+            return (new org.apache.geronimo.jee.openejb.ObjectFactory()).createEjbRelationshipRoleRoleMapping();
+        } else if ( type.equals( Relationships.class ) ) {
+            return (new org.apache.geronimo.jee.openejb.ObjectFactory()).createRelationships();
         }
         
         return null;

Modified: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v21.ui/src/main/java/org/apache/geronimo/st/v21/ui/pages/NamingFormPage.java
URL: http://svn.apache.org/viewvc/geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v21.ui/src/main/java/org/apache/geronimo/st/v21/ui/pages/NamingFormPage.java?rev=705002&r1=705001&r2=705002&view=diff
==============================================================================
--- geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v21.ui/src/main/java/org/apache/geronimo/st/v21/ui/pages/NamingFormPage.java
(original)
+++ geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v21.ui/src/main/java/org/apache/geronimo/st/v21/ui/pages/NamingFormPage.java
Wed Oct 15 12:34:27 2008
@@ -25,6 +25,7 @@
 import org.apache.geronimo.st.v21.core.GeronimoServerInfo;
 import org.apache.geronimo.st.v21.ui.sections.EjbLocalRefSection;
 import org.apache.geronimo.st.v21.ui.sections.EjbRefSection;
+import org.apache.geronimo.st.v21.ui.sections.EjbRelationSection;
 import org.apache.geronimo.st.v21.ui.sections.GBeanRefSection;
 import org.apache.geronimo.st.v21.ui.sections.MessageDestSection;
 import org.apache.geronimo.st.v21.ui.sections.PersContextRefSection;
@@ -74,6 +75,7 @@
         }
         else if (OpenejbJar.class.isInstance (getDeploymentPlan().getValue())){
             OpenejbJar ejbJar = (OpenejbJar)((AbstractGeronimoDeploymentPlanEditor) getEditor()).getDeploymentPlan().getValue();
+            managedForm.addPart(new EjbRelationSection(getDeploymentPlan(), body, toolkit,
getStyle(), ejbJar.getRelationships()));
             managedForm.addPart(new MessageDestSection(getDeploymentPlan(), body, toolkit,
getStyle(), ejbJar.getMessageDestination()));
         }
     }

Added: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v21.ui/src/main/java/org/apache/geronimo/st/v21/ui/sections/EjbRelationSection.java
URL: http://svn.apache.org/viewvc/geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v21.ui/src/main/java/org/apache/geronimo/st/v21/ui/sections/EjbRelationSection.java?rev=705002&view=auto
==============================================================================
--- geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v21.ui/src/main/java/org/apache/geronimo/st/v21/ui/sections/EjbRelationSection.java
(added)
+++ geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v21.ui/src/main/java/org/apache/geronimo/st/v21/ui/sections/EjbRelationSection.java
Wed Oct 15 12:34:27 2008
@@ -0,0 +1,173 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.geronimo.st.v21.ui.sections;
+
+import java.util.List;
+
+import javax.xml.bind.JAXBElement;
+
+import org.apache.geronimo.jee.openejb.EjbRelation;
+import org.apache.geronimo.jee.openejb.EjbRelationshipRole;
+import org.apache.geronimo.jee.openejb.Relationships;
+import org.apache.geronimo.st.ui.CommonMessages;
+import org.apache.geronimo.st.ui.sections.AbstractTreeSection;
+import org.apache.geronimo.st.v21.ui.Activator;
+import org.apache.geronimo.st.v21.ui.wizards.EjbRelationWizard;
+import org.eclipse.jface.viewers.ILabelProvider;
+import org.eclipse.jface.viewers.ITreeContentProvider;
+import org.eclipse.jface.wizard.Wizard;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.ui.forms.widgets.FormToolkit;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class EjbRelationSection extends AbstractTreeSection {
+    public EjbRelationSection(JAXBElement plan, Composite parent, FormToolkit toolkit, int
style, Relationships relationships) {
+        super(plan, parent, toolkit, style);
+        this.objectContainer = relationships == null ? null : relationships.getEjbRelation();
+        createClient();
+    }
+
+    @Override
+    public String getTitle() {
+        return CommonMessages.editorEjbRelationTitle;
+    }
+
+    @Override
+    public String getDescription() {
+        return CommonMessages.editorEjbRelationDescription;
+    }
+
+    @Override
+    public Wizard getWizard() {
+        return new EjbRelationWizard(this);
+    }
+
+    @Override
+    public Class getTableEntryObjectType() {
+        return EjbRelation.class;
+    }
+
+    @Override
+    protected void activateAddButton() {
+        if (tree.getSelectionCount() == 0 || tree.getSelection()[0].getParentItem() == null
||
+            tree.getSelection()[0].getParentItem().getParentItem() == null) {
+            addButton.setEnabled(true);
+        } else {
+            addButton.setEnabled(false);
+        }
+    }
+
+    public Object getSelectedObject () {
+        if (tree.getSelection().length == 0) {
+            return null;
+        }
+        return tree.getSelection()[0].getData();
+    }
+
+    @Override
+    public void removeItem(Object anItem) {
+        if (EjbRelation.class.isInstance(anItem)) {
+            getObjectContainer().remove(anItem);
+        }
+        else if (EjbRelationshipRole.class.isInstance(anItem)) {
+            EjbRelation relation = (EjbRelation)tree.getSelection()[0].getParentItem().getData();
+            relation.getEjbRelationshipRole().remove(anItem);
+        }
+        else if (EjbRelationshipRole.RoleMapping.CmrFieldMapping.class.isInstance(anItem))
{
+            EjbRelationshipRole role = (EjbRelationshipRole)tree.getSelection()[0].getParentItem().getData();
+            role.getRoleMapping().getCmrFieldMapping().remove(anItem);
+        }
+    }
+    
+    @Override
+    public Object getInput() {
+        if (objectContainer != null) {
+            return objectContainer;
+        }
+        return super.getInput();
+    }
+
+    public void resetInput (Relationships relationships) {
+        objectContainer = relationships.getEjbRelation();
+        getViewer().setInput(objectContainer);
+    }
+
+    @Override
+    public ITreeContentProvider getContentProvider() {
+        return new ContentProvider() {
+            @Override
+            public Object[] getElements(Object inputElement) {
+                return getChildren(inputElement);
+            }
+
+            @Override
+            public Object[] getChildren(Object parentElement) {
+                if (List.class.isInstance(parentElement)) {
+                    return ((List)parentElement).toArray();
+                }
+                if (EjbRelation.class.isInstance(parentElement)) {
+                    EjbRelation relation = (EjbRelation)parentElement;
+                    return relation.getEjbRelationshipRole().toArray();
+                }
+                if (EjbRelationshipRole.class.isInstance(parentElement)) {
+                    EjbRelationshipRole role = (EjbRelationshipRole)parentElement;
+                    if (role.getRoleMapping() != null) {
+                        return role.getRoleMapping().getCmrFieldMapping().toArray();
+                    }
+                }
+                return new String[] {};
+            }
+        };
+    }
+
+    @Override
+    public ILabelProvider getLabelProvider() {
+        return new LabelProvider() {
+            @Override
+            public String getText(Object element) {
+                if (EjbRelation.class.isInstance(element)) {
+                    EjbRelation relation = (EjbRelation)element;
+                    return "EJB Relation: name = \"" + relation.getEjbRelationName() +
+                            "\", MTM table name = \"" + relation.getManyToManyTableName()
+ "\"";
+                }
+                if (EjbRelationshipRole.class.isInstance(element)) {
+                    EjbRelationshipRole role = (EjbRelationshipRole)element;
+                    return "EJB Relationship Role: name = \"" + role.getEjbRelationshipRoleName()
+
+                            "\", source = \"" + role.getRelationshipRoleSource().getEjbName()
+
+                            "\", CMR field name = \"" + role.getCmrField().getCmrFieldName()
+ "\"";
+                }
+                if (EjbRelationshipRole.RoleMapping.CmrFieldMapping.class.isInstance(element))
{
+                    EjbRelationshipRole.RoleMapping.CmrFieldMapping fieldMapping =
+                            (EjbRelationshipRole.RoleMapping.CmrFieldMapping)element;
+                    return "CMR Field Mapping: key column = \"" + fieldMapping.getKeyColumn()
+
+                            "\", foreign key column = \"" + fieldMapping.getForeignKeyColumn()
+ "\"";
+                }
+
+                return null;
+            }
+
+            @Override
+            public Image getImage(Object arg0) {
+                return Activator.imageDescriptorFromPlugin("org.eclipse.jst.j2ee",
+                        "icons/full/obj16/module_web_obj.gif").createImage();
+            }
+        };
+    }
+}

Propchange: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v21.ui/src/main/java/org/apache/geronimo/st/v21/ui/sections/EjbRelationSection.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v21.ui/src/main/java/org/apache/geronimo/st/v21/ui/sections/EjbRelationSection.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v21.ui/src/main/java/org/apache/geronimo/st/v21/ui/sections/EjbRelationSection.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v21.ui/src/main/java/org/apache/geronimo/st/v21/ui/wizards/EjbRelationWizard.java
URL: http://svn.apache.org/viewvc/geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v21.ui/src/main/java/org/apache/geronimo/st/v21/ui/wizards/EjbRelationWizard.java?rev=705002&view=auto
==============================================================================
--- geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v21.ui/src/main/java/org/apache/geronimo/st/v21/ui/wizards/EjbRelationWizard.java
(added)
+++ geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v21.ui/src/main/java/org/apache/geronimo/st/v21/ui/wizards/EjbRelationWizard.java
Wed Oct 15 12:34:27 2008
@@ -0,0 +1,223 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.geronimo.st.v21.ui.wizards;
+
+import javax.xml.bind.JAXBElement;
+
+import org.apache.geronimo.jee.openejb.EjbRelation;
+import org.apache.geronimo.jee.openejb.EjbRelationshipRole;
+import org.apache.geronimo.jee.openejb.Relationships;
+import org.apache.geronimo.st.core.jaxb.JAXBObjectFactory;
+import org.apache.geronimo.st.ui.CommonMessages;
+import org.apache.geronimo.st.ui.sections.AbstractTreeSection;
+import org.apache.geronimo.st.ui.wizards.AbstractTreeWizard;
+import org.apache.geronimo.st.v21.core.jaxb.JAXBModelUtils;
+import org.apache.geronimo.st.v21.core.jaxb.JAXBObjectFactoryImpl;
+import org.apache.geronimo.st.v21.ui.sections.EjbRelationSection;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class EjbRelationWizard extends AbstractTreeWizard {
+
+    private final int EJB_RELATION = 0;
+    private final int RELATIONSHIP_ROLE = 1;
+    private final int CMR_FIELD_MAPPING = 2;
+
+    public EjbRelationWizard(AbstractTreeSection section) {
+        super(section, 3, 3);
+        elementTypes[EJB_RELATION] = "EJB Relation";
+        elementTypes[RELATIONSHIP_ROLE] = "EJB Relationship Role";
+        elementTypes[CMR_FIELD_MAPPING] = "CMR Field Mapping";
+    }
+
+    public class EjbRelationWizardPage extends AbstractTreeWizardPage {
+
+        public EjbRelationWizardPage(String pageName) {
+            super(pageName);
+        }
+
+        protected void initControl () {
+            if (eObject == null) {
+                element.select(EJB_RELATION);
+                if (EjbRelation.class.isInstance(((EjbRelationSection)section).getSelectedObject()))
{
+                    element.remove(elementTypes[CMR_FIELD_MAPPING]);
+                }
+                else if (EjbRelationshipRole.class.isInstance(((EjbRelationSection)section).getSelectedObject()))
{
+                    element.select(CMR_FIELD_MAPPING);
+                    element.setEnabled(false);
+                }
+                else {
+                    element.setEnabled(false);
+                }
+            }
+            else {
+                if (EjbRelation.class.isInstance(eObject)) {
+                    textList.get(0).setText(((EjbRelation)eObject).getEjbRelationName());
+                    textList.get(1).setText(((EjbRelation)eObject).getManyToManyTableName());
+                    element.select(EJB_RELATION);
+                }
+                else if (EjbRelationshipRole.class.isInstance(eObject)) {
+                    EjbRelationshipRole role = (EjbRelationshipRole)eObject;
+                    textList.get(0).setText(role.getEjbRelationshipRoleName());
+                    textList.get(1).setText(role.getRelationshipRoleSource().getEjbName());
+                    textList.get(2).setText(role.getCmrField().getCmrFieldName());
+                    element.select(RELATIONSHIP_ROLE);
+                }
+                else if (EjbRelationshipRole.RoleMapping.CmrFieldMapping.class.isInstance(eObject))
{
+                    EjbRelationshipRole.RoleMapping.CmrFieldMapping fieldMapping =
+                            (EjbRelationshipRole.RoleMapping.CmrFieldMapping)eObject;
+                    textList.get(0).setText(fieldMapping.getKeyColumn());
+                    textList.get(1).setText(fieldMapping.getForeignKeyColumn());
+                    element.select(CMR_FIELD_MAPPING);
+                }
+                element.setEnabled(false);
+            }
+        }
+        
+        protected void toggleFields (boolean clearFields) {
+            if (element.getText().equals(elementTypes[EJB_RELATION])) {
+                for (int i = 0; i < maxTextFields; i++) {
+                    labelList.get(i).setVisible(i < 2 ? true : false);
+                    textList.get(i).setVisible(i < 2 ? true : false);
+                    if (clearFields == true) {
+                        textList.get(i).setText("");
+                    }
+                }
+                labelList.get(0).setText(CommonMessages.name);
+                labelList.get(1).setText(CommonMessages.mtmTableName);
+                // if we are doing an add, then we need to make sure that the longest
+                // text can be handled
+                labelList.get(2).setText(CommonMessages.foreignKeyColumn);
+            }
+            else if (element.getText().equals(elementTypes[RELATIONSHIP_ROLE])) {
+                for (int i = 0; i < maxTextFields; i++) {
+                    labelList.get(i).setVisible(true);
+                    textList.get(i).setVisible(true);
+                    if (clearFields == true) {
+                        textList.get(i).setText("");
+                    }
+                }
+                labelList.get(0).setText(CommonMessages.name);
+                labelList.get(1).setText(CommonMessages.ejbSourceName);
+                labelList.get(2).setText(CommonMessages.cmrFieldName);
+            }
+            else if (element.getText().equals(elementTypes[CMR_FIELD_MAPPING])) {
+                for (int i = 0; i < maxTextFields; i++) {
+                    labelList.get(i).setVisible(i < 2 ? true : false);
+                    textList.get(i).setVisible(i < 2 ? true : false);
+                    if (clearFields == true) {
+                        textList.get(i).setText("");
+                    }
+                }
+                labelList.get(0).setText(CommonMessages.keyColumn);
+                labelList.get(1).setText(CommonMessages.foreignKeyColumn);
+            }
+        }
+    }
+
+    @Override
+    public void addPages() {
+        addPage(new EjbRelationWizardPage("Page0"));
+    }
+
+    @Override
+    public boolean performFinish() {
+        EjbRelation relation;
+        if (element.getText().equals(elementTypes[EJB_RELATION])) {
+            relation = (EjbRelation)eObject;
+            if (relation == null) {
+                relation = (EjbRelation)getEFactory().create(EjbRelation.class);
+                JAXBElement plan = section.getPlan();
+                
+                if (JAXBModelUtils.getEjbRelationships(plan) == null) {
+                    Relationships relationships = (Relationships)getEFactory().create(Relationships.class);
+
+                    JAXBModelUtils.setEjbRelationships(plan, relationships);
+                    ((EjbRelationSection)section).resetInput(relationships);
+                }
+                JAXBModelUtils.getEjbRelationships(plan).add(relation);
+            }
+            relation.setEjbRelationName(textList.get(0).getText());
+            relation.setManyToManyTableName(textList.get(1).getText());
+        }
+        else if (element.getText().equals(elementTypes[RELATIONSHIP_ROLE])) {
+            if (isEmpty(textList.get(1).getText())) {
+                return false;
+            }
+            EjbRelationshipRole role = (EjbRelationshipRole)eObject;
+            if (role == null) {
+                role = (EjbRelationshipRole)getEFactory().create(EjbRelationshipRole.class);
+                relation = (EjbRelation)((EjbRelationSection)section).getSelectedObject();
+                relation.getEjbRelationshipRole().add(role);
+            }
+            role.setEjbRelationshipRoleName(textList.get(0).getText());
+            EjbRelationshipRole.RelationshipRoleSource source = role.getRelationshipRoleSource();
+            if (source == null) {
+                source = (EjbRelationshipRole.RelationshipRoleSource)getEFactory().create(EjbRelationshipRole.RelationshipRoleSource.class);
+                role.setRelationshipRoleSource(source);
+            }
+            source.setEjbName(textList.get(1).getText());
+            EjbRelationshipRole.CmrField cmrField = role.getCmrField();
+            if (cmrField == null) {
+                cmrField = (EjbRelationshipRole.CmrField)getEFactory().create(EjbRelationshipRole.CmrField.class);
+                role.setCmrField(cmrField);
+            }
+            cmrField.setCmrFieldName(textList.get(2).getText());
+        }
+        else if (element.getText().equals(elementTypes[CMR_FIELD_MAPPING])) { 
+            if (isEmpty(textList.get(0).getText()) || isEmpty(textList.get(1).getText()))
{
+                return false;
+            }
+            EjbRelationshipRole.RoleMapping.CmrFieldMapping fieldMapping =
+                    (EjbRelationshipRole.RoleMapping.CmrFieldMapping)eObject;
+            if (fieldMapping == null) {
+                fieldMapping = (EjbRelationshipRole.RoleMapping.CmrFieldMapping)getEFactory().create(EjbRelationshipRole.RoleMapping.CmrFieldMapping.class);
+                EjbRelationshipRole role = (EjbRelationshipRole)((EjbRelationSection)section).getSelectedObject();
+                EjbRelationshipRole.RoleMapping roleMapping = role.getRoleMapping();
+                if (roleMapping == null) {
+                    roleMapping = (EjbRelationshipRole.RoleMapping)getEFactory().create(EjbRelationshipRole.RoleMapping.class);
+                    role.setRoleMapping(roleMapping);
+                }
+                role.getRoleMapping().getCmrFieldMapping().add(fieldMapping);
+            }
+            fieldMapping.setKeyColumn(textList.get(0).getText());
+            fieldMapping.setForeignKeyColumn(textList.get(1).getText());
+        }
+        return true;
+    }
+
+    public JAXBObjectFactory getEFactory() {
+        return JAXBObjectFactoryImpl.getInstance();
+    }
+
+    public String getAddWizardWindowTitle() {
+        return CommonMessages.wizardNewTitle_EjbRelation;
+    }
+
+    public String getEditWizardWindowTitle() {
+        return CommonMessages.wizardEditTitle_EjbRelation;
+    }
+
+    public String getWizardPageTitle() {
+        return CommonMessages.wizardPageTitle_EjbRelation;
+    }
+
+    public String getWizardPageDescription() {
+        return CommonMessages.wizardPageDescription_EjbRelation;
+    }
+}

Propchange: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v21.ui/src/main/java/org/apache/geronimo/st/v21/ui/wizards/EjbRelationWizard.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v21.ui/src/main/java/org/apache/geronimo/st/v21/ui/wizards/EjbRelationWizard.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v21.ui/src/main/java/org/apache/geronimo/st/v21/ui/wizards/EjbRelationWizard.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain



Mime
View raw message