Example usage for org.eclipse.jface.dialogs MessageDialog QUESTION

List of usage examples for org.eclipse.jface.dialogs MessageDialog QUESTION

Introduction

In this page you can find the example usage for org.eclipse.jface.dialogs MessageDialog QUESTION.

Prototype

int QUESTION

To view the source code for org.eclipse.jface.dialogs MessageDialog QUESTION.

Click Source Link

Document

Constant for the question image, or a simple dialog with the question image and Yes/No buttons (value 3).

Usage

From source file:org.eclipse.jubula.client.ui.rcp.editors.TestCaseEditor.java

License:Open Source License

/**
 * Shows information dialog that saving on observation mode is not allowed
 * @return returnCode of Dialog//w  ww .java  2  s  .  c o  m
 */
private int showSaveInObservModeDialog() {
    MessageDialog dialog = new MessageDialog(Plugin.getActiveWorkbenchWindowShell(),
            Messages.SaveInObservationModeDialogTitle, null, Messages.SaveInObservationModeDialogQuestion,
            MessageDialog.QUESTION,
            new String[] { Messages.DialogMessageButton_YES, Messages.DialogMessageButton_NO }, 0);
    dialog.create();
    DialogUtils.setWidgetNameForModalDialog(dialog);
    dialog.open();
    return dialog.getReturnCode();
}

From source file:org.eclipse.jubula.client.ui.rcp.handlers.AUTAgentDisconnectHandler.java

License:Open Source License

/**
 * @return a confirm Dialog, if monitoring job is still running.
 *///  w  w w .j  av  a  2s  .  c  o m
private MessageDialog getConfirmDialog() {

    MessageDialog dialog = new MessageDialog(getActiveShell(), Messages.ClientDisconnectFromAutAgentTitle, null,
            Messages.ClientDisconnectFromAutAgentMessage, MessageDialog.QUESTION,
            new String[] { Messages.DialogMessageButton_YES, Messages.DialogMessageButton_NO }, 0);
    dialog.create();
    DialogUtils.setWidgetNameForModalDialog(dialog);
    dialog.open();
    return dialog;
}

From source file:org.eclipse.jubula.client.ui.rcp.handlers.delete.AbstractDeleteTreeItemHandler.java

License:Open Source License

/**
 * Pops up a "confirmDelete" dialog./*from   w w w  .  j  ava2s.co  m*/
 * 
 * @param itemNames
 *            The names of the items to be deleted.
 * @return <code>true</code>, if "yes" was clicked, 
 *         <code>false</code> otherwise.
 */
public boolean confirmDelete(Collection<String> itemNames) {
    String label = StringConstants.EMPTY;
    if (itemNames.size() == 1) {
        label = NLS.bind(Messages.DeleteTreeItemActionDeleteOneItem, itemNames.iterator().next());
    } else if (itemNames.size() == 0) {
        return false;
    } else {
        label = NLS.bind(Messages.DeleteTreeItemActionDeleteMultipleItems, itemNames.size());
    }
    MessageDialog dialog = new MessageDialog(getActiveShell(), Messages.DeleteTreeItemActionShellTitle, null,
            label, MessageDialog.QUESTION,
            new String[] { Messages.DialogMessageButton_YES, Messages.DialogMessageButton_NO }, 0);
    dialog.create();
    DialogUtils.setWidgetNameForModalDialog(dialog);
    dialog.open();
    return dialog.getReturnCode() == 0;
}

From source file:org.eclipse.jubula.client.ui.rcp.handlers.DeleteTestresultsHandler.java

License:Open Source License

/**
 * Shows information dialog, that selected testresults will be deleted
 * @return returnCode of Dialog/*w  w w  .  j av  a  2  s .  c  o m*/
 */
private int showDeleteTestresultsDialog() {
    MessageDialog dialog = new MessageDialog(getActiveShell(),
            Messages.TestresultSummaryDeleteTestrunDialogTitle, null,
            Messages.TestresultSummaryDeleteTestrunDialogMessage, MessageDialog.QUESTION,
            new String[] { Messages.DialogMessageButton_YES, Messages.DialogMessageButton_NO }, 0);
    dialog.create();
    DialogUtils.setWidgetNameForModalDialog(dialog);
    dialog.open();
    return dialog.getReturnCode();
}

From source file:org.eclipse.jubula.client.ui.rcp.handlers.RevertEditorChangesHandler.java

License:Open Source License

/**
 * Shows confirm dialog for this action and returns the dialog object
 * @return confirm dialog for this action
 *///from   ww w  . j  a  v a2s .  c om
private MessageDialog showConfirmDialog() {
    MessageDialog dialog = new MessageDialog(getActiveShell(), Messages.RevertEditorChangesActionShellTitle,
            null, Messages.RevertEditorChangesActionQuestionText, MessageDialog.QUESTION,
            new String[] { Messages.DialogMessageButton_YES, Messages.DialogMessageButton_NO }, 0);
    dialog.create();
    DialogUtils.setWidgetNameForModalDialog(dialog);
    dialog.open();
    return dialog;
}

