geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From de...@apache.org
Subject svn commit: r921247 [10/11] - in /geronimo/devtools/eclipse-plugin/trunk: ./ features/org.apache.geronimo.v30.feature/ plugins/org.apache.geronimo.runtime.v30/ plugins/org.apache.geronimo.runtime.v30/META-INF/ plugins/org.apache.geronimo.st.v30.core/ p...
Date Wed, 10 Mar 2010 08:31:32 GMT
Added: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.ui/src/main/java/org/apache/geronimo/st/v21/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/v21/ui/wizards/PersUnitRefWizard.java?rev=921247&view=auto
==============================================================================
--- geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.ui/src/main/java/org/apache/geronimo/st/v21/ui/wizards/PersUnitRefWizard.java (added)
+++ geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.ui/src/main/java/org/apache/geronimo/st/v21/ui/wizards/PersUnitRefWizard.java Wed Mar 10 08:31:28 2010
@@ -0,0 +1,196 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.geronimo.st.v21.ui.wizards;
+
+import javax.xml.bind.JAXBElement;
+
+import org.apache.geronimo.jee.naming.PersistenceUnitRef;
+import org.apache.geronimo.jee.naming.ObjectFactory;
+import org.apache.geronimo.jee.naming.Pattern;
+import org.apache.geronimo.st.core.jaxb.JAXBObjectFactory;
+import org.apache.geronimo.st.ui.CommonMessages;
+import org.apache.geronimo.st.ui.sections.AbstractTreeSection;
+import org.apache.geronimo.st.ui.wizards.AbstractTreeWizard;
+import org.apache.geronimo.st.v21.core.jaxb.JAXBModelUtils;
+import org.apache.geronimo.st.v21.core.jaxb.JAXBObjectFactoryImpl;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Text;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class PersUnitRefWizard extends AbstractTreeWizard {
+
+    protected Button specifyUnit;
+    protected Button specifyPattern;
+    
+    public PersUnitRefWizard(AbstractTreeSection section) {
+        super(section, 1, 7);
+    }
+
+    public JAXBObjectFactory getEFactory() {
+        return JAXBObjectFactoryImpl.getInstance();
+    }
+
+    public String getAddWizardWindowTitle() {
+        return CommonMessages.wizardNewTitle_PersUnitRef;
+    }
+
+    public String getEditWizardWindowTitle() {
+        return CommonMessages.wizardEditTitle_PersUnitRef;
+    }
+ 
+    /*
+     * (non-Javadoc)
+     * 
+     * @see org.eclipse.jface.wizard.IWizard#addPages()
+     */
+    public void addPages() {
+        addPage(new PersUnitRefWizardPage("Page0"));
+    }
+
+    // need to extend the DynamicWizardPage only so that when the Edit dialog is shown
+    // the values are brought in properly.
+    public class PersUnitRefWizardPage extends AbstractTreeWizardPage {
+        public PersUnitRefWizardPage(String pageName) {
+            super(pageName);
+        }
+
+        @Override
+        public void createControl(Composite parent) {
+            Label label;
+            Text text;
+            Composite composite = createComposite(parent);
+            for (int i = 0; i < maxTextFields; i++) {
+                label = createLabel(composite, "");
+                labelList.add(label);
+                text = createTextField(composite, "");
+                textList.add(text);
+                if (i == 0) {
+                    specifyUnit = createButton(composite, CommonMessages.useUnitName);
+                }
+                if (i == 1) {
+                    specifyPattern = createButton(composite, CommonMessages.usePattern);
+                }
+            }
+            specifyUnit.addSelectionListener(new SelectionAdapter() {
+                public void widgetSelected(SelectionEvent arg0) {
+                    toggleFields(false);
+                }
+            });
+            specifyPattern.addSelectionListener(new SelectionAdapter() {
+                public void widgetSelected(SelectionEvent arg0) {
+                    toggleFields(false);
+                }
+            });
+            
+            initControl();
+            toggleFields(false);
+            setControl(composite);
+        }
+
+        protected void initControl () {
+            if (eObject != null) {
+                if (JAXBElement.class.isInstance(eObject)) {
+                    eObject = ((JAXBElement)eObject).getValue();
+                    PersistenceUnitRef unitRef = (PersistenceUnitRef)eObject;
+                    textList.get(0).setText(unitRef.getPersistenceUnitRefName());
+                    if (unitRef.getPersistenceUnitName() != null)
+                        textList.get(1).setText(unitRef.getPersistenceUnitName());
+                    if (unitRef.getPattern() != null) {
+                        specifyPattern.setSelection(true);
+                        textList.get(2).setText(unitRef.getPattern().getName());
+                        if (unitRef.getPattern().getGroupId() != null)
+                            textList.get(3).setText(unitRef.getPattern().getGroupId());
+                        if (unitRef.getPattern().getArtifactId() != null)
+                            textList.get(4).setText(unitRef.getPattern().getArtifactId());
+                        if (unitRef.getPattern().getVersion() != null)
+                            textList.get(5).setText(unitRef.getPattern().getVersion());
+                        if (unitRef.getPattern().getModule() != null)
+                            textList.get(6).setText(unitRef.getPattern().getModule());
+                    }
+                }
+            }
+        }
+        
+        protected void toggleFields (boolean clearFields) {
+            labelList.get(0).setText(CommonMessages.contextName);
+            labelList.get(1).setText(CommonMessages.unitName);
+            textList.get(1).setEnabled(specifyUnit.getSelection());
+
+            labelList.get(2).setText(CommonMessages.name);
+            labelList.get(3).setText(CommonMessages.groupId);
+            labelList.get(4).setText(CommonMessages.artifactId);
+            labelList.get(5).setText(CommonMessages.version);
+            labelList.get(6).setText(CommonMessages.moduleId);
+            for (int i = 2; i < maxTextFields; i++) {
+                textList.get(i).setEnabled(specifyPattern.getSelection());
+            }
+        }
+
+        public String getWizardPageTitle() {
+            return CommonMessages.wizardPageTitle_PersUnitRef;
+        }
+
+        public String getWizardPageDescription() {
+            return CommonMessages.wizardPageDescription_PersUnitRef;
+        }
+    }
+
+    @Override
+    public boolean performFinish() {
+        PersistenceUnitRef unitRef;
+        if (isEmpty(textList.get(0).getText()) ||
+            isEmpty(textList.get(1).getText()) && isEmpty(textList.get(2).getText())) {
+            return false;
+        }
+        unitRef = (PersistenceUnitRef)eObject;
+        ObjectFactory objectFactory = new ObjectFactory();
+        if (unitRef == null) {
+            unitRef = (PersistenceUnitRef)getEFactory().create(PersistenceUnitRef.class);
+            JAXBElement plan = section.getPlan();
+
+            // add the JAXBElement of the PersistenceContextRef
+            JAXBModelUtils.getGbeanRefs(plan).add(objectFactory.createPersistenceUnitRef(unitRef));
+            section.getObjectContainer().add(objectFactory.createPersistenceUnitRef(unitRef));
+        }
+        unitRef.setPersistenceUnitRefName(textList.get(0).getText());
+        if (specifyUnit.getSelection() == true) {
+            unitRef.setPersistenceUnitName(textList.get(1).getText());
+            unitRef.setPattern(null);
+        }
+        else {
+            unitRef.setPersistenceUnitName(null);
+            Pattern pattern = unitRef.getPattern();
+            if (pattern == null) {
+                pattern = objectFactory.createPattern();
+            }
+            pattern.setName(textList.get(2).getText());
+            pattern.setGroupId(textList.get(3).getText());
+            pattern.setArtifactId(textList.get(4).getText());
+            pattern.setVersion(textList.get(5).getText());
+            pattern.setModule(textList.get(6).getText());
+            unitRef.setPattern(pattern);
+        }
+
+        return true;
+    }
+}

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

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

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

