geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From de...@apache.org
Subject svn commit: r996559 [4/4] - in /geronimo/devtools/eclipse-plugin/trunk/plugins: org.apache.geronimo.j2ee.v11.jaxbmodel/META-INF/ org.apache.geronimo.runtime.common/ org.apache.geronimo.runtime.common/META-INF/ org.apache.geronimo.st.ui/src/main/java/or...
Date Mon, 13 Sep 2010 14:40:09 GMT
Added: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.ui/src/main/java/org/apache/geronimo/st/v30/ui/sections/blueprint/OtherElementsSection.java
URL: http://svn.apache.org/viewvc/geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.ui/src/main/java/org/apache/geronimo/st/v30/ui/sections/blueprint/OtherElementsSection.java?rev=996559&view=auto
==============================================================================
--- geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.ui/src/main/java/org/apache/geronimo/st/v30/ui/sections/blueprint/OtherElementsSection.java
(added)
+++ geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.ui/src/main/java/org/apache/geronimo/st/v30/ui/sections/blueprint/OtherElementsSection.java
Mon Sep 13 14:40:05 2010
@@ -0,0 +1,160 @@
+package org.apache.geronimo.st.v30.ui.sections.blueprint;
+
+import java.lang.reflect.Field;
+import java.lang.reflect.InvocationTargetException;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.xml.bind.JAXBElement;
+
+import org.apache.geronimo.osgi.blueprint.Tbean;
+import org.apache.geronimo.osgi.blueprint.Tblueprint;
+import org.apache.geronimo.osgi.blueprint.Tcomponent;
+import org.apache.geronimo.osgi.blueprint.Treference;
+import org.apache.geronimo.osgi.blueprint.TreferenceList;
+import org.apache.geronimo.osgi.blueprint.Tservice;
+import org.apache.geronimo.st.ui.internal.Trace;
+import org.apache.geronimo.st.v30.core.jaxb.BlueprintJAXBHelper;
+import org.apache.geronimo.st.v30.ui.CommonMessages;
+import org.apache.geronimo.st.v30.ui.wizards.blueprint.BlueprintElementWizardProxy;
+import org.eclipse.jface.wizard.Wizard;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.ui.forms.widgets.FormToolkit;
+
+public class OtherElementsSection extends AbstractBlueprintTreeSectionPart {
+
+
+    public OtherElementsSection(Composite parent, FormToolkit toolkit, int style,JAXBElement
blueprint) {
+       super(blueprint, parent, toolkit, style);
+       
+       this.objectContainer = getBlueprint().getServiceOrReferenceListOrBean();
+       createClient();
+      
+    }
+    
+    @Override
+    public void createClient(){
+        super.createClient();
+        
+        GridData gridData = new GridData();
+        gridData.horizontalSpan = 2;
+        gridData.horizontalAlignment = GridData.FILL;
+        gridData.verticalAlignment = GridData.FILL;
+        gridData.grabExcessHorizontalSpace=true;
+        gridData.grabExcessVerticalSpace=true;
+        this.getSection().setLayoutData(gridData);
+    }
+
+    @Override
+    public String getTitle() {
+        return CommonMessages.blueprintOtherElementsSection;
+    }
+
+    @Override
+    public String getDescription() {
+        return CommonMessages.blueprintOtherElementsSectionDescription;
+    }
+
+    @Override
+    public Wizard getWizard() {
+        return new BlueprintElementWizardProxy(this).getWizard();
+    }
+
+    @Override
+    public Class getTableEntryObjectType() {
+        //In fact, only Tbean, Treference,Tref are allowed. 
+        //Maybe we can declare a common super classes for these three types
+        return Tcomponent.class;
+    }
+
+    @Override
+    public Object getInput() {
+        if (objectContainer != null) {
+            return objectContainer;
+        }
+        return super.getInput();
+    }
+
+    @Override
+    protected void activateAddButton() {
+        Object object = getSelectedObject();
+        if (!BlueprintJAXBHelper.hasChildElements(object.getClass(),getExcludedFieldsOfClazz(object.getClass())))
{
+            addButton.setEnabled(false);
+        }else{
+            addButton.setEnabled(true);
+        }
+    }
+
+    public Object getSelectedObject() {
+        if (tree.getSelection().length == 0) {
+            return getBlueprint();
+        }
+        Object object;
+        if (tree.getSelection()[0].getParentItem() == null) {
+            object = tree.getSelection()[0].getData();
+        } else {
+            object = tree.getSelection()[0].getParentItem().getData();
+        }
+        if (isSubElements(object)) {
+            return object;
+        } else {
+            return ((JAXBElement) object).getValue();
+        }
+    }
+
+    @Override
+    public void removeItem(Object anItem) {
+        List childList = this.getBlueprint().getServiceOrReferenceListOrBean();
+        if (isSubElements(anItem) && childList.contains(anItem)) {
+            //remove direct children
+            getObjectContainer().remove(anItem);
+            this.getBlueprint().getServiceOrReferenceListOrBean().remove(anItem);
+        } else {            
+            Object object = tree.getSelection()[0].getParentItem().getData();
+            //TODO:detach anItem from object 
+            Field field = treeFieldMap.get(anItem);
+            try {
+                BlueprintJAXBHelper.detachFromParent(object, anItem, field);
+            } catch (IllegalArgumentException e) {
+                Trace.trace(Trace.SEVERE, "can't remove object "+ anItem, e);
+            } catch (IllegalAccessException e) {
+                Trace.trace(Trace.SEVERE, "can't remove object "+ anItem, e);
+            } catch (InvocationTargetException e) {
+                Trace.trace(Trace.SEVERE, "can't remove object "+ anItem, e);
+            }
+        } 
+    }
+
+    
+    
+   
+    
+    private boolean isSubElements(Object object){
+        return Tbean.class.isInstance(object)||TreferenceList.class.isInstance(object)||Treference.class.isInstance(object)||Tservice.class.isInstance(object);
+        
+    }
+
+    @Override
+    protected Object getSectionRootElement() {
+        return  getBlueprint();
+    }
+
+    @Override
+    public List<Field> getExcludedFieldsOfClazz(Class clazz) {
+        if (clazz.equals(Tblueprint.class)){
+            //exclude Tdescription and Ttypeconverters
+            List<Field> excludedList = new ArrayList<Field>();
+            try {
+                excludedList.add(getBlueprint().getClass().getDeclaredField("description"));
+                excludedList.add(getBlueprint().getClass().getDeclaredField("typeConverters"));
+            } catch (SecurityException e) {
+                Trace.trace(Trace.SEVERE, "Can't find field! ", e);
+            } catch (NoSuchFieldException e) {
+                Trace.trace(Trace.SEVERE, "Can't find field! ", e);
+            }
+            return excludedList;
+        }
+        return null;
+    }
+}