From source file:org.eclipse.jubula.client.ui.rcp.handlers.StopAutHandler.java

License:Open Source License

/**
 * @return a confirm Dialog/*  w  w w .  j  av  a 2  s  .c o m*/
 */
private MessageDialog getConfirmDialog() {
    String questionText;
    if (isJobRunning()) {
        questionText = Messages.StopAUTActionQuestionTextIfcollecting;
    } else {
        questionText = Messages.StopAUTActionQuestionText;
    }
    MessageDialog dialog = new MessageDialog(getActiveShell(), Messages.StopAUTActionShellTitle, null,
            questionText, MessageDialog.QUESTION,
            new String[] { Messages.DialogMessageButton_YES, Messages.DialogMessageButton_NO }, 0);
    dialog.create();
    DialogUtils.setWidgetNameForModalDialog(dialog);
    dialog.open();
    return dialog;
}

From source file:org.eclipse.jubula.client.ui.rcp.properties.ProjectGeneralPropertyPage.java

License:Open Source License

/**
 * @param parent The parent <code>Composite</code>
 *///from   ww  w  .  j  a  v  a 2  s.co  m
private void createTrackChangesDeleteDataButton(Composite parent) {
    m_deleteChanges = new Button(parent, SWT.PUSH);
    m_deleteChanges.setText(Messages.PrefPageTrackChangesDeleteData);
    GridData gridData = new GridData(SWT.END, SWT.BEGINNING, false, false);
    gridData.horizontalSpan = 1;
    gridData.grabExcessHorizontalSpace = false;
    m_deleteChanges.setLayoutData(gridData);

    m_deleteChanges.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent e) {
            Dialog qDialog = new MessageDialog(getShell(), Messages.UtilsConfirmation, null,
                    Messages.PrefPageTrackChangesDeleteDataQuestion, MessageDialog.QUESTION,
                    new String[] { Messages.UtilsYes, Messages.UtilsNo }, 0);
            qDialog.setBlockOnOpen(true);
            qDialog.open();
            if (qDialog.getReturnCode() == 0) {
                // delete all tracked changes
                try {
                    PlatformUI.getWorkbench().getProgressService().run(true, false,
                            new DeleteTrackedChangesOperation());
                } catch (InvocationTargetException ite) {
                    // nothing
                } catch (InterruptedException ie) {
                    // nothing
                }
            }
        }
    });
}

From source file:org.eclipse.jubula.client.ui.rcp.properties.ProjectGeneralPropertyPage.java

License:Open Source License

/**
 * creates and opens a dialog if a search for the deprecated Modules
 * should be done//from   ww  w.jav a 2  s  .  c om
 * @return the boolean if the search should be done
 */
private boolean openSearchForDeprecatedDialog() {
    MessageDialog mdiag = new MessageDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(),
            Messages.ProjectPropertyPageSearchForDeprProjModuleTitle, null,
            Messages.ProjectPropertyPageSearchForDeprProjModuleMsg, MessageDialog.QUESTION,
            new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL }, 0);
    mdiag.create();
    Plugin.getHelpSystem().setHelp(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(),
            ContextHelpIds.SEARCH_FOR_DEPRECATED_MODULES_DIALOG);
    return (mdiag.open() == Window.OK);
}

From source file:org.eclipse.jubula.client.ui.rcp.utils.Utils.java

License:Open Source License

/**
 * Opens a perspective with the given ID.
 * @param perspectiveID The ID of the perspective to open.
 * @return True, if the user wants to change the perspective, false otherwise.
 *//*from w w w .  j ava 2 s  . co m*/
