Search in sources :

Example 1 with WizardPage

use of org.eclipse.jface.wizard.WizardPage in project dbeaver by serge-rider.

the class AbstractToolWizard method createPageControls.

@Override
public void createPageControls(Composite pageContainer) {
    super.createPageControls(pageContainer);
    WizardPage currentPage = (WizardPage) getStartingPage();
    String clientHomeId = connectionInfo.getClientHomeId();
    if (clientHomeId == null) {
        currentPage.setErrorMessage(CoreMessages.tools_wizard_message_no_client_home);
        getContainer().updateMessage();
        return;
    }
    //MySQLDataSourceProvider.getServerHome(clientHomeId);
    clientHome = findServerHome(clientHomeId);
    if (clientHome == null) {
        currentPage.setErrorMessage(NLS.bind(CoreMessages.tools_wizard_message_client_home_not_found, clientHomeId));
        getContainer().updateMessage();
    }
}
Also used : WizardPage(org.eclipse.jface.wizard.WizardPage)

Example 2 with WizardPage

use of org.eclipse.jface.wizard.WizardPage in project yamcs-studio by yamcs.

the class ImportOPIExamplesWizard method addPages.

@Override
public void addPages() {
    super.addPages();
    setWindowTitle("Install OPI Examples");
    addPage(new WizardPage("OPI Examples") {

        @Override
        public void createControl(Composite parent) {
            setTitle("Install OPI Examples");
            setDescription("Creates a new project with sample OPI displays");
            Composite container = new Composite(parent, SWT.None);
            container.setLayout(new GridLayout());
            setControl(container);
            Label label = new Label(container, SWT.WRAP);
            GridData gd = new GridData();
            gd.widthHint = 500;
            label.setLayoutData(gd);
            label.setText("OPI Examples will be imported to your workspace. " + NLS.bind("If there is already a project named \"{0}\" in your workspace," + "the import will fail. ", InstallOPIExamplesAction.PROJECT_NAME) + "Please rename or delete it and import again.");
        }
    });
}
Also used : GridLayout(org.eclipse.swt.layout.GridLayout) Composite(org.eclipse.swt.widgets.Composite) WizardPage(org.eclipse.jface.wizard.WizardPage) Label(org.eclipse.swt.widgets.Label) GridData(org.eclipse.swt.layout.GridData)

Example 3 with WizardPage

use of org.eclipse.jface.wizard.WizardPage in project dbeaver by dbeaver.

the class AbstractToolWizard method createPageControls.

@Override
public void createPageControls(Composite pageContainer) {
    super.createPageControls(pageContainer);
    WizardPage currentPage = (WizardPage) getStartingPage();
    if (clientHomeRequired) {
        String clientHomeId = connectionInfo.getClientHomeId();
        if (clientHomeId == null) {
            currentPage.setErrorMessage(CoreMessages.tools_wizard_message_no_client_home);
            getContainer().updateMessage();
            return;
        }
        // MySQLDataSourceProvider.getServerHome(clientHomeId);
        clientHome = findServerHome(clientHomeId);
        if (clientHome == null) {
            currentPage.setErrorMessage(NLS.bind(CoreMessages.tools_wizard_message_client_home_not_found, clientHomeId));
            getContainer().updateMessage();
        }
    }
}
Also used : WizardPage(org.eclipse.jface.wizard.WizardPage)

Example 4 with WizardPage

use of org.eclipse.jface.wizard.WizardPage in project n4js by eclipse.

the class WorkingSetManualAssociationWizard method addPages.

