Example usage for org.eclipse.jface.wizard IWizardPage dispose

List of usage examples for org.eclipse.jface.wizard IWizardPage dispose

Introduction

In this page you can find the example usage for org.eclipse.jface.wizard IWizardPage dispose.

Prototype

void dispose();

Source Link

Document

Disposes the SWT resources allocated by this dialog page.

Usage

From source file:com.byterefinery.rmbench.dialogs.export.ExportWizard.java

License:Open Source License

public void dispose() {
    if (noExportPage != null)
        noExportPage.dispose();//  www . j a  v  a 2 s  . co m
    else {
        if (exportSelectionPage != null)
            exportSelectionPage.dispose();
        if (imageExportPage != null)
            imageExportPage.dispose();
        if (modelExportPage != null)
            modelExportPage.dispose();
    }
    if (modelPages != null) {
        for (int i = 0; i < modelPages.length; i++) {
            pageDump.add(modelPages[i]);
        }
    }
    for (IWizardPage page : pageDump) {
        page.dispose();
    }
    if (defaultImage != null)
        defaultImage.dispose();
}

From source file:com.nokia.carbide.internal.api.template.engine.LoadedTemplateUI.java

License:Open Source License

public void dispose() {
    if (wizardPages != null) {
        for (IWizardPage page : wizardPages) {
            page.dispose();
        }/*from w ww .j av a  2s  . co m*/
        wizardPages.clear();
        wizardPages = null;
    }
}

From source file:gov.redhawk.ide.spd.internal.ui.editor.wizard.ImplementationWizard.java

License:Open Source License

@Override
public void generatorChanged(final Implementation impl, final ICodeGeneratorDescriptor codeGeneratorDescriptor,
        final String previousImplId) {
    // If the code generator has settings, update the page as needed
    if (codeGeneratorDescriptor != null) {

        // First we find and remove the old pages.
        ICodegenWizardPage[] oldCodeGenPages = RedhawkCodegenUiActivator.getCodeGeneratorsRegistry()
                .findPageByGeneratorId(previousImplId);
        int numOfOldGenPages = oldCodeGenPages.length;

        // Only used these to determine number of pages, not needed
        for (ICodegenWizardPage oldCodeGenPage : oldCodeGenPages) {
            oldCodeGenPage.dispose();/*from w  ww  .  j  a va  2s . c  o m*/
        }

        List<IWizardPage> tmpList = new ArrayList<IWizardPage>();
        if (wizPages.size() > 1) {
            for (int i = 0; i < numOfOldGenPages; i++) {
                // The first page is always the implementation selection here.
                tmpList.add(wizPages.get(1 + i));
            }
        }

        ICodegenWizardPage[] oldGenPages = tmpList.toArray(new ICodegenWizardPage[tmpList.size()]);

        ImplementationSettings settings = this.implPage.getImplSettings();

        ICodegenWizardPage codeGenPages[] = null;

        boolean createControl = true;
        final ITemplateDesc[] templates = RedhawkCodegenActivator.getCodeGeneratorTemplatesRegistry()
                .findTemplatesByCodegen(codeGeneratorDescriptor.getId(),
                        this.softPkg.getDescriptor().getComponent().getComponentType());

        // Add the new page first
        if (settings != null && templates.length > 0) {
            // findPageByGeneratorId is always guaranteed to return at least
            // one page.
            codeGenPages = RedhawkCodegenUiActivator.getCodeGeneratorsRegistry()
                    .findPageByGeneratorId(settings.getGeneratorId());

            if (oldGenPages != null && oldGenPages.length > 0) {
                // Determine if this is the same set of codegen Pages as the previous selection. 
                boolean sameSetOfPages = true;
                if (numOfOldGenPages == codeGenPages.length) {
                    for (int i = 0; i < numOfOldGenPages; i++) {
                        if (oldGenPages[i].getClass() != codeGenPages[i].getClass()) {
                            sameSetOfPages = false;
                            break;
                        }
                    }
                } else {
                    sameSetOfPages = false;
                }

                // If the generator pages are different, add the new ones
                if (!sameSetOfPages) {
                    int tmpCodegenIndex = 1;
                    for (IWizardPage newCodeGenPage : codeGenPages) {
                        wizPages.add(tmpCodegenIndex, newCodeGenPage);
                        tmpCodegenIndex++;
                    }

                    // Otherwise get rid of the one we just created and
                    // reuse it
                } else {
                    for (IWizardPage newCodeGenPage : codeGenPages) {
                        newCodeGenPage.dispose();
                    }
                    codeGenPages = oldGenPages;
                    oldGenPages = null;

                    createControl = false;
                }
            } else {
                int tmpCodegenIndex = 1;
                for (ICodegenWizardPage cgp : codeGenPages) {
                    wizPages.add(tmpCodegenIndex, cgp);
                    tmpCodegenIndex++;
                }

            }
        }

        if (oldGenPages != null && oldGenPages.length > 0) {
            for (IWizardPage oldGenPage : oldGenPages) {
                wizPages.remove(oldGenPage);
                oldGenPage.dispose();
            }
        }

        // Initialize the settings page
        if (codeGenPages != null && settings != null && templates.length > 0) {

            settings.setOutputDir(null); // let the page pick the outputdir

            for (ICodegenWizardPage cgp : codeGenPages) {
                if (createControl) {
                    cgp.setWizard(this);
                    cgp.setCanFinish(true);
                    cgp.setCanFlipToNextPage(true);
                }
                // Configure the wizard page with the current settings
                cgp.configure(this.softPkg, impl, codeGeneratorDescriptor, settings,
                        this.softPkg.getDescriptor().getComponent().getComponentType());
            }

        }
    }

    // Force an update on the buttons, changing the generator may have
    // enabled or disabled the display of one of the buttons
    this.getContainer().updateButtons();
}

