Example usage for com.intellij.openapi.ui Messages getQuestionIcon

List of usage examples for com.intellij.openapi.ui Messages getQuestionIcon

Introduction

In this page you can find the example usage for com.intellij.openapi.ui Messages getQuestionIcon.

Prototype

@NotNull
    public static Icon getQuestionIcon() 

Source Link

Usage

From source file:com.magnet.plugin.r2m.ui.AddControllerForm.java

License:Open Source License

private void showCloseDialog(File file) {
    String path = file.getAbsolutePath();
    String folder = path.substring(0, path.lastIndexOf(File.separator));
    String className = path.substring(path.lastIndexOf(File.separator) + 1);
    int option = Messages.showOkCancelDialog(
            R2MMessages.getMessage("SOURCE_AVAILABLE_CONTINUE_EDITING_QUESTION", className, folder),
            R2MMessages.getMessage("SUCCESS"), R2MMessages.getMessage("CLOSE_AND_SHOW_CODE_BUTTON_TEXT"),
            R2MMessages.getMessage("CONTINUE_EDITING_BUTTON_TEXT"), Messages.getQuestionIcon());
    if (option != 0) {
        getThis().setVisible(true);/*  www . j av a  2  s .c o  m*/
    } else {
        dispose();
    }
}

From source file:com.magnet.plugin.r2m.ui.chooser.ExampleChooserHelper.java

License:Open Source License

public static String showExamplesDialog() {

    EXAMPLES_DIALOG_UP = true;/*from w w  w. j ava  2s .c  om*/
    try {
        List<String> examples = getManifest().getExamplesList();
        String response = Messages.showEditableChooseDialog(R2MMessages.getMessage("CHOOSE_EXAMPLE_LABEL"),
                R2MMessages.getMessage("CHOOSE_EXAMPLE_TITLE"), Messages.getQuestionIcon(),
                examples.toArray(new String[examples.size()]),
                R2MMessages.getMessage("CHOOSE_EXAMPLE_DEFAULT_VALUE"), null);
        return response == null ? null : response.split(ExamplesManifest.DESCRIPTION_SEPARATOR_KEY)[0];
    } finally {
        EXAMPLES_DIALOG_UP = false;
    }
}

From source file:com.magnet.plugin.ui.chooser.ExampleChooserHelper.java

License:Open Source License

public static String showExamplesDialog() {

    EXAMPLES_DIALOG_UP = true;//from  ww  w  . jav  a 2  s  . com
    try {
        List<String> examples = getManifest().getExamplesList();
        String response = Messages.showEditableChooseDialog(
                Rest2MobileMessages.getMessage(Rest2MobileMessages.CHOOSE_EXAMPLE_LABEL),
                Rest2MobileMessages.getMessage(Rest2MobileMessages.CHOOSE_EXAMPLE_TITLE),
                Messages.getQuestionIcon(), examples.toArray(new String[examples.size()]),
                Rest2MobileMessages.getMessage(Rest2MobileMessages.CHOOSE_EXAMPLE_DEFAULT_VALUE), null);
        return response == null ? null : response.split(ExamplesManifest.DESCRIPTION_SEPARATOR_KEY)[0];
    } finally {
        EXAMPLES_DIALOG_UP = false;
    }
}

From source file:com.mbeddr.pluginmanager.com.intellij.ide.plugins.InstalledPluginsTableModel.java

License:Apache License

