You are viewing a plain text version of this content. The canonical link for it is here.
Posted to scm@geronimo.apache.org by bj...@apache.org on 2008/10/14 17:23:40 UTC

svn commit: r704564 - in /geronimo/devtools/eclipse-plugin/branches/2.1.4/plugins: org.apache.geronimo.jee.v21.jaxbmodel/src/main/java/org/apache/geronimo/jee/naming/ org.apache.geronimo.st.core/src/main/java/org/apache/geronimo/st/core/jaxb/ org.apach...

Author: bjreed
Date: Tue Oct 14 08:23:39 2008
New Revision: 704564

URL: http://svn.apache.org/viewvc?rev=704564&view=rev
Log:
GERONIMODEVTOOLS-388. Adding 3 sections to Web Naming Page to handle the Abstract Naming Entries

Added:
    geronimo/devtools/eclipse-plugin/branches/2.1.4/plugins/org.apache.geronimo.st.v21.ui/src/main/java/org/apache/geronimo/st/v21/ui/sections/PersContextRefSection.java   (with props)
    geronimo/devtools/eclipse-plugin/branches/2.1.4/plugins/org.apache.geronimo.st.v21.ui/src/main/java/org/apache/geronimo/st/v21/ui/sections/PersUnitRefSection.java   (with props)
    geronimo/devtools/eclipse-plugin/branches/2.1.4/plugins/org.apache.geronimo.st.v21.ui/src/main/java/org/apache/geronimo/st/v21/ui/wizards/PersContextRefWizard.java   (with props)
    geronimo/devtools/eclipse-plugin/branches/2.1.4/plugins/org.apache.geronimo.st.v21.ui/src/main/java/org/apache/geronimo/st/v21/ui/wizards/PersUnitRefWizard.java   (with props)
Modified:
    geronimo/devtools/eclipse-plugin/branches/2.1.4/plugins/org.apache.geronimo.jee.v21.jaxbmodel/src/main/java/org/apache/geronimo/jee/naming/Pattern.java
    geronimo/devtools/eclipse-plugin/branches/2.1.4/plugins/org.apache.geronimo.st.core/src/main/java/org/apache/geronimo/st/core/jaxb/MarshallerListener.java
    geronimo/devtools/eclipse-plugin/branches/2.1.4/plugins/org.apache.geronimo.st.ui/src/main/java/org/apache/geronimo/st/ui/internal/Messages.java
    geronimo/devtools/eclipse-plugin/branches/2.1.4/plugins/org.apache.geronimo.st.ui/src/main/java/org/apache/geronimo/st/ui/internal/Messages.properties
    geronimo/devtools/eclipse-plugin/branches/2.1.4/plugins/org.apache.geronimo.st.ui/src/main/java/org/apache/geronimo/st/ui/wizards/AbstractWizard.java
    geronimo/devtools/eclipse-plugin/branches/2.1.4/plugins/org.apache.geronimo.st.v21.core/src/main/java/org/apache/geronimo/st/v21/core/jaxb/JAXBModelUtils.java
    geronimo/devtools/eclipse-plugin/branches/2.1.4/plugins/org.apache.geronimo.st.v21.core/src/main/java/org/apache/geronimo/st/v21/core/jaxb/JAXBObjectFactoryImpl.java
    geronimo/devtools/eclipse-plugin/branches/2.1.4/plugins/org.apache.geronimo.st.v21.ui/src/main/java/org/apache/geronimo/st/v21/ui/pages/NamingFormPage.java
    geronimo/devtools/eclipse-plugin/branches/2.1.4/plugins/org.apache.geronimo.st.v21.ui/src/main/java/org/apache/geronimo/st/v21/ui/sections/GBeanRefSection.java
    geronimo/devtools/eclipse-plugin/branches/2.1.4/plugins/org.apache.geronimo.st.v21.ui/src/main/java/org/apache/geronimo/st/v21/ui/wizards/GBeanRefWizard.java

