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:com.softlanding.rse.extensions.compare.MergeDialog.java

License:Open Source License

protected void okPressed() {
    if (ExtensionsPlugin.getDefault().getPreferenceStore()
            .getBoolean(ExtensionsPlugin.PREFERENCE_COMPARE_MERGE_WARNING)) {
        WarningDialog dialog = new WarningDialog(getShell(),
                ExtensionsPlugin.getResourceString("MergeDialog.16"), null, //$NON-NLS-1$
                ExtensionsPlugin.getResourceString("MergeDialog.17"), MessageDialog.WARNING, //$NON-NLS-1$
                new String[] { ExtensionsPlugin.getResourceString("MergeDialog.18"), //$NON-NLS-1$
                        ExtensionsPlugin.getResourceString("MergeDialog.19") }, //$NON-NLS-1$
                0);/*from  ww  w.ja  va2  s.  c  o m*/
        if (dialog.open() == WarningDialog.CANCEL) {
            super.cancelPressed();
            return;
        }
    }
    maintenanceConnection = IBMiConnection.getConnection(maintenanceConnectionCombo.getHost());
    rootConnection = IBMiConnection.getConnection(rootConnectionCombo.getHost());
    maintenanceLibrary = maintenanceMemberPrompt.getLibraryName();
    maintenanceFile = maintenanceMemberPrompt.getFileName();
    maintenanceMember = maintenanceMemberPrompt.getMemberName();
    rootLibrary = rootMemberPrompt.getLibraryName();
    rootFile = rootMemberPrompt.getFileName();
    rootMember = rootMemberPrompt.getMemberName();
    super.okPressed();
}

From source file:com.wakatime.eclipse.plugin.WakaTime.java

@Override
public void earlyStartup() {
    final IWorkbench workbench = PlatformUI.getWorkbench();

    // listen for save file events
    ICommandService commandService = (ICommandService) workbench.getService(ICommandService.class);
    executionListener = new CustomExecutionListener();
    commandService.addExecutionListener(executionListener);

    workbench.getDisplay().asyncExec(new Runnable() {
        public void run() {
            IWorkbenchWindow window = workbench.getActiveWorkbenchWindow();
            if (window == null)
                return;

            // prompt for apiKey if not set
            MenuHandler handler = new MenuHandler();
            DEBUG = handler.getDebug();// www .ja  v  a  2 s  .c om
            String apiKey = handler.getApiKey();
            if (apiKey == "") {
                handler.promptForApiKey(window);
            }

            Dependencies deps = new Dependencies();

            if (!deps.isPythonInstalled()) {
                deps.installPython();
                if (!deps.isPythonInstalled()) {
                    MessageDialog dialog = new MessageDialog(window.getShell(), "Warning!", null,
                            "WakaTime needs Python installed. Please install Python from python.org/downloads, then restart Eclipse.",
                            MessageDialog.WARNING, new String[] { IDialogConstants.OK_LABEL }, 0);
                    dialog.open();
                }
            }
            if (!deps.isCLIInstalled()) {
                deps.installCLI();
            }

            if (window.getPartService() == null)
                return;

            // listen for caret movement
            if (window.getPartService().getActivePartReference() != null
                    && window.getPartService().getActivePartReference().getPage() != null
                    && window.getPartService().getActivePartReference().getPage().getActiveEditor() != null) {
                IEditorPart part = window.getPartService().getActivePartReference().getPage().getActiveEditor();
                if (!(part instanceof AbstractTextEditor))
                    return;
                ((StyledText) part.getAdapter(Control.class)).addCaretListener(new CustomCaretListener());
            }

            // listen for change of active file
            window.getPartService().addPartListener(editorListener);

            if (window.getPartService().getActivePart() == null)
                return;
            if (window.getPartService().getActivePart().getSite() == null)
                return;
            if (window.getPartService().getActivePart().getSite().getPage() == null)
                return;
            if (window.getPartService().getActivePart().getSite().getPage().getActiveEditor() == null)
                return;
            if (window.getPartService().getActivePart().getSite().getPage().getActiveEditor()
                    .getEditorInput() == null)
                return;

            // log file if one is opened by default
            IEditorInput input = window.getPartService().getActivePart().getSite().getPage().getActiveEditor()
                    .getEditorInput();
            if (input instanceof IURIEditorInput) {
                URI uri = ((IURIEditorInput) input).getURI();
                if (uri != null && uri.getPath() != null) {
                    String currentFile = uri.getPath();
                    long currentTime = System.currentTimeMillis() / 1000;
                    if (!currentFile.equals(WakaTime.getDefault().lastFile)
                            || WakaTime.getDefault().lastTime + WakaTime.FREQUENCY * 60 < currentTime) {
                        WakaTime.logFile(currentFile, WakaTime.getActiveProject(), false);
                        WakaTime.getDefault().lastFile = currentFile;
                        WakaTime.getDefault().lastTime = currentTime;
                    }
                }
            }

            WakaTime.log("Finished initializing WakaTime plugin (https://wakatime.com) v" + VERSION);
        }
    });
}

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

