You are viewing a plain text version of this content. The canonical link for it is here.
Posted to scm@geronimo.apache.org by sp...@apache.org on 2005/10/03 15:36:37 UTC

svn commit: r293346 - in /geronimo/devtools/trunk/modules/eclipse-plugin/plugins/org.apache.geronimo.ui/src/org/apache/geronimo/ui: pages/ sections/

Author: sppatel
Date: Mon Oct  3 06:36:33 2005
New Revision: 293346

URL: http://svn.apache.org/viewcvs?rev=293346&view=rev
Log:
- abstract out common code for configID and parentID
- add openejbjar and connector general section

Added:
    geronimo/devtools/trunk/modules/eclipse-plugin/plugins/org.apache.geronimo.ui/src/org/apache/geronimo/ui/sections/AbstractSectionPart.java
    geronimo/devtools/trunk/modules/eclipse-plugin/plugins/org.apache.geronimo.ui/src/org/apache/geronimo/ui/sections/CommonGeneralSection.java
    geronimo/devtools/trunk/modules/eclipse-plugin/plugins/org.apache.geronimo.ui/src/org/apache/geronimo/ui/sections/ConnectorGeneralSection.java
    geronimo/devtools/trunk/modules/eclipse-plugin/plugins/org.apache.geronimo.ui/src/org/apache/geronimo/ui/sections/OpenEjbJarGeneralSection.java
Modified:
    geronimo/devtools/trunk/modules/eclipse-plugin/plugins/org.apache.geronimo.ui/src/org/apache/geronimo/ui/pages/AppGeneralPage.java
    geronimo/devtools/trunk/modules/eclipse-plugin/plugins/org.apache.geronimo.ui/src/org/apache/geronimo/ui/pages/WebGeneralPage.java
    geronimo/devtools/trunk/modules/eclipse-plugin/plugins/org.apache.geronimo.ui/src/org/apache/geronimo/ui/sections/AppGeneralSection.java
    geronimo/devtools/trunk/modules/eclipse-plugin/plugins/org.apache.geronimo.ui/src/org/apache/geronimo/ui/sections/WebGeneralSection.java

Modified: geronimo/devtools/trunk/modules/eclipse-plugin/plugins/org.apache.geronimo.ui/src/org/apache/geronimo/ui/pages/AppGeneralPage.java
URL: http://svn.apache.org/viewcvs/geronimo/devtools/trunk/modules/eclipse-plugin/plugins/org.apache.geronimo.ui/src/org/apache/geronimo/ui/pages/AppGeneralPage.java?rev=293346&r1=293345&r2=293346&view=diff
==============================================================================
--- geronimo/devtools/trunk/modules/eclipse-plugin/plugins/org.apache.geronimo.ui/src/org/apache/geronimo/ui/pages/AppGeneralPage.java (original)
+++ geronimo/devtools/trunk/modules/eclipse-plugin/plugins/org.apache.geronimo.ui/src/org/apache/geronimo/ui/pages/AppGeneralPage.java Mon Oct  3 06:36:33 2005
@@ -63,11 +63,11 @@
         form.setText(getTitle());
         form.getBody().setLayout(new GridLayout());
 
-        AppGeneralSection sec = new AppGeneralSection(plan, form.getBody(),
+        AppGeneralSection sec = new AppGeneralSection(form.getBody(),
                 managedForm.getToolkit(), ExpandableComposite.TWISTIE
                         | ExpandableComposite.EXPANDED
                         | ExpandableComposite.TITLE_BAR | Section.DESCRIPTION
-                        | ExpandableComposite.FOCUS_TITLE);
+                        | ExpandableComposite.FOCUS_TITLE, plan);
         managedForm.addPart(sec);
 
         form.reflow(true);