Modified: geronimo/devtools/eclipse-plugin/branches/2.1.4/plugins/org.apache.geronimo.jee.v21.jaxbmodel/src/main/java/org/apache/geronimo/jee/naming/Pattern.java
URL: http://svn.apache.org/viewvc/geronimo/devtools/eclipse-plugin/branches/2.1.4/plugins/org.apache.geronimo.jee.v21.jaxbmodel/src/main/java/org/apache/geronimo/jee/naming/Pattern.java?rev=704564&r1=704563&r2=704564&view=diff
==============================================================================
--- geronimo/devtools/eclipse-plugin/branches/2.1.4/plugins/org.apache.geronimo.jee.v21.jaxbmodel/src/main/java/org/apache/geronimo/jee/naming/Pattern.java (original)
+++ geronimo/devtools/eclipse-plugin/branches/2.1.4/plugins/org.apache.geronimo.jee.v21.jaxbmodel/src/main/java/org/apache/geronimo/jee/naming/Pattern.java Tue Oct 14 08:23:39 2008
@@ -89,7 +89,10 @@
      *     
      */
     public void setGroupId(String value) {
-        this.groupId = value;
+        if (value == null || value.length() == 0)
+            this.groupId = null;
+        else
+            this.groupId = value;
     }
 
     /**
@@ -113,7 +116,10 @@
      *     
      */
     public void setArtifactId(String value) {
-        this.artifactId = value;
+        if (value == null || value.length() == 0)
+            this.artifactId = null;
+        else
+            this.artifactId = value;
     }
 
     /**
@@ -137,7 +143,10 @@
      *     
      */
     public void setVersion(String value) {
-        this.version = value;
+        if (value == null || value.length() == 0)
+            this.version = null;
+        else
+            this.version = value;
     }
 
     /**
@@ -161,7 +170,10 @@
      *     
      */
     public void setModule(String value) {
-        this.module = value;
+        if (value == null || value.length() == 0)
+            this.module = null;
+        else
+            this.module = value;
     }
 
     /**

Modified: geronimo/devtools/eclipse-plugin/branches/2.1.4/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/branches/2.1.4/plugins/org.apache.geronimo.st.core/src/main/java/org/apache/geronimo/st/core/jaxb/MarshallerListener.java?rev=704564&r1=704563&r2=704564&view=diff
==============================================================================
--- geronimo/devtools/eclipse-plugin/branches/2.1.4/plugins/org.apache.geronimo.st.core/src/main/java/org/apache/geronimo/st/core/jaxb/MarshallerListener.java (original)
+++ geronimo/devtools/eclipse-plugin/branches/2.1.4/plugins/org.apache.geronimo.st.core/src/main/java/org/apache/geronimo/st/core/jaxb/MarshallerListener.java Tue Oct 14 08:23:39 2008
@@ -20,6 +20,7 @@
 
 import org.apache.geronimo.jee.naming.GbeanLocator;
 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.OpenejbJar;
 import org.apache.geronimo.jee.security.Security;
@@ -46,6 +47,11 @@
             if (locator != null && isEmpty(locator.getResourceLink()) && isEmpty(locator.getUrl()) && isEmpty(locator.getPattern())) {
                 openejb.setCmpConnectionFactory(null);
             }
+        } else if (source instanceof PersistenceContextRef) {
+            PersistenceContextRef contextRef = (PersistenceContextRef)source;
+            if (contextRef.getPattern() != null && isEmpty(contextRef.getPattern())) {
+                contextRef.setPattern(null);
+            }
         }
 	}
 		

Modified: geronimo/devtools/eclipse-plugin/branches/2.1.4/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/branches/2.1.4/plugins/org.apache.geronimo.st.ui/src/main/java/org/apache/geronimo/st/ui/internal/Messages.java?rev=704564&r1=704563&r2=704564&view=diff
==============================================================================
--- geronimo/devtools/eclipse-plugin/branches/2.1.4/plugins/org.apache.geronimo.st.ui/src/main/java/org/apache/geronimo/st/ui/internal/Messages.java (original)
+++ geronimo/devtools/eclipse-plugin/branches/2.1.4/plugins/org.apache.geronimo.st.ui/src/main/java/org/apache/geronimo/st/ui/internal/Messages.java Tue Oct 14 08:23:39 2008
@@ -189,6 +189,12 @@
     public static String editorGBeanRefTargetName;
     public static String editorGBeanRefProxyType;
     //
+    //
+    public static String editorPersContextRefTitle;
+    public static String editorPersContextRefDescription;
+    public static String editorPersUnitRefTitle;
+    public static String editorPersUnitRefDescription;
+    //
     public static String editorServiceRefDescription;
     public static String editorServiceRefTitle;
     public static String editorServiceRefName;
@@ -220,6 +226,11 @@
     public static String wizardPageTitle_GBeanRef;
     public static String wizardPageDescription_GBeanRef;
     //
+    public static String wizardNewTitle_PersContextRef;
+    public static String wizardEditTitle_PersContextRef;
+    public static String wizardPageTitle_PersContextRef;
+    public static String wizardPageDescription_PersContextRef;
+    //
     public static String wizardNewTitle_ServiceRef;
     public static String wizardEditTitle_ServiceRef;
     public static String wizardPageTitle_ServiceRef;
@@ -240,6 +251,11 @@
     public static String wizardPageTitle_EjbLocalRef;
     public static String wizardPageDescription_EjbLocalRef;
     //
+    public static String wizardNewTitle_PersUnitRef;
+    public static String wizardEditTitle_PersUnitRef;
+    public static String wizardPageTitle_PersUnitRef;
+    public static String wizardPageDescription_PersUnitRef;
+    //
     public static String wizardNewTitle_RoleMapping;
     public static String wizardEditTitle_RoleMapping;
     public static String wizardPageTitle_RoleMapping;
@@ -268,6 +284,9 @@
     public static String messageDestinationName;
     public static String adminModule;
     public static String adminLink;
+    public static String contextName;
+    public static String unitRefName;
+    public static String unitName;
     //
     public static String wizardNewTitle_Import;
     public static String wizardEditTitle_Import;
@@ -326,6 +345,8 @@
     public static String supressDefaultEnv;
     public static String sharedLibDepends;
 
+    public static String useUnitName;
+    public static String usePattern;
     public static String useResourceLink;
     public static String useUrl;
     public static String useResourcePattern;

Modified: geronimo/devtools/eclipse-plugin/branches/2.1.4/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/branches/2.1.4/plugins/org.apache.geronimo.st.ui/src/main/java/org/apache/geronimo/st/ui/internal/Messages.properties?rev=704564&r1=704563&r2=704564&view=diff
==============================================================================
--- geronimo/devtools/eclipse-plugin/branches/2.1.4/plugins/org.apache.geronimo.st.ui/src/main/java/org/apache/geronimo/st/ui/internal/Messages.properties (original)
+++ geronimo/devtools/eclipse-plugin/branches/2.1.4/plugins/org.apache.geronimo.st.ui/src/main/java/org/apache/geronimo/st/ui/internal/Messages.properties Tue Oct 14 08:23:39 2008
@@ -129,6 +129,11 @@
 editorGBeanRefTargetName=Target
 editorGBeanRefProxyType=Proxy Type
 
+editorPersContextRefTitle=Persistence Context References
+editorPersContextRefDescription=The following persistence context references are defined:
+editorPersUnitRefTitle=Persistence Unit References
+editorPersUnitRefDescription=The following persistence unit references are defined:
+
 editorServiceRefDescription=The following  service references are defined:
 editorServiceRefTitle=Service Refs
 editorServiceRefName=Name
@@ -175,6 +180,16 @@
 wizardPageTitle_GBeanRef=GBean Reference Details
 wizardPageDescription_GBeanRef=Provide details for this gbean reference.
 
+wizardNewTitle_PersUnitRef=New Persistence Unit Reference
+wizardEditTitle_PersUnitRef=Edit Persistence Unit Reference
+wizardPageTitle_PersUnitRef=Persistence Unit Reference Details
+wizardPageDescription_PersUnitRef=Provide details for this persistence unit reference.
+
+wizardNewTitle_PersContextRef=New Persistence Context Reference
+wizardEditTitle_PersContextRef=Edit Persistence Context Reference
+wizardPageTitle_PersContextRef=Persistence Context Reference Details
+wizardPageDescription_PersContextRef=Provide details for this persistence context reference.
+
 wizardNewTitle_SecurityRole=New Security Role
 wizardEditTitle_SecurityRole=Edit Security Role
 wizardPageTitle_SecurityRole=Security Role Details
@@ -247,6 +262,9 @@
 element=Element
 customName=Custom Name
 value=Value
+contextName=Context Name
+unitRefName=Unit Ref Name
+unitName=Unit Name
 
 messageDestinationName=Message Destination Name
 adminModule=Admin Module
@@ -334,6 +352,8 @@
 useGBeanPattern=Specify as GBean Pattern
 moduleId=Module Id:
 
+useUnitName=Specify as Unit Name
+usePattern=Specify as Pattern
 cmpConnectionSection=C-M-P Connection Factory
 cmpConnectionSectionDescription=C-M-P Connection Factory Configuration
 useResourceLink=Specify as Resource Link

Modified: geronimo/devtools/eclipse-plugin/branches/2.1.4/plugins/org.apache.geronimo.st.ui/src/main/java/org/apache/geronimo/st/ui/wizards/AbstractWizard.java
URL: http://svn.apache.org/viewvc/geronimo/devtools/eclipse-plugin/branches/2.1.4/plugins/org.apache.geronimo.st.ui/src/main/java/org/apache/geronimo/st/ui/wizards/AbstractWizard.java?rev=704564&r1=704563&r2=704564&view=diff
==============================================================================
--- geronimo/devtools/eclipse-plugin/branches/2.1.4/plugins/org.apache.geronimo.st.ui/src/main/java/org/apache/geronimo/st/ui/wizards/AbstractWizard.java (original)
+++ geronimo/devtools/eclipse-plugin/branches/2.1.4/plugins/org.apache.geronimo.st.ui/src/main/java/org/apache/geronimo/st/ui/wizards/AbstractWizard.java Tue Oct 14 08:23:39 2008
@@ -24,6 +24,7 @@
 import org.eclipse.swt.SWT;
 import org.eclipse.swt.layout.GridData;
 import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
 import org.eclipse.swt.widgets.Combo;
 import org.eclipse.swt.widgets.Composite;
 import org.eclipse.swt.widgets.Label;
@@ -89,7 +90,9 @@
             data.grabExcessHorizontalSpace = true;
             data.widthHint = 100;
             text.setLayoutData(data);
-            text.setText(initialValue);
+            if (initialValue != null) {
+                text.setText(initialValue);
+            }
             return text;
         }
 
@@ -106,6 +109,15 @@
             combo.setItems(items);
             return combo;
         }
+
+        protected Button createButton(Composite composite, String buttonString) {
+            Button button = new Button(composite, SWT.RADIO);
+            button.setText(buttonString);
+            GridData data = new GridData();
+            data.horizontalSpan = 2;
+            button.setLayoutData(data);
+            return button;
+        }
     }
 
     protected abstract String getWizardPageTitle();

Modified: geronimo/devtools/eclipse-plugin/branches/2.1.4/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/branches/2.1.4/plugins/org.apache.geronimo.st.v21.core/src/main/java/org/apache/geronimo/st/v21/core/jaxb/JAXBModelUtils.java?rev=704564&r1=704563&r2=704564&view=diff
==============================================================================
--- geronimo/devtools/eclipse-plugin/branches/2.1.4/plugins/org.apache.geronimo.st.v21.core/src/main/java/org/apache/geronimo/st/v21/core/jaxb/JAXBModelUtils.java (original)
+++ geronimo/devtools/eclipse-plugin/branches/2.1.4/plugins/org.apache.geronimo.st.v21.core/src/main/java/org/apache/geronimo/st/v21/core/jaxb/JAXBModelUtils.java Tue Oct 14 08:23:39 2008
@@ -164,6 +164,9 @@
         if (ApplicationClient.class.isInstance (plan)) {
             return ((ApplicationClient)plan).getGbeanRef() == null ? null : ((ApplicationClient)plan).getGbeanRef();
         }
+        else if (WebApp.class.isInstance (plan)) {
+            return ((WebApp)plan).getAbstractNamingEntry() == null ? null : ((WebApp)plan).getAbstractNamingEntry();
+        }
         return null;
     }
 

Modified: geronimo/devtools/eclipse-plugin/branches/2.1.4/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/branches/2.1.4/plugins/org.apache.geronimo.st.v21.core/src/main/java/org/apache/geronimo/st/v21/core/jaxb/JAXBObjectFactoryImpl.java?rev=704564&r1=704563&r2=704564&view=diff
==============================================================================
--- geronimo/devtools/eclipse-plugin/branches/2.1.4/plugins/org.apache.geronimo.st.v21.core/src/main/java/org/apache/geronimo/st/v21/core/jaxb/JAXBObjectFactoryImpl.java (original)
+++ geronimo/devtools/eclipse-plugin/branches/2.1.4/plugins/org.apache.geronimo.st.v21.core/src/main/java/org/apache/geronimo/st/v21/core/jaxb/JAXBObjectFactoryImpl.java Tue Oct 14 08:23:39 2008
@@ -32,8 +32,11 @@
 import org.apache.geronimo.jee.naming.EjbLocalRef;
 import org.apache.geronimo.jee.naming.GbeanRef;
 import org.apache.geronimo.jee.naming.MessageDestination;
+import org.apache.geronimo.jee.naming.PersistenceContextRef;
+import org.apache.geronimo.jee.naming.PersistenceUnitRef;
 import org.apache.geronimo.jee.naming.Port;
 import org.apache.geronimo.jee.naming.PortCompletion;
+import org.apache.geronimo.jee.naming.Property;
 import org.apache.geronimo.jee.naming.ServiceCompletion;
 import org.apache.geronimo.jee.naming.ResourceEnvRef;
 import org.apache.geronimo.jee.naming.ResourceRef;
@@ -71,6 +74,10 @@
             return (new org.apache.geronimo.jee.naming.ObjectFactory()).createEjbRef();
         } else if ( type.equals( GbeanRef.class ) ) {
             return (new org.apache.geronimo.jee.naming.ObjectFactory()).createGbeanRef();
+        } else if ( type.equals( PersistenceContextRef.class ) ) {
+            return (new org.apache.geronimo.jee.naming.ObjectFactory()).createPersistenceContextRef();
+        } else if ( type.equals( PersistenceUnitRef.class ) ) {
+            return (new org.apache.geronimo.jee.naming.ObjectFactory()).createPersistenceUnitRef();
         } else if ( type.equals( MessageDestination.class ) ) {
             return (new org.apache.geronimo.jee.naming.ObjectFactory()).createMessageDestination();
         } else if ( type.equals( org.apache.geronimo.jee.naming.Pattern.class ) ) {
@@ -79,6 +86,8 @@
             return (new org.apache.geronimo.jee.naming.ObjectFactory()).createPort();
         } else if ( type.equals( PortCompletion.class ) ) {
             return (new org.apache.geronimo.jee.naming.ObjectFactory()).createPortCompletion();
+        } else if ( type.equals( Property.class ) ) {
+            return (new org.apache.geronimo.jee.naming.ObjectFactory()).createProperty();
         } else if ( type.equals( ServiceCompletion.class ) ) {
             return (new org.apache.geronimo.jee.naming.ObjectFactory()).createServiceCompletion();
         } else if ( type.equals( ServiceRef.class ) ) {

Modified: geronimo/devtools/eclipse-plugin/branches/2.1.4/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/branches/2.1.4/plugins/org.apache.geronimo.st.v21.ui/src/main/java/org/apache/geronimo/st/v21/ui/pages/NamingFormPage.java?rev=704564&r1=704563&r2=704564&view=diff
==============================================================================
--- geronimo/devtools/eclipse-plugin/branches/2.1.4/plugins/org.apache.geronimo.st.v21.ui/src/main/java/org/apache/geronimo/st/v21/ui/pages/NamingFormPage.java (original)
+++ geronimo/devtools/eclipse-plugin/branches/2.1.4/plugins/org.apache.geronimo.st.v21.ui/src/main/java/org/apache/geronimo/st/v21/ui/pages/NamingFormPage.java Tue Oct 14 08:23:39 2008
@@ -27,6 +27,8 @@
 import org.apache.geronimo.st.v21.ui.sections.EjbRefSection;
 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;
+import org.apache.geronimo.st.v21.ui.sections.PersUnitRefSection;
 import org.apache.geronimo.st.v21.ui.sections.ResourceEnvRefSection;
 import org.apache.geronimo.st.v21.ui.sections.ResourceRefSection;
 import org.apache.geronimo.st.v21.ui.sections.ServiceRefSection;
@@ -56,6 +58,9 @@
             managedForm.addPart(new ServiceRefSection(getDeploymentPlan(), body, toolkit, getStyle(), webapp.getServiceRef()));
             managedForm.addPart(new ResourceEnvRefSection(getDeploymentPlan(), body, toolkit, getStyle(), webapp.getResourceEnvRef()));
             managedForm.addPart(new EjbLocalRefSection(getDeploymentPlan(), body, toolkit, getStyle(), webapp.getEjbLocalRef()));
+            managedForm.addPart(new GBeanRefSection(getDeploymentPlan(), body, toolkit, getStyle(), webapp.getAbstractNamingEntry()));
+            managedForm.addPart(new PersContextRefSection(getDeploymentPlan(), body, toolkit, getStyle(), webapp.getAbstractNamingEntry()));
+            managedForm.addPart(new PersUnitRefSection(getDeploymentPlan(), body, toolkit, getStyle(), webapp.getAbstractNamingEntry()));
             managedForm.addPart(new MessageDestSection(getDeploymentPlan(), body, toolkit, getStyle(), webapp.getMessageDestination()));
         }
         else if (ApplicationClient.class.isInstance (getDeploymentPlan().getValue())){

Modified: geronimo/devtools/eclipse-plugin/branches/2.1.4/plugins/org.apache.geronimo.st.v21.ui/src/main/java/org/apache/geronimo/st/v21/ui/sections/GBeanRefSection.java
URL: http://svn.apache.org/viewvc/geronimo/devtools/eclipse-plugin/branches/2.1.4/plugins/org.apache.geronimo.st.v21.ui/src/main/java/org/apache/geronimo/st/v21/ui/sections/GBeanRefSection.java?rev=704564&r1=704563&r2=704564&view=diff
==============================================================================
--- geronimo/devtools/eclipse-plugin/branches/2.1.4/plugins/org.apache.geronimo.st.v21.ui/src/main/java/org/apache/geronimo/st/v21/ui/sections/GBeanRefSection.java (original)
+++ geronimo/devtools/eclipse-plugin/branches/2.1.4/plugins/org.apache.geronimo.st.v21.ui/src/main/java/org/apache/geronimo/st/v21/ui/sections/GBeanRefSection.java Tue Oct 14 08:23:39 2008
@@ -16,64 +16,190 @@
  */
 package org.apache.geronimo.st.v21.ui.sections;
 
