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

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

Introduction

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

Prototype

public void setWizard(IWizard newWizard);

Source Link

Document

Sets the wizard that hosts this wizard page.

Usage

From source file:com.aptana.deploy.engineyard.ui.wizard.EngineYardLoginWizardPage.java

License:Open Source License

public void createControl(Composite parent) {
    Composite composite = new Composite(parent, SWT.NULL);
    composite.setLayout(new GridLayout());
    composite.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_FILL | GridData.HORIZONTAL_ALIGN_FILL));
    setControl(composite);/*from  www  .java  2s  .  c  o  m*/

    initializeDialogUnits(parent);

    // Actual contents
    Label label = new Label(composite, SWT.NONE);
    label.setText(Messages.EngineYardLoginWizardPage_EnterCredentialsLabel);

    Composite credentials = new Composite(composite, SWT.NONE);
    credentials.setLayout(new GridLayout(2, false));

    Label userIdLabel = new Label(credentials, SWT.NONE);
    userIdLabel.setText(Messages.EngineYardLoginWizardPage_EmailAddressLabel);
    userId = new Text(credentials, SWT.SINGLE | SWT.BORDER);
    userId.setMessage(Messages.EngineYardLoginWizardPage_EmailAddressExample);
    GridData gd = new GridData(300, SWT.DEFAULT);
    userId.setLayoutData(gd);
    userId.addModifyListener(new ModifyListener() {

        public void modifyText(ModifyEvent e) {
            getContainer().updateButtons();
        }
    });

    Label passwordLabel = new Label(credentials, SWT.NONE);
    passwordLabel.setText(Messages.EngineYardLoginWizardPage_PasswordLabel);
    password = new Text(credentials, SWT.SINGLE | SWT.BORDER | SWT.PASSWORD);
    password.setMessage(Messages.EngineYardLoginWizardPage_PasswordExample);
    password.setLayoutData(gd);
    password.addModifyListener(new ModifyListener() {

        public void modifyText(ModifyEvent e) {
            getContainer().updateButtons();
        }
    });

    Button checkAuth = new Button(credentials, SWT.PUSH);
    checkAuth.setText(Messages.EngineYardLoginWizardPage_SubmitButtonLabel);
    checkAuth.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            if (validateLogin() && isPageComplete()) {
                getContainer().showPage(getNextPage());
            }
        }
    });

    // Signup link
    Link link = new Link(composite, SWT.NONE);
    link.setText(Messages.EngineYardLoginWizardPage_SignupLinkLabel);
    link.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            // Open the next dialog page where user can begin signup process!
            IWizardPage signupPage = new EngineYardSignupPage(userId.getText());
            signupPage.setWizard(getWizard());
            getContainer().showPage(signupPage);
        }
    });

    Dialog.applyDialogFont(composite);
}

From source file:com.aptana.deploy.heroku.ui.wizard.HerokuLoginWizardPage.java

License:Open Source License

public void createControl(Composite parent) {
    Composite composite = new Composite(parent, SWT.NULL);
    composite.setLayout(new GridLayout());
    composite.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_FILL | GridData.HORIZONTAL_ALIGN_FILL));
    setControl(composite);/*from  w  w w  .ja va2 s.c om*/

    initializeDialogUnits(parent);

    // Actual contents
    Label label = new Label(composite, SWT.NONE);
    label.setText(Messages.HerokuLoginWizardPage_EnterCredentialsLabel);

    Composite credentials = new Composite(composite, SWT.NONE);
    credentials.setLayout(new GridLayout(2, false));

    Label userIdLabel = new Label(credentials, SWT.NONE);
    userIdLabel.setText(Messages.HerokuLoginWizardPage_UserIDLabel);
    userId = new Text(credentials, SWT.SINGLE | SWT.BORDER);
    userId.setMessage(Messages.HerokuLoginWizardPage_UserIDExample);
    GridData gd = new GridData(300, SWT.DEFAULT);
    userId.setLayoutData(gd);
    userId.addModifyListener(new ModifyListener() {

        public void modifyText(ModifyEvent e) {
            getContainer().updateButtons();
        }
    });

    Label passwordLabel = new Label(credentials, SWT.NONE);
    passwordLabel.setText(Messages.HerokuLoginWizardPage_PasswordLabel);
    password = new Text(credentials, SWT.SINGLE | SWT.BORDER | SWT.PASSWORD);
    password.setMessage(Messages.HerokuLoginWizardPage_PasswordExample);
    password.setLayoutData(gd);
    password.addModifyListener(new ModifyListener() {

        public void modifyText(ModifyEvent e) {
            getContainer().updateButtons();
        }
    });

    Button checkAuth = new Button(credentials, SWT.PUSH);
    checkAuth.setText(Messages.HerokuLoginWizardPage_SubmitButtonLabel);
    checkAuth.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            // api.writeCredentials(); // we write them automatically via a page changed listener below...
            if (validateLogin() && isPageComplete()) {
                getContainer().showPage(getNextPage());
            }
        }
    });

    // Signup link
    Link link = new Link(composite, SWT.NONE);
    link.setText(Messages.HerokuLoginWizardPage_SignupLink);
    link.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            // Open the next dialog page where user can begin signup process!
            IWizardPage signupPage = new HerokuSignupPage(userId.getText());
            signupPage.setWizard(getWizard());
            getContainer().showPage(signupPage);
        }
    });

    Dialog.applyDialogFont(composite);

    // Save credentials if user hit Next too!!!
    IWizardContainer container = getWizard().getContainer();
    ((IPageChangeProvider) container).addPageChangedListener(new IPageChangedListener() {

        public void pageChanged(PageChangedEvent event) {
            Object selected = event.getSelectedPage();
            if (selected instanceof HerokuDeployWizardPage) {
                // If user has moved on to deploy page, write their credentials to a file
                HerokuAPI api = new HerokuAPI(userId.getText(), password.getText());
                api.writeCredentials();
            }
        }
    });
}

