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

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

Introduction

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

Prototype

public int open() 

Source Link

Document

Opens this window, creating it first if it has not yet been created.

Usage

From source file:com.mercatis.lighthouse3.base.ui.handlers.AbstractDeleteHandler.java

License:Apache License

protected boolean showDialog(Object[] elements) {
    String message = "";
    if (elements.length == 1) {
        message = "Do you really want to delete " + LabelConverter.getLabel(elements[0]) + "?";
    } else if (elements.length > 1) {
        message = "Do you really want to delete these " + elements.length + " elements?";
    } else {//ww w.j  a va 2s. c  o  m
        throw new RuntimeException("No elements in selection!");
    }
    MessageDialog md = new MessageDialog(PlatformUI.getWorkbench().getDisplay().getActiveShell(), "Delete",
            null, message, MessageDialog.QUESTION, new String[] { "Yes", "No" }, 1);
    int button = md.open();
    return button == 0;
}

From source file:com.mercatis.lighthouse3.ui.operations.ui.handlers.ExecuteJobHandler.java

License:Apache License

@Override
protected void execute(Object element) throws ExecutionException {
    if (element instanceof Job) {
        Job job = (Job) element;//from w  w w .ja v  a2  s. com
        MessageDialog md = new MessageDialog(PlatformUI.getWorkbench().getDisplay().getActiveShell(),
                "Manual Execute", null, "Execute " + LabelConverter.getLabel(job) + "?", MessageDialog.QUESTION,
                new String[] { "Yes", "No" }, 1);
        int button = md.open();
        if (button == 0) {
            LighthouseDomain lighthouseDomain = OperationBase.getJobService().getLighthouseDomainForJob(job);
            OperationBase.getOperationInstallationService().execute(lighthouseDomain, job.getScheduledCall());
        }
    }
}

From source file:com.mercatis.lighthouse3.ui.status.handler.ViewReasonHandler.java

License:Apache License

@Override
protected void execute(Object element) throws ExecutionException {
    if (element instanceof ManualStatusClearance) {
        ManualStatusClearance msc = (ManualStatusClearance) element;
        String message = "Cleared by: " + msc.getClearer() + "\n\n";
        message += msc.getReason() != null && !msc.getReason().equals("") ? msc.getReason()
                : "No reason defined";
        MessageDialog md = new MessageDialog(PlatformUI.getWorkbench().getDisplay().getActiveShell(),
                "Manual Clearance Reason", null, message, MessageDialog.INFORMATION, new String[] { "Ok" }, 0);
        md.open();
    }//from w w w.ja v a2s  .c  om
}

From source file:com.microsoft.azuretools.docker.utils.AzureDockerUIResources.java

License:Open Source License

public static int deleteAzureDockerHostConfirmationDialog(Shell shell, Azure azureClient,
        DockerHost dockerHost) {/*from www. j ava 2  s  .  co  m*/
    String promptMessageDeleteAll = String.format(
            "This operation will delete virtual machine %s and its resources:\n"
                    + "\t - network interface: %s\n" + "\t - public IP: %s\n" + "\t - virtual network: %s\n"
                    + "The associated disks and storage account will not be deleted\n",
            dockerHost.hostVM.name, dockerHost.hostVM.nicName, dockerHost.hostVM.publicIpName,
            dockerHost.hostVM.vnetName);

    String promptMessageDelete = String.format("This operation will delete virtual machine %s.\n"
            + "The associated disks and storage account will not be deleted\n\n"
            + "Are you sure you want to continue?\n", dockerHost.hostVM.name);

    String[] options;
    String promptMessage;

    if (AzureDockerVMOps.isDeletingDockerHostAllSafe(azureClient, dockerHost.hostVM.resourceGroupName,
            dockerHost.hostVM.name)) {
        promptMessage = promptMessageDeleteAll;
        options = new String[] { "Cancel", "Delete VM Only", "Delete All" };
    } else {
        promptMessage = promptMessageDelete;
        options = new String[] { "Cancel", "Delete" };
    }

    MessageDialog deleteDialog = new MessageDialog(shell, "Delete Docker Host", null, promptMessage,
            MessageDialog.ERROR, options, 0);
    int dialogReturn = deleteDialog.open();

    switch (dialogReturn) {
    case 0:
        if (AzureDockerUtils.DEBUG)
            System.out.format("Delete Docker Host op was canceled %s\n", dialogReturn);
        break;
    case 1:
        if (AzureDockerUtils.DEBUG)
            System.out.println("Delete VM only: " + dockerHost.name);
        break;
    case 2:
        if (AzureDockerUtils.DEBUG)
            System.out.println("Delete VM and resources: " + dockerHost.name);
        break;
    default:
        if (AzureDockerUtils.DEBUG)
            System.out.format("Delete Docker Host op was canceled %s\n", dialogReturn);
    }

    return dialogReturn;
}

