geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mcco...@apache.org
Subject svn commit: r692233 - in /geronimo/devtools/eclipse-plugin/trunk/plugins: org.apache.geronimo.st.ui/src/main/java/org/apache/geronimo/st/ui/internal/ org.apache.geronimo.st.ui/src/main/java/org/apache/geronimo/st/ui/wizards/ org.apache.geronimo.st.v21....
Date Thu, 04 Sep 2008 20:43:24 GMT
Author: mcconne
Date: Thu Sep  4 13:43:23 2008
New Revision: 692233

URL: http://svn.apache.org/viewvc?rev=692233&view=rev
Log:
GERONIMODEVTOOLS-128 Add usabilty enhancements for Web Service References in geronimo-web.xml
deployment plan editor. Thanks to Shiva for the original patch and to BJ Reed for subsequent
refinements !!

Added:
    geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.ui/src/main/java/org/apache/geronimo/st/ui/wizards/AbstractTreeWizard.java
  (with props)
Modified:
    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.ui/src/main/java/org/apache/geronimo/st/ui/wizards/AbstractWizard.java
    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/sections/GBeanSection.java
    geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v21.ui/src/main/java/org/apache/geronimo/st/v21/ui/sections/ServiceRefSection.java
    geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v21.ui/src/main/java/org/apache/geronimo/st/v21/ui/wizards/GBeanWizard.java
    geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v21.ui/src/main/java/org/apache/geronimo/st/v21/ui/wizards/ServiceRefWizard.java

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=692233&r1=692232&r2=692233&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
Thu Sep  4 13:43:23 2008
@@ -335,6 +335,12 @@
     public static String internalPath;
     public static String externalPath;
     public static String altDD;
+
+    public static String serviceCompletionName;
+    public static String protocol;
+    public static String credential;
+    public static String bindingName;
+    public static String uri;
     
     public static String connector;
     public static String ejb;

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=692233&r1=692232&r2=692233&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
Thu Sep  4 13:43:23 2008
@@ -340,6 +340,12 @@
 externalPath=External Path
 altDD=Alternate DD
 
+serviceCompletionName=Service Completion Name:
+protocol=Protocol:
+credential=Credential:
+bindingName=Binding Name:
+uri=URI:
+
 connector=Connector
 ejb=EJB
 java=Java

Added: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.ui/src/main/java/org/apache/geronimo/st/ui/wizards/AbstractTreeWizard.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/wizards/AbstractTreeWizard.java?rev=692233&view=auto
==============================================================================
--- geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.ui/src/main/java/org/apache/geronimo/st/ui/wizards/AbstractTreeWizard.java
(added)
+++ geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.ui/src/main/java/org/apache/geronimo/st/ui/wizards/AbstractTreeWizard.java
Thu Sep  4 13:43:23 2008
@@ -0,0 +1,101 @@
+/*
+ * 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.ui.wizards;
+
+import java.util.ArrayList;
+
+import org.apache.geronimo.st.ui.CommonMessages;
+import org.apache.geronimo.st.ui.sections.AbstractTreeSection;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+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 abstract class AbstractTreeWizard extends AbstractWizard {
+
+    protected String[] elementTypes = null;
+    protected int maxTextFields;
+
+    protected Combo element;
+    protected ArrayList<Text> textList;
+    
+    /*
+     * AbstractTreeWizard takes 3 parameters
+     * The Tree Section that is being added/edited
+     * elementTypeCount for how many different elements could be handled
+     * maxTextFields for the maximum number of fields an element may have.
+     * 
+     * For the most part, the user will be given an opportunity to add any kind of\
+     * element by using a combo.  When the combo changes, the fields need to change
+     * to allow the appropriate fields to be used.
+     */
+    public AbstractTreeWizard(AbstractTreeSection section, int elementTypeCount, int maxTextFields)
{
+        super(section);
+        elementTypes = new String[elementTypeCount];
+        this.maxTextFields = maxTextFields;
+        textList = new ArrayList<Text>(maxTextFields);
+    }
+
+    public abstract class AbstractTreeWizardPage extends AbstractWizardPage {
+        protected ArrayList<Label> labelList;
+
+        public AbstractTreeWizardPage(String pageName) {
+            super(pageName);
+            labelList = new ArrayList<Label>(maxTextFields);
+        }
+
+        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);
+                text = createTextField(composite, "");
+                textList.add(text);
+            }
+            element.addSelectionListener(new SelectionAdapter() {
+                public void widgetSelected(SelectionEvent arg0) {
+                    toggleFields(true);
+                }
+            });
+            
+            initControl();
+            toggleFields(false);
+            setControl(composite);
+        }
+
+        protected abstract void initControl();
+
+        protected abstract void toggleFields(boolean clearFields);
+    }
+
+    protected abstract String getWizardPageTitle();
+
+    protected abstract String getWizardPageDescription();
+
+    protected abstract String getAddWizardWindowTitle();
+
+    protected abstract String getEditWizardWindowTitle();
+}

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

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

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