Added: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.ui/src/main/java/org/apache/geronimo/st/v21/ui/wizards/PrerequisiteWizard.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/v21/ui/wizards/PrerequisiteWizard.java?rev=921247&view=auto
==============================================================================
--- geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.ui/src/main/java/org/apache/geronimo/st/v21/ui/wizards/PrerequisiteWizard.java (added)
+++ geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.ui/src/main/java/org/apache/geronimo/st/v21/ui/wizards/PrerequisiteWizard.java Wed Mar 10 08:31:28 2010
@@ -0,0 +1,148 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.geronimo.st.v21.ui.wizards;
+
+import org.apache.geronimo.st.ui.CommonMessages;
+import org.apache.geronimo.st.ui.wizards.AbstractWizard;
+import org.apache.geronimo.system.plugin.model.ArtifactType;
+import org.apache.geronimo.system.plugin.model.PrerequisiteType;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Text;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class PrerequisiteWizard extends AbstractWizard {
+
+    protected PrerequisiteType prereq;
+    
+    protected Text group;
+    protected Text artifact;
+    protected Text version;
+    protected Text type;
+    protected Text description;
+    
+    public PrerequisiteWizard (PrerequisiteType oldPrereq) {
+        super();
+        prereq = oldPrereq;
+    }
+
+    public String getAddWizardWindowTitle() {
+        return CommonMessages.wizardNewTitle_Prerequisite;
+    }
+
+    public String getEditWizardWindowTitle() {
+        return CommonMessages.wizardEditTitle_Prerequisite;
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see org.eclipse.jface.wizard.IWizard#addPages()
+     */
+    public void addPages() {
+        addPage(new MessageDestWizardPage("Page0"));
+    }
+
+    // need to extend the DynamicWizardPage only so that when the Edit dialog is shown
+    // the values are brought in properly.
+    public class MessageDestWizardPage extends AbstractWizardPage {
+        public MessageDestWizardPage(String pageName) {
+            super(pageName);
+        }
+
+        public void createControl(Composite parent) {
+            Composite composite = createComposite(parent);
+            createLabel (composite, CommonMessages.groupId);
+            group = createTextField (composite, "");
+            createLabel (composite, CommonMessages.artifactId);
+            artifact = createTextField (composite, "");
+            createLabel (composite, CommonMessages.version);
+            version = createTextField (composite, "");
+            createLabel (composite, CommonMessages.type);
+            type = createTextField (composite, "");
+            createLabel (composite, CommonMessages.description);
+            description = createTextField (composite, "");
+            
+            group.addModifyListener(new ModifyListener(){
+				public void modifyText(ModifyEvent arg0) {
+					PrerequisiteWizard.this.getContainer().updateButtons();
+				}
+            });
+            
+            artifact.addModifyListener(new ModifyListener(){
+				public void modifyText(ModifyEvent arg0) {
+					PrerequisiteWizard.this.getContainer().updateButtons();
+				}
+            });
+            
+            type.addModifyListener(new ModifyListener(){
+				public void modifyText(ModifyEvent arg0) {
+					PrerequisiteWizard.this.getContainer().updateButtons();
+				}
+            });
+
+            if (prereq != null) {
+                group.setText(prereq.getId().getGroupId());
+                artifact.setText(prereq.getId().getArtifactId());
+                version.setText(prereq.getId().getVersion());
+                type.setText(prereq.getResourceType());
+                description.setText(prereq.getDescription());
+            }
+            setControl(composite);
+        }
+
+        public String getWizardPageTitle() {
+            return CommonMessages.wizardPageTitle_Prerequisite;
+        }
+
+        public String getWizardPageDescription() {
+            return CommonMessages.wizardPageDescription_Prerequisite;
+        }
+        
+    }
+    
+    public boolean performFinish() {
+        prereq = new PrerequisiteType();
+        ArtifactType artType = new ArtifactType();
+        artType.setGroupId(group.getText());
+        artType.setArtifactId(artifact.getText());
+        artType.setType(type.getText());
+        if(!"".equals(version.getText()))
+        	artType.setVersion(version.getText());
+        prereq.setId(artType);
+        prereq.setResourceType(type.getText());
+        prereq.setDescription(description.getText());
+
+        return true;
+    }
+    
+    public PrerequisiteType getPrerequisite() {
+        return prereq;
+    }
+    
+    public boolean canFinish(){
+    	if (group.getText()!=null && group.getText().length()!=0
+    			&& artifact.getText()!=null && artifact.getText().length()!=0
+    			&& type.getText()!=null && type.getText().length()!=0){
+    		return true;
+    	}else return false;
+    }
+   
+}

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

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

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

Added: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.ui/src/main/java/org/apache/geronimo/st/v21/ui/wizards/ResourceEnvRefWizard.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/v21/ui/wizards/ResourceEnvRefWizard.java?rev=921247&view=auto
==============================================================================
--- geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.ui/src/main/java/org/apache/geronimo/st/v21/ui/wizards/ResourceEnvRefWizard.java (added)
+++ geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.ui/src/main/java/org/apache/geronimo/st/v21/ui/wizards/ResourceEnvRefWizard.java Wed Mar 10 08:31:28 2010
@@ -0,0 +1,68 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.geronimo.st.v21.ui.wizards;
+
+import 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.v21.core.jaxb.JAXBObjectFactoryImpl;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class ResourceEnvRefWizard extends AbstractTableWizard {
+
+ 
+    public ResourceEnvRefWizard(AbstractTableSection section) {
+        super(section);
+    }
+
+    public JAXBObjectFactory getEFactory() {
+        return JAXBObjectFactoryImpl.getInstance();
+    }
+
+    public String[] getTableColumnEAttributes() {
+        return new String[] { "RefName", "MessageDestinationLink" };
+    }
+
+    public String getAddWizardWindowTitle() {
+        return CommonMessages.wizardPageTitle_ResEnvRef;
+    }
+
+    public String getEditWizardWindowTitle() {
+        return CommonMessages.wizardEditTitle_ResEnvRef;
+    }
+    
+    public void addPages() {
+        addPage(new ResourceEnvRefWizardPage("Page0"));
+    }
+
+    public class ResourceEnvRefWizardPage extends AbstractTableWizardPage {
+        public ResourceEnvRefWizardPage(String pageName) {
+            super(pageName);
+        }
+
+        public String getWizardPageTitle() {
+            return CommonMessages.wizardPageTitle_ResEnvRef;
+        }
+
+        public String getWizardPageDescription() {
+            return CommonMessages.wizardPageDescription_ResEnvRef;
+        }
+    }
+}

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

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

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

Added: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.ui/src/main/java/org/apache/geronimo/st/v21/ui/wizards/ResourceRefWizard.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/v21/ui/wizards/ResourceRefWizard.java?rev=921247&view=auto
==============================================================================
--- geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.ui/src/main/java/org/apache/geronimo/st/v21/ui/wizards/ResourceRefWizard.java (added)
+++ geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.ui/src/main/java/org/apache/geronimo/st/v21/ui/wizards/ResourceRefWizard.java Wed Mar 10 08:31:28 2010
@@ -0,0 +1,67 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.geronimo.st.v21.ui.wizards;
+
+import 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.v21.core.jaxb.JAXBObjectFactoryImpl;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class ResourceRefWizard extends AbstractTableWizard {
+
+    public ResourceRefWizard(AbstractTableSection section) {
+        super(section);
+    }
+
+    public JAXBObjectFactory getEFactory() {
+        return JAXBObjectFactoryImpl.getInstance();
+    }
+
+    public String[] getTableColumnEAttributes() {
+        return new String[] { "RefName", "ResourceLink" };
+    }
+
+    public String getAddWizardWindowTitle() {
+        return CommonMessages.wizardPageTitle_ResRef;
+    }
+
+    public String getEditWizardWindowTitle() {
+        return CommonMessages.wizardEditTitle_ResRef;
+    }
+    
+    public void addPages() {
+        addPage(new ResourceRefWizardPage("Page0"));
+    }
+
+    public class ResourceRefWizardPage extends AbstractTableWizardPage {
+        public ResourceRefWizardPage(String pageName) {
+            super(pageName);
+        }
+
+        public String getWizardPageTitle() {
+            return CommonMessages.wizardPageTitle_ResRef;
+        }
+
+        public String getWizardPageDescription() {
+            return CommonMessages.wizardPageDescription_ResRef;
+        }
+    }
+}

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

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

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

Added: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.ui/src/main/java/org/apache/geronimo/st/v21/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/v21/ui/wizards/SecurityRealmWizard.java?rev=921247&view=auto
==============================================================================
--- geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.ui/src/main/java/org/apache/geronimo/st/v21/ui/wizards/SecurityRealmWizard.java (added)
+++ geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.ui/src/main/java/org/apache/geronimo/st/v21/ui/wizards/SecurityRealmWizard.java Wed Mar 10 08:31:28 2010
@@ -0,0 +1,1155 @@
+package org.apache.geronimo.st.v21.ui.wizards;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.xml.bind.JAXBElement;
+
+import org.apache.geronimo.jee.application.Application;
+import org.apache.geronimo.jee.deployment.Attribute;
+import org.apache.geronimo.jee.deployment.Dependencies;
+import org.apache.geronimo.jee.deployment.Dependency;
+import org.apache.geronimo.jee.deployment.Environment;
+import org.apache.geronimo.jee.deployment.Gbean;
+import org.apache.geronimo.jee.deployment.ObjectFactory;
+import org.apache.geronimo.jee.deployment.Reference;
+import org.apache.geronimo.jee.deployment.XmlAttributeType;
+import org.apache.geronimo.jee.loginconfig.ControlFlag;
+import org.apache.geronimo.jee.loginconfig.LoginConfig;
+import org.apache.geronimo.jee.loginconfig.LoginModule;
+import org.apache.geronimo.jee.loginconfig.Option;
+import org.apache.geronimo.jee.naming.Pattern;
+import org.apache.geronimo.jee.openejb.OpenejbJar;
+import org.apache.geronimo.jee.web.WebApp;
+import org.apache.geronimo.st.core.jaxb.JAXBObjectFactory;
+import org.apache.geronimo.st.ui.Activator;
+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.v21.core.GeronimoServerInfo;
+import org.apache.geronimo.st.v21.core.jaxb.JAXBObjectFactoryImpl;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.jface.dialogs.ErrorDialog;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.wizard.IWizardPage;
+import org.eclipse.jface.wizard.WizardPage;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Combo;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Group;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Text;
+
+public class SecurityRealmWizard extends AbstractTableWizard {
+    protected ImageDescriptor descriptor = Activator.imageDescriptorFromPlugin(
+	    "org.apache.geronimo.st.ui", "icons/bigG.gif");
+
+    public SecurityRealmWizard(AbstractTableSection section) {
+	super(section);
+    }
+
+    public String getWizardWindowTitle() {
+	return CommonMessages.wizardTitle_SecurityRealm;
+    }
+
+    @Override
+    public void addPages() {
+	SecurityRealmBasicPage page0 = new SecurityRealmBasicPage(
+		"SecurityRealmBasicPage");
+	page0.setImageDescriptor(descriptor);
+	addPage(page0);
+
+	PropertiesFileRealmPage page1 = new PropertiesFileRealmPage(
+		"PropertiesFileRealmPage");
+	page1.setImageDescriptor(descriptor);
+	addPage(page1);
+
+	SelectSQLPage page2 = new SelectSQLPage("SelectSQLPage");
+	page2.setImageDescriptor(descriptor);
+	addPage(page2);
+
+	DBConnectionPage page3 = new DBConnectionPage("DBConnectionPage");
+	page3.setImageDescriptor(descriptor);
+	addPage(page3);
+
+	LDAPConnectionPage page4 = new LDAPConnectionPage("LDAPConnectionPage");
+	page4.setImageDescriptor(descriptor);
+	addPage(page4);
+
+	LDAPSearchPage page5 = new LDAPSearchPage("LDAPSearchPage");
+	page5.setImageDescriptor(descriptor);
+	addPage(page5);
+
+    }
+
+    @Override
+    public JAXBObjectFactory getEFactory() {
+	return JAXBObjectFactoryImpl.getInstance();
+    }
+
+    @Override
+    public String[] getTableColumnEAttributes() {
+	return new String[] {};
+    }
+
+    @Override
+    protected String getAddWizardWindowTitle() {
+	return "New Security Realm";// TODO put into message
+    }
+
+    @Override
+    protected String getEditWizardWindowTitle() {
+	return "Edit Security Realm";// TODO put into message
+    }
+
+    public boolean performFinish() {
+	boolean isedit = false;
+	JAXBElement<?> plan = this.section.getPlan();
+	ObjectFactory objectFactory = new ObjectFactory();
+	// all pages
+	SecurityRealmBasicPage page0 = (SecurityRealmBasicPage) this
+		.getPage("SecurityRealmBasicPage");
+	PropertiesFileRealmPage page1 = (PropertiesFileRealmPage) this
+		.getPage("PropertiesFileRealmPage");
+	SelectSQLPage page2 = (SelectSQLPage) this.getPage("SelectSQLPage");
+	DBConnectionPage page3 = (DBConnectionPage) this
+		.getPage("DBConnectionPage");
+	LDAPConnectionPage page4 = (LDAPConnectionPage) this
+		.getPage("LDAPConnectionPage");
+	LDAPSearchPage page5 = (LDAPSearchPage) this.getPage("LDAPSearchPage");
+
+	// password not match , popup a dialog
+	if (!page3.textEntries[3].getText().equals(
+		page3.textEntries[4].getText())) {
+	    Status status = new Status(IStatus.WARNING, "Login Error", 0,
+		    "Password provided in both fields do not match", null);
+	    ErrorDialog.openError(this.getShell(), "Login Error",
+		    "Invalid Login Details", status);
+	    return false;
+	}
+
+	// set a gbean according to the input from wizard
+	Gbean gbean = null;
+	if (eObject != null) {
+	    gbean = (Gbean) ((JAXBElement) eObject).getValue();
+	    isedit = true;
+	} else {
+	    gbean = new Gbean();// create a new gbean
+	    eObject = objectFactory.createGbean(gbean);
+	}
+
+	// add the data into gbean
+	String realmName = page0.textEntries[0].getText() == null ? ""
+		: page0.textEntries[0].getText();
+	gbean.setName(realmName);// set the gbean name the same as realm name
+	gbean
+		.setClazz("org.apache.geronimo.security.realm.GenericSecurityRealm");// TODO
+	// message
+
+	List<JAXBElement<?>> elelist = gbean
+		.getAttributeOrXmlAttributeOrReference();
+
+	// set the attribute
+	JAXBElement<Attribute> attributeElement = getAttributeElement(elelist);
+	if (attributeElement == null) {
+	    attributeElement = objectFactory.createGbeanAttribute(null);
+	    elelist.add(attributeElement);
+	}
+	Attribute attribute = new Attribute();
+	attribute.setName("realmName");
+	attribute.setValue(realmName);
+	attributeElement.setValue(attribute);
+
+	// set the reference
+	JAXBElement<Reference> referenceElement = getReferenceElement(elelist);
+	if (referenceElement == null) {
+	    referenceElement = objectFactory.createGbeanReference(null);
+	    elelist.add(referenceElement);
+	}
+	Reference ref = new Reference();
+	ref.setName("ServerInfo");
+	ref.setCustomFoo("ServerInfo");
+	referenceElement.setValue(ref);
+
+	// set the xml-reference
+	JAXBElement<XmlAttributeType> xmlrefElement = getXmlReferenceElement(elelist);
+	if (xmlrefElement == null) {
+	    xmlrefElement = objectFactory.createGbeanXmlReference(null);
+	    elelist.add(xmlrefElement);
+	}
+	XmlAttributeType xmlAtttribute = new XmlAttributeType();
+	xmlAtttribute.setName("LoginModuleConfiguration");
+	xmlrefElement.setValue(xmlAtttribute);
+
+	LoginConfig config = new LoginConfig();
+	xmlAtttribute.setAny(config);
+	LoginModule loginModule = new LoginModule();
+	config.getLoginModuleRefOrLoginModule().add(loginModule);
+	loginModule.setControlFlag(ControlFlag.fromValue("REQUIRED"));
+	loginModule.setWrapPrincipals(false);
+	loginModule.setLoginDomainName(realmName);
+
+	String realmType = page0.combo.getText().trim();
+	if (realmType.equals("Properties File Realm")) {
+	    loginModule
+		    .setLoginModuleClass("org.apache.geronimo.security.realm.providers.PropertiesFileLoginModule");
+
+	    String usersfile = page1.textEntries[0].getText().trim();
+	    Option usersfileopt = createOption("usersURI", usersfile);
+
+	    String groupsfile = page1.textEntries[1].getText().trim();
+	    Option groupsfileopt = createOption("groupsURI", groupsfile);
+
+	    String algorithm = page1.textEntries[2].getText();
+	    Option algorithmopt = createOption("digest", algorithm);
+
+	    String encoding = page1.textEntries[3].getText();
+	    Option encodingopt = createOption("encoding", encoding);
+
+	    loginModule.getOption().add(usersfileopt);
+	    loginModule.getOption().add(groupsfileopt);
+	    if (algorithm != null)
+		loginModule.getOption().add(algorithmopt);
+	    if (encoding != null)
+		loginModule.getOption().add(encodingopt);
+
+	} else if (realmType.equals("SQL Realm")) {
+	    loginModule
+		    .setLoginModuleClass("org.apache.geronimo.security.realm.providers.SQLLoginModule");
+
+	    String selectUsers = page2.textEntries[0].getText().trim();
+	    Option selectUsersopt = createOption("userSelect", selectUsers);
+
+	    String selectGroups = page2.textEntries[1].getText().trim();
+	    Option selectGroupsopt = createOption("groupSelect", selectGroups);
+
+	    String algorithm = page2.textEntries[2].getText().trim();
+	    Option algorithmopt = createOption("digest", algorithm);
+
+	    String encoding = page2.textEntries[3].getText().trim();
+	    Option encodingopt = createOption("encoding", encoding);
+
+	    if (page3.buttons[0].getSelection()) {
+		String dsname = page3.dataBasePoolCombo.getText();
+		Option dsnameopt = createOption("dataSourceName", dsname);
+		loginModule.getOption().add(dsnameopt);
+	    } else if (page3.buttons[1].getSelection()) {
+
+		String jdbcDriverClass = page3.textEntries[0].getText().trim();
+		Option jdbcDriverClassopt = createOption("jdbcDriver",
+			jdbcDriverClass);
+
+		String jdbcURL = page3.textEntries[1].getText().trim();
+		Option jdbcURLopt = createOption("jdbcURL", jdbcURL);
+
+		String userName = page3.textEntries[2].getText().trim();
+		Option userNameopt = createOption("jdbcUser", userName);
+
+		String password = page3.textEntries[3].getText().trim();
+		Option passwordopt = createOption("jdbcPassword", password);
+
+		loginModule.getOption().add(jdbcDriverClassopt);
+		loginModule.getOption().add(jdbcURLopt);
+		loginModule.getOption().add(userNameopt);
+		loginModule.getOption().add(passwordopt);
+
+	    }
+
+	    loginModule.getOption().add(selectUsersopt);
+	    loginModule.getOption().add(selectGroupsopt);
+	    loginModule.getOption().add(algorithmopt);
+	    loginModule.getOption().add(encodingopt);
+
+	} else if (realmType.equals("LDAP Realm")) {
+	    loginModule
+		    .setLoginModuleClass("org.apache.geronimo.security.realm.providers.LDAPLoginModule");
+	    String initialContextFactory = page4.combo[0].getText().trim();
+	    loginModule.getOption()
+		    .add(
+			    createOption("initialContextFactory",
+				    initialContextFactory));
+	    String connectionURL = page4.combo[1].getText();
+	    loginModule.getOption().add(
+		    createOption("connectionURL", connectionURL));
+	    String connectionUsername = page4.text[0].getText();
+	    loginModule.getOption().add(
+		    createOption("connectionUsername", connectionUsername));
+	    String connectionPassword = page4.text[1].getText();
+	    loginModule.getOption().add(
+		    createOption("connectionPassword", connectionPassword));
+	    String connectionProtocol = page4.text[3].getText();
+	    loginModule.getOption().add(
+		    createOption("connectionProtocol", connectionProtocol));
+	    String authentication = page4.combo[2].getText();
+	    loginModule.getOption().add(
+		    createOption("authentication", authentication));
+
+	    String userBase = page5.text[0].getText();
+	    loginModule.getOption().add(createOption("userBase", userBase));
+	    String userSearchMatching = page5.text[1].getText();
+	    loginModule.getOption().add(
+		    createOption("userSearchMatching", userSearchMatching));
+	    String userSearchSubtree = Boolean.toString(page5.userSearchSubtree
+		    .getSelection());
+	    loginModule.getOption().add(
+		    createOption("userSearchSubtree", userSearchSubtree));
+	    String roleBase = page5.text[2].getText();
+	    loginModule.getOption().add(createOption("roleBase", roleBase));
+	    String roleName = page5.text[3].getText();
+	    loginModule.getOption().add(createOption("roleName", roleName));
+	    String roleSearchMatching = page5.text[4].getText();
+	    loginModule.getOption().add(
+		    createOption("roleSearchMatching", roleSearchMatching));
+	    String userRoleName = page5.text[5].getText();
+	    loginModule.getOption().add(
+		    createOption("userRoleName", userRoleName));
+	    String roleSearchSubtree = Boolean.toString(page5.roleSearchSubtree
+		    .getSelection());
+	    loginModule.getOption().add(
+		    createOption("roleSearchSubtree", roleSearchSubtree));
+	}
+
+	if (isedit)
+	    return true;
+
+	// is add, need to add the gbean into plan
+	Object planValue = plan.getValue();
+	if (Application.class.isInstance(planValue)) {
+	    Application application = (Application) planValue;
+
+	    // set dependency
+	    Environment env = application.getEnvironment();
+	    if (env == null) {
+		env = new Environment();
+		application.setEnvironment(env);
+	    }
+	    setDependency(env);
+
+	    // add the gbean into plan
+	    JAXBElement<Gbean> gbeanElement = objectFactory.createGbean(gbean);
+	    application.getService().add(gbeanElement);
+	} else if (WebApp.class.isInstance(planValue)) {
+	    WebApp webapp = (WebApp) planValue;
+
+	    // set dependency
+	    Environment env = webapp.getEnvironment();
+	    if (env == null) {
+		env = new Environment();
+		webapp.setEnvironment(env);
+	    }
+	    setDependency(env);
+
+	    // add the gbean into plan
+	    JAXBElement<Gbean> gbeanElement = objectFactory.createGbean(gbean);
+	    webapp.getServiceOrPersistence().add(gbeanElement);
+	} else if (OpenejbJar.class.isInstance(planValue)) {
+	    OpenejbJar openejbJar = (OpenejbJar) planValue;
+
+	    // set dependency
+	    Environment env = openejbJar.getEnvironment();
+	    if (env == null) {
+		env = new Environment();
+		openejbJar.setEnvironment(env);
+	    }
+	    setDependency(env);
+
+	    // add the gbean into plan
+	    JAXBElement<Gbean> gbeanElement = objectFactory.createGbean(gbean);
+	    openejbJar.getService().add(gbeanElement);
+	}
+
+	return true;
+    }
+
+    private void setDependency(Environment env) {
+	Dependencies dependencies = env.getDependencies();
+	if (dependencies == null) {
+	    dependencies = new Dependencies();
+	    env.setDependencies(dependencies);
+	}
+	Dependency securityDependency = new Dependency();
+	securityDependency.setGroupId("org.apache.geronimo.framework");
+	securityDependency.setArtifactId("j2ee-security");
+	securityDependency.setType("car");
+	if (!dependencies.getDependency().contains(securityDependency)) {
+	    dependencies.getDependency().add(securityDependency);
+	}
+    }
+
+    private Option createOption(String name, String value) {
+	Option option = new Option();
+	option.setName(name);
+	option.setValue(value);
+	return option;
+    }
+
+    private JAXBElement<Attribute> getAttributeElement(List<JAXBElement<?>> list) {
+	for (JAXBElement<?> ele : list) {
+	    if (Attribute.class.isInstance(ele.getValue())
+		    && ((Attribute) ele.getValue()).getName().equals(
+			    "realmName")) {
+		return (JAXBElement<Attribute>) ele;
+	    }
+	}
+	return null;
+    }
+
+    private JAXBElement<Reference> getReferenceElement(List<JAXBElement<?>> list) {
+	for (JAXBElement<?> ele : list) {
+	    if (Reference.class.isInstance(ele.getValue())
+		    && ((Reference) ele.getValue()).getName().equals(
+			    "ServerInfo")) {
+		return (JAXBElement<Reference>) ele;
+	    }
+	}
+	return null;
+    }
+
+    private JAXBElement<XmlAttributeType> getXmlReferenceElement(
+	    List<JAXBElement<?>> list) {
+	for (JAXBElement<?> ele : list) {
+	    if (XmlAttributeType.class.isInstance(ele.getValue())
+		    && ((XmlAttributeType) ele.getValue()).getName().equals(
+			    "LoginModuleConfiguration")) {
+		return (JAXBElement<XmlAttributeType>) ele;
+	    }
+	}
+	return null;
+    }
+
+    public class SecurityRealmBasicPage extends WizardPage {
+	private int recordedRealmType = -2;
+
+	Text textEntries[] = new Text[1];
+	Combo combo = null;
+
+	public SecurityRealmBasicPage(String pageName) {
+	    super(pageName);
+	    setTitle(CommonMessages.wizardFirstPageTitle_SecurityRealm);
+	    setDescription(CommonMessages.wizardFirstPageDescription_SecurityRealm);
+	}
+
+	public void createControl(Composite parent) {
+	    Composite composite = new Composite(parent, SWT.NULL);
+	    GridLayout layout = new GridLayout();
+	    layout.numColumns = 2;
+	    composite.setLayout(layout);
+	    GridData data = new GridData();
+	    data.verticalAlignment = GridData.FILL;
+	    data.horizontalAlignment = GridData.FILL;
+	    data.widthHint = 300;
+	    composite.setLayoutData(data);
+
+	    Group basicGroup = new Group(composite, SWT.NONE);
+	    basicGroup.setText("Basic Settings");
+	    GridLayout gridLayout = new GridLayout();
+	    gridLayout.numColumns = 4;
+	    GridData data1 = new GridData();
+	    data1.horizontalAlignment = GridData.FILL;
+	    data1.grabExcessHorizontalSpace = true;
+	    data1.grabExcessVerticalSpace = true;
+	    data1.horizontalSpan = 2;
+	    basicGroup.setLayout(gridLayout);
+	    data1.grabExcessHorizontalSpace = true;
+	    basicGroup.setLayoutData(data1);
+	    createLabel(basicGroup, CommonMessages.realmName, 1);
+	    textEntries[0] = createText(basicGroup, 3);
+	    createLabel(basicGroup, CommonMessages.realmType, 1);
+	    combo = new Combo(basicGroup, SWT.NONE | SWT.READ_ONLY);
+	    combo.setLayoutData(new GridData(GridData.FILL, GridData.FILL,
+		    true, false, 3, 1));
+	    combo.add("Properties File Realm");
+	    combo.add("SQL Realm");
+	    combo.add("LDAP Realm");
+	    combo.select(0);
+
+	    if (eObject != null) {
+		Gbean gbean = (Gbean) ((JAXBElement) eObject).getValue();
+		String realmName = getAttributeValue(gbean, "realmName");
+		this.textEntries[0].setText(realmName == null ? "" : realmName);
+		String loginModuleClass = getLoginModuleClass(gbean);
+		if ("org.apache.geronimo.security.realm.providers.PropertiesFileLoginModule"
+			.equals(loginModuleClass)) {
+		    this.combo.select(0);
+		} else if ("org.apache.geronimo.security.realm.providers.SQLLoginModule"
+			.equals(loginModuleClass)) {
+		    this.combo.select(1);
+		} else if ("org.apache.geronimo.security.realm.providers.LDAPLoginModule"
+			.equals(loginModuleClass)) {
+		    this.combo.select(2);
+		}
+	    }
+	    setControl(composite);
+	}
+
+	public int getRecordedRealmType() {
+	    return recordedRealmType;
+	}
+
+	public void setRecordedRealmType(int recordedRealmType) {
+	    this.recordedRealmType = recordedRealmType;
+	}
+
+	public int getRealmTypeSelectionIndex() {
+	    if (combo != null) {
+		return combo.getSelectionIndex();
+	    } else {
+		return -1;
+	    }
+	}
+
+	@Override
+	public IWizardPage getNextPage() {
+	    if (combo.getText().trim().equals("Properties File Realm")) {// properties
+		// file
+		// type
+		return this.getWizard().getPage("PropertiesFileRealmPage");
+	    } else if (combo.getText().trim().equals("SQL Realm")) {// sql realm
+		// type
+		return this.getWizard().getPage("SelectSQLPage");
+	    } else if (combo.getText().trim().equals("LDAP Realm")) {// ldap
+		// realm
+		// type
+		return this.getWizard().getPage("LDAPConnectionPage");
+	    }
+	    return null;
+	}
+    }
+
+    public class PropertiesFileRealmPage extends WizardPage {
+
+	Text textEntries[] = new Text[4];
+
+	public PropertiesFileRealmPage(String pageName) {
+	    super(pageName);
+	    setTitle("Properties File Realm");
+	    setDescription("Edit settings for users file and groups file's pathes");
+	}
+
+	public void createControl(Composite parent) {
+	    Composite composite = new Composite(parent, SWT.NULL);
+	    GridLayout layout = new GridLayout();
+	    layout.numColumns = 2;
+	    composite.setLayout(layout);
+	    GridData data = new GridData();
+	    data.verticalAlignment = GridData.FILL;
+	    data.horizontalAlignment = GridData.FILL;
+	    data.widthHint = 300;
+	    composite.setLayoutData(data);
+
+	    Group uriGroup = new Group(composite, SWT.NONE);
+	    uriGroup.setText("Files's URI");
+	    GridLayout gridLayout = new GridLayout();
+	    gridLayout.numColumns = 4;
+	    uriGroup.setLayout(gridLayout);
+	    GridData data1 = new GridData();
+	    data1.horizontalAlignment = GridData.FILL;
+	    data1.grabExcessHorizontalSpace = true;
+	    data1.grabExcessVerticalSpace = true;
+	    data1.horizontalSpan = 2;
+	    data1.grabExcessHorizontalSpace = true;
+	    uriGroup.setLayoutData(data1);
+	    createLabel(uriGroup, "Users File URI:", 1);
+	    textEntries[0] = createText(uriGroup, 3);
+	    createLabel(uriGroup, "Groups File URI:", 1);
+	    textEntries[1] = createText(uriGroup, 3);
+
+	    Group digestGroup = new Group(composite, SWT.NONE);
+	    digestGroup.setText("Digest Configuration");
+	    gridLayout = new GridLayout();
+	    gridLayout.numColumns = 4;
+	    digestGroup.setLayout(gridLayout);
+	    data1 = new GridData();
+	    data1.horizontalAlignment = GridData.FILL;
+	    data1.grabExcessHorizontalSpace = true;
+	    data1.grabExcessVerticalSpace = true;
+	    data1.horizontalSpan = 2;
+	    data1.grabExcessHorizontalSpace = true;
+	    digestGroup.setLayoutData(data1);
+	    createLabel(digestGroup, "Digest Algorithm:", 1);
+	    textEntries[2] = createText(digestGroup, 3);
+	    createLabel(digestGroup, "Digest Encoding:", 1);
+	    textEntries[3] = createText(digestGroup, 3);
+
+	    if (eObject != null) {
+		Gbean gbean = (Gbean) ((JAXBElement) eObject).getValue();
+		if (getOptionValue(gbean, "usersURI") != null) {
+		    textEntries[0].setText(getOptionValue(gbean, "usersURI"));
+		}
+		if (getOptionValue(gbean, "groupsURI") != null) {
+		    textEntries[1].setText(getOptionValue(gbean, "groupsURI"));
+		}
+		if (getOptionValue(gbean, "digest") != null) {
+		    textEntries[2].setText(getOptionValue(gbean, "digest"));
+		}
+		if (getOptionValue(gbean, "encoding") != null) {
+		    textEntries[3].setText(getOptionValue(gbean, "encoding"));
+		}
+	    }
+
+	    setControl(composite);
+	}
+
+	public boolean canFlipToNextPage() {
+	    // no next page for this path through the wizard
+	    return false;
+	}
+
+	public IWizardPage getNextPage() {
+	    return null;
+	}
+    }
+
+    public class SelectSQLPage extends WizardPage {
+
+	Text textEntries[] = new Text[4];
+
+	public SelectSQLPage(String pageName) {
+	    super(pageName);
+	    setTitle("SQL Realm");
+	    setDescription("Edit settings for user and group select sql");
+	}
+
+	public void createControl(Composite parent) {
+	    Composite composite = new Composite(parent, SWT.NULL);
+	    GridLayout layout = new GridLayout();
+	    layout.numColumns = 2;
+	    composite.setLayout(layout);
+	    GridData data = new GridData();
+	    data.verticalAlignment = GridData.FILL;
+	    data.horizontalAlignment = GridData.FILL;
+	    data.widthHint = 300;
+	    composite.setLayoutData(data);
+
+	    Group uriGroup = new Group(composite, SWT.NONE);
+	    uriGroup.setText("Select SQL");
+	    GridLayout gridLayout = new GridLayout();
+	    gridLayout.numColumns = 4;
+	    uriGroup.setLayout(gridLayout);
+	    GridData data1 = new GridData();
+	    data1.horizontalAlignment = GridData.FILL;
+	    data1.grabExcessHorizontalSpace = true;
+	    data1.grabExcessVerticalSpace = true;
+	    data1.horizontalSpan = 2;
+	    data1.grabExcessHorizontalSpace = true;
+	    uriGroup.setLayoutData(data1);
+	    createLabel(uriGroup, "Users Select SQL:", 1);
+	    textEntries[0] = createText(uriGroup, 3);
+	    createLabel(uriGroup, "Groups Select SQL:", 1);
+	    textEntries[1] = createText(uriGroup, 3);
+
+	    Group digestGroup = new Group(composite, SWT.NONE);
+	    digestGroup.setText("Digest Configuration");
+	    gridLayout = new GridLayout();
+	    gridLayout.numColumns = 4;
+	    digestGroup.setLayout(gridLayout);
+	    data1 = new GridData();
+	    data1.horizontalAlignment = GridData.FILL;
+	    data1.grabExcessHorizontalSpace = true;
+	    data1.grabExcessVerticalSpace = true;
+	    data1.horizontalSpan = 2;
+	    data1.grabExcessHorizontalSpace = true;
+	    digestGroup.setLayoutData(data1);
+	    createLabel(digestGroup, "Digest Algorithm:", 1);
+	    textEntries[2] = createText(digestGroup, 3);
+	    createLabel(digestGroup, "Digest Encoding:", 1);
+	    textEntries[3] = createText(digestGroup, 3);
+
+	    if (eObject != null) {
+		Gbean gbean = (Gbean) ((JAXBElement) eObject).getValue();
+		if (getOptionValue(gbean, "userSelect") != null) {
+		    textEntries[0].setText(getOptionValue(gbean, "userSelect"));
+		}
+		if (getOptionValue(gbean, "groupSelect") != null) {
+		    textEntries[1]
+			    .setText(getOptionValue(gbean, "groupSelect"));
+		}
+		if (getOptionValue(gbean, "digest") != null) {
+		    textEntries[2].setText(getOptionValue(gbean, "digest"));
+		}
+		if (getOptionValue(gbean, "encoding") != null) {
+		    textEntries[3].setText(getOptionValue(gbean, "encoding"));
+		}
+	    }
+
+	    setControl(composite);
+	}
+
+	@Override
+	public IWizardPage getNextPage() {
+	    return this.getWizard().getPage("DBConnectionPage");
+	}
+
+    }
+
+    public class DBConnectionPage extends WizardPage {
+
+	Text textEntries[] = new Text[5];
+	Button buttons[] = new Button[2];
+	Combo dataBasePoolCombo;
+
+	protected DBConnectionPage(String pageName) {
+	    super(pageName);
+	    setTitle(CommonMessages.wizardSecondPageTitle_SecurityRealm);
+	    setDescription(CommonMessages.wizardSecondPageDescription_SecurityRealm);
+	}
+
+	public void createControl(Composite parent) {
+	    Composite composite = new Composite(parent, SWT.NULL);
+	    GridLayout layout = new GridLayout();
+	    layout.numColumns = 2;
+	    composite.setLayout(layout);
+	    GridData data = new GridData();
+	    data.verticalAlignment = GridData.FILL;
+	    data.horizontalAlignment = GridData.FILL;
+	    data.widthHint = 300;
+	    composite.setLayoutData(data);
+
+	    Group databasePoolGroup = new Group(composite, SWT.NONE);
+	    databasePoolGroup.setText(CommonMessages.dataBasePool);
+	    GridLayout gridLayout = new GridLayout();
+	    gridLayout.numColumns = 4;
+	    GridData data1 = new GridData();
+	    data1.horizontalAlignment = GridData.FILL;
+	    data1.grabExcessHorizontalSpace = true;
+	    data1.horizontalSpan = 2;
+	    databasePoolGroup.setLayout(gridLayout);
+	    databasePoolGroup.setLayoutData(data1);
+	    buttons[0] = new Button(databasePoolGroup, SWT.RADIO);
+	    buttons[0].setSelection(true);
+	    buttons[0].setText(CommonMessages.useDataBasePool);
+	    buttons[0].setLayoutData(new GridData(GridData.FILL,
+		    GridData.CENTER, true, false, 4, 1));
+	    buttons[0].addSelectionListener(new SelectionAdapter() {
+		public void widgetSelected(SelectionEvent event) {
+		    buttons[1].setSelection(false);
+		    dataBasePoolCombo.setEnabled(true);
+		    for (int i = 0; i < textEntries.length; i++) {
+			textEntries[i].setEnabled(false);
+		    }
+		}
+	    });
+	    createLabel(databasePoolGroup, CommonMessages.dataBasePoolName, 1);
+	    dataBasePoolCombo = new Combo(databasePoolGroup, SWT.NONE);
+	    dataBasePoolCombo.setLayoutData(new GridData(GridData.FILL,
+		    GridData.FILL, true, false, 3, 1));
+	    populateList(dataBasePoolCombo);
+	    dataBasePoolCombo.select(0);
+
+	    GridData data2 = new GridData();
+	    data2.horizontalAlignment = GridData.FILL;
+	    data2.grabExcessHorizontalSpace = true;
+	    data2.horizontalSpan = 2;
+	    Group databaseGroup = new Group(composite, SWT.NONE);
+	    databaseGroup.setLayout(gridLayout);
+	    databaseGroup.setLayoutData(data2);
+	    buttons[1] = new Button(databaseGroup, SWT.RADIO);
+	    buttons[1].setText(CommonMessages.useDataBase);
+	    buttons[1].setLayoutData(new GridData(GridData.FILL, GridData.FILL,
+		    true, false, 4, 1));
+	    buttons[1].addSelectionListener(new SelectionAdapter() {
+		public void widgetSelected(SelectionEvent event) {
+		    buttons[0].setSelection(false);
+		    dataBasePoolCombo.setEnabled(false);
+		    for (int i = 0; i < textEntries.length; i++) {
+			textEntries[i].setEnabled(true);
+		    }
+		}
+	    });
+	    createLabel(databaseGroup, CommonMessages.jdbcDriverClass, 1);
+	    textEntries[0] = createText(databaseGroup, 3);
+
+	    createLabel(databaseGroup, CommonMessages.jdbcURL, 1);
+	    textEntries[1] = createText(databaseGroup, 3);
+	    createLabel(databaseGroup, CommonMessages.jdbcUserName, 1);
+	    textEntries[2] = createText(databaseGroup, 3);
+	    createLabel(databaseGroup, CommonMessages.jdbcPassword, 1);
+	    textEntries[3] = createText(databaseGroup, 1);
+	    textEntries[3].setEchoChar('*');
+	    createLabel(databaseGroup, CommonMessages.confirmPassword, 1);
+	    textEntries[4] = createText(databaseGroup, 1);
+	    textEntries[4].setEchoChar('*');
+
+	    dataBasePoolCombo.setEnabled(true);
+	    for (int i = 0; i < textEntries.length; i++) {
+		textEntries[i].setEnabled(false);
+	    }
+
+	    if (eObject != null) {
+		Gbean gbean = (Gbean) ((JAXBElement) eObject).getValue();
+		if (getOptionValue(gbean, "dataSourceName") != null) {
+		    this.buttons[0].setSelection(true);
+		    this.dataBasePoolCombo.setEnabled(true);
+		    this.dataBasePoolCombo.setText(getOptionValue(gbean,
+			    "dataSourceName"));
+
+		    this.buttons[1].setSelection(false);
+		    for (int i = 0; i < textEntries.length; i++) {
+			this.textEntries[i].setEnabled(false);
+		    }
+
+		} else {
+		    this.buttons[1].setSelection(true);
+		    this.buttons[0].setSelection(false);
+		    this.dataBasePoolCombo.setEnabled(false);
+		    for (int i = 0; i < textEntries.length; i++) {
+			textEntries[i].setEnabled(true);
+		    }
+
+		    if (getOptionValue(gbean, "jdbcDriver") != null) {
+			this.textEntries[0].setText(getOptionValue(gbean,
+				"jdbcDriver"));
+		    }
+		    if (getOptionValue(gbean, "jdbcURL") != null) {
+			this.textEntries[1].setText(getOptionValue(gbean,
+				"jdbcURL"));
+		    }
+		    if (getOptionValue(gbean, "jdbcUser") != null) {
+			this.textEntries[2].setText(getOptionValue(gbean,
+				"jdbcUser"));
+		    }
+		    if (getOptionValue(gbean, "jdbcPassword") != null) {
+			this.textEntries[3].setText(getOptionValue(gbean,
+				"jdbcPassword"));
+			this.textEntries[4].setText(getOptionValue(gbean,
+				"jdbcPassword"));
+		    }
+		}
+
+	    }
+
+	    setControl(composite);
+
+	}
+
+	private void populateList(Combo combo) {
+	    ArrayList<Pattern> dbPool = GeronimoServerInfo.getInstance()
+		    .getJdbcConnectionPools();
+	    for (int i = 0; i < dbPool.size(); i++) {
+		String str = dbPool.get(i).getName();
+		combo.add(str);
+	    }
+	}
+
+	public boolean canFlipToNextPage() {
+	    // no next page for this path through the wizard
+	    return false;
+	}
+
+	public IWizardPage getNextPage() {
+	    return null;
+	}
+    }
+
+    public class LDAPConnectionPage extends WizardPage {
+	Text[] text = new Text[4];
+	Combo[] combo = new Combo[3];
+
+	protected LDAPConnectionPage(String pageName) {
+	    super(pageName);
+	    setTitle("LDAP Realm Connection");
+	    setDescription("Edit settings for LDAP server connection");
+	}
+
+	public void createControl(Composite parent) {
+	    Composite composite = new Composite(parent, SWT.NULL);
+	    GridLayout layout = new GridLayout();
+	    layout.numColumns = 2;
+	    composite.setLayout(layout);
+	    GridData data = new GridData();
+	    data.verticalAlignment = GridData.FILL;
+	    data.horizontalAlignment = GridData.FILL;
+	    data.widthHint = 300;
+	    composite.setLayoutData(data);
+
+	    Group connectionGroup = new Group(composite, SWT.NULL);
+	    connectionGroup.setText("LDAP server connection");
+	    GridLayout gridLayout = new GridLayout();
+	    gridLayout.numColumns = 4;
+	    GridData data1 = new GridData();
+	    data1.horizontalAlignment = GridData.FILL;
+	    data1.grabExcessHorizontalSpace = true;
+	    data1.horizontalSpan = 2;
+	    connectionGroup.setLayout(gridLayout);
+	    connectionGroup.setLayoutData(data1);
+
+	    createLabel(connectionGroup, "Initial Context Factory:", 1);
+	    combo[0] = new Combo(connectionGroup, SWT.NONE);
+	    combo[0].setLayoutData(new GridData(GridData.FILL, GridData.FILL,
+		    true, false, 3, 1));
+	    combo[0].add("com.sun.jndi.ldap.LdapCtxFactory");
+	    createLabel(connectionGroup, "Connection URL:", 1);
+	    combo[1] = new Combo(connectionGroup, SWT.NONE);
+	    combo[1].setLayoutData(new GridData(GridData.FILL, GridData.FILL,
+		    true, false, 3, 1));
+	    combo[1].add("ldap://localhost:1389");
+	    combo[1].add("ldap://localhost:389");
+	    createLabel(connectionGroup, "Connect Username:", 1);
+	    text[0] = createText(connectionGroup, 3);
+	    text[0].setText("system");
+	    createLabel(connectionGroup, "Connect Password:", 1);
+	    text[1] = createText(connectionGroup, 3);
+	    text[1].setEchoChar('*');
+	    text[1].setText("manager");
+	    createLabel(connectionGroup, "Confirm Password:", 1);
+	    text[2] = createText(connectionGroup, 3);
+	    text[2].setEchoChar('*');
+	    text[2].setText("manager");
+	    createLabel(connectionGroup, "Connect Protocol:", 1);
+	    text[3] = createText(connectionGroup, 1);
+	    createLabel(connectionGroup, "Authentication:", 1);
+	    combo[2] = new Combo(connectionGroup, SWT.NONE);
+	    combo[2].setLayoutData(new GridData(GridData.FILL, GridData.FILL,
+		    true, false, 1, 1));
+	    combo[2].add("none");
+	    combo[2].add("simple");
+	    combo[2].add("strong");
+	    combo[2].select(1);
+
+	    if (eObject != null) {
+		Gbean gbean = (Gbean) ((JAXBElement) eObject).getValue();
+		if (getOptionValue(gbean, "initialContextFactory") != null) {
+		    this.combo[0].setText(getOptionValue(gbean,
+			    "initialContextFactory"));
+		}
+		if (getOptionValue(gbean, "connectionURL") != null) {
+		    this.combo[1]
+			    .setText(getOptionValue(gbean, "connectionURL"));
+		}
+		if (getOptionValue(gbean, "connectionUsername") != null) {
+		    this.text[0].setText(getOptionValue(gbean,
+			    "connectionUsername"));
+		}
+		if (getOptionValue(gbean, "connectionPassword") != null) {
+		    this.text[1].setText(getOptionValue(gbean,
+			    "connectionPassword"));
+		    this.text[2].setText(getOptionValue(gbean,
+			    "connectionPassword"));
+		}
+		if (getOptionValue(gbean, "connectionProtocol") != null) {
+		    this.text[3].setText(getOptionValue(gbean,
+			    "connectionProtocol"));
+		}
+		if (getOptionValue(gbean, "authentication") != null) {
+		    this.combo[2].setText(getOptionValue(gbean,
+			    "authentication"));
+		}
+
+	    }
+
+	    setControl(composite);
+	}
+
+	public IWizardPage getNextPage() {
+	    return this.getWizard().getPage("LDAPSearchPage");
+	}
+
+    }
+
+    public class LDAPSearchPage extends WizardPage {
+	Text[] text = new Text[6];
+	Button userSearchSubtree, roleSearchSubtree;
+
+	protected LDAPSearchPage(String pageName) {
+	    super(pageName);
+	    setTitle("LDAP Realm Search Configuration");
+	    setDescription("Edit settings for LDAP realm search");
+	}
+
+	public void createControl(Composite parent) {
+	    Composite composite = new Composite(parent, SWT.NULL);
+	    GridLayout layout = new GridLayout();
+	    layout.numColumns = 2;
+	    composite.setLayout(layout);
+	    GridData data = new GridData();
+	    data.verticalAlignment = GridData.FILL;
+	    data.horizontalAlignment = GridData.FILL;
+	    data.widthHint = 300;
+	    composite.setLayoutData(data);
+
+	    Group userGroup = new Group(composite, SWT.NULL);
+	    userGroup.setText("User Search Configuration");
+	    GridLayout gridLayout = new GridLayout();
+	    gridLayout.numColumns = 4;
+	    GridData data1 = new GridData();
+	    data1.horizontalAlignment = GridData.FILL;
+	    data1.grabExcessHorizontalSpace = true;
+	    data1.horizontalSpan = 2;
+	    userGroup.setLayout(gridLayout);
+	    userGroup.setLayoutData(data1);
+
+	    createLabel(userGroup, "User Base:", 1);
+	    text[0] = createText(userGroup, 3);
+	    createLabel(userGroup, "User Search Matching:", 1);
+	    text[1] = createText(userGroup, 3);
+	    userSearchSubtree = new Button(userGroup, SWT.CHECK);
+	    userSearchSubtree.setText("User Search Subtree");
+	    userSearchSubtree.setLayoutData(new GridData(GridData.FILL,
+		    GridData.FILL, true, false, 4, 1));
+	    userSearchSubtree.setSelection(true);
+
+	    Group roleGroup = new Group(composite, SWT.NULL);
+	    roleGroup.setText("Role Search Configuration");
+	    gridLayout = new GridLayout();
+	    gridLayout.numColumns = 4;
+	    data1 = new GridData();
+	    data1.horizontalAlignment = GridData.FILL;
+	    data1.grabExcessHorizontalSpace = true;
+	    data1.horizontalSpan = 2;
+	    roleGroup.setLayout(gridLayout);
+	    roleGroup.setLayoutData(data1);
+	    createLabel(roleGroup, "Role Base:", 1);
+	    text[2] = createText(roleGroup, 3);
+	    createLabel(roleGroup, "Role Name:", 1);
+	    text[3] = createText(roleGroup, 3);
+	    createLabel(roleGroup, "Role User Search String:", 1);
+	    text[4] = createText(roleGroup, 3);
+	    createLabel(roleGroup, "User Role Search String:", 1);
+	    text[5] = createText(roleGroup, 3);
+	    roleSearchSubtree = new Button(roleGroup, SWT.CHECK);
+	    roleSearchSubtree.setText("Role Search Subtree");
+	    roleSearchSubtree.setLayoutData(new GridData(GridData.FILL,
+		    GridData.FILL, true, false, 4, 1));
+	    roleSearchSubtree.setSelection(true);
+
+	    if (eObject != null) {
+		Gbean gbean = (Gbean) ((JAXBElement<?>) eObject).getValue();
+		if (getOptionValue(gbean, "userBase") != null) {
+		    text[0].setText(getOptionValue(gbean, "userBase"));
+		}
+		if (getOptionValue(gbean, "userSearchMatching") != null) {
+		    text[1]
+			    .setText(getOptionValue(gbean, "userSearchMatching"));
+		}
+		if (getOptionValue(gbean, "userSearchSubtree") != null) {
+		    this.userSearchSubtree.setSelection(Boolean
+			    .parseBoolean(getOptionValue(gbean,
+				    "userSearchSubtree")));
+		}
+		if (getOptionValue(gbean, "roleBase") != null) {
+		    text[2].setText(getOptionValue(gbean, "roleBase"));
+		}
+		if (getOptionValue(gbean, "roleName") != null) {
+		    text[3].setText(getOptionValue(gbean, "roleName"));
+		}
+		if (getOptionValue(gbean, "roleSearchMatching") != null) {
+		    text[4]
+			    .setText(getOptionValue(gbean, "roleSearchMatching"));
+		}
+		if (getOptionValue(gbean, "userRoleName") != null) {
+		    text[5].setText(getOptionValue(gbean, "userRoleName"));
+		}
+		if (getOptionValue(gbean, "roleSearchSubtree") != null) {
+		    this.userSearchSubtree.setSelection(Boolean
+			    .parseBoolean(getOptionValue(gbean,
+				    "roleSearchSubtree")));
+		}
+	    }
+
+	    setControl(composite);
+	}
+
+	public boolean canFlipToNextPage() {
+	    // no next page for this path through the wizard
+	    return false;
+	}
+
+	public IWizardPage getNextPage() {
+	    return null;
+	}
+
+    }
+
+    private String getAttributeValue(Gbean gbean, String attributeName) {
+	try {
+	    List<JAXBElement<?>> elelist = gbean
+		    .getAttributeOrXmlAttributeOrReference();
+	    for (JAXBElement<?> ele : elelist) {
+		if (Attribute.class.isInstance(ele.getValue())
+			&& ((Attribute) ele.getValue()).getName().equals(
+				attributeName)) {
+		    return ((Attribute) ele.getValue()).getValue();
+		}
+	    }
+	} catch (NullPointerException e) {
+	    // ignore
+	}
+	return null;
+    }
+
+    private String getLoginModuleClass(Gbean gbean) {
+
+	try {
+	    List<JAXBElement<?>> elelist = gbean
+		    .getAttributeOrXmlAttributeOrReference();
+	    for (JAXBElement<?> ele : elelist) {
+		if (XmlAttributeType.class.isInstance(ele.getValue())
+			&& ((XmlAttributeType) ele.getValue()).getName()
+				.equals("LoginModuleConfiguration")) {
+		    LoginModule loginModule = (LoginModule) ((LoginConfig) ((XmlAttributeType) ele
+			    .getValue()).getAny())
+			    .getLoginModuleRefOrLoginModule().get(0);
+		    return loginModule.getLoginModuleClass();
+		}
+	    }
+	    return null;
+	} catch (NullPointerException e) {
+	    // ignore
+	}
+
+	return null;
+    }
+
+    private String getOptionValue(Gbean gbean, String optionName) {
+	try {
+	    List<JAXBElement<?>> elelist = gbean
+		    .getAttributeOrXmlAttributeOrReference();
+	    for (JAXBElement<?> ele : elelist) {
+		if (XmlAttributeType.class.isInstance(ele.getValue())
+			&& ((XmlAttributeType) ele.getValue()).getName()
+				.equals("LoginModuleConfiguration")) {
+		    LoginModule loginModule = (LoginModule) ((LoginConfig) ((XmlAttributeType) ele
+			    .getValue()).getAny())
+			    .getLoginModuleRefOrLoginModule().get(0);
+		    List<Option> options = loginModule.getOption();
+		    for (Option opt : options) {
+			if (opt.getName().equals(optionName))
+			    return opt.getValue();
+		    }
+		}
+	    }
+	    return null;
+	} catch (NullPointerException e) {
+	    // ignore
+	}
+
+	return null;
+    }
+
+    protected Label createLabel(Composite composite, String value, int span) {
+	Label label = new Label(composite, SWT.NONE);
+	label.setText(value);
+	GridData labelData = new GridData();
+	labelData.horizontalAlignment = GridData.FILL;
+	labelData.horizontalSpan = span;
+	label.setLayoutData(labelData);
+	return label;
+    }
+
+    protected Text createText(Composite composite, int span) {
+	Text text = new Text(composite, SWT.BORDER);
+	GridData textData = new GridData(GridData.HORIZONTAL_ALIGN_FILL
+		| GridData.VERTICAL_ALIGN_FILL);
+	textData.grabExcessHorizontalSpace = true;
+	textData.widthHint = 100;
+	textData.horizontalSpan = span;
+	text.setLayoutData(textData);
+	return text;
+    }
+}

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

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

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

Added: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.ui/src/main/java/org/apache/geronimo/st/v21/ui/wizards/SecurityRoleMappingWizard.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/v21/ui/wizards/SecurityRoleMappingWizard.java?rev=921247&view=auto
==============================================================================
--- geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.ui/src/main/java/org/apache/geronimo/st/v21/ui/wizards/SecurityRoleMappingWizard.java (added)
+++ geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.ui/src/main/java/org/apache/geronimo/st/v21/ui/wizards/SecurityRoleMappingWizard.java Wed Mar 10 08:31:28 2010
@@ -0,0 +1,234 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.geronimo.st.v21.ui.wizards;
+
+import java.util.List;
+
+import org.apache.geronimo.jee.security.DistinguishedName;
+import org.apache.geronimo.jee.security.LoginDomainPrincipal;
+import org.apache.geronimo.jee.security.Principal;
+import org.apache.geronimo.jee.security.RealmPrincipal;
+import org.apache.geronimo.jee.security.Role;
+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.v21.core.GeronimoServerInfo;
+import org.apache.geronimo.st.v21.core.jaxb.JAXBObjectFactoryImpl;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.widgets.Combo;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Text;
+
+/**
+ *  @version $Rev$ $Date$
+ */
+public class SecurityRoleMappingWizard extends AbstractWizard {
+    public static final String[] PRINCIPAL_CLASSES = {
+            "org.apache.geronimo.security.realm.providers.GeronimoGroupPrincipal",
+            "org.apache.geronimo.security.realm.providers.GeronimoUserPrincipal" };
+
+    private final int DISTINGUISHED_NAME = 0;
+    private final int PRINCIPAL = 1;
+    private final int LOGIN_DOMAIN_PRINCIPAL = 2;
+    private final int REALM_PRINCIPAL = 3;
+    private final String[] ROLE_MAPPING_TYPES = {
+            "Distinguished Name", "Principal", "Login Domain Principal", "Realm Principal" };
+
+    protected AbstractTreeSection section;
+    protected Combo type;
+    protected Text name;
+    protected Combo clazz;
+    protected Text domainName;
+    protected Combo realmName;
+    
+    public SecurityRoleMappingWizard(AbstractTreeSection section) {
+        super();
+        this.section = section;
+    }
+
+    protected static String[] getSecurityRealms() {
+        List<String> securityRealms = GeronimoServerInfo.getInstance().getSecurityRealms();
+        return securityRealms.toArray(new String[securityRealms.size()]);
+    }
+
+    public class SecurityRoleMappingsWizardPage extends AbstractWizardPage {
+        protected Label nameLabel, clazzLabel, domainNameLabel, realmNameLabel;
+
+        public SecurityRoleMappingsWizardPage(String pageName) {
+            super(pageName);
+        }
+
+        public void createControl(Composite parent) {
+            Composite composite = createComposite(parent);
+            createLabel(composite, CommonMessages.type);
+            type = createCombo(composite, ROLE_MAPPING_TYPES, false);
+            nameLabel = createLabel(composite, CommonMessages.name);
+            name = createTextField(composite, "");
+            name.setFocus();
+            clazzLabel = createLabel(composite, CommonMessages.className);
+            clazz = createCombo(composite, PRINCIPAL_CLASSES, true);
+            clazz.select(0);
+            domainNameLabel = createLabel(composite, CommonMessages.editorDomainName);
+            domainName = createTextField(composite, "");
+            realmNameLabel = createLabel(composite, CommonMessages.editorRealmName);
+            realmName = createCombo(composite, getSecurityRealms(), true);
+
+            type.addSelectionListener(new SelectionAdapter() {
+                public void widgetSelected(SelectionEvent arg0) {
+                    toggleFields();
+                }
+            });
+            if (eObject == null) {
+                type.select(DISTINGUISHED_NAME);
+            }
+            else {
+                // set the fields to the values in eObject and select the correct type
+                if (DistinguishedName.class.isInstance(eObject)) {
+                    name.setText(((DistinguishedName)eObject).getName());
+                    type.select(DISTINGUISHED_NAME);
+                }
+                else {
+                    name.setText(((Principal)eObject).getName());
+                    clazz.setText(((Principal)eObject).getClazz());
+                    if (LoginDomainPrincipal.class.isInstance(eObject)) {
+                        domainName.setText(((LoginDomainPrincipal)eObject).getDomainName());
+                        if (RealmPrincipal.class.isInstance(eObject)) {
+                            realmName.setText(((RealmPrincipal)eObject).getRealmName());
+                            type.select(REALM_PRINCIPAL);
+                        }
+                        else {
+                            type.select(LOGIN_DOMAIN_PRINCIPAL);
+                        }
+                    }
+                    else {
+                        type.select(PRINCIPAL);
+                    }
+                }
+                type.setEnabled(false);
+            }
+            toggleFields();
+            setControl(composite);
+        }
+
+        private void toggleFields() {
+            int selection = type.getSelectionIndex();
+            clazzLabel.setVisible (selection >= PRINCIPAL ? true : false);
+            clazz.setVisible (selection >= PRINCIPAL ? true : false);
+            domainNameLabel.setVisible (selection >= LOGIN_DOMAIN_PRINCIPAL ? true : false);
+            domainName.setVisible (selection >= LOGIN_DOMAIN_PRINCIPAL ? true : false);
+            realmNameLabel.setVisible (selection == REALM_PRINCIPAL ? true : false);
+            realmName.setVisible (selection == REALM_PRINCIPAL ? true : false);
+        }
+
+        @Override
+        protected String getWizardPageTitle() {
+            return CommonMessages.wizardPageTitle_RoleMapping;
+        }
+
+        @Override
+        protected String getWizardPageDescription() {
+            return CommonMessages.wizardPageDescription_RoleMapping;
+        }
+    }
+
+    @Override
+    public void addPages() {
+        addPage(new SecurityRoleMappingsWizardPage("Page0"));
+    }
+
+    @Override
+    public boolean performFinish() {
+        switch (type.getSelectionIndex()) {
+        case DISTINGUISHED_NAME:
+            if (isEmpty(name.getText())) {
+                return false;
+            }
+            DistinguishedName distinguishedName = (DistinguishedName)eObject;
+            if (distinguishedName == null) {
+                distinguishedName = (DistinguishedName)getEFactory().create(DistinguishedName.class);
+                Role role = (Role) section.getSelectedObject();
+                role.getDistinguishedName().add(distinguishedName);
+            }
+            distinguishedName.setName(name.getText());
+            break;
+
+        case PRINCIPAL:
+            if (isEmpty(name.getText()) || isEmpty(clazz.getText())) {
+                return false;
+            }
+            Principal principal = (Principal)eObject;
+            if (principal == null) {
+                principal = (Principal)getEFactory().create(Principal.class);
+                Role role = (Role) section.getSelectedObject();
+                role.getPrincipal().add(principal);
+            }
+            principal.setName(name.getText());
+            principal.setClazz(clazz.getText());
+            break;
+
+        case LOGIN_DOMAIN_PRINCIPAL:
+            if (isEmpty(name.getText()) || isEmpty(clazz.getText()) || isEmpty(domainName.getText())) {
+                return false;
+            }
+            LoginDomainPrincipal loginDomainPrincipal = (LoginDomainPrincipal)eObject;
+            if (loginDomainPrincipal == null) {
+                loginDomainPrincipal = (LoginDomainPrincipal)getEFactory().create(LoginDomainPrincipal.class);
+                Role role = (Role) section.getSelectedObject();
+                role.getLoginDomainPrincipal().add(loginDomainPrincipal);
+            }
+            loginDomainPrincipal.setName(name.getText());
+            loginDomainPrincipal.setClazz(clazz.getText());
+            loginDomainPrincipal.setDomainName(domainName.getText()); 
+            break;
+
+        case REALM_PRINCIPAL:
+            if (isEmpty(name.getText()) || isEmpty(clazz.getText()) || isEmpty(domainName.getText())
+                    || isEmpty(realmName.getText())) {
+                return false;
+            }
+            RealmPrincipal realmPrincipal = (RealmPrincipal)eObject;
+            if (realmPrincipal == null) {
+                realmPrincipal = (RealmPrincipal)getEFactory().create(RealmPrincipal.class);
+                Role role = (Role) section.getSelectedObject();
+                role.getRealmPrincipal().add(realmPrincipal);
+            }
+            realmPrincipal.setName(name.getText());
+            realmPrincipal.setClazz(clazz.getText());
+            realmPrincipal.setDomainName(domainName.getText());
+            realmPrincipal.setRealmName(realmName.getText());
+            break;
+        }
+        return true;
+    }
+    
+    public JAXBObjectFactory getEFactory() {
+        return JAXBObjectFactoryImpl.getInstance();
+    }
+
+    @Override
+    protected String getAddWizardWindowTitle() {
+        return CommonMessages.wizardNewTitle_RoleMapping;
+    }
+
+    @Override
+    protected String getEditWizardWindowTitle() {
+        return CommonMessages.wizardEditTitle_RoleMapping;
+    }
+}

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

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

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

Added: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.ui/src/main/java/org/apache/geronimo/st/v21/ui/wizards/SecurityRunAsSubjectWizard.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/v21/ui/wizards/SecurityRunAsSubjectWizard.java?rev=921247&view=auto
==============================================================================
--- geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.ui/src/main/java/org/apache/geronimo/st/v21/ui/wizards/SecurityRunAsSubjectWizard.java (added)
+++ geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.ui/src/main/java/org/apache/geronimo/st/v21/ui/wizards/SecurityRunAsSubjectWizard.java Wed Mar 10 08:31:28 2010
@@ -0,0 +1,110 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.geronimo.st.v21.ui.wizards;
+
+import org.apache.geronimo.jee.security.Role;
+import org.apache.geronimo.jee.security.SubjectInfo;
+import org.apache.geronimo.st.ui.CommonMessages;
+import org.apache.geronimo.st.ui.sections.AbstractTableSection;
+import org.apache.geronimo.st.ui.wizards.AbstractWizard;
+import org.apache.geronimo.st.v21.ui.sections.SecurityAdvancedSection;
+import org.eclipse.swt.widgets.Combo;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Text;
+
+/**
+ *  @version $Rev$ $Date$
+ */
+public class SecurityRunAsSubjectWizard extends AbstractWizard {
+    protected Combo role;
+    protected Text realm;
+    protected Text id;
+    protected AbstractTableSection section;
+
+    public SecurityRunAsSubjectWizard(AbstractTableSection section) {
+        super();
+        this.section = section;
+    }
+
+    public class SecurityRunAsSubjectAddWizardPage extends AbstractWizardPage {
+        public SecurityRunAsSubjectAddWizardPage(String pageName) {
+            super(pageName);
+        }
+
+        public void createControl(Composite parent) {
+            Composite composite = createComposite(parent);
+            createLabel(composite, CommonMessages.securityRunAsSubjectRole);
+            role = createCombo(composite, ((SecurityAdvancedSection) section).getRolesWithoutRunAsSubject(), false);
+            createLabel(composite, CommonMessages.securityRunAsSubjectRealm);
+            realm = createTextField(composite, "");
+            createLabel(composite, CommonMessages.securityRunAsSubjectId);
+            id = createTextField(composite, "");
+            if (eObject != null) {
+                //TODO  role.setText (((SecurityAdvancedSection) section).);
+                role.setEnabled(false);
+                realm.setText (((Role)eObject).getRunAsSubject().getRealm());
+                id.setText(((Role)eObject).getRunAsSubject().getId());
+            }
+            setControl(composite);
+        }
+
+        @Override
+        protected String getWizardPageTitle() {
+            return CommonMessages.wizardPageTitle_RunAsSubject;
+        }
+
+        @Override
+        protected String getWizardPageDescription() {
+            return CommonMessages.wizardPageDescription_RunAsSubject;
+        }
+    }
+
+    @Override
+    public void addPages() {
+        addPage(new SecurityRunAsSubjectAddWizardPage("Page0"));
+    }
+
+    @Override
+    public boolean performFinish() {
+        if (isEmpty(realm.getText()) || isEmpty(id.getText())) {
+            return false;
+        }
+        if (eObject == null) {
+            SubjectInfo subjectInfo = new SubjectInfo();
+            subjectInfo.setRealm(realm.getText());
+            subjectInfo.setId(id.getText());
+            ((SecurityAdvancedSection) section).getRole(role.getText()).setRunAsSubject(subjectInfo);
+            ((SecurityAdvancedSection) section).activateAddButton();
+        }
+        else {
+            ((Role)eObject).getRunAsSubject().setRealm(realm.getText());
+            ((Role)eObject).getRunAsSubject().setId(id.getText());
+        }
+
+        return true;
+    }
+
+    @Override
+    protected String getAddWizardWindowTitle() {
+        return CommonMessages.wizardNewTitle_RunAsSubject;
+    }
+
+    @Override
+    protected String getEditWizardWindowTitle() {
+        return CommonMessages.wizardNewTitle_RunAsSubject;
+    }
+}

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

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

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



Mime
View raw message