+import java.util.ArrayList;
 import java.util.List;
 
 import javax.xml.bind.JAXBElement;
 
 import org.apache.geronimo.jee.naming.GbeanRef;
+import org.apache.geronimo.jee.naming.Pattern;
+import org.apache.geronimo.jee.web.WebApp;
 import org.apache.geronimo.st.ui.CommonMessages;
-import org.apache.geronimo.st.ui.sections.AbstractTableSection;
+import org.apache.geronimo.st.ui.sections.AbstractTreeSection;
+import org.apache.geronimo.st.v21.core.jaxb.JAXBModelUtils;
+import org.apache.geronimo.st.v21.ui.Activator;
 import org.apache.geronimo.st.v21.ui.wizards.GBeanRefWizard;
-import org.eclipse.jface.viewers.ITableLabelProvider;
+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 GBeanRefSection extends AbstractTableSection {
+public class GBeanRefSection extends AbstractTreeSection {
 
 	public GBeanRefSection(JAXBElement plan, Composite parent, FormToolkit toolkit, int style, List gbeanRef) {
 		super(plan, parent, toolkit, style);
-		this.objectContainer = gbeanRef;
-		COLUMN_NAMES = new String[] {
-		        CommonMessages.editorGBeanRefName, CommonMessages.editorGBeanRefType};
+		//this.objectContainer = gbeanRef;
+	      this.objectContainer = new ArrayList(gbeanRef.size());
+	        for (int i = 0; i < gbeanRef.size(); i++) {
+	            if (GbeanRef.class.isInstance(gbeanRef.get(i))) {
+	                this.objectContainer.add(gbeanRef.get(i));
+	            }
+	            else if (GbeanRef.class.isInstance(((JAXBElement)gbeanRef.get(i)).getValue())) {
+	                this.objectContainer.add(gbeanRef.get(i));
+	            }
+	        }
 		createClient();
 	}
 
+    @Override
 	public String getTitle() {
 		return CommonMessages.editorGBeanRefTitle;
 	}
 
+    @Override
 	public String getDescription() {
 		return CommonMessages.editorGBeanRefDescription;
 	}
 
+    @Override
 	public Wizard getWizard() {
 		return new GBeanRefWizard(this);
 	}
 
+    @Override
 	public Class getTableEntryObjectType() {
 		return GbeanRef.class;
 	}
 
     @Override
-    public ITableLabelProvider getLabelProvider() {
+    public Object getInput() {
+        if (objectContainer != null) {
+            return objectContainer;
+        }
+        return super.getInput();
+    }
+
+    @Override
+    protected void activateAddButton() {
+        if (tree.getSelectionCount() == 0 || tree.getSelection()[0].getParentItem() == null) {
+            addButton.setEnabled(true);
+        } else {
+            addButton.setEnabled(false);
+        }
+    }
+
+    public GbeanRef getSelectedGbeanRef () {
+        if (tree.getSelection().length == 0) {
+            return null;
+        }
+        Object object;
+        if (tree.getSelection()[0].getParentItem() == null) {
+            object = tree.getSelection()[0].getData();
+        }
+        else {
+            object = tree.getSelection()[0].getParentItem().getData();
+        }
+        if (GbeanRef.class.isInstance(object)) {
+            return (GbeanRef)object;
+        }
+        else {
+            return (GbeanRef)((JAXBElement)object).getValue();
+        }
+    }
+    
+    @Override
+    public void removeItem(Object anItem) {
+        if (GbeanRef.class.isInstance(anItem) || JAXBElement.class.isInstance(anItem)) {
+            getObjectContainer().remove(anItem);
+            JAXBModelUtils.getGbeanRefs(getPlan()).remove(anItem);
+        }
+        else if (String.class.isInstance(anItem)) {
+            Object object = tree.getSelection()[0].getParentItem().getData();
+            if (GbeanRef.class.isInstance(object)) {
+                ((GbeanRef)object).getRefType().remove(anItem);
+            }
+            else {
+                ((GbeanRef)((JAXBElement)object).getValue()).getRefType().remove(anItem);
+            }
+        }
+        else if (Pattern.class.isInstance(anItem)) {
+            Object object = tree.getSelection()[0].getParentItem().getData();
+            if (GbeanRef.class.isInstance(object)) {
+                ((GbeanRef)object).getPattern().remove(anItem);
+            }
+            else {
+                ((GbeanRef)((JAXBElement)object).getValue()).getPattern().remove(anItem);
+            }
+        }
+    }
+
+    @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 (JAXBElement.class.isInstance(parentElement)) {
+                    parentElement = ((JAXBElement)parentElement).getValue();
+                }
+                if (GbeanRef.class.isInstance(parentElement)) {
+                    GbeanRef gbeanRef = (GbeanRef)parentElement;
+                    Object[] typeList = gbeanRef.getRefType().toArray();
+                    Object[] patternList = gbeanRef.getPattern().toArray();
+                    Object[] fullList = new Object[typeList.length + patternList.length];
+                    System.arraycopy(typeList, 0, fullList, 0, typeList.length);
+                    System.arraycopy(patternList, 0, fullList, typeList.length, patternList.length);
+                    return fullList;
+                }
+                return new String[] {};
+            }
+        };
+    }
+
+    @Override
+    public ILabelProvider getLabelProvider() {
         return new LabelProvider() {
             @Override
-            public String getColumnText(Object element, int columnIndex) {
+            public String getText(Object element) {
+                if (JAXBElement.class.isInstance(element)) {
+                    element = ((JAXBElement)element).getValue();
+                }
                 if (GbeanRef.class.isInstance(element)) {
-                    GbeanRef gbeanRef = (GbeanRef) element;
-                    switch (columnIndex) {
-                    case 0:
-                        return gbeanRef.getRefName();
-                    case 1:
-                        return gbeanRef.getRefType().get(0);
-                    }
+                    GbeanRef gbeanRef = (GbeanRef)element;
+                    return "Gbean Ref: name = \"" + gbeanRef.getRefName() + "\"";
+                }
+                else if (String.class.isInstance(element)) {
+                    return "Gbean type: name = \"" + (String)element + "\"";
+                }
+                else if (Pattern.class.isInstance(element)) {
+                    Pattern pattern = (Pattern)element;
+                    return "Pattern: name = \"" + pattern.getName() + 
+                            "\", group = \"" + pattern.getGroupId() + 
+                            "\", artifact = \"" + pattern.getArtifactId() + 
+                            "\", version = \"" + pattern.getVersion() + 
+                            "\", module = \"" + pattern.getModule() + "\"";
                 }
+
                 return null;
             }
+
+            @Override
+            public Image getImage(Object arg0) {
+                return Activator.imageDescriptorFromPlugin("org.eclipse.jst.j2ee",
+                        "icons/full/obj16/module_web_obj.gif").createImage();
+            }
         };
     }
 }