Modified: geronimo/devtools/trunk/modules/eclipse-plugin/plugins/org.apache.geronimo.ui/src/org/apache/geronimo/ui/pages/WebGeneralPage.java
URL: http://svn.apache.org/viewcvs/geronimo/devtools/trunk/modules/eclipse-plugin/plugins/org.apache.geronimo.ui/src/org/apache/geronimo/ui/pages/WebGeneralPage.java?rev=293346&r1=293345&r2=293346&view=diff
==============================================================================
--- geronimo/devtools/trunk/modules/eclipse-plugin/plugins/org.apache.geronimo.ui/src/org/apache/geronimo/ui/pages/WebGeneralPage.java (original)
+++ geronimo/devtools/trunk/modules/eclipse-plugin/plugins/org.apache.geronimo.ui/src/org/apache/geronimo/ui/pages/WebGeneralPage.java Mon Oct  3 06:36:33 2005
@@ -43,18 +43,19 @@
      */
     protected void createFormContent(IManagedForm managedForm) {
 
-        WebAppType plan = (WebAppType) ((WebEditor) getEditor()).getDeploymentPlan();
+        WebAppType plan = (WebAppType) ((WebEditor) getEditor())
+                .getDeploymentPlan();
 
         ScrolledForm form = managedForm.getForm();
         form.setText(getTitle());
         form.getBody().setLayout(new GridLayout());
 
         // create web plan general section
-        WebGeneralSection sec = new WebGeneralSection(plan, form.getBody(),
+        WebGeneralSection sec = new WebGeneralSection(form.getBody(),
                 managedForm.getToolkit(), ExpandableComposite.TWISTIE
                         | ExpandableComposite.EXPANDED
                         | ExpandableComposite.TITLE_BAR | Section.DESCRIPTION
-                        | ExpandableComposite.FOCUS_TITLE);
+                        | ExpandableComposite.FOCUS_TITLE, plan);
         managedForm.addPart(sec);
 
         form.reflow(true);

Added: geronimo/devtools/trunk/modules/eclipse-plugin/plugins/org.apache.geronimo.ui/src/org/apache/geronimo/ui/sections/AbstractSectionPart.java
URL: http://svn.apache.org/viewcvs/geronimo/devtools/trunk/modules/eclipse-plugin/plugins/org.apache.geronimo.ui/src/org/apache/geronimo/ui/sections/AbstractSectionPart.java?rev=293346&view=auto
==============================================================================
--- geronimo/devtools/trunk/modules/eclipse-plugin/plugins/org.apache.geronimo.ui/src/org/apache/geronimo/ui/sections/AbstractSectionPart.java (added)
+++ geronimo/devtools/trunk/modules/eclipse-plugin/plugins/org.apache.geronimo.ui/src/org/apache/geronimo/ui/sections/AbstractSectionPart.java Mon Oct  3 06:36:33 2005
@@ -0,0 +1,57 @@
+/**
+ * Copyright 2004, 2005 The Apache Software Foundation or its licensors, as applicable
+ *
+ *  Licensed 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.ui.sections;
+
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.ui.forms.SectionPart;
+import org.eclipse.ui.forms.widgets.FormToolkit;
+import org.eclipse.ui.forms.widgets.Section;
+
+public abstract class AbstractSectionPart extends SectionPart {
+
+    /**
+     * @param section
+     */
+    public AbstractSectionPart(Section section) {
+        super(section);
+    }
+
+    /**
+     * @param parent
+     * @param toolkit
+     * @param style
+     */
+    public AbstractSectionPart(Composite parent, FormToolkit toolkit, int style) {
+        super(parent, toolkit, style);
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see org.eclipse.ui.forms.IFormPart#commit(boolean)
+     * 
+     * Overriding this method as a workaround as switching tabs on a dirty
+     * editor commits the page and marks the part as not dirty.
+     */
+    public void commit(boolean onSave) {
+        boolean currentDirtyState = isDirty();
+        super.commit(onSave);
+        if (!onSave && currentDirtyState) {
+            markDirty();
+        }
+    }
+
+}

Modified: geronimo/devtools/trunk/modules/eclipse-plugin/plugins/org.apache.geronimo.ui/src/org/apache/geronimo/ui/sections/AppGeneralSection.java
URL: http://svn.apache.org/viewcvs/geronimo/devtools/trunk/modules/eclipse-plugin/plugins/org.apache.geronimo.ui/src/org/apache/geronimo/ui/sections/AppGeneralSection.java?rev=293346&r1=293345&r2=293346&view=diff
==============================================================================
--- geronimo/devtools/trunk/modules/eclipse-plugin/plugins/org.apache.geronimo.ui/src/org/apache/geronimo/ui/sections/AppGeneralSection.java (original)
+++ geronimo/devtools/trunk/modules/eclipse-plugin/plugins/org.apache.geronimo.ui/src/org/apache/geronimo/ui/sections/AppGeneralSection.java Mon Oct  3 06:36:33 2005
@@ -15,126 +15,45 @@
  */
 package org.apache.geronimo.ui.sections;
 
-import org.apache.geronimo.ui.internal.Messages;
+import org.apache.geronimo.xml.ns.j2ee.application.ApplicationPackage;
 import org.apache.geronimo.xml.ns.j2ee.application.ApplicationType;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.ModifyEvent;
-import org.eclipse.swt.events.ModifyListener;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.emf.ecore.EAttribute;
+import org.eclipse.emf.ecore.EObject;
 import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Text;
-import org.eclipse.ui.forms.FormColors;
-import org.eclipse.ui.forms.SectionPart;
 import org.eclipse.ui.forms.widgets.FormToolkit;
 import org.eclipse.ui.forms.widgets.Section;
 
-/**
- * 
- *
- */
-public class AppGeneralSection extends SectionPart {
-    
-    ApplicationType plan;
-    
-    protected Text configId;
-
-    protected Text parentId;
+public class AppGeneralSection extends CommonGeneralSection {
 
-    /**
-     * @param section
-     */
-    public AppGeneralSection(Section section) {
-        super(section);
-        // TODO Auto-generated constructor stub
-    }
+    ApplicationType plan;
 
-    /**
-     * @param parent
-     * @param toolkit
-     * @param style
-     */
-    public AppGeneralSection(Composite parent, FormToolkit toolkit, int style) {
-        super(parent, toolkit, style);
-        // TODO Auto-generated constructor stub
-    }
-    
-    public AppGeneralSection(ApplicationType plan, Composite parent,
-            FormToolkit toolkit, int style) {
-        this(parent, toolkit, style);
-        this.plan = plan;
+    public AppGeneralSection(Composite parent, FormToolkit toolkit, int style,
+            EObject plan) {
+        super(parent, toolkit, style, plan);
+        this.plan = (ApplicationType) plan;
         createClient(getSection(), toolkit);
     }
-    
-    private void createClient(Section section, FormToolkit toolkit) {
-
-        section.setText(Messages.editorSectionGeneralTitle);
-        section.setDescription(Messages.editorSectionGeneralDescription);
-        section.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false));
-
-        Composite composite = toolkit.createComposite(section);
-        GridLayout layout = new GridLayout();
-        layout.numColumns = 2;
-        layout.marginHeight = 5;
-        layout.marginWidth = 10;
-        layout.verticalSpacing = 5;
-        layout.horizontalSpacing = 15;
-        composite.setLayout(layout);
-        composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
-        section.setClient(composite);
-
-        // ------- Label and text field for the config Id -------
-        createLabel(composite, Messages.editorConfigId, toolkit);
-
-        configId = toolkit
-                .createText(composite, plan.getConfigId(), SWT.BORDER);
-        configId.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
-        configId.addModifyListener(new ModifyListener() {
-            public void modifyText(ModifyEvent e) {
-                plan.setConfigId(configId.getText());
-                markDirty();
-            }
-        });
-
-        // ------- Label and text field for the parent Id -------
-        createLabel(composite, Messages.editorParentId, toolkit);
-
-        parentId = toolkit
-                .createText(composite, plan.getParentId(), SWT.BORDER);
-        parentId
-                .setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false));
-        parentId.addModifyListener(new ModifyListener() {
-            public void modifyText(ModifyEvent e) {
-                plan.setParentId(parentId.getText());
-                markDirty();
-            }
-        });
 
+    private void createClient(Section section, FormToolkit toolkit) {
+        createConfigAndParentComposite(section, toolkit);
     }
 
-    protected Label createLabel(Composite parent, String text,
-            FormToolkit toolkit) {
-        Label label = toolkit.createLabel(parent, text);
-        label.setForeground(toolkit.getColors().getColor(FormColors.TITLE));
-        label.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false));
-        return label;
+    /*
+     * (non-Javadoc)
+     * 
+     * @see org.apache.geronimo.ui.sections.CommonGeneralSection#getConfigIdEAttribute()
+     */
+    protected EAttribute getConfigIdEAttribute() {
+        return ApplicationPackage.eINSTANCE.getApplicationType_ConfigId();
     }
 
     /*
      * (non-Javadoc)
      * 
-     * @see org.eclipse.ui.forms.IFormPart#commit(boolean)
-     * 
-     * Overriding this method as a workaround as switching tabs on a dirty
-     * editor commits the page and marks the part as not dirty.
+     * @see org.apache.geronimo.ui.sections.CommonGeneralSection#getParentIdEAttribute()
      */
