plugins/org.apache.geronimo.st.v21.ui/src/main/java/org/apache/geronimo/st/v21/ui/wizards/GBeanWizard.java [36:192]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
public class GBeanWizard extends AbstractTreeWizard {

    private final int GBEAN = 0;
    private final int ATTRIBUTE = 1;
    private final int DEPENDENCY = 2;
    private final int REFERENCE = 3;

    public GBeanWizard(AbstractTreeSection section) {
        super(section, 4, 7);
        elementTypes[GBEAN] = "GBean";
        elementTypes[ATTRIBUTE] = "Attribute";
        elementTypes[DEPENDENCY] = "Dependency";
        elementTypes[REFERENCE] = "Reference";
    }

    public class GBeanWizardPage extends AbstractTreeWizardPage {

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

        protected void initControl() {
            if (eObject == null) {
                element.select(GBEAN);
                if (section.getSelectedObject() == null) {
                    element.setEnabled(false);
                }
            }
            else {
                // change eObject to be the value of the JAXBElement
                eObject = ((JAXBElement)eObject).getValue();
                if (Gbean.class.isInstance(eObject)) {
                    textList.get(0).setText(((Gbean)eObject).getName());
                    textList.get(1).setText(((Gbean)eObject).getClazz());
                    element.select(GBEAN);
                }
                else if (Attribute.class.isInstance(eObject)) {
                    textList.get(0).setText(((Attribute)eObject).getName());
                    textList.get(1).setText(((Attribute)eObject).getType());
                    textList.get(2).setText(((Attribute)eObject).getValue());
                    element.select(ATTRIBUTE);
                }
                else if (Pattern.class.isInstance(eObject)) {
                    textList.get(0).setText(((Pattern)eObject).getGroupId());
                    textList.get(1).setText(((Pattern)eObject).getArtifactId());
                    textList.get(2).setText(((Pattern)eObject).getVersion());
                    textList.get(3).setText(((Pattern)eObject).getModule());
                    textList.get(4).setText(((Pattern)eObject).getType());
                    textList.get(5).setText(((Pattern)eObject).getCustomFoo());
                    element.select(DEPENDENCY);
                }
                else if (Reference.class.isInstance(eObject)) {
                    textList.get(0).setText(((Reference)eObject).getName());
                    textList.get(1).setText(((Reference)eObject).getGroupId());
                    textList.get(2).setText(((Reference)eObject).getArtifactId());
                    textList.get(3).setText(((Reference)eObject).getVersion());
                    textList.get(4).setText(((Reference)eObject).getModule());
                    textList.get(5).setText(((Reference)eObject).getType());
                    textList.get(6).setText(((Reference)eObject).getCustomFoo());
                    element.select(REFERENCE);
                }
                element.setEnabled(false);
            }
        }
        
