Example usage for org.eclipse.jface.dialogs IDialogConstants BACK_ID

List of usage examples for org.eclipse.jface.dialogs IDialogConstants BACK_ID

Introduction

In this page you can find the example usage for org.eclipse.jface.dialogs IDialogConstants BACK_ID.

Prototype

int BACK_ID

To view the source code for org.eclipse.jface.dialogs IDialogConstants BACK_ID.

Click Source Link

Document

Button id for a "Back" button (value 14).

Usage

From source file:org.eclipse.ltk.internal.ui.refactoring.RefactoringWizardDialog2.java

License:Open Source License

public void updateButtons() {
    boolean previewPage = isPreviewPageActive();
    boolean ok = fWizard.canFinish();
    boolean canFlip = fCurrentPage.canFlipToNextPage();

    Button defaultButton = null;/*from   www. j av a  2  s  .c om*/

    Button previewButton = getButton(PREVIEW_ID);
    if (previewButton != null && !previewButton.isDisposed()) {
        String previewLabel = previewPage ? IDialogConstants.BACK_LABEL
                : RefactoringUIMessages.RefactoringWizardDialog2_buttons_preview_label;
        previewButton.setText(previewLabel);
        setButtonLayoutData(previewButton);
        getShell().layout(new Control[] { previewButton });

        boolean enable = true;
        if (!previewPage)
            enable = canFlip;
        previewButton.setEnabled(enable);
        if (enable)
            defaultButton = previewButton;
    }

    Button nextButton = getButton(IDialogConstants.NEXT_ID);
    if (nextButton != null && !nextButton.isDisposed()) {
        nextButton.setEnabled(!previewPage);
        if (!previewPage)
            nextButton.setEnabled(canFlip);
        if (nextButton.isEnabled())
            defaultButton = nextButton;
    }

    Button backButton = getButton(IDialogConstants.BACK_ID);
    if (backButton != null && !backButton.isDisposed())
        backButton.setEnabled(!isFirstPage());

    Button okButton = getButton(IDialogConstants.OK_ID);
    if (okButton != null && !okButton.isDisposed()) {
        okButton.setEnabled(ok);
        if (ok)
            defaultButton = okButton;
    }

    if (defaultButton != null) {
        defaultButton.getShell().setDefaultButton(defaultButton);
    }
}

From source file:org.eclipse.ltk.internal.ui.refactoring.RefactoringWizardDialog2.java

License:Open Source License

private Map saveUIState(boolean keepCancelEnabled) {
    Map savedState = new HashMap(10);
    saveEnableStateAndSet(getButton(PREVIEW_ID), savedState, "preview", false); //$NON-NLS-1$
    saveEnableStateAndSet(getButton(IDialogConstants.OK_ID), savedState, "ok", false); //$NON-NLS-1$
    saveEnableStateAndSet(getButton(IDialogConstants.BACK_ID), savedState, "back", false); //$NON-NLS-1$
    saveEnableStateAndSet(getButton(IDialogConstants.NEXT_ID), savedState, "next", false); //$NON-NLS-1$
    saveEnableStateAndSet(getButton(IDialogConstants.CANCEL_ID), savedState, "cancel", keepCancelEnabled); //$NON-NLS-1$
    savedState.put("page", ControlEnableState.disable(fVisiblePage.getControl())); //$NON-NLS-1$
    return savedState;
}

From source file:org.eclipse.ltk.internal.ui.refactoring.RefactoringWizardDialog2.java

License:Open Source License

private void restoreUIState(Map state) {
    restoreEnableState(getButton(PREVIEW_ID), state, "preview");//$NON-NLS-1$
    restoreEnableState(getButton(IDialogConstants.OK_ID), state, "ok");//$NON-NLS-1$
    restoreEnableState(getButton(IDialogConstants.BACK_ID), state, "back"); //$NON-NLS-1$
    restoreEnableState(getButton(IDialogConstants.NEXT_ID), state, "next"); //$NON-NLS-1$
    restoreEnableState(getButton(IDialogConstants.CANCEL_ID), state, "cancel");//$NON-NLS-1$
    ControlEnableState pageState = (ControlEnableState) state.get("page");//$NON-NLS-1$
    pageState.restore();// w  w w . ja  va2 s .c o  m
}

From source file:org.eclipse.ltk.internal.ui.refactoring.RefactoringWizardDialog2.java

License:Open Source License

