geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From de...@apache.org
Subject svn commit: r817996 [20/23] - in /geronimo/devtools/eclipse-plugin/trunk: assembly/ assembly/src/main/assembly/ features/ features/org.apache.geronimo.v22.feature/ plugins/ plugins/org.apache.geronimo.j2ee.v11.jaxbmodel/ plugins/org.apache.geronimo.j2e...
Date Wed, 23 Sep 2009 08:04:34 GMT
Added: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v11.ui/src/org/apache/geronimo/st/v11/ui/sections/GBeanSection.java
URL: http://svn.apache.org/viewvc/geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v11.ui/src/org/apache/geronimo/st/v11/ui/sections/GBeanSection.java?rev=817996&view=auto
==============================================================================
--- geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v11.ui/src/org/apache/geronimo/st/v11/ui/sections/GBeanSection.java (added)
+++ geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v11.ui/src/org/apache/geronimo/st/v11/ui/sections/GBeanSection.java Wed Sep 23 08:04:12 2009
@@ -0,0 +1,180 @@
+/*
+ * 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.v11.ui.sections;
+
+import java.util.List;
+
+import javax.xml.bind.JAXBElement;
+
+import org.apache.geronimo.st.ui.CommonMessages;
+import org.apache.geronimo.st.ui.sections.AbstractTreeSection;
+import org.apache.geronimo.st.v11.ui.Activator;
+import org.apache.geronimo.st.v11.ui.wizards.GBeanWizard;
+import org.apache.geronimo.xml.ns.deployment_1.AttributeType;
+import org.apache.geronimo.xml.ns.deployment_1.GbeanType;
+import org.apache.geronimo.xml.ns.deployment_1.PatternType;
+import org.apache.geronimo.xml.ns.deployment_1.ReferenceType;
+import org.eclipse.jface.viewers.ILabelProvider;
+import org.eclipse.jface.viewers.ITreeContentProvider;
+import org.eclipse.jface.wizard.Wizard;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.ui.forms.widgets.FormToolkit;
+
+/**
+ * @version $Rev: 688452 $ $Date: 2008-08-24 01:56:20 -0400 (Sun, 24 Aug 2008) $
+ */
+public class GBeanSection extends AbstractTreeSection {
+
+    public GBeanSection(JAXBElement plan, List gbeans, Composite parent, FormToolkit toolkit, int style) {
+        super(plan, parent, toolkit, style);
+        this.objectContainer = gbeans;
+        createClient();
+    }
+
+    @Override
+    public String getTitle() {
+        return CommonMessages.editorSectionGBeanTitle;
+    }
+
+    @Override
+    public String getDescription() {
+        return CommonMessages.editorSectionGBeanDescription;
+    }
+
+    @Override
+    public Wizard getWizard() {
+        return new GBeanWizard(this);
+    }
+
+    @Override
+    public Class getTableEntryObjectType() {
+        return GbeanType.class;
+    }
+
+    @Override
+    protected void activateAddButton() {
+        if (tree.getSelectionCount() == 0 || tree.getSelection()[0].getParentItem() == null) {
+            addButton.setEnabled(true);
+        } else {
+            addButton.setEnabled(false);
+        }
+    }
+
+    public GbeanType getSelectedObject () {
+        if (tree.getSelection().length == 0) {
+            return null;
+        }
+        return (GbeanType)((JAXBElement)tree.getSelection()[0].getData()).getValue();
+    }
+    
+    @Override
+    public void removeItem(Object anItem) {
+        JAXBElement element =(JAXBElement)tree.getSelection()[0].getData(); 
+        Object object = element.getValue();
+        if (GbeanType.class.isInstance(object)) {
+            objectContainer.remove(anItem);
+        }
+        else {
+        	GbeanType gbean = (GbeanType)((JAXBElement)tree.getSelection()[0].getParentItem().getData()).getValue();
+            gbean.getAttributeOrXmlAttributeOrReference().remove(element);
+        }
+    }
+    
+    @Override
+    public Object getInput() {
+        if (objectContainer != null) {
+            return objectContainer;
+        }
+        return super.getInput();
+    }
+
+    @Override
+    public ITreeContentProvider getContentProvider() {
+        return new ContentProvider() {
+            @Override
+            public Object[] getElements(Object inputElement) {
+                return getChildren(inputElement);
+            }
+
+            @Override
+            public Object[] getChildren(Object parentElement) {
+                if (List.class.isInstance(parentElement)) {
+                    return ((List)parentElement).toArray();
+                }
+                if (JAXBElement.class.isInstance(parentElement)) {
+                    Object object = ((JAXBElement)parentElement).getValue();
+                    if (GbeanType.class.isInstance(object)) {
+                    	GbeanType gbean = (GbeanType)object;
+                        return gbean.getAttributeOrXmlAttributeOrReference().toArray();
+                    }
+                }
+                return new String[] {};
+            }
+        };
+    }
+
+    @Override
+    public ILabelProvider getLabelProvider() {
+        return new LabelProvider() {
+            @Override
+            public String getText(Object element) {
+                if (JAXBElement.class.isInstance(element)) {
+                    Object object = ((JAXBElement)element).getValue();
+                    if (GbeanType.class.isInstance(object)) {
+                    	GbeanType gbean = (GbeanType)object;
+                        return "GBean: name = \"" + gbean.getName() +
+                                "\", class = \"" + gbean.getClazz() + "\"";
+                    }
+                    else if (AttributeType.class.isInstance(object)) {
+                    	AttributeType attribute = (AttributeType)object;
+                        return "Attribute: name = \"" + attribute.getName() + 
+                                "\", type = \"" + attribute.getType() + 
+                                "\", value = \"" + attribute.getValue() + "\"";
+                    }
+                    else if (PatternType.class.isInstance(object)) {
+                    	PatternType dependency = (PatternType)object;
+                        return "Dependency: group = \"" + dependency.getGroupId() +
+                                "\", artifact = \"" + dependency.getArtifactId() +
+                                "\", version = \"" + dependency.getVersion() +
+                                "\", module = \"" + dependency.getModule() +
+                                "\", type = \"" + dependency.getType() +
+                                "\", custom name = \"" + dependency.getCustomFoo() + "\"";
+                    }
+                    else if (ReferenceType.class.isInstance(object)) {
+                    	ReferenceType reference = (ReferenceType)object;
+                        return "Reference: name = \"" + reference.getName() +
+                                "\", group = \"" + reference.getGroupId() +
+                                "\", artifact = \"" + reference.getArtifactId() +
+                                "\", version = \"" + reference.getVersion() +
+                                "\", module = \"" + reference.getModule() +
+                                "\", type = \"" + reference.getType() +
+                                "\", custom name = \"" + reference.getCustomFoo() + "\"";
+                    }
+                }
+
+                return null;
+            }
+
+            @Override
+            public Image getImage(Object arg0) {
+                return Activator.imageDescriptorFromPlugin("org.eclipse.jst.j2ee",
+                        "icons/full/obj16/accessbean_obj.gif").createImage();
+            }
+        };
+    }
+}

Added: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v11.ui/src/org/apache/geronimo/st/v11/ui/sections/MessageDestSection.java
URL: http://svn.apache.org/viewvc/geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v11.ui/src/org/apache/geronimo/st/v11/ui/sections/MessageDestSection.java?rev=817996&view=auto
==============================================================================
--- geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v11.ui/src/org/apache/geronimo/st/v11/ui/sections/MessageDestSection.java (added)
+++ geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v11.ui/src/org/apache/geronimo/st/v11/ui/sections/MessageDestSection.java Wed Sep 23 08:04:12 2009
@@ -0,0 +1,93 @@
+/*
+ * 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.v11.ui.sections;
+
+import java.util.List;
+
+import javax.xml.bind.JAXBElement;
+
+import org.apache.geronimo.st.ui.CommonMessages;
+import org.apache.geronimo.st.ui.sections.AbstractTableSection;
+import org.apache.geronimo.st.v11.ui.wizards.MessageDestWizard;
+import org.apache.geronimo.xml.ns.naming_1.MessageDestinationType;
+import org.eclipse.jface.viewers.ITableLabelProvider;
+import org.eclipse.jface.wizard.Wizard;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.ui.forms.widgets.FormToolkit;
+
+/**
+ * @version $Rev: 688452 $ $Date: 2008-08-24 13:56:20 +0800 (Sun, 24 Aug 2008) $
+ */
+public class MessageDestSection extends AbstractTableSection {
+
+    public MessageDestSection(JAXBElement plan, Composite parent, FormToolkit toolkit, int style, List messageDest) {
+        super(plan, parent, toolkit, style);
+        this.objectContainer = messageDest;
+        COLUMN_NAMES = new String[] {
+                CommonMessages.messageDestinationName, CommonMessages.adminModule, CommonMessages.adminLink, 
+                CommonMessages.groupId, CommonMessages.artifactId, CommonMessages.version,
+                CommonMessages.moduleId, CommonMessages.name };
+        createClient();
+    }
+
+    public String getTitle() {
+        return CommonMessages.editorSectionMessageDestTitle;
+    }
+
+    public String getDescription() {
+        return CommonMessages.editorSectionMessageDestDescription;
+    }
+
+    public Wizard getWizard() {
+        return new MessageDestWizard(this);
+    }
+
+    public Class getTableEntryObjectType() {
+        return MessageDestinationType.class;
+    }
+
+    @Override
+    public ITableLabelProvider getLabelProvider() {
+        return new LabelProvider() {
+            @Override
+            public String getColumnText(Object element, int columnIndex) {
+                if (MessageDestinationType.class.isInstance(element)) {
+                	MessageDestinationType msgDest = (MessageDestinationType) element;
+                    switch (columnIndex) {
+                    case 0:
+                        return msgDest.getMessageDestinationName();
+                    case 1:
+                        return msgDest.getAdminObjectModule();
+                    case 2:
+                        return msgDest.getAdminObjectLink();
+                    case 3:
+                        return msgDest.getPattern().getGroupId();
+                    case 4:
+                        return msgDest.getPattern().getArtifactId();
+                    case 5:
+                        return msgDest.getPattern().getVersion();
+                    case 6:
+                        return msgDest.getPattern().getModule();
+                    case 7:
+                        return msgDest.getPattern().getName();
+                    }
+                }
+                return null;
+            }
+        };
+    }
+}

