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

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

Introduction

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

Prototype

public static void showWarningDialog(@NotNull Component component, String message,
            @NotNull @Nls(capitalization = Nls.Capitalization.Title) String title) 

Source Link

Usage

From source file:org.jetbrains.plugins.github.util.GithubNotifications.java

License:Apache License

public static void showWarningDialog(final @Nullable Project project, final @NotNull String title,
        final @NotNull String message) {
    LOG.info(title + "; " + message);
    Messages.showWarningDialog(project, message, title);
}

From source file:org.jetbrains.plugins.github.util.GithubNotifications.java

License:Apache License

public static void showWarningDialog(final @NotNull Component component, final @NotNull String title,
        final @NotNull String message) {
    LOG.info(title + "; " + message);
    Messages.showWarningDialog(component, message, title);
}

From source file:org.jetbrains.plugins.groovy.annotator.intentions.dynamic.ui.DynamicDialog.java

License:Apache License

protected void doOKAction() {
    super.doOKAction();

    mySettings.setContainingClassName((String) myClassComboBox.getSelectedItem());
    mySettings.setStatic(myStaticCheckBox.isSelected());
    GrTypeElement typeElement = getEnteredTypeName();

    if (typeElement == null) {
        mySettings.setType(CommonClassNames.JAVA_LANG_OBJECT);
    } else {/*w ww.  j  a  v  a  2  s . c om*/
        PsiType type = typeElement.getType();
        if (type instanceof PsiPrimitiveType) {
            type = TypesUtil.boxPrimitiveType(type, typeElement.getManager(),
                    ProjectScope.getAllScope(myProject));
        }

        final String typeQualifiedName = type.getCanonicalText();

        if (typeQualifiedName != null) {
            mySettings.setType(typeQualifiedName);
        } else {
            mySettings.setType(type.getPresentableText());
        }
    }

    final Document document = PsiDocumentManager.getInstance(myProject)
            .getDocument(myContext.getContainingFile());

    CommandProcessor.getInstance().executeCommand(myProject, new Runnable() {
        public void run() {
            UndoManager.getInstance(myProject).undoableActionPerformed(new GlobalUndoableAction(document) {
                public void undo() throws UnexpectedUndoException {

                    final DItemElement itemElement;
                    if (mySettings.isMethod()) {
                        final List<ParamInfo> myPairList = mySettings.getParams();
                        final String[] argumentsTypes = QuickfixUtil.getArgumentsTypes(myPairList);
                        itemElement = myDynamicManager.findConcreteDynamicMethod(
                                mySettings.getContainingClassName(), mySettings.getName(), argumentsTypes);
                    } else {
                        itemElement = myDynamicManager.findConcreteDynamicProperty(
                                mySettings.getContainingClassName(), mySettings.getName());
                    }

                    if (itemElement == null) {
                        Messages.showWarningDialog(myProject,
                                GroovyInspectionBundle.message("Cannot.perform.undo.operation"),
                                GroovyInspectionBundle.message("Undo.disable"));
                        return;
                    }
                    final DClassElement classElement = myDynamicManager.getClassElementByItem(itemElement);

                    if (classElement == null) {
                        Messages.showWarningDialog(myProject,
                                GroovyInspectionBundle.message("Cannot.perform.undo.operation"),
                                GroovyInspectionBundle.message("Undo.disable"));
                        return;
                    }

                    removeElement(itemElement);

                    if (classElement.getMethods().size() == 0 && classElement.getProperties().size() == 0) {
                        myDynamicManager.removeClassElement(classElement);
                    }
                }

                public void redo() throws UnexpectedUndoException {
                    addElement(mySettings);
                }
            });

            addElement(mySettings);
        }
    }, "Add dynamic element", null);
}

From source file:org.jetbrains.tfsIntegration.checkin.PolicyBase.java

License:Apache License

/**
 * This method is invoked when user double clicks on policy failure item in Checkin Parameters dialog.
 * Default implementation shows message dialog with the problem description
 *
 * @param project       project for the current frame
 * @param policyFailure item that is activated
 *//*from   w  w  w  .j a  v  a 2s . com*/