public static boolean openPerspective(String perspectiveID) {
    IWorkbench worbench = PlatformUI.getWorkbench();
    IWorkbenchWindow activeWindow = worbench.getActiveWorkbenchWindow();
    try {
        IPerspectiveDescriptor activePerspective = getActivePerspective(activeWindow.getActivePage());
        if (activePerspective != null && activePerspective.getId().equals(perspectiveID)) {
            return true;
        }
        final IPreferenceStore preferenceStore = Plugin.getDefault().getPreferenceStore();
        int value = preferenceStore.getInt(Constants.PERSP_CHANGE_KEY);
        if (value == Constants.PERSPECTIVE_CHANGE_YES) {
            worbench.showPerspective(perspectiveID, activeWindow);
            return true;
        } else if (value == Constants.PERSPECTIVE_CHANGE_NO) {
            return true;
        }
        // if --> value = Constants.PERSPECTIVE_CHANGE_PROMPT:
        String perspectiveName = StringConstants.EMPTY;
        if (perspectiveID.equals(Constants.SPEC_PERSPECTIVE)) {
            perspectiveName = Messages.UtilsSpecPerspective;
        } else {
            perspectiveName = Messages.UtilsExecPerspective;
        }
        final int returnCodeYES = 256; // since Eclipse3.2 (not 0)
        final int returnCodeNO = 257; // since Eclipse3.2 (not 1)
        final int returnCodeCANCEL = -1;
        MessageDialogWithToggle dialog = new MessageDialogWithToggle(activeWindow.getShell(),
                Messages.UtilsTitle, null, NLS.bind(Messages.UtilsQuestion, perspectiveName),
                MessageDialog.QUESTION, new String[] { Messages.UtilsYes, Messages.UtilsNo }, 0,
                Messages.UtilsRemember, false) {
            /**
             * {@inheritDoc}
             */
            protected void buttonPressed(int buttonId) {
                super.buttonPressed(buttonId);
                preferenceStore.setValue(Constants.REMEMBER_KEY, getToggleState());
                int val = Constants.PERSPECTIVE_CHANGE_PROMPT;
                if (getToggleState() && getReturnCode() == returnCodeNO) {
                    val = Constants.PERSPECTIVE_CHANGE_NO;
                } else if (getToggleState() && getReturnCode() == returnCodeYES) {
                    val = Constants.PERSPECTIVE_CHANGE_YES;
                }
                preferenceStore.setValue(Constants.PERSP_CHANGE_KEY, val);
            }
        };
        dialog.create();
        DialogUtils.setWidgetNameForModalDialog(dialog);
        dialog.open();
        if (dialog.getReturnCode() == returnCodeNO) {
            return true;
        } else if (dialog.getReturnCode() == returnCodeCANCEL) {
            return false;
        }
        worbench.showPerspective(perspectiveID, activeWindow);
    } catch (WorkbenchException e) {
        StringBuilder msg = new StringBuilder();
        msg.append(Messages.CannotOpenThePerspective).append(StringConstants.COLON)
                .append(StringConstants.SPACE).append(perspectiveID).append(StringConstants.LEFT_PARENTHESES)
                .append(e).append(StringConstants.RIGHT_PARENTHESES).append(StringConstants.DOT);
        log.error(msg.toString());
        ErrorHandlingUtil.createMessageDialog(MessageIDs.E_NO_PERSPECTIVE);
        return false;
    }
    return true;
}

From source file:org.eclipse.jubula.client.ui.utils.ErrorHandlingUtil.java

License:Open Source License

/**
 * Open the message dialog./*from   w w  w  .java2  s.c o m*/
 * <p><b>Use createMessageDialog(JBException ex, Object[] params, String[] details)
 * instead, if you want to get an entry in error log.</b></p>
 * @param messageID the actual messageID
 * @param params Parameter of the message text or null, if not needed.
 * @param details use null, or overwrite in MessageIDs hardcoded details.
 * @param parent the parent shell to use for this message dialog
 * @return the dialog.
 */
public static Dialog createMessageDialog(final Integer messageID, final Object[] params, final String[] details,
        final Shell parent) {
    String title = StringConstants.EMPTY;
    String message = StringConstants.EMPTY;
    String[] labels = new String[] { JFaceResources.getString(IDialogLabelKeys.OK_LABEL_KEY) };
    int imageID = MessageDialog.INFORMATION;
    Message msg = MessageIDs.getMessageObject(messageID);
    String[] detail = lineFeed(msg.getDetails());
    if (details != null) {
        detail = lineFeed(details);
    }
    switch (msg.getSeverity()) {
    case Message.ERROR:
        title = Messages.UtilsError;
        message = Messages.UtilsErrorOccurred;
        break;
    case Message.INFO:
        title = Messages.UtilsInfo1;
        message = Messages.UtilsInfo2;
        break;
    case Message.WARNING:
        title = Messages.UtilsWarning1;
        message = Messages.UtilsWarning2;
        break;
    case Message.QUESTION:
        title = Messages.UtilsRequest1;
        message = Messages.UtilsRequest2;
        labels = new String[] { JFaceResources.getString(IDialogLabelKeys.YES_LABEL_KEY),
                JFaceResources.getString(IDialogLabelKeys.NO_LABEL_KEY) };
        imageID = MessageDialog.QUESTION;
        break;
    default:
        break;
    }
    IStatus[] status = new Status[detail.length];
    for (int i = 0; i < detail.length; i++) {
        status[i] = new Status(msg.getSeverity(), Constants.PLUGIN_ID, IStatus.OK, detail[i], null);
    }
    if ((msg.getSeverity() == Message.INFO || msg.getSeverity() == Message.QUESTION)) {
        StringBuilder messageBuilder = new StringBuilder(message);
        messageBuilder.append(msg.getMessage(params));
        messageBuilder.append(StringConstants.NEWLINE);
        for (IStatus s : status) {
            if (s.getMessage() != Message.NO_DETAILS) {
                messageBuilder.append(StringConstants.NEWLINE);
                messageBuilder.append(s.getMessage());
            }
        }
        dlg = new MessageDialog(parent, title, null, messageBuilder.toString(), imageID, labels, 0);
    } else {
        dlg = new ErrorDialog(parent, title, message,
                new MultiStatus(Constants.PLUGIN_ID, IStatus.OK, status, msg.getMessage(params), null),
                IStatus.OK | IStatus.INFO | IStatus.WARNING | IStatus.ERROR);
    }
    dlg.create();
    DialogUtils.setWidgetNameForModalDialog(dlg);
    dlg.open();
    return dlg;
}