plugins/org.apache.geronimo.st.v21.ui/src/main/java/org/apache/geronimo/st/v21/ui/wizards/ServiceRefWizard.java [35:173]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
public class ServiceRefWizard extends AbstractTreeWizard {

    private final int SERVICE_REF = 0;
    private final int PORT = 1;
    private final int PORT_COMPLETION = 2;

    public ServiceRefWizard(AbstractTreeSection section) {
        super(section, 3, 7);
        elementTypes[SERVICE_REF] = "Service Reference";
        elementTypes[PORT] = "Port";
        elementTypes[PORT_COMPLETION] = "Port Completion";
    }

    public class ServiceRefWizardPage extends AbstractTreeWizardPage {

        public ServiceRefWizardPage(String pageName) {
            super(pageName);
        }

        protected void initControl () {
            if (eObject == null) {
                element.select(SERVICE_REF);
                ServiceRef serviceRef = (ServiceRef)section.getSelectedObject();
                // use of ports and port completions are mutually exclusive
                if (serviceRef == null) {
                    element.setEnabled(false);
                } else if (serviceRef.getServiceCompletion() == null) {
                    element.remove(PORT_COMPLETION);
                } else {
                    element.remove(PORT);
                }
            }
            else {
                if (ServiceRef.class.isInstance(eObject)) {
                    textList.get(0).setText(((ServiceRef)eObject).getServiceRefName());
                    if (((ServiceRef)eObject).getServiceCompletion() != null) {
                        textList.get(1).setText(((ServiceRef)eObject).getServiceCompletion().getServiceName());
                    }
                    element.select(SERVICE_REF);
                }
                else if (Port.class.isInstance(eObject)) {
                    textList.get(0).setText(((Port)eObject).getPortName());
                    textList.get(1).setText(((Port)eObject).getProtocol());
                    textList.get(2).setText(((Port)eObject).getHost());
                    textList.get(3).setText(((Port)eObject).getPort().toString());
                    textList.get(4).setText(((Port)eObject).getUri());
                    textList.get(5).setText(((Port)eObject).getCredentialsName());
                    element.select(PORT);
                }
                else if (PortCompletion.class.isInstance(eObject)) {
                    textList.get(0).setText(((PortCompletion)eObject).getPort().getPortName());
                    textList.get(1).setText(((PortCompletion)eObject).getPort().getProtocol());
                    textList.get(2).setText(((PortCompletion)eObject).getPort().getHost());
                    textList.get(3).setText(((PortCompletion)eObject).getPort().getPort().toString());
                    textList.get(4).setText(((PortCompletion)eObject).getPort().getUri());
                    textList.get(5).setText(((PortCompletion)eObject).getPort().getCredentialsName());
                    textList.get(6).setText(((PortCompletion)eObject).getBindingName());
                    element.select(PORT_COMPLETION);
                }
                element.setEnabled(false);
            }
        }
        