private void warnAboutMissedDependencies(final Boolean newVal,
        final IdeaPluginDescriptor... ideaPluginDescriptors) {
    final Set<PluginId> deps = new HashSet<PluginId>();
    final List<IdeaPluginDescriptor> descriptorsToCheckDependencies = new ArrayList<IdeaPluginDescriptor>();
    if (newVal) {
        Collections.addAll(descriptorsToCheckDependencies, ideaPluginDescriptors);
    } else {/*ww w. j a  v a  2  s.c o m*/
        descriptorsToCheckDependencies.addAll(getAllPlugins());
        descriptorsToCheckDependencies.removeAll(Arrays.asList(ideaPluginDescriptors));

        for (Iterator<IdeaPluginDescriptor> iterator = descriptorsToCheckDependencies.iterator(); iterator
                .hasNext();) {
            IdeaPluginDescriptor descriptor = iterator.next();
            final Boolean enabled = myEnabled.get(descriptor.getPluginId());
            if (enabled == null || !enabled.booleanValue()) {
                iterator.remove();
            }
        }
    }

    for (final IdeaPluginDescriptor ideaPluginDescriptor : descriptorsToCheckDependencies) {
        PluginManagerCore.checkDependants(ideaPluginDescriptor, new Function<PluginId, IdeaPluginDescriptor>() {
            @Override
            @Nullable
            public IdeaPluginDescriptor fun(final PluginId pluginId) {
                return PluginManager.getPlugin(pluginId);
            }
        }, new Condition<PluginId>() {
            @Override
            public boolean value(final PluginId pluginId) {
                Boolean enabled = myEnabled.get(pluginId);
                if (enabled == null) {
                    return false;
                }
                if (newVal && !enabled.booleanValue()) {
                    deps.add(pluginId);
                }

                if (!newVal) {
                    if (ideaPluginDescriptor instanceof IdeaPluginDescriptorImpl
                            && ((IdeaPluginDescriptorImpl) ideaPluginDescriptor).isDeleted()) {
                        return true;
                    }
                    final PluginId pluginDescriptorId = ideaPluginDescriptor.getPluginId();
                    for (IdeaPluginDescriptor descriptor : ideaPluginDescriptors) {
                        if (pluginId.equals(descriptor.getPluginId())) {
                            deps.add(pluginDescriptorId);
                            break;
                        }
                    }
                }
                return true;
            }
        });
    }
    if (!deps.isEmpty()) {
        final String listOfSelectedPlugins = StringUtil.join(ideaPluginDescriptors,
                new Function<IdeaPluginDescriptor, String>() {
                    @Override
                    public String fun(IdeaPluginDescriptor pluginDescriptor) {
                        return pluginDescriptor.getName();
                    }
                }, ", ");
        final Set<IdeaPluginDescriptor> pluginDependencies = new HashSet<IdeaPluginDescriptor>();
        final String listOfDependencies = StringUtil.join(deps, new Function<PluginId, String>() {
            @Override
            public String fun(final PluginId pluginId) {
                final IdeaPluginDescriptor pluginDescriptor = PluginManager.getPlugin(pluginId);
                assert pluginDescriptor != null;
                pluginDependencies.add(pluginDescriptor);
                return pluginDescriptor.getName();
            }
        }, "<br>");
        final String message = !newVal
                ? "<html>The following plugins <br>" + listOfDependencies + "<br>are enabled and depend"
                        + (deps.size() == 1 ? "s" : "") + " on selected plugins. "
                        + "<br>Would you like to disable them too?</html>"
                : "<html>The following plugins on which " + listOfSelectedPlugins + " depend"
                        + (ideaPluginDescriptors.length == 1 ? "s" : "") + " are disabled:<br>"
                        + listOfDependencies + "<br>Would you like to enable them?</html>";
        if (Messages.showOkCancelDialog(message,
                newVal ? "Enable Dependant Plugins" : "Disable Plugins with Dependency on this",
                Messages.getQuestionIcon()) == Messages.OK) {
            for (PluginId pluginId : deps) {
                myEnabled.put(pluginId, newVal);
            }

            updatePluginDependencies();
            hideNotApplicablePlugins(newVal,
                    pluginDependencies.toArray(new IdeaPluginDescriptor[pluginDependencies.size()]));
        }
    }
}

From source file:com.mbeddr.pluginmanager.com.intellij.ide.plugins.InstallPluginAction.java

License:Apache License

private static boolean suggestToEnableInstalledPlugins(InstalledPluginsTableModel pluginsModel,
        Set<IdeaPluginDescriptor> disabled, Set<IdeaPluginDescriptor> disabledDependants,
        List<PluginNode> list) {
    if (!disabled.isEmpty() || !disabledDependants.isEmpty()) {
        String message = "";
        if (disabled.size() == 1) {
            message += "Updated plugin '" + disabled.iterator().next().getName() + "' is disabled.";
        } else if (!disabled.isEmpty()) {
            message += "Updated plugins "
                    + StringUtil.join(disabled, new Function<IdeaPluginDescriptor, String>() {
                        @Override
                        public String fun(IdeaPluginDescriptor pluginDescriptor) {
                            return pluginDescriptor.getName();
                        }/*from   ww w . jav a2s  . c o  m*/
                    }, ", ") + " are disabled.";
        }

        if (!disabledDependants.isEmpty()) {
            message += "<br>";
            message += "Updated plugin" + (list.size() > 1 ? "s depend " : " depends ") + "on disabled";
            if (disabledDependants.size() == 1) {
                message += " plugin '" + disabledDependants.iterator().next().getName() + "'.";
            } else {
                message += " plugins "
                        + StringUtil.join(disabledDependants, new Function<IdeaPluginDescriptor, String>() {
                            @Override
                            public String fun(IdeaPluginDescriptor pluginDescriptor) {
                                return pluginDescriptor.getName();
                            }
                        }, ", ") + ".";
            }
        }
        message += " Disabled plugins " + (disabled.isEmpty() ? "and plugins which depend on disabled " : "")
                + "won't be activated after restart.";

        int result;
        if (!disabled.isEmpty() && !disabledDependants.isEmpty()) {
            result = Messages.showYesNoCancelDialog(XmlStringUtil.wrapInHtml(message),
                    CommonBundle.getWarningTitle(), "Enable all",
                    "Enable updated plugin" + (disabled.size() > 1 ? "s" : ""),
                    CommonBundle.getCancelButtonText(), Messages.getQuestionIcon());
            if (result == Messages.CANCEL)
                return false;
        } else {
            message += "<br>Would you like to enable ";
            if (!disabled.isEmpty()) {
                message += "updated plugin" + (disabled.size() > 1 ? "s" : "");
            } else {
                //noinspection SpellCheckingInspection
                message += "plugin dependenc" + (disabledDependants.size() > 1 ? "ies" : "y");
            }
            message += "?";
            result = Messages.showYesNoDialog(XmlStringUtil.wrapInHtml(message), CommonBundle.getWarningTitle(),
                    Messages.getQuestionIcon());
            if (result == Messages.NO)
                return false;
        }

        if (result == Messages.YES) {
            disabled.addAll(disabledDependants);
            pluginsModel.enableRows(disabled.toArray(new IdeaPluginDescriptor[disabled.size()]), true);
        } else if (result == Messages.NO && !disabled.isEmpty()) {
            pluginsModel.enableRows(disabled.toArray(new IdeaPluginDescriptor[disabled.size()]), true);
        }
        return true;
    }
    return false;
}

