plugins/org.apache.geronimo.st.v21.ui/src/main/java/org/apache/geronimo/st/v21/ui/sections/CommonGeneralSection.java [51:292]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
public abstract class CommonGeneralSection extends AbstractSectionPart {

    protected Text artifactId;

    protected Text groupId;

    protected Text version;

    protected Text type;

    protected Button inverseClassLoading;

    protected Button suppressDefaultEnv;
    
    protected Button sharedLibDepends;
    
    protected ObjectFactory deploymentObjectFactory = null;

    public CommonGeneralSection(Composite parent, FormToolkit toolkit, int style, JAXBElement plan) {
        super(parent, toolkit, style, plan);
    }

    protected void createClient() {

        Section section = getSection();

        section.setText(getSectionGeneralTitle());
        section.setDescription(getSectionGeneralDescription());
        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);

        createLabel(composite, CommonMessages.groupId);

        groupId = toolkit.createText(composite, getGroupId(), SWT.BORDER);
        groupId.setLayoutData(createTextFieldGridData());
        groupId.addModifyListener(new ModifyListener() {
            public void modifyText(ModifyEvent e) {
                getModuleId(true).setGroupId(groupId.getText());
                markDirty();
            }
        });

        createLabel(composite, CommonMessages.artifactId);

        artifactId = toolkit.createText(composite, getArtifactId(), SWT.BORDER);
        artifactId.setLayoutData(createTextFieldGridData());
        artifactId.addModifyListener(new ModifyListener() {
            public void modifyText(ModifyEvent e) {
                getModuleId(true).setArtifactId(artifactId.getText());
                markDirty();
            }
        });

        createLabel(composite, CommonMessages.version);

        version = toolkit.createText(composite, getVersion(), SWT.BORDER);
        version.setLayoutData(createTextFieldGridData());
        version.addModifyListener(new ModifyListener() {
            public void modifyText(ModifyEvent e) {
                getModuleId(true).setVersion(version.getText());
                markDirty();
            }
        });

        createLabel(composite, CommonMessages.artifactType);

        type = toolkit.createText(composite, getArtifact(), SWT.BORDER);
        type.setLayoutData(createTextFieldGridData());
        type.addModifyListener(new ModifyListener() {
            public void modifyText(ModifyEvent e) {
                getModuleId(true).setType(type.getText());
                markDirty();
            }
        });

        inverseClassLoading = toolkit.createButton(composite, CommonMessages.inverseClassloading, SWT.CHECK);
        inverseClassLoading.setSelection(isInverseClassloading());
        GridData data = new GridData();
        data.horizontalSpan = 2;
        inverseClassLoading.setLayoutData(data);

        inverseClassLoading.addSelectionListener(new SelectionListener() {
            public void widgetDefaultSelected(SelectionEvent e) {
            }

            public void widgetSelected(SelectionEvent e) {
                setInverseClassloading(inverseClassLoading.getSelection());
                markDirty();
            }
        });

        suppressDefaultEnv = toolkit.createButton(composite, CommonMessages.supressDefaultEnv, SWT.CHECK);
        suppressDefaultEnv.setSelection(isSuppressDefaultEnvironment());
        data = new GridData();
        data.horizontalSpan = 2;
        suppressDefaultEnv.setLayoutData(data);

        suppressDefaultEnv.addSelectionListener(new SelectionListener() {
            public void widgetDefaultSelected(SelectionEvent e) {
            }

            public void widgetSelected(SelectionEvent e) {
                setSuppressDefaultEnvironment(suppressDefaultEnv.getSelection());
                markDirty();
            }
        });
        
        sharedLibDepends = toolkit.createButton(composite, CommonMessages.sharedLibDepends, SWT.CHECK);
        sharedLibDepends.setSelection(isSharedLibDependency());
        data = new GridData();
        data.horizontalSpan = 2;
        sharedLibDepends.setLayoutData(data);