License:Open Source License

/**
 * Convenience method to open a standard warning dialog.
 *
 * @param title//from w  w w .ja va2s .  c o  m
 *            the dialog's title, or <code>null</code> if none
 * @param message
 *            the message
 */
public static void openWarning(final String title, final String message) {
    Display.getDefault().syncExec(new Runnable() {
        @Override
        public void run() {
            MessageDialog.open(MessageDialog.WARNING, 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  ava2s .co 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);
            }
        });
    }
}

From source file:cu.uci.abos.core.util.MessageDialogUtil.java

License:Open Source License

public static void openWarning(Shell parent, String title, String message, DialogCallback callback) {
    open(MessageDialog.WARNING, parent, title, message, callback);
}

From source file:cu.uci.abos.core.util.MessageDialogUtil.java

License:Open Source License

private static String[] getButtonLabels(int kind) {
    String[] dialogButtonLabels;//from   www.  ja  v a  2 s  .  c  o m
    switch (kind) {
    case MessageDialog.ERROR:
    case MessageDialog.INFORMATION:
    case MessageDialog.WARNING: {
        dialogButtonLabels = new String[] { AbosMessages.get().BUTTON_CLOSE };
        break;
    }
    case MessageDialog.CONFIRM: {
        dialogButtonLabels = new String[] { AbosMessages.get().BUTTON_ACCEPT,
                AbosMessages.get().BUTTON_CANCEL };
        break;
    }
    case MessageDialog.QUESTION: {
        dialogButtonLabels = new String[] { AbosMessages.get().BUTTON_ACCEPT,
                AbosMessages.get().BUTTON_CANCEL };
        break;
    }
    case MessageDialog.QUESTION_WITH_CANCEL: {
        dialogButtonLabels = new String[] { AbosMessages.get().BUTTON_ACCEPT, AbosMessages.get().BUTTON_CANCEL,
                AbosMessages.get().BUTTON_CLOSE };
        break;
    }
    default: {
        throw new IllegalArgumentException("Illegal value for kind in MessageDialog.open()");
    }
    }
    return dialogButtonLabels;
}

From source file:de.anbos.eclipse.easyshell.plugin.preferences.CommandPage.java

License:Open Source License

@Override
public boolean performOk() {
    boolean save = true;
    if (!CommandDataStore.instance().isMigrated()) {
        String title = Activator.getResourceString("easyshell.command.page.dialog.migration.title");
        String question = Activator.getResourceString("easyshell.command.page.dialog.migration.question");
        MessageDialog dialog = new MessageDialog(null, title, null, question, MessageDialog.WARNING,
                new String[] { "Yes", "No" }, 1); // no is the default
        int result = dialog.open();
        if (result == 0) {
            CommandDataStore.instance().setMigrated(true);
        } else {/*from  w w w.j  a  va2s.co m*/
            save = false;
        }
    }
    if (save) {
        CommandDataStore.instance().save();
        MenuDataStore.instance().save();
    }
    return save;
}