From source file:com.microsoft.tfs.client.common.ui.dialogs.vc.checkinpolicies.PolicyScopeDialog.java

License:Open Source License

@Override
protected void hookCustomButtonPressed(final int buttonId) {
    if (buttonId == IDialogConstants.HELP_ID) {
        final String text = Messages.getString("PolicyScopeDialog.CheckInPolicyRegexDialogText"); //$NON-NLS-1$

        final MessageDialog dialog = new MessageDialog(getShell(),
                Messages.getString("PolicyScopeDialog.CheckInPolicyRegexDialogTitle"), //$NON-NLS-1$
                null, text, MessageDialog.INFORMATION, new String[] { IDialogConstants.OK_LABEL }, 0);

        dialog.open();
    }/*from   ww w. j  av  a  2  s .com*/
}

From source file:com.microsoft.tfs.client.common.ui.helpers.UndoHelper.java

License:Open Source License

private static int promptForChange(final Shell shell, final PendingChange change) {
    final String message = MessageFormat.format(
            Messages.getString("UndoHelper.ConfirmUndoAndDiscardChangesFormat"), //$NON-NLS-1$
            change.getLocalItem());/*from   w  ww .ja  v  a 2 s.  c  om*/

    final MessageDialog dialog = new MessageDialog(shell, Messages.getString("UndoHelper.ConfirmDialogTitle"), //$NON-NLS-1$
            null, message, MessageDialog.WARNING, DIALOG_BUTTON_LABELS, YES);

    return dialog.open();
}

From source file:com.mindquarry.desktop.client.MindClient.java

License:Open Source License

private void ensureSettingsFolderExists() {
    File file = new File(PreferenceUtilities.SETTINGS_FOLDER);
    if (!file.exists()) {
        if (!file.mkdirs()) {
            log.error("Cannot create settings folder '" + file.getAbsolutePath() + "'");
            MessageDialog dlg = new MessageDialog(getShell(), I18N.getString("Cannot create settings folder"),
                    null,/*w  ww .  j  a  v a2s . co m*/
                    I18N.get("The Mindquarry Desktop Client cannot create its settings folder at\n\n"
                            + "'{0}'\n\nMaybe you don't have permissions to access it?\n\n"
                            + "If you continue, the program won't work properly, so it is strongly "
                            + "recommended to ensure write-access to that folder and restart the client.",
                            file.getAbsolutePath()),
                    MessageDialog.ERROR,
                    new String[] { I18N.getString("Exit"), I18N.getString("Start anyway") }, 0);
            int result = dlg.open();
            if (result == 0) {
                System.exit(1);
            } else {
                log.warn("Starting despite missing settings folder"); //$NON-NLS-1$
            }
        }
    }
}

From source file:com.mindquarry.desktop.client.MindClient.java

License:Open Source License