private boolean showErrorDialog(ErrorWizardPage page) {
    RefactoringStatusDialog dialog = new RefactoringStatusDialog(getShell(), page,
            fWizard.internalShowBackButtonOnStatusDialog(InternalAPI.INSTANCE));
    switch (dialog.open()) {
    case IDialogConstants.OK_ID:
        return true;
    case IDialogConstants.BACK_ID:
        fCurrentPage = fCurrentPage.getPreviousPage();
        break;// w ww  .jav  a  2  s .  c  o m
    case IDialogConstants.CANCEL_ID:
        cancelPressed();
    }
    return false;
}

From source file:org.eclipse.ltk.internal.ui.refactoring.RefactoringWizardDialog2.java

License:Open Source License

private Composite createPreviousAndNextButtons(Composite parent) {
    // Copied from Wizard Dialog.

    // increment the number of columns in the button bar
    GridLayout barLayout = (GridLayout) parent.getLayout();
    barLayout.numColumns += 2; // parent is assumed to have a GridLayout (see javadoc of Dialog#createButton(..))
    Composite composite = new Composite(parent, SWT.NONE);
    // create a layout with spacing and margins appropriate for the font
    // size./* w w w.  j  ava 2 s.  c om*/
    GridLayout layout = new GridLayout();
    layout.numColumns = 0; // will be incremented by createButton
    layout.marginWidth = 0;
    layout.marginHeight = 0;
    layout.horizontalSpacing = 0;
    layout.verticalSpacing = 0;
    composite.setLayout(layout);
    composite.setFont(parent.getFont());
    Button backButton = createButton(composite, IDialogConstants.BACK_ID, IDialogConstants.BACK_LABEL, false);
    backButton.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent e) {
            backPressed();
        }
    });
    Button nextButton = createButton(composite, IDialogConstants.NEXT_ID, IDialogConstants.NEXT_LABEL, false);
    nextButton.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent e) {
            nextOrPreviewPressed();
        }
    });

    GridData data = new GridData();
    int widthHint = convertHorizontalDLUsToPixels(IDialogConstants.BUTTON_WIDTH);
    Point minSize1 = backButton.computeSize(SWT.DEFAULT, SWT.DEFAULT, true);
    Point minSize2 = nextButton.computeSize(SWT.DEFAULT, SWT.DEFAULT, true);
    int minSize = Math.max(minSize1.x, minSize2.x);
    ((GridData) backButton.getLayoutData()).widthHint = minSize;
    ((GridData) nextButton.getLayoutData()).widthHint = minSize;
    data.widthHint = 2 * Math.max(widthHint, minSize) + barLayout.horizontalSpacing;
    data.horizontalAlignment = SWT.FILL;
    data.grabExcessHorizontalSpace = true;
    data.horizontalSpan = 2;
    composite.setLayoutData(data);

    return composite;
}

From source file:org.eclipse.oomph.setup.ui.wizards.ProgressPage.java

License:Open Source License

