plugins/org.apache.geronimo.st.v21.ui/src/main/java/org/apache/geronimo/st/v21/ui/sections/SecurityAdvancedSection.java [81:296]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
        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 Combo(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);
        populateCredentialStores();
        credentialStoreRef.addSelectionListener(new SelectionAdapter(){

			public void widgetSelected(SelectionEvent arg0) {
				setCredentialStoreRef();
				populateDefaultSubjectRealmName();
        		populateDefaultSubjectId();
				toggleAdvancedSettings();
				markDirty();
			}
        	
        });

        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 |SWT.READ_ONLY);
        populateDefaultSubjectRealmName();
        gridData = new GridData(SWT.LEFT, SWT.CENTER, false, false, 2, 1);
        gridData.widthHint = 100;
        defaultSubjectRealmName.setLayoutData(gridData);
        defaultSubjectRealmName.addSelectionListener(new SelectionAdapter() {
        	public void widgetSelected(SelectionEvent arg0) {
        		populateDefaultSubjectId();
                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 |SWT.READ_ONLY);
        defaultSubjectId.add(getDefaultSubjectId());
        gridData = new GridData(SWT.LEFT, SWT.CENTER, false, false, 2, 1);
        gridData.widthHint = 100;
        defaultSubjectId.setLayoutData(gridData);
        populateDefaultSubjectId();
        defaultSubjectId.addSelectionListener(new SelectionAdapter() {
        	public void widgetSelected(SelectionEvent arg0) {
                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 void populateDefaultSubjectRealmName() {
    	 defaultSubjectRealmName.removeAll();
    	
    	 String realmName = getDefaultSubjectRealmName();
    	 
    	 defaultSubjectRealmName.add(realmName);
         if (realmName.length() > 0) {
        	 defaultSubjectRealmName.add("");
         }
        
         String credentialStoreName = credentialStoreRef.getText();
         if (credentialStoreName!=null && credentialStoreName.length()!=0) {
        	 Map<String,ArrayList<String>> realmNameMap = credentialStoreAttributes.get(credentialStoreList.get(credentialStoreName));
        	 if (realmNameMap!=null) {
        		 Set<String> nameSet = realmNameMap.keySet();
        		 for (String name: nameSet){
        			 if (!name.equals(realmName))
        				 defaultSubjectRealmName.add(name);
        		 }
        	 }
         }   
         defaultSubjectRealmName.select(0);
	}
    
    private void populateDefaultSubjectId() {
	   	 defaultSubjectId.removeAll();
	   	
	   	 String subjectId = getDefaultSubjectId();
	   	 defaultSubjectId.add(subjectId);
	     if (subjectId.length() > 0) {
	       	defaultSubjectId.add(""); 
	     }
	        
	     String credentialStoreName = credentialStoreRef.getText();
	     String defaultRealmName = defaultSubjectRealmName.getText();
	     if (credentialStoreName!=null && credentialStoreName.length()!=0 && defaultRealmName!=null && defaultRealmName.length()!=0) {
	    	 Map<String,ArrayList<String>> realmNameMap = credentialStoreAttributes.get(credentialStoreList.get(credentialStoreName));
	    	 if (realmNameMap!=null) {
	    		 ArrayList<String> ids = realmNameMap.get(defaultRealmName);
	    		 for (String id: ids){
	    			 if (!id.equals(subjectId))   				 
	    				 defaultSubjectId.add(id);
	    		 }
	    	 }
	     }   
	     defaultSubjectId.select(0);
    }

/*    private Wizard getCredentialStoreRefWizard() {
        return null;
    }*/

    private void toggleAdvancedSettings() {
        boolean enable = false;
        
        if (getSecurity() != null && getSecurity().getCredentialStoreRef() != null 
        		&& (defaultSubjectRealmName.getItemCount() > 0 || defaultSubjectId.getItemCount() >0)) {
            enable = true;
        }
        
        defaultSubjectRealmName.setEnabled(enable);
        defaultSubjectId.setEnabled(enable);
        table.setEnabled(enable);        
        activateAddButton();
    }

    @Override
    public Object getInput() {
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



plugins/org.apache.geronimo.st.v30.ui/src/main/java/org/apache/geronimo/st/v30/ui/sections/SecurityAdvancedSection.java [77:292]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
        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 Combo(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);
        populateCredentialStores();
        credentialStoreRef.addSelectionListener(new SelectionAdapter(){

            public void widgetSelected(SelectionEvent arg0) {
                setCredentialStoreRef();
                populateDefaultSubjectRealmName();
                populateDefaultSubjectId();
                toggleAdvancedSettings();
                markDirty();
            }
            
        });

        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 |SWT.READ_ONLY);
        populateDefaultSubjectRealmName();
        gridData = new GridData(SWT.LEFT, SWT.CENTER, false, false, 2, 1);
        gridData.widthHint = 100;
        defaultSubjectRealmName.setLayoutData(gridData);
        defaultSubjectRealmName.addSelectionListener(new SelectionAdapter() {
            public void widgetSelected(SelectionEvent arg0) {
                populateDefaultSubjectId();
                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 |SWT.READ_ONLY);
        defaultSubjectId.add(getDefaultSubjectId());
        gridData = new GridData(SWT.LEFT, SWT.CENTER, false, false, 2, 1);
        gridData.widthHint = 100;
        defaultSubjectId.setLayoutData(gridData);
        populateDefaultSubjectId();
        defaultSubjectId.addSelectionListener(new SelectionAdapter() {
            public void widgetSelected(SelectionEvent arg0) {
                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 void populateDefaultSubjectRealmName() {
         defaultSubjectRealmName.removeAll();
        
         String realmName = getDefaultSubjectRealmName();
         
         defaultSubjectRealmName.add(realmName);
         if (realmName.length() > 0) {
             defaultSubjectRealmName.add("");
         }
        
         String credentialStoreName = credentialStoreRef.getText();
         if (credentialStoreName!=null && credentialStoreName.length()!=0) {
             Map<String,ArrayList<String>> realmNameMap = credentialStoreAttributes.get(credentialStoreList.get(credentialStoreName));
             if (realmNameMap!=null) {
                 Set<String> nameSet = realmNameMap.keySet();
                 for (String name: nameSet){
                     if (!name.equals(realmName))
                         defaultSubjectRealmName.add(name);
                 }
             }
         }   
         defaultSubjectRealmName.select(0);
    }
    
    private void populateDefaultSubjectId() {
         defaultSubjectId.removeAll();
        
         String subjectId = getDefaultSubjectId();
         defaultSubjectId.add(subjectId);
         if (subjectId.length() > 0) {
            defaultSubjectId.add(""); 
         }
            
         String credentialStoreName = credentialStoreRef.getText();
         String defaultRealmName = defaultSubjectRealmName.getText();
         if (credentialStoreName!=null && credentialStoreName.length()!=0 && defaultRealmName!=null && defaultRealmName.length()!=0) {
             Map<String,ArrayList<String>> realmNameMap = credentialStoreAttributes.get(credentialStoreList.get(credentialStoreName));
             if (realmNameMap!=null) {
                 ArrayList<String> ids = realmNameMap.get(defaultRealmName);
                 for (String id: ids){
                     if (!id.equals(subjectId))                  
                         defaultSubjectId.add(id);
                 }
             }
         }   
         defaultSubjectId.select(0);
    }

/*    private Wizard getCredentialStoreRefWizard() {
        return null;
    }*/

    private void toggleAdvancedSettings() {
        boolean enable = false;
        
        if (getSecurity() != null && getSecurity().getCredentialStoreRef() != null 
                && (defaultSubjectRealmName.getItemCount() > 0 || defaultSubjectId.getItemCount() >0)) {
            enable = true;
        }
        
        defaultSubjectRealmName.setEnabled(enable);
        defaultSubjectId.setEnabled(enable);
        table.setEnabled(enable);        
        activateAddButton();
    }

    @Override
    public Object getInput() {
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



