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

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

Introduction

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

Prototype

public MessageDialog(Shell parentShell, String dialogTitle, Image dialogTitleImage, String dialogMessage,
        int dialogImageType, int defaultIndex, String... dialogButtonLabels) 

Source Link

Document

Create a message dialog.

Usage

From source file:net.resheim.eclipse.timekeeper.ui.Activator.java

License:Open Source License

/**
 * Must be called by the UI-thread//from ww  w .  j  a va2 s. c  o m
 *
 * @param idleTimeMillis
 */
private void handleReactivation(long idleTimeMillis) {
    // We want only one dialog open.
    if (dialogIsOpen) {
        return;
    }
    synchronized (this) {
        if (idleTimeMillis < lastIdleTime && lastIdleTime > IDLE_INTERVAL) {
            // If we have an active task
            ITask task = TasksUi.getTaskActivityManager().getActiveTask();
            if (task != null && Activator.getValue(task, Activator.START) != null) {
                dialogIsOpen = true;
                String tickString = Activator.getValue(task, Activator.TICK);
                LocalDateTime started = getActiveSince();
                LocalDateTime ticked = LocalDateTime.parse(tickString);
                LocalDateTime lastTick = ticked;
                // Subtract the IDLE_INTERVAL time the computer _was_
                // idle while counting up to the threshold. During this
                // period fields were updated. Thus must be adjusted for.
                ticked = ticked.minusNanos(IDLE_INTERVAL);
                String time = DurationFormatUtils.formatDuration(lastIdleTime, "H:mm:ss", true);

                StringBuilder sb = new StringBuilder();
                if (task.getTaskKey() != null) {
                    sb.append(task.getTaskKey());
                    sb.append(": ");
                }
                sb.append(task.getSummary());
                MessageDialog md = new MessageDialog(Display.getCurrent().getActiveShell(),
                        "Disregard idle time?", null,
                        MessageFormat.format(
                                "The computer has been idle since {0}, more than {1}. The active task \"{2}\" was started on {3}. Deactivate the task and disregard the idle time?",
                                ticked.format(DateTimeFormatter.ofPattern("EEE e, HH:mm:ss", Locale.US)), time,
                                sb.toString(),
                                started.format(DateTimeFormatter.ofPattern("EEE e, HH:mm:ss", Locale.US))),
                        MessageDialog.QUESTION, new String[] { "No", "Yes" }, 1);
                int open = md.open();
                dialogIsOpen = false;
                if (open == 1) {
                    // Stop task, subtract initial idle time
                    TasksUi.getTaskActivityManager().deactivateTask(task);
                    reduceTime(task, ticked.toLocalDate().toString(), IDLE_INTERVAL / 1000);
                } else {
                    // Continue task, add idle time
                    LocalDateTime now = LocalDateTime.now();
                    long seconds = lastTick.until(now, ChronoUnit.MILLIS);
                    accumulateTime(task, ticked.toLocalDate().toString(), seconds);
                    Activator.setValue(task, Activator.TICK, now.toString());
                }
            }
        }
    }
}

From source file:net.rim.ejde.internal.core.BasicClasspathElementChangedListener.java

License:Open Source License

