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

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

Introduction

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

Prototype

int INFORMATION

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

Click Source Link

Document

Constant for the info image, or a simple dialog with the info image and a single OK button (value 2).

Usage

From source file:com.toubassi.filebunker.ui.backup.BackupController.java

License:Open Source License

private void performBackup() {
    Shell shell = getShell();/*  w  w w . j  ava 2 s.  c  o m*/

    if (!vault.isConfigured()) {

        String[] buttons = new String[] { "Configure", "Cancel" };

        MessageDialog dialog = new MessageDialog(shell, "Backup", null,
                "You cannot perform a backup until FileBunker has been "
                        + "configured.  You can select the Configure button "
                        + "below or select Configuration from the File menu " + "at any time.",
                MessageDialog.INFORMATION, buttons, 0);
        int selectedButton = dialog.open();

        if (selectedButton == 0) {
            configurationAction.run();
        }
        return;
    }

    BackupResult result = new BackupResult();
    PerformBackup performBackup = new PerformBackup(vault, backupSpec, result, false);

    try {
        new ProgressMonitorDialog(shell).run(true, true, performBackup);

        String message;
        if (result.numberOfFiles() == 0) {
            message = "No files are in need of backup.";
        } else {
            message = formatBackupResultMessage(result, performBackup.estimate(), false);
        }
        MessageDialog.openInformation(shell, "Backup Complete", message);

    } catch (InvocationTargetException e) {
        handleBackupException(e, result, performBackup.estimate());
    } catch (InterruptedException e) {
        handleBackupException(e, result, performBackup.estimate());
    }
}

From source file:com.toubassi.filebunker.ui.restore.RestoreController.java

License:Open Source License

public void restore(RestoreSpecification restoreSpec) {
    Shell shell = getShell();//w  w w.  j a va2  s. c  o m

    if (!vault.isConfigured()) {

        String[] buttons = new String[] { "Configure", "Cancel" };

        MessageDialog dialog = new MessageDialog(shell, "Backup", null,
                "You cannot restore files until FileBunker has been "
                        + "configured.  You can select the Configure button "
                        + "below or select Configuration from the File menu " + "at any time.",
                MessageDialog.INFORMATION, buttons, 0);
        int selectedButton = dialog.open();

        if (selectedButton == 0) {
            configurationAction.run();
        }
        return;
    }

    String restorePath;
    ArrayList revisions = restoreSpec.revisions();
    boolean singleFileSelected = revisions.size() == 1 && !((Revision) revisions.get(0)).isDirectory();

    if (singleFileSelected) {
        FileRevision revision = (FileRevision) revisions.get(0);
        File proposedFile = proposedFileRestoreLocation(revision.node().file());

        FileDialog dialog = new FileDialog(getShell(), SWT.SAVE);
        dialog.setFilterPath(proposedFile.getParent());
        dialog.setFileName(proposedFile.getName());

        restorePath = dialog.open();
    } else {

        DirectoryDialog dialog = new DirectoryDialog(getShell());

        if (revisions.size() == 1) {
            dialog.setMessage("Choose the name that the selected folder "
                    + "will be restored as.  For files that already exist "
                    + "on disk, unique names will be used so that no " + "files are overwritten.");
        } else {
            dialog.setMessage("Choose the folder into which the selected files "
                    + "will be restored.  For files that already exist "
                    + "on disk, unique names will be used so that no " + "files are overwritten.");
        }
        dialog.setFilterPath(spec.commonPath());

        restorePath = dialog.open();
    }

    if (restorePath == null) {
        return;
    }

    File restoreRoot = new File(restorePath);

    if (singleFileSelected && restoreRoot.exists()) {
        MessageBox dialog = new MessageBox(getShell(), SWT.ICON_WARNING | SWT.YES | SWT.NO);

        dialog.setMessage(restoreRoot.getName() + " already exists.  Do you want to replace it?");

        if (dialog.open() != SWT.YES) {
            return;
        }
    }

    RestoreResult result = new RestoreResult();
    PerformRestore performRestore = new PerformRestore(vault, restoreSpec, restoreRoot, result);

    try {
        new ProgressMonitorDialog(shell).run(true, true, performRestore);

        String message;
        if (result.numberOfFiles() == 0) {
            message = "No files were restored.";
        } else {
            message = formatRestoreResultMessage(result, performRestore.estimate(), false);
        }
        MessageDialog.openInformation(shell, "Restore Complete", message);
    } catch (InvocationTargetException e) {
        handleException(e, restoreSpec, result, performRestore.estimate());
    } catch (InterruptedException e) {
        handleException(e, restoreSpec, result, performRestore.estimate());
    }
}

