Search in sources :

Example 1 with IWizardContainer

use of org.eclipse.jface.wizard.IWizardContainer in project hale by halestudio.

the class FeatureChainingConfigurationPage method createContent.

/**
 * @see eu.esdihumboldt.hale.ui.HaleWizardPage#createContent(org.eclipse.swt.widgets.Composite)
 */
@Override
protected void createContent(Composite page) {
    IWizardContainer container = getContainer();
    if (container instanceof WizardDialog) {
        changeListener = new IPageChangingListener() {

            @Override
            public void handlePageChanging(PageChangingEvent event) {
                Object currentPage = event.getCurrentPage();
                Object targetPage = event.getTargetPage();
                if ((currentPage instanceof ChainPage || currentPage instanceof WorkspaceConfigurationPage) && targetPage instanceof FeatureChainingConfigurationPage) {
                    goingBack = true;
                } else if (currentPage instanceof IncludeSchemaConfigurationPage && targetPage instanceof FeatureChainingConfigurationPage) {
                    goingBack = false;
                }
            }
        };
        WizardDialog dialog = (WizardDialog) container;
        dialog.addPageChangingListener(changeListener);
    } else {
        changeListener = null;
    }
}
Also used : IWizardContainer(org.eclipse.jface.wizard.IWizardContainer) PageChangingEvent(org.eclipse.jface.dialogs.PageChangingEvent) IPageChangingListener(org.eclipse.jface.dialogs.IPageChangingListener) WizardDialog(org.eclipse.jface.wizard.WizardDialog)

Example 2 with IWizardContainer

use of org.eclipse.jface.wizard.IWizardContainer in project hale by halestudio.

the class IncludeSchemaConfigurationPage method createContent.

/**
 * @see eu.esdihumboldt.hale.ui.HaleWizardPage#createContent(org.eclipse.swt.widgets.Composite)
 */
@Override
protected void createContent(Composite page) {
    GridLayoutFactory.swtDefaults().numColumns(1).applyTo(page);
    Group includeGroup = new Group(page, SWT.NONE);
    includeGroup.setText("Include schema");
    GridLayoutFactory.swtDefaults().numColumns(2).applyTo(includeGroup);
    GridDataFactory.fillDefaults().grab(true, false).applyTo(includeGroup);
    checkInclude = new Button(includeGroup, SWT.CHECK);
    checkInclude.setText("Include target schema in the archive");
    GridDataFactory.swtDefaults().span(2, 1).applyTo(checkInclude);
    IWizardContainer container = getContainer();
    if (container instanceof WizardDialog) {
        changeListener = new IPageChangingListener() {

            @Override
            public void handlePageChanging(PageChangingEvent event) {
                Object currentPage = event.getCurrentPage();
                Object targetPage = event.getTargetPage();
                if (currentPage instanceof FeatureChainingConfigurationPage && targetPage instanceof IncludeSchemaConfigurationPage) {
                    goingBack = true;
                } else if (currentPage instanceof ExportSelectTargetPage && targetPage instanceof IncludeSchemaConfigurationPage) {
                    goingBack = false;
                }
            }
        };
        WizardDialog dialog = (WizardDialog) container;
        dialog.addPageChangingListener(changeListener);
    } else {
        changeListener = null;
    }
}
Also used : IWizardContainer(org.eclipse.jface.wizard.IWizardContainer) Group(org.eclipse.swt.widgets.Group) Button(org.eclipse.swt.widgets.Button) PageChangingEvent(org.eclipse.jface.dialogs.PageChangingEvent) IPageChangingListener(org.eclipse.jface.dialogs.IPageChangingListener) WizardDialog(org.eclipse.jface.wizard.WizardDialog) ExportSelectTargetPage(eu.esdihumboldt.hale.ui.io.ExportSelectTargetPage)

Example 3 with IWizardContainer

use of org.eclipse.jface.wizard.IWizardContainer in project xtext-eclipse by eclipse.

the class RefactoringWizardOpenOperation_NonForking method run.

/**
 * That one exists since
 * see RefactoringWizardOpenOperation#run(Shell, String, IRunnableContext)
 * - not a JavaDoc link since this breaks the build on Galileo :-)
 */
