Example usage for org.eclipse.jface.wizard WizardPage WizardPage

List of usage examples for org.eclipse.jface.wizard WizardPage WizardPage

Introduction

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

Prototype

protected WizardPage(String pageName, String title, ImageDescriptor titleImage) 

Source Link

Document

Creates a new wizard page with the given name, title, and image.

Usage

From source file:org.eclipse.sirius.ui.business.api.viewpoint.ViewpointSelection.java

License:Open Source License

/**
 * Create a selection wizard page to select a viewpoint.
 * /*from  w  w  w. j a va  2s.c  o m*/
 * @param fileExtension
 *            the semantic file extension.
 * @param viewpointsMap
 *            an empty map, which will be filled
 * @return the wizard page
 * @since 0.9.0
 */
public static WizardPage createWizardPage(final String fileExtension,
        final SortedMap<Viewpoint, Boolean> viewpointsMap) {
    final SortedSet<Viewpoint> viewpoints = new TreeSet<Viewpoint>(new ViewpointRegistry.ViewpointComparator());
    viewpoints.addAll(ViewpointSelection.getViewpoints(fileExtension));

    for (final Viewpoint viewpoint : viewpoints) {
        viewpointsMap.put(viewpoint, Boolean.FALSE);
    }

    final WizardPage page = new WizardPage(VIEWPOINTS_SELECTION_WIZARD_PAGE_ID,
            VIEWPOINT_SELECTION_WIZARD_PAGE_TITLE, null) {

        public void createControl(final Composite parent) {
            setControl(ViewpointSelection.createViewpointsTableControl(parent, this.getContainer(),
                    viewpointsMap));
        }

        private boolean isThereOneSelectedViewpoint() {
            return Maps.filterValues(viewpointsMap, new Predicate<Boolean>() {
                public boolean apply(final Boolean input) {
                    return input.booleanValue();
                }
            }).entrySet().iterator().hasNext();
        }

        @Override
        public boolean isPageComplete() {
            return super.isPageComplete() && isThereOneSelectedViewpoint();
        }

    };
    return page;
}

From source file:org.emftext.language.forms.interpreter.FormInterpreter.java

License:Open Source License

private void createWizard(final EObject form) {
    Wizard wizard = new Wizard() {

        @Override/* w  w  w  . j a va2  s .  c  o  m*/
        public boolean performFinish() {
            return true;
        }
    };
    wizard.setWindowTitle(getString(form, FORM_TITLE));
    List<EObject> groups = getList(form, FORM_GROUPS);
    for (EObject group : groups) {
        List<EObject> items = getList(group, GROUP_ITEMS);
        for (final EObject item : items) {
            String groupTitle = getString(group, GROUP_NAME);
            if (groupTitle == null) {
                groupTitle = "";
            }
            wizard.addPage(new WizardPage(groupTitle, groupTitle, null) {

                public void createControl(Composite parent) {
                    GridData gd = new GridData(SWT.FILL, SWT.BOTTOM, true, false, 1, 1);
                    GridData gd2 = new GridData(SWT.FILL, SWT.BOTTOM, true, false, 2, 1);

                    Composite composite = new Composite(parent, SWT.NONE);
                    // create the desired layout for this wizard page
                    GridLayout gl = new GridLayout();
                    gl.numColumns = 2;
                    composite.setLayout(gl);

                    Label question = new Label(composite, NONE);
                    question.setText(getString(item, ITEM_TEXT));

                    EObject itemType = get(item, ITEM_TYPES);
                    if (isA(itemType, FREETEXT)) {
                        Text text = new Text(composite, SWT.SINGLE);
                        text.setLayoutData(gd);
                        question.setLayoutData(gd);
                    }
                    boolean itemIsChoice = isA(itemType, CHOICE);
                    boolean itemIsDecision = isA(itemType, DECISION);
                    if (itemIsChoice || itemIsDecision) {
                        int type = SWT.RADIO;
                        if (getBoolean(itemType, CHOICE_MULTIPLE)) {
                            type = SWT.CHECK;
                        }
                        List<EObject> options = getList(itemType, CHOICE_OPTIONS);
                        for (EObject option : options) {
                            Button radioButton = new Button(composite, type);
                            radioButton.setLayoutData(gd2);
                            String optionName = getString(option, CHOICE_NAME);
                            if (optionName == null) {
                                optionName = "";
                            }
                            radioButton.setText(optionName);
                        }
                        question.setLayoutData(gd2);
                    }
                    if (isA(itemType, NUMBER)) {
                        Spinner spinner = new Spinner(composite, SWT.NONE);
                        spinner.setLayoutData(gd);
                        question.setLayoutData(gd);
                    }
                    if (isA(itemType, DATE)) {
                        DateTime dateTime = new DateTime(composite, SWT.NONE);
                        dateTime.setLayoutData(gd);
                        question.setLayoutData(gd2);
                    }

                    setControl(composite);
                }

            });
        }
    }
    WizardDialog dialog = new WizardDialog(Display.getCurrent().getActiveShell(), wizard);
    dialog.create();
    dialog.open();
}