        protected void toggleFields (boolean clearFields) {
            int selection = element.getSelectionIndex();
            switch (selection) {
            case GBEAN:
                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.className);
                // if we are doing an add, then we need to make sure that the longest
                // text can be handled
                labelList.get(2).setText(CommonMessages.groupId);
                labelList.get(3).setText(CommonMessages.artifactId);
                labelList.get(4).setText(CommonMessages.moduleId);
                labelList.get(5).setText(CommonMessages.artifactType);
                labelList.get(6).setText(CommonMessages.customName);
                break;
            case ATTRIBUTE:
                for (int i = 0; i < maxTextFields; i++) {
                    labelList.get(i).setVisible(i < 3 ? true : false);
                    textList.get(i).setVisible(i < 3 ? true : false);
                    if (clearFields == true) {
                        textList.get(i).setText("");
                    }
                }
                labelList.get(0).setText(CommonMessages.name);
                labelList.get(1).setText(CommonMessages.type);
                labelList.get(2).setText(CommonMessages.value);
                break;
            case DEPENDENCY:
                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.groupId);
                labelList.get(1).setText(CommonMessages.artifactId);
                labelList.get(2).setText(CommonMessages.version);
                labelList.get(3).setText(CommonMessages.moduleId);
                labelList.get(4).setText(CommonMessages.artifactType);
                labelList.get(5).setText(CommonMessages.customName);
                break;
            case REFERENCE:
                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.groupId);
                labelList.get(2).setText(CommonMessages.artifactId);
                labelList.get(3).setText(CommonMessages.version);
                labelList.get(4).setText(CommonMessages.moduleId);
                labelList.get(5).setText(CommonMessages.artifactType);
                labelList.get(6).setText(CommonMessages.customName);
                break;
            }
        }

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

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

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

    @Override
    public boolean performFinish() {
        Gbean gbean;
        switch (element.getSelectionIndex()) {
        case GBEAN:
            if (isEmpty(textList.get(0).getText()) || isEmpty(textList.get(1).getText())) {
                return false;
            }
            gbean = (Gbean)eObject;
            if (gbean == null) {
                gbean = (Gbean)getEFactory().create(Gbean.class);
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



plugins/org.apache.geronimo.st.v30.ui/src/main/java/org/apache/geronimo/st/v30/ui/wizards/GBeanWizard.java [36:192]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
public class GBeanWizard extends AbstractTreeWizard {

    private final int GBEAN = 0;
    private final int ATTRIBUTE = 1;
    private final int DEPENDENCY = 2;
    private final int REFERENCE = 3;

    public GBeanWizard(AbstractTreeSection section) {
        super(section, 4, 7);
        elementTypes[GBEAN] = "GBean";
        elementTypes[ATTRIBUTE] = "Attribute";
        elementTypes[DEPENDENCY] = "Dependency";
        elementTypes[REFERENCE] = "Reference";
    }

    public class GBeanWizardPage extends AbstractTreeWizardPage {

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

        protected void initControl() {
            if (eObject == null) {
                element.select(GBEAN);
                if (section.getSelectedObject() == null) {
                    element.setEnabled(false);
                }
            }
            else {
                // change eObject to be the value of the JAXBElement
                eObject = ((JAXBElement)eObject).getValue();
                if (Gbean.class.isInstance(eObject)) {
                    textList.get(0).setText(((Gbean)eObject).getName());
                    textList.get(1).setText(((Gbean)eObject).getClazz());
                    element.select(GBEAN);
                }
                else if (Attribute.class.isInstance(eObject)) {
                    textList.get(0).setText(((Attribute)eObject).getName());
                    textList.get(1).setText(((Attribute)eObject).getType());
                    textList.get(2).setText(((Attribute)eObject).getValue());
                    element.select(ATTRIBUTE);
                }
                else if (Pattern.class.isInstance(eObject)) {
                    textList.get(0).setText(((Pattern)eObject).getGroupId());
                    textList.get(1).setText(((Pattern)eObject).getArtifactId());
                    textList.get(2).setText(((Pattern)eObject).getVersion());
                    textList.get(3).setText(((Pattern)eObject).getModule());
                    textList.get(4).setText(((Pattern)eObject).getType());
                    textList.get(5).setText(((Pattern)eObject).getCustomFoo());
                    element.select(DEPENDENCY);
                }
                else if (Reference.class.isInstance(eObject)) {
                    textList.get(0).setText(((Reference)eObject).getName());
                    textList.get(1).setText(((Reference)eObject).getGroupId());
                    textList.get(2).setText(((Reference)eObject).getArtifactId());
                    textList.get(3).setText(((Reference)eObject).getVersion());
                    textList.get(4).setText(((Reference)eObject).getModule());
                    textList.get(5).setText(((Reference)eObject).getType());
                    textList.get(6).setText(((Reference)eObject).getCustomFoo());
                    element.select(REFERENCE);
                }
                element.setEnabled(false);
            }
        }
        
        protected void toggleFields (boolean clearFields) {
            int selection = element.getSelectionIndex();
            switch (selection) {
            case GBEAN:
                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.className);
                // if we are doing an add, then we need to make sure that the longest
                // text can be handled
                labelList.get(2).setText(CommonMessages.groupId);
                labelList.get(3).setText(CommonMessages.artifactId);
                labelList.get(4).setText(CommonMessages.moduleId);
                labelList.get(5).setText(CommonMessages.artifactType);
                labelList.get(6).setText(CommonMessages.customName);
                break;
            case ATTRIBUTE:
                for (int i = 0; i < maxTextFields; i++) {
                    labelList.get(i).setVisible(i < 3 ? true : false);
                    textList.get(i).setVisible(i < 3 ? true : false);
                    if (clearFields == true) {
                        textList.get(i).setText("");
                    }
                }
                labelList.get(0).setText(CommonMessages.name);
                labelList.get(1).setText(CommonMessages.type);
                labelList.get(2).setText(CommonMessages.value);
                break;
            case DEPENDENCY:
                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.groupId);
                labelList.get(1).setText(CommonMessages.artifactId);
                labelList.get(2).setText(CommonMessages.version);
                labelList.get(3).setText(CommonMessages.moduleId);
                labelList.get(4).setText(CommonMessages.artifactType);
                labelList.get(5).setText(CommonMessages.customName);
                break;
            case REFERENCE:
                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.groupId);
                labelList.get(2).setText(CommonMessages.artifactId);
                labelList.get(3).setText(CommonMessages.version);
                labelList.get(4).setText(CommonMessages.moduleId);
                labelList.get(5).setText(CommonMessages.artifactType);
                labelList.get(6).setText(CommonMessages.customName);
                break;
            }
        }

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

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

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

    @Override
    public boolean performFinish() {
        Gbean gbean;
        switch (element.getSelectionIndex()) {
        case GBEAN:
            if (isEmpty(textList.get(0).getText()) || isEmpty(textList.get(1).getText())) {
                return false;
            }
            gbean = (Gbean)eObject;
            if (gbean == null) {
                gbean = (Gbean)getEFactory().create(Gbean.class);
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