Added: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v11.ui/src/org/apache/geronimo/st/v11/ui/sections/ModuleSection.java
URL: http://svn.apache.org/viewvc/geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v11.ui/src/org/apache/geronimo/st/v11/ui/sections/ModuleSection.java?rev=817996&view=auto
==============================================================================
--- geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v11.ui/src/org/apache/geronimo/st/v11/ui/sections/ModuleSection.java (added)
+++ geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v11.ui/src/org/apache/geronimo/st/v11/ui/sections/ModuleSection.java Wed Sep 23 08:04:12 2009
@@ -0,0 +1,102 @@
+/*
+ * 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.v11.ui.sections;
+
+import java.util.List;
+
+import javax.xml.bind.JAXBElement;
+
+import org.apache.geronimo.st.ui.CommonMessages;
+import org.apache.geronimo.st.ui.sections.AbstractTableSection;
+import org.apache.geronimo.st.v11.ui.wizards.ModuleWizard;
+import org.apache.geronimo.xml.ns.j2ee.application_1.ModuleType;
+import org.eclipse.jface.viewers.ITableLabelProvider;
+import org.eclipse.jface.wizard.Wizard;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.ui.forms.widgets.FormToolkit;
+
+/*
+ * @version $Rev: 688452 $ $Date: 2008-08-24 13:56:20 +0800 (Sun, 24 Aug 2008) $
+ */
+public class ModuleSection extends AbstractTableSection {
+
+    public ModuleSection(JAXBElement plan, Composite parent, FormToolkit toolkit, int style, List modules) {
+        super(plan, parent, toolkit, style);
+        this.objectContainer = modules;
+        COLUMN_NAMES = new String[] {
+                CommonMessages.moduleType, CommonMessages.path, CommonMessages.altDD };
+        createClient();
+    }
+
+    public String getTitle() {
+        return CommonMessages.editorSectionModuleTitle;
+    }
+
+    public String getDescription() {
+        return CommonMessages.editorSectionModuleDescription;
+    }
+
+    public Wizard getWizard() {
+        return new ModuleWizard(this);
+    }
+
+    public Class getTableEntryObjectType() {
+        return ModuleType.class;
+    }
+
+    @Override
+    public ITableLabelProvider getLabelProvider() {
+        return new LabelProvider() {
+            @Override
+            public String getColumnText(Object element, int columnIndex) {
+                if (ModuleType.class.isInstance(element)) {
+                	ModuleType module = (ModuleType) element;
+                    switch (columnIndex) {
+                    case 0:
+                        if (module.getConnector() != null) {
+                            return "connector";
+                        } else if (module.getEjb() != null) {
+                            return "ejb";
+                        } else if (module.getJava() != null) {
+                            return "java";
+                        } else if (module.getWeb() != null) {
+                            return "web";
+                        }
+                        return "";
+                    case 1:
+                        if (module.getConnector() != null) {
+                            return module.getConnector().getValue();
+                        } else if (module.getEjb() != null) {
+                            return module.getEjb().getValue();
+                        } else if (module.getJava() != null) {
+                            return module.getJava().getValue();
+                        } else if (module.getWeb() != null) {
+                            return module.getWeb().getValue();
+                        }
+                        return "";
+                    case 2:
+                        if (module.getAltDd() != null) {
+                            return module.getAltDd().getValue();
+                        }
+                        return "";
+                    }
+                }
+                return null;
+            }
+        };
+    }
+}