From source file:org.emftext.language.javaforms.example.Test2Wizard.java

License:Open Source License

@Override
public void addPages() {
    addPage(new WizardPage("Personal Details", "Personal Details", null) {

        public void createControl(Composite parent) {
            GridData gd = new GridData(SWT.FILL, SWT.BOTTOM, true, false, 1, 1);
            GridData gd2 = new GridData(SWT.FILL, SWT.BOTTOM, true, false, 2, 1);

            Composite composite = new Composite(parent, SWT.NONE);
            // create the desired layout for this wizard page
            GridLayout gl = new GridLayout();
            gl.numColumns = 2;/*from   ww  w.j a v  a  2  s .c  o m*/
            composite.setLayout(gl);

            Label question = new Label(composite, NONE);
            question.setText("Name");

            Text text = new Text(composite, SWT.SINGLE);
            text.setLayoutData(gd);
            question.setLayoutData(gd);
            // TODO handle conditional item
            boolean isEnabled = true;
            if (isEnabled) {
            }

            setControl(composite);
        }
    });
    addPage(new WizardPage("Personal Details", "Personal Details", null) {

        public void createControl(Composite parent) {
            GridData gd = new GridData(SWT.FILL, SWT.BOTTOM, true, false, 1, 1);
            GridData gd2 = new GridData(SWT.FILL, SWT.BOTTOM, true, false, 2, 1);

            Composite composite = new Composite(parent, SWT.NONE);
            // create the desired layout for this wizard page
            GridLayout gl = new GridLayout();
            gl.numColumns = 2;
            composite.setLayout(gl);

            Label question = new Label(composite, NONE);
            question.setText("Age");

            Spinner spinner = new Spinner(composite, SWT.NONE);
            spinner.setLayoutData(gd);
            question.setLayoutData(gd);
            // TODO handle conditional item
            boolean isEnabled = true;
            if (isEnabled) {
            }

            setControl(composite);
        }
    });
    addPage(new WizardPage("Personal Details", "Personal Details", null) {

        public void createControl(Composite parent) {
            GridData gd = new GridData(SWT.FILL, SWT.BOTTOM, true, false, 1, 1);
            GridData gd2 = new GridData(SWT.FILL, SWT.BOTTOM, true, false, 2, 1);

            Composite composite = new Composite(parent, SWT.NONE);
            // create the desired layout for this wizard page
            GridLayout gl = new GridLayout();
            gl.numColumns = 2;
            composite.setLayout(gl);

            Label question = new Label(composite, NONE);
            question.setText("Legal Guardian");

            Text text = new Text(composite, SWT.SINGLE);
            text.setLayoutData(gd);
            question.setLayoutData(gd);
            // TODO handle conditional item
            boolean isEnabled = true;
            isEnabled = age < 18;
            if (isEnabled) {
            }

            setControl(composite);
        }
    });
    addPage(new WizardPage("Personal Details", "Personal Details", null) {

        public void createControl(Composite parent) {
            GridData gd = new GridData(SWT.FILL, SWT.BOTTOM, true, false, 1, 1);
            GridData gd2 = new GridData(SWT.FILL, SWT.BOTTOM, true, false, 2, 1);

            Composite composite = new Composite(parent, SWT.NONE);
            // create the desired layout for this wizard page
            GridLayout gl = new GridLayout();
            gl.numColumns = 2;
            composite.setLayout(gl);

            Label question = new Label(composite, NONE);
            question.setText("Vegetarian");

            int type = SWT.RADIO;
            {
                Button radioButton = new Button(composite, type);
                radioButton.setLayoutData(gd2);
                String optionName = "yes";
                if (optionName == null) {
                    optionName = "";
                }
                radioButton.setText(optionName);
            }
            {
                Button radioButton = new Button(composite, type);
                radioButton.setLayoutData(gd2);
                String optionName = "no";
                if (optionName == null) {
                    optionName = "";
                }
                radioButton.setText(optionName);
            }
            question.setLayoutData(gd2);
            // TODO handle conditional item
            boolean isEnabled = true;
            if (isEnabled) {
            }

            setControl(composite);
        }
    });
    addPage(new WizardPage("Personal Details", "Personal Details", null) {

        public void createControl(Composite parent) {
            GridData gd = new GridData(SWT.FILL, SWT.BOTTOM, true, false, 1, 1);
            GridData gd2 = new GridData(SWT.FILL, SWT.BOTTOM, true, false, 2, 1);

            Composite composite = new Composite(parent, SWT.NONE);
            // create the desired layout for this wizard page
            GridLayout gl = new GridLayout();
            gl.numColumns = 2;
            composite.setLayout(gl);

            Label question = new Label(composite, NONE);
            question.setText("Want free beer?");

            int type = SWT.RADIO;
            {
                Button radioButton = new Button(composite, type);
                radioButton.setLayoutData(gd2);
                String optionName = "yes";
                if (optionName == null) {
                    optionName = "";
                }
                radioButton.setText(optionName);
            }
            {
                Button radioButton = new Button(composite, type);
                radioButton.setLayoutData(gd2);
                String optionName = "no";
                if (optionName == null) {
                    optionName = "";
                }
                radioButton.setText(optionName);
            }
            question.setLayoutData(gd2);
            // TODO handle conditional item
            boolean isEnabled = true;
            isEnabled = name.contains("Mirko");
            if (isEnabled) {
            }

            setControl(composite);
        }
    });
}