-    public void commit(boolean onSave) {
-        boolean currentDirtyState = isDirty();
-        super.commit(onSave);
-        if (!onSave && currentDirtyState) {
-            markDirty();
-        }
+    protected EAttribute getParentIdEAttribute() {
+        return ApplicationPackage.eINSTANCE.getApplicationType_ParentId();
     }
 
 }

Added: geronimo/devtools/trunk/modules/eclipse-plugin/plugins/org.apache.geronimo.ui/src/org/apache/geronimo/ui/sections/CommonGeneralSection.java
URL: http://svn.apache.org/viewcvs/geronimo/devtools/trunk/modules/eclipse-plugin/plugins/org.apache.geronimo.ui/src/org/apache/geronimo/ui/sections/CommonGeneralSection.java?rev=293346&view=auto
==============================================================================
--- geronimo/devtools/trunk/modules/eclipse-plugin/plugins/org.apache.geronimo.ui/src/org/apache/geronimo/ui/sections/CommonGeneralSection.java (added)
+++ geronimo/devtools/trunk/modules/eclipse-plugin/plugins/org.apache.geronimo.ui/src/org/apache/geronimo/ui/sections/CommonGeneralSection.java Mon Oct  3 06:36:33 2005
@@ -0,0 +1,125 @@
+/**
+ * Copyright 2004, 2005 The Apache Software Foundation or its licensors, as applicable
+ *
+ *  Licensed 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.ui.sections;
+
+import org.apache.geronimo.ui.internal.Messages;
+import org.eclipse.emf.ecore.EAttribute;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.ui.forms.FormColors;
+import org.eclipse.ui.forms.widgets.FormToolkit;
+import org.eclipse.ui.forms.widgets.Section;
+
+public abstract class CommonGeneralSection extends AbstractSectionPart {
+
+    protected Text configId;
+
+    protected Text parentId;
+    
+    private EObject plan;
+    
+    public CommonGeneralSection(Composite parent, FormToolkit toolkit, int style, EObject plan) {
+        super(parent, toolkit, style);
+        this.plan = plan;
+    }
+
+    protected void createConfigAndParentComposite(Section section,
+            FormToolkit toolkit) {
+
+        section.setText(Messages.editorSectionGeneralTitle);
+        section.setDescription(Messages.editorSectionGeneralDescription);
+        section.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false));
+
+        Composite composite = toolkit.createComposite(section);
+        GridLayout layout = new GridLayout();
+        layout.numColumns = 2;
+        layout.marginHeight = 5;
+        layout.marginWidth = 10;
+        layout.verticalSpacing = 5;
+        layout.horizontalSpacing = 15;
+        composite.setLayout(layout);
+        composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
+        section.setClient(composite);
+
+        // ------- Label and text field for the config Id -------
+        createLabel(composite, Messages.editorConfigId, toolkit);
+
+        configId = toolkit.createText(composite, getConfigID(), SWT.BORDER);
+        configId.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
+        configId.addModifyListener(new ModifyListener() {
+            public void modifyText(ModifyEvent e) {
+                setConfigID(configId.getText());
+                markDirty();
+            }
+        });
+
+        // ------- Label and text field for the parent Id -------
+        createLabel(composite, Messages.editorParentId, toolkit);
+
+        parentId = toolkit.createText(composite, getParentID(), SWT.BORDER);
+        parentId
+                .setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false));
+        parentId.addModifyListener(new ModifyListener() {
+            public void modifyText(ModifyEvent e) {
+                setParentID(parentId.getText());
+                markDirty();
+            }
+        });
+    }
+
+    protected Label createLabel(Composite parent, String text,
+            FormToolkit toolkit) {
+        Label label = toolkit.createLabel(parent, text);
+        label.setForeground(toolkit.getColors().getColor(FormColors.TITLE));
+        label.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false));
+        return label;
+    }
+
+    protected String getConfigID() {
+        return getID(getConfigIdEAttribute());
+    }
+
+    protected String getParentID() {
+        return getID(getParentIdEAttribute());
+    }
+
+    protected void setConfigID(String id) {
+        plan.eSet(getConfigIdEAttribute(), id);
+    }
+
+    protected void setParentID(String id) {
+        plan.eSet(getParentIdEAttribute(), id);
+    }
+    
+    private String getID(EAttribute configIdAttribute) {
+        if (configIdAttribute != null && plan.eIsSet(configIdAttribute)) {
+            return plan.eGet(configIdAttribute).toString();
+        }
+        return "";
+    }
+
+    protected abstract EAttribute getConfigIdEAttribute();
+
+    protected abstract EAttribute getParentIdEAttribute();
+    
+}

Added: geronimo/devtools/trunk/modules/eclipse-plugin/plugins/org.apache.geronimo.ui/src/org/apache/geronimo/ui/sections/ConnectorGeneralSection.java
URL: http://svn.apache.org/viewcvs/geronimo/devtools/trunk/modules/eclipse-plugin/plugins/org.apache.geronimo.ui/src/org/apache/geronimo/ui/sections/ConnectorGeneralSection.java?rev=293346&view=auto
==============================================================================
--- geronimo/devtools/trunk/modules/eclipse-plugin/plugins/org.apache.geronimo.ui/src/org/apache/geronimo/ui/sections/ConnectorGeneralSection.java (added)
+++ geronimo/devtools/trunk/modules/eclipse-plugin/plugins/org.apache.geronimo.ui/src/org/apache/geronimo/ui/sections/ConnectorGeneralSection.java Mon Oct  3 06:36:33 2005
@@ -0,0 +1,53 @@
+/**
+ * Copyright 2004, 2005 The Apache Software Foundation or its licensors, as applicable
+ *
+ *  Licensed 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.ui.sections;
+
+import org.apache.geronimo.xml.ns.j2ee.connector.ConnectorPackage;
+import org.apache.geronimo.xml.ns.j2ee.connector.ConnectorType;
+import org.eclipse.emf.ecore.EAttribute;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.ui.forms.widgets.FormToolkit;
+
+public class ConnectorGeneralSection extends CommonGeneralSection {
+
+    ConnectorType plan;
+
+    public ConnectorGeneralSection(Composite parent, FormToolkit toolkit,
+            int style, EObject plan) {
+        super(parent, toolkit, style, plan);
+        this.plan = (ConnectorType) plan;
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see org.apache.geronimo.ui.sections.CommonGeneralSection#getConfigIdEAttribute()
+     */
+    protected EAttribute getConfigIdEAttribute() {
+        return ConnectorPackage.eINSTANCE.getConnectorType_ConfigId();
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see org.apache.geronimo.ui.sections.CommonGeneralSection#getParentIdEAttribute()
+     */
+    protected EAttribute getParentIdEAttribute() {
+        return ConnectorPackage.eINSTANCE.getConnectorType_ParentId();
+    }
+
+}

