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

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

Introduction

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

Prototype

int WARNING

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

Click Source Link

Document

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

Usage

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

License:Open Source License

private void removeKeys() {
    try {/* w  w w.java2s.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.
 */// w  w  w  .  jav  a 2 s .c  om
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;//from   w  w w.  j ava  2 s  .c  om
    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 {// w  ww.  j  av  a  2s .c  om
        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());
    }
}

From source file:net.rim.ejde.internal.util.FileUtils.java

License:Open Source License

public static IStatus canChange(final java.io.File osFile, final String dialogTitle, final String errorMessage,
        final boolean showResourcePath, final String questionMessage) {
    IStatus result = Status.CANCEL_STATUS;

    if ((osFile != null) && (osFile.exists())) {
        if (osFile.canWrite()) {
            result = Status.OK_STATUS;//from   w  ww  .  j a  v a2  s  .com
        } else {
            // prompt for making resource writable
            Display.getDefault().syncExec(new Runnable() {
                public void run() {
                    StringBuffer buffer = new StringBuffer();
                    buffer.append(errorMessage);
                    if (showResourcePath) {
                        buffer.append(osFile.getAbsolutePath());
                    }
                    buffer.append(questionMessage);
                    String[] buttons = new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL };
                    Shell shell = new Shell();
                    MessageDialog promptSaveDia = new MessageDialog(shell, dialogTitle, null, buffer.toString(),
                            MessageDialog.WARNING, buttons, 0);
                    int ret = promptSaveDia.open();
                    shell.dispose();
                    if (ret == Window.OK) {
                        // make this resource writable
                        setWritable(osFile);
                    }
                }
            });

            if (osFile.canWrite()) {
                result = Status.OK_STATUS;
            }
        }
    }

    return result;

}

From source file:net.sf.eclipsecs.ui.config.CheckConfigurationPropertiesDialog.java

License:Open Source License

/**
 * @see org.eclipse.jface.dialogs.Dialog#okPressed()
 *//*w ww.  jav  a  2  s.c  o  m*/
protected void okPressed() {
    try {
        // Check if the configuration is valid
        mCheckConfig = mConfigurationEditor.getEditedWorkingCopy();

        CheckConfigurationTester tester = new CheckConfigurationTester(mCheckConfig);
        List<ResolvableProperty> unresolvedProps = tester.getUnresolvedProperties();

        if (!unresolvedProps.isEmpty()) {

            MessageDialog dialog = new MessageDialog(getShell(),
                    Messages.CheckConfigurationPropertiesDialog_titleUnresolvedProps, null,
                    NLS.bind(Messages.CheckConfigurationPropertiesDialog_msgUnresolvedProps,
                            "" + unresolvedProps.size()), //$NON-NLS-1$
                    MessageDialog.WARNING, new String[] { Messages.CheckConfigurationPropertiesDialog_btnEditProps,
                            Messages.CheckConfigurationPropertiesDialog_btnContinue,
                            Messages.CheckConfigurationPropertiesDialog_btnCancel },
                    0);
            int result = dialog.open();

            if (0 == result) {
                ResolvablePropertiesDialog propsDialog = new ResolvablePropertiesDialog(getShell(),
                        mCheckConfig);
                propsDialog.open();
                return;
            } else if (1 == result) {
                super.okPressed();
            } else if (2 == result) {
                return;
            }
        } else {
            super.okPressed();
        }
    } catch (CheckstylePluginException e) {
        CheckstyleLog.log(e);
        this.setErrorMessage(e.getLocalizedMessage());
    }
}

From source file:net.sf.eclipsensis.installoptions.actions.INIFileDeleteControlAction.java

License:Open Source License

@Override
protected boolean doRun2(INIFile iniFile, INISection section) {
    boolean showOnShift = InstallOptionsPlugin.getDefault().getPreferenceStore()
            .getBoolean(IInstallOptionsConstants.PREFERENCE_DELETE_CONTROL_WARNING);
    if (!showOnShift || WinAPI.INSTANCE.getKeyState(WinAPI.VK_SHIFT) < 0) {
        MessageDialogWithToggle dialog = new MessageDialogWithToggle(
                PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), mEditor.getPartName(),
                InstallOptionsPlugin.getShellImage(),
                InstallOptionsPlugin.getFormattedString("delete.control.action.warning", //$NON-NLS-1$
                        new String[] { section.getName() }), MessageDialog.WARNING,
                new String[] { IDialogConstants.OK_LABEL, IDialogConstants.CANCEL_LABEL }, 0,
                InstallOptionsPlugin.getResourceString("delete.control.warning.toggle.label"), showOnShift); //$NON-NLS-1$
        dialog.open();/*  w w w.  j a va 2  s.co  m*/
        if (dialog.getReturnCode() == IDialogConstants.OK_ID) {
            InstallOptionsPlugin.getDefault().getPreferenceStore().setValue(
                    IInstallOptionsConstants.PREFERENCE_DELETE_CONTROL_WARNING, dialog.getToggleState());
        } else {
            return false;
        }
    }
    iniFile.removeChild(section);
    iniFile.update(INILine.VALIDATE_FIX_ERRORS);
    updateDocument(iniFile, section);
    return true;
}