private void createLock() {
    File f = new File(LOCK_FILE);

    try {//from  w  w  w .ja  v a  2s. co m
        if (!f.exists()) {
            f.createNewFile();
        }
    } catch (IOException e) {
        log.error("Cannot create lock file '" + f.getAbsolutePath() + "'", e); //$NON-NLS-1$
    }

    // this is the recommended way to implement locking, it doesn't leave
    // a lock file, not even if the app crashes:
    FileChannel fileChannel;
    try {
        fileChannel = (new FileOutputStream(f)).getChannel();
        fileLock = fileChannel.tryLock();
        if (fileLock == null) {
            MessageDialog dlg = new MessageDialog(getShell(),
                    I18N.getString("Mindquarry Client already running"), null,
                    I18N.getString("The Mindquarry Desktop Client seems to be running "
                            + "already. Only one instance of the Desktop Client can be "
                            + "running at a time. If you are sure that the Desktop Client "
                            + "isn't running, select 'Start anyway'."),
                    MessageDialog.ERROR,
                    new String[] { I18N.getString("Exit"), I18N.getString("Start anyway") }, 0);
            int result = dlg.open();
            if (result == 0) {
                System.exit(1);
            } else {
                log.warn("Starting despite lock file"); //$NON-NLS-1$
            }
        } else {
            log.info("Aquired lock: " + fileLock);
        }
    } catch (IOException e) {
        log.error("Cannot create lock on lock file '" + f.getAbsolutePath(), e);
    }
    // Note: no need to delete the lock, the JVM will care about that
}

From source file:com.mindquarry.desktop.client.MindClient.java

License:Open Source License

/**
 * Displays an error message and prompts the user to check their credentials
 * in the preferences dialog, or to cancel.
 * //  w w w.  j  a  v  a  2s .  c o m
 * @param exception
 *            Contains the error message to be displayed.
 * @return True if and only if preferences dialog was shown to user which
 *         means that the credentials were potentially updated.
 */
public boolean handleNotAuthorizedException(NotAuthorizedException exception) {
    // create custom error message with the option to open the preferences
    // dialog
    MessageDialog messageDialog = new MessageDialog(getShell(), I18N.getString("Error"), //$NON-NLS-1$
            null, (exception.getLocalizedMessage() + "\n\n" //$NON-NLS-1$
                    + I18N.getString(
                            "Please check your username and password settings in the preferences dialog.")), //$NON-NLS-1$
            MessageDialog.ERROR, new String[] { I18N.getString("Go to preferences"), //$NON-NLS-1$
                    I18N.getString("Cancel") //$NON-NLS-1$
            }, 0);

    int buttonClicked = messageDialog.open();
    switch (buttonClicked) {
    case 0: // go to preferences
        showPreferenceDialog(true);
        return true;

    case 1: // cancel
        displayNotConnected();
        return false;
    }
    return false;
}

From source file:com.mindquarry.desktop.client.MindClient.java

License:Open Source License

/**
 * Displays an error message and prompts the user to check their server
 * settings in the preferences dialog, or to cancel.
 * /*w ww.  j ava2s.c  o m*/
 * @param exception
 *            Contains the unknown host.
 * @return True if and only if preferences dialog was shown to user which
 *         means that the server details were potentially updated.
 */
public boolean handleUnknownHostException(UnknownHostException exception) {
    // create custom error message with the option to open the preferences
    // dialog
    MessageDialog messageDialog = new MessageDialog(getShell(), I18N.getString("Error"), //$NON-NLS-1$
            null, (I18N.get("Unknown server: \"{0}\"", exception.getLocalizedMessage()) //$NON-NLS-1$
                    + "\n\n" //$NON-NLS-1$
                    + I18N.getString("Please check your Mindquarry server URL in the preferences dialog.")), //$NON-NLS-1$
            MessageDialog.ERROR, new String[] { I18N.getString("Go to preferences"), //$NON-NLS-1$
                    I18N.getString("Cancel") //$NON-NLS-1$
            }, 0);

    int buttonClicked = messageDialog.open();
    switch (buttonClicked) {
    case 0: // go to preferences
        showPreferenceDialog(true);
        return true;

    case 1: // cancel
        displayNotConnected();
        return false;
    }
    return false;
}