Added: geronimo/devtools/trunk/modules/eclipse-plugin/plugins/org.apache.geronimo.ui/src/org/apache/geronimo/ui/sections/OpenEjbJarGeneralSection.java
URL: http://svn.apache.org/viewcvs/geronimo/devtools/trunk/modules/eclipse-plugin/plugins/org.apache.geronimo.ui/src/org/apache/geronimo/ui/sections/OpenEjbJarGeneralSection.java?rev=293346&view=auto
==============================================================================
--- geronimo/devtools/trunk/modules/eclipse-plugin/plugins/org.apache.geronimo.ui/src/org/apache/geronimo/ui/sections/OpenEjbJarGeneralSection.java (added)
+++ geronimo/devtools/trunk/modules/eclipse-plugin/plugins/org.apache.geronimo.ui/src/org/apache/geronimo/ui/sections/OpenEjbJarGeneralSection.java Mon Oct  3 06:36:33 2005
@@ -0,0 +1,53 @@
+/**
+ * Copyright 2004, 2005 The Apache Software Foundation or its licensors, as applicable
+ *
+ *  Licensed 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.ui.sections;
+
+import org.eclipse.emf.ecore.EAttribute;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.ui.forms.widgets.FormToolkit;
+import org.openejb.xml.ns.openejb.jar.JarPackage;
+import org.openejb.xml.ns.openejb.jar.OpenejbJarType;
+
+public class OpenEjbJarGeneralSection extends CommonGeneralSection {
+
+    OpenejbJarType plan;
+
+    public OpenEjbJarGeneralSection(Composite parent, FormToolkit toolkit,
+            int style, EObject plan) {
+        super(parent, toolkit, style, plan);
+        this.plan = (OpenejbJarType) plan;
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see org.apache.geronimo.ui.sections.CommonGeneralSection#getConfigIdEAttribute()
+     */
+    protected EAttribute getConfigIdEAttribute() {
+        return JarPackage.eINSTANCE.getOpenejbJarType_ConfigId();
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see org.apache.geronimo.ui.sections.CommonGeneralSection#getParentIdEAttribute()
+     */
+    protected EAttribute getParentIdEAttribute() {
+        return JarPackage.eINSTANCE.getOpenejbJarType_ParentId();
+    }
+
+}

