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

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

Introduction

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

Prototype

String YES_LABEL

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

Click Source Link

Document

The label for yes buttons.

Usage

From source file:org.eclipse.egit.ui.view.repositories.GitRepositoriesViewRepoHandlingTest.java

License:Open Source License

@Test
public void testRemoveRepositoryWithProjectsYes() throws Exception {
    deleteAllProjects();//from www.j  ava  2s. co  m
    assertProjectExistence(PROJ1, false);
    clearView();
    Activator.getDefault().getRepositoryUtil().addConfiguredRepository(repositoryFile);
    shareProjects(repositoryFile);
    assertProjectExistence(PROJ1, true);
    refreshAndWait();
    assertHasRepo(repositoryFile);
    SWTBotTree tree = getOrOpenView().bot().tree();
    tree.getAllItems()[0].select();
    ContextMenuHelper.clickContextMenu(tree, myUtil.getPluginLocalizedValue("RemoveRepositoryCommand"));
    SWTBotShell shell = bot.shell(UIText.RepositoriesView_ConfirmProjectDeletion_WindowTitle);
    shell.activate();
    shell.bot().button(IDialogConstants.YES_LABEL).click();
    waitInUI();
    refreshAndWait();
    assertEmpty();
    assertProjectExistence(PROJ1, false);
}

From source file:org.eclipse.egit.ui.view.repositories.GitRepositoriesViewTagHandlingTest.java

License:Open Source License

@Test
public void testResetToTag() throws Exception {
    SWTBotTree tree = getOrOpenView().bot().tree();
    IJobChangeListener listener = null;/*from  w  w w .  j  a v  a  2s . c o m*/
    try {
        String initialContent = getTestFileContent();
        createTag("ResetToFirst", "The first tag");
        touchAndSubmit(null);
        String newContent = getTestFileContent();
        assertFalse("Wrong content", initialContent.equals(newContent));
        createTag("ResetToSecond", "The second tag");
        refreshAndWait();
        myRepoViewUtil.getTagsItem(tree, repositoryFile).expand().getNode("ResetToFirst").select();

        final boolean[] done = new boolean[] { false };

        final String jobName = NLS.bind(UIText.ResetAction_reset, "refs/tags/ResetToFirst");

        listener = new JobChangeAdapter() {

            @Override
            public void done(IJobChangeEvent event) {
                if (jobName.equals(event.getJob().getName()))
                    done[0] = true;
            }

        };

        Job.getJobManager().addJobChangeListener(listener);

        ContextMenuHelper.clickContextMenu(tree, myUtil.getPluginLocalizedValue("ResetCommand"));

        SWTBotShell resetDialog = bot.shell(UIText.ResetCommand_WizardTitle);
        resetDialog.bot().radio(UIText.ResetTargetSelectionDialog_ResetTypeHardButton).click();
        waitInUI();
        resetDialog.bot().button(IDialogConstants.FINISH_LABEL).click();
        waitInUI();

        bot.shell(UIText.ResetTargetSelectionDialog_ResetQuestion).bot().button(IDialogConstants.YES_LABEL)
                .click();

        for (int i = 0; i < 1000; i++) {
            if (done[0])
                break;
            Thread.sleep(10);
        }

        assertTrue("Job should be completed", done[0]);

        ResourcesPlugin.getWorkspace().getRoot().refreshLocal(IResource.DEPTH_INFINITE, null);
        assertEquals("Wrong content", initialContent, getTestFileContent());
    } finally {
        if (listener != null)
            Job.getJobManager().removeJobChangeListener(listener);
    }
}

From source file:org.eclipse.emf.cdo.internal.ui.actions.CloseSessionAction.java

License:Open Source License