From source file:gov.redhawk.ide.spd.ui.wizard.NewScaResourceWizard.java

License:Open Source License

/**
 * @since 8.1/*from ww  w  .  j a  v  a 2  s . co m*/
 */
@Override
public void generatorChanged(final Implementation impl, final ICodeGeneratorDescriptor codeGeneratorDescriptor,
        final String previousImplId) {
    if (this.initializing) {
        return;
    }

    // If the code generator has settings, update the page as needed
    if (codeGeneratorDescriptor != null) {
        // Go through the list of implementations to see if we already have the selected implementation in the list.
        int implIndex = -1;
        for (int i = 0; i < this.implList.size(); i++) {
            if (this.implList.get(i).getImplementation() == impl) {
                implIndex = i;
                break;
            }
        }

        // This is assuming that the codegen page is the last page since it is the last statically added page.
        // TODO: Can we remove this now? Or is it needed down the line where its not going to be properly set?
        int codegenIndex = this.wizPages.size();
        ICodegenWizardPage[] oldGenPages = null;
        ImplementationSettings settings = null;
        int numOfOldGenPages = -1;
        // Figure out where the codegen page to replace is, based on the
        // current implementation
        for (int i = this.firstImplPage; i < this.wizPages.size(); ++i) {
            final IWizardPage page = this.wizPages.get(i);
            // If this is an implementation page, check to see if its index
            // matches the one for the current implementation
            if (page instanceof ImplementationWizardPage) {
                // If it does, check to see where to put the codegen page
                if (implIndex == 0) {
                    settings = ((ImplementationWizardPage) page).getImplSettings();
                    // The generator page is going after this one
                    codegenIndex = getWizardPageIndex(page) + 1;

                    // Three scenarios:
                    // - Implementation is the last in the list and it
                    // doesn't have a settings page previously
                    // - The implementation is in the middle of the list
                    // without a settings page
                    // - There is a settings page after this implementation
                    // page, replace it
                    // Store the generator page if it's next, otherwise
                    // we'll be inserting one

                    // If the wizard has an old codeGen page we need to snatch up then the wizards size will be
                    // greater or equal than codeGen index + 1.
                    // If the wizard has an old codeGen page we need to snatch up then the old codeGen page will be
                    // of type ICodegenWizardPage
                    if (codegenIndex + 1 <= this.wizPages.size()
                            && (this.wizPages.get(codegenIndex) instanceof ICodegenWizardPage)) {
                        ICodegenWizardPage[] oldCodeGenPages = RedhawkCodegenUiActivator
                                .getCodeGeneratorsRegistry().findPageByGeneratorId(previousImplId);
                        numOfOldGenPages = oldCodeGenPages.length;

                        // Only used these to determine number of pages, not needed
                        for (ICodegenWizardPage oldCodeGenPage : oldCodeGenPages) {
                            oldCodeGenPage.dispose();
                        }

                        List<IWizardPage> tmpList = new ArrayList<IWizardPage>();
                        for (int ii = 0; ii < numOfOldGenPages; ii++) {
                            tmpList.add(this.wizPages.get(codegenIndex + ii));
                        }

                        oldGenPages = tmpList.toArray(new ICodegenWizardPage[tmpList.size()]);
                    }
                    break;
                }
                // Otherwise decrement and try again
                implIndex--;
            }
        }

        // Allow the wizards to exit now if the generators are the same
        if (this.checkGenerator(settings, codeGeneratorDescriptor)) {
            this.getContainer().updateButtons();
            return;
        }
        ICodegenWizardPage[] codeGenPages = null;
        boolean createControl = true;
        final ITemplateDesc[] templates = RedhawkCodegenActivator.getCodeGeneratorTemplatesRegistry()
                .findTemplatesByCodegen(codeGeneratorDescriptor.getId(), this.componentType);

        // Add the new page first
        if (settings != null && templates.length > 0) {
            // findPageByGeneratorId is always guaranteed to return at least
            // one page.
            codeGenPages = RedhawkCodegenUiActivator.getCodeGeneratorsRegistry()
                    .findPageByGeneratorId(settings.getGeneratorId());

            if (oldGenPages != null) {
                // Determine if this is the same set of codegen Pages as the previous selection.
                boolean sameSetOfPages = true;
                if (numOfOldGenPages == codeGenPages.length) {
                    for (int i = 0; i < numOfOldGenPages; i++) {
                        if (oldGenPages[i].getClass() != codeGenPages[i].getClass()) {
                            sameSetOfPages = false;
                            break;
                        }
                    }
                } else {
                    sameSetOfPages = false;
                }

                // If the generator pages are different, add the new ones
                if (!sameSetOfPages) {
                    int tmpCodegenIndex = codegenIndex;
                    for (IWizardPage newCodeGenPage : codeGenPages) {
                        this.wizPages.add(tmpCodegenIndex, newCodeGenPage);
                        tmpCodegenIndex++;
                    }

                    // Otherwise get rid of the one we just created and
                    // reuse it
                } else {
                    for (IWizardPage newCodeGenPage : codeGenPages) {
                        newCodeGenPage.dispose();
                    }
                    codeGenPages = oldGenPages;
                    oldGenPages = null;

                    createControl = false;

                }
            } else if (codegenIndex == this.wizPages.size()) {
                for (IWizardPage codeGenPage : codeGenPages) {
                    this.wizPages.add(codeGenPage);
                }
            } else {
                int tmpCodegenIndex = codegenIndex;
                for (ICodegenWizardPage codeGenPage : codeGenPages) {
                    this.wizPages.add(tmpCodegenIndex, codeGenPage);
                    tmpCodegenIndex++;
                }

            }
        }

        if (oldGenPages != null) {
            for (IWizardPage oldGenPage : oldGenPages) {
                this.wizPages.remove(oldGenPage);
                oldGenPage.dispose();
            }
        }

        // Initialize the settings page
        if (codeGenPages != null && settings != null && templates.length > 0) {

            settings.setOutputDir(null); // let the page pick the outputdir

            for (ICodegenWizardPage codeGenPage : codeGenPages) {
                if (createControl) {
                    codeGenPage.setWizard(this);
                    codeGenPage.setCanFinish(true);
                    codeGenPage.setCanFlipToNextPage(true);
                }
                // Configure the wizard page with the current settings
                codeGenPage.configure(this.getSoftPkg(), impl, codeGeneratorDescriptor, settings,
                        this.componentType);
            }

        }
    }

    // Force an update on the buttons, changing the generator may have
    // enabled or disabled the display of one of the buttons
    this.getContainer().updateButtons();
}