public void activate(@NotNull Project project, @NotNull PolicyFailure policyFailure) {
    final String message;
    if (policyFailure.getTooltipText() != null) {
        message = MessageFormat.format("{0}\n\n{1}", policyFailure.getMessage(),
                policyFailure.getTooltipText());
    } else {
        message = policyFailure.getMessage();
    }
    Messages.showWarningDialog(project, message, "Checkin Policy Warning");
}

From source file:org.jraf.intellijplugin.opencurrentactivity.OpenCurrentActivityAnAction.java

License:Open Source License

public void actionPerformed(AnActionEvent event) {
    final Project project = event.getData(PlatformDataKeys.PROJECT);
    if (project == null) {
        log.warn("project is null, which should never happen: give up");
        return;//from  www  . j a va  2 s  .  c  o  m
    }

    mStatusBar = WindowManager.getInstance().getStatusBar(project);
    if (mStatusBar == null) {
        log.warn("mStatusBar is null, which should never happen: give up");
        return;
    }

    String androidSdkPath = getAndroidSdkPath();
    if (androidSdkPath == null) {
        log.warn("Could not find Android sdk path");
        Messages.showWarningDialog(project, UI_NO_SDK_MESSAGE, UI_GENERIC_WARNING);
        return;
    }

    String activityName;
    try {
        activityName = getCurrentActivityName(null, androidSdkPath);
        openActivityFile(project, activityName);
    } catch (MultipleDevicesAdbException e) {
        log.info("Multiple devices detected, get the list and try again");
        try {
            List<String> deviceIdList = getDeviceIdList(androidSdkPath);
            for (String deviceId : deviceIdList) {
                try {
                    activityName = getCurrentActivityName(deviceId, androidSdkPath);
                    openActivityFile(project, activityName);
                } catch (ExecutionAdbException e2) {
                    mStatusBar.setInfo("Could not execute adb (" + e2.getCause().getMessage() + ")");
                } catch (ParseAdbException e2) {
                    mStatusBar.setInfo("Could not parse adb output");
                } catch (MultipleDevicesAdbException e2) {
                    // This should never happen since we passed a device id
                    log.error("Got a multiple devices message when passing a device id!?", e2);
                    mStatusBar.setInfo("Something went wrong!");
                }
            }
        } catch (ExecutionAdbException e1) {
            mStatusBar.setInfo("Could not execute adb (" + e1.getCause().getMessage() + ")");
        } catch (ParseAdbException e1) {
            mStatusBar.setInfo("Could not parse adb output");
        } catch (NoDevicesAdbException e1) {
            // This should never happen since we have multiple devices
            log.error("Got a no devices message when passing a device id!?", e1);
            mStatusBar.setInfo("Something went wrong!");
        }
    } catch (ExecutionAdbException e) {
        mStatusBar.setInfo("Could not execute adb (" + e.getCause().getMessage() + ")");
    } catch (ParseAdbException e) {
        mStatusBar.setInfo("Could not parse adb output");
    } catch (NoDevicesAdbException e) {
        mStatusBar.setInfo("Could not find any devices or emulators");
    }
}

From source file:org.napile.idea.thermit.config.actions.ThermitAntBuildFile.java

License:Apache License

public void actionPerformed(AnActionEvent event) {
    DataContext dataContext = event.getDataContext();
    Project project = PlatformDataKeys.PROJECT.getData(dataContext);
    VirtualFile file = PlatformDataKeys.VIRTUAL_FILE.getData(dataContext);
    ThermitConfiguration thermitConfiguration = ThermitConfiguration.getInstance(project);
    try {/* w  ww .  j a  v a2  s .  c om*/
        thermitConfiguration.addBuildFile(file);
        ToolWindowManager.getInstance(project).getToolWindow(ToolWindowId.ANT_BUILD).activate(null);
    } catch (AntNoFileException e) {
        String message = e.getMessage();
        if (message == null || message.length() == 0) {
            message = ThermitBundle.message("cannot.add.build.files.from.excluded.directories.error.message",
                    e.getFile().getPresentableUrl());
        }

        Messages.showWarningDialog(project, message,
                ThermitBundle.message("cannot.add.build.file.dialog.title"));
    }
}