From source file:de.anbos.eclipse.easyshell.plugin.preferences.CommandPage.java

License:Open Source License

@Override
protected void performDefaults() {
    // get the selected commands and referenced menus as lists
    CommandDataList commands = new CommandDataList(CommandDataStore.instance().getDataList());
    List<MenuData> menus = new ArrayList<MenuData>();
    for (CommandData command : commands) {
        if (command.getPresetType() == PresetType.presetUser) {
            List<MenuData> menusForOne = MenuDataStore.instance().getRefencedBy(command.getId());
            menus.addAll(menusForOne);//  www .ja  v  a  2s  . com
        }
    }
    String title = Activator.getResourceString("easyshell.command.page.dialog.defaults.title");
    String question = Activator.getResourceString("easyshell.command.page.dialog.defaults.question");
    int dialogImageType = MessageDialog.QUESTION;
    if (menus.size() >= 0) {
        dialogImageType = MessageDialog.WARNING;
        String menuNames = "";
        for (MenuData menu : menus) {
            menuNames += menu.getNameExpanded() + "\n";
        }
        question = MessageFormat.format(
                Activator.getResourceString("easyshell.command.page.dialog.defaults.menu.question"), menuNames);
    }
    MessageDialog dialog = new MessageDialog(null, title, null, question, dialogImageType,
            new String[] { "Yes", "No" }, 1); // no is the default
    int result = dialog.open();
    if (result == 0) {
        if (menus.size() >= 0) {
            for (MenuData menu : menus) {
                MenuDataStore.instance().delete(menu);
            }
            //MenuDataStore.instance().save();
        }
        CommandDataStore.instance().loadDefaults();
        tableViewer.refresh();
    }
}

From source file:de.anbos.eclipse.easyshell.plugin.preferences.CommandPage.java

License:Open Source License

private void removeDialog() {
    // get the selected commands and referenced menus as lists
    List<CommandData> commands = new ArrayList<CommandData>();
    List<MenuData> menus = new ArrayList<MenuData>();
    IStructuredSelection selection = (IStructuredSelection) tableViewer.getSelection();
    Iterator<?> elements = selection.iterator();
    while (elements.hasNext()) {
        CommandData data = (CommandData) elements.next();
        commands.add(data);/*w  w w . j a va 2 s  . c o  m*/
        List<MenuData> menusForOne = MenuDataStore.instance().getRefencedBy(data.getId());
        menus.addAll(menusForOne);
    }
    // ask user
    String commandNames = "";
    PresetType type = PresetType.presetUnknown;
    for (CommandData command : commands) {
        if (type == PresetType.presetUnknown) {
            type = command.getPresetType();
        }
        commandNames += command.getCommandAsComboName() + "\n";
    }
    String title = null;
    String question = null;
    if (type == PresetType.presetPluginAndUser) {
        title = Activator.getResourceString("easyshell.command.page.dialog.remove.user.title");
        question = MessageFormat.format(
                Activator.getResourceString("easyshell.command.page.dialog.remove.user.question"),
                commandNames);
    } else {
        title = Activator.getResourceString("easyshell.command.page.dialog.remove.title");
        question = MessageFormat.format(
                Activator.getResourceString("easyshell.command.page.dialog.remove.question"), commandNames);
    }
    int dialogImageType = MessageDialog.QUESTION;
    if (menus.size() > 0) {
        dialogImageType = MessageDialog.WARNING;
        String menuNames = "";
        for (MenuData menu : menus) {
            menuNames += menu.getNameExpanded() + "\n";
        }
        if (type == PresetType.presetPluginAndUser) {
            title = Activator.getResourceString("easyshell.command.page.dialog.remove.menu.user.title");
            question = MessageFormat.format(
                    Activator.getResourceString("easyshell.command.page.dialog.remove.menu.user.question"),
                    commandNames, menuNames);
        } else {
            title = Activator.getResourceString("easyshell.command.page.dialog.remove.menu.title");
            question = MessageFormat.format(
                    Activator.getResourceString("easyshell.command.page.dialog.remove.menu.question"),
                    commandNames, menuNames);
        }
    }
    MessageDialog dialog = new MessageDialog(null, title, null, question, dialogImageType,
            new String[] { "Yes", "No" }, 1); // no is the default
    int result = dialog.open();
    if (result == 0) {
        if (menus.size() >= 0 && type == PresetType.presetUser) {
            for (MenuData menu : menus) {
                MenuDataStore.instance().delete(menu);
            }
            //MenuDataStore.instance().save();
        }
        for (CommandData command : commands) {
            if (command.getPresetType() == PresetType.presetUser) {
                CommandDataStore.instance().delete(command);
            } else if (command.getPresetType() == PresetType.presetPluginAndUser) {
                command.removeUserData();
                CommandDataStore.instance().replace(command);
            }
        }
        tableViewer.refresh();
    }
}