private void run(final String jobName, final ProgressLogRunnable runnable) {
    try {/* ww w  .j a  v a  2 s.  c om*/
        // Remember and use the progressPageLog that is valid at this point in time.
        final ProgressPageLog progressLog = progressPageLog;

        Runnable jobRunnable = new Runnable() {
            public void run() {
                final SetupWizard wizard = getWizard();
                final Shell shell = wizard.getShell();

                setButtonState(IDialogConstants.CANCEL_ID, false);
                setButtonState(IDialogConstants.BACK_ID, false);

                final Job job = new Job(jobName) {
                    @Override
                    protected IStatus run(IProgressMonitor monitor) {
                        progressLog.setProgressMonitor(monitor);

                        final Trigger trigger = getTrigger();
                        long start = System.currentTimeMillis();
                        boolean success = false;
                        Set<String> restartReasons = null;

                        UIUtil.syncExec(new Runnable() {
                            public void run() {
                                shell.setData(PROGRESS_STATUS, null);
                                if (trigger != Trigger.BOOTSTRAP) {
                                    if (trigger == Trigger.STARTUP
                                            || !SetupPropertyTester.isShowProgressInWizard()) {
                                        shell.setVisible(false);
                                    }

                                    SetupPropertyTester.setPerformingShell(shell);
                                }
                            }
                        });

                        try {
                            restartReasons = runnable.run(progressLog);

                            SetupTaskPerformer performer = getPerformer();
                            saveLocalFiles(performer);

                            if (launchAutomatically && trigger == Trigger.BOOTSTRAP) {
                                hasLaunched = launchProduct(performer);
                            }

                            success = true;
                        } catch (OperationCanceledException ex) {
                            // Do nothing
                        } catch (Throwable ex) {
                            final IStatus status = SetupUIPlugin.INSTANCE.getStatus(ex);
                            SetupUIPlugin.INSTANCE.log(new IStatus() {
                                public IStatus[] getChildren() {
                                    return status.getChildren();
                                }

                                public int getCode() {
                                    return status.getCode();
                                }

                                public Throwable getException() {
                                    return status.getException();
                                }

                                public String getMessage() {
                                    return status.getMessage();
                                }

                                public String getPlugin() {
                                    return status.getPlugin();
                                }

                                public int getSeverity() {
                                    return IStatus.WARNING;
                                }

                                public boolean isMultiStatus() {
                                    return status.isMultiStatus();
                                }

                                public boolean isOK() {
                                    return false;
                                }

                                public boolean matches(int severityMask) {
                                    return (severityMask & IStatus.WARNING) != 0;
                                }

                                @Override
                                public String toString() {
                                    StringBuilder result = new StringBuilder();
                                    result.append("Status WARNING");
                                    result.append(": ");
                                    result.append(getPlugin());
                                    result.append(" code=");
                                    result.append(getCode());
                                    result.append(' ');
                                    result.append(getMessage());
                                    result.append(' ');
                                    result.append(getException());
                                    result.append(" children=[");
                                    result.append(status);
                                    result.append("]");
                                    return result.toString();
                                }
                            });
                            progressLog.log(ex);
                        } finally {
                            long seconds = (System.currentTimeMillis() - start) / 1000;
                            progressLog.setTerminating();
                            progressLog.message("Took " + seconds + " seconds.");

                            getWizard().sendStats(success);

                            final AtomicBoolean disableCancelButton = new AtomicBoolean(true);

                            final boolean restart = restartReasons != null && !restartReasons.isEmpty()
                                    && trigger != Trigger.BOOTSTRAP;
                            if (restart) {
                                progressLog.message("A restart is needed for the following reasons:", false,
                                        Severity.INFO);
                                for (String reason : restartReasons) {
                                    progressLog.message("  - " + reason);
                                }

                                wizard.setFinishAction(new Runnable() {
                                    public void run() {
                                        progressLog.done();

                                        UIUtil.asyncExec(new Runnable() {
                                            public void run() {
                                                // Also include any triggered task whose implementation is currently unavailable.
                                                // Such tasks will not be needed by are likely needed after the restart when their implementations have been installed.
                                                SetupTaskPerformer performer = getPerformer();
                                                EList<SetupTask> remainingTasks = new BasicEList<SetupTask>(
                                                        performer.getNeededTasks());
                                                for (SetupTask setupTask : performer.getTriggeredSetupTasks()) {
                                                    if (setupTask instanceof DynamicSetupTaskImpl) {
                                                        remainingTasks.add(setupTask);
                                                    }
                                                }

                                                SetupUIPlugin.restart(trigger, remainingTasks);
                                            }
                                        });
                                    }
                                });

                                if (success && launchAutomatically) {
                                    wizard.performFinish();
                                    return Status.OK_STATUS;
                                }

                                progressLog.message("Press Finish to restart now or Cancel to restart later.",
                                        Severity.INFO);
                                disableCancelButton.set(false);
                            } else {
                                if (success && dismissAutomatically) {
                                    wizard.setFinishAction(new Runnable() {
                                        public void run() {
                                            IWizardContainer container = getContainer();
                                            if (container instanceof WizardDialog) {
                                                WizardDialog dialog = (WizardDialog) container;
                                                progressLog.done();
                                                dialog.close();
                                            }
                                        }
                                    });

                                    wizard.performFinish();
                                    return Status.OK_STATUS;
                                }

                                if (success) {
                                    progressLog.message("Press Finish to close the dialog.", Severity.INFO);

                                    if (launchButton != null && !hasLaunched && trigger == Trigger.BOOTSTRAP) {
                                        wizard.setFinishAction(new Runnable() {
                                            public void run() {
                                                if (launchAutomatically) {
                                                    try {
                                                        hasLaunched = launchProduct(getPerformer());
                                                    } catch (Exception ex) {
                                                        SetupUIPlugin.INSTANCE.log(ex);
                                                    }
                                                }
                                            }
                                        });
                                    }
                                } else {
                                    if (progressLog.isCanceled()) {
                                        progressLog.message("Task execution was canceled.", Severity.WARNING);
                                    } else {
                                        progressLog.message("There are failed tasks.", Severity.ERROR);
                                    }

                                    progressLog.message(
                                            "Press Back to choose different settings or Cancel to abort.",
                                            Severity.INFO);
                                }
                            }

                            IOUtil.close(getPerformer().getLogStream());

                            final boolean finalSuccess = success;
                            UIUtil.syncExec(new Runnable() {
                                public void run() {
                                    progressLog.done();
                                    setPageComplete(finalSuccess);
                                    setButtonState(IDialogConstants.BACK_ID, true);

                                    if (finalSuccess) {
                                        if (restart) {
                                            setMessage(
                                                    "Task execution has successfully completed but requires a restart.  Press Finish to restart now or Cancel to restart later.",
                                                    IMessageProvider.WARNING);
                                            setButtonState(IDialogConstants.CANCEL_ID, true);

                                            shell.setData(PROGRESS_STATUS, new Status(IStatus.WARNING,
                                                    SetupEditPlugin.INSTANCE.getSymbolicName(),
                                                    "Task execution has successfully completed but requires a restart"));
                                        } else {
                                            setMessage(
                                                    "Task execution has successfully completed.  Press Back to choose different settings or Finish to exit.");
                                            if (disableCancelButton.get()) {
                                                setButtonState(IDialogConstants.CANCEL_ID, false);
                                            }

                                            shell.setData(PROGRESS_STATUS,
                                                    new Status(IStatus.OK,
                                                            SetupEditPlugin.INSTANCE.getSymbolicName(),
                                                            "Task execution has successfully completed"));
                                        }
                                    } else {
                                        setButtonState(IDialogConstants.CANCEL_ID, true);
                                        if (progressLog.isCanceled()) {
                                            setErrorMessage(
                                                    "Task execution was canceled.  Press Back to choose different settings or Cancel to abort.");

                                            shell.setData(PROGRESS_STATUS,
                                                    new Status(IStatus.CANCEL,
                                                            SetupEditPlugin.INSTANCE.getSymbolicName(),
                                                            "Task execution was canceled."));
                                        } else {
                                            setErrorMessage(
                                                    "There are failed tasks.  Press Back to choose different settings or Cancel to abort.");

                                            shell.setData(PROGRESS_STATUS,
                                                    new Status(IStatus.ERROR,
                                                            SetupEditPlugin.INSTANCE.getSymbolicName(),
                                                            "Task execution was failed."));
                                        }
                                    }
                                }
                            });
                        }

                        return Status.OK_STATUS;
                    }

                    @Override
                    public boolean belongsTo(Object family) {
                        return family == PROGRESS_FAMILY;
                    }
                };

                job.schedule();

            }
        };

        UIUtil.asyncExec(jobRunnable);
    } catch (

    Throwable ex)

    {
        SetupUIPlugin.INSTANCE.log(ex);
        ErrorDialog.open(ex);
    }

}