From source file:com.vectrace.MercurialEclipse.views.MergeView.java

License:Open Source License

/**
 * Must be called from the UI thread/*ww w  . ja  v  a2  s  .  c o  m*/
 */
public static void showMergeConflict(HgRoot hgRoot, final ConflictResolvingContext ctx, Shell shell)
        throws PartInitException {
    MergeView view = (MergeView) MercurialEclipsePlugin.getActivePage().showView(MergeView.ID);
    view.refresh(hgRoot, ctx);
    MercurialEclipsePlugin.showDontShowAgainConfirmDialog("A merge conflict occurred",
            "A merge conflict occurred. Use the merge view to resolve and commit the merge",
            MessageDialog.INFORMATION, MercurialPreferenceConstants.PREF_SHOW_MERGE_CONFICT_NOTIFICATION_DIALOG,
            shell);

}

From source file:com.vectrace.MercurialEclipse.views.MergeView.java

License:Open Source License

/**
 * Must be called from the UI thread//from  w w w . j a  v a  2 s .co  m
 */
public static void showRebaseConflict(HgRoot hgRoot, final ConflictResolvingContext ctx, Shell shell)
        throws PartInitException {
    MergeView view = (MergeView) MercurialEclipsePlugin.getActivePage().showView(MergeView.ID);
    view.refresh(hgRoot, ctx);
    MercurialEclipsePlugin.showDontShowAgainConfirmDialog("A rebase conflict occurred",
            "A rebase conflict occurred. Use the merge view to resolve and complete the rebase",
            MessageDialog.INFORMATION,
            MercurialPreferenceConstants.PREF_SHOW_REBASE_CONFICT_NOTIFICATION_DIALOG, shell);
}

From source file:com.vectrace.MercurialEclipse.wizards.PushRepoPage.java

License:Open Source License

/**
 * @see com.vectrace.MercurialEclipse.wizards.PushPullPage#onForceEnabled()
 *///ww  w. j ava2  s  . c  om
@Override
protected void onForceEnabled() {
    MercurialEclipsePlugin.showDontShowAgainConfirmDialog("Push Changesets",
            "On the next page of the wizard " + "please select the revision to push and select the "
                    + "checkbox to enable pushing only that revision (and ancestors)",
            MessageDialog.INFORMATION, MercurialPreferenceConstants.PREF_SHOW_PUSH_FORCE_GUIDANCE_DIALOG,
            getShell());
}

From source file:com.versant.core.jdo.tools.plugins.eclipse.dialogs.WriterOutputDialog.java

License:Open Source License

public WriterOutputDialog(Shell parentShell, String dialogTitle, String dialogMessage) {
    super(parentShell, dialogTitle, null, dialogMessage, MessageDialog.INFORMATION,
            new String[] { IDialogConstants.CLOSE_LABEL }, 0);
    writer = new Writer() {
        public void close() throws IOException {
            final Runnable run = new Runnable() {
                public void run() {
                    if (closeWhenDone.getSelection()) {
                        WriterOutputDialog.this.close();
                    } else {
                        closeWhenDone.setEnabled(false);
                        getButton(0).setEnabled(true);
                    }//from w  ww .j a  v a  2 s  .c om
                }
            };
            if (text != null && !text.isDisposed()) {
                try {
                    text.getDisplay().asyncExec(run);
                } catch (RuntimeException e) {
                    VOAToolsPlugin.log(e);
                }
            }
        }

        public void flush() throws IOException {
        }

        public void write(char[] cbuf, int off, int len) throws IOException {
            final String add = new String(cbuf, off, len);
            final Runnable run = new Runnable() {
                public void run() {
                    text.append(add);
                }
            };
            if (text != null && !text.isDisposed()) {
                try {
                    text.getDisplay().asyncExec(run);
                } catch (RuntimeException e) {
                    VOAToolsPlugin.log(e);
                }
            }
        }
    };
    printWriter = new PrintWriter(writer, true);
}