From source file:org.bonitasoft.studio.common.jface.ExtensibleWizard.java

License:Open Source License

public void removeAllAdditionalPages() {
    for (IWizardPage p : additionalPages) {
        p.dispose();
    }
    additionalPages.clear();
}

From source file:org.eclipse.wst.common.project.facet.ui.ModifyFacetedProjectWizard.java

License:Open Source License

public void dispose() {
    super.dispose();

    for (int i = 0; i < this.facetPages.length; i++) {
        this.pagesToDispose.addAll(this.facetPages[i].pages);
    }/*from w ww  .  j  ava 2 s .c o  m*/

    for (IWizardPage page : this.pagesToDispose) {
        page.dispose();
    }

    for (Runnable onDisposeAction : this.onDisposeActions) {
        try {
            onDisposeAction.run();
        } catch (Exception e) {
            FacetUiPlugin.log(e);
        }
    }

    if (this.disposeWorkingCopy) {
        this.fpjwc.dispose();
    }
}

From source file:org.entirej.ide.ui.wizards.service.NewEJPojoServiceContentPage.java

License:Apache License

private void cleanSubPages() {
    for (IWizardPage page : pages) {
        page.dispose();
    }
    pages.clear();
}

From source file:org.jboss.jca.eclipse.wizards.DefinitionWizardPage.java