Modified: geronimo/devtools/trunk/modules/eclipse-plugin/plugins/org.apache.geronimo.ui/src/org/apache/geronimo/ui/sections/WebGeneralSection.java
URL: http://svn.apache.org/viewcvs/geronimo/devtools/trunk/modules/eclipse-plugin/plugins/org.apache.geronimo.ui/src/org/apache/geronimo/ui/sections/WebGeneralSection.java?rev=293346&r1=293345&r2=293346&view=diff
==============================================================================
--- geronimo/devtools/trunk/modules/eclipse-plugin/plugins/org.apache.geronimo.ui/src/org/apache/geronimo/ui/sections/WebGeneralSection.java (original)
+++ geronimo/devtools/trunk/modules/eclipse-plugin/plugins/org.apache.geronimo.ui/src/org/apache/geronimo/ui/sections/WebGeneralSection.java Mon Oct  3 06:36:33 2005
@@ -17,30 +17,26 @@
 
 import org.apache.geronimo.ui.internal.Messages;
 import org.apache.geronimo.xml.ns.web.WebAppType;
+import org.apache.geronimo.xml.ns.web.WebPackage;
+import org.eclipse.emf.ecore.EAttribute;
+import org.eclipse.emf.ecore.EObject;
 import org.eclipse.swt.SWT;
 import org.eclipse.swt.events.ModifyEvent;
 import org.eclipse.swt.events.ModifyListener;
 import org.eclipse.swt.events.SelectionEvent;
 import org.eclipse.swt.events.SelectionListener;
 import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
 import org.eclipse.swt.widgets.Button;
 import org.eclipse.swt.widgets.Composite;
 import org.eclipse.swt.widgets.Label;
 import org.eclipse.swt.widgets.Text;