private void setJDKCompatibilitySettings(final IJavaProject mainProject, final List<IJavaProject> nonBBProjects,
        final List<IJavaProject> projectsWithProblem) {
    _log.trace("Entered setJDKCompatibilitySettings()");
    if (projectsWithProblem.size() > 0) {
        StringBuffer projectList = new StringBuffer();
        for (IJavaProject javaProject : projectsWithProblem) {
            projectList.append(javaProject.getProject().getName() + "\n");
        }/*from   w ww.ja  v  a 2s.  c o  m*/
        final String projectNames = projectList.toString();
        Display.getDefault().syncExec(new Runnable() {
            public void run() {
                Shell shell = ContextManager.getActiveWorkbenchWindow().getShell();
                StringBuffer messageBuffer = new StringBuffer(
                        Messages.ClasspathChangeManager_settingJDKComplianceMsg1);
                messageBuffer.append("\n");
                messageBuffer.append(NLS.bind(Messages.ClasspathChangeManager_settingJDKComplianceMsg2,
                        mainProject.getProject().getName()));
                messageBuffer.append("\n");
                messageBuffer.append(projectNames);
                messageBuffer.append("\n");
                messageBuffer.append(Messages.ClasspathChangeManager_settingJDKComplianceMsg3);
                MessageDialog complianceDialog = new MessageDialog(shell,
                        Messages.ClasspathChangeManager_DialogTitle, null, messageBuffer.toString(),
                        MessageDialog.INFORMATION, new String[] { Messages.IConstants_OK_BUTTON_TITLE,
                                Messages.IConstants_CANCEL_BUTTON_TITLE },
                        0);

                int buttonEventCode = complianceDialog.open();

                switch (buttonEventCode) {
                case Window.OK: {
                    processNonBBProjects(nonBBProjects, projectsWithProblem, true);
                    break;
                }
                case Window.CANCEL: {
                    processNonBBProjects(nonBBProjects, projectsWithProblem, false);
                    break;
                }
                default:
                    throw new IllegalArgumentException("Unsupported dialog button event!");
                }
                complianceDialog.close();
            }
        });
    } else {
        processNonBBProjects(nonBBProjects, projectsWithProblem, false);
    }
}

From source file:net.rim.ejde.internal.core.BasicClasspathElementChangedListener.java

License:Open Source License

private void processNonBBProjects(final List<IJavaProject> nonBBProjects,
        final List<IJavaProject> projectsWithProblem, final boolean fix) {
    for (IJavaProject javaProject : nonBBProjects) {
        if (fix && projectsWithProblem.contains(javaProject)) {
            ImportUtils.initializeProjectOptions(javaProject);
        }//from   w  w w  . j a v  a 2  s . com
    }
    if (fix) {
        Shell shell = ContextManager.getActiveWorkbenchWindow().getShell();
        String message = Messages.ClasspathChangeManager_rebuildProjectMsg1;
        StringBuffer projectList = new StringBuffer();
        for (IJavaProject javaProject : projectsWithProblem) {
            projectList.append(javaProject.getProject().getName() + "\n");
        }
        message += projectList.toString();
        message += Messages.ClasspathChangeManager_rebuildProjectMsg2;
        MessageDialog dialog = new MessageDialog(shell,
                Messages.ClasspathChangeManager_RebuildProjectDialogTitle, null, message,
                MessageDialog.INFORMATION,
                new String[] { Messages.IConstants_OK_BUTTON_TITLE, Messages.IConstants_CANCEL_BUTTON_TITLE },
                0);
        int buttonEventCode = dialog.open();

        switch (buttonEventCode) {
        case Window.OK: {
            buildProjects(projectsWithProblem);
            break;
        }
        case Window.CANCEL: {
            break;
        }
        default:
            throw new IllegalArgumentException("Unsupported dialog button event!");
        }
        dialog.close();
    }
}

From source file:net.rim.ejde.internal.launching.MDSCSChecker.java

License:Open Source License

private static void askUserDecision(final String title, final String message) {
    Display.getDefault().syncExec(new Runnable() {
        public void run() {
            Shell shell = new Shell();
            MessageDialog dialog = new MessageDialog(shell, title, null, // accept the default window icon
                    message, MessageDialog.WARNING,
                    new String[] { IDialogConstants.PROCEED_LABEL, IDialogConstants.STOP_LABEL }, 0); // proceed
            // is the default
            _userDecision = dialog.open();
            shell.dispose();/*w  ww .j  ava 2  s . c  om*/
        }
    });
}

From source file:net.rim.ejde.internal.signing.ImportCSIFilesAction.java

License:Open Source License

/**
 * Displays a warning dialog indicating that the signature tool is already running.
 *//*from   ww w  .  j a  v a 2s  .c o m*/
