geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ge...@apache.org
Subject svn commit: r239958 - in /geronimo/trunk/sandbox/eclipse-plugin/org.apache.geronimo.ui/src/org/apache/geronimo/ui: internal/ sections/ wizards/
Date Wed, 24 Aug 2005 22:57:15 GMT
Author: geirm
Date: Wed Aug 24 15:57:11 2005
New Revision: 239958

URL: http://svn.apache.org/viewcvs?rev=239958&view=rev
Log:
GERONIMO-885 : applied #2 (18/Aug/05)


Modified:
    geronimo/trunk/sandbox/eclipse-plugin/org.apache.geronimo.ui/src/org/apache/geronimo/ui/internal/Messages.java
    geronimo/trunk/sandbox/eclipse-plugin/org.apache.geronimo.ui/src/org/apache/geronimo/ui/internal/Messages.properties
    geronimo/trunk/sandbox/eclipse-plugin/org.apache.geronimo.ui/src/org/apache/geronimo/ui/sections/DynamicTableSection.java
    geronimo/trunk/sandbox/eclipse-plugin/org.apache.geronimo.ui/src/org/apache/geronimo/ui/sections/SecuritySection.java
    geronimo/trunk/sandbox/eclipse-plugin/org.apache.geronimo.ui/src/org/apache/geronimo/ui/wizards/DynamicAddEditWizard.java

Modified: geronimo/trunk/sandbox/eclipse-plugin/org.apache.geronimo.ui/src/org/apache/geronimo/ui/internal/Messages.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/sandbox/eclipse-plugin/org.apache.geronimo.ui/src/org/apache/geronimo/ui/internal/Messages.java?rev=239958&r1=239957&r2=239958&view=diff
==============================================================================
--- geronimo/trunk/sandbox/eclipse-plugin/org.apache.geronimo.ui/src/org/apache/geronimo/ui/internal/Messages.java
(original)
+++ geronimo/trunk/sandbox/eclipse-plugin/org.apache.geronimo.ui/src/org/apache/geronimo/ui/internal/Messages.java
Wed Aug 24 15:57:11 2005
@@ -57,6 +57,10 @@
     public static String editorSectionSecurityRolesTitle;
 
     public static String editorSectionSecurityRolesDescription;
+    
+    public static String name;
+    
+    public static String description;
 
     //
 
@@ -143,6 +147,16 @@
     public static String wizardPageTitle_EjbLocalRef;
 
     public static String wizardPageDescription_EjbLocalRef;
+
+    //
+
+    public static String wizardNewTitle_SecurityRole;
+
+    public static String wizardEditTitle_SecurityRole;
+
+    public static String wizardPageTitle_SecurityRole;
+
+    public static String wizardPageDescription_SecurityRole;
 
     static {
         NLS.initializeMessages(GeronimoUIPlugin.PLUGIN_ID

Modified: geronimo/trunk/sandbox/eclipse-plugin/org.apache.geronimo.ui/src/org/apache/geronimo/ui/internal/Messages.properties
URL: http://svn.apache.org/viewcvs/geronimo/trunk/sandbox/eclipse-plugin/org.apache.geronimo.ui/src/org/apache/geronimo/ui/internal/Messages.properties?rev=239958&r1=239957&r2=239958&view=diff
==============================================================================
--- geronimo/trunk/sandbox/eclipse-plugin/org.apache.geronimo.ui/src/org/apache/geronimo/ui/internal/Messages.properties
(original)
+++ geronimo/trunk/sandbox/eclipse-plugin/org.apache.geronimo.ui/src/org/apache/geronimo/ui/internal/Messages.properties
Wed Aug 24 15:57:11 2005
@@ -58,7 +58,15 @@
 wizardPageTitle_EjbLocalRef=EJB Reference Local Details
 wizardPageDescription_EjbLocalRef=Provide details for this ejb local reference.
 
+wizardNewTitle_SecurityRole=New Security Role
+wizardEditTitle_SecurityRole=Edit Security Role
+wizardPageTitle_SecurityRole=Security Rolel Details
+wizardPageDescription_SecurityRole=Provide details for this security role.
+
 editorTabGeneral=General
 editorTabNaming=Naming
 editorTabSecurity=Security
-editorTabDependencies=Dependencies
\ No newline at end of file
+editorTabDependencies=Dependencies
+
+name=Name
+description=Description
\ No newline at end of file

Modified: geronimo/trunk/sandbox/eclipse-plugin/org.apache.geronimo.ui/src/org/apache/geronimo/ui/sections/DynamicTableSection.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/sandbox/eclipse-plugin/org.apache.geronimo.ui/src/org/apache/geronimo/ui/sections/DynamicTableSection.java?rev=239958&r1=239957&r2=239958&view=diff
==============================================================================
--- geronimo/trunk/sandbox/eclipse-plugin/org.apache.geronimo.ui/src/org/apache/geronimo/ui/sections/DynamicTableSection.java
(original)
+++ geronimo/trunk/sandbox/eclipse-plugin/org.apache.geronimo.ui/src/org/apache/geronimo/ui/sections/DynamicTableSection.java
Wed Aug 24 15:57:11 2005
@@ -26,6 +26,7 @@
 import org.eclipse.emf.ecore.EFactory;
 import org.eclipse.emf.ecore.EObject;
 import org.eclipse.emf.ecore.EReference;
+import org.eclipse.emf.ecore.util.EcoreUtil;
 import org.eclipse.jface.dialogs.Dialog;
 import org.eclipse.jface.resource.ImageDescriptor;
 import org.eclipse.jface.viewers.ColumnWeightData;
@@ -103,7 +104,7 @@
 
         section.setText(getTitle());
         section.setDescription(getDescription());
-        
+
         configureSection(section);
 
         Composite composite = createTableComposite(section, toolkit);
@@ -138,7 +139,7 @@
         return composite;
     }
 
-    protected void configureSection(Section section) {       
+    protected void configureSection(Section section) {
         section.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false));
     }
 