Added: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.ui/src/main/java/org/apache/geronimo/st/v30/ui/sections/blueprint/TypeConverterSection.java
URL: http://svn.apache.org/viewvc/geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.ui/src/main/java/org/apache/geronimo/st/v30/ui/sections/blueprint/TypeConverterSection.java?rev=996559&view=auto
==============================================================================
--- geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.ui/src/main/java/org/apache/geronimo/st/v30/ui/sections/blueprint/TypeConverterSection.java
(added)
+++ geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.ui/src/main/java/org/apache/geronimo/st/v30/ui/sections/blueprint/TypeConverterSection.java
Mon Sep 13 14:40:05 2010
@@ -0,0 +1,168 @@
+/*
+ * 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.v30.ui.sections.blueprint;
+
+import java.lang.reflect.Field;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.xml.bind.JAXBElement;
+
+import org.apache.geronimo.osgi.blueprint.Targument;
+import org.apache.geronimo.osgi.blueprint.Tbean;
+import org.apache.geronimo.osgi.blueprint.Tcomponent;
+import org.apache.geronimo.osgi.blueprint.Tproperty;
+import org.apache.geronimo.osgi.blueprint.Tref;
+import org.apache.geronimo.osgi.blueprint.Treference;
+import org.apache.geronimo.osgi.blueprint.TtypeConverters;
+import org.apache.geronimo.st.v30.core.jaxb.BlueprintJAXBHelper;
+import org.apache.geronimo.st.v30.ui.BlueprintEditorUIHelper;
+import org.apache.geronimo.st.v30.ui.CommonMessages;
+import org.apache.geronimo.st.v30.ui.wizards.blueprint.BlueprintElementWizardProxy;
+import org.eclipse.jface.wizard.Wizard;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.ui.forms.widgets.FormToolkit;
+
+/**
+ * @version $Rev: 939152 $ $Date: 2010-04-29 08:57:12 +0800 (Thu, 29 Apr 2010) $
+ */
+public class TypeConverterSection extends AbstractBlueprintTreeSectionPart{
+    
+    private  TtypeConverters typeConverters;
+
+    public TypeConverterSection(Composite parent, FormToolkit toolkit, int style,JAXBElement
blueprint) {
+       super(blueprint, parent, toolkit, style);
+       typeConverters = getBlueprint().getTypeConverters();
+       
+       if (typeConverters!=null)
+           this.objectContainer = typeConverters.getBeanOrReferenceOrRef();
+       else {
+           typeConverters = BlueprintEditorUIHelper.getBlueprintObjectFactory().createTtypeConverters();
+           getBlueprint().setTypeConverters(typeConverters);
+           this.objectContainer = new ArrayList();
+       }
+       createClient();
+      
+    }
+    
+    @Override
+    public void createClient(){
+        super.createClient();
+        
+        GridData gridData = new GridData();
+        gridData.horizontalSpan = 2;
+        gridData.horizontalAlignment = GridData.FILL;
+        gridData.verticalAlignment = GridData.FILL;
+        gridData.grabExcessHorizontalSpace=true;
+        gridData.grabExcessVerticalSpace=true;        
+        this.getSection().setLayoutData(gridData);
+    }
+
+    @Override
+    public String getTitle() {
+        return CommonMessages.blueprintTypeConverterSectionTitle;
+    }
+
+    @Override
+    public String getDescription() {
+        return CommonMessages.blueprintTypeConverterSectionDescription;
+    }
+
+    @Override
+    public Wizard getWizard() {
+        return new BlueprintElementWizardProxy(this).getWizard();
+    }
+
+    @Override
+    public Class getTableEntryObjectType() {
+        //In fact, only Tbean, Treference,Tref are allowed. 
+        //Maybe we can declare a common super classes for these three types
+        return Tcomponent.class;
+    }
+
+    @Override
+    public Object getInput() {
+        if (objectContainer != null) {
+            return objectContainer;
+        }
+        return super.getInput();
+    }
+
+    @Override
+    protected void activateAddButton() {
+        Object object = getSelectedObject();
+        if (!BlueprintJAXBHelper.hasChildElements(object.getClass(),getExcludedFieldsOfClazz(object.getClass())))
{
+            addButton.setEnabled(false);
+        }else{
+            addButton.setEnabled(true);
+        }
+    }
+
+    public Object getSelectedObject() {
+        if (tree.getSelection().length == 0) {
+            return typeConverters;
+        }
+        Object object;
+        if (tree.getSelection()[0].getParentItem() == null) {
+            object = tree.getSelection()[0].getData();
+        } else {
+            object = tree.getSelection()[0].getParentItem().getData();
+        }
+        if (isBeanOrReferenceOrRef(object)) {
+            return object;
+        } else {
+            return ((JAXBElement) object).getValue();
+        }
+    }
+
+    @Override
+    public void removeItem(Object anItem) {
+        List childList = this.getBlueprint().getTypeConverters().getBeanOrReferenceOrRef();
+        if (isBeanOrReferenceOrRef(anItem) && childList.contains(anItem)) {
+            getObjectContainer().remove(anItem);
+            this.getBlueprint().getTypeConverters().getBeanOrReferenceOrRef().remove(anItem);
+        } else if (Targument.class.isInstance(anItem) || Tproperty.class.isInstance(anItem))
{            
+            Object object = tree.getSelection()[0].getParentItem().getData();
+            //it must be Tbean 
+            Tbean bean = (Tbean)object;
+            bean.getArgumentOrPropertyOrAny().remove(anItem);          
+        } 
+    }
+
+    
+    
+   
+    
+    private boolean isBeanOrReferenceOrRef(Object object){
+        return Tbean.class.isInstance(object)||Treference.class.isInstance(object)||Tref.class.isInstance(object);
+        
+    }
+
+    @Override
+    protected Object getSectionRootElement() {
+        return  typeConverters;
+    }
+
+    @Override
+    public List<Field> getExcludedFieldsOfClazz(Class clazz) {
+        return null;
+    }
+
+
+  
+}