Added: geronimo/devtools/eclipse-plugin/branches/2.1.4/plugins/org.apache.geronimo.st.v21.ui/src/main/java/org/apache/geronimo/st/v21/ui/sections/PersContextRefSection.java
URL: http://svn.apache.org/viewvc/geronimo/devtools/eclipse-plugin/branches/2.1.4/plugins/org.apache.geronimo.st.v21.ui/src/main/java/org/apache/geronimo/st/v21/ui/sections/PersContextRefSection.java?rev=704564&view=auto
==============================================================================
--- geronimo/devtools/eclipse-plugin/branches/2.1.4/plugins/org.apache.geronimo.st.v21.ui/src/main/java/org/apache/geronimo/st/v21/ui/sections/PersContextRefSection.java (added)
+++ geronimo/devtools/eclipse-plugin/branches/2.1.4/plugins/org.apache.geronimo.st.v21.ui/src/main/java/org/apache/geronimo/st/v21/ui/sections/PersContextRefSection.java Tue Oct 14 08:23:39 2008
@@ -0,0 +1,178 @@
+/*
+ * 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.ArrayList;
+import java.util.List;
+
+import javax.xml.bind.JAXBElement;
+
+import org.apache.geronimo.jee.naming.PersistenceContextRef;
+import org.apache.geronimo.jee.naming.Property;
+import org.apache.geronimo.st.ui.CommonMessages;
+import org.apache.geronimo.st.ui.sections.AbstractTreeSection;
+import org.apache.geronimo.st.v21.core.jaxb.JAXBModelUtils;
+import org.apache.geronimo.st.v21.ui.Activator;
+import org.apache.geronimo.st.v21.ui.wizards.PersContextRefWizard;
+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 PersContextRefSection extends AbstractTreeSection {
+    
+	public PersContextRefSection(JAXBElement plan, Composite parent, FormToolkit toolkit, int style, List persContextRefs) {
+		super(plan, parent, toolkit, style);
+		this.objectContainer = new ArrayList(persContextRefs.size());
+		for (int i = 0; i < persContextRefs.size(); i++) {
+		    if (PersistenceContextRef.class.isInstance(((JAXBElement)persContextRefs.get(i)).getValue())) {
+		        this.objectContainer.add(persContextRefs.get(i));
+		    }
+		}
+		createClient();
+	}
+
+    @Override
+	public String getTitle() {
+		return CommonMessages.editorPersContextRefTitle;
+	}
+
+    @Override
+	public String getDescription() {
+		return CommonMessages.editorPersContextRefDescription;
+	}
+
+    @Override
+	public Wizard getWizard() {
+		return new PersContextRefWizard(this);
+	}
+
+    @Override
+	public Class getTableEntryObjectType() {
+		return PersistenceContextRef.class;
+	}
+
+    @Override
+    public Object getInput() {
+        if (objectContainer != null) {
+            return objectContainer;
+        }
+        return super.getInput();
+    }
+
+    @Override
+    protected void activateAddButton() {
+        if (tree.getSelectionCount() == 0 || tree.getSelection()[0].getParentItem() == null) {
+            addButton.setEnabled(true);
+        } else {
+            addButton.setEnabled(false);
+        }
+    }
+
+    public PersistenceContextRef getSelectedPersContext () {
+        if (tree.getSelection().length == 0) {
+            return null;
+        }
+        Object object;
+        if (tree.getSelection()[0].getParentItem() == null) {
+            object = tree.getSelection()[0].getData();
+        }
+        else {
+            object = tree.getSelection()[0].getParentItem().getData();
+        }
+        return (PersistenceContextRef)((JAXBElement)object).getValue();
+    }
+    
+    @Override
+    public void removeItem(Object anItem) {
+        if (JAXBElement.class.isInstance(anItem)) {
+            getObjectContainer().remove(anItem);
+            JAXBModelUtils.getGbeanRefs(getPlan()).remove(anItem);
+        }
+        else if (Property.class.isInstance(anItem)) {
+            Object object = tree.getSelection()[0].getParentItem().getData();
+            ((PersistenceContextRef)((JAXBElement)object).getValue()).getProperty().remove(anItem);
+        }
+    }
+
+    @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 (JAXBElement.class.isInstance(parentElement)) {
+                    return ((PersistenceContextRef)((JAXBElement)parentElement).getValue()).getProperty().toArray();
+                }
+                return new String[] {};
+            }
+        };
+    }
+
+    @Override
+    public ILabelProvider getLabelProvider() {
+        return new LabelProvider() {
+            @Override
+            public String getText(Object element) {
+                if (JAXBElement.class.isInstance(element)) {
+                    PersistenceContextRef contextRef = (PersistenceContextRef)((JAXBElement)element).getValue();
+                    String temp = "Persistence Context Ref: name = \"" + contextRef.getPersistenceContextRefName() +
+                                  "\", type = \"" + contextRef.getPersistenceContextType().value();
+                    if (contextRef.getPersistenceUnitName() != null)
+                        temp += "\", unit name = \"" + contextRef.getPersistenceUnitName();
+                    if (contextRef.getPattern() != null && contextRef.getPattern().getName() != null)
+                        temp += "\", pattern name = \"" + contextRef.getPattern().getName();
+                    if (contextRef.getPattern() != null && contextRef.getPattern().getGroupId() != null)
+                        temp += "\", pattern group = \"" + contextRef.getPattern().getGroupId();
+                    if (contextRef.getPattern() != null && contextRef.getPattern().getArtifactId() != null)
+                        temp += "\", pattern artifact = \"" + contextRef.getPattern().getArtifactId();
+                    if (contextRef.getPattern() != null && contextRef.getPattern().getVersion() != null)
+                        temp += "\", pattern version = \"" + contextRef.getPattern().getVersion();
+                    if (contextRef.getPattern() != null && contextRef.getPattern().getModule() != null)
+                        temp += "\", pattern module = \"" + contextRef.getPattern().getModule();
+                    temp += "\"";
+                    return temp;
+                }
+                else if (Property.class.isInstance(element)) {
+                    Property property = (Property)element;
+                    return "Property: key = \"" + property.getKey() + 
+                            "\", value = \"" + property.getValue() + "\"";
+                }
+
+                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/branches/2.1.4/plugins/org.apache.geronimo.st.v21.ui/src/main/java/org/apache/geronimo/st/v21/ui/sections/PersContextRefSection.java
------------------------------------------------------------------------------
    svn:eol-style = native

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

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

Added: geronimo/devtools/eclipse-plugin/branches/2.1.4/plugins/org.apache.geronimo.st.v21.ui/src/main/java/org/apache/geronimo/st/v21/ui/sections/PersUnitRefSection.java
URL: http://svn.apache.org/viewvc/geronimo/devtools/eclipse-plugin/branches/2.1.4/plugins/org.apache.geronimo.st.v21.ui/src/main/java/org/apache/geronimo/st/v21/ui/sections/PersUnitRefSection.java?rev=704564&view=auto
==============================================================================
--- geronimo/devtools/eclipse-plugin/branches/2.1.4/plugins/org.apache.geronimo.st.v21.ui/src/main/java/org/apache/geronimo/st/v21/ui/sections/PersUnitRefSection.java (added)
+++ geronimo/devtools/eclipse-plugin/branches/2.1.4/plugins/org.apache.geronimo.st.v21.ui/src/main/java/org/apache/geronimo/st/v21/ui/sections/PersUnitRefSection.java Tue Oct 14 08:23:39 2008
@@ -0,0 +1,157 @@
+/*
+ * 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.ArrayList;
+import java.util.List;
+
+import javax.xml.bind.JAXBElement;
+
+import org.apache.geronimo.jee.naming.PersistenceUnitRef;
+import org.apache.geronimo.st.ui.CommonMessages;
+import org.apache.geronimo.st.ui.sections.AbstractTreeSection;
+import org.apache.geronimo.st.v21.core.jaxb.JAXBModelUtils;
+import org.apache.geronimo.st.v21.ui.Activator;
+import org.apache.geronimo.st.v21.ui.wizards.PersUnitRefWizard;
+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 PersUnitRefSection extends AbstractTreeSection {
+    
+	public PersUnitRefSection(JAXBElement plan, Composite parent, FormToolkit toolkit, int style, List persUnitRefs) {
+		super(plan, parent, toolkit, style);
+		this.objectContainer = new ArrayList(persUnitRefs.size());
+		for (int i = 0; i < persUnitRefs.size(); i++) {
+		    if (PersistenceUnitRef.class.isInstance(((JAXBElement)persUnitRefs.get(i)).getValue())) {
+		        this.objectContainer.add(persUnitRefs.get(i));
+		    }
+		}
+		createClient();
+	}
+
+    @Override
+	public String getTitle() {
+		return CommonMessages.editorPersUnitRefTitle;
+	}
+
+    @Override
+	public String getDescription() {
+		return CommonMessages.editorPersUnitRefDescription;
+	}
+
+    @Override
+	public Wizard getWizard() {
+		return new PersUnitRefWizard(this);
+	}
+
+    @Override
+	public Class getTableEntryObjectType() {
+		return PersistenceUnitRef.class;
+	}
+
+    @Override
+    public Object getInput() {
+        if (objectContainer != null) {
+            return objectContainer;
+        }
+        return super.getInput();
+    }
+
+    @Override
+    protected void activateAddButton() {
+        if (tree.getSelectionCount() == 0 || tree.getSelection()[0].getParentItem() == null) {
+            addButton.setEnabled(true);
+        } else {
+            addButton.setEnabled(false);
+        }
+    }
+
+    public PersistenceUnitRef getSelectedPersContext () {
+        if (tree.getSelection().length == 0) {
+            return null;
+        }
+        return (PersistenceUnitRef)((JAXBElement)tree.getSelection()[0].getData()).getValue();
+    }
+    
+    @Override
+    public void removeItem(Object anItem) {
+        if (JAXBElement.class.isInstance(anItem)) {
+            getObjectContainer().remove(anItem);
+            JAXBModelUtils.getGbeanRefs(getPlan()).remove(anItem);
+        }
+    }
+
+    @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();
+                }
+                return new String[] {};
+            }
+        };
+    }
+
+    @Override
+    public ILabelProvider getLabelProvider() {
+        return new LabelProvider() {
+            @Override
+            public String getText(Object element) {
+                if (JAXBElement.class.isInstance(element)) {
+                    PersistenceUnitRef unitRef = (PersistenceUnitRef)((JAXBElement)element).getValue();
+                    String temp = "Persistence Unit Ref: name = \"" + unitRef.getPersistenceUnitRefName();
+                    if (unitRef.getPersistenceUnitName() != null)
+                        temp += "\", unit name = \"" + unitRef.getPersistenceUnitName();
+                    if (unitRef.getPattern() != null && unitRef.getPattern().getName() != null)
+                        temp += "\", pattern name = \"" + unitRef.getPattern().getName();
+                    if (unitRef.getPattern() != null && unitRef.getPattern().getGroupId() != null)
+                        temp += "\", pattern group = \"" + unitRef.getPattern().getGroupId();
+                    if (unitRef.getPattern() != null && unitRef.getPattern().getArtifactId() != null)
+                        temp += "\", pattern artifact = \"" + unitRef.getPattern().getArtifactId();
+                    if (unitRef.getPattern() != null && unitRef.getPattern().getVersion() != null)
+                        temp += "\", pattern version = \"" + unitRef.getPattern().getVersion();
+                    if (unitRef.getPattern() != null && unitRef.getPattern().getModule() != null)
+                        temp += "\", pattern module = \"" + unitRef.getPattern().getModule();
+                    temp += "\"";
+                    return temp;
+                }
+
+                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/branches/2.1.4/plugins/org.apache.geronimo.st.v21.ui/src/main/java/org/apache/geronimo/st/v21/ui/sections/PersUnitRefSection.java
------------------------------------------------------------------------------
    svn:eol-style = native

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

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

Modified: geronimo/devtools/eclipse-plugin/branches/2.1.4/plugins/org.apache.geronimo.st.v21.ui/src/main/java/org/apache/geronimo/st/v21/ui/wizards/GBeanRefWizard.java
URL: http://svn.apache.org/viewvc/geronimo/devtools/eclipse-plugin/branches/2.1.4/plugins/org.apache.geronimo.st.v21.ui/src/main/java/org/apache/geronimo/st/v21/ui/wizards/GBeanRefWizard.java?rev=704564&r1=704563&r2=704564&view=diff
==============================================================================
--- geronimo/devtools/eclipse-plugin/branches/2.1.4/plugins/org.apache.geronimo.st.v21.ui/src/main/java/org/apache/geronimo/st/v21/ui/wizards/GBeanRefWizard.java (original)
+++ geronimo/devtools/eclipse-plugin/branches/2.1.4/plugins/org.apache.geronimo.st.v21.ui/src/main/java/org/apache/geronimo/st/v21/ui/wizards/GBeanRefWizard.java Tue Oct 14 08:23:39 2008
@@ -16,43 +16,40 @@
  */
 package org.apache.geronimo.st.v21.ui.wizards;
 