public int run(final Shell parent, final String dialogTitle, final IRunnableContext context) throws InterruptedException {
    Assert.isNotNull(dialogTitle);
    final Refactoring refactoring = fWizard.getRefactoring();
    final IJobManager manager = Job.getJobManager();
    final int[] result = new int[1];
    final InterruptedException[] canceled = new InterruptedException[1];
    Runnable r = new Runnable() {

        @Override
        public void run() {
            try {
                // we are getting the block dialog for free if we pass in null
                manager.beginRule(ResourcesPlugin.getWorkspace().getRoot(), null);
                refactoring.setValidationContext(parent);
                fInitialConditions = checkInitialConditions(refactoring, parent, dialogTitle, context);
                if (fInitialConditions.hasFatalError()) {
                    String message = fInitialConditions.getMessageMatchingSeverity(RefactoringStatus.FATAL);
                    MessageDialog.openError(parent, dialogTitle, message);
                    result[0] = INITIAL_CONDITION_CHECKING_FAILED;
                } else {
                    fWizard.setInitialConditionCheckingStatus(fInitialConditions);
                    /* CHANGE: don't use package private RefactoringUI */
                    Dialog dialog = createRefactoringWizardDialog(fWizard, parent);
                    dialog.create();
                    IWizardContainer wizardContainer = (IWizardContainer) dialog;
                    if (wizardContainer.getCurrentPage() == null)
                        /*
							 * Don't show the dialog at all if there are no user
							 * input pages and change creation was cancelled.
							 */
                        result[0] = Window.CANCEL;
                    else
                        result[0] = dialog.open();
                }
            } catch (InterruptedException e) {
                canceled[0] = e;
            } catch (OperationCanceledException e) {
                canceled[0] = new InterruptedException(e.getMessage());
            } finally {
                manager.endRule(ResourcesPlugin.getWorkspace().getRoot());
                refactoring.setValidationContext(null);
                disposeRefactoringContext(fWizard);
            }
        }
    };
    BusyIndicator.showWhile(parent != null ? parent.getDisplay() : null, r);
    if (canceled[0] != null)
        throw canceled[0];
    return result[0];
}
Also used : IWizardContainer(org.eclipse.jface.wizard.IWizardContainer) MessageDialog(org.eclipse.jface.dialogs.MessageDialog) Dialog(org.eclipse.jface.dialogs.Dialog) RefactoringWizardDialog(org.eclipse.ltk.internal.ui.refactoring.RefactoringWizardDialog) OperationCanceledException(org.eclipse.core.runtime.OperationCanceledException) IJobManager(org.eclipse.core.runtime.jobs.IJobManager) Refactoring(org.eclipse.ltk.core.refactoring.Refactoring)

Example 4 with IWizardContainer

use of org.eclipse.jface.wizard.IWizardContainer in project jbosstools-openshift by jbosstools.

the class ListDockerImagesWizardPage method doCreateControls.