From source file:org.eclipse.oomph.setup.ui.wizards.SetupWizardDialog.java

License:Open Source License

@Override
protected void createButtonsForButtonBar(Composite parent) {
    super.createButtonsForButtonBar(parent);
    AccessUtil.setKey(getButton(IDialogConstants.BACK_ID), "back");
    AccessUtil.setKey(getButton(IDialogConstants.NEXT_ID), "next");
    AccessUtil.setKey(getButton(IDialogConstants.FINISH_ID), "finish");
    AccessUtil.setKey(getButton(IDialogConstants.CANCEL_ID), "cancel");
}

From source file:org.eclipse.osee.framework.ui.swt.NonmodalWizardDialog.java

License:Open Source License

private Composite createPreviousAndNextButtons(Composite parent) {
    // increment the number of columns in the button bar
    ((GridLayout) parent.getLayout()).numColumns++;
    Composite composite = new Composite(parent, SWT.NONE);
    // create a layout with spacing and margins appropriate for the font size.
    GridLayout layout = new GridLayout();
    layout.numColumns = 0; // will be incremented by createButton
    layout.marginWidth = 0;//  w w  w  .  ja  v a  2 s .c o  m
    layout.marginHeight = 0;
    layout.horizontalSpacing = 0;
    layout.verticalSpacing = 0;
    composite.setLayout(layout);
    GridData data = new GridData(GridData.HORIZONTAL_ALIGN_CENTER | GridData.VERTICAL_ALIGN_CENTER);
    composite.setLayoutData(data);
    composite.setFont(parent.getFont());
    backButton = createButton(composite, IDialogConstants.BACK_ID, IDialogConstants.BACK_LABEL, false);
    nextButton = createButton(composite, IDialogConstants.NEXT_ID, IDialogConstants.NEXT_LABEL, false);
    nextButton.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent event) {
            //            System.out.println("the next button was pressed");
        }
    });
    return composite;
}