From source file:com.windowtester.test.eclipse.locator.DialogMessageLocatorSmokeTest.java

License:Open Source License

public void testInfoTextIdentification() throws WidgetSearchException {

    final Label[] label = new Label[1];
    Display.getDefault().asyncExec(new Runnable() {
        public void run() {
            MessageDialog dialog = new MessageDialog(getShell(), "Info", null, "Something",
                    MessageDialog.INFORMATION, new String[] { IDialogConstants.OK_LABEL }, 0) {

                public void create() {
                    super.create();
                    label[0] = this.messageLabel; //cache label
                }/*ww  w  . jav  a2  s.  co m*/
            };
            dialog.open();
        }
    });

    IUIContext ui = getUI();
    ui.wait(new ShellShowingCondition("Info"));

    assertIsMessageLocator(identify(label[0]));

    ui.assertThat(new DialogMessageLocator().hasText("Something"));
    ui.click(new ButtonLocator("OK"));
    ui.wait(new ShellDisposedCondition("Info"));
}

From source file:com.windowtester.test.runtime.CloseNestedShellsTest.java

License:Open Source License

public void uiSetup() {
    Shell shell = new Shell(Display.getDefault());
    dialog = new MessageDialog(shell, "First Shell", null, "message", MessageDialog.INFORMATION,
            new String[] { IDialogConstants.OK_LABEL }, 0) {

        /* (non-Javadoc)
         * @see org.eclipse.jface.dialogs.Dialog#close()
         *///from w w  w .j  a  v  a  2  s . c o m
        @Override
        public boolean close() {
            boolean confirmed = MessageDialog.openConfirm(getShell(), "Nested", "Nested Shell");
            if (confirmed)
                return super.close();
            return false;
        }

    };

    dialog.open();
}

From source file:com.xse.eclipseui.dialog.MessageDialogHelper.java

License:Open Source License

/**
 * Convenience method to open a standard information dialog.
 *
 * @param title/*  w ww.  j a v  a2 s  . co  m*/
 *            the dialog's title, or <code>null</code> if none
 * @param message
 *            the message
 */
public static void openInformation(final String title, final String message) {
    Display.getDefault().syncExec(new Runnable() {
        @Override
        public void run() {
            MessageDialog.open(MessageDialog.INFORMATION, Display.getDefault().getActiveShell(), title, message,
                    SWT.NONE);
        }
    });
}

From source file:com.xse.eclipseui.logging.MessageHelper.java

License:Open Source License

public static void post(final String pluginId, final Severity severity, final String title,
        final String message, final Throwable t) {
    final Status status;
    int kind = MessageDialog.INFORMATION;

    switch (severity) {
    case INFORMATION:
        status = new Status(IStatus.INFO, pluginId, message, t);
        break;/*from   w ww.  j av a2  s  .  c o m*/
    case WARNING:
        status = new Status(IStatus.WARNING, pluginId, message, t);
        kind = MessageDialog.WARNING;
        break;
    case ERROR:
        status = new Status(IStatus.ERROR, pluginId, message, t);
        kind = MessageDialog.ERROR;
        break;
    default:
        status = null;
        break;
    }

    if (status != null) {
        Logger.log(status);
        final int kind2 = kind;
        Display.getDefault().syncExec(new Runnable() {
            @Override
            public void run() {
                MessageDialog.open(kind2, Display.getDefault().getActiveShell(), title, message, SWT.NONE);
            }
        });
    }
}