@@ -157,7 +158,7 @@
     protected void createTable(Composite composite) {
         table = new Table(composite, SWT.BORDER | SWT.FULL_SELECTION
                 | SWT.V_SCROLL | SWT.SINGLE);
-        if (getTableColumnNames().length > 0) {
+        if (isHeaderVisible()) {
             table.setHeaderVisible(true);
         }
 
@@ -173,7 +174,6 @@
             tableLayout.addColumnData(new ColumnWeightData(35));
             TableColumn tableColumn = new TableColumn(table, SWT.NONE);
             tableColumn.setText(getTableColumnNames()[i]);
-
         }
 
     }
@@ -205,7 +205,7 @@
                     TableItem tableItem = table.getItem(selectedIndices[i]);
                     EObject type = (EObject) (tableItem.getData());
                     table.remove(selectedIndices[i]);
-                    ((EList) plan.eGet(getEReference())).remove(type);
+                    EcoreUtil.remove(type);
                     markDirty();
                 }
             }
@@ -268,12 +268,15 @@
     public String[] getTableText(EObject eObject) {
         List tableText = new ArrayList();
         for (int i = 0; i < getTableColumnEAttributes().length; i++) {
-            String value = (String) eObject
-                    .eGet(getTableColumnEAttributes()[i]);
-            if (value != null) {
-                tableText.add(value);
-            } else {
-                tableText.add("");
+            if (getTableColumnEAttributes()[i].getEContainingClass().equals(
+                    eObject.eClass())) {
+                String value = (String) eObject
+                        .eGet(getTableColumnEAttributes()[i]);
+                if (value != null) {
+                    tableText.add(value);
+                } else {
+                    tableText.add("");
+                }
             }
         }
         return (String[]) tableText.toArray(new String[tableText.size()]);
@@ -289,6 +292,10 @@
 
     public EObject getPlan() {
         return plan;
+    }
+
+    public boolean isHeaderVisible() {
+        return true;
     }
 
     /**

Modified: geronimo/trunk/sandbox/eclipse-plugin/org.apache.geronimo.ui/src/org/apache/geronimo/ui/sections/SecuritySection.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/sandbox/eclipse-plugin/org.apache.geronimo.ui/src/org/apache/geronimo/ui/sections/SecuritySection.java?rev=239958&r1=239957&r2=239958&view=diff
==============================================================================
--- geronimo/trunk/sandbox/eclipse-plugin/org.apache.geronimo.ui/src/org/apache/geronimo/ui/sections/SecuritySection.java
(original)
+++ geronimo/trunk/sandbox/eclipse-plugin/org.apache.geronimo.ui/src/org/apache/geronimo/ui/sections/SecuritySection.java
Wed Aug 24 15:57:11 2005
@@ -17,16 +17,27 @@
 
 import org.apache.geronimo.ui.internal.Messages;
 import org.apache.geronimo.ui.wizards.DynamicAddEditWizard;
+import org.apache.geronimo.ui.wizards.SecurityRoleWizard;
+import org.apache.geronimo.xml.ns.security.DescriptionType;
+import org.apache.geronimo.xml.ns.security.RoleType;
 import org.apache.geronimo.xml.ns.security.SecurityFactory;
+import org.apache.geronimo.xml.ns.security.SecurityPackage;
+import org.apache.geronimo.xml.ns.security.SecurityType;
 import org.apache.geronimo.xml.ns.web.WebAppType;
+import org.apache.geronimo.xml.ns.web.impl.WebPackageImpl;
+import org.eclipse.emf.common.util.EList;
 import org.eclipse.emf.ecore.EAttribute;
 import org.eclipse.emf.ecore.EFactory;
+import org.eclipse.emf.ecore.EObject;
 import org.eclipse.emf.ecore.EReference;
 import org.eclipse.swt.SWT;
+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.Composite;
 import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.TableItem;
 import org.eclipse.swt.widgets.Text;
 import org.eclipse.ui.forms.widgets.FormToolkit;
 import org.eclipse.ui.forms.widgets.Section;
@@ -37,6 +48,9 @@
  */
 public class SecuritySection extends DynamicTableSection {
 
+    public static EReference securityERef = WebPackageImpl.eINSTANCE
+            .getWebAppType_Security();
+
     /**
      * @param plan
      * @param parent
@@ -46,13 +60,13 @@
     public SecuritySection(WebAppType plan, Composite parent,
             FormToolkit toolkit, int style) {
         super(plan, parent, toolkit, style);
-     
+
     }
-    
+
     /**
      * @return
      */
-    public String getTitle(){
+    public String getTitle() {
         return Messages.editorSectionSecurityRolesTitle;
     }
 
@@ -74,44 +88,61 @@
      * @return
      */
     public EReference getEReference() {
-        return SecurityFactory.eINSTANCE.getSecurityPackage().getRoleMappingsType_Role();
+        return SecurityFactory.eINSTANCE.getSecurityPackage()
+                .getRoleMappingsType_Role();
     }
 
     /**
      * @return
      */
     public String[] getTableColumnNames() {
-        return new String[0];
+        return new String[] { Messages.name, Messages.description };
     }
 
     /**
      * @return
      */
     public EAttribute[] getTableColumnEAttributes() {
-        return new EAttribute[0];
+        return new EAttribute[] {
+                SecurityPackage.eINSTANCE.getRoleType_RoleName(),
+                SecurityPackage.eINSTANCE.getDescriptionType_Lang() };
     }
 
     /**
      * @return
      */
     public DynamicAddEditWizard getWizard() {
-        return null;
+        return new SecurityRoleWizard(this);
     }
-    
-    /* (non-Javadoc)
+
+    /*
+     * (non-Javadoc)
+     * 
      * @see org.apache.geronimo.ui.sections.DynamicTableSection#configureSection(org.eclipse.ui.forms.widgets.Section)
      */
-    protected void configureSection(Section section) {       
+    protected void configureSection(Section section) {
         section.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
     }
 
-    /* (non-Javadoc)
-     * @see org.apache.geronimo.ui.sections.DynamicTableSection#createClient(org.eclipse.ui.forms.widgets.Section,
org.eclipse.ui.forms.widgets.FormToolkit)
+    /*
+     * (non-Javadoc)
+     * 
+     * @see org.apache.geronimo.ui.sections.DynamicTableSection#showTableColumNames()
+     */
+    public boolean isHeaderVisible() {
+        return false;
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see org.apache.geronimo.ui.sections.DynamicTableSection#createClient(org.eclipse.ui.forms.widgets.Section,
+     *      org.eclipse.ui.forms.widgets.FormToolkit)
      */
     public void createClient(Section section, FormToolkit toolkit) {
-        
-        super.createClient(section, toolkit);       
-        
+
+        super.createClient(section, toolkit);
+
         Composite detail = toolkit.createComposite(table.getParent());
         GridLayout gl = new GridLayout();
         gl.marginWidth = 4;
@@ -120,26 +151,80 @@
         detail.setLayout(gl);
         detail.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
 
-        Label roleNameLabel = toolkit.createLabel(detail, "Name");
-        roleNameLabel.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false));
+        Label roleNameLabel = toolkit.createLabel(detail, Messages.name + ":");
+        roleNameLabel.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false,
+                false));
         roleNameLabel.setEnabled(true);
 
         Text roleNameText = toolkit.createText(detail, "", SWT.BORDER);
-        roleNameText.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
+        roleNameText
+                .setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
         roleNameText.setEnabled(true);
-        
-        Label roleDescriptionLabel = toolkit.createLabel(detail, "Description");
-        roleDescriptionLabel.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false));
+
+        Label roleDescriptionLabel = toolkit.createLabel(detail, Messages.description + ":");
+        roleDescriptionLabel.setLayoutData(new GridData(SWT.FILL, SWT.FILL,
+                false, false));
         roleDescriptionLabel.setEnabled(true);
 