@Override
protected void preRun() throws Exception {
    if (CDOUtil.isSessionDirty(getSession())) {
        MessageDialog dialog = new MessageDialog(getShell(), TITLE, null,
                Messages.getString("CloseSessionAction.2"), //$NON-NLS-1$
                MessageDialog.QUESTION, new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL,
                        IDialogConstants.CANCEL_LABEL },
                0);/*from w  ww.  ja v  a  2 s .c  om*/
        if (dialog.open() != MessageDialog.OK) {
            cancel();
        }
    }
}

From source file:org.eclipse.emf.cdo.internal.ui.actions.CloseViewAction.java

License:Open Source License

@Override
protected void preRun() throws Exception {
    if (getView().isDirty()) {
        MessageDialog dialog = new MessageDialog(getShell(), TITLE, null,
                Messages.getString("CloseViewAction.2"), //$NON-NLS-1$
                MessageDialog.QUESTION, new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL,
                        IDialogConstants.CANCEL_LABEL },
                0);/*from  w w w  . jav a2  s .  c  om*/
        if (dialog.open() != MessageDialog.OK) {
            cancel();
        }
    }
}

From source file:org.eclipse.emf.cdo.ui.internal.admin.actions.DeleteRepositoryAction.java

License:Open Source License

@Override
protected void preRun() throws Exception {
    final int NO_BUTTON = 1;
    String message = MessageFormat.format(Messages.DeleteRepositoryAction_4, target.getName());
    MessageDialog dlg = new MessageDialog(getShell(), getText(), null, message, MessageDialog.WARNING,
            new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL }, NO_BUTTON);
    if (dlg.open() == NO_BUTTON) {
        cancel();//  w w  w.j a  va 2 s  .c om
    }
}

From source file:org.eclipse.epf.authoring.ui.actions.UserInteractionHandler.java

License:Open Source License

/**
 * Return action text/*w  w  w .j  av a  2s  . com*/
 * 
 * @param action
 * @return Action text - either ABORT, CANCEL, OK, RETRY
 */
public static String getActionText(int action) {
    switch (action) {
    case IUserInteractionHandler.ACTION_ABORT:
        return IDialogConstants.ABORT_LABEL;
    case IUserInteractionHandler.ACTION_CANCEL:
        return IDialogConstants.CANCEL_LABEL;
    case IUserInteractionHandler.ACTION_OK:
        return IDialogConstants.OK_LABEL;
    case IUserInteractionHandler.ACTION_RETRY:
        return IDialogConstants.RETRY_LABEL;
    case IUserInteractionHandler.ACTION_YES:
        return IDialogConstants.YES_LABEL;
    case IUserInteractionHandler.ACTION_NO:
        return IDialogConstants.NO_LABEL;
    default:
        break;
    }
    return null;
}

From source file:org.eclipse.epf.common.serviceability.WrappedMessageDialog.java

License:Open Source License

public static boolean openQuestion(Shell parent, String title, String message) {
    WrappedMessageDialog dialog = new WrappedMessageDialog(parent, title, null, // accept
            // the
            // default
            // window
            // icon
            message, QUESTION, new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL }, 0); // yes is the
    // default//  w ww.j  a  v a2 s .c  o  m
    return dialog.open() == 0;
}

From source file:org.eclipse.equinox.internal.p2.ui.sdk.scheduler.migration.ImportFromInstallationWizard_c.java

License:Open Source License

public boolean performCancel() {
    String[] buttons = new String[] { IDialogConstants.YES_LABEL,
            ProvUIMessages.ImportFromInstallationPag_LATER_BUTTON, IDialogConstants.NO_LABEL };
    MessageDialog dialog = new MessageDialog(getShell(),
            ProvUIMessages.ImportFromInstallationPage_CONFIRMATION_TITLE, null,
            ProvUIMessages.ImportFromInstallationPage_CONFIRMATION_DIALOG, MessageDialog.QUESTION, buttons, 2);

    return rememberCancellationDecision(dialog.open());
}

From source file:org.eclipse.equinox.internal.p2.ui.sdk.scheduler.migration.MigrationWizard.java