private void warnSignatureToolRunning() {
    MessageDialog dialog = new MessageDialog(ContextManager.getActiveWorkbenchShell(),
            "Signature Tool is already running...", null,
            "The Signature Tool is already running.  Please exit the tool before running it again.",
            MessageDialog.WARNING, new String[] { "OK" }, 0);
    dialog.open();
}

From source file:net.rim.ejde.internal.signing.ImportSignKeysAction.java

License:Open Source License

@Override
public void run(IAction action) {
    // Open file dialog to allow user select the parent folder of *.csk and *.db files
    SigningSearchDialog oldKeyDialog = new SigningSearchDialog(ContextManager.getActiveWorkbenchShell());
    try {/*w  ww  .  j a v a2  s.  c  o m*/
        ArrayList<File> oldKeyFiles = oldKeyDialog.search();
        if (oldKeyFiles != null) {
            oldKeyDialog.copyFileIntoSignToolDir(oldKeyFiles);
            MessageDialog dialog = new MessageDialog(ContextManager.getActiveWorkbenchShell(),
                    Messages.CodeSigningPrefsPage_MessageDialogTitle1, null,
                    Messages.CodeSigningPrefsPage_MessageDialogMsg1, MessageDialog.INFORMATION,
                    new String[] { IDialogConstants.OK_LABEL }, 0);
            dialog.open();
            _log.info(Messages.CodeSigningPrefsPage_MessageDialogMsg9);
        }
    } catch (IllegalArgumentException ex) {
        MessageDialog dialog = new MessageDialog(ContextManager.getActiveWorkbenchShell(),
                Messages.CodeSigningPrefsPage_MessageDialogTitle1, null, ex.getMessage(), MessageDialog.WARNING,
                new String[] { IDialogConstants.OK_LABEL }, 0);
        dialog.open();
    }
}

From source file:net.rim.ejde.internal.signing.RemoveSignKeysAction.java

License:Open Source License

private void removeKeys() {
    try {//from   w ww  .  jav a2 s.  c o m
        File cskFile = new File(
                VMToolsUtils.getVMToolsFolderPath() + File.separator + IConstants.CSK_FILE_NAME);
        File dbFile = new File(VMToolsUtils.getVMToolsFolderPath() + File.separator + IConstants.DB_FILE_NAME);
        if ((!cskFile.exists()) && (!dbFile.exists())) {
            MessageDialog dialog = new MessageDialog(ContextManager.getActiveWorkbenchShell(),
                    Messages.CodeSigningPrefsPage_MessageDialogTitle3, null,
                    Messages.CodeSigningPrefsPage_MessageDialogMsg3, MessageDialog.WARNING,
                    new String[] { IDialogConstants.OK_LABEL }, 0);
            dialog.open();
            return;
        }
        if (cskFile.exists()) {
            cskFile.renameTo(new File(VMToolsUtils.getVMToolsFolderPath() + File.separator
                    + IConstants.CSK_FILE_NAME + IConstants.UNDERSCORE_STRING + System.currentTimeMillis()));
        }
        if (dbFile.exists()) {
            dbFile.renameTo(new File(VMToolsUtils.getVMToolsFolderPath() + File.separator
                    + IConstants.DB_FILE_NAME + IConstants.UNDERSCORE_STRING + System.currentTimeMillis()));
        }
        if ((!cskFile.exists()) && (!dbFile.exists())) {
            MessageDialog dialog = new MessageDialog(ContextManager.getActiveWorkbenchShell(),
                    Messages.CodeSigningPrefsPage_MessageDialogTitle3, null,
                    Messages.CodeSigningPrefsPage_MessageDialogMsg5
                            + Messages.CodeSigningPrefsPage_MessageDialogMsg6,
                    MessageDialog.INFORMATION, new String[] { IDialogConstants.OK_LABEL }, 0);
            dialog.open();
            _log.info(Messages.CodeSigningPrefsPage_MessageDialogMsg7);
        }
    } catch (IOException e) {
        _log.error(e.getMessage());
    }
}

From source file:net.rim.ejde.internal.signing.SignatureToolLaunchAction.java

License:Open Source License