From source file:com.ebmwebsourcing.petals.services.su.wizards.AbstractServiceUnitWizard.java

License:Open Source License

@Override
public void addPage(IWizardPage page) {
    super.addPage(page);
    page.setWizard(this);

    String title = this.petalsMode == PetalsMode.provides ? "Petals Service Provider"
            : "Petals Service Consumer";
    title += " (" + getComponentVersionDescription().getComponentAlias() + ")";
    page.setTitle(title);//w  ww  .ja va2s.c  om

    if (page.getDescription() == null) {
        if (this.petalsMode == PetalsMode.consumes)
            page.setDescription(getComponentVersionDescription().getConsumeDescription());
        else if (this.petalsMode == PetalsMode.provides)
            page.setDescription(getComponentVersionDescription().getProvideDescription());
    }
}

From source file:com.mentor.nucleus.bp.core.ui.DelegatingWizard.java

License:Open Source License

/**
 * Returns the successor of the given page.
 * <p>//  ww  w. j  ava 2 s. c o  m
 * This method is typically called by a wizard page
 * </p>
 *
 * @param page the page
 * @return the next page, or <code>null</code> if none
 */
public IWizardPage getNextPage(IWizardPage page) {
    IWizardPage next = null;
    if (isActive(page)) {
        next = super.getNextPage(page);
        if (next == null) {
            //
            // We are at the last page of this wizard
            // start the next wizard at its first page.
            //
            next = delegateWizard.getStartingPage();
        }
    } else {
        next = delegateWizard.getNextPage(page);
    }
    if (next != null) {
        next.setWizard(this);
    }
    return next;
}

From source file:com.mentor.nucleus.bp.core.ui.DelegatingWizard.java

License:Open Source License

/**
 * Returns the wizard page with the given name belonging to this wizard.
 *
 * @param pageName the name of the wizard page
 * @return the wizard page with the given name, or <code>null</code> if none
 *//* w w w. j  a v  a  2s .  c om*/
public IWizardPage getPage(String pageName) {
    IWizardPage page = super.getPage(pageName);
    if (page == null) {
        page = delegateWizard.getPage(pageName);
    }
    if (page != null) {
        page.setWizard(this);
    }
    return page;
}

From source file:com.mentor.nucleus.bp.core.ui.DelegatingWizard.java

License:Open Source License

/**
 * Returns the predecessor of the given page.
 * <p>//from w w  w  . j a  v  a  2s .c  om
 * This method is typically called by a wizard page
 * </p>
 *
 * @param page the page
 * @return the previous page, or <code>null</code> if none
 */
public IWizardPage getPreviousPage(IWizardPage page) {
    IWizardPage prev = null;
    if (isActive(page)) {
        //
        // This can result in a null page. The client
        // wizard resolves this (see else clause below)
        //
        prev = super.getPreviousPage(page);
    } else {
        prev = delegateWizard.getPreviousPage(page);
        if (prev == null) {
            //
            // The delegate has no more pages in this direction,
            // so start at the current wizards last page . . . 
            //
            prev = getLastPage();
        }
    }
    if (prev != null) {
        prev.setWizard(this);
    }
    return prev;
}

From source file:com.mentor.nucleus.bp.core.ui.DelegatingWizard.java

License:Open Source License

/**
 * Returns the first page inserted into the wizard or its
 * downstream delegate./*from  w w  w  . j  a  v  a 2  s .c o  m*/
 */
public IWizardPage getStartingPage() {
    IWizardPage start = super.getStartingPage();
    if (start == null) {
        //
        // The current wizard has no pages of its own,
        // see if the delegate has any.
        //
        start = delegateWizard.getStartingPage();
    }
    if (start != null) {
        start.setWizard(this);
    }
    return start;
}

From source file:com.nokia.cdt.internal.debug.launch.wizard.LaunchCreationWizard.java

License:Open Source License

public void addPages() {
    if (fBinarySelectionPage != null) {
        addPage(fBinarySelectionPage);//from   ww w  .  j a  v a  2  s  .  c  o  m
        addPage(fBuildOptionsSelectionPage);
        addPage(fEmulationSummaryPage);
    } else if (fWizardSelectionPage != null) {
        List<AbstractLaunchWizard> wizards = getWizardsForCategory(getCategoryId());
        if (wizards.size() > 1) {
            addPage(fWizardSelectionPage);
        } else {
            // just directly "select" the single wizard and add its pages instead of using
            // a wizard selection node, to avoid a needless intermediate selection page
            AbstractLaunchWizard wizard = wizards.get(0);
            for (IWizardPage page : wizard.getPages()) {
                page.setWizard(null);
                addPage(page);
            }
            setWindowTitle(wizard.getWindowTitle());
            fWizardSelectionPage = null;
            selectedWizard = wizard;
        }
    }
}

From source file:de.ovgu.featureide.fm.ui.wizards.AbstractWizard.java

License:Open Source License

@Override
public void addPage(IWizardPage page) {
    page.setWizard(this);
    pages.add((AbstractWizardPage) page);
    super.addPage(page);
}

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

License:Open Source License

/**
 * @since 8.1//from  w  ww.j  av  a  2s  .  c o  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();
}