Modified: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.ui/src/main/java/org/apache/geronimo/st/v30/ui/wizards/AdminObjectWizard.java
URL: http://svn.apache.org/viewvc/geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.ui/src/main/java/org/apache/geronimo/st/v30/ui/wizards/AdminObjectWizard.java?rev=996559&r1=996558&r2=996559&view=diff
==============================================================================
--- geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.ui/src/main/java/org/apache/geronimo/st/v30/ui/wizards/AdminObjectWizard.java
(original)
+++ geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.ui/src/main/java/org/apache/geronimo/st/v30/ui/wizards/AdminObjectWizard.java
Mon Sep 13 14:40:05 2010
@@ -25,7 +25,6 @@ import org.apache.geronimo.st.v30.core.j
 import org.apache.geronimo.st.v30.core.jaxb.JAXBObjectFactoryImpl;
 import org.apache.geronimo.st.v30.ui.CommonMessages;
 import org.apache.geronimo.st.v30.ui.sections.AbstractTreeSection;
-import org.apache.geronimo.st.v30.ui.wizards.AbstractTreeWizard;
 import org.apache.geronimo.st.v30.ui.sections.AdminObjectSection;
 
 /**

Modified: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.ui/src/main/java/org/apache/geronimo/st/v30/ui/wizards/ClassFilterWizard.java
URL: http://svn.apache.org/viewvc/geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.ui/src/main/java/org/apache/geronimo/st/v30/ui/wizards/ClassFilterWizard.java?rev=996559&r1=996558&r2=996559&view=diff
==============================================================================
--- geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.ui/src/main/java/org/apache/geronimo/st/v30/ui/wizards/ClassFilterWizard.java
(original)
+++ geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.ui/src/main/java/org/apache/geronimo/st/v30/ui/wizards/ClassFilterWizard.java
Mon Sep 13 14:40:05 2010
@@ -82,7 +82,7 @@ public class ClassFilterWizard extends A
 
         if (eObject == null) {
             eObject = new String();
-            JAXBElement plan = section.getPlan();
+            JAXBElement plan = section.getRootElement();
 
             Environment environment = null;
             environment = JAXBModelUtils.getEnvironment(plan, isServerEnvironment);

Modified: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.ui/src/main/java/org/apache/geronimo/st/v30/ui/wizards/DBPoolWizard.java
URL: http://svn.apache.org/viewvc/geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.ui/src/main/java/org/apache/geronimo/st/v30/ui/wizards/DBPoolWizard.java?rev=996559&r1=996558&r2=996559&view=diff
==============================================================================
--- geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.ui/src/main/java/org/apache/geronimo/st/v30/ui/wizards/DBPoolWizard.java
(original)
+++ geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.ui/src/main/java/org/apache/geronimo/st/v30/ui/wizards/DBPoolWizard.java
Mon Sep 13 14:40:05 2010
@@ -121,7 +121,7 @@ public class DBPoolWizard extends Abstra
     }
 
     public boolean performFinish() {
-    JAXBElement plan = this.section.getPlan();
+    JAXBElement plan = this.section.getRootElement();
 
     // all pages
     ExternalPathPage page0 = (ExternalPathPage) getPages()[0];
@@ -251,7 +251,7 @@ public class DBPoolWizard extends Abstra
         outboundAdpater.getConnectionDefinition().add(definition);
         adapter.setOutboundResourceadapter(outboundAdpater);
 
-        if (section.getViewer().getInput() == section.getPlan()) {
+        if (section.getViewer().getInput() == section.getRootElement()) {
         section.getViewer().setInput(section.getInput());
         }
         return true;

Modified: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.ui/src/main/java/org/apache/geronimo/st/v30/ui/wizards/EjbRelationWizard.java
URL: http://svn.apache.org/viewvc/geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.ui/src/main/java/org/apache/geronimo/st/v30/ui/wizards/EjbRelationWizard.java?rev=996559&r1=996558&r2=996559&view=diff
==============================================================================
--- geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.ui/src/main/java/org/apache/geronimo/st/v30/ui/wizards/EjbRelationWizard.java
(original)
+++ geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.ui/src/main/java/org/apache/geronimo/st/v30/ui/wizards/EjbRelationWizard.java
Mon Sep 13 14:40:05 2010
@@ -150,7 +150,7 @@ public class EjbRelationWizard extends A
             relation = (EjbRelation)eObject;
             if (relation == null) {
                 relation = (EjbRelation)getEFactory().create(EjbRelation.class);
-                JAXBElement plan = section.getPlan();
+                JAXBElement plan = section.getRootElement();
                 
                 if (JAXBModelUtils.getEjbRelationships(plan) == null) {
                     Relationships relationships = (Relationships)getEFactory().create(Relationships.class);

Modified: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.ui/src/main/java/org/apache/geronimo/st/v30/ui/wizards/ExtModuleWizard.java
URL: http://svn.apache.org/viewvc/geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.ui/src/main/java/org/apache/geronimo/st/v30/ui/wizards/ExtModuleWizard.java?rev=996559&r1=996558&r2=996559&view=diff
==============================================================================
--- geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.ui/src/main/java/org/apache/geronimo/st/v30/ui/wizards/ExtModuleWizard.java
(original)
+++ geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.ui/src/main/java/org/apache/geronimo/st/v30/ui/wizards/ExtModuleWizard.java
Mon Sep 13 14:40:05 2010
@@ -276,7 +276,7 @@ public class ExtModuleWizard extends Abs
 
         if (eObject == null) {
             eObject = getEFactory().create(ExtModule.class);
-            JAXBElement plan = section.getPlan();
+            JAXBElement plan = section.getRootElement();
             extModule = (ExtModule)eObject;
             //This is the extModule field in plan(Application Type)
             List<ExtModule> extModuleList = ((Application)plan.getValue()).getExtModule();
@@ -323,7 +323,7 @@ public class ExtModuleWizard extends Abs
             extModule.setInternalPath(null);
         }
 
-        if (section.getViewer().getInput() == section.getPlan()) {
+        if (section.getViewer().getInput() == section.getRootElement()) {
             section.getViewer().setInput(section.getInput());
         }
 

Modified: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.ui/src/main/java/org/apache/geronimo/st/v30/ui/wizards/GBeanRefWizard.java
URL: http://svn.apache.org/viewvc/geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.ui/src/main/java/org/apache/geronimo/st/v30/ui/wizards/GBeanRefWizard.java?rev=996559&r1=996558&r2=996559&view=diff
==============================================================================
--- geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.ui/src/main/java/org/apache/geronimo/st/v30/ui/wizards/GBeanRefWizard.java
(original)
+++ geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.ui/src/main/java/org/apache/geronimo/st/v30/ui/wizards/GBeanRefWizard.java
Mon Sep 13 14:40:05 2010
@@ -151,7 +151,7 @@ public class GBeanRefWizard extends Abst
             gbeanRef = (GbeanRef)eObject;
             if (gbeanRef == null) {
                 gbeanRef = (GbeanRef)getEFactory().create(GbeanRef.class);
-                JAXBElement plan = section.getPlan();
+                JAXBElement plan = section.getRootElement();
 
                 // if we have a WebApp, add the JAXBElement of the GBeanRef, not the GBeanRef
                 if (WebApp.class.isInstance(plan.getValue())) {

Modified: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.ui/src/main/java/org/apache/geronimo/st/v30/ui/wizards/GBeanWizard.java
URL: http://svn.apache.org/viewvc/geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.ui/src/main/java/org/apache/geronimo/st/v30/ui/wizards/GBeanWizard.java?rev=996559&r1=996558&r2=996559&view=diff
==============================================================================
--- geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.ui/src/main/java/org/apache/geronimo/st/v30/ui/wizards/GBeanWizard.java
(original)
+++ geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.ui/src/main/java/org/apache/geronimo/st/v30/ui/wizards/GBeanWizard.java
Mon Sep 13 14:40:05 2010
@@ -190,7 +190,7 @@ public class GBeanWizard extends Abstrac
             gbean = (Gbean)eObject;
             if (gbean == null) {
                 gbean = (Gbean)getEFactory().create(Gbean.class);
-                JAXBElement plan = section.getPlan();
+                JAXBElement plan = section.getRootElement();
                 
                 // add the JAXBElement of a GBean, not the GBean
                 ObjectFactory objectFactory = new ObjectFactory();

Modified: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.ui/src/main/java/org/apache/geronimo/st/v30/ui/wizards/MessageDestWizard.java
URL: http://svn.apache.org/viewvc/geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.ui/src/main/java/org/apache/geronimo/st/v30/ui/wizards/MessageDestWizard.java?rev=996559&r1=996558&r2=996559&view=diff
==============================================================================
--- geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.ui/src/main/java/org/apache/geronimo/st/v30/ui/wizards/MessageDestWizard.java
(original)
+++ geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.ui/src/main/java/org/apache/geronimo/st/v30/ui/wizards/MessageDestWizard.java
Mon Sep 13 14:40:05 2010
@@ -148,7 +148,7 @@ public class MessageDestWizard extends A
 
         if (eObject == null) {
             eObject = getEFactory().create(MessageDestination.class);
-            JAXBElement plan = section.getPlan();
+            JAXBElement plan = section.getRootElement();
 
             messageDest = (MessageDestination)eObject;
             msgPattern = (Pattern)getEFactory().create(Pattern.class);
@@ -181,7 +181,7 @@ public class MessageDestWizard extends A
                 }
         }
         
-        if (section.getViewer().getInput() == section.getPlan()) {
+        if (section.getViewer().getInput() == section.getRootElement()) {
             section.getViewer().setInput(section.getInput());
         }
 

Modified: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.ui/src/main/java/org/apache/geronimo/st/v30/ui/wizards/ModuleWizard.java
URL: http://svn.apache.org/viewvc/geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.ui/src/main/java/org/apache/geronimo/st/v30/ui/wizards/ModuleWizard.java?rev=996559&r1=996558&r2=996559&view=diff
==============================================================================
--- geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.ui/src/main/java/org/apache/geronimo/st/v30/ui/wizards/ModuleWizard.java
(original)
+++ geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.ui/src/main/java/org/apache/geronimo/st/v30/ui/wizards/ModuleWizard.java
Mon Sep 13 14:40:05 2010
@@ -171,7 +171,7 @@ public class ModuleWizard extends Abstra
 
         if (eObject == null) {
             eObject = getEFactory().create(Module.class);
-            JAXBElement plan = section.getPlan();
+            JAXBElement plan = section.getRootElement();
 
             module = (Module)eObject;
 
@@ -207,7 +207,7 @@ public class ModuleWizard extends Abstra
         path.setValue(altDD);
         module.setAltDd(path);
         
-        if (section.getViewer().getInput() == section.getPlan()) {
+        if (section.getViewer().getInput() == section.getRootElement()) {
             section.getViewer().setInput(section.getInput());
         }
 

Modified: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.ui/src/main/java/org/apache/geronimo/st/v30/ui/wizards/PersContextRefWizard.java
URL: http://svn.apache.org/viewvc/geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.ui/src/main/java/org/apache/geronimo/st/v30/ui/wizards/PersContextRefWizard.java?rev=996559&r1=996558&r2=996559&view=diff
==============================================================================
--- geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.ui/src/main/java/org/apache/geronimo/st/v30/ui/wizards/PersContextRefWizard.java
(original)
+++ geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.ui/src/main/java/org/apache/geronimo/st/v30/ui/wizards/PersContextRefWizard.java
Mon Sep 13 14:40:05 2010
@@ -224,7 +224,7 @@ public class PersContextRefWizard extend
             ObjectFactory objectFactory = new ObjectFactory();
             if (contextRef == null) {
                 contextRef = (PersistenceContextRef)getEFactory().create(PersistenceContextRef.class);
-                JAXBElement plan = section.getPlan();
+                JAXBElement plan = section.getRootElement();
 
                 // add the JAXBElement of the PersistenceContextRef
                 JAXBModelUtils.getGbeanRefs(plan).add(objectFactory.createPersistenceContextRef(contextRef));

Modified: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.ui/src/main/java/org/apache/geronimo/st/v30/ui/wizards/PersUnitRefWizard.java
URL: http://svn.apache.org/viewvc/geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.ui/src/main/java/org/apache/geronimo/st/v30/ui/wizards/PersUnitRefWizard.java?rev=996559&r1=996558&r2=996559&view=diff
==============================================================================
--- geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.ui/src/main/java/org/apache/geronimo/st/v30/ui/wizards/PersUnitRefWizard.java
(original)
+++ geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.ui/src/main/java/org/apache/geronimo/st/v30/ui/wizards/PersUnitRefWizard.java
Mon Sep 13 14:40:05 2010
@@ -166,7 +166,7 @@ public class PersUnitRefWizard extends A
         ObjectFactory objectFactory = new ObjectFactory();
         if (unitRef == null) {
             unitRef = (PersistenceUnitRef)getEFactory().create(PersistenceUnitRef.class);
-            JAXBElement plan = section.getPlan();
+            JAXBElement plan = section.getRootElement();
 
             // add the JAXBElement of the PersistenceContextRef
             JAXBModelUtils.getGbeanRefs(plan).add(objectFactory.createPersistenceUnitRef(unitRef));

Modified: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.ui/src/main/java/org/apache/geronimo/st/v30/ui/wizards/SecurityRealmWizard.java
URL: http://svn.apache.org/viewvc/geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.ui/src/main/java/org/apache/geronimo/st/v30/ui/wizards/SecurityRealmWizard.java?rev=996559&r1=996558&r2=996559&view=diff
==============================================================================
--- geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.ui/src/main/java/org/apache/geronimo/st/v30/ui/wizards/SecurityRealmWizard.java
(original)
+++ geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.ui/src/main/java/org/apache/geronimo/st/v30/ui/wizards/SecurityRealmWizard.java
Mon Sep 13 14:40:05 2010
@@ -129,7 +129,7 @@ public class SecurityRealmWizard extends
 
     public boolean performFinish() {
     boolean isedit = false;
-    JAXBElement<?> plan = this.section.getPlan();
+    JAXBElement<?> plan = this.section.getRootElement();
     ObjectFactory objectFactory = new ObjectFactory();
     // all pages
     SecurityRealmBasicPage page0 = (SecurityRealmBasicPage) this

Modified: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.ui/src/main/java/org/apache/geronimo/st/v30/ui/wizards/ServiceRefWizard.java
URL: http://svn.apache.org/viewvc/geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.ui/src/main/java/org/apache/geronimo/st/v30/ui/wizards/ServiceRefWizard.java?rev=996559&r1=996558&r2=996559&view=diff
==============================================================================
--- geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.ui/src/main/java/org/apache/geronimo/st/v30/ui/wizards/ServiceRefWizard.java
(original)
+++ geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.ui/src/main/java/org/apache/geronimo/st/v30/ui/wizards/ServiceRefWizard.java
Mon Sep 13 14:40:05 2010
@@ -171,7 +171,7 @@ public class ServiceRefWizard extends Ab
             serviceRef = (ServiceRef)eObject;
             if (serviceRef == null) {
                 serviceRef = (ServiceRef)getEFactory().create(ServiceRef.class);
-                JAXBElement plan = section.getPlan();
+                JAXBElement plan = section.getRootElement();
                 JAXBModelUtils.getServiceRefs(plan).add(serviceRef);
             }
             serviceRef.setServiceRefName(textList.get(0).getText());

Added: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.ui/src/main/java/org/apache/geronimo/st/v30/ui/wizards/blueprint/BlueprintElementWizardProxy.java
URL: http://svn.apache.org/viewvc/geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.ui/src/main/java/org/apache/geronimo/st/v30/ui/wizards/blueprint/BlueprintElementWizardProxy.java?rev=996559&view=auto
==============================================================================
--- geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.ui/src/main/java/org/apache/geronimo/st/v30/ui/wizards/blueprint/BlueprintElementWizardProxy.java
(added)
+++ geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.ui/src/main/java/org/apache/geronimo/st/v30/ui/wizards/blueprint/BlueprintElementWizardProxy.java
Mon Sep 13 14:40:05 2010
@@ -0,0 +1,245 @@
+package org.apache.geronimo.st.v30.ui.wizards.blueprint;
+
+import java.lang.reflect.Field;
+import java.lang.reflect.InvocationTargetException;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+
+import javax.xml.bind.annotation.XmlAttribute;
+import javax.xml.bind.annotation.XmlRootElement;
+
+import org.apache.geronimo.st.ui.internal.Trace;
+import org.apache.geronimo.st.v30.core.jaxb.BlueprintJAXBHelper;
+import org.apache.geronimo.st.v30.core.jaxb.BlueprintJAXBHelper.SubClazzWrapper;
+import org.apache.geronimo.st.v30.ui.sections.blueprint.AbstractBlueprintTreeSectionPart;
+import org.apache.geronimo.st.v30.ui.wizards.AbstractTreeWizard;
+import org.eclipse.jface.wizard.Wizard;
+import org.eclipse.swt.widgets.Text;
+
+public class BlueprintElementWizardProxy{
+    
+    private AbstractTreeWizard wizard ;
+    
+    private Object parentElement;
+    
+    private SubClazzWrapper childElementClazz;  
+    
+    private List<SubClazzWrapper> childrenClazz;
+    
+    private AbstractBlueprintTreeSectionPart section;
+   
+         
+    private class BlueprintWizard extends AbstractTreeWizard{
+        
+        
+        private class BlueprintWizardPage extends AbstractTreeWizardPage{
+
+            public BlueprintWizardPage(AbstractTreeWizard abstractTreeWizard, String pageName)
{
+                abstractTreeWizard.super(pageName);
+                
+                //init combo
+                
+                Iterator<SubClazzWrapper> iter = childrenClazz.iterator();
+                int count = 0;
+                while(iter.hasNext()){
+                    SubClazzWrapper wrapper = iter.next();
+                    Class clazz = wrapper.getClazz();
+                    XmlRootElement element = (XmlRootElement) clazz.getAnnotation(javax.xml.bind.annotation.XmlRootElement.class);
+                    elementTypes[count++]=element.name();
+                }
+            }
+
+            @Override
+            protected void initControl() {
+                if (eObject!=null){
+                    //it's edit mode
+                    XmlRootElement rootElement = (XmlRootElement) eObject.getClass().getAnnotation(javax.xml.bind.annotation.XmlRootElement.class);
+                    element.setItem(0, rootElement.name());
+                    element.select(0);
+                    element.setEnabled(false);
+                    childElementClazz = new SubClazzWrapper(eObject.getClass(),null);
+                    
+                    //set value for text field
+                    try {
+                        HashMap<String,String> attrMap = BlueprintJAXBHelper.getAllAttributes(eObject);
+                        Collection<String> values = attrMap.values();
+                        
+                        int count =0;
+                        Iterator<String> iter = values.iterator();
+                        while (iter.hasNext()){
+                            String value = iter.next();
+                            if (count<textList.size()){ 
+                                Text text = textList.get(count);
+                                text.setText(value);
+                            }else {
+                                //there must be an error
+                                break;
+                            }
+                            count++;
+                        }
+                    } catch (SecurityException e) {
+                        Trace.trace(Trace.SEVERE, "get child elements error! ", e);
+                    } catch (IllegalArgumentException e) {
+                        Trace.trace(Trace.SEVERE, "get child elements error! ", e);
+                    } catch (NoSuchMethodException e) {
+                        Trace.trace(Trace.SEVERE, "get child elements error! ", e);
+                    } catch (IllegalAccessException e) {
+                        Trace.trace(Trace.SEVERE, "get child elements error! ", e);
+                    } catch (InvocationTargetException e) {
+                        Trace.trace(Trace.SEVERE, "get child elements error! ", e);
+                    }
+                    
+                }else{
+                    //it's add mode
+                    element.select(0);
+                    element.setEnabled(true);
+                }
+                
+            }
+            
+           
+
+            @Override
+            protected void toggleFields(boolean clearFields) {
+                if (element.isEnabled()) {
+                    int index = element.getSelectionIndex();
+                    childElementClazz = childrenClazz.get(index);
+                }
+                
+                List<Field> attrList = BlueprintJAXBHelper.getAllAttributeFields(childElementClazz.getClazz());
+                
+                Iterator<Field> iter = attrList.iterator();
+                int count = 0;
+                while (iter.hasNext()){
+                    Field attr = iter.next();
+                    XmlAttribute attrAnnotation = attr.getAnnotation(javax.xml.bind.annotation.XmlAttribute.class);
+                    String attrName = attrAnnotation.name();
+                    if (attrName.contains("#")) {
+                        //name property is not set in the annotation
+                        attrName = attr.getName();
+                    }
+                    labelList.get(count).setText(attrName);
+                    labelList.get(count).setVisible(true);
+                    textList.get(count).setVisible(true);
+                    if (clearFields) textList.get(count).setText("");
+                    count++;
+                }
+                
+                for (int i=count;i<labelList.size();i++){
+                    labelList.get(i).setVisible(false);
+                    textList.get(i).setVisible(false);
+                }
+                
+            }
+
+            @Override
+            protected String getWizardPageTitle() {
+                return "Blueprint Configuration";
+            }
+
+            @Override
+            protected String getWizardPageDescription() {
+                return "Add or Edit elements in blueprint schema";
+            }
+            
+            public HashMap<Field,String> getResult(){
+              //init attribute map
+                HashMap<Field,String> attrMap = new HashMap<Field,String>();
+                
+                List<Field> attrList = BlueprintJAXBHelper.getAllAttributeFields(childElementClazz.getClazz());
+                Iterator<Text> iter = textList.iterator();
+                int count=0;
+                while (iter.hasNext()){
+                    Text text = iter.next();
+                    String value = text.getText();
+                    if (text.isVisible()&&value!=null&&!value.isEmpty())
{
+                        Field attrField = attrList.get(count);
+                        attrMap.put(attrField, value);
+                    }
+                    count++;
+                }
+                
+                return attrMap;
+            }
+            
+        }
+        
+        private BlueprintWizardPage page;
+        
+        public BlueprintWizard(int maxTextField){
+            super(BlueprintElementWizardProxy.this.section,childrenClazz.size(),maxTextField);
+           
+        }
+        
+        @Override
+        public void addPages() {
+            page = new BlueprintWizardPage(wizard, parentElement.getClass().getSimpleName());
+            addPage(page);
+        }
+
+        @Override
+        protected String getAddWizardWindowTitle() {
+            return "Blueprint Editor - Adding";
+        }
+
+        @Override
+        protected String getEditWizardWindowTitle() {
+            return "Blueprint Editor - Editing";
+        }
+
+        @Override
+        public boolean performFinish() {
+            HashMap<Field,String> attrMap = page.getResult();
+            
+            if (element.isEnabled()){
+                //add mode
+                BlueprintElementWizardProxy.this.section.setNewObjectValue(parentElement,childElementClazz,
attrMap);                
+            }else{
+                //edit mode
+                BlueprintElementWizardProxy.this.section.setObjectValue(section.getSelectedObject(),
attrMap);
+            }
+            
+            return true;
+        }
+        
+    }
+    
+
+    public BlueprintElementWizardProxy(AbstractBlueprintTreeSectionPart  blueprintSection)
{
+        section = blueprintSection;
+        
+        parentElement= blueprintSection.getParentElement();
+        
+        childrenClazz = BlueprintJAXBHelper.getAllSubTypes(parentElement.getClass(),blueprintSection.getExcludedFieldsOfClazz(parentElement.getClass()));
+        
+        //init attribute map
+        Iterator<SubClazzWrapper> iter = childrenClazz.iterator();
+        int maxTextField = 0;
+        while (iter.hasNext()){
+            SubClazzWrapper wrapper = (SubClazzWrapper)iter.next();
+            Class clazz = wrapper.getClazz();
+            List<Field> attributeFields = BlueprintJAXBHelper.getAllAttributeFields(clazz);
+            if (maxTextField < attributeFields.size()) maxTextField = attributeFields.size();
+        }
+        
+        initWizard(maxTextField);
+    }
+    
+    
+
+    private void initWizard(int maxTextField) {
+        
+        wizard = new BlueprintWizard(maxTextField);
+        
+        
+    }
+    
+    public Wizard getWizard(){
+        return wizard;
+    }
+
+    
+}



Mime
View raw message