License:Open Source License

/**
 * @param container/*from www. j  av  a2s .  c o  m*/
 */
private void createBoundTypeGroup(Composite container) {
    Label label = new Label(container, SWT.NULL);
    label.setText(((CodeGenWizard) getWizard()).getCodegenResourceString("support.bound") + ":");

    final String[] items = { "Outbound", "Inbound", "Bidirectional" };
    boundCombo = new Combo(container, SWT.DROP_DOWN | SWT.READ_ONLY);
    boundCombo.setItems(items);
    boundCombo.setText("Outbound");
    ((CodeGenWizard) getWizard()).getDef().setSupportOutbound(true);
    ((CodeGenWizard) getWizard()).getDef().setSupportInbound(false);

    boundCombo.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent e) {
            if (boundCombo.getText().equals("Outbound")) {
                ((CodeGenWizard) getWizard()).getDef().setSupportOutbound(true);
                ((CodeGenWizard) getWizard()).getDef().setSupportInbound(false);
            } else if (boundCombo.getText().equals("Inbound")) {
                ((CodeGenWizard) getWizard()).getDef().setSupportOutbound(false);
                ((CodeGenWizard) getWizard()).getDef().setSupportInbound(true);
            } else if (boundCombo.getText().equals("Bidirectional")) {
                ((CodeGenWizard) getWizard()).getDef().setSupportOutbound(true);
                ((CodeGenWizard) getWizard()).getDef().setSupportInbound(true);
            }

            IWizardPage page = ((CodeGenWizard) getWizard()).getRaPage();
            if (page.getControl() != null)
                page.dispose();
        }
    });
}

From source file:org.jboss.jca.eclipse.wizards.McfWizardPage.java

License:Open Source License

/**
 * @param parent Composite/*from  w  w w.  j a va 2s.c o  m*/
 * @see IDialogPage#createControl(Composite)
 */