From source file:org.napile.idea.thermit.config.explorer.AntExplorer.java

License:Apache License

private void addBuildFile() {
    final FileChooserDescriptor descriptor = createXmlDescriptor();
    descriptor.setTitle(ThermitBundle.message("select.ant.build.file.dialog.title"));
    descriptor.setDescription(ThermitBundle.message("select.ant.build.file.dialog.description"));
    final VirtualFile[] files = FileChooser.chooseFiles(descriptor, myProject, null);
    if (files.length == 0) {
        return;/*  w  w w.  j  a v a 2s .c o m*/
    }
    ApplicationManager.getApplication().invokeLater(new Runnable() {
        public void run() {
            final ThermitConfiguration thermitConfiguration = myConfig;
            if (thermitConfiguration == null) {
                return;
            }
            final List<VirtualFile> ignoredFiles = new ArrayList<VirtualFile>();
            for (VirtualFile file : files) {
                try {
                    thermitConfiguration.addBuildFile(file);
                } catch (AntNoFileException e) {
                    ignoredFiles.add(e.getFile());
                }
            }
            if (ignoredFiles.size() != 0) {
                String messageText;
                final StringBuilder message = StringBuilderSpinAllocator.alloc();
                try {
                    String separator = "";
                    for (final VirtualFile virtualFile : ignoredFiles) {
                        message.append(separator);
                        message.append(virtualFile.getPresentableUrl());
                        separator = "\n";
                    }
                    messageText = message.toString();
                } finally {
                    StringBuilderSpinAllocator.dispose(message);
                }
                Messages.showWarningDialog(myProject, messageText,
                        ThermitBundle.message("cannot.add.ant.files.dialog.title"));
            }
        }
    });
}

From source file:org.sonarlint.intellij.tasks.ServerUpdateTask.java

License:Open Source License

private void updateModules(ServerConfiguration serverConfiguration, TaskProgressMonitor monitor) {
    //here we assume that server is updated, or this won't work
    final Set<String> existingProjectKeys = engine.allModulesByKey().keySet();
    final Set<String> invalidModules = new HashSet<>();

    for (Map.Entry<String, List<Project>> entry : projectsPerModule.entrySet()) {
        String moduleKey = entry.getKey();
        if (existingProjectKeys.contains(moduleKey)) {
            updateModule(serverConfiguration, moduleKey, entry.getValue(), monitor);
        } else {//from   ww w.ja v a2s.co  m
            invalidModules.add(moduleKey);
        }
    }

    if (!projectsPerModule.isEmpty() && !invalidModules.isEmpty()) {
        log.log("The following modules could not be updated because they don't exist in the SonarQube server: "
                + invalidModules.toString(), LogOutput.Level.WARN);

        ApplicationManager.getApplication().invokeLater(new RunnableAdapter() {
            @Override
            public void doRun() throws Exception {
                Messages.showWarningDialog((Project) null,
                        "The following modules could not be updated because they don't exist in the SonarQube server: "
                                + invalidModules.toString(),
                        "Modules Not Updated");
            }
        }, ModalityState.any());
    }
}

From source file:org.trzcinka.intellitrac.view.toolwindow.wiki.WikiTabForm.java

License:Apache License

public WikiTabForm() {
    launchWikiButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            if (BrowserUtil.canStartDefaultBrowser()) {
                String baseUrl = ApplicationModel.getConnectionSettings().getTracUrl();
                String suffix = IntelliTracConfiguration.getInstance().getConfiguration()
                        .getString("wiki_suffix");
                String url = baseUrl + suffix;
                BrowserUtil.launchBrowser(url);
            } else {
                ResourceBundle bundle = BundleLocator.getBundle();
                Messages.showWarningDialog(ApplicationModel.getProject(),
                        bundle.getString("dialogs.cannot_start_browser"), bundle.getString("dialogs.warning"));
            }/* w  w  w  . ja v  a2s  .c o m*/
        }
    });
}