/**
 * Displays a warning dialog indicating that the signature tool is already running.
 *///from   w  w w  .j a  v  a2 s  . c o  m
private static void warnSignatureToolRunning() {
    Display.getDefault().syncExec(new Runnable() {
        public void run() {
            MessageDialog dialog = new MessageDialog(ContextManager.getActiveWorkbenchShell(),
                    Messages.SignCommandHandler_SigToolRunningDialogTitleMsg, null,
                    Messages.SignCommandHandler_SigToolRunningDialogMsg, MessageDialog.WARNING,
                    new String[] { IDialogConstants.OK_LABEL }, 0);
            dialog.open();
        }
    });
}

From source file:net.rim.ejde.internal.ui.preferences.SignatureToolPrefsPage.java

License:Open Source License

@Override
protected Control createContents(Composite parent) {

    Composite main = new Composite(parent, SWT.NONE);
    GridLayout layout = new GridLayout();
    layout.numColumns = 1;/*ww w. java 2 s .  c o  m*/
    main.setLayout(layout);
    main.setLayoutData(new GridData(GridData.FILL_BOTH));

    Label linkLabel = new Label(main, SWT.NONE);
    linkLabel.setText(Messages.CodeSigningPrefsPage_ClickHereLabel);

    Link keyLink = new Link(main, SWT.NONE);
    keyLink.setText(Messages.CodeSigningPrefsPage_AddNewKeyLabel);
    keyLink.setToolTipText(Messages.CodeSigningPrefsPage_AddNewKeyToolTip);

    keyLink.addListener(SWT.Selection, new Listener() {
        public void handleEvent(Event event) {
            ImportCSIFilesAction action = new ImportCSIFilesAction();
            action.run(null);
        }
    });

    _searchKeyLink = new Link(main, SWT.NONE);
    _searchKeyLink.setText(Messages.CodeSigningPrefsPage_AddOldKeyLabel);
    _searchKeyLink.setToolTipText(Messages.CodeSigningPrefsPage_AddOldKeyToolTip);

    _removeKeyLink = new Link(main, SWT.NONE);
    _removeKeyLink.setText(Messages.CodeSigningPrefsPage_RemoveCurrentKeyLabel);
    _removeKeyLink.setToolTipText(Messages.CodeSigningPrefsPage_RemoveCurrentKeyToolTip);

    File cskFile;
    File dbFile;
    try {
        cskFile = new File(VMToolsUtils.getVMToolsFolderPath() + File.separator + IConstants.CSK_FILE_NAME);
        dbFile = new File(VMToolsUtils.getVMToolsFolderPath() + File.separator + IConstants.DB_FILE_NAME);
        if ((cskFile.exists()) && (dbFile.exists())) {
            _searchKeyLink.setEnabled(false);
            _removeKeyLink.setEnabled(true);
        } else {
            _searchKeyLink.setEnabled(true);
            _removeKeyLink.setEnabled(false);
        }
    } catch (IOException io) {
        _log.error(io.getMessage());
    }

    _searchKeyLink.addListener(SWT.Selection, new Listener() {
        public void handleEvent(Event event) {
            // Open file dialog to allow user select the parent folder of *.csk and *.db files
            SigningSearchDialog oldKeyDialog = new SigningSearchDialog(getShell());
            try {
                ArrayList<File> oldKeyFiles = oldKeyDialog.search();
                if (oldKeyFiles != null) {
                    oldKeyDialog.copyFileIntoSignToolDir(oldKeyFiles);
                    MessageDialog dialog = new MessageDialog(getShell(),
                            Messages.CodeSigningPrefsPage_MessageDialogTitle1, null,
                            Messages.CodeSigningPrefsPage_MessageDialogMsg1, MessageDialog.INFORMATION,
                            new String[] { IDialogConstants.OK_LABEL }, 0);
                    dialog.open();
                    _searchKeyLink.setEnabled(false);
                    _removeKeyLink.setEnabled(true);
                    _log.info(Messages.CodeSigningPrefsPage_MessageDialogMsg9);
                }
            } catch (IllegalArgumentException ex) {
                MessageDialog dialog = new MessageDialog(getShell(),
                        Messages.CodeSigningPrefsPage_MessageDialogTitle1, null, ex.getMessage(),
                        MessageDialog.WARNING, new String[] { IDialogConstants.OK_LABEL }, 0);
                dialog.open();
            }
        }
    });

    _removeKeyLink.addListener(SWT.Selection, new Listener() {
        public void handleEvent(Event event) {
            if (MessageDialog.openQuestion(getShell(), Messages.CodeSigningPrefsPage_MessageDialogTitle3,
                    Messages.CodeSigningPrefsPage_MessageDialogMsg4
                            + Messages.CodeSigningPrefsPage_MessageDialogMsg6)) {
                removeKeys();
            }
        }
    });

    GridData gridData = new GridData(GridData.FILL, GridData.CENTER, true, false);
    gridData.verticalIndent = 15;

    _runSignToolAutomatically = new Button(main, SWT.CHECK);
    _runSignToolAutomatically.setText(Messages.SignatureToolPrefsPage_AutomaticallySigningBtnMsg);
    _runSignToolAutomatically.setToolTipText(Messages.SignatureToolPrefsPage_AutomaticallySigningBtnTooltipMsg);
    _runSignToolAutomatically.setLayoutData(gridData);

    _runSignToolSilently = new Button(main, SWT.CHECK);
    _runSignToolSilently.setText(Messages.SignatureToolPrefsPage_SilentToolBtnMsg);
    _runSignToolSilently.setToolTipText(Messages.SignatureToolPrefsPage_SilentToolBtnTooltipMsg);
    _runSignToolSilently.setLayoutData(gridData);

    initValues();

    return parent;
}