-        Text roleDescriptionText = toolkit.createText(detail, "", SWT.MULTI | SWT.BORDER);
+        Text roleDescriptionText = toolkit.createText(detail, "", SWT.MULTI
+                | SWT.BORDER);
         GridData data = new GridData(SWT.FILL, SWT.FILL, true, false);
         data.heightHint = 50;
         roleDescriptionText.setLayoutData(data);
         roleDescriptionText.setEnabled(true);
 
+        table.addSelectionListener(new TableSelectionListener(roleNameText,
+                roleDescriptionText));
+
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see org.apache.geronimo.ui.sections.DynamicTableSection#fillTableItems()
+     */
+    protected void fillTableItems() {
+
+        SecurityType secType = (SecurityType) getPlan().eGet(securityERef);
+
+        EList list = (EList) (secType.getRoleMappings().getRole());
+
+        for (int j = 0; j < list.size(); j++) {
+            TableItem item = new TableItem(table, SWT.NONE);
+            String[] tableTextData = getTableText((EObject) list.get(j));
+            item.setImage(getImage());
+            item.setText(tableTextData);
+            item.setData((EObject) list.get(j));
+        }
+    }
+
+    class TableSelectionListener implements SelectionListener {
+
+        Text roleName;
+
+        Text description;
+
+        public TableSelectionListener(Text roleName, Text description) {
+            this.roleName = roleName;
+            this.description = description;
+        }
+
+        public void widgetSelected(SelectionEvent e) {
+            TableItem item = (TableItem) e.item;
+            RoleType roleType = (RoleType) item.getData();
+            roleName.setText(roleType.getRoleName());
+            
+            if(!roleType.getDescription().isEmpty()) {
+                description.setText(((DescriptionType)roleType.getDescription().get(0)).getLang());
+            } else {
+                description.setText("");
+            }
+        }
+
+        public void widgetDefaultSelected(SelectionEvent e) {
+            // do nothing
+        }
+
     }