        protected void toggleFields (boolean clearFields) {
            if (element.getText().equals(elementTypes[SERVICE_REF])) {
                for (int i = 0; i < maxTextFields; i++) {
                    labelList.get(i).setVisible(i < 2 ? true : false);
                    textList.get(i).setVisible(i < 2 ? true : false);
                    if (clearFields == true) {
                        textList.get(i).setText("");
                    }
                }
                labelList.get(0).setText(CommonMessages.name);
                labelList.get(1).setText(CommonMessages.serviceCompletionName);
                // if we are doing an add, then we need to make sure that the longest
                // text can be handled
                labelList.get(2).setText(CommonMessages.protocol);
                labelList.get(3).setText(CommonMessages.hostName);
                labelList.get(4).setText(CommonMessages.portValue);
                labelList.get(5).setText(CommonMessages.credential);
                labelList.get(6).setText(CommonMessages.bindingName);
            }
            else if (element.getText().equals(elementTypes[PORT])) {
                for (int i = 0; i < maxTextFields; i++) {
                    labelList.get(i).setVisible(i < 6 ? true : false);
                    textList.get(i).setVisible(i < 6 ? true : false);
                    if (clearFields == true) {
                        textList.get(i).setText("");
                    }
                }
                labelList.get(0).setText(CommonMessages.name);
                labelList.get(1).setText(CommonMessages.protocol);
                labelList.get(2).setText(CommonMessages.hostName);
                labelList.get(3).setText(CommonMessages.portValue);
                labelList.get(4).setText(CommonMessages.uri);
                labelList.get(5).setText(CommonMessages.credential);
            }
            else if (element.getText().equals(elementTypes[PORT_COMPLETION])) {
                for (int i = 0; i < maxTextFields; i++) {
                    labelList.get(i).setVisible(true);
                    textList.get(i).setVisible(true);
                    if (clearFields == true) {
                        textList.get(i).setText("");
                    }
                }
                labelList.get(0).setText(CommonMessages.name);
                labelList.get(1).setText(CommonMessages.protocol);
                labelList.get(2).setText(CommonMessages.hostName);
                labelList.get(3).setText(CommonMessages.portValue);
                labelList.get(4).setText(CommonMessages.uri);
                labelList.get(5).setText(CommonMessages.credential);
                labelList.get(6).setText(CommonMessages.bindingName);
            }
        }

        public String getWizardPageTitle() {
            return CommonMessages.wizardPageTitle_ServiceRef;
        }

        public String getWizardPageDescription() {
            return CommonMessages.wizardPageDescription_ServiceRef;
        }
    }

    @Override
    public void addPages() {
        addPage(new ServiceRefWizardPage("Page0"));
    }