From source file:com.mbeddr.pluginmanager.com.intellij.ide.plugins.InstallPluginAction.java

License:Apache License

private boolean userConfirm(IdeaPluginDescriptor[] selection) {
    String message;/*ww w .j  a  va 2 s .com*/
    if (selection.length == 1) {
        if (selection[0] instanceof IdeaPluginDescriptorImpl) {
            message = IdeBundle.message("prompt.update.plugin", selection[0].getName());
        } else {
            message = IdeBundle.message("prompt.download.and.install.plugin", selection[0].getName());
        }
    } else {
        message = IdeBundle.message("prompt.install.several.plugins", selection.length);
    }

    return Messages.showYesNoDialog(myHost.getMainPanel(), message,
            IdeBundle.message("action.download.and.install.plugin"),
            Messages.getQuestionIcon()) == Messages.YES;
}

From source file:com.mbeddr.pluginmanager.com.intellij.ide.plugins.PluginManagerConfigurable_mbeddr.java

License:Apache License

@Messages.YesNoResult
public static int showRestartDialog(@NotNull String title) {
    String action = IdeBundle/*  www  .ja va2s.  co m*/
            .message(ApplicationManagerEx.getApplicationEx().isRestartCapable() ? "ide.restart.action"
                    : "ide.shutdown.action");
    String message = IdeBundle.message("ide.restart.required.message", action,
            ApplicationNamesInfo.getInstance().getFullProductName());
    return Messages.showYesNoDialog(message, title, action, IdeBundle.message("ide.postpone.action"),
            Messages.getQuestionIcon());
}

From source file:com.mbeddr.pluginmanager.com.intellij.ide.plugins.UninstallPluginAction.java

License:Apache License

public static void uninstall(PluginManagerMain host, boolean confirmed, IdeaPluginDescriptor... selection) {
    String message;//from  w  w w .  j a  va2s  .  c  o m

    if (selection.length == 1) {
        message = IdeBundle.message("prompt.uninstall.plugin", selection[0].getName());
    } else {
        message = IdeBundle.message("prompt.uninstall.several.plugins", selection.length);
    }

    if (!confirmed && Messages.showYesNoDialog(host.getMainPanel(), message,
            IdeBundle.message("title.plugin.uninstall"), Messages.getQuestionIcon()) != Messages.YES)
        return;

    for (IdeaPluginDescriptor descriptor : selection) {
        IdeaPluginDescriptorImpl pluginDescriptor = (IdeaPluginDescriptorImpl) descriptor;

        boolean actualDelete = true;

        //  Get the list of plugins which depend on this one. If this list is
        //  not empty - issue warning instead of simple prompt.
        List<IdeaPluginDescriptorImpl> dependant = host.getDependentList(pluginDescriptor);
        if (dependant.size() > 0) {
            message = IdeBundle.message("several.plugins.depend.on.0.continue.to.remove",
                    pluginDescriptor.getName());
            actualDelete = (Messages.showYesNoDialog(host.getMainPanel(), message,
                    IdeBundle.message("title.plugin.uninstall"), Messages.getQuestionIcon()) == Messages.YES);
        }

        if (actualDelete) {
            uninstallPlugin(pluginDescriptor, host);
        }
    }
}

From source file:com.mediaworx.intellij.opencmsplugin.listeners.OpenCmsModuleFileChangeListener.java