public void createControl(Composite parent) {
    mcfDef = new McfDef(1, ((CodeGenWizard) getWizard()).getDef());
    List<McfDef> mcfDefs = new ArrayList<McfDef>();
    mcfDefs.add(mcfDef);
    ((CodeGenWizard) getWizard()).getDef().setMcfDefs(mcfDefs);

    List<ConfigPropType> propList = mcfDef.getMcfConfigProps();
    if (propList == null) {
        propList = new ArrayList<ConfigPropType>();
        mcfDef.setMcfConfigProps(propList);
    }
    Composite wholeContainer = new Composite(parent, SWT.NULL);
    GridLayout layout = new GridLayout();
    wholeContainer.setLayout(layout);
    layout.numColumns = 1;

    Composite mcfContainer = new Composite(wholeContainer, SWT.NULL);
    layout = new GridLayout();
    mcfContainer.setLayout(layout);
    layout.numColumns = 2;
    layout.verticalSpacing = 9;

    Label label = new Label(mcfContainer, SWT.NULL);
    label.setText(((CodeGenWizard) getWizard()).getCodegenResourceString("mcf.class.name") + ":");

    mcfText = new Text(mcfContainer, SWT.BORDER | SWT.SINGLE);
    GridData gd = new GridData(GridData.FILL_HORIZONTAL);
    gd.widthHint = 600;
    mcfText.setLayoutData(gd);
    mcfText.setText(((CodeGenWizard) getWizard()).getDef().getDefaultValue() + "ManagedConnectionFactory");
    mcfDef.setMcfClass(((CodeGenWizard) getWizard()).getDef().getDefaultValue() + "ManagedConnectionFactory");
    mcfText.addModifyListener(new ModifyListener() {
        public void modifyText(ModifyEvent e) {
            String string = mcfText.getText();
            if (string.length() > 0) {
                boolean changeDefault = false;
                if (string.endsWith("ManagedConnectionFactory")) {
                    ((CodeGenWizard) getWizard()).getDef().setDefaultValue(
                            string.substring(0, string.lastIndexOf("ManagedConnectionFactory")));
                    changeDefault = true;
                }
                if (string.endsWith("MCF")) {
                    ((CodeGenWizard) getWizard()).getDef()
                            .setDefaultValue(string.substring(0, string.lastIndexOf("MCF")));
                    changeDefault = true;
                }
                if (changeDefault) {
                    mcText.setText(
                            ((CodeGenWizard) getWizard()).getDef().getDefaultValue() + "ManagedConnection");
                    mcfDef.setMcClass(
                            ((CodeGenWizard) getWizard()).getDef().getDefaultValue() + "ManagedConnection");

                    cfText.setText(
                            ((CodeGenWizard) getWizard()).getDef().getDefaultValue() + "ConnectionFactory");
                    mcfDef.setCfInterfaceClass(
                            ((CodeGenWizard) getWizard()).getDef().getDefaultValue() + "ConnectionFactory");

                    cfImplText.setText(
                            ((CodeGenWizard) getWizard()).getDef().getDefaultValue() + "ConnectionFactoryImpl");
                    mcfDef.setCfClass(
                            ((CodeGenWizard) getWizard()).getDef().getDefaultValue() + "ConnectionFactoryImpl");

                    connText.setText(((CodeGenWizard) getWizard()).getDef().getDefaultValue() + "Connection");
                    mcfDef.setConnInterfaceClass(
                            ((CodeGenWizard) getWizard()).getDef().getDefaultValue() + "Connection");

                    connImplText.setText(
                            ((CodeGenWizard) getWizard()).getDef().getDefaultValue() + "ConnectionImpl");
                    mcfDef.setConnImplClass(
                            ((CodeGenWizard) getWizard()).getDef().getDefaultValue() + "ConnectionImpl");

                    IWizardPage page = ((CodeGenWizard) getWizard()).getInboundPage();
                    if (page.getControl() != null)
                        page.dispose();

                    page = ((CodeGenWizard) getWizard()).getAoPage();
                    if (page.getControl() != null)
                        page.dispose();
                }

                mcfDef.setMcfClass(string);
                updateStatus(null);
            }
            dialogChanged();
        }
    });

    label = new Label(mcfContainer, SWT.NULL);
    label.setText(((CodeGenWizard) getWizard()).getCodegenResourceString("mcf.config.properties") + ":");

    container = new Composite(wholeContainer, SWT.NULL);
    layout = new GridLayout();
    container.setLayout(layout);
    layout.numColumns = 2;

    propsTableViewer = createTableViewer(container);
    Composite buttonGroup = new Composite(container, SWT.NONE);
    GridLayout layoutBtns = new GridLayout();
    layoutBtns.marginHeight = 0;
    layoutBtns.marginWidth = 0;
    buttonGroup.setLayout(layoutBtns);
    buttonGroup.setLayoutData(new GridData(GridData.FILL_VERTICAL | GridData.HORIZONTAL_ALIGN_FILL));
    buttonGroup.setFont(buttonGroup.getFont());

    addButtonsToButtonGroup(buttonGroup);

    mcfContainer = new Composite(wholeContainer, SWT.NULL);
    layout = new GridLayout();
    mcfContainer.setLayout(layout);
    layout.numColumns = 2;
    layout.verticalSpacing = 9;

    label = new Label(mcfContainer, SWT.NULL);
    label.setText(((CodeGenWizard) getWizard()).getCodegenResourceString("mcf.impl.raa") + ":");

    final Button annoButton = new Button(mcfContainer, SWT.CHECK);
    annoButton.setSelection(true);
    mcfDef.setImplRaAssociation(true);
    annoButton.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent event) {

            mcfDef.setImplRaAssociation(annoButton.getSelection());
        }
    });

    label = new Label(mcfContainer, SWT.NULL);
    label.setText(((CodeGenWizard) getWizard()).getCodegenResourceString("mc.class.name") + ":");

    mcText = new Text(mcfContainer, SWT.BORDER | SWT.SINGLE);
    gd = new GridData(GridData.FILL_HORIZONTAL);
    gd.widthHint = 600;
    mcText.setLayoutData(gd);
    mcText.setText(((CodeGenWizard) getWizard()).getDef().getDefaultValue() + "ManagedConnection");
    mcfDef.setMcClass(((CodeGenWizard) getWizard()).getDef().getDefaultValue() + "ManagedConnection");
    mcText.addModifyListener(new ModifyListener() {
        public void modifyText(ModifyEvent e) {
            String string = mcText.getText();
            if (string.length() > 0) {
                mcfDef.setMcClass(string);
                updateStatus(null);
            }
            dialogChanged();
        }
    });

    label = new Label(mcfContainer, SWT.NULL);
    label.setText(((CodeGenWizard) getWizard()).getCodegenResourceString("mcf.use.cci") + ":");

    final Button cciButton = new Button(mcfContainer, SWT.CHECK);
    cciButton.setSelection(false);
    mcfDef.setUseCciConnection(false);
    cciButton.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent event) {

            mcfDef.setUseCciConnection(cciButton.getSelection());
            if (cciButton.getSelection()) {
                cfText.setEnabled(false);
                cfImplText.setEnabled(false);
                connText.setEnabled(false);
                connImplText.setEnabled(false);
            } else {
                cfText.setEnabled(true);
                cfImplText.setEnabled(true);
                connText.setEnabled(true);
                connImplText.setEnabled(true);
            }
        }
    });

    label = new Label(mcfContainer, SWT.NULL);
    label.setText(((CodeGenWizard) getWizard()).getCodegenResourceString("cf.interface.name") + ":");

    cfText = new Text(mcfContainer, SWT.BORDER | SWT.SINGLE);
    gd = new GridData(GridData.FILL_HORIZONTAL);
    gd.widthHint = 600;
    cfText.setLayoutData(gd);
    cfText.setText(((CodeGenWizard) getWizard()).getDef().getDefaultValue() + "ConnectionFactory");
    mcfDef.setCfInterfaceClass(((CodeGenWizard) getWizard()).getDef().getDefaultValue() + "ConnectionFactory");
    cfText.addModifyListener(new ModifyListener() {
        public void modifyText(ModifyEvent e) {
            String string = cfText.getText();
            if (string.length() > 0) {
                mcfDef.setCfInterfaceClass(string);
                updateStatus(null);
            }
            dialogChanged();
        }
    });

    label = new Label(mcfContainer, SWT.NULL);
    label.setText(((CodeGenWizard) getWizard()).getCodegenResourceString("cf.class.name") + ":");

    cfImplText = new Text(mcfContainer, SWT.BORDER | SWT.SINGLE);
    gd = new GridData(GridData.FILL_HORIZONTAL);
    gd.widthHint = 600;
    cfImplText.setLayoutData(gd);
    cfImplText.setText(((CodeGenWizard) getWizard()).getDef().getDefaultValue() + "ConnectionFactoryImpl");
    mcfDef.setCfClass(((CodeGenWizard) getWizard()).getDef().getDefaultValue() + "ConnectionFactoryImpl");
    cfImplText.addModifyListener(new ModifyListener() {
        public void modifyText(ModifyEvent e) {
            String string = cfImplText.getText();
            if (string.length() > 0) {
                mcfDef.setCfClass(string);
                updateStatus(null);
            }
            dialogChanged();
        }
    });

    label = new Label(mcfContainer, SWT.NULL);
    label.setText(((CodeGenWizard) getWizard()).getCodegenResourceString("conn.interface.name") + ":");

    connText = new Text(mcfContainer, SWT.BORDER | SWT.SINGLE);
    gd = new GridData(GridData.FILL_HORIZONTAL);
    gd.widthHint = 600;
    connText.setLayoutData(gd);
    connText.setText(((CodeGenWizard) getWizard()).getDef().getDefaultValue() + "Connection");
    mcfDef.setConnInterfaceClass(((CodeGenWizard) getWizard()).getDef().getDefaultValue() + "Connection");
    connText.addModifyListener(new ModifyListener() {
        public void modifyText(ModifyEvent e) {
            String string = connText.getText();
            if (string.length() > 0) {
                mcfDef.setConnInterfaceClass(string);
                updateStatus(null);
            }
            dialogChanged();
        }
    });

    label = new Label(mcfContainer, SWT.NULL);
    label.setText(((CodeGenWizard) getWizard()).getCodegenResourceString("conn.class.name") + ":");

    connImplText = new Text(mcfContainer, SWT.BORDER | SWT.SINGLE);
    gd = new GridData(GridData.FILL_HORIZONTAL);
    gd.widthHint = 600;
    connImplText.setLayoutData(gd);
    connImplText.setText(((CodeGenWizard) getWizard()).getDef().getDefaultValue() + "ConnectionImpl");
    mcfDef.setConnImplClass(((CodeGenWizard) getWizard()).getDef().getDefaultValue() + "ConnectionImpl");
    connImplText.addModifyListener(new ModifyListener() {
        public void modifyText(ModifyEvent e) {
            String string = connImplText.getText();
            if (string.length() > 0) {
                mcfDef.setConnImplClass(string);
                updateStatus(null);
            }
            dialogChanged();
        }
    });
    initialize();
    dialogChanged();
    setControl(wholeContainer);
}