Added: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v11.ui/src/org/apache/geronimo/st/v11/ui/sections/OpenEjbJarCMPSection.java
URL: http://svn.apache.org/viewvc/geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v11.ui/src/org/apache/geronimo/st/v11/ui/sections/OpenEjbJarCMPSection.java?rev=817996&view=auto
==============================================================================
--- geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v11.ui/src/org/apache/geronimo/st/v11/ui/sections/OpenEjbJarCMPSection.java (added)
+++ geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v11.ui/src/org/apache/geronimo/st/v11/ui/sections/OpenEjbJarCMPSection.java Wed Sep 23 08:04:12 2009
@@ -0,0 +1,300 @@
+/*
+ * 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.v11.ui.sections;
+
+import javax.xml.bind.JAXBElement;
+
+import org.apache.geronimo.st.ui.CommonMessages;
+import org.apache.geronimo.st.ui.internal.Messages;
+import org.apache.geronimo.st.ui.sections.AbstractSectionPart;
+import org.apache.geronimo.xml.ns.naming_1.ObjectFactory;
+import org.apache.geronimo.xml.ns.naming_1.PatternType;
+import org.apache.geronimo.xml.ns.naming_1.ResourceLocatorType;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+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.Composite;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.ui.forms.widgets.FormToolkit;
+import org.eclipse.ui.forms.widgets.Section;
+import org.openejb.xml.ns.openejb_jar_2.OpenejbJarType;
+
+/**
+ * @version $Rev: 700249 $ $Date: 2008-09-30 04:50:12 +0800 (Tue, 30 Sep 2008) $
+ */
+public class OpenEjbJarCMPSection extends AbstractSectionPart {
+
+    protected Text resourceLink;
+
+    protected Text url;
+
+    protected Text artifact;
+
+    protected Text group;
+
+    protected Text module;
+
+    protected Text name;
+
+    protected Text version;
+
+    protected Button specifyAsLink;
+
+    protected Button specifyAsUrl;
+
+    protected Button specifyAsPattern;
+
+    OpenejbJarType plan;
+    
+    private ObjectFactory namingFactory;
+
+    /**
+     * @param parent
+     * @param toolkit
+     * @param style
+     * @param plan
+     */
+    public OpenEjbJarCMPSection(Composite parent, FormToolkit toolkit, int style, JAXBElement plan) {
+        super(parent, toolkit, style, plan);
+        this.plan = (OpenejbJarType) plan.getValue();
+        namingFactory = new ObjectFactory();
+        createClient();
+    }
+
+    protected void createClient() {
+        Section section = getSection();
+
+        section.setText(Messages.cmpConnectionSection);
+        section.setDescription(Messages.cmpConnectionSectionDescription);
+        section.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false));
+
+        Composite composite = toolkit.createComposite(section);
+        GridLayout layout = new GridLayout();
+        layout.numColumns = 2;
+        layout.marginHeight = 5;
+        layout.marginWidth = 10;
+        layout.verticalSpacing = 5;
+        layout.horizontalSpacing = 15;
+        composite.setLayout(layout);
+        composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
+        section.setClient(composite);
+
+        specifyAsLink = toolkit.createButton(composite, CommonMessages.useResourceLink, SWT.RADIO);
+        GridData data = new GridData();
+        data.horizontalSpan = 2;
+        specifyAsLink.setLayoutData(data);
+
+        ResourceLocatorType locator = plan.getCmpConnectionFactory();
+
+        toolkit.createLabel(composite, CommonMessages.resourceLink);
+        String value = locator != null ? locator.getResourceLink() : null;
+        resourceLink = toolkit.createText(composite, value, SWT.BORDER);
+        resourceLink.setLayoutData(createTextFieldGridData());
+        resourceLink.addModifyListener(new ModifyListener() {
+            public void modifyText(ModifyEvent e) {
+                getResourceLocator().setResourceLink(resourceLink.getText());
+                markDirty();
+            }
+        });
+        
+        specifyAsUrl = toolkit.createButton(composite, CommonMessages.useUrl, SWT.RADIO);
+        data = new GridData();
+        data.horizontalSpan = 2;
+        specifyAsUrl.setLayoutData(data);
+
+        toolkit.createLabel(composite, CommonMessages.url);
+        value = locator != null ? locator.getUrl() : null;
+        url = toolkit.createText(composite, value, SWT.BORDER);
+        url.setLayoutData(createTextFieldGridData());
+        url.addModifyListener(new ModifyListener() {
+            public void modifyText(ModifyEvent e) {
+                getResourceLocator().setUrl(url.getText());
+                markDirty();
+            }
+        });
+
+        specifyAsPattern = toolkit.createButton(composite, CommonMessages.useResourcePattern, SWT.RADIO);
+        specifyAsPattern.setLayoutData(data);
+
+        toolkit.createLabel(composite, CommonMessages.groupId);
+        value = locator != null && locator.getPattern() != null ? locator.getPattern().getGroupId()
+                : null;
+        group = toolkit.createText(composite, value, SWT.BORDER);
+        group.setLayoutData(createTextFieldGridData());
+        group.addModifyListener(new ModifyListener() {
+            public void modifyText(ModifyEvent e) {
+                getPattern().setGroupId(group.getText());
+                markDirty();
+            }
+        });
+
+        toolkit.createLabel(composite, CommonMessages.artifactId);
+        value = locator != null && locator.getPattern() != null ? locator.getPattern().getArtifactId()
+                : null;
+        artifact = toolkit.createText(composite, value, SWT.BORDER);
+        artifact.setLayoutData(createTextFieldGridData());
+        artifact.addModifyListener(new ModifyListener() {
+            public void modifyText(ModifyEvent e) {
+                getPattern().setArtifactId(artifact.getText());
+                markDirty();
+            }
+        });
+
+        toolkit.createLabel(composite, CommonMessages.moduleId);
+        value = locator != null && locator.getPattern() != null ? locator.getPattern().getModule()
+                : null;
+        module = toolkit.createText(composite, value, SWT.BORDER);
+        module.setLayoutData(createTextFieldGridData());
+        module.addModifyListener(new ModifyListener() {
+            public void modifyText(ModifyEvent e) {
+                getPattern().setModule(module.getText());
+                markDirty();
+            }
+        });
+
+        toolkit.createLabel(composite, CommonMessages.name);
+        value = locator != null && locator.getPattern() != null ? locator.getPattern().getName()
+                : null;
+        name = toolkit.createText(composite, value, SWT.BORDER);
+        name.setLayoutData(createTextFieldGridData());
+        name.addModifyListener(new ModifyListener() {
+            public void modifyText(ModifyEvent e) {
+                getPattern().setName(name.getText());
+                markDirty();
+            }
+        });
+
+        toolkit.createLabel(composite, CommonMessages.version);
+        value = locator != null && locator.getPattern() != null ? locator.getPattern().getVersion()
+                : null;
+        version = toolkit.createText(composite, value, SWT.BORDER);
+        version.setLayoutData(createTextFieldGridData());
+        version.addModifyListener(new ModifyListener() {
+            public void modifyText(ModifyEvent e) {
+                getPattern().setVersion(version.getText());
+                markDirty();
+            }
+        });
+
+        specifyAsLink.addSelectionListener(new SelectionAdapter() {
+            public void widgetSelected(SelectionEvent e) {
+                if (specifyAsLink.getSelection()) {
+                    getResourceLocator().setUrl(null);
+                    getResourceLocator().setPattern(null);
+                    if (resourceLink.getText().length() > 0) {
+                        getResourceLocator().setResourceLink(resourceLink.getText());
+                    }
+                    markDirty();
+                    toggle();
+                }
+            }
+        });
+
+        specifyAsUrl.addSelectionListener(new SelectionAdapter() {
+            public void widgetSelected(SelectionEvent e) {
+                if (specifyAsUrl.getSelection()) {
+                    getResourceLocator().setResourceLink(null);
+                    getResourceLocator().setPattern(null);
+                    if (url.getText().length() > 0) {
+                        getResourceLocator().setUrl(url.getText());
+                    }
+                    markDirty();
+                    toggle();
+                }
+            }
+        });
+ 
+        specifyAsPattern.addSelectionListener(new SelectionAdapter() {
+            public void widgetSelected(SelectionEvent e) {
+                if (specifyAsPattern.getSelection()) {
+              	    getResourceLocator().setResourceLink (null);
+                    getResourceLocator().setUrl (null);
+
+                    if (group.getText().length() > 0) {
+                        getPattern().setGroupId(group.getText());
+                    }
+                    if (artifact.getText().length() > 0) {
+                        getPattern().setArtifactId(artifact.getText());
+                    }
+                    if (module.getText().length() > 0) {
+                        getPattern().setModule(module.getText());
+                    }
+                    if (name.getText().length() > 0) {
+                        getPattern().setName(name.getText());
+                    }
+                    if (version.getText().length() > 0) {
+                        getPattern().setVersion(version.getText());
+                    }
+                    markDirty();
+                    toggle();
+                }
+            }
+        });
+
+        if (locator != null) {
+            if (locator.getResourceLink() != null) {
+                specifyAsLink.setSelection(true);
+            } else if (locator.getUrl() != null) {
+                specifyAsUrl.setSelection(true);
+            } else if (locator.getPattern() != null) {
+                specifyAsPattern.setSelection(true);
+            }
+        }
+
+        toggle();
+    }
+
+    public void toggle() {
+        resourceLink.setEnabled(specifyAsLink.getSelection());
+        url.setEnabled(specifyAsUrl.getSelection());
+        artifact.setEnabled(specifyAsPattern.getSelection());
+        group.setEnabled(specifyAsPattern.getSelection());
+        module.setEnabled(specifyAsPattern.getSelection());
+        name.setEnabled(specifyAsPattern.getSelection());
+        version.setEnabled(specifyAsPattern.getSelection());
+    }
+
+    /**
+     * @return
+     */
+    private ResourceLocatorType getResourceLocator() {
+    	ResourceLocatorType locator = plan.getCmpConnectionFactory();
+        if (locator == null) {
+            locator = namingFactory.createResourceLocatorType();
+            plan.setCmpConnectionFactory(locator);
+        }
+        return locator;
+    }
+
+    /**
+     * @return
+     */
+    private PatternType getPattern() {
+        ResourceLocatorType locator = getResourceLocator();
+        PatternType pattern = locator.getPattern();
+        if (pattern == null) {
+            pattern = namingFactory.createPatternType();
+            locator.setPattern(pattern);
+        }
+        return pattern;
+    }
+}