@SuppressWarnings("unchecked")
@Override
protected void doCreateControls(final Composite parent, final DataBindingContext dbc) {
    GridLayoutFactory.fillDefaults().margins(10, 10).numColumns(2).applyTo(parent);
    // filter image by name
    final Label filterByNameLabel = new Label(parent, SWT.SEARCH);
    filterByNameLabel.setText("Filter:");
    filterByNameLabel.setToolTipText("Filter images by their name");
    GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(false, false).applyTo(filterByNameLabel);
    final Text filterByNameText = new Text(parent, SWT.BORDER);
    GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false).applyTo(filterByNameText);
    // table with all images
    final Table dockerImagesTable = new Table(parent, SWT.BORDER | SWT.FULL_SELECTION | SWT.V_SCROLL | SWT.H_SCROLL);
    final TableViewer dockerImagesTableViewer = new TableViewer(dockerImagesTable);
    dockerImagesTable.setHeaderVisible(true);
    dockerImagesTable.setLinesVisible(true);
    addTableViewerColum(dockerImagesTableViewer, "Name", SWT.NONE, SWT.LEFT, 200, new ColumnLabelProvider() {

        @Override
        public String getText(final Object element) {
            return ((DockerImageTag) element).getRepoName();
        }
    });
    addTableViewerColum(dockerImagesTableViewer, "Tag", SWT.NONE, SWT.LEFT, 100, new ColumnLabelProvider() {

        @Override
        public String getText(final Object element) {
            return ((DockerImageTag) element).getTag();
        }
    });
    addTableViewerColum(dockerImagesTableViewer, "Image ID", SWT.NONE, SWT.LEFT, 150, new ColumnLabelProvider() {

        @Override
        public String getText(final Object element) {
            return ((DockerImageTag) element).getId();
        }
    });
    GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).grab(true, true).span(2, 1).hint(200, 100).applyTo(dockerImagesTable);
    // observe the viewer content
    dockerImagesTableViewer.setContentProvider(new ObservableListContentProvider());
    // observe the viewer content
    dockerImagesTableViewer.setInput(BeanProperties.list(ListDockerImagesWizardModel.class, ListDockerImagesWizardModel.DOCKER_IMAGES).observe(model));
    // filter by name
    final ViewerFilter imageNameFilter = new ViewerFilter() {

        @Override
        public boolean select(Viewer viewer, Object parentElement, Object element) {
            return ((DockerImageTag) element).getRepoName().contains(filterByNameText.getText());
        }
    };
    dockerImagesTableViewer.addFilter(imageNameFilter);
    filterByNameText.addModifyListener(onFilterImages(dockerImagesTableViewer));
    // bind selection
    dbc.bindValue(ViewerProperties.singleSelection().observe(dockerImagesTableViewer), BeanProperties.value(ListDockerImagesWizardModel.SELECTED_DOCKER_IMAGE).observe(model));
    dockerImagesTableViewer.addDoubleClickListener(new IDoubleClickListener() {

        @Override
        public void doubleClick(DoubleClickEvent event) {
            IWizardContainer container = getWizard().getContainer();
            if (container instanceof OkCancelButtonWizardDialog) {
                ((OkCancelButtonWizardDialog) container).autoFinish();
            }
        }
    });
    // load the Docker images
    try {
        getContainer().run(true, false, new IRunnableWithProgress() {

            @Override
            public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
                model.setDockerImages(model.getDockerConnection().getImages(true));
            }
        });
    } catch (InvocationTargetException | InterruptedException e) {
        OpenShiftUIActivator.getDefault().getLogger().logError(e);
    }
}
Also used : ObservableListContentProvider(org.eclipse.jface.databinding.viewers.ObservableListContentProvider) Table(org.eclipse.swt.widgets.Table) ViewerFilter(org.eclipse.jface.viewers.ViewerFilter) Label(org.eclipse.swt.widgets.Label) Text(org.eclipse.swt.widgets.Text) TableViewer(org.eclipse.jface.viewers.TableViewer) Viewer(org.eclipse.jface.viewers.Viewer) DoubleClickEvent(org.eclipse.jface.viewers.DoubleClickEvent) OkCancelButtonWizardDialog(org.jboss.tools.openshift.internal.common.ui.wizard.OkCancelButtonWizardDialog) InvocationTargetException(java.lang.reflect.InvocationTargetException) IRunnableWithProgress(org.eclipse.jface.operation.IRunnableWithProgress) IWizardContainer(org.eclipse.jface.wizard.IWizardContainer) ColumnLabelProvider(org.eclipse.jface.viewers.ColumnLabelProvider) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) IDoubleClickListener(org.eclipse.jface.viewers.IDoubleClickListener) TableViewer(org.eclipse.jface.viewers.TableViewer)

Example 5 with IWizardContainer

use of org.eclipse.jface.wizard.IWizardContainer in project egit by eclipse.

the class FetchGerritChangePage method getRefsForContentAssist.