From source file:org.jboss.jca.eclipse.wizards.RaWizardPage.java

License:Open Source License

/**
 * @param parent Composite/*from   w  ww  .j a v a 2  s .c  om*/
 * @see IDialogPage#createControl(Composite)
 */
public void createControl(Composite parent) {
    List<ConfigPropType> propList = ((CodeGenWizard) getWizard()).getDef().getRaConfigProps();
    if (propList == null) {
        propList = new ArrayList<ConfigPropType>();
        ((CodeGenWizard) getWizard()).getDef().setRaConfigProps(propList);
    }
    Composite wholeContainer = new Composite(parent, SWT.NULL);
    GridLayout layout = new GridLayout();
    wholeContainer.setLayout(layout);
    layout.numColumns = 1;

    Composite raContainer = new Composite(wholeContainer, SWT.NULL);
    layout = new GridLayout();
    raContainer.setLayout(layout);
    layout.numColumns = 2;
    layout.verticalSpacing = 9;

    Label label = new Label(raContainer, SWT.NULL);
    label.setText(((CodeGenWizard) getWizard()).getCodegenResourceString("use.ra") + ":");
    final Button raButton = new Button(raContainer, SWT.CHECK);

    raButton.setSelection(true);
    ((CodeGenWizard) getWizard()).getDef().setUseRa(true);
    raButton.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent event) {

            ((CodeGenWizard) getWizard()).getDef().setUseRa(raButton.getSelection());
            raText.setEnabled(raButton.getSelection());
            raSerialButton.setEnabled(raButton.getSelection());
        }
    });

    if (((CodeGenWizard) getWizard()).getDef().isSupportInbound()) {
        raButton.setEnabled(false);
    } else {
        raButton.setEnabled(true);
    }

    label = new Label(raContainer, SWT.NULL);
    label.setText(((CodeGenWizard) getWizard()).getCodegenResourceString("ra.class.name") + ":");
    raText = new Text(raContainer, SWT.BORDER | SWT.SINGLE);
    GridData gd = new GridData(GridData.FILL_HORIZONTAL);
    gd.widthHint = 600;
    raText.setLayoutData(gd);
    raText.setText(((CodeGenWizard) getWizard()).getDef().getDefaultValue() + "ResourceAdapter");
    ((CodeGenWizard) getWizard()).getDef()
            .setRaClass(((CodeGenWizard) getWizard()).getDef().getDefaultValue() + "ResourceAdapter");
    raText.addModifyListener(new ModifyListener() {
        public void modifyText(ModifyEvent e) {
            String string = raText.getText();
            if (string.length() > 0) {
                boolean changeDefault = false;
                if (string.endsWith("ResourceAdapter")) {
                    ((CodeGenWizard) getWizard()).getDef()
                            .setDefaultValue(string.substring(0, string.lastIndexOf("ResourceAdapter")));
                    changeDefault = true;
                }
                if (string.endsWith("RA")) {
                    ((CodeGenWizard) getWizard()).getDef()
                            .setDefaultValue(string.substring(0, string.lastIndexOf("RA")));
                    changeDefault = true;
                }
                if (changeDefault) {
                    IWizardPage page = ((CodeGenWizard) getWizard()).getMcfPage();
                    if (page.getControl() != null)
                        page.dispose();

                    page = ((CodeGenWizard) getWizard()).getInboundPage();
                    if (page.getControl() != null)
                        page.dispose();

                    page = ((CodeGenWizard) getWizard()).getAoPage();
                    if (page.getControl() != null)
                        page.dispose();
                }
                ((CodeGenWizard) getWizard()).getDef().setRaClass(string);
                updateStatus(null);
            }
            dialogChanged();
        }
    });

    label = new Label(raContainer, SWT.NULL);
    label.setText(((CodeGenWizard) getWizard()).getCodegenResourceString("ra.serial") + ":");
    raSerialButton = new Button(raContainer, SWT.CHECK);

    raSerialButton.setSelection(true);
    ((CodeGenWizard) getWizard()).getDef().setUseRa(true);
    raSerialButton.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent event) {
            ((CodeGenWizard) getWizard()).getDef().setRaSerial(raSerialButton.getSelection());
        }
    });

    label = new Label(raContainer, SWT.NULL);
    label.setText(((CodeGenWizard) getWizard()).getCodegenResourceString("ra.config.properties") + ":");

    container = new Composite(wholeContainer, SWT.NULL);
    layout = new GridLayout();
    container.setLayout(layout);
    layout.numColumns = 2;

    propsTableViewer = createTableViewer(container);

    Composite buttonGroup = new Composite(container, SWT.NONE);
    GridLayout layoutBtns = new GridLayout();
    layoutBtns.marginHeight = 0;
    layoutBtns.marginWidth = 0;
    buttonGroup.setLayout(layoutBtns);
    buttonGroup.setLayoutData(new GridData(GridData.FILL_VERTICAL | GridData.HORIZONTAL_ALIGN_FILL));
    buttonGroup.setFont(buttonGroup.getFont());

    addButtonsToButtonGroup(buttonGroup);

    initialize();
    dialogChanged();
    setControl(wholeContainer);
}