-import org.eclipse.ui.forms.FormColors;
-import org.eclipse.ui.forms.SectionPart;
 import org.eclipse.ui.forms.widgets.FormToolkit;
 import org.eclipse.ui.forms.widgets.Section;
 
-public class WebGeneralSection extends SectionPart {
-
-    protected Text configId;
-
-    protected Text parentId;
+public class WebGeneralSection extends CommonGeneralSection {
 
     protected Text contextRoot;
-    
+
     protected Text securityRealm;
 
     protected Button cpClassLoaderWebAppFirst;
@@ -49,64 +45,17 @@
 
     WebAppType plan;
 
-    public WebGeneralSection(Section section) {
-        super(section);
-    }
-
-    public WebGeneralSection(Composite parent, FormToolkit toolkit, int style) {
-        super(parent, toolkit, style);
-    }
-
-    public WebGeneralSection(WebAppType plan, Composite parent,
-            FormToolkit toolkit, int style) {
-        this(parent, toolkit, style);
-        this.plan = plan;
+    public WebGeneralSection(Composite parent, FormToolkit toolkit, int style,
+            EObject plan) {
+        super(parent, toolkit, style, plan);
+        this.plan = (WebAppType) plan;
         createClient(getSection(), toolkit);
     }
 
     private void createClient(Section section, FormToolkit toolkit) {
 
-        section.setText(Messages.editorSectionGeneralTitle);
-        section.setDescription(Messages.editorSectionGeneralDescription);
-        section.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false));
-
-        Composite composite = toolkit.createComposite(section);
-        GridLayout layout = new GridLayout();
-        layout.numColumns = 2;
-        layout.marginHeight = 5;
-        layout.marginWidth = 10;
-        layout.verticalSpacing = 5;
-        layout.horizontalSpacing = 15;
-        composite.setLayout(layout);
-        composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
-        section.setClient(composite);
-
-        // ------- Label and text field for the config Id -------
-        createLabel(composite, Messages.editorConfigId, toolkit);
-
-        configId = toolkit
-                .createText(composite, plan.getConfigId(), SWT.BORDER);
-        configId.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
-        configId.addModifyListener(new ModifyListener() {
-            public void modifyText(ModifyEvent e) {
-                plan.setConfigId(configId.getText());
-                markDirty();
-            }
-        });
-
-        // ------- Label and text field for the parent Id -------
-        createLabel(composite, Messages.editorParentId, toolkit);
-
-        parentId = toolkit
-                .createText(composite, plan.getParentId(), SWT.BORDER);
-        parentId
-                .setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false));
-        parentId.addModifyListener(new ModifyListener() {
-            public void modifyText(ModifyEvent e) {
-                plan.setParentId(parentId.getText());
-                markDirty();
-            }
-        });
+        createConfigAndParentComposite(section, toolkit);
+        Composite composite = (Composite) section.getClient();
 
         // ------- Label and text field for the context root -------
         createLabel(composite, Messages.editorContextRoot, toolkit);