From source file:net.sf.eclipsensis.settings.NSISPreferences.java

License:Open Source License

public void fileChanged(int type, File file) {
    if (file.equals(mNSISHome == null ? null : mNSISHome.getNSISExe().getFile())) {
        final String message;
        switch (type) {
        case FileMonitor.FILE_MODIFIED:
        case FileMonitor.FILE_CREATED:
            message = EclipseNSISPlugin.getResourceString("makensis.modified.message"); //$NON-NLS-1$
            break;
        case FileMonitor.FILE_DELETED:
            message = EclipseNSISPlugin.getResourceString("makensis.deleted.message"); //$NON-NLS-1$
            break;
        default:/*w ww . jav a2  s .com*/
            return;
        }
        final String nsisHome = mNSISHome.getLocation().getAbsolutePath();
        mNSISHome = null;
        final boolean silent = !mPreferenceStore.getBoolean(NOTIFY_MAKENSIS_CHANGED);
        if (silent) {
            setBestNSISHome(nsisHome);
            if (mListeners.size() > 0) {
                new NSISHomeChangedRunnable(null, mNSISHome).run(new NullProgressMonitor());
            }

            Display.getDefault().syncExec(new Runnable() {
                public void run() {
                    maybeConfigure();
                }
            });
        } else {
            Display.getDefault().asyncExec(new Runnable() {
                public void run() {
                    Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
                    MessageDialogWithToggle dialog = new MessageDialogWithToggle(shell,
                            EclipseNSISPlugin.getDefault().getName(), EclipseNSISPlugin.getShellImage(),
                            message, MessageDialog.WARNING, new String[] { IDialogConstants.OK_LABEL }, 0,
                            EclipseNSISPlugin.getResourceString("notify.makensis.changed.toggle"), silent); //$NON-NLS-1$
                    dialog.open();
                    mPreferenceStore.setValue(NOTIFY_MAKENSIS_CHANGED, !dialog.getToggleState());
                    BusyIndicator.showWhile(shell.getDisplay(), new Runnable() {
                        public void run() {
                            setBestNSISHome(nsisHome);
                            fireNSISHomeChanged(null, mNSISHome);
                        }
                    });
                    maybeConfigure();
                }
            });
        }
    }

}

From source file:net.sf.eclipsensis.settings.NSISSettingsEditorGeneralPage.java

License:Open Source License

/**
 * @param parent//from  ww  w  .  jav  a 2  s .c  om
 */
protected void createProcessPriorityCombo(Composite parent) {
    Label l;
    mProcessPriority = createCombo(parent, EclipseNSISPlugin.getResourceString("process.priority.text"), //$NON-NLS-1$
            EclipseNSISPlugin.getResourceString("process.priority.tooltip"), //$NON-NLS-1$
            INSISSettingsConstants.PROCESS_PRIORITY_ARRAY, mSettings.getProcessPriority() + 1);
    mProcessPriorityIndex = mProcessPriority.getSelectionIndex();
    l = new Label(parent, SWT.None);
    l.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false));
    mProcessPriority.setData(LABELS, new Object[] { mProcessPriority.getData(LABEL), l });
    mProcessPriority.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            if (isProcessPrioritySupported()) {
                if (isWarnProcessPriority()) {
                    if (mProcessPriority.getSelectionIndex() > INSISSettingsConstants.PROCESS_PRIORITY_HIGH
                            && mProcessPriorityIndex <= INSISSettingsConstants.PROCESS_PRIORITY_HIGH) {
                        MessageDialogWithToggle dialog = new MessageDialogWithToggle(
                                mProcessPriority.getShell(),
                                EclipseNSISPlugin.getResourceString("confirm.title"), //$NON-NLS-1$
                                EclipseNSISPlugin.getShellImage(),
                                EclipseNSISPlugin.getResourceString("process.priority.question"), //$NON-NLS-1$
                                MessageDialog.WARNING,
                                new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL }, 1,
                                EclipseNSISPlugin.getResourceString("process.priority.toggle"), //$NON-NLS-1$
                                false);
                        dialog.open();
                        setWarnProcessPriority(!dialog.getToggleState());
                        if (dialog.getReturnCode() == IDialogConstants.NO_ID) {
                            mProcessPriority.select(mProcessPriorityIndex);
                            return;
                        }
                    }
                }
            }
            mProcessPriorityIndex = mProcessPriority.getSelectionIndex();
        }
    });
}

From source file:net.sf.eclipsensis.util.Common.java

License:Open Source License

public static void openWarning(Shell parent, String title, String message, Image icon) {
    MessageDialog dialog = new MessageDialog(parent, title, icon, message, MessageDialog.WARNING,
            new String[] { IDialogConstants.OK_LABEL }, 0);
    dialog.open();/*w w w  .j a  v a 2  s  . c  om*/
}