From source file:org.jboss.mapper.eclipse.wizards.NewTransformationTestWizard.java

License:Open Source License

private IWizardPage constructMainPage() {
    return new WizardPage("New Transformation Test", "New Transformation Test",
            Activator.imageDescriptor("transform.png")) {

        protected Text testClassNameText;
        protected Text testClassPackageNameText;
        protected ComboViewer transformationIDViewer;

        /**/*from   w w  w  .j a  va2  s.com*/
         * {@inheritDoc}
         *
         * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
         */
        @Override
        public void createControl(final Composite parent) {
            setDescription("Specify the transformation endpoint to test, "
                    + "then provide the class name and java package for the generated test class.");
            final Composite page = new Composite(parent, SWT.NONE);
            setControl(page);
            page.setLayout(GridLayoutFactory.swtDefaults().spacing(0, 5).numColumns(3).create());
            Label label = new Label(page, SWT.NONE);
            label.setText("Transformation ID:");
            label.setToolTipText("Transformation endpoint to test");
            transformationIDViewer = new ComboViewer(new Combo(page, SWT.READ_ONLY));
            transformationIDViewer.getCombo().setLayoutData(GridDataFactory.swtDefaults().grab(true, false)
                    .span(2, 1).align(SWT.FILL, SWT.CENTER).create());

            new Label(page, SWT.NONE).setText("Test Class Name:");
            label.setToolTipText("Name of the generated test class");
            testClassNameText = new Text(page, SWT.BORDER);
            testClassNameText.setLayoutData(GridDataFactory.swtDefaults().grab(true, false).span(2, 1)
                    .align(SWT.FILL, SWT.CENTER).create());
            testClassNameText.addModifyListener(new ModifyListener() {
                @Override
                public void modifyText(ModifyEvent event) {
                    className = testClassNameText.getText().trim();
                    validatePage();
                }
            });

            new Label(page, SWT.NONE).setText("Test Class Package:");
            label.setToolTipText("Package where the test class is to be generated");
            testClassPackageNameText = new Text(page, SWT.BORDER);
            testClassPackageNameText.setLayoutData(
                    GridDataFactory.swtDefaults().grab(true, false).align(SWT.FILL, SWT.CENTER).create());
            Button browsePackage = new Button(page, SWT.PUSH);
            browsePackage.setText("...");
            browsePackage.setLayoutData(new GridData());
            browsePackage.setToolTipText("Select existing package.");
            browsePackage.addSelectionListener(new SelectionListener() {

                @Override
                public void widgetSelected(SelectionEvent event) {
                    if (javaProject != null) {
                        try {
                            SelectionDialog dialog = JavaUI.createPackageDialog(getShell(), javaProject, 0);
                            if (dialog.open() == SelectionDialog.OK) {
                                IPackageFragment result = (IPackageFragment) dialog.getResult()[0];
                                testClassPackageNameText.setText(result.getElementName());
                                packageName = result.getElementName();
                            }
                        } catch (JavaModelException e) {
                            Activator.error(e);
                        }
                    }
                }

                @Override
                public void widgetDefaultSelected(SelectionEvent event) {
                    // empty
                }
            });
            testClassPackageNameText.addModifyListener(new ModifyListener() {
                @Override
                public void modifyText(ModifyEvent event) {
                    packageName = testClassPackageNameText.getText().trim();
                    validatePage();
                }
            });
            if (packageName != null) {
                testClassPackageNameText.setText(packageName);
            }

            transformationIDViewer.setLabelProvider(new LabelProvider() {
                @Override
                public String getText(final Object element) {
                    return ((String) element);
                }
            });
            if (builder != null) {
                transformationIDViewer.add(builder.getTransformEndpointIds().toArray());
            }

            transformationIDViewer.getCombo().addSelectionListener(new SelectionAdapter() {

                @Override
                public void widgetSelected(final SelectionEvent event) {
                    transformID = (String) ((IStructuredSelection) transformationIDViewer.getSelection())
                            .getFirstElement();
                    validatePage();
                }
            });
            validatePage();
        }

        void validatePage() {
            if (!transformationIDViewer.getSelection().isEmpty()
                    && !testClassNameText.getText().trim().isEmpty()
                    && !testClassPackageNameText.getText().trim().isEmpty()) {
                if (javaProject != null) {
                    IStatus packageOK = JavaUtil.validatePackageName(packageName, javaProject);
                    if (!packageOK.isOK()) {
                        setErrorMessage(packageOK.getMessage());
                    } else {
                        IStatus classNameOK = JavaUtil.validateClassFileName(className, javaProject);
                        if (!classNameOK.isOK()) {
                            setErrorMessage(classNameOK.getMessage());
                        } else {
                            try {
                                IType foundType = javaProject.findType(packageName + "." + className);
                                if (foundType != null) {
                                    setErrorMessage("A generated test class with that "
                                            + "name and package already exists.");
                                } else {
                                    setErrorMessage(null);
                                }
                            } catch (JavaModelException e) {
                                e.printStackTrace();
                            }
                        }
                    }
                }
                setPageComplete(true);
                return;
            }
            setPageComplete(false);
        }
    };
}