Added: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v11.ui/src/org/apache/geronimo/st/v11/ui/sections/OpenEjbJarGeneralSection.java
URL: http://svn.apache.org/viewvc/geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v11.ui/src/org/apache/geronimo/st/v11/ui/sections/OpenEjbJarGeneralSection.java?rev=817996&view=auto
==============================================================================
--- geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v11.ui/src/org/apache/geronimo/st/v11/ui/sections/OpenEjbJarGeneralSection.java (added)
+++ geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v11.ui/src/org/apache/geronimo/st/v11/ui/sections/OpenEjbJarGeneralSection.java Wed Sep 23 08:04:12 2009
@@ -0,0 +1,102 @@
+/*
+ * 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.v11.ui.sections;
+
+import javax.xml.bind.JAXBElement;
+
+import org.apache.geronimo.st.ui.CommonMessages;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.ui.forms.widgets.FormToolkit;
+import org.openejb.xml.ns.openejb_jar_2.ObjectFactory;
+import org.openejb.xml.ns.openejb_jar_2.OpenejbJarType;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class OpenEjbJarGeneralSection extends CommonGeneralSection {
+
+    protected Text ejbqlCompilerFactory;
+
+    protected Text dbSyntaxFactory;
+
+    protected Button enforceForeignKeyConstraints;
+    
+    OpenejbJarType plan;
+
+    public OpenEjbJarGeneralSection(Composite parent, FormToolkit toolkit, int style, JAXBElement plan) {
+        super(parent, toolkit, style, plan);
+        this.plan = (OpenejbJarType) plan.getValue();
+        createClient();
+    }
+
+    protected void createClient() {
+        super.createClient();
+        Composite composite = (Composite) getSection().getClient();
+
+        createLabel(composite, CommonMessages.editorejbqlCompilerFactory);
+
+        ejbqlCompilerFactory = toolkit.createText(composite, plan.getEjbQlCompilerFactory(), SWT.BORDER);
+        ejbqlCompilerFactory.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false));
+        ejbqlCompilerFactory.addModifyListener(new ModifyListener() {
+            public void modifyText(ModifyEvent e) {
+                plan.setEjbQlCompilerFactory(ejbqlCompilerFactory.getText());
+                markDirty();
+            }
+        });
+
+        createLabel(composite, CommonMessages.editordbSyntaxFactory);
+
+        dbSyntaxFactory = toolkit.createText(composite, plan.getDbSyntaxFactory(), SWT.BORDER);
+        dbSyntaxFactory.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false));
+        dbSyntaxFactory.addModifyListener(new ModifyListener() {
+            public void modifyText(ModifyEvent e) {
+                plan.setDbSyntaxFactory(dbSyntaxFactory.getText());
+                markDirty();
+            }
+        });
+
+        enforceForeignKeyConstraints = toolkit.createButton(composite, CommonMessages.enforceForeignKeyConstraints, SWT.CHECK);
+        enforceForeignKeyConstraints.setSelection(plan.getEnforceForeignKeyConstraints() != null);
+        GridData data = new GridData();
+        data.horizontalSpan = 2;
+        enforceForeignKeyConstraints.setLayoutData(data);
+
+        enforceForeignKeyConstraints.addSelectionListener(new SelectionListener() {
+            public void widgetDefaultSelected(SelectionEvent e) {
+            }
+
+            public void widgetSelected(SelectionEvent e) {
+            	if (enforceForeignKeyConstraints.getSelection()) {
+            		ObjectFactory objFactory = new ObjectFactory();
+            		plan.setEnforceForeignKeyConstraints(objFactory.createEmptyType());
+            	}
+            	else {
+            		plan.setEnforceForeignKeyConstraints(null);
+            	}
+                markDirty();
+            }
+        });
+    }
+}

Added: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v11.ui/src/org/apache/geronimo/st/v11/ui/sections/ResourceEnvRefSection.java
URL: http://svn.apache.org/viewvc/geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v11.ui/src/org/apache/geronimo/st/v11/ui/sections/ResourceEnvRefSection.java?rev=817996&view=auto
==============================================================================
--- geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v11.ui/src/org/apache/geronimo/st/v11/ui/sections/ResourceEnvRefSection.java (added)
+++ geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v11.ui/src/org/apache/geronimo/st/v11/ui/sections/ResourceEnvRefSection.java Wed Sep 23 08:04:12 2009
@@ -0,0 +1,86 @@
+/*
+ * 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.v11.ui.sections;
+
+import java.util.List;
+
+import javax.xml.bind.JAXBElement;
+
+import org.apache.geronimo.st.ui.CommonMessages;
+import org.apache.geronimo.st.ui.sections.AbstractTableSection;
+import org.apache.geronimo.st.v11.ui.Activator;
+import org.apache.geronimo.st.v11.ui.wizards.ResourceEnvRefWizard;
+import org.apache.geronimo.xml.ns.naming_1.ResourceEnvRefType;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.viewers.ITableLabelProvider;
+import org.eclipse.jface.wizard.Wizard;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.ui.forms.widgets.FormToolkit;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class ResourceEnvRefSection extends AbstractTableSection {
+
+
+    public ResourceEnvRefSection(JAXBElement plan, Composite parent, FormToolkit toolkit, int style, List resourceEnvRefs) {
+        super(plan, parent, toolkit, style);
+        this.objectContainer = resourceEnvRefs;
+        COLUMN_NAMES = new String[] {
+                CommonMessages.editorResEnvRefNameTitle, CommonMessages.editorResEnvRefMsgDestTitle };
+        createClient();
+    }
+
+    public String getTitle() {
+        return CommonMessages.editorResourceEnvRefTitle;
+    }
+
+    public String getDescription() {
+        return CommonMessages.editorResourceEnvRefDescription;
+    }
+
+    public Wizard getWizard() {
+        return new ResourceEnvRefWizard(this);
+    }
+
+    public ImageDescriptor getImageDescriptor() {
+        return Activator.imageDescriptorFromPlugin("org.eclipse.jst.j2ee", "icons/full/obj16/res_env_ref_obj.gif");
+    }
+
+    public Class getTableEntryObjectType() {
+        return ResourceEnvRefType.class;
+    }
+
+    @Override
+    public ITableLabelProvider getLabelProvider() {
+        return new LabelProvider() {
+            @Override
+            public String getColumnText(Object element, int columnIndex) {
+                if (ResourceEnvRefType.class.isInstance(element)) {
+                	ResourceEnvRefType resourceEnvRef = (ResourceEnvRefType) element;
+                    switch (columnIndex) {
+                    case 0:
+                        return resourceEnvRef.getRefName();
+                    case 1:
+                        return resourceEnvRef.getMessageDestinationLink();
+                    }
+                }
+                return null;
+            }
+        };
+    }
+}

Added: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v11.ui/src/org/apache/geronimo/st/v11/ui/sections/ResourceRefSection.java
URL: http://svn.apache.org/viewvc/geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v11.ui/src/org/apache/geronimo/st/v11/ui/sections/ResourceRefSection.java?rev=817996&view=auto
==============================================================================
--- geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v11.ui/src/org/apache/geronimo/st/v11/ui/sections/ResourceRefSection.java (added)
+++ geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v11.ui/src/org/apache/geronimo/st/v11/ui/sections/ResourceRefSection.java Wed Sep 23 08:04:12 2009
@@ -0,0 +1,86 @@
+/*
+ * 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.v11.ui.sections;
+
+import java.util.List;
+
+import javax.xml.bind.JAXBElement;
+
+import org.apache.geronimo.st.ui.CommonMessages;
+import org.apache.geronimo.st.ui.sections.AbstractTableSection;
+import org.apache.geronimo.st.v11.ui.Activator;
+import org.apache.geronimo.st.v11.ui.wizards.ResourceRefWizard;
+import org.apache.geronimo.xml.ns.naming_1.ResourceRefType;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.viewers.ITableLabelProvider;
+import org.eclipse.jface.wizard.Wizard;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.ui.forms.widgets.FormToolkit;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class ResourceRefSection extends AbstractTableSection {
+
+    public ResourceRefSection(JAXBElement plan, Composite parent, FormToolkit toolkit, int style, List resourceRefs) {
+        super(plan, parent, toolkit, style);
+        this.objectContainer = resourceRefs;
+        COLUMN_NAMES = new String[] {
+                CommonMessages.editorResRefNameTitle, CommonMessages.editorResRefLinkTitle};
+        createClient();
+        getSection().setExpanded(false);
+    }
+
+    public String getTitle() {
+        return CommonMessages.editorResourceRefTitle;
+    }
+
+    public String getDescription() {
+        return CommonMessages.editorResourceRefDescription;
+    }
+
+    public Wizard getWizard() {
+        return new ResourceRefWizard(this);
+    }
+
+    public ImageDescriptor getImageDescriptor() {
+        return Activator.imageDescriptorFromPlugin("org.eclipse.jst.j2ee", "icons/full/obj16/resourceRef_obj.gif");
+    }
+
+    public Class getTableEntryObjectType() {
+        return ResourceRefType.class;
+    }
+
+    @Override
+    public ITableLabelProvider getLabelProvider() {
+        return new LabelProvider() {
+            @Override
+            public String getColumnText(Object element, int columnIndex) {
+                if (ResourceRefType.class.isInstance(element)) {
+                	ResourceRefType resourceRef = (ResourceRefType) element;
+                    switch (columnIndex) {
+                    case 0:
+                        return resourceRef.getRefName();
+                    case 1:
+                        return resourceRef.getResourceLink();
+                    }
+                }
+                return null;
+            }
+        };
+    }
+}

Added: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v11.ui/src/org/apache/geronimo/st/v11/ui/sections/SecurityAdvancedSection.java
URL: http://svn.apache.org/viewvc/geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v11.ui/src/org/apache/geronimo/st/v11/ui/sections/SecurityAdvancedSection.java?rev=817996&view=auto
==============================================================================
--- geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v11.ui/src/org/apache/geronimo/st/v11/ui/sections/SecurityAdvancedSection.java (added)
+++ geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v11.ui/src/org/apache/geronimo/st/v11/ui/sections/SecurityAdvancedSection.java Wed Sep 23 08:04:12 2009
@@ -0,0 +1,460 @@
+///*
+// * 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.v11.ui.sections;
+//
+//import java.util.ArrayList;
+//import java.util.Hashtable;
+//import java.util.List;
+//
+//import javax.xml.bind.JAXBElement;
+//
+//import org.apache.geronimo.st.ui.CommonMessages;
+//import org.apache.geronimo.st.ui.sections.AbstractTableSection;
+//import org.apache.geronimo.st.v21.core.jaxb.JAXBModelUtils;
+//import org.apache.geronimo.st.v11.ui.wizards.SecurityRunAsSubjectWizard;
+//import org.apache.geronimo.xml.ns.deployment_1.PatternType;
+//import org.apache.geronimo.xml.ns.security_1.RoleMappingsType;
+//import org.apache.geronimo.xml.ns.security_1.RoleType;
+//import org.apache.geronimo.xml.ns.security_1.SecurityType;
+//import org.eclipse.jface.dialogs.Dialog;
+//import org.eclipse.jface.viewers.IBaseLabelProvider;
+//import org.eclipse.jface.viewers.IContentProvider;
+//import org.eclipse.jface.viewers.Viewer;
+//import org.eclipse.jface.wizard.Wizard;
+//import org.eclipse.jface.wizard.WizardDialog;
+//import org.eclipse.swt.SWT;
+//import org.eclipse.swt.events.ModifyEvent;
+//import org.eclipse.swt.events.ModifyListener;
+//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.Display;
+//import org.eclipse.swt.widgets.Text;
+//import org.eclipse.ui.forms.widgets.FormToolkit;
+//import org.eclipse.ui.forms.widgets.Section;
+//
+///**
+// * @version $Rev: 723874 $ $Date: 2008-12-06 05:30:03 +0800 (Sat, 06 Dec 2008) $
+// */
+//public class SecurityAdvancedSection extends AbstractTableSection {
+//
+//    private static final String SPECIFY_CREDENTIAL_STORE_MANUALLY = "<specify manually>";
+//
+//    protected Text credentialStoreRef;
+//    protected Button specifyCredentialStoreRefButton;
+//    protected Button deleteCredentialStoreRefButton;
+//
+//    private Hashtable<String, Pattern> credentialStoreList = new Hashtable<String, Pattern>();
+//
+//    protected Combo defaultSubjectRealmName;
+//
+//    protected Combo defaultSubjectId;
+//
+//    protected Button doAsCurrentCaller;
+//
+//    protected Button useContextHandler;
+//
+//    public SecurityAdvancedSection(JAXBElement plan, Composite parent, FormToolkit toolkit, int style) {
+//        super(plan, parent, toolkit, style);
+//        createClient();
+//    }
+//
+//    public void createClient() {
+//        Section section = getSection();
+//        section.setText(getTitle());
+//        section.setDescription(getDescription());
+//        section.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false));
+//        Composite clientComposite = createComposite(getSection(), 3);
+//        section.setClient(clientComposite);
+//
+//        Composite composite1 = createComposite(clientComposite, 2);
+//        composite1.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 3, 1));
+//
+//        doAsCurrentCaller = toolkit.createButton(composite1, CommonMessages.securityDoasCurrentCaller,
+//                SWT.CHECK);
+//        doAsCurrentCaller.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
+//        doAsCurrentCaller.addSelectionListener(new SelectionAdapter() {
+//            public void widgetSelected(SelectionEvent e) {
+//                setDoAsCurrentCaller();
+//                markDirty();
+//            }
+//        });
+//        doAsCurrentCaller.setSelection(isDoasCurrentCaller());
+//
+//        useContextHandler = toolkit.createButton(composite1, CommonMessages.securityUseContextHandler,
+//                SWT.CHECK);
+//        useContextHandler.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
+//        useContextHandler.addSelectionListener(new SelectionAdapter() {
+//            public void widgetSelected(SelectionEvent e) {
+//                setUseContextHandler();
+//                markDirty();
+//            }
+//        });
+//        useContextHandler.setSelection(isUseContextHandler());
+//
+//        createLabel(clientComposite, CommonMessages.securityCredentialStore);
+//        credentialStoreRef = new Text(clientComposite, SWT.READ_ONLY| SWT.BORDER);
+//        credentialStoreRef.setText("<credential store ref name will go here>");
+//        GridData gridData = new GridData(SWT.FILL, SWT.CENTER, false, false);
+//        gridData.widthHint = 300;
+//        credentialStoreRef.setLayoutData(gridData);
+//
+//        Composite composite2 = toolkit.createComposite(clientComposite);
+//        GridLayout layout = new GridLayout();
+//        layout.numColumns = 2;
+//        layout.marginHeight = 5;
+//        layout.marginWidth = 0;
+//        layout.verticalSpacing = 5;
+//        layout.horizontalSpacing = 5;
+//        composite2.setLayout(layout);
+//        composite2.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false));
+//        specifyCredentialStoreRefButton = toolkit.createButton(composite2, CommonMessages.edit, SWT.NONE);
+//        specifyCredentialStoreRefButton.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false));
+//        specifyCredentialStoreRefButton.addSelectionListener(new SelectionAdapter() {
+//            @Override
+//            public void widgetSelected(SelectionEvent e) {
+//                Wizard wizard = getCredentialStoreRefWizard();
+//                WizardDialog dialog = new WizardDialog(Display.getCurrent().getActiveShell(), wizard);
+//                dialog.open();
+//                if (dialog.getReturnCode() == Dialog.OK) {
+//                    setCredentialStoreRef();
+//                    toggleAdvancedSettings();
+//                    markDirty();
+//                }
+//            }
+//        });
+//        deleteCredentialStoreRefButton = toolkit.createButton(composite2, CommonMessages.remove, SWT.NONE);
+//        deleteCredentialStoreRefButton.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false));
+//        deleteCredentialStoreRefButton.addSelectionListener(new SelectionAdapter(){
+//            @Override
+//            public void widgetSelected(SelectionEvent e) {
+//            }
+//        });
+//
+//        createLabel(clientComposite, CommonMessages.securityDefaultSubject);
+//        createLabel(clientComposite, "");
+//        createLabel(clientComposite, "");
+//        //group = createGroup(clientComposite, CommonMessages.securityDefaultSubject);
+//
+//        //createLabel(clientComposite, "");
+//        //Composite composite3 = createComposite(clientComposite, 2);
+//        //composite3.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false, 2, 1));
+//        createLabel(clientComposite, CommonMessages.securityDefaultSubjectRealmName).setLayoutData(
+//                new GridData(SWT.RIGHT, SWT.CENTER, false, false));
+//        defaultSubjectRealmName = new Combo(clientComposite, SWT.SINGLE | SWT.DROP_DOWN);
+//        defaultSubjectRealmName.add(getDefaultSubjectRealmName());
+//        defaultSubjectRealmName.select(0);
+//        gridData = new GridData(SWT.LEFT, SWT.CENTER, false, false, 2, 1);
+//        gridData.widthHint = 100;
+//        defaultSubjectRealmName.setLayoutData(gridData);
+//        defaultSubjectRealmName.addModifyListener(new ModifyListener() {
+//            public void modifyText(ModifyEvent e) {
+//                setDefaultSubject();
+//                markDirty();
+//            }
+//        });
+//        defaultSubjectRealmName.pack();
+//
+//        //createLabel(clientComposite, "");
+//        //Composite composite4 = createComposite(clientComposite, 2);
+//        //composite4.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false, 2, 1));
+//        createLabel(clientComposite, CommonMessages.securityDefaultSubjectId).setLayoutData(
+//                new GridData(SWT.RIGHT, SWT.CENTER, false, false));
+//        defaultSubjectId = new Combo(clientComposite, SWT.SINGLE | SWT.DROP_DOWN);
+//        defaultSubjectId.add(getDefaultSubjectId());
+//        defaultSubjectId.select(0);
+//        gridData = new GridData(SWT.LEFT, SWT.CENTER, false, false, 2, 1);
+//        gridData.widthHint = 100;
+//        defaultSubjectId.setLayoutData(gridData);
+//        defaultSubjectId.addModifyListener(new ModifyListener() {
+//            public void modifyText(ModifyEvent e) {
+//                setDefaultSubject();
+//                markDirty();
+//            }
+//        });
+//        defaultSubjectId.pack();
+//
+//        //group = createGroup(clientComposite, CommonMessages.securityRunAsSubjects);
+//        createLabel(clientComposite, "").setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false, 3, 1));
+//        createLabel(clientComposite, CommonMessages.securityRunAsSubjects).setLayoutData(
+//                new GridData(SWT.LEFT, SWT.TOP, false, false));
+//        createViewer(clientComposite);
+//        viewer.setContentProvider(getContentProvider());
+//        viewer.setLabelProvider(getLabelProvider());
+//        viewer.setInput(getInput());
+//
+//        Composite buttonComposite = createButtonComposite(clientComposite);
+//        createAddButton(buttonComposite);
+//        createRemoveButton(buttonComposite);
+//        createEditButton(buttonComposite);
+//        activateButtons();
+//
+//        section.setExpanded(false);
+//        toggleAdvancedSettings();
+//    }
+//
+//    private Wizard getCredentialStoreRefWizard() {
+//        return null;
+//    }
+//
+//    private void toggleAdvancedSettings() {
+//        boolean enable = false;
+//        if (getSecurity() != null && getSecurity().getCredentialStoreRef() != null) {
+//            enable = true;
+//        }
+//        defaultSubjectRealmName.setEnabled(enable);
+//        defaultSubjectId.setEnabled(enable);
+//        table.setEnabled(enable);
+//        activateAddButton();
+//    }
+//
+//    @Override
+//    public Object getInput() {
+//        return SecurityRoleMappingSection.getRoleMappings(getPlan(), false);
+//    }
+//
+//    @Override
+//    public IContentProvider getContentProvider() {
+//        return new ContentProvider() {
+//            @Override
+//            public Object[] getElements(Object inputElement) {
+//                if (inputElement instanceof RoleMappingsType) {
+//                    return ((RoleMappingsType) inputElement).getRole().toArray();
+//                }
+//                return super.getElements(inputElement);
+//            }
+//        };
+//    }
+//
+//    @Override
+//    protected boolean filter(Viewer viewer, Object parentElement, Object element) {
+//        if (element instanceof RoleType) {
+//            return ((RoleType) element).getRunAsSubject() != null;
+//        }
+//        return false;
+//    }
+//
+//    @Override
+//    public IBaseLabelProvider getLabelProvider() {
+//        return new LabelProvider() {
+//            @Override
+//            public String getColumnText(Object element, int columnIndex) {
+//                if (element instanceof RoleType) {
+//                	RoleType role = (RoleType) element;
+//                    switch (columnIndex) {
+//                    case 0:
+//                        return role.getRoleName();
+//                    case 1:
+//                        return role.getRunAsSubject().getRealm();
+//                    case 2:
+//                        return role.getRunAsSubject().getId();
+//                    }
+//                }
+//                return "";
+//            }
+//        };
+//    }
+//
+//    @Override
+//    protected void removeItem(Object selectedItem) {
+//        if (selectedItem instanceof RoleType) {
+//            ((RoleType) selectedItem).setRunAsSubject(null);
+//            return;
+//        }
+//        super.removeItem(selectedItem);
+//    }
+//
+//    @Override
+//    protected Wizard getWizard() {
+//        return new SecurityRunAsSubjectWizard(this);
+//    }
+//
+//    @Override
+//    public void activateAddButton() {
+//        if (getSecurity() != null && getSecurity().getCredentialStoreRef() != null
+//                && getRolesWithoutRunAsSubject().length > 0) {
+//            addButton.setEnabled(true);
+//        } else {
+//            addButton.setEnabled(false);
+//        }
+//    }
+//
+//    public RoleType getRole(String roleName) {
+//        List<RoleType> roles = SecurityRoleMappingSection.getRoles(getPlan(), false);
+//        for (int i = 0; i < roles.size(); i++) {
+//        	RoleType role = roles.get(i);
+//            if (role.getRoleName().equals(roleName)) {
+//                return role;
+//            }
+//        }
+//        return null;
+//    }
+//
+//    public String[] getRolesWithoutRunAsSubject() {
+//        List<RoleType> roles = SecurityRoleMappingSection.getRoles(getPlan(), false);
+//        List<RoleType> rolesWithoutRunAsSubject = new ArrayList<RoleType>();
+//        for (int i = 0; i < roles.size(); i++) {
+//        	RoleType role = roles.get(i);
+//            if(role.getRunAsSubject() == null) {
+//                rolesWithoutRunAsSubject.add(role);
+//            }
+//        }
+//        String[] roleNames = new String[rolesWithoutRunAsSubject.size()];
+//        for (int i = 0; i < rolesWithoutRunAsSubject.size(); i++) {
+//            roleNames[i] = rolesWithoutRunAsSubject.get(i).getRoleName();
+//        }
+//        return roleNames;
+//    }
+//
+//    /*private void populateCredentialStores() {
+//        String credentialStoreRefName = getCredentialStoreRefName();
+//        if (credentialStoreRefName.length() > 0) {
+//            credentialStoreRef.add(""); //users will select this empty string to unset credentialStoreRef
+//        }
+//        credentialStoreRef.add(credentialStoreRefName);
+//        List<Pattern> deployedCredentialStores = GeronimoServerInfo.getInstance().getDeployedCredentialStores();
+//        Pattern pattern = new Pattern();
+//        pattern.setCustomFoo(credentialStoreRefName);
+//        if (deployedCredentialStores.contains(pattern)) {
+//            deployedCredentialStores.remove(pattern);
+//        }
+//        for (int i = 0; i < deployedCredentialStores.size(); i++) {
+//            credentialStoreRef.add(deployedCredentialStores.get(i).toString());
+//        }
+//        credentialStoreRef.add(SPECIFY_CREDENTIAL_STORE_MANUALLY);
+//    }*/
+//
+//    @Override
+//    public List getObjectContainer() {
+//        return getSecurity().getRoleMappings().getRole();
+//    }
+//
+//    @Override
+//    public Class getTableEntryObjectType() {
+//        return Role.class;
+//    }
+//
+//    @Override
+//    public String[] getTableColumnNames() {
+//        return new String[] { CommonMessages.securityRunAsSubjectRole, CommonMessages.securityRunAsSubjectRealm,
+//                CommonMessages.securityRunAsSubjectId };
+//    }
+//
+//    @Override
+//    public String getTitle() {
+//        return CommonMessages.editorSectionSecurityAdvancedTitle;
+//    }
+//
+//    @Override
+//    public String getDescription() {
+//        return CommonMessages.editorSectionSecurityAdvancedDescription;
+//    }
+//
+//    private SecurityType getSecurity() {
+//        return JAXBModelUtils.getSecurity(getPlan());
+//    }
+//
+//    private String getCredentialStoreRefName() {
+//        if (getSecurity() != null) {
+//            PatternType credentialStoreRef = getSecurity().getCredentialStoreRef();
+//            if (credentialStoreRef != null) {
+//                return credentialStoreRef.getCustomFoo();
+//            }
+//        }
+//        return "";
+//    }
+//
+//    private String getDefaultSubjectRealmName() {
+//        if (getSecurity() != null) {
+//            SubjectInfo subjectInfo = getSecurity().getDefaultSubject();
+//            if (subjectInfo != null) {
+//                return subjectInfo.getRealm();
+//            }
+//        }
+//        return "";
+//    }
+//
+//    private String getDefaultSubjectId() {
+//        if (getSecurity() != null) {
+//            SubjectInfo subjectInfo = getSecurity().getDefaultSubject();
+//            if (subjectInfo != null) {
+//                return subjectInfo.getId();
+//            }
+//        }
+//        return "";
+//    }
+//
+//    private boolean isDoasCurrentCaller() {
+//        if (getSecurity() != null) {
+//            return getSecurity().isDoasCurrentCaller();
+//        }
+//        return false;
+//    }
+//
+//    private boolean isUseContextHandler() {
+//        if (getSecurity() != null) {
+//            return getSecurity().isUseContextHandler();
+//        }
+//        return false;
+//    }
+//
+//    private void setCredentialStoreRef() {
+//        if (getSecurity() != null) {
+//            String credentialStoreRefName = credentialStoreRef.getText();
+//            if (credentialStoreRefName.trim().length() > 0) {
+//            	PatternType credentialStoreRef = new PatternType();
+//                // credentialStoreRef.setGroupId("org.apache.geronimo.framework");
+//                // credentialStoreRef.setArtifactId("server-security-config");
+//                //credentialStoreRef.setCustomFoo(credentialStoreRef.getText());
+//                getSecurity().setCredentialStoreRef(credentialStoreRef);
+//            } else {
+//                getSecurity().setCredentialStoreRef(null);
+//            }
+//        }
+//    }
+//
+//    private void setDefaultSubject() {
+//        if (getSecurity() != null) {
+//            String realmName = defaultSubjectRealmName.getText();
+//            String realmId = defaultSubjectId.getText();
+//            if (realmName.trim().length() > 0 && realmId.trim().length() > 0) {
+//                SubjectInfo defaultSubject = new SubjectInfo();
+//                defaultSubject.setRealm(realmName);
+//                defaultSubject.setId(realmId);
+//                getSecurity().setDefaultSubject(defaultSubject);
+//            } else {
+//                getSecurity().setDefaultSubject(null);
+//            }
+//        }
+//    }
+//
+//    private void setDoAsCurrentCaller() {
+//        if (getSecurity() != null) {
+//            getSecurity().setDoasCurrentCaller(doAsCurrentCaller.getSelection());
+//        }
+//    }
+//
+//    private void setUseContextHandler() {
+//        if (getSecurity() != null) {
+//            getSecurity().setUseContextHandler(useContextHandler.getSelection());
+//        }
+//    }
+//}