@Override
public void addPages() {
    addPage(new WizardPage("") {

        private Text nameText;

        private final Collection<IProject> workspaceProjects = newTreeSet(PROJECT_NAME_COMPARATOR);

        private final Collection<IProject> workingSetProjects = newTreeSet(PROJECT_NAME_COMPARATOR);

        @Override
        public void createControl(Composite parent) {
            final Composite composite = new Composite(parent, NONE);
            composite.setLayout(GridLayoutFactory.fillDefaults().numColumns(2).equalWidth(false).create());
            composite.setLayoutData(fillDefaults().align(FILL, FILL).grab(true, true).create());
            new Label(composite, NONE).setText("Working set name:");
            nameText = new Text(composite, BORDER);
            nameText.setLayoutData(fillDefaults().align(FILL, CENTER).grab(true, false).create());
            Composite tableComposite = new Composite(composite, NONE);
            tableComposite.setLayout(GridLayoutFactory.fillDefaults().numColumns(3).equalWidth(false).create());
            tableComposite.setLayoutData(fillDefaults().align(FILL, FILL).grab(true, true).span(2, 1).create());
            Group workspaceGroup = new Group(tableComposite, SHADOW_IN);
            workspaceGroup.setText("Available workspace projects");
            workspaceGroup.setLayout(GridLayoutFactory.fillDefaults().create());
            workspaceGroup.setLayoutData(fillDefaults().align(FILL, FILL).grab(true, true).create());
            final TableViewer allProjectsViewer = new TableViewerBuilder(singletonList("")).setHasBorder(true).setHeaderVisible(false).setLinesVisible(false).setMultipleSelection(true).setColumnWidthsInPixel(Ints.asList(350)).setLabelProvider(labelProvider).build(workspaceGroup);
            Composite buttonComposite = new Composite(tableComposite, NONE);
            buttonComposite.setLayout(GridLayoutFactory.fillDefaults().create());
            // buttonComposite.setLayoutData(fillDefaults().align(CENTER, CENTER).grab(false, false).create());
            final Button addButton = new Button(buttonComposite, PUSH);
            addButton.setImage(ImageRef.RIGHT_ARROW.asImage().orNull());
            addButton.setToolTipText("Add all selected workspace projects");
            addButton.setEnabled(false);
            final Button removeButton = new Button(buttonComposite, PUSH);
            removeButton.setImage(ImageRef.LEFT_ARROW.asImage().orNull());
            removeButton.setToolTipText("Remove all selected working set element projects");
            removeButton.setEnabled(false);
            Group workingSetGroup = new Group(tableComposite, SHADOW_IN);
            workingSetGroup.setText("Associated working set projects");
            workingSetGroup.setLayout(GridLayoutFactory.fillDefaults().create());
            workingSetGroup.setLayoutData(fillDefaults().align(FILL, FILL).grab(true, true).create());
            final TableViewer associatedProjectsViewer = new TableViewerBuilder(singletonList("")).setHasBorder(true).setHeaderVisible(false).setLinesVisible(false).setMultipleSelection(true).setColumnWidthsInPixel(Ints.asList(350)).setLabelProvider(labelProvider).build(workingSetGroup);
            addButton.addSelectionListener(new SelectionAdapter() {

                @Override
                public void widgetSelected(SelectionEvent e) {
                    IStructuredSelection selection = allProjectsViewer.getStructuredSelection();
                    if (selection != null && !selection.isEmpty()) {
                        final IProject[] projects = Arrays2.filter(selection.toArray(), IProject.class);
                        allProjectsViewer.remove(projects);
                        associatedProjectsViewer.add(projects);
                        workspaceProjects.removeAll(Arrays.asList(projects));
                        workingSetProjects.addAll(Arrays.asList(projects));
                        setPageComplete(validatePage());
                    }
                }
            });
            removeButton.addSelectionListener(new SelectionAdapter() {

                @Override
                public void widgetSelected(SelectionEvent e) {
                    IStructuredSelection selection = associatedProjectsViewer.getStructuredSelection();
                    if (selection != null && !selection.isEmpty()) {
                        final IProject[] projects = Arrays2.filter(selection.toArray(), IProject.class);
                        associatedProjectsViewer.remove(projects);
                        allProjectsViewer.add(projects);
                        workingSetProjects.removeAll(Arrays.asList(projects));
                        workspaceProjects.addAll(Arrays.asList(projects));
                        setPageComplete(validatePage());
                    }
                }
            });
            associatedProjectsViewer.addSelectionChangedListener(event -> {
                final IStructuredSelection selection = associatedProjectsViewer.getStructuredSelection();
                removeButton.setEnabled(null != selection && !selection.isEmpty());
            });
            allProjectsViewer.addSelectionChangedListener(event -> {
                final IStructuredSelection selection = allProjectsViewer.getStructuredSelection();
                addButton.setEnabled(null != selection && !selection.isEmpty());
            });
            setPageComplete(false);
            setControl(composite);
            final Optional<WorkingSet> editedWorkingSet = getEditedWorkingSet();
            workspaceProjects.addAll(Arrays.asList(ResourcesPlugin.getWorkspace().getRoot().getProjects()));
            if (editedWorkingSet.isPresent()) {
                final ManualAssociationWorkingSet workingSet = (ManualAssociationWorkingSet) editedWorkingSet.get();
                workingSetRef.set(workingSet);
                nameText.setText(workingSet.getName());
                nameText.selectAll();
                workingSetProjects.addAll(workingSet.getAssociatedProjects());
                workspaceProjects.removeAll(workingSetProjects);
                originalName.set(workingSet.getName());
            }
            composite.getDisplay().asyncExec(() -> {
                setTitle(TITLE);
                setDescription(DESCRIPTION);
                allProjectsViewer.setInput(workspaceProjects);
                associatedProjectsViewer.setInput(workingSetProjects);
            });
            nameText.addModifyListener(e -> setPageComplete(validatePage()));
        }

        @Override
        public void setVisible(boolean visible) {
            if (visible) {
                Rectangle location = UIUtils.getConstrainedShellBounds(getShell(), SHELL_SIZE);
                getShell().setBounds(location);
            }
            super.setVisible(visible);
        }

        @SuppressWarnings("null")
        private boolean validatePage() {
            String errorMessage = null;
            final String name = nameText.getText();
            final WorkingSetManager manager = getManager();
            if (manager == null) {
                errorMessage = "No active working set manager is available.";
            }
            if (errorMessage == null) {
                if (name == null || name.trim().length() == 0) {
                    errorMessage = "Working set name should be specified.";
                }
            }
            if (errorMessage == null) {
                if (!name.equals(originalName.get()) && // This case ID and name are equal. Intentionally name.
                getAllWorkingSets().stream().anyMatch(ws -> ws.getName().equals(name))) {
                    errorMessage = "A working set already exists with name '" + name + "'.";
                }
            }
            if (errorMessage != null) {
                workingSetRef.set(null);
            } else {
                final Iterable<String> projectNames = from(workingSetProjects).transform(p -> p.getName());
                workingSetRef.set(new ManualAssociationWorkingSet(projectNames, name, manager));
            }
            setMessage(errorMessage, ERROR);
            return errorMessage == null;
        }
    });
}
Also used : Arrays(java.util.Arrays) ResourcesPlugin(org.eclipse.core.resources.ResourcesPlugin) TableViewer(org.eclipse.jface.viewers.TableViewer) Inject(com.google.inject.Inject) Rectangle(org.eclipse.swt.graphics.Rectangle) Arrays2(org.eclipse.n4js.utils.collections.Arrays2) AtomicReference(java.util.concurrent.atomic.AtomicReference) Point(org.eclipse.swt.graphics.Point) Collections.singletonList(java.util.Collections.singletonList) Sets.newTreeSet(com.google.common.collect.Sets.newTreeSet) IProject(org.eclipse.core.resources.IProject) Composite(org.eclipse.swt.widgets.Composite) Optional(com.google.common.base.Optional) FluentIterable.from(com.google.common.collect.FluentIterable.from) WizardPage(org.eclipse.jface.wizard.WizardPage) N4JSProjectExplorerLabelProvider(org.eclipse.n4js.ui.navigator.N4JSProjectExplorerLabelProvider) BORDER(org.eclipse.swt.SWT.BORDER) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) Text(org.eclipse.swt.widgets.Text) PUSH(org.eclipse.swt.SWT.PUSH) Button(org.eclipse.swt.widgets.Button) UIUtils(org.eclipse.n4js.ui.utils.UIUtils) TableViewerBuilder(org.eclipse.n4js.ui.viewer.TableViewerBuilder) Collection(java.util.Collection) Group(org.eclipse.swt.widgets.Group) Ints(com.google.common.primitives.Ints) GridLayoutFactory(org.eclipse.jface.layout.GridLayoutFactory) CENTER(org.eclipse.swt.SWT.CENTER) FILL(org.eclipse.swt.SWT.FILL) GridDataFactory.fillDefaults(org.eclipse.jface.layout.GridDataFactory.fillDefaults) SHADOW_IN(org.eclipse.swt.SWT.SHADOW_IN) ManualAssociationWorkingSet(org.eclipse.n4js.ui.workingsets.ManualAssociationAwareWorkingSetManager.ManualAssociationWorkingSet) SelectionEvent(org.eclipse.swt.events.SelectionEvent) Comparator(java.util.Comparator) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) ImageRef(org.eclipse.n4js.ui.ImageDescriptorCache.ImageRef) Label(org.eclipse.swt.widgets.Label) Group(org.eclipse.swt.widgets.Group) Composite(org.eclipse.swt.widgets.Composite) Optional(com.google.common.base.Optional) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) Label(org.eclipse.swt.widgets.Label) Rectangle(org.eclipse.swt.graphics.Rectangle) Text(org.eclipse.swt.widgets.Text) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) IProject(org.eclipse.core.resources.IProject) Button(org.eclipse.swt.widgets.Button) ManualAssociationWorkingSet(org.eclipse.n4js.ui.workingsets.ManualAssociationAwareWorkingSetManager.ManualAssociationWorkingSet) WizardPage(org.eclipse.jface.wizard.WizardPage) SelectionEvent(org.eclipse.swt.events.SelectionEvent) TableViewer(org.eclipse.jface.viewers.TableViewer) TableViewerBuilder(org.eclipse.n4js.ui.viewer.TableViewerBuilder)