    @Override
    public boolean performFinish() {
        ServiceRef serviceRef;
        if (element.getText().equals(elementTypes[SERVICE_REF])) {
            if (isEmpty(textList.get(0).getText())) {
                return false;
            }
            serviceRef = (ServiceRef)eObject;
            if (serviceRef == null) {
                serviceRef = (ServiceRef)getEFactory().create(ServiceRef.class);
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



plugins/org.apache.geronimo.st.v30.ui/src/main/java/org/apache/geronimo/st/v30/ui/wizards/ServiceRefWizard.java [35:173]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
public class ServiceRefWizard extends AbstractTreeWizard {

    private final int SERVICE_REF = 0;
    private final int PORT = 1;
    private final int PORT_COMPLETION = 2;

    public ServiceRefWizard(AbstractTreeSection section) {
        super(section, 3, 7);
        elementTypes[SERVICE_REF] = "Service Reference";
        elementTypes[PORT] = "Port";
        elementTypes[PORT_COMPLETION] = "Port Completion";
    }

    public class ServiceRefWizardPage extends AbstractTreeWizardPage {

        public ServiceRefWizardPage(String pageName) {
            super(pageName);
        }

        protected void initControl () {
            if (eObject == null) {
                element.select(SERVICE_REF);
                ServiceRef serviceRef = (ServiceRef)section.getSelectedObject();
                // use of ports and port completions are mutually exclusive
                if (serviceRef == null) {
                    element.setEnabled(false);
                } else if (serviceRef.getServiceCompletion() == null) {
                    element.remove(PORT_COMPLETION);
                } else {
                    element.remove(PORT);
                }
            }
            else {
                if (ServiceRef.class.isInstance(eObject)) {
                    textList.get(0).setText(((ServiceRef)eObject).getServiceRefName());
                    if (((ServiceRef)eObject).getServiceCompletion() != null) {
                        textList.get(1).setText(((ServiceRef)eObject).getServiceCompletion().getServiceName());
                    }
                    element.select(SERVICE_REF);
                }
                else if (Port.class.isInstance(eObject)) {
                    textList.get(0).setText(((Port)eObject).getPortName());
                    textList.get(1).setText(((Port)eObject).getProtocol());
                    textList.get(2).setText(((Port)eObject).getHost());
                    textList.get(3).setText(((Port)eObject).getPort().toString());
                    textList.get(4).setText(((Port)eObject).getUri());
                    textList.get(5).setText(((Port)eObject).getCredentialsName());
                    element.select(PORT);
                }
                else if (PortCompletion.class.isInstance(eObject)) {
                    textList.get(0).setText(((PortCompletion)eObject).getPort().getPortName());
                    textList.get(1).setText(((PortCompletion)eObject).getPort().getProtocol());
                    textList.get(2).setText(((PortCompletion)eObject).getPort().getHost());
                    textList.get(3).setText(((PortCompletion)eObject).getPort().getPort().toString());
                    textList.get(4).setText(((PortCompletion)eObject).getPort().getUri());
                    textList.get(5).setText(((PortCompletion)eObject).getPort().getCredentialsName());
                    textList.get(6).setText(((PortCompletion)eObject).getBindingName());
                    element.select(PORT_COMPLETION);
                }
                element.setEnabled(false);
            }
        }
        
        protected void toggleFields (boolean clearFields) {
            if (element.getText().equals(elementTypes[SERVICE_REF])) {
                for (int i = 0; i < maxTextFields; i++) {
                    labelList.get(i).setVisible(i < 2 ? true : false);
                    textList.get(i).setVisible(i < 2 ? true : false);
                    if (clearFields == true) {
                        textList.get(i).setText("");
                    }
                }
                labelList.get(0).setText(CommonMessages.name);
                labelList.get(1).setText(CommonMessages.serviceCompletionName);
                // if we are doing an add, then we need to make sure that the longest
                // text can be handled
                labelList.get(2).setText(CommonMessages.protocol);
                labelList.get(3).setText(CommonMessages.hostName);
                labelList.get(4).setText(CommonMessages.portValue);
                labelList.get(5).setText(CommonMessages.credential);
                labelList.get(6).setText(CommonMessages.bindingName);
            }
            else if (element.getText().equals(elementTypes[PORT])) {
                for (int i = 0; i < maxTextFields; i++) {
                    labelList.get(i).setVisible(i < 6 ? true : false);
                    textList.get(i).setVisible(i < 6 ? true : false);
                    if (clearFields == true) {
                        textList.get(i).setText("");
                    }
                }
                labelList.get(0).setText(CommonMessages.name);
                labelList.get(1).setText(CommonMessages.protocol);
                labelList.get(2).setText(CommonMessages.hostName);
                labelList.get(3).setText(CommonMessages.portValue);
                labelList.get(4).setText(CommonMessages.uri);
                labelList.get(5).setText(CommonMessages.credential);
            }
            else if (element.getText().equals(elementTypes[PORT_COMPLETION])) {
                for (int i = 0; i < maxTextFields; i++) {
                    labelList.get(i).setVisible(true);
                    textList.get(i).setVisible(true);
                    if (clearFields == true) {
                        textList.get(i).setText("");
                    }
                }
                labelList.get(0).setText(CommonMessages.name);
                labelList.get(1).setText(CommonMessages.protocol);
                labelList.get(2).setText(CommonMessages.hostName);
                labelList.get(3).setText(CommonMessages.portValue);
                labelList.get(4).setText(CommonMessages.uri);
                labelList.get(5).setText(CommonMessages.credential);
                labelList.get(6).setText(CommonMessages.bindingName);
            }
        }

        public String getWizardPageTitle() {
            return CommonMessages.wizardPageTitle_ServiceRef;
        }

        public String getWizardPageDescription() {
            return CommonMessages.wizardPageDescription_ServiceRef;
        }
    }

    @Override
    public void addPages() {
        addPage(new ServiceRefWizardPage("Page0"));
    }

    @Override
    public boolean performFinish() {
        ServiceRef serviceRef;
        if (element.getText().equals(elementTypes[SERVICE_REF])) {
            if (isEmpty(textList.get(0).getText())) {
                return false;
            }
            serviceRef = (ServiceRef)eObject;
            if (serviceRef == null) {
                serviceRef = (ServiceRef)getEFactory().create(ServiceRef.class);
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