Modified: geronimo/devtools/eclipse-plugin/trunk/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/trunk/plugins/org.apache.geronimo.st.ui/src/main/java/org/apache/geronimo/st/ui/wizards/AbstractWizard.java?rev=692233&r1=692232&r2=692233&view=diff
==============================================================================
--- geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.ui/src/main/java/org/apache/geronimo/st/ui/wizards/AbstractWizard.java
(original)
+++ geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.ui/src/main/java/org/apache/geronimo/st/ui/wizards/AbstractWizard.java
Thu Sep  4 13:43:23 2008
@@ -16,7 +16,6 @@
  */
 package org.apache.geronimo.st.ui.wizards;
 
-import org.apache.geronimo.st.core.jaxb.JAXBObjectFactory;
 import org.apache.geronimo.st.ui.Activator;
 import org.apache.geronimo.st.ui.sections.AbstractListSection;
 import org.eclipse.jface.resource.ImageDescriptor;

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=692233&r1=692232&r2=692233&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
Thu Sep  4 13:43:23 2008
@@ -167,6 +167,14 @@
         return null;
     }
 
+    public static List getServiceRefs (JAXBElement element) {
+        Object plan = element.getValue();
+        if (WebApp.class.isInstance (plan)) {
+            return ((WebApp)plan).getServiceRef() == null ? null : ((WebApp)plan).getServiceRef();
+        }
+        return null;
+    }
+
     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=692233&r1=692232&r2=692233&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
Thu Sep  4 13:43:23 2008
@@ -32,6 +32,9 @@
 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.Port;
+import org.apache.geronimo.jee.naming.PortCompletion;
+import org.apache.geronimo.jee.naming.ServiceCompletion;
 import org.apache.geronimo.jee.naming.ResourceEnvRef;
 import org.apache.geronimo.jee.naming.ResourceRef;
 import org.apache.geronimo.jee.naming.ServiceRef;
@@ -72,6 +75,12 @@
             return (new org.apache.geronimo.jee.naming.ObjectFactory()).createMessageDestination();
         } else if ( type.equals( org.apache.geronimo.jee.naming.Pattern.class ) ) {
             return (new org.apache.geronimo.jee.naming.ObjectFactory()).createPattern();
+        } else if ( type.equals( Port.class ) ) {
+            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( ServiceCompletion.class ) ) {
+            return (new org.apache.geronimo.jee.naming.ObjectFactory()).createServiceCompletion();
         } else if ( type.equals( ServiceRef.class ) ) {
             return (new org.apache.geronimo.jee.naming.ObjectFactory()).createServiceRef();
         } else if ( type.equals( EjbLocalRef.class ) ) {

Modified: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v21.ui/src/main/java/org/apache/geronimo/st/v21/ui/sections/GBeanSection.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/GBeanSection.java?rev=692233&r1=692232&r2=692233&view=diff
==============================================================================
--- geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v21.ui/src/main/java/org/apache/geronimo/st/v21/ui/sections/GBeanSection.java
(original)
+++ geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v21.ui/src/main/java/org/apache/geronimo/st/v21/ui/sections/GBeanSection.java
Thu Sep  4 13:43:23 2008
@@ -173,7 +173,7 @@
             @Override
             public Image getImage(Object arg0) {
                 return Activator.imageDescriptorFromPlugin("org.eclipse.jst.j2ee",
-                        "icons/full/obj16/security_role.gif").createImage();
+                        "icons/full/obj16/accessbean_obj.gif").createImage();
             }
         };
     }