License:Open Source License

/**
 * Presents a dialog asking the user if files are to be deleted from the VFS and handles the deletions if the user
 * chooses to do so/*from  ww w  .j  av  a 2s . c o m*/
 * @return  <code>true</code> if the user elected to delete files, <code>false</code> if the user cancelled the
 *          deletion
 * @throws CmsConnectionException if the connection to OpenCms failed
 */
private boolean deleteFiles() throws CmsConnectionException {
    StringBuilder msg = new StringBuilder(
            "Do you want to delete the following files/folders from the OpenCms VFS?");
    for (VfsFileDeleteInfo vfsFileToBeDeleted : vfsFilesToBeDeleted) {
        msg.append("\n").append(vfsFileToBeDeleted.vfsPath);
    }

    int dlgStatus = Messages.showOkCancelDialog(msg.toString(), "Delete Files/Folders?",
            Messages.getQuestionIcon());

    if (dlgStatus == 0) {
        console.clear();
        plugin.showConsole();
        for (VfsFileDeleteInfo deleteInfo : vfsFilesToBeDeleted) {
            console.info("DELETE: " + deleteInfo.vfsPath);
            getVfsAdapter().deleteResource(deleteInfo.vfsPath);
            // check export points
            deleteExportedFileIfNecessary(deleteInfo.vfsPath);

            // handle meta data files
            boolean isDirectory = deleteInfo.isDirectory;
            String metaDataFilePath = getMetaDataFilePath(deleteInfo.ocmsModule, deleteInfo.vfsPath,
                    isDirectory);
            console.info("Remove meta data file " + metaDataFilePath);
            File metaDataFile = new File(metaDataFilePath);
            FileUtils.deleteQuietly(metaDataFile);
            refreshFiles.add(metaDataFile);

            if (isDirectory) {
                String metaFolderPath = getMetaDataFilePathWithoutSuffix(deleteInfo.ocmsModule,
                        deleteInfo.vfsPath);
                console.info("Remove meta data folder " + metaFolderPath);
                File metaFolder = new File(metaFolderPath);
                FileUtils.deleteQuietly(metaFolder);
                refreshFiles.add(metaFolder);
            }
        }
        return true;
    }
    return false;
}

From source file:com.mediaworx.intellij.opencmsplugin.listeners.OpenCmsModuleFileChangeListener.java

License:Open Source License

/**
 * Presents a dialog asking the user if files are to be moved in the VFS and handles the moves if the user
 * chooses to do so//  w  ww  .jav  a  2  s .  co  m
 * @return  <code>true</code> if the user elected to move files, <code>false</code> if the user cancelled the
 *          move
 * @throws CmsConnectionException if the connection to OpenCms failed
 */
private boolean moveFiles() throws CmsConnectionException {
    StringBuilder msg = new StringBuilder(
            "Do you want to move the following files/folders in the OpenCms VFS as well?");
    for (VfsFileMoveInfo vfsFileToBeMoved : vfsFilesToBeMoved) {
        msg.append("\n").append(vfsFileToBeMoved.oldVfsPath);
    }

    int dlgStatus = Messages.showOkCancelDialog(msg.toString(), "Move Files/Folders?",
            Messages.getQuestionIcon());

    if (dlgStatus == 0) {
        console.clear();
        plugin.showConsole();
        for (VfsFileMoveInfo moveInfo : vfsFilesToBeMoved) {
            try {
                console.info("MOVE: " + moveInfo.oldVfsPath + " to " + moveInfo.newParentPath);
                Folder oldParent = (Folder) getVfsAdapter().getVfsObject(moveInfo.oldParentPath);
                Folder newParent = (Folder) getVfsAdapter().getVfsObject(moveInfo.newParentPath);
                if (newParent == null) {
                    newParent = getVfsAdapter().createFolder(moveInfo.newParentPath);
                }
                FileableCmisObject resource = (FileableCmisObject) getVfsAdapter()
                        .getVfsObject(moveInfo.oldVfsPath);
                resource.move(oldParent, newParent);

                // handle export points
                handleExportPointsForMovedResources(moveInfo.oldVfsPath, moveInfo.newVfsPath,
                        moveInfo.newIdeaVFile.getPath());

                // handle meta data files
                handleMetaDataForMovedResources(moveInfo.oldOcmsModule, moveInfo.newOcmsModule,
                        moveInfo.oldVfsPath, moveInfo.newVfsPath, moveInfo.newIdeaVFile.isDirectory());
            } catch (CmsPermissionDeniedException e) {
                Messages.showDialog("Error moving files/folders." + e.getMessage(), "Error",
                        new String[] { "Ok" }, 0, Messages.getErrorIcon());
            }
        }
        return true;
    }
    return false;
}