Added: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v11.ui/src/org/apache/geronimo/st/v11/ui/sections/SecurityRoleMappingSection.java
URL: http://svn.apache.org/viewvc/geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v11.ui/src/org/apache/geronimo/st/v11/ui/sections/SecurityRoleMappingSection.java?rev=817996&view=auto
==============================================================================
--- geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v11.ui/src/org/apache/geronimo/st/v11/ui/sections/SecurityRoleMappingSection.java (added)
+++ geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v11.ui/src/org/apache/geronimo/st/v11/ui/sections/SecurityRoleMappingSection.java Wed Sep 23 08:04:12 2009
@@ -0,0 +1,294 @@
+/*
+ * 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.v11.ui.sections;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.xml.bind.JAXBElement;
+
+import org.apache.geronimo.st.core.descriptor.AbstractDeploymentDescriptor;
+import org.apache.geronimo.st.core.descriptor.ApplicationDeploymentDescriptor;
+import org.apache.geronimo.st.core.descriptor.EjbDeploymentDescriptor;
+import org.apache.geronimo.st.core.descriptor.WebDeploymentDescriptor;
+import org.apache.geronimo.st.core.jaxb.JAXBUtils;
+import org.apache.geronimo.st.ui.CommonMessages;
+import org.apache.geronimo.st.ui.sections.AbstractTreeSection;
+import org.apache.geronimo.st.v11.core.jaxb.JAXBModelUtils;
+import org.apache.geronimo.st.v11.ui.Activator;
+import org.apache.geronimo.st.v11.ui.wizards.SecurityRoleMappingWizard;
+import org.apache.geronimo.xml.ns.security_1.DistinguishedNameType;
+import org.apache.geronimo.xml.ns.security_1.LoginDomainPrincipalType;
+import org.apache.geronimo.xml.ns.security_1.PrincipalType;
+import org.apache.geronimo.xml.ns.security_1.RealmPrincipalType;
+import org.apache.geronimo.xml.ns.security_1.RoleMappingsType;
+import org.apache.geronimo.xml.ns.security_1.RoleType;
+import org.apache.geronimo.xml.ns.security_1.SecurityType;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.viewers.ILabelProvider;
+import org.eclipse.jface.viewers.ITreeContentProvider;
+import org.eclipse.jface.wizard.Wizard;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.TreeItem;
+import org.eclipse.ui.forms.widgets.FormToolkit;
+
+/**
+ * @version $Rev: 707635 $ $Date: 2008-10-24 21:55:28 +0800 (Fri, 24 Oct 2008) $
+ */
+public class SecurityRoleMappingSection extends AbstractTreeSection {
+
+    public SecurityRoleMappingSection(JAXBElement plan, Composite parent, FormToolkit toolkit, int style) {
+        super(plan, parent, toolkit, style);
+        createClient();
+    }
+
+    public SecurityRoleMappingSection(JAXBElement plan, AbstractDeploymentDescriptor descriptor, Composite parent,
+            FormToolkit toolkit, int style) {
+        super(plan, descriptor, parent, toolkit, style);
+        createClient();
+    }
+
+    @Override
+    protected boolean isRequiredSyncToolbarAction() {
+        return true;
+    }
+
+    @Override
+    protected IAction getSyncAction() {
+        return new SyncAction(CommonMessages.securityRefreshRoles) {
+            @Override
+            public void run() {
+                if( addRolesFromDeploymentDescriptor() ) {
+                    markDirty();
+                }
+            }
+        };
+    }
+
+    @Override
+    protected void activateRemoveButton() {
+        if (tree.getSelectionCount() > 0 && tree.getSelection()[0].getParentItem() != null) {
+            removeButton.setEnabled(true);
+        } else {
+            removeButton.setEnabled(false);
+        }
+    }
+
+    @Override
+    protected void activateEditButton() {
+        if (tree.getSelectionCount() > 0 && tree.getSelection()[0].getParentItem() != null) {
+            editButton.setEnabled(true);
+        } else {
+            editButton.setEnabled(false);
+        }
+    }
+
+    @Override
+    protected void activateAddButton() {
+        if (tree.getSelectionCount() > 0 && tree.getSelection()[0].getParentItem() == null) {
+            addButton.setEnabled(true);
+        } else {
+            addButton.setEnabled(false);
+        }
+    }
+
+    @Override
+    public void handleDelete() {
+        TreeItem selectedItem = tree.getSelection()[0];
+        Object selectedObject = selectedItem.getData();
+        RoleType role = (RoleType) selectedItem.getParentItem().getData();
+        try {
+			((ArrayList) JAXBUtils.getValue(role, selectedObject.getClass().getSimpleName())).remove(selectedObject);
+		} catch (Exception e) {
+			MessageDialog.openError(Display.getCurrent().getActiveShell(),"Error", e.getMessage());
+		}
+    }
+
+    public RoleType getSelectedObject() {
+        return (RoleType) tree.getSelection()[0].getData();
+    }
+
+    @Override
+    public String getTitle() {
+        return CommonMessages.editorSectionSecurityRolesTitle;
+    }
+
+    @Override
+    public String getDescription() {
+        return CommonMessages.editorSectionSecurityRolesDescription;
+    }
+
+    @Override
+    public Wizard getWizard() {
+        return new SecurityRoleMappingWizard(this);
+    }
+
+    @Override
+    public Class getTableEntryObjectType() {
+        return RoleType.class;
+    }
+
+    @Override
+    public List getObjectContainer() {
+        return getRoles(getPlan(), false);
+    }
+
+    public static List<RoleType> getRoles(JAXBElement plan, boolean create) {
+    	RoleMappingsType roleMappings = getRoleMappings(plan, create);
+        if (roleMappings != null) {
+            return roleMappings.getRole();
+        }
+        return null;
+    }
+
+    public static RoleMappingsType getRoleMappings(JAXBElement plan, boolean create) {
+    	SecurityType security = JAXBModelUtils.getSecurity(plan);
+        if (security == null && create) {
+            security = new SecurityType();
+            JAXBModelUtils.setSecurity(plan, security);
+        }
+        if (security != null) {
+        	RoleMappingsType roleMappings = security.getRoleMappings();
+            if (roleMappings == null && create) {
+                roleMappings = new RoleMappingsType();
+                security.setRoleMappings(roleMappings);
+            }
+            return roleMappings;
+        }
+        return null;
+    }
+
+    protected boolean addRolesFromDeploymentDescriptor() {
+        List<String> declaredRoleNames = null;
+        if (WebDeploymentDescriptor.class.isInstance(getDescriptor())) {
+            declaredRoleNames = ((WebDeploymentDescriptor)getDescriptor()).getSecurityRoles();
+        }
+        else if (ApplicationDeploymentDescriptor.class.isInstance(getDescriptor())) {
+            declaredRoleNames = ((ApplicationDeploymentDescriptor)getDescriptor()).getSecurityRoles();
+        }
+        else if (EjbDeploymentDescriptor.class.isInstance(getDescriptor())) {
+            declaredRoleNames = ((EjbDeploymentDescriptor)getDescriptor()).getSecurityRoles();
+        }
+        
+        if (declaredRoleNames == null || declaredRoleNames.size() <= 0) {
+            return false;
+        }
+        List<RoleType> definedRoles = getRoles(getPlan(), true);
+        List<RoleType> newRoles = new ArrayList<RoleType>();
+        for (int i = 0; i < declaredRoleNames.size(); i++) {
+            String roleName = declaredRoleNames.get(i);
+            boolean roleExists = false;
+            for (int j = 0; j < definedRoles.size(); j++) {
+                if (definedRoles.get(j).getRoleName().equals(roleName)) {
+                    roleExists = true;
+                    break;
+                }
+            }
+            if (!roleExists) {
+            	RoleType newRole = new RoleType();
+                newRole.setRoleName(roleName);
+                newRoles.add(newRole);
+            }
+        }
+        definedRoles.addAll(newRoles);
+        return newRoles.size() > 0;
+    }
+
+    @Override
+    public Object getInput() {
+        addRolesFromDeploymentDescriptor();
+        return getRoleMappings(getPlan(), false);
+    }
+
+    @Override
+    public ITreeContentProvider getContentProvider() {
+        return new ContentProvider() {
+            @Override
+            public Object[] getElements(Object inputElement) {
+                return getChildren(inputElement);
+            }
+
+            @Override
+            public Object[] getChildren(Object parentElement) {
+                if (RoleMappingsType.class.isInstance(parentElement)) {
+                    return ((RoleMappingsType) parentElement).getRole().toArray();
+                }
+                if (parentElement instanceof RoleType) {
+                	RoleType role = (RoleType) parentElement;
+                    return concat(role.getDistinguishedName().toArray(), role.getPrincipal().toArray(), 
+                            role.getLoginDomainPrincipal().toArray(), role.getRealmPrincipal().toArray());
+                }
+                return new String[] {};
+            }
+
+            private Object[] concat(Object[] arr1, Object[] arr2, Object[] arr3, Object[] arr4) {
+                Object[] all = new Object[arr1.length + arr2.length + arr3.length + arr4.length];
+                System.arraycopy(arr1, 0, all, 0, arr1.length);
+                System.arraycopy(arr2, 0, all, arr1.length, arr2.length);
+                System.arraycopy(arr3, 0, all, arr1.length + arr2.length, arr3.length);
+                System.arraycopy(arr4, 0, all, arr1.length + arr2.length + arr3.length, arr4.length);
+                return all;
+            }
+        };
+    }
+
+    @Override
+    public ILabelProvider getLabelProvider() {
+        return new LabelProvider() {
+            @Override
+            public String getText(Object element) {
+                if (RoleType.class.isInstance(element)) {
+                	RoleType role = (RoleType) element;
+                    return "Role: role-name = \"" + role.getRoleName() + "\"";
+                }
+                else if (element instanceof DistinguishedNameType) {
+                	DistinguishedNameType object = (DistinguishedNameType) element;
+                    return "DistinguishedName: name = \"" + object.getName() + "\"";
+                }
+                else if (element instanceof RealmPrincipalType) {
+                	RealmPrincipalType object = (RealmPrincipalType) element;
+                    return "RealmPrincipal: name = \"" + object.getName() +
+                            "\", class = \"" + object.getClazz() +
+                            "\", domain-name = \"" + object.getDomainName() +
+                            "\", realm-name = \"" + object.getRealmName() +"\"";
+                }
+                else if (element instanceof LoginDomainPrincipalType) {
+                	LoginDomainPrincipalType object = (LoginDomainPrincipalType) element;
+                    return "LoginDomainPrincipal: name = \"" + object.getName() +
+                            "\", class = \"" + object.getClazz() +
+                            "\", domain-name = \"" + object.getDomainName() +"\"";
+                }
+                else if (element instanceof PrincipalType) {
+                	PrincipalType object = (PrincipalType) element;
+                    return "Principal: name = \"" + object.getName() +
+                            "\", class = \"" + object.getClazz() + "\"";
+                }
+
+                return null;
+            }
+
+            @Override
+            public Image getImage(Object arg0) {
+                return Activator.imageDescriptorFromPlugin("org.eclipse.jst.j2ee",
+                        "icons/full/obj16/security_role.gif").createImage();
+            }
+        };
+    }
+}