Modified: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v21.ui/src/main/java/org/apache/geronimo/st/v21/ui/sections/ServiceRefSection.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/ServiceRefSection.java?rev=692233&r1=692232&r2=692233&view=diff
==============================================================================
--- geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v21.ui/src/main/java/org/apache/geronimo/st/v21/ui/sections/ServiceRefSection.java
(original)
+++ geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v21.ui/src/main/java/org/apache/geronimo/st/v21/ui/sections/ServiceRefSection.java
Thu Sep  4 13:43:23 2008
@@ -20,58 +20,161 @@
 
 import javax.xml.bind.JAXBElement;
 
+
+import org.apache.geronimo.jee.naming.Port;
+import org.apache.geronimo.jee.naming.PortCompletion;
 import org.apache.geronimo.jee.naming.ServiceRef;
 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.ui.Activator;
 import org.apache.geronimo.st.v21.ui.wizards.ServiceRefWizard;
-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 ServiceRefSection extends AbstractTableSection {
-
+public class ServiceRefSection extends AbstractTreeSection {
     public ServiceRefSection(JAXBElement plan, Composite parent, FormToolkit toolkit, int
style, List serviceRefs) {
         super(plan, parent, toolkit, style);
         this.objectContainer = serviceRefs;
-        COLUMN_NAMES = new String[] { CommonMessages.editorServiceRefName };
         createClient();
-        getSection().setExpanded(false);
     }
 
+    @Override
     public String getTitle() {
         return CommonMessages.editorServiceRefTitle;
     }
 
+    @Override
     public String getDescription() {
         return CommonMessages.editorServiceRefDescription;
     }
 
+    @Override
     public Wizard getWizard() {
         return new ServiceRefWizard(this);
     }
 
+    @Override
     public Class getTableEntryObjectType() {
         return ServiceRef.class;
     }
 
     @Override
-    public ITableLabelProvider getLabelProvider() {
+    protected void activateAddButton() {
+        if (tree.getSelectionCount() == 0 || tree.getSelection()[0].getParentItem() == null)
{
+            addButton.setEnabled(true);
+        } else {
+            addButton.setEnabled(false);
+        }
+    }
+
+    public ServiceRef getSelectedServiceRef () {
+        if (tree.getSelection().length == 0) {
+            return null;
+        }
+        return (ServiceRef)tree.getSelection()[0].getData();
+    }
+    
+    @Override
+    public void removeItem(Object anItem) {
+        if (ServiceRef.class.isInstance(anItem)) {
+            getObjectContainer().remove(anItem);
+        }
+        else if (Port.class.isInstance(anItem)) {
+            ServiceRef serviceRef = (ServiceRef)tree.getSelection()[0].getParentItem().getData();
+            serviceRef.getPort().remove(anItem);
+        }
+        else if (PortCompletion.class.isInstance(anItem)) {
+            ServiceRef serviceRef = (ServiceRef)tree.getSelection()[0].getParentItem().getData();
+            serviceRef.getServiceCompletion().getPortCompletion().remove(anItem);
+        }
+    }
+    
+    @Override
+    public Object getInput() {
+        if (objectContainer != null) {
+            return objectContainer;
+        }
+        return super.getInput();
+    }
+
+    @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 (ServiceRef.class.isInstance(parentElement)) {
+                    ServiceRef serviceRef = (ServiceRef)parentElement;
+                    Object[] portList = serviceRef.getPort().toArray();
+                    Object[] compList = new Object[0];
+                    if (serviceRef.getServiceCompletion() != null) {
+                        compList = serviceRef.getServiceCompletion().getPortCompletion().toArray();
+                    }
+                    Object[] fullList = new Object[portList.length + compList.length];
+                    System.arraycopy(portList, 0, fullList, 0, portList.length);
+                    System.arraycopy(compList, 0, fullList, portList.length, compList.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 (ServiceRef.class.isInstance(element)) {
-                    ServiceRef serviceRef = (ServiceRef) element;
-                    switch (columnIndex) {
-                    case 0:
-                        return serviceRef.getServiceRefName();
-                    }
+                    ServiceRef serviceRef = (ServiceRef)element;
+                        String retString = "Service Ref: name = \"" + serviceRef.getServiceRefName()
+ "\"";
+                        if (serviceRef.getServiceCompletion() != null) {
+                            retString += ", service completion name = \"" + serviceRef.getServiceCompletion().getServiceName()
+ "\"";
+                        }
+                        return retString;
+                }
+                else if (Port.class.isInstance(element)) {
+                    Port port = (Port)element;
+                    return "Port: name = \"" + port.getPortName() + 
+                            "\", protocol = \"" + port.getProtocol() + 
+                            "\", host = \"" + port.getHost() + 
+                            "\", port = \"" + port.getPort() + 
+                            "\", uri = \"" + port.getUri() + 
+                            "\", credential = \"" + port.getCredentialsName() + "\"";
+                }
+                else if (PortCompletion.class.isInstance(element)) {
+                    PortCompletion portComp = (PortCompletion)element;
+                    return "Port Completion: name = \"" + portComp.getPort().getPortName()
+ 
+                            "\", protocol = \"" + portComp.getPort().getProtocol() + 
+                            "\", host = \"" + portComp.getPort().getHost() + 
+                            "\", port = \"" + portComp.getPort().getPort() + 
+                            "\", uri = \"" + portComp.getPort().getUri() + 
+                            "\", credential = \"" + portComp.getPort().getCredentialsName()
+
+                            "\", binding name = \"" + portComp.getBindingName() + "\"";
                 }
+
                 return null;
             }
+
+            @Override
+            public Image getImage(Object arg0) {
+                return Activator.imageDescriptorFromPlugin("org.eclipse.jst.j2ee",
+                        "icons/full/obj16/module_web_obj.gif").createImage();
+            }
         };
     }
 }

Modified: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v21.ui/src/main/java/org/apache/geronimo/st/v21/ui/wizards/GBeanWizard.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/GBeanWizard.java?rev=692233&r1=692232&r2=692233&view=diff
==============================================================================
--- geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v21.ui/src/main/java/org/apache/geronimo/st/v21/ui/wizards/GBeanWizard.java
(original)
+++ geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v21.ui/src/main/java/org/apache/geronimo/st/v21/ui/wizards/GBeanWizard.java
Thu Sep  4 13:43:23 2008
@@ -16,7 +16,6 @@
  */
 package org.apache.geronimo.st.v21.ui.wizards;
 
-import java.util.ArrayList;
 import javax.xml.bind.JAXBElement;
 
 import org.apache.geronimo.jee.deployment.Attribute;
@@ -27,65 +26,36 @@
 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.AbstractWizard;
+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.GBeanSection;
-import org.apache.geronimo.st.v21.ui.wizards.SecurityRoleMappingWizard.SecurityRoleMappingsWizardPage;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-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 GBeanWizard extends AbstractWizard {
+public class GBeanWizard extends AbstractTreeWizard {
 
     private final int GBEAN = 0;
     private final int ATTRIBUTE = 1;
     private final int DEPENDENCY = 2;
     private final int REFERENCE = 3;
-    private final String[] ELEMENT_TYPES = {
-            "GBean", "Attribute", "Dependency", "Reference" };
-
-    protected Combo element;
-    protected ArrayList<Text> textList;
 
     public GBeanWizard(AbstractTreeSection section) {
-        super(section);
-        textList = new ArrayList<Text>(7);
+        super(section, 4, 7);
+        elementTypes[GBEAN] = "GBean";
+        elementTypes[ATTRIBUTE] = "Attribute";
+        elementTypes[DEPENDENCY] = "Dependency";
+        elementTypes[REFERENCE] = "Reference";
     }
 
-    public class GBeanWizardPage extends AbstractWizardPage {
-        protected ArrayList<Label> labelList;
-        protected Composite composite;
+    public class GBeanWizardPage extends AbstractTreeWizardPage {
 
         public GBeanWizardPage(String pageName) {
             super(pageName);
-            labelList = new ArrayList<Label>(7);
         }
 
-        public void createControl(Composite parent) {
-            Label label;
-            Text text;
-            composite = createComposite(parent);
-            createLabel(composite, CommonMessages.element);
-            element = createCombo(composite, ELEMENT_TYPES, false);
-            for (int i = 0; i < 7; i++) {
-                label = createLabel(composite, "");
-                labelList.add(label);
-                text = createTextField(composite, "");
-                textList.add(text);
-            }
-            element.addSelectionListener(new SelectionAdapter() {
-                public void widgetSelected(SelectionEvent arg0) {
-                    toggleFields();
-                }
-            });
-
+        protected void initControl() {
             if (eObject == null) {
                 element.select(GBEAN);
                 if (((GBeanSection)section).getSelectedGbean() == null) {
@@ -127,17 +97,18 @@
                 }
                 element.setEnabled(false);
             }
-            toggleFields();
-            setControl(composite);
         }
         
-        private void toggleFields () {
+        protected void toggleFields (boolean clearFields) {
             int selection = element.getSelectionIndex();
             switch (selection) {
             case GBEAN:
-                for (int i = 0; i < 7; i++) {
+                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.className);
@@ -150,18 +121,24 @@
                 labelList.get(6).setText(CommonMessages.customName);
                 break;
             case ATTRIBUTE:
-                for (int i = 0; i < 7; i++) {
+                for (int i = 0; i < maxTextFields; i++) {
                     labelList.get(i).setVisible(i < 3 ? true : false);
                     textList.get(i).setVisible(i < 3 ? true : false);
+                    if (clearFields == true) {
+                        textList.get(i).setText("");
+                    }
                 }
                 labelList.get(0).setText(CommonMessages.name);
                 labelList.get(1).setText(CommonMessages.type);
                 labelList.get(2).setText(CommonMessages.value);
                 break;
             case DEPENDENCY:
-                for (int i = 0; i < 7; i++) {
+                for (int i = 0; i < maxTextFields; i++) {
                     labelList.get(i).setVisible(i < 6 ? true : false);
                     textList.get(i).setVisible(i < 6 ? true : false);
+                    if (clearFields == true) {
+                        textList.get(i).setText("");
+                    }
                 }
                 labelList.get(0).setText(CommonMessages.groupId);
                 labelList.get(1).setText(CommonMessages.artifactId);
@@ -171,9 +148,12 @@
                 labelList.get(5).setText(CommonMessages.customName);
                 break;
             case REFERENCE:
-                for (int i = 0; i < 7; i++) {
+                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.groupId);

Modified: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v21.ui/src/main/java/org/apache/geronimo/st/v21/ui/wizards/ServiceRefWizard.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/ServiceRefWizard.java?rev=692233&r1=692232&r2=692233&view=diff
==============================================================================
--- geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v21.ui/src/main/java/org/apache/geronimo/st/v21/ui/wizards/ServiceRefWizard.java
(original)
+++ geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v21.ui/src/main/java/org/apache/geronimo/st/v21/ui/wizards/ServiceRefWizard.java
Thu Sep  4 13:43:23 2008
@@ -16,29 +16,215 @@
  */
 package org.apache.geronimo.st.v21.ui.wizards;
 
+import javax.xml.bind.JAXBElement;
+
+import org.apache.geronimo.jee.naming.Port;
+import org.apache.geronimo.jee.naming.PortCompletion;
+import org.apache.geronimo.jee.naming.ServiceCompletion;
+import org.apache.geronimo.jee.naming.ServiceRef;
 import org.apache.geronimo.st.core.jaxb.JAXBObjectFactory;
 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.apache.geronimo.st.v21.ui.sections.ServiceRefSection;
 
 /**
  * @version $Rev$ $Date$
  */
-public class ServiceRefWizard extends AbstractTableWizard {
+public class ServiceRefWizard extends AbstractTreeWizard {
 
-    public ServiceRefWizard(AbstractTableSection section) {
-        super(section);
+    private final int SERVICE_REF = 0;
+    private final int PORT = 1;
+    private final int PORT_COMPLETION = 2;
+
+    public ServiceRefWizard(AbstractTreeSection section) {
+        super(section, 3, 7);
+        elementTypes[SERVICE_REF] = "Service Reference";
+        elementTypes[PORT] = "Port";
+        elementTypes[PORT_COMPLETION] = "Port Completion";
+    }
+
+    public class ServiceRefWizardPage extends AbstractTreeWizardPage {
+
+        public ServiceRefWizardPage(String pageName) {
+            super(pageName);
+        }
+
+        protected void initControl () {
+            if (eObject == null) {
+                element.select(SERVICE_REF);
+                ServiceRef serviceRef = ((ServiceRefSection)section).getSelectedServiceRef();
+                // use of ports and port completions are mutually exclusive
+                if (serviceRef == null) {
+                    element.setEnabled(false);
+                } else if (serviceRef.getServiceCompletion() == null) {
+                    element.remove(PORT_COMPLETION);
+                } else {
+                    element.remove(PORT);
+                }
+            }
+            else {
+                if (ServiceRef.class.isInstance(eObject)) {
+                    textList.get(0).setText(((ServiceRef)eObject).getServiceRefName());
+                    if (((ServiceRef)eObject).getServiceCompletion() != null) {
+                        textList.get(1).setText(((ServiceRef)eObject).getServiceCompletion().getServiceName());
+                    }
+                    element.select(SERVICE_REF);
+                }
+                else if (Port.class.isInstance(eObject)) {
+                    textList.get(0).setText(((Port)eObject).getPortName());
+                    textList.get(1).setText(((Port)eObject).getProtocol());
+                    textList.get(2).setText(((Port)eObject).getHost());
+                    textList.get(3).setText(((Port)eObject).getPort().toString());
+                    textList.get(4).setText(((Port)eObject).getUri());
+                    textList.get(5).setText(((Port)eObject).getCredentialsName());
+                    element.select(PORT);
+                }
+                else if (PortCompletion.class.isInstance(eObject)) {
+                    textList.get(0).setText(((PortCompletion)eObject).getPort().getPortName());
+                    textList.get(1).setText(((PortCompletion)eObject).getPort().getProtocol());
+                    textList.get(2).setText(((PortCompletion)eObject).getPort().getHost());
+                    textList.get(3).setText(((PortCompletion)eObject).getPort().getPort().toString());
+                    textList.get(4).setText(((PortCompletion)eObject).getPort().getUri());
+                    textList.get(5).setText(((PortCompletion)eObject).getPort().getCredentialsName());
+                    textList.get(6).setText(((PortCompletion)eObject).getBindingName());
+                    element.select(PORT_COMPLETION);
+                }
+                element.setEnabled(false);
+            }
+        }
+        
+        protected void toggleFields (boolean clearFields) {
+            if (element.getText().equals(elementTypes[SERVICE_REF])) {
+                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.serviceCompletionName);
+                // if we are doing an add, then we need to make sure that the longest
+                // text can be handled
+                labelList.get(2).setText(CommonMessages.protocol);
+                labelList.get(3).setText(CommonMessages.hostName);
+                labelList.get(4).setText(CommonMessages.portValue);
+                labelList.get(5).setText(CommonMessages.credential);
+                labelList.get(6).setText(CommonMessages.bindingName);
+            }
+            else if (element.getText().equals(elementTypes[PORT])) {
+                for (int i = 0; i < maxTextFields; i++) {
+                    labelList.get(i).setVisible(i < 6 ? true : false);
+                    textList.get(i).setVisible(i < 6 ? true : false);
+                    if (clearFields == true) {
+                        textList.get(i).setText("");
+                    }
+                }
+                labelList.get(0).setText(CommonMessages.name);
+                labelList.get(1).setText(CommonMessages.protocol);
+                labelList.get(2).setText(CommonMessages.hostName);
+                labelList.get(3).setText(CommonMessages.portValue);
+                labelList.get(4).setText(CommonMessages.uri);
+                labelList.get(5).setText(CommonMessages.credential);
+            }
+            else if (element.getText().equals(elementTypes[PORT_COMPLETION])) {
+                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.protocol);
+                labelList.get(2).setText(CommonMessages.hostName);
+                labelList.get(3).setText(CommonMessages.portValue);
+                labelList.get(4).setText(CommonMessages.uri);
+                labelList.get(5).setText(CommonMessages.credential);
+                labelList.get(6).setText(CommonMessages.bindingName);
+            }
+        }
+    }
+
+    @Override
+    public void addPages() {
+        addPage(new ServiceRefWizardPage("Page0"));
+    }
+
+    @Override
+    public boolean performFinish() {
+        ServiceRef serviceRef;
+        if (element.getText().equals(elementTypes[SERVICE_REF])) {
+            if (isEmpty(textList.get(0).getText())) {
+                return false;
+            }
+            serviceRef = (ServiceRef)eObject;
+            if (serviceRef == null) {
+                serviceRef = (ServiceRef)getEFactory().create(ServiceRef.class);
+                JAXBElement plan = section.getPlan();
+                JAXBModelUtils.getServiceRefs(plan).add(serviceRef);
+            }
+            serviceRef.setServiceRefName(textList.get(0).getText());
+            if (isEmpty(textList.get(1).getText())) {
+                serviceRef.setServiceCompletion(null);
+            }
+            else {
+                ServiceCompletion serviceComp = serviceRef.getServiceCompletion();
+                if (serviceComp == null) {
+                    serviceComp = (ServiceCompletion)getEFactory().create(ServiceCompletion.class);
+                    serviceRef.setServiceCompletion(serviceComp);
+                }
+                serviceRef.getServiceCompletion().setServiceName(textList.get(1).getText());
+            }
+        }
+        else if (element.getText().equals(elementTypes[PORT])) {
+            if (isEmpty(textList.get(0).getText()) || isEmpty(textList.get(4).getText()))
{
+                return false;
+            }
+            Port port = (Port)eObject;
+            if (port == null) {
+                port = (Port)getEFactory().create(Port.class);
+                serviceRef = ((ServiceRefSection)section).getSelectedServiceRef();
+                serviceRef.getPort().add(port);
+            }
+            port.setPortName(textList.get(0).getText());
+            port.setProtocol(textList.get(1).getText());
+            port.setHost(textList.get(2).getText());
+            port.setPort(Integer.valueOf(textList.get(3).getText()));
+            port.setUri(textList.get(4).getText());
+            port.setCredentialsName(textList.get(5).getText());
+        }
+        else if (element.getText().equals(elementTypes[PORT_COMPLETION])) { 
+            if (isEmpty(textList.get(0).getText()) || isEmpty(textList.get(4).getText())
||
+                isEmpty(textList.get(6).getText())) {
+                return false;
+            }
+            PortCompletion portComp = (PortCompletion)eObject;
+            if (portComp == null) {
+                portComp = (PortCompletion)getEFactory().create(PortCompletion.class);
+                serviceRef = ((ServiceRefSection)section).getSelectedServiceRef();
+                serviceRef.getServiceCompletion().getPortCompletion().add(portComp);
+                Port port = (Port)getEFactory().create(Port.class);
+                portComp.setPort (port);
+            }
+            portComp.getPort().setPortName(textList.get(0).getText());
+            portComp.getPort().setProtocol(textList.get(1).getText());
+            portComp.getPort().setHost(textList.get(2).getText());
+            portComp.getPort().setPort(Integer.valueOf(textList.get(3).getText()));
+            portComp.getPort().setUri(textList.get(4).getText());
+            portComp.getPort().setCredentialsName(textList.get(5).getText());
+            portComp.setBindingName(textList.get(6).getText());
+        }
+        return true;
     }
 
     public JAXBObjectFactory getEFactory() {
         return JAXBObjectFactoryImpl.getInstance();
     }
 
-    public String[] getTableColumnEAttributes() {
-        return new String[] { "ServiceRefName" };
-    }
-
     public String getAddWizardWindowTitle() {
         return CommonMessages.wizardNewTitle_ServiceRef;
     }
@@ -47,11 +233,11 @@
         return CommonMessages.wizardEditTitle_ServiceRef;
     }
 
-    public String getWizardFirstPageTitle() {
+    public String getWizardPageTitle() {
         return CommonMessages.wizardPageTitle_ServiceRef;
     }
 
-    public String getWizardFirstPageDescription() {
+    public String getWizardPageDescription() {
         return CommonMessages.wizardPageDescription_ServiceRef;
     }
 }



Mime
View raw message