        sharedLibDepends.addSelectionListener(new SelectionListener() {
            public void widgetDefaultSelected(SelectionEvent e) {
            }

            public void widgetSelected(SelectionEvent e) {
                setSharedLibDependency(sharedLibDepends.getSelection());
                markDirty();
            }
        });
    }

    protected String getGroupId() {
        Artifact moduleId = getModuleId(false);
        if (moduleId != null
                && moduleId.getGroupId() != null)
            return moduleId.getGroupId();
        return "";
    }

    protected String getArtifactId() {
        Artifact moduleId = getModuleId(false);
        if (moduleId != null
                && moduleId.getArtifactId() != null)
            return moduleId.getArtifactId();
        return "";
    }

    protected String getVersion() {
        Artifact moduleId = getModuleId(false);
        if (moduleId != null
                && moduleId.getVersion() != null)
            return moduleId.getVersion();
        return "";
    }

    protected String getArtifact() {
        Artifact moduleId = getModuleId(false);
        if (moduleId != null
                && moduleId.getType() != null)
            return moduleId.getType();
        return "";
    }

    protected boolean isInverseClassloading() {
        Environment type = getEnvironment(false);
        return type != null && type.getInverseClassloading() != null;
    }

    protected boolean isSuppressDefaultEnvironment() {
        Environment type = getEnvironment(false);
        return type != null && type.getSuppressDefaultEnvironment() != null;
    }
    
    protected boolean isSharedLibDependency() {
        Dependencies depType = getDependencies(false);
        if(depType != null) {
            return getSharedLibDependency(depType) != null;
        }
        return false;
    }

    protected void setInverseClassloading(boolean enable) {
        if (enable) {
            Environment type = getEnvironment(true);
            type.setInverseClassloading(getDeploymentObjectFactory().createEmpty());
        } else {
            Environment type = getEnvironment(false);
            if (type != null) {
                type.setInverseClassloading(null);
            }
        }
    }

    protected void setSuppressDefaultEnvironment(boolean enable) {
        if (enable) {
            Environment type = getEnvironment(true);
            type.setSuppressDefaultEnvironment(getDeploymentObjectFactory().createEmpty());
        } else {
            Environment type = getEnvironment(false);
            if (type != null) {
                type.setSuppressDefaultEnvironment(null);
            }
        }
    }
    
    protected void setSharedLibDependency(boolean enable) {
        if (enable) {
            Dependencies deptype = getDependencies(true);
            Dependency sharedLib = getDeploymentObjectFactory().createDependency();
            sharedLib.setGroupId("org.apache.geronimo.configs");
            sharedLib.setArtifactId("sharedlib");
            sharedLib.setType("car");
            deptype.getDependency().add(sharedLib);
        } else {
            Dependencies deptype = getDependencies(false);
            if (deptype != null) {
                Artifact artifact = getSharedLibDependency(deptype);
                if(artifact != null) {
                    deptype.getDependency().remove(artifact);
                }
            }
        }
    }
    
    private Artifact getSharedLibDependency(Dependencies dependencies) {
        Dependencies depType = getDependencies(false);
        List dependenciesList = depType.getDependency();
        Iterator i = dependenciesList.iterator();
        while(i.hasNext()) {
            Artifact artifact = (Artifact) i.next();
            if("org.apache.geronimo.configs".equals(artifact.getGroupId()) && "sharedlib".equals(artifact.getArtifactId()) && "car".equals(artifact.getType())) {
                return artifact;
            }
        }
        return null;
    }

    protected Environment getEnvironment(boolean create) {
        Environment type = null;
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



plugins/org.apache.geronimo.st.v30.ui/src/main/java/org/apache/geronimo/st/v30/ui/sections/CommonGeneralSection.java [50:291]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
public abstract class CommonGeneralSection extends AbstractSectionPart {

    protected Text artifactId;

    protected Text groupId;

    protected Text version;

    protected Text type;

    protected Button inverseClassLoading;

    protected Button suppressDefaultEnv;
    
    protected Button sharedLibDepends;
    
    protected ObjectFactory deploymentObjectFactory = null;

    public CommonGeneralSection(Composite parent, FormToolkit toolkit, int style, JAXBElement plan) {
        super(parent, toolkit, style, plan);
    }

    protected void createClient() {

        Section section = getSection();

        section.setText(getSectionGeneralTitle());
        section.setDescription(getSectionGeneralDescription());
        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);

        createLabel(composite, CommonMessages.groupId);

        groupId = toolkit.createText(composite, getGroupId(), SWT.BORDER);
        groupId.setLayoutData(createTextFieldGridData());
        groupId.addModifyListener(new ModifyListener() {
            public void modifyText(ModifyEvent e) {
                getModuleId(true).setGroupId(groupId.getText());
                markDirty();
            }
        });

        createLabel(composite, CommonMessages.artifactId);

        artifactId = toolkit.createText(composite, getArtifactId(), SWT.BORDER);
        artifactId.setLayoutData(createTextFieldGridData());
        artifactId.addModifyListener(new ModifyListener() {
            public void modifyText(ModifyEvent e) {
                getModuleId(true).setArtifactId(artifactId.getText());
                markDirty();
            }
        });

        createLabel(composite, CommonMessages.version);

        version = toolkit.createText(composite, getVersion(), SWT.BORDER);
        version.setLayoutData(createTextFieldGridData());
        version.addModifyListener(new ModifyListener() {
            public void modifyText(ModifyEvent e) {
                getModuleId(true).setVersion(version.getText());
                markDirty();
            }
        });

        createLabel(composite, CommonMessages.artifactType);

        type = toolkit.createText(composite, getArtifact(), SWT.BORDER);
        type.setLayoutData(createTextFieldGridData());
        type.addModifyListener(new ModifyListener() {
            public void modifyText(ModifyEvent e) {
                getModuleId(true).setType(type.getText());
                markDirty();
            }
        });

        inverseClassLoading = toolkit.createButton(composite, CommonMessages.inverseClassloading, SWT.CHECK);
        inverseClassLoading.setSelection(isInverseClassloading());
        GridData data = new GridData();
        data.horizontalSpan = 2;
        inverseClassLoading.setLayoutData(data);

        inverseClassLoading.addSelectionListener(new SelectionListener() {
            public void widgetDefaultSelected(SelectionEvent e) {
            }

            public void widgetSelected(SelectionEvent e) {
                setInverseClassloading(inverseClassLoading.getSelection());
                markDirty();
            }
        });

        suppressDefaultEnv = toolkit.createButton(composite, CommonMessages.supressDefaultEnv, SWT.CHECK);
        suppressDefaultEnv.setSelection(isSuppressDefaultEnvironment());
        data = new GridData();
        data.horizontalSpan = 2;
        suppressDefaultEnv.setLayoutData(data);

        suppressDefaultEnv.addSelectionListener(new SelectionListener() {
            public void widgetDefaultSelected(SelectionEvent e) {
            }

            public void widgetSelected(SelectionEvent e) {
                setSuppressDefaultEnvironment(suppressDefaultEnv.getSelection());
                markDirty();
            }
        });
        
        sharedLibDepends = toolkit.createButton(composite, CommonMessages.sharedLibDepends, SWT.CHECK);
        sharedLibDepends.setSelection(isSharedLibDependency());
        data = new GridData();
        data.horizontalSpan = 2;
        sharedLibDepends.setLayoutData(data);

        sharedLibDepends.addSelectionListener(new SelectionListener() {
            public void widgetDefaultSelected(SelectionEvent e) {
            }

            public void widgetSelected(SelectionEvent e) {
                setSharedLibDependency(sharedLibDepends.getSelection());
                markDirty();
            }
        });
    }

    protected String getGroupId() {
        Artifact moduleId = getModuleId(false);
        if (moduleId != null
                && moduleId.getGroupId() != null)
            return moduleId.getGroupId();
        return "";
    }

    protected String getArtifactId() {
        Artifact moduleId = getModuleId(false);
        if (moduleId != null
                && moduleId.getArtifactId() != null)
            return moduleId.getArtifactId();
        return "";
    }

    protected String getVersion() {
        Artifact moduleId = getModuleId(false);
        if (moduleId != null
                && moduleId.getVersion() != null)
            return moduleId.getVersion();
        return "";
    }

    protected String getArtifact() {
        Artifact moduleId = getModuleId(false);
        if (moduleId != null
                && moduleId.getType() != null)
            return moduleId.getType();
        return "";
    }

    protected boolean isInverseClassloading() {
        Environment type = getEnvironment(false);
        return type != null && type.getInverseClassloading() != null;
    }

    protected boolean isSuppressDefaultEnvironment() {
        Environment type = getEnvironment(false);
        return type != null && type.getSuppressDefaultEnvironment() != null;
    }
    
    protected boolean isSharedLibDependency() {
        Dependencies depType = getDependencies(false);
        if(depType != null) {
            return getSharedLibDependency(depType) != null;
        }
        return false;
    }

    protected void setInverseClassloading(boolean enable) {
        if (enable) {
            Environment type = getEnvironment(true);
            type.setInverseClassloading(getDeploymentObjectFactory().createEmpty());
        } else {
            Environment type = getEnvironment(false);
            if (type != null) {
                type.setInverseClassloading(null);
            }
        }
    }

    protected void setSuppressDefaultEnvironment(boolean enable) {
        if (enable) {
            Environment type = getEnvironment(true);
            type.setSuppressDefaultEnvironment(getDeploymentObjectFactory().createEmpty());
        } else {
            Environment type = getEnvironment(false);
            if (type != null) {
                type.setSuppressDefaultEnvironment(null);
            }
        }
    }
    
    protected void setSharedLibDependency(boolean enable) {
        if (enable) {
            Dependencies deptype = getDependencies(true);
            Dependency sharedLib = getDeploymentObjectFactory().createDependency();
            sharedLib.setGroupId("org.apache.geronimo.configs");
            sharedLib.setArtifactId("sharedlib");
            sharedLib.setType("car");
            deptype.getDependency().add(sharedLib);
        } else {
            Dependencies deptype = getDependencies(false);
            if (deptype != null) {
                Artifact artifact = getSharedLibDependency(deptype);
                if(artifact != null) {
                    deptype.getDependency().remove(artifact);
                }
            }
        }
    }
    
    private Artifact getSharedLibDependency(Dependencies dependencies) {
        Dependencies depType = getDependencies(false);
        List dependenciesList = depType.getDependency();
        Iterator i = dependenciesList.iterator();
        while(i.hasNext()) {
            Artifact artifact = (Artifact) i.next();
            if("org.apache.geronimo.configs".equals(artifact.getGroupId()) && "sharedlib".equals(artifact.getArtifactId()) && "car".equals(artifact.getType())) {
                return artifact;
            }
        }
        return null;
    }

    protected Environment getEnvironment(boolean create) {
        Environment type = null;
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