@@ -121,13 +70,12 @@
                 markDirty();
             }
         });
-        
-        
+
         // ------- Label and text field for the security realm -------
         createLabel(composite, Messages.securityRealmName, toolkit);
 
-        securityRealm = toolkit.createText(composite, plan.getSecurityRealmName(),
-                SWT.BORDER);
+        securityRealm = toolkit.createText(composite, plan
+                .getSecurityRealmName(), SWT.BORDER);
         securityRealm.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false,
                 false));
         securityRealm.addModifyListener(new ModifyListener() {
@@ -166,7 +114,6 @@
                 plan.setContextPriorityClassloader(cpClassLoaderWebAppFirst
                         .getSelection());
                 markDirty();
-
             }
 
             public void widgetDefaultSelected(SelectionEvent e) {
@@ -176,28 +123,17 @@
 
     }
 
-    protected Label createLabel(Composite parent, String text,
-            FormToolkit toolkit) {
-        Label label = toolkit.createLabel(parent, text);
-        label.setForeground(toolkit.getColors().getColor(FormColors.TITLE));
-        label.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false));
-        return label;
+    /* (non-Javadoc)
+     * @see org.apache.geronimo.ui.sections.CommonGeneralSection#getConfigIdEAttribute()
+     */
+    protected EAttribute getConfigIdEAttribute() {
+        return WebPackage.eINSTANCE.getWebAppType_ConfigId();
     }
 
-    /*
-     * (non-Javadoc)
-     * 
-     * @see org.eclipse.ui.forms.IFormPart#commit(boolean)
-     * 
-     * Overriding this method as a workaround as switching tabs on a dirty
-     * editor commits the page and marks the part as not dirty.
+    /* (non-Javadoc)
+     * @see org.apache.geronimo.ui.sections.CommonGeneralSection#getParentIdEAttribute()
      */
-    public void commit(boolean onSave) {
-        boolean currentDirtyState = isDirty();
-        super.commit(onSave);
-        if (!onSave && currentDirtyState) {
-            markDirty();
-        }
+    protected EAttribute getParentIdEAttribute() {
+        return WebPackage.eINSTANCE.getWebAppType_ParentId();
     }
-
 }