private Collection<Change> getRefsForContentAssist(String originalRefText) throws InvocationTargetException, InterruptedException {
    String uriText = uriCombo.getText();
    if (!changeRefs.containsKey(uriText)) {
        changeRefs.put(uriText, new ChangeList(repository, uriText));
    }
    ChangeList list = changeRefs.get(uriText);
    if (!list.isFinished()) {
        IWizardContainer container = getContainer();
        IRunnableWithProgress operation = monitor -> {
            monitor.beginTask(MessageFormat.format(UIText.AsynchronousRefProposalProvider_FetchingRemoteRefsMessage, uriText), IProgressMonitor.UNKNOWN);
            Collection<Change> result = list.get();
            if (monitor.isCanceled()) {
                return;
            }
            // If we get here, the ChangeList future is done.
            if (result == null || result.isEmpty() || fetching) {
                // Don't bother if we didn't get any results
                return;
            }
            // If we do have results now, open the proposals.
            Job showProposals = new WorkbenchJob(UIText.AsynchronousRefProposalProvider_ShowingProposalsJobName) {

                @Override
                public boolean shouldRun() {
                    return super.shouldRun() && !fetching;
                }

                @Override
                public IStatus runInUIThread(IProgressMonitor uiMonitor) {
                    // the same
                    try {
                        if (container instanceof NonBlockingWizardDialog) {
                            // focus will be restored
                            if (fetching) {
                                return Status.CANCEL_STATUS;
                            }
                            String uriNow = uriCombo.getText();
                            if (!uriNow.equals(uriText)) {
                                return Status.CANCEL_STATUS;
                            }
                            if (refText != refText.getDisplay().getFocusControl()) {
                                fillInPatchSet(result, null);
                                return Status.CANCEL_STATUS;
                            }
                            // Try not to interfere with the user's typing.
                            // Only fill in the patch set number if the text
                            // is still the same.
                            fillInPatchSet(result, originalRefText);
                            doAutoFill = false;
                        } else {
                            // Dialog was blocked
                            fillInPatchSet(result, null);
                            doAutoFill = false;
                        }
                        contentProposer.openProposalPopup();
                    } catch (SWTException e) {
                        // Disposed already
                        return Status.CANCEL_STATUS;
                    } finally {
                        doAutoFill = true;
                        uiMonitor.done();
                    }
                    return Status.OK_STATUS;
                }
            };
            showProposals.schedule();
        };
        if (container instanceof NonBlockingWizardDialog) {
            NonBlockingWizardDialog dialog = (NonBlockingWizardDialog) container;
            dialog.run(operation, () -> {
                if (!fetching) {
                    list.cancel(ChangeList.CancelMode.ABANDON);
                }
            });
        } else {
            container.run(true, true, operation);
        }
        return null;
    }
    // ChangeList is already here, so get() won't block
    Collection<Change> changes = list.get();
    if (doAutoFill) {
        fillInPatchSet(changes, originalRefText);
    }
    return changes;
}
Also used : SortedSet(java.util.SortedSet) UIPreferences(org.eclipse.egit.ui.UIPreferences) Date(java.util.Date) URISyntaxException(java.net.URISyntaxException) CoreException(org.eclipse.core.runtime.CoreException) ExplicitContentProposalAdapter(org.eclipse.egit.ui.UIUtils.ExplicitContentProposalAdapter) RemoteConfig(org.eclipse.jgit.transport.RemoteConfig) IDialogSettings(org.eclipse.jface.dialogs.IDialogSettings) Clipboard(org.eclipse.swt.dnd.Clipboard) RevWalk(org.eclipse.jgit.revwalk.RevWalk) IStatus(org.eclipse.core.runtime.IStatus) OperationCanceledException(org.eclipse.core.runtime.OperationCanceledException) Matcher(java.util.regex.Matcher) Composite(org.eclipse.swt.widgets.Composite) Map(java.util.Map) KeyEvent(org.eclipse.swt.events.KeyEvent) URIish(org.eclipse.jgit.transport.URIish) FetchResult(org.eclipse.jgit.transport.FetchResult) SWTException(org.eclipse.swt.SWTException) IContentProposal(org.eclipse.jface.fieldassist.IContentProposal) KeyAdapter(org.eclipse.swt.events.KeyAdapter) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) JobFamilies(org.eclipse.egit.ui.JobFamilies) Text(org.eclipse.swt.widgets.Text) ModifyEvent(org.eclipse.swt.events.ModifyEvent) Button(org.eclipse.swt.widgets.Button) TagBuilder(org.eclipse.jgit.lib.TagBuilder) NLS(org.eclipse.osgi.util.NLS) ActionUtils(org.eclipse.egit.ui.internal.ActionUtils) RefSpec(org.eclipse.jgit.transport.RefSpec) Collection(java.util.Collection) Status(org.eclipse.core.runtime.Status) Constants(org.eclipse.jgit.lib.Constants) AsynchronousListOperation(org.eclipse.egit.ui.internal.components.AsynchronousListOperation) AbstractBranchSelectionDialog(org.eclipse.egit.ui.internal.dialogs.AbstractBranchSelectionDialog) InvocationTargetException(java.lang.reflect.InvocationTargetException) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) Transfer(org.eclipse.swt.dnd.Transfer) Objects(java.util.Objects) PersonIdent(org.eclipse.jgit.lib.PersonIdent) TagOperation(org.eclipse.egit.core.op.TagOperation) GerritDialogSettings(org.eclipse.egit.ui.internal.gerrit.GerritDialogSettings) List(java.util.List) Window(org.eclipse.jface.window.Window) UIText(org.eclipse.egit.ui.internal.UIText) Ref(org.eclipse.jgit.lib.Ref) SWT(org.eclipse.swt.SWT) Pattern(java.util.regex.Pattern) IPageChangeProvider(org.eclipse.jface.dialogs.IPageChangeProvider) IWizardContainer(org.eclipse.jface.wizard.IWizardContainer) Label(org.eclipse.swt.widgets.Label) IWorkspaceRunnable(org.eclipse.core.resources.IWorkspaceRunnable) ResourcesPlugin(org.eclipse.core.resources.ResourcesPlugin) RevCommit(org.eclipse.jgit.revwalk.RevCommit) Activator(org.eclipse.egit.ui.Activator) SubMonitor(org.eclipse.core.runtime.SubMonitor) SimpleDateFormat(java.text.SimpleDateFormat) HashMap(java.util.HashMap) JFaceResources(org.eclipse.jface.resource.JFaceResources) WorkbenchJob(org.eclipse.ui.progress.WorkbenchJob) TreeSet(java.util.TreeSet) MessageFormat(java.text.MessageFormat) ArrayList(java.util.ArrayList) ValidationUtils(org.eclipse.egit.ui.internal.ValidationUtils) IWorkspace(org.eclipse.core.resources.IWorkspace) PageChangedEvent(org.eclipse.jface.dialogs.PageChangedEvent) TextTransfer(org.eclipse.swt.dnd.TextTransfer) WizardPage(org.eclipse.jface.wizard.WizardPage) GridData(org.eclipse.swt.layout.GridData) LinkedHashSet(java.util.LinkedHashSet) IPageChangedListener(org.eclipse.jface.dialogs.IPageChangedListener) BranchNameNormalizer(org.eclipse.egit.ui.internal.components.BranchNameNormalizer) Combo(org.eclipse.swt.widgets.Combo) Job(org.eclipse.core.runtime.jobs.Job) CreateLocalBranchOperation(org.eclipse.egit.core.op.CreateLocalBranchOperation) GridDataFactory(org.eclipse.jface.layout.GridDataFactory) IOException(java.io.IOException) NonBlockingWizardDialog(org.eclipse.egit.ui.internal.dialogs.NonBlockingWizardDialog) Group(org.eclipse.swt.widgets.Group) BranchOperationUI(org.eclipse.egit.ui.internal.branch.BranchOperationUI) Dialog(org.eclipse.jface.dialogs.Dialog) ModifyListener(org.eclipse.swt.events.ModifyListener) GerritUtil(org.eclipse.egit.core.internal.gerrit.GerritUtil) UIUtils(org.eclipse.egit.ui.UIUtils) IInputValidator(org.eclipse.jface.dialogs.IInputValidator) IRunnableWithProgress(org.eclipse.jface.operation.IRunnableWithProgress) BranchEditDialog(org.eclipse.egit.ui.internal.dialogs.BranchEditDialog) ActionFactory(org.eclipse.ui.actions.ActionFactory) SelectionEvent(org.eclipse.swt.events.SelectionEvent) Collections(java.util.Collections) Repository(org.eclipse.jgit.lib.Repository) Control(org.eclipse.swt.widgets.Control) GridLayout(org.eclipse.swt.layout.GridLayout) IStatus(org.eclipse.core.runtime.IStatus) WorkbenchJob(org.eclipse.ui.progress.WorkbenchJob) IRunnableWithProgress(org.eclipse.jface.operation.IRunnableWithProgress) IWizardContainer(org.eclipse.jface.wizard.IWizardContainer) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) NonBlockingWizardDialog(org.eclipse.egit.ui.internal.dialogs.NonBlockingWizardDialog) SWTException(org.eclipse.swt.SWTException) Collection(java.util.Collection) WorkbenchJob(org.eclipse.ui.progress.WorkbenchJob) Job(org.eclipse.core.runtime.jobs.Job)