Added: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v11.ui/src/org/apache/geronimo/st/v11/ui/sections/ServiceRefSection.java
URL: http://svn.apache.org/viewvc/geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v11.ui/src/org/apache/geronimo/st/v11/ui/sections/ServiceRefSection.java?rev=817996&view=auto
==============================================================================
--- geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v11.ui/src/org/apache/geronimo/st/v11/ui/sections/ServiceRefSection.java (added)
+++ geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v11.ui/src/org/apache/geronimo/st/v11/ui/sections/ServiceRefSection.java Wed Sep 23 08:04:12 2009
@@ -0,0 +1,180 @@
+/*
+ * 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.v11.ui.sections;
+
+import java.util.List;
+
+import javax.xml.bind.JAXBElement;
+
+
+import org.apache.geronimo.st.ui.CommonMessages;
+import org.apache.geronimo.st.ui.sections.AbstractTreeSection;
+import org.apache.geronimo.st.v11.ui.Activator;
+import org.apache.geronimo.st.v11.ui.wizards.ServiceRefWizard;
+import org.apache.geronimo.xml.ns.naming_1.PortCompletionType;
+import org.apache.geronimo.xml.ns.naming_1.PortType;
+import org.apache.geronimo.xml.ns.naming_1.ServiceRefType;
+import org.eclipse.jface.viewers.ILabelProvider;
+import org.eclipse.jface.viewers.ITreeContentProvider;
+import org.eclipse.jface.wizard.Wizard;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.ui.forms.widgets.FormToolkit;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class ServiceRefSection extends AbstractTreeSection {
+    public ServiceRefSection(JAXBElement plan, Composite parent, FormToolkit toolkit, int style, List serviceRefs) {
+        super(plan, parent, toolkit, style);
+        this.objectContainer = serviceRefs;
+        createClient();
+    }
+
+    @Override
+    public String getTitle() {
+        return CommonMessages.editorServiceRefTitle;
+    }
+
+    @Override
+    public String getDescription() {
+        return CommonMessages.editorServiceRefDescription;
+    }
+
+    @Override
+    public Wizard getWizard() {
+        return new ServiceRefWizard(this);
+    }
+
+    @Override
+    public Class getTableEntryObjectType() {
+        return ServiceRefType.class;
+    }
+
+    @Override
+    protected void activateAddButton() {
+        if (tree.getSelectionCount() == 0 || tree.getSelection()[0].getParentItem() == null) {
+            addButton.setEnabled(true);
+        } else {
+            addButton.setEnabled(false);
+        }
+    }
+
+    public ServiceRefType getSelectedObject () {
+        if (tree.getSelection().length == 0) {
+            return null;
+        }
+        return (ServiceRefType)tree.getSelection()[0].getData();
+    }
+    
+    @Override
+    public void removeItem(Object anItem) {
+        if (ServiceRefType.class.isInstance(anItem)) {
+            getObjectContainer().remove(anItem);
+        }
+        else if (PortType.class.isInstance(anItem)) {
+        	ServiceRefType serviceRef = (ServiceRefType)tree.getSelection()[0].getParentItem().getData();
+            serviceRef.getPort().remove(anItem);
+        }
+        else if (PortCompletionType.class.isInstance(anItem)) {
+        	ServiceRefType serviceRef = (ServiceRefType)tree.getSelection()[0].getParentItem().getData();
+            serviceRef.getServiceCompletion().getPortCompletion().remove(anItem);
+        }
+    }
+    
+    @Override
+    public Object getInput() {
+        if (objectContainer != null) {
+            return objectContainer;
+        }
+        return super.getInput();
+    }
+
+    @Override
+    public ITreeContentProvider getContentProvider() {
+        return new ContentProvider() {
+            @Override
+            public Object[] getElements(Object inputElement) {
+                return getChildren(inputElement);
+            }
+
+            @Override
+            public Object[] getChildren(Object parentElement) {
+                if (List.class.isInstance(parentElement)) {
+                    return ((List)parentElement).toArray();
+                }
+                if (ServiceRefType.class.isInstance(parentElement)) {
+                    ServiceRefType serviceRef = (ServiceRefType)parentElement;
+                    Object[] portList = serviceRef.getPort().toArray();
+                    Object[] compList = new Object[0];
+                    if (serviceRef.getServiceCompletion() != null) {
+                        compList = serviceRef.getServiceCompletion().getPortCompletion().toArray();
+                    }
+                    Object[] fullList = new Object[portList.length + compList.length];
+                    System.arraycopy(portList, 0, fullList, 0, portList.length);
+                    System.arraycopy(compList, 0, fullList, portList.length, compList.length);
+                    return fullList;
+                }
+                return new String[] {};
+            }
+        };
+    }
+
+    @Override
+    public ILabelProvider getLabelProvider() {
+        return new LabelProvider() {
+            @Override
+            public String getText(Object element) {
+                if (ServiceRefType.class.isInstance(element)) {
+                	ServiceRefType serviceRef = (ServiceRefType)element;
+                        String retString = "Service Ref: name = \"" + serviceRef.getServiceRefName() + "\"";
+                        if (serviceRef.getServiceCompletion() != null) {
+                            retString += ", service completion name = \"" + serviceRef.getServiceCompletion().getServiceName() + "\"";
+                        }
+                        return retString;
+                }
+                else if (PortType.class.isInstance(element)) {
+                	PortType port = (PortType)element;
+                    return "Port: name = \"" + port.getPortName() + 
+                            "\", protocol = \"" + port.getProtocol() + 
+                            "\", host = \"" + port.getHost() + 
+                            "\", port = \"" + port.getPort() + 
+                            "\", uri = \"" + port.getUri() + 
+                            "\", credential = \"" + port.getCredentialsName() + "\"";
+                }
+                else if (PortCompletionType.class.isInstance(element)) {
+                	PortCompletionType portComp = (PortCompletionType)element;
+                    return "Port Completion: name = \"" + portComp.getPort().getPortName() + 
+                            "\", protocol = \"" + portComp.getPort().getProtocol() + 
+                            "\", host = \"" + portComp.getPort().getHost() + 
+                            "\", port = \"" + portComp.getPort().getPort() + 
+                            "\", uri = \"" + portComp.getPort().getUri() + 
+                            "\", credential = \"" + portComp.getPort().getCredentialsName() +
+                            "\", binding name = \"" + portComp.getBindingName() + "\"";
+                }
+
+                return null;
+            }
+
+            @Override
+            public Image getImage(Object arg0) {
+                return Activator.imageDescriptorFromPlugin("org.eclipse.jst.j2ee",
+                        "icons/full/obj16/module_web_obj.gif").createImage();
+            }
+        };
+    }
+}



Mime
View raw message