From source file:org.teiid.designer.tools.textimport.ui.wizards.ImportTextWizard.java

License:Open Source License

/**
 * @see org.eclipse.ui.IWorkbenchWizard#init(org.eclipse.ui.IWorkbench, org.eclipse.jface.viewers.IStructuredSelection)
 * @since 4.0/*from w  ww .j a va 2s .c om*/
 */
@Override
public void init(final IWorkbench workbench, final IStructuredSelection selection) {

    IStructuredSelection finalSelection = selection;
    if (!ModelerUiViewUtils.workspaceHasOpenModelProjects()) {
        IProject newProject = ModelerUiViewUtils.queryUserToCreateModelProject();

        if (newProject != null) {
            finalSelection = new StructuredSelection(newProject);
        }
    }

    if (importLicensed) {
        importTextMainPage = new ImportTextMainPage(finalSelection);
        addPage(importTextMainPage);
        //
        for (int i = 0; i < importers.length; i++) {
            addPage((IWizardPage) importers[i]);
        }
    } else {
        // Create empty page
        WizardPage page = new WizardPage(ImportTextWizard.class.getSimpleName(), TITLE, null) {

            @Override
            public void createControl(final Composite parent) {
                setControl(createEmptyPageControl(parent));
            }
        };
        page.setMessage(NOT_LICENSED_MSG, IMessageProvider.ERROR);
        page.setPageComplete(false);
        addPage(page);
    }
}