Aggregations

IWizardContainer (org.eclipse.jface.wizard.IWizardContainer)19 IPageChangeProvider (org.eclipse.jface.dialogs.IPageChangeProvider)5 IPageChangedListener (org.eclipse.jface.dialogs.IPageChangedListener)5 PageChangedEvent (org.eclipse.jface.dialogs.PageChangedEvent)5 WizardDialog (org.eclipse.jface.wizard.WizardDialog)5 InvocationTargetException (java.lang.reflect.InvocationTargetException)4 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)4 Composite (org.eclipse.swt.widgets.Composite)4 URISyntaxException (java.net.URISyntaxException)3 IPageChangingListener (org.eclipse.jface.dialogs.IPageChangingListener)3 PageChangingEvent (org.eclipse.jface.dialogs.PageChangingEvent)3 IRunnableWithProgress (org.eclipse.jface.operation.IRunnableWithProgress)3 Button (org.eclipse.swt.widgets.Button)3 Group (org.eclipse.swt.widgets.Group)3 Label (org.eclipse.swt.widgets.Label)3 Text (org.eclipse.swt.widgets.Text)3 Date (java.util.Date)2 TreeSet (java.util.TreeSet)2 Matcher (java.util.regex.Matcher)2 IWorkspaceRunnable (org.eclipse.core.resources.IWorkspaceRunnable)2