From source file:de.anbos.eclipse.easyshell.plugin.preferences.MenuDataDialog.java

License:Open Source License

private void removeDialog() {
    // get the selected commands and referenced menus as lists
    List<CommandData> commands = new ArrayList<CommandData>();
    List<MenuData> menus = new ArrayList<MenuData>();
    // get the selected
    int index = commandCombo.getSelectionIndex();
    CommandData data = cmdList.get(index);
    commands.add(data);//from   w  w w.  j  ava 2 s.co  m
    // get referenced menus and remove the the actual menus
    menus.addAll(MenuDataStore.instance().getRefencedBy(data.getId()));
    menus.remove(this.menuData);
    // ask user
    String commandNames = commandCombo.getItem(index);
    String title = null;
    String question = null;
    if (data.getPresetType() == PresetType.presetPluginAndUser) {
        title = Activator.getResourceString("easyshell.menu.editor.dialog.title.user.remove");
        question = MessageFormat.format(
                Activator.getResourceString("easyshell.menu.editor.dialog.question.user.remove"), commandNames);
    } else {
        title = Activator.getResourceString("easyshell.menu.editor.dialog.title.remove");
        question = MessageFormat.format(
                Activator.getResourceString("easyshell.menu.editor.dialog.question.remove"), commandNames);
    }
    int dialogImageType = MessageDialog.QUESTION;
    if (menus.size() > 0) {
        dialogImageType = MessageDialog.WARNING;
        String menuNames = "";
        for (MenuData menu : menus) {
            menuNames += menu.getNameExpanded() + "\n";
        }
        if (data.getPresetType() == PresetType.presetPluginAndUser) {
            title = Activator.getResourceString("easyshell.menu.editor.dialog.title.remove.user.menu");
            question = MessageFormat.format(
                    Activator.getResourceString("easyshell.menu.editor.dialog.question.remove.user.menu"),
                    commandNames, menuNames);
        } else {
            title = Activator.getResourceString("easyshell.menu.editor.dialog.title.remove.menu");
            question = MessageFormat.format(
                    Activator.getResourceString("easyshell.menu.editor.dialog.question.remove.menu"),
                    commandNames, menuNames);
        }
    }
    MessageDialog dialog = new MessageDialog(null, title, null, question, dialogImageType,
            new String[] { "Yes", "No" }, 1); // no is the default
    int result = dialog.open();
    if (result == 0) {
        for (MenuData menu : menus) {
            MenuDataStore.instance().delete(menu);
        }
        removeCommand(index, data);
        refreshCommandCombo();
    }
}