Example 5 with WizardPage

use of org.eclipse.jface.wizard.WizardPage in project ecf by eclipse.

the class RemoteServiceConsumerExample1Template method addPages.

public void addPages(Wizard wizard) {
    WizardPage page = createPage(0, "org.eclipse.pde.doc.user.rcp_mail");
    page.setTitle("Hello Remote Service Consumer");
    page.setDescription("This template creates a Hello remote service consumer");
    wizard.addPage(page);
    markPagesAdded();
}
Also used : WizardPage(org.eclipse.jface.wizard.WizardPage)

Aggregations

WizardPage (org.eclipse.jface.wizard.WizardPage)25 IWizardPage (org.eclipse.jface.wizard.IWizardPage)6 Composite (org.eclipse.swt.widgets.Composite)6 Label (org.eclipse.swt.widgets.Label)6 GridData (org.eclipse.swt.layout.GridData)5 GridLayout (org.eclipse.swt.layout.GridLayout)5 OptionTemplateWizardPage (org.eclipse.gemoc.commons.eclipse.pde.wizards.pages.pde.ui.templates.OptionTemplateWizardPage)3 InvocationTargetException (java.lang.reflect.InvocationTargetException)2 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)2 TemplateOption (org.eclipse.gemoc.commons.eclipse.pde.wizards.pages.pde.ui.templates.TemplateOption)2 IRunnableWithProgress (org.eclipse.jface.operation.IRunnableWithProgress)2 IWizardContainer (org.eclipse.jface.wizard.IWizardContainer)2 Optional (com.google.common.base.Optional)1 FluentIterable.from (com.google.common.collect.FluentIterable.from)1 Sets.newTreeSet (com.google.common.collect.Sets.newTreeSet)1 Ints (com.google.common.primitives.Ints)1 Inject (com.google.inject.Inject)1 Arrays (java.util.Arrays)1 Collection (java.util.Collection)1 Collections.singletonList (java.util.Collections.singletonList)1