From source file:org.eclipse.papyrus.modelexplorer.dialog.NavigatorSearchDialog.java

License:Open Source License

@Override
protected void createButtonsForButtonBar(Composite parent) {

    backButton = createButton(parent, IDialogConstants.BACK_ID, IDialogConstants.BACK_LABEL, false);
    nextButton = createButton(parent, IDialogConstants.NEXT_ID, IDialogConstants.NEXT_LABEL, false);
    createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, true);

    backButton.setEnabled(false);/*from w  w  w  .j  a  v  a 2s  .c  om*/
    nextButton.setEnabled(false);

    nextButton.addSelectionListener(new SelectionListener() {

        public void widgetDefaultSelected(SelectionEvent e) {
        }

        public void widgetSelected(SelectionEvent e) {
            ISelection sel = viewer.getSelection();
            if (!(sel instanceof StructuredSelection)) {
                return;
            }
            StructuredSelection ssel = (StructuredSelection) sel;

            int index = matchedObjects.lastIndexOf(ssel.getFirstElement());
            if (index == matchedObjects.size() - 1) {
                index = -1;
            }
            index++;
            fireSetSelection(new StructuredSelection(matchedObjects.get(index)), true);
        }

    });

    backButton.addSelectionListener(new SelectionListener() {

        public void widgetDefaultSelected(SelectionEvent e) {
        }

        public void widgetSelected(SelectionEvent e) {
            ISelection sel = viewer.getSelection();
            if (!(sel instanceof StructuredSelection)) {
                return;
            }
            StructuredSelection ssel = (StructuredSelection) sel;

            int index = matchedObjects.lastIndexOf(ssel.getFirstElement());
            if (index == 0) {
                index = matchedObjects.size() - 1;
            }
            index--;
            fireSetSelection(new StructuredSelection(matchedObjects.get(index)), true);
        }

    });
}

From source file:org.eclipse.papyrus.views.modelexplorer.dialog.ApexNavigatorSearchDialog.java

License:Open Source License

@Override
protected void createButtonsForButtonBar(Composite parent) {

    backButton = createButton(parent, IDialogConstants.BACK_ID, IDialogConstants.BACK_LABEL, false);
    nextButton = createButton(parent, IDialogConstants.NEXT_ID, IDialogConstants.NEXT_LABEL, false);
    okButton = createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, true);

    /* apex replaced //from w  w  w.j a  va2  s .c  o m
    createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL,
    true);
    */

    backButton.setEnabled(false);
    nextButton.setEnabled(false);

    nextButton.addSelectionListener(new SelectionListener() {

        public void widgetDefaultSelected(SelectionEvent e) {
        }

        public void widgetSelected(SelectionEvent e) {
            if (currentIndex >= matchedObjects.size() - 1) {
                currentIndex = 0;
            } else {
                currentIndex++;
            }
            fireSetSelection(new StructuredSelection(matchedObjects.get(currentIndex)), true);
        }

    });

    backButton.addSelectionListener(new SelectionListener() {

        public void widgetDefaultSelected(SelectionEvent e) {
        }

        public void widgetSelected(SelectionEvent e) {
            if (currentIndex <= 0) {
                currentIndex = matchedObjects.size() - 1;
            } else {
                currentIndex--;
            }
            fireSetSelection(new StructuredSelection(matchedObjects.get(currentIndex)), true);
        }

    });

    /* apex added start */
    final Shell shell = parent.getShell();
    okButton.addSelectionListener(new SelectionListener() {

        public void widgetDefaultSelected(SelectionEvent e) {
        }

        public void widgetSelected(SelectionEvent e) {
            System.out.println(
                    "ApexNavigatorSearchDialog.createButtonsForButtonBar(...).new SelectionListener() {...}.widgetSelected(), line : "
                            + Thread.currentThread().getStackTrace()[1].getLineNumber());
            HierarchyInformationControl resultControl = new HierarchyInformationControl(shell,
                    SWT.RESIZE | SWT.BORDER, SWT.NONE);

            resultControl.open();
            /*
            if(currentIndex <= 0) {
               currentIndex = matchedObjects.size() - 1;
            } else {
               currentIndex--;
            }
            fireSetSelection(new StructuredSelection(matchedObjects.get(currentIndex)), true);
            */
        }

    });
    /* apex added end */
}