From source file:net.rim.ejde.internal.ui.preferences.SignatureToolPrefsPage.java

License:Open Source License

private void removeKeys() {
    try {/*from ww  w  .  j  a va2 s  .c o  m*/
        File cskFile = new File(
                VMToolsUtils.getVMToolsFolderPath() + File.separator + IConstants.CSK_FILE_NAME);
        File dbFile = new File(VMToolsUtils.getVMToolsFolderPath() + File.separator + IConstants.DB_FILE_NAME);
        if ((!cskFile.exists()) && (!dbFile.exists())) {
            MessageDialog dialog = new MessageDialog(getShell(),
                    Messages.CodeSigningPrefsPage_MessageDialogTitle3, null,
                    Messages.CodeSigningPrefsPage_MessageDialogMsg3, MessageDialog.WARNING,
                    new String[] { IDialogConstants.OK_LABEL }, 0);
            dialog.open();
            return;
        }
        if (cskFile.exists()) {
            cskFile.renameTo(new File(VMToolsUtils.getVMToolsFolderPath() + File.separator
                    + IConstants.CSK_FILE_NAME + IConstants.UNDERSCORE_STRING + System.currentTimeMillis()));
        }
        if (dbFile.exists()) {
            dbFile.renameTo(new File(VMToolsUtils.getVMToolsFolderPath() + File.separator
                    + IConstants.DB_FILE_NAME + IConstants.UNDERSCORE_STRING + System.currentTimeMillis()));
        }
        if ((!cskFile.exists()) && (!dbFile.exists())) {
            MessageDialog dialog = new MessageDialog(getShell(),
                    Messages.CodeSigningPrefsPage_MessageDialogTitle3, null,
                    Messages.CodeSigningPrefsPage_MessageDialogMsg5
                            + Messages.CodeSigningPrefsPage_MessageDialogMsg6,
                    MessageDialog.INFORMATION, new String[] { IDialogConstants.OK_LABEL }, 0);
            dialog.open();
            _searchKeyLink.setEnabled(true);
            _removeKeyLink.setEnabled(false);
            _log.info(Messages.CodeSigningPrefsPage_MessageDialogMsg7);
        }
    } catch (IOException e) {
        _log.error(e.getMessage());
    }
}