-    
-   
 
 }

Modified: geronimo/trunk/sandbox/eclipse-plugin/org.apache.geronimo.ui/src/org/apache/geronimo/ui/wizards/DynamicAddEditWizard.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/sandbox/eclipse-plugin/org.apache.geronimo.ui/src/org/apache/geronimo/ui/wizards/DynamicAddEditWizard.java?rev=239958&r1=239957&r2=239958&view=diff
==============================================================================
--- geronimo/trunk/sandbox/eclipse-plugin/org.apache.geronimo.ui/src/org/apache/geronimo/ui/wizards/DynamicAddEditWizard.java
(original)
+++ geronimo/trunk/sandbox/eclipse-plugin/org.apache.geronimo.ui/src/org/apache/geronimo/ui/wizards/DynamicAddEditWizard.java
Wed Aug 24 15:57:11 2005
@@ -78,7 +78,8 @@
             eObject = section.getEFactory().create(
                     section.getTableColumnEAttributes()[0]
                             .getEContainingClass());
-            EObject plan = section.getPlan();
+            EObject plan = section.getPlan();           
+            
             ((EList) plan.eGet(section.getEReference())).add(eObject);
             isNew = true;
         }
@@ -183,7 +184,7 @@
             }
 
             setControl(composite);
-
+                        
             textEntries[0].setFocus();
 
         }



Mime
View raw message