-
-import java.util.List;
-
 import javax.xml.bind.JAXBElement;
 
 import org.apache.geronimo.jee.naming.GbeanRef;
-import org.apache.geronimo.jee.security.Description;
+import org.apache.geronimo.jee.naming.ObjectFactory;
+import org.apache.geronimo.jee.naming.Pattern;
+import org.apache.geronimo.jee.web.WebApp;
 import org.apache.geronimo.st.core.jaxb.JAXBObjectFactory;
-import org.apache.geronimo.st.core.jaxb.JAXBUtils;
 import org.apache.geronimo.st.ui.CommonMessages;
-import org.apache.geronimo.st.ui.sections.AbstractTableSection;
-import org.apache.geronimo.st.ui.wizards.AbstractTableWizard;
+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.eclipse.swt.SWT;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Text;
+import org.apache.geronimo.st.v21.ui.sections.GBeanRefSection;
 
 /**
  * @version $Rev$ $Date$
  */
-public class GBeanRefWizard extends AbstractTableWizard {
+public class GBeanRefWizard extends AbstractTreeWizard {
 
-    public GBeanRefWizard(AbstractTableSection section) {
-        super(section);
+    private final int GBEAN_REF = 0;
+    private final int GBEAN_TYPE = 1;
+    private final int PATTERN = 2;
+    
+    public GBeanRefWizard(AbstractTreeSection section) {
+        super(section, 3, 5);
+        elementTypes[GBEAN_REF] = "GBean Reference";
+        elementTypes[GBEAN_TYPE] = "Gbean type";
+        elementTypes[PATTERN] = "Pattern";
     }
 
     public JAXBObjectFactory getEFactory() {
         return JAXBObjectFactoryImpl.getInstance();
     }
 
-    public String[] getTableColumnEAttributes() {
-         return new String[] { "RefName", "RefType" };
-    }
-
     public String getAddWizardWindowTitle() {
         return CommonMessages.wizardNewTitle_GBeanRef;
     }
@@ -61,11 +58,11 @@
         return CommonMessages.wizardEditTitle_GBeanRef;
     }
 
-    public String getWizardFirstPageTitle() {
+    public String getWizardPageTitle() {
         return CommonMessages.wizardPageTitle_GBeanRef;
     }
 
-    public String getWizardFirstPageDescription() {
+    public String getWizardPageDescription() {
         return CommonMessages.wizardPageDescription_GBeanRef;
     }
  
@@ -80,82 +77,125 @@
 
     // need to extend the DynamicWizardPage only so that when the Edit dialog is shown
     // the values are brought in properly.
-    public class GbeanRefWizardPage extends DynamicWizardPage {
+    public class GbeanRefWizardPage extends AbstractTreeWizardPage {
         public GbeanRefWizardPage(String pageName) {
             super(pageName);
         }
 
-        public void createControl(Composite parent) {
-            Composite composite = createComposite(parent);
-            for (int i = 0; i < section.getTableColumnNames().length; i++) {
-                Label label = new Label(composite, SWT.LEFT);
-                String columnName = section.getTableColumnNames()[i];
-                if (!columnName.endsWith(":"))
-                    columnName = columnName.concat(":");
-                label.setText(columnName);
-                GridData data = new GridData();
-                data.horizontalAlignment = GridData.FILL;
-                label.setLayoutData(data);
-
-                Text text = new Text(composite, SWT.SINGLE | SWT.BORDER);
-                data = new GridData(GridData.HORIZONTAL_ALIGN_FILL
-                        | GridData.VERTICAL_ALIGN_FILL);
-                data.grabExcessHorizontalSpace = true;
-                data.widthHint = 100;
-                text.setLayoutData(data);
-                if (eObject != null) {
-                    if (i == 1) {
-                        // get the description
-                        GbeanRef gbeanRef = (GbeanRef) eObject;
-                        String value = gbeanRef.getRefType().get(0);
-                        if (value != null) {
-                            text.setText(value);
-                        }                        
-                    }
-                    else
-                    {
-                        String value = (String) JAXBUtils.getValue(eObject,getTableColumnEAttributes()[i]);
-                        if (value != null) {
-                            text.setText(value);
-                        }
-                    }
-                }
-                textEntries[i] = text;
-            }
-
-            doCustom(composite);
-            setControl(composite);
-            textEntries[0].setFocus();
+        protected void initControl () {
+            if (eObject == null) {
+                element.select(GBEAN_REF);
+                GbeanRef gbeanRef = ((GBeanRefSection)section).getSelectedGbeanRef();
+                if (gbeanRef == null) {
+                    element.setEnabled(false);
+                }
+            }
+            else {
+                if (JAXBElement.class.isInstance(eObject)) {
+                    eObject = ((JAXBElement)eObject).getValue();
+                }
+                if (GbeanRef.class.isInstance(eObject)) {
+                    textList.get(0).setText(((GbeanRef)eObject).getRefName());
+                    element.select(GBEAN_REF);
+                }
+                else if (String.class.isInstance(eObject)) {
+                    textList.get(0).setText(((String)eObject));
+                    element.select(GBEAN_TYPE);
+                }
+                else if (Pattern.class.isInstance(eObject)) {
+                    textList.get(0).setText(((Pattern)eObject).getName());
+                    textList.get(1).setText(((Pattern)eObject).getGroupId());
+                    textList.get(2).setText(((Pattern)eObject).getArtifactId());
+                    textList.get(3).setText(((Pattern)eObject).getVersion());
+                    textList.get(4).setText(((Pattern)eObject).getModule());
+                    element.select(PATTERN);
+                }
+                element.setEnabled(false);
+            }
+        }
+        
+        protected void toggleFields (boolean clearFields) {
+            for (int i = 0; i < maxTextFields; i++) {
+                labelList.get(i).setVisible(i < 1 ? true : false);
+                textList.get(i).setVisible(i < 1 ? true : false);
+                if (clearFields == true) {
+                    textList.get(i).setText("");
+                }
+            }
+            if (element.getText().equals(elementTypes[GBEAN_TYPE])) {
+                labelList.get(0).setText(CommonMessages.type);
+            }
+            else {
+                labelList.get(0).setText(CommonMessages.name);
+            }
+            labelList.get(1).setText(CommonMessages.groupId);
+            labelList.get(2).setText(CommonMessages.artifactId);
+            labelList.get(3).setText(CommonMessages.version);
+            labelList.get(4).setText(CommonMessages.moduleId);
+            for (int i = 1; i < maxTextFields; i++) {
+                labelList.get(i).setVisible(element.getText().equals(elementTypes[PATTERN]));
+                textList.get(i).setVisible(element.getText().equals(elementTypes[PATTERN]));
+                if (clearFields == true) {
+                    textList.get(i).setText("");
+                }
+            }
         }
     }
-    
-    public boolean performFinish() {
-        DynamicWizardPage page = (DynamicWizardPage) getPages()[0];
 
-        if (eObject == null) {
-            eObject = getEFactory().create(GbeanRef.class);
-            JAXBElement plan = section.getPlan();
-
-            List gbeanRefList = JAXBModelUtils.getGbeanRefs(plan); 
-            if (gbeanRefList == null) {
-                gbeanRefList = (List)getEFactory().create(GbeanRef.class);
+    @Override
+    public boolean performFinish() {
+        GbeanRef gbeanRef;
+        if (element.getText().equals(elementTypes[GBEAN_REF])) {
+            if (isEmpty(textList.get(0).getText())) {
+                return false;
             }
-            gbeanRefList.add(eObject);
+            gbeanRef = (GbeanRef)eObject;
+            if (gbeanRef == null) {
+                gbeanRef = (GbeanRef)getEFactory().create(GbeanRef.class);
+                JAXBElement plan = section.getPlan();
+
+                // if we have a WebApp, add the JAXBElement of the GBeanRef, not the GBeanRef
+                if (WebApp.class.isInstance(plan.getValue())) {
+                    ObjectFactory objectFactory = new ObjectFactory();
+                    JAXBModelUtils.getGbeanRefs(plan).add(objectFactory.createGbeanRef(gbeanRef));
+                    section.getObjectContainer().add(objectFactory.createGbeanRef(gbeanRef));
+                }
+                else {
+                    JAXBModelUtils.getGbeanRefs(plan).add(gbeanRef);
+                    section.getObjectContainer().add(gbeanRef);
+                }
+            }
+            gbeanRef.setRefName(textList.get(0).getText());
         }
-
-        // NOTE!! this replaces the call to processEAttributes (page);
-        String value = page.getTextEntry(0).getText();
-        String attribute = getTableColumnEAttributes()[0];
-        JAXBUtils.setValue(eObject, attribute, value);
-
-        Description type = null;
-        GbeanRef gbeanRef = (GbeanRef) eObject;
-        gbeanRef.getRefType().add(page.getTextEntry(1).getText());
-
-        if (section.getViewer().getInput() == section.getPlan()) {
-            section.getViewer().setInput(section.getInput());
+        else if (element.getText().equals(elementTypes[GBEAN_TYPE])) {
+            if (isEmpty(textList.get(0).getText())) {
+                return false;
+            }
+            String type = (String)eObject;
+            gbeanRef = ((GBeanRefSection)section).getSelectedGbeanRef();
+            if (type == null) {
+                gbeanRef.getRefType().add(textList.get(0).getText());
+            }
+            else {
+                gbeanRef.getRefType().set(gbeanRef.getRefType().indexOf(type), textList.get(0).getText());
+            }
+        }
+        else if (element.getText().equals(elementTypes[PATTERN])) { 
+            if (isEmpty(textList.get(0).getText())) {
+                return false;
+            }
+            Pattern pattern = (Pattern)eObject;
+            if (pattern == null) {
+                pattern = (Pattern)getEFactory().create(Pattern.class);
+                gbeanRef = ((GBeanRefSection)section).getSelectedGbeanRef();
+                gbeanRef.getPattern().add(pattern);
+            }
+            pattern.setName(textList.get(0).getText());
+            pattern.setGroupId(textList.get(1).getText());
+            pattern.setArtifactId(textList.get(2).getText());
+            pattern.setVersion(textList.get(3).getText());
+            pattern.setModule(textList.get(4).getText());
         }
-
         return true;
     }
 }

Added: geronimo/devtools/eclipse-plugin/branches/2.1.4/plugins/org.apache.geronimo.st.v21.ui/src/main/java/org/apache/geronimo/st/v21/ui/wizards/PersContextRefWizard.java
URL: http://svn.apache.org/viewvc/geronimo/devtools/eclipse-plugin/branches/2.1.4/plugins/org.apache.geronimo.st.v21.ui/src/main/java/org/apache/geronimo/st/v21/ui/wizards/PersContextRefWizard.java?rev=704564&view=auto
==============================================================================
--- geronimo/devtools/eclipse-plugin/branches/2.1.4/plugins/org.apache.geronimo.st.v21.ui/src/main/java/org/apache/geronimo/st/v21/ui/wizards/PersContextRefWizard.java (added)
+++ geronimo/devtools/eclipse-plugin/branches/2.1.4/plugins/org.apache.geronimo.st.v21.ui/src/main/java/org/apache/geronimo/st/v21/ui/wizards/PersContextRefWizard.java Tue Oct 14 08:23:39 2008
@@ -0,0 +1,269 @@
+/*
+ * 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.naming.PersistenceContextRef;
+import org.apache.geronimo.jee.naming.PersistenceContextType;
+import org.apache.geronimo.jee.naming.ObjectFactory;
+import org.apache.geronimo.jee.naming.Pattern;
+import org.apache.geronimo.jee.naming.Property;
+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.PersContextRefSection;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Combo;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Text;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class PersContextRefWizard extends AbstractTreeWizard {
+
+    private final int CONTEXT = 0;
+    private final int PROPERTY = 1;
+    
+    private final String[] CONTEXT_TYPES = {
+            "Extended", "Transactional" };
+    protected Combo contextType;
+    protected Button specifyUnit;
+    protected Button specifyPattern;
+    
+    public PersContextRefWizard(AbstractTreeSection section) {
+        super(section, 2, 8);
+        elementTypes[CONTEXT] = "Persistence Context";
+        elementTypes[PROPERTY] = "Property";
+    }
+
+    public JAXBObjectFactory getEFactory() {
+        return JAXBObjectFactoryImpl.getInstance();
+    }
+
+    public String getAddWizardWindowTitle() {
+        return CommonMessages.wizardNewTitle_PersContextRef;
+    }
+
+    public String getEditWizardWindowTitle() {
+        return CommonMessages.wizardEditTitle_PersContextRef;
+    }
+
+    public String getWizardPageTitle() {
+        return CommonMessages.wizardPageTitle_PersContextRef;
+    }
+
+    public String getWizardPageDescription() {
+        return CommonMessages.wizardPageDescription_PersContextRef;
+    }
+ 
+    /*
+     * (non-Javadoc)
+     * 
+     * @see org.eclipse.jface.wizard.IWizard#addPages()
+     */
+    public void addPages() {
+        addPage(new PersContextRefWizardPage("Page0"));
+    }
+
+    // need to extend the DynamicWizardPage only so that when the Edit dialog is shown
+    // the values are brought in properly.
+    public class PersContextRefWizardPage extends AbstractTreeWizardPage {
+        public PersContextRefWizardPage(String pageName) {
+            super(pageName);
+        }
+
+        @Override
+        public void createControl(Composite parent) {
+            Label label;
+            Text text;
+            Composite composite = createComposite(parent);
+            createLabel(composite, CommonMessages.element);
+            element = createCombo(composite, elementTypes, false);
+            for (int i = 0; i < maxTextFields; i++) {
+                label = createLabel(composite, "");
+                labelList.add(label);
+                if (i == 1) {
+                    contextType = createCombo(composite, CONTEXT_TYPES, false);
+                    textList.add (null);
+                    specifyUnit = createButton(composite, CommonMessages.useUnitName);
+                }
+                else {
+                    text = createTextField(composite, "");
+                    textList.add(text);
+                    if (i == 2) {
+                        specifyPattern = createButton(composite, CommonMessages.usePattern);
+                    }
+                }
+            }
+            element.addSelectionListener(new SelectionAdapter() {
+                public void widgetSelected(SelectionEvent arg0) {
+                    toggleFields(true);
+                }
+            });
+            specifyUnit.addSelectionListener(new SelectionAdapter() {
+                public void widgetSelected(SelectionEvent arg0) {
+                    toggleFields(false);
+                }
+            });
+            specifyPattern.addSelectionListener(new SelectionAdapter() {
+                public void widgetSelected(SelectionEvent arg0) {
+                    toggleFields(false);
+                }
+            });
+            
+            initControl();
+            toggleFields(false);
+            setControl(composite);
+        }
+
+        protected void initControl () {
+            if (eObject == null) {
+                element.select(CONTEXT);
+                PersistenceContextRef contextRef = ((PersContextRefSection)section).getSelectedPersContext();
+                if (contextRef == null) {
+                    element.setEnabled(false);
+                }
+            }
+            else {
+                if (JAXBElement.class.isInstance(eObject)) {
+                    eObject = ((JAXBElement)eObject).getValue();
+                    PersistenceContextRef contextRef = (PersistenceContextRef)eObject;
+                    textList.get(0).setText(contextRef .getPersistenceContextRefName());
+                    contextType.setText(contextRef .getPersistenceContextType().value());
+                    if (contextRef .getPersistenceUnitName() != null)
+                        textList.get(2).setText(contextRef .getPersistenceUnitName());
+                    if (contextRef .getPattern() != null) {
+                        specifyPattern.setSelection(true);
+                        textList.get(3).setText(contextRef.getPattern().getName());
+                        if (contextRef .getPattern().getGroupId() != null)
+                            textList.get(4).setText(contextRef .getPattern().getGroupId());
+                        if (contextRef .getPattern().getArtifactId() != null)
+                            textList.get(5).setText(contextRef .getPattern().getArtifactId());
+                        if (contextRef .getPattern().getVersion() != null)
+                            textList.get(6).setText(contextRef .getPattern().getVersion());
+                        if (contextRef .getPattern().getModule() != null)
+                            textList.get(7).setText(contextRef .getPattern().getModule());
+                    }
+                    element.select(CONTEXT);
+                }
+                else if (Property.class.isInstance(eObject)) {
+                    textList.get(0).setText(((Property)eObject).getKey());
+                    textList.get(2).setText(((Property)eObject).getValue());
+                    element.select(PROPERTY);
+                }
+                element.setEnabled(false);
+            }
+        }
+        
+        protected void toggleFields (boolean clearFields) {
+            if (element.getText().equals(elementTypes[CONTEXT])) {
+                labelList.get(0).setText(CommonMessages.contextName);
+                labelList.get(2).setText(CommonMessages.unitName);
+                textList.get(2).setEnabled(specifyUnit.getSelection());
+                labelList.get(1).setVisible(true);
+                contextType.setVisible(true);    
+                specifyUnit.setVisible(true);
+                specifyPattern.setVisible(true);
+            }
+            else {
+                labelList.get(0).setText(CommonMessages.name);
+                labelList.get(2).setText(CommonMessages.value);
+                textList.get(2).setEnabled(true);
+                labelList.get(1).setVisible(false);
+                contextType.setVisible(false);
+                specifyUnit.setVisible(false);
+                specifyPattern.setVisible(false);
+            }
+            labelList.get(1).setText(CommonMessages.type);
+            labelList.get(3).setText(CommonMessages.name);
+            labelList.get(4).setText(CommonMessages.groupId);
+            labelList.get(5).setText(CommonMessages.artifactId);
+            labelList.get(6).setText(CommonMessages.version);
+            labelList.get(7).setText(CommonMessages.moduleId);
+            for (int i = 3; i < maxTextFields; i++) {
+                labelList.get(i).setVisible(element.getText().equals(elementTypes[CONTEXT]));
+                textList.get(i).setVisible(element.getText().equals(elementTypes[CONTEXT]));
+                textList.get(i).setEnabled(specifyPattern.getSelection());
+                if (clearFields == true) {
+                    textList.get(i).setText("");
+                }
+            }
+        }
+    }
+
+    @Override
+    public boolean performFinish() {
+        PersistenceContextRef contextRef;
+        if (element.getText().equals(elementTypes[CONTEXT])) {
+            if (isEmpty(textList.get(0).getText()) ||
+                isEmpty(textList.get(2).getText()) && isEmpty(textList.get(3).getText())) {
+                return false;
+            }
+            contextRef = (PersistenceContextRef)eObject;
+            ObjectFactory objectFactory = new ObjectFactory();
+            if (contextRef == null) {
+                contextRef = (PersistenceContextRef)getEFactory().create(PersistenceContextRef.class);
+                JAXBElement plan = section.getPlan();
+
+                // add the JAXBElement of the PersistenceContextRef
+                JAXBModelUtils.getGbeanRefs(plan).add(objectFactory.createPersistenceContextRef(contextRef));
+                section.getObjectContainer().add(objectFactory.createPersistenceContextRef(contextRef));
+            }
+            contextRef.setPersistenceContextRefName(textList.get(0).getText());
+            contextRef.setPersistenceContextType(PersistenceContextType.fromValue(contextType.getText()));
+            if (specifyUnit.getSelection() == true) {
+                contextRef.setPersistenceUnitName(textList.get(2).getText());
+                contextRef.setPattern(null);
+            }
+            else {
+                contextRef.setPersistenceUnitName(null);
+                Pattern pattern = contextRef.getPattern();
+                if (pattern == null) {
+                    pattern = objectFactory.createPattern();
+                }
+                pattern.setName(textList.get(3).getText());
+                pattern.setGroupId(textList.get(4).getText());
+                pattern.setArtifactId(textList.get(5).getText());
+                pattern.setVersion(textList.get(6).getText());
+                pattern.setModule(textList.get(7).getText());
+                contextRef.setPattern(pattern);
+            }
+        }
+        else if (element.getText().equals(elementTypes[PROPERTY])) { 
+            if (isEmpty(textList.get(0).getText())) {
+                return false;
+            }
+            Property property = (Property)eObject;
+            if (property == null) {
+                property = (Property)getEFactory().create(Property.class);
+                contextRef = ((PersContextRefSection)section).getSelectedPersContext();
+                contextRef.getProperty().add(property);
+            }
+            property.setKey(textList.get(0).getText());
+            property.setValue(textList.get(2).getText());
+        }
+        return true;
+    }
+}

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

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

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

Added: geronimo/devtools/eclipse-plugin/branches/2.1.4/plugins/org.apache.geronimo.st.v21.ui/src/main/java/org/apache/geronimo/st/v21/ui/wizards/PersUnitRefWizard.java
URL: http://svn.apache.org/viewvc/geronimo/devtools/eclipse-plugin/branches/2.1.4/plugins/org.apache.geronimo.st.v21.ui/src/main/java/org/apache/geronimo/st/v21/ui/wizards/PersUnitRefWizard.java?rev=704564&view=auto
==============================================================================
--- geronimo/devtools/eclipse-plugin/branches/2.1.4/plugins/org.apache.geronimo.st.v21.ui/src/main/java/org/apache/geronimo/st/v21/ui/wizards/PersUnitRefWizard.java (added)
+++ geronimo/devtools/eclipse-plugin/branches/2.1.4/plugins/org.apache.geronimo.st.v21.ui/src/main/java/org/apache/geronimo/st/v21/ui/wizards/PersUnitRefWizard.java Tue Oct 14 08:23:39 2008
@@ -0,0 +1,196 @@
+/*
+ * 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.naming.PersistenceUnitRef;
+import org.apache.geronimo.jee.naming.ObjectFactory;
+import org.apache.geronimo.jee.naming.Pattern;
+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.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Text;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class PersUnitRefWizard extends AbstractTreeWizard {
+
+    protected Button specifyUnit;
+    protected Button specifyPattern;
+    
+    public PersUnitRefWizard(AbstractTreeSection section) {
+        super(section, 1, 7);
+    }
+
+    public JAXBObjectFactory getEFactory() {
+        return JAXBObjectFactoryImpl.getInstance();
+    }
+
+    public String getAddWizardWindowTitle() {
+        return CommonMessages.wizardNewTitle_PersUnitRef;
+    }
+
+    public String getEditWizardWindowTitle() {
+        return CommonMessages.wizardEditTitle_PersUnitRef;
+    }
+
+    public String getWizardPageTitle() {
+        return CommonMessages.wizardPageTitle_PersUnitRef;
+    }
+
+    public String getWizardPageDescription() {
+        return CommonMessages.wizardPageDescription_PersUnitRef;
+    }
+ 
+    /*
+     * (non-Javadoc)
+     * 
+     * @see org.eclipse.jface.wizard.IWizard#addPages()
+     */
+    public void addPages() {
+        addPage(new PersUnitRefWizardPage("Page0"));
+    }
+
+    // need to extend the DynamicWizardPage only so that when the Edit dialog is shown
+    // the values are brought in properly.
+    public class PersUnitRefWizardPage extends AbstractTreeWizardPage {
+        public PersUnitRefWizardPage(String pageName) {
+            super(pageName);
+        }
+
+        @Override
+        public void createControl(Composite parent) {
+            Label label;
+            Text text;
+            Composite composite = createComposite(parent);
+            for (int i = 0; i < maxTextFields; i++) {
+                label = createLabel(composite, "");
+                labelList.add(label);
+                text = createTextField(composite, "");
+                textList.add(text);
+                if (i == 0) {
+                    specifyUnit = createButton(composite, CommonMessages.useUnitName);
+                }
+                if (i == 1) {
+                    specifyPattern = createButton(composite, CommonMessages.usePattern);
+                }
+            }
+            specifyUnit.addSelectionListener(new SelectionAdapter() {
+                public void widgetSelected(SelectionEvent arg0) {
+                    toggleFields(false);
+                }
+            });
+            specifyPattern.addSelectionListener(new SelectionAdapter() {
+                public void widgetSelected(SelectionEvent arg0) {
+                    toggleFields(false);
+                }
+            });
+            
+            initControl();
+            toggleFields(false);
+            setControl(composite);
+        }
+
+        protected void initControl () {
+            if (eObject != null) {
+                if (JAXBElement.class.isInstance(eObject)) {
+                    eObject = ((JAXBElement)eObject).getValue();
+                    PersistenceUnitRef unitRef = (PersistenceUnitRef)eObject;
+                    textList.get(0).setText(unitRef.getPersistenceUnitRefName());
+                    if (unitRef.getPersistenceUnitName() != null)
+                        textList.get(1).setText(unitRef.getPersistenceUnitName());
+                    if (unitRef.getPattern() != null) {
+                        specifyPattern.setSelection(true);
+                        textList.get(2).setText(unitRef.getPattern().getName());
+                        if (unitRef.getPattern().getGroupId() != null)
+                            textList.get(3).setText(unitRef.getPattern().getGroupId());
+                        if (unitRef.getPattern().getArtifactId() != null)
+                            textList.get(4).setText(unitRef.getPattern().getArtifactId());
+                        if (unitRef.getPattern().getVersion() != null)
+                            textList.get(5).setText(unitRef.getPattern().getVersion());
+                        if (unitRef.getPattern().getModule() != null)
+                            textList.get(6).setText(unitRef.getPattern().getModule());
+                    }
+                }
+            }
+        }
+        
+        protected void toggleFields (boolean clearFields) {
+            labelList.get(0).setText(CommonMessages.contextName);
+            labelList.get(1).setText(CommonMessages.unitName);
+            textList.get(1).setEnabled(specifyUnit.getSelection());
+
+            labelList.get(2).setText(CommonMessages.name);
+            labelList.get(3).setText(CommonMessages.groupId);
+            labelList.get(4).setText(CommonMessages.artifactId);
+            labelList.get(5).setText(CommonMessages.version);
+            labelList.get(6).setText(CommonMessages.moduleId);
+            for (int i = 2; i < maxTextFields; i++) {
+                textList.get(i).setEnabled(specifyPattern.getSelection());
+            }
+        }
+    }
+
+    @Override
+    public boolean performFinish() {
+        PersistenceUnitRef unitRef;
+        if (isEmpty(textList.get(0).getText()) ||
+            isEmpty(textList.get(1).getText()) && isEmpty(textList.get(2).getText())) {
+            return false;
+        }
+        unitRef = (PersistenceUnitRef)eObject;
+        ObjectFactory objectFactory = new ObjectFactory();
+        if (unitRef == null) {
+            unitRef = (PersistenceUnitRef)getEFactory().create(PersistenceUnitRef.class);
+            JAXBElement plan = section.getPlan();
+
+            // add the JAXBElement of the PersistenceContextRef
+            JAXBModelUtils.getGbeanRefs(plan).add(objectFactory.createPersistenceUnitRef(unitRef));
+            section.getObjectContainer().add(objectFactory.createPersistenceUnitRef(unitRef));
+        }
+        unitRef.setPersistenceUnitRefName(textList.get(0).getText());
+        if (specifyUnit.getSelection() == true) {
+            unitRef.setPersistenceUnitName(textList.get(1).getText());
+            unitRef.setPattern(null);
+        }
+        else {
+            unitRef.setPersistenceUnitName(null);
+            Pattern pattern = unitRef.getPattern();
+            if (pattern == null) {
+                pattern = objectFactory.createPattern();
+            }
+            pattern.setName(textList.get(2).getText());
+            pattern.setGroupId(textList.get(3).getText());
+            pattern.setArtifactId(textList.get(4).getText());
+            pattern.setVersion(textList.get(5).getText());
+            pattern.setModule(textList.get(6).getText());
+            unitRef.setPattern(pattern);
+        }
+
+        return true;
+    }
+}

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

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

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