From source file:org.teiid.designer.vdb.ui.wizards.ImportVdbWizard.java

License:Open Source License

/**
 * @see org.eclipse.ui.IWorkbenchWizard#init(org.eclipse.ui.IWorkbench, org.eclipse.jface.viewers.IStructuredSelection)
 * @since 4.0/*from   w  w  w  .j  a  v  a 2s  .  c  o  m*/
 */
@Override
public void init(final IWorkbench workbench, final IStructuredSelection selection) {
    if (importLicensed) {
        zipPage = createMainPage(selection);
        addPage(zipPage);
    } else {
        // Create empty page
        final WizardPage page = new WizardPage(ImportVdbWizard.class.getSimpleName(), TITLE, null) {
            @Override
            public void createControl(final Composite parent) {
                setControl(createEmptyPageControl(parent));
            }
        };
        page.setMessage(NOT_LICENSED_MSG, IMessageProvider.ERROR);
        page.setPageComplete(false);
        addPage(page);
    }
}

From source file:org.teiid.designer.webservice.ui.wizard.WsdlFileSystemImportWizard.java

License:Open Source License

/**
 * Method declared on IWorkbenchWizard.//  ww  w.  j  av a  2  s.  co  m
 */
@Override
public void init(IWorkbench workbench, IStructuredSelection currentSelection) {
    this.selection = currentSelection;

    if (ProductCustomizerMgr.getInstance().getProductCharacteristics().isHiddenProjectCentric()) {
        // get the project
        this.selection = new StructuredSelection(
                ProductCustomizerMgr.getInstance().getProductCharacteristics().getHiddenProject());
    } else {
        List selectedResources = IDE.computeSelectedResources(currentSelection);
        if (!selectedResources.isEmpty()) {
            this.selection = new StructuredSelection(selectedResources);
        }
    }

    if (!ModelerUiViewUtils.workspaceHasOpenModelProjects()) {
        IProject newProject = ModelerUiViewUtils.queryUserToCreateModelProject();

        if (newProject != null) {
            this.selection = new StructuredSelection(newProject);
        }
    }

    if (importLicensed) {
        createWizardPages(this.selection);
    } else {
        // Create empty page
        WizardPage page = new WizardPage(WsdlFileSystemImportWizard.class.getSimpleName(), TITLE, null) {
            @Override
            public void createControl(final Composite parent) {
                setControl(createEmptyPageControl(parent));
            }
        };
        page.setMessage(NOT_LICENSED_MSG, IMessageProvider.ERROR);
        page.setPageComplete(false);
        addPage(page);
    }
    setNeedsProgressMonitor(true);

}

From source file:org.teiid.designer.xsd.ui.wizards.XsdFileSystemImportWizard.java

License:Open Source License

/**
 * Method declared on IWorkbenchWizard./*  w w w  .ja v a2  s  .c om*/
 */
@Override
public void init(IWorkbench workbench, IStructuredSelection currentSelection) {
    this.workbench = workbench;
    this.selection = currentSelection;

    List selectedResources = IDE.computeSelectedResources(currentSelection);
    if (!selectedResources.isEmpty()) {
        this.selection = new StructuredSelection(selectedResources);
    }

    if (!ModelerUiViewUtils.workspaceHasOpenModelProjects()) {
        this.newProject = ModelerUiViewUtils.queryUserToCreateModelProject();

        if (this.newProject != null) {
            this.selection = new StructuredSelection(this.newProject);
            openProjectExists = true;
        } else {
            openProjectExists = false;
        }
    }

    if (importLicensed) {
        importMainPage = new XsdImportMainPage();
        importFromFileMainPage = createFileMainPage(selection);
        importFromUrlMainPage = createUrlMainPage(selection);
        addPage(importMainPage);
        addPage(importFromFileMainPage);
    } else {
        // Create empty page
        WizardPage page = new WizardPage(XsdFileSystemImportWizard.class.getSimpleName(), TITLE, null) {
            @Override
            public void createControl(final Composite parent) {
                setControl(createEmptyPageControl(parent));
            }
        };
        page.setMessage(NOT_LICENSED_MSG, IMessageProvider.ERROR);
        page.setPageComplete(false);
        addPage(page);
    }
    setNeedsProgressMonitor(true);
}