License:Open Source License

public boolean performCancel() {
    String[] buttons = new String[] { IDialogConstants.YES_LABEL, ProvUIMessages.MigrationPage_LATER_BUTTON,
            IDialogConstants.NO_LABEL };
    MessageDialog dialog = new MessageDialog(getShell(), ProvUIMessages.MigrationPage_CONFIRMATION_TITLE, null,
            ProvUIMessages.MigrationPage_CONFIRMATION_DIALOG, MessageDialog.QUESTION, buttons, 2);

    return rememberCancellationDecision(dialog.open());
}

From source file:org.eclipse.gmf.runtime.diagram.ui.render.actions.CopyToImageAction.java

License:Open Source License

/**
 * Displays the dialog and performs <code>OutOfMemoryError</code> checking
 * //  w ww  . j a  v  a 2  s. co m
 * @param dialog the copy to image dialog
 */
private void runCopyToImageUI(CopyToImageDialog dialog) {
    if (dialog.open() == CopyToImageDialog.CANCEL) {
        return;
    }

    if (!overwriteExisting()) {
        return;
    }

    Trace.trace(DiagramUIRenderPlugin.getInstance(), "Copy Diagram to " + dialog.getDestination().toOSString() //$NON-NLS-1$
            + " as " + dialog.getImageFormat().toString()); //$NON-NLS-1$

    final MultiStatus status = new MultiStatus(DiagramUIRenderPlugin.getPluginId(),
            DiagramUIRenderStatusCodes.OK, DiagramUIRenderMessages.CopyToImageAction_Label, null);

    IRunnableWithProgress runnable = createRunnable(status);

    ProgressMonitorDialog progressMonitorDialog = new ProgressMonitorDialog(
            Display.getCurrent().getActiveShell());
    try {
        progressMonitorDialog.run(false, true, runnable);
    } catch (InvocationTargetException e) {
        Log.warning(DiagramUIRenderPlugin.getInstance(), DiagramUIRenderStatusCodes.IGNORED_EXCEPTION_WARNING,
                e.getTargetException().getMessage(), e.getTargetException());

        if (e.getTargetException() instanceof OutOfMemoryError) {
            if (dialog.exportToHTML()) {
                openErrorDialog(DiagramUIRenderMessages.CopyToImageAction_outOfMemoryMessage);
            } else {
                if (new MessageDialog(dialog.getShell(),
                        DiagramUIRenderMessages.CopyToImageOutOfMemoryDialog_title, null,
                        DiagramUIRenderMessages.CopyToImageOutOfMemoryDialog_message, MessageDialog.ERROR,
                        new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL }, 0)
                                .open() == 0) {
                    runCopyToImageUI(dialog);
                }
            }
        } else if (e.getTargetException() instanceof SWTError) {
            /**
             * SWT returns an out of handles error when processing large
             * diagrams
             */
            if (dialog.exportToHTML()) {
                openErrorDialog(DiagramUIRenderMessages.CopyToImageAction_outOfMemoryMessage);
            } else {
                if (new MessageDialog(dialog.getShell(),
                        DiagramUIRenderMessages.CopyToImageOutOfMemoryDialog_title, null,
                        DiagramUIRenderMessages.CopyToImageOutOfMemoryDialog_message, MessageDialog.ERROR,
                        new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL }, 0)
                                .open() == 0) {
                    runCopyToImageUI(dialog);
                }
            }
        } else {
            openErrorDialog(e.getTargetException().getMessage());
        }
        return;
    } catch (InterruptedException e) {
        /* the user pressed cancel */
        Log.warning(DiagramUIRenderPlugin.getInstance(), DiagramUIRenderStatusCodes.IGNORED_EXCEPTION_WARNING,
                e.getMessage(), e);
    }

    if (!status.isOK()) {
        openErrorDialog(status.getChildren()[0].getMessage());
    }
}