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

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

Introduction

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

Prototype

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

Source Link

Document

Shows dialog with given message and title, information icon #getInformationIcon() and OK button

Use this method only if you do not know project or component

Usage

From source file:com.jetbrains.edu.coursecreator.actions.taskFile.CCShowPreview.java

License:Apache License

@Override
public void actionPerformed(@NotNull AnActionEvent e) {
    final Project project = e.getProject();
    Module module = LangDataKeys.MODULE.getData(e.getDataContext());
    if (project == null || module == null) {
        return;//from www  .j ava 2 s .  c om
    }
    final PsiFile file = CommonDataKeys.PSI_FILE.getData(e.getDataContext());
    if (file == null) {
        return;
    }
    Course course = StudyTaskManager.getInstance(project).getCourse();
    if (course == null) {
        return;
    }
    VirtualFile virtualFile = file.getVirtualFile();
    TaskFile taskFile = EduUtils.getTaskFile(project, virtualFile);
    if (taskFile == null || !taskFile.isVisible()) {
        return;
    }
    final PsiDirectory taskDir = file.getContainingDirectory();
    if (taskDir == null) {
        return;
    }
    PsiDirectory lessonDir = taskDir.getParentDirectory();
    if (lessonDir == null) {
        return;
    }

    if (taskFile.getAnswerPlaceholders().isEmpty()) {
        Messages.showInfoMessage(NO_PREVIEW_MESSAGE, "No Preview for This File");
        return;
    }

    final Task task = taskFile.getTask();
    ApplicationManager.getApplication().runWriteAction(() -> {
        TaskFile studentTaskFile = EduUtils.createStudentFile(project, virtualFile, task);
        if (studentTaskFile != null) {
            showPreviewDialog(project, studentTaskFile);
        }
    });
}

From source file:com.magnet.plugin.helpers.UIHelper.java

License:Open Source License

public static void showErrorMessage(String message) {
    Messages.showInfoMessage(message, Rest2MobileMessages.getMessage(Rest2MobileMessages.WINDOW_TITLE));
}

From source file:com.magnet.plugin.r2m.helpers.UIHelper.java

License:Open Source License

public static void showErrorMessage(String message) {
    Messages.showInfoMessage(message, R2MMessages.getMessage("WINDOW_TITLE"));
}

From source file:com.microsoft.intellij.ui.azureroles.DebugConfigurationDialog.java

License:Open Source License

@Override
protected void doOKAction() {
    if (!projText.getText().isEmpty()) {
        Module module = ModuleManager.getInstance(project).findModuleByName(projText.getText());
        try {/*from   www  .  j ava2  s .c  o m*/
            //check for project exists/open/JAVA nature
            if (module == null) {
                PluginUtil.displayErrorDialog(message("dbgInvdProjTitle"), message("dbgInvdProjMsg"));
                return;
            }
        } catch (Exception e) {
            PluginUtil.displayErrorDialogAndLog(message("dbgProjErrTitle"), message("dbgProjErr"), e);
            return;
        }
    }
    try {
        //method which pass the required parameters for creating new
        //debug launch configuration.
        createLaunchConfigParams();
    } catch (Exception e) {
        PluginUtil.displayErrorDialogAndLog(message("dlgDbgConfErrTtl"), message("dlgDbgConfErr"), e);
        return;
    }
    StringBuilder message = new StringBuilder(message("dlgConfDbgDlgMsg"));
    for (String str : configList) {
        message.append(String.format("\n-   %s", str));
    }
    Messages.showInfoMessage(message.toString(), message("dlgConfDbgTitle"));
    super.doOKAction();
}

From source file:com.microsoft.intellij.ui.azureroles.RoleEndpointsPanel.java

License:Open Source License

private void setEndpointType(WindowsAzureEndpoint endpoint, WindowsAzureEndpointType type, String prvPort,
        String pubPort) throws WindowsAzureInvalidProjectOperationException {
    if (windowsAzureRole.isValidEndpoint(endpoint.getName(), type, prvPort, pubPort)) {
        endpoint.setPrivatePort(prvPort);
        setModified(true);/*w  ww.j  av  a 2 s.c  om*/
        endpoint.setEndPointType(type);
    } else {
        Messages.showInfoMessage(message("changeErr"), message("dlgTypeTitle"));
    }
}

From source file:com.microsoft.intellij.ui.debug.AzureRemoteStateState.java

License:Open Source License

public ExecutionResult execute(final Executor executor, @NotNull final ProgramRunner runner)
        throws ExecutionException {
    try {/*from w w  w  .ja  va 2  s  .  co  m*/
        // get web app name to which user want to debug his application
        String website = webAppName;
        if (!website.isEmpty()) {
            website = website.substring(0, website.indexOf('(')).trim();
            Map<WebSite, WebSiteConfiguration> webSiteConfigMap = AzureSettings.getSafeInstance(project)
                    .loadWebApps();
            // retrieve web apps configurations
            for (Map.Entry<WebSite, WebSiteConfiguration> entry : webSiteConfigMap.entrySet()) {
                final WebSite websiteTemp = entry.getKey();
                if (websiteTemp.getName().equals(website)) {
                    final WebSiteConfiguration webSiteConfiguration = entry.getValue();
                    // case - if user uses shortcut without going to Azure Tab
                    Map<String, Boolean> mp = AzureSettings.getSafeInstance(project).getWebsiteDebugPrep();
                    if (!mp.containsKey(website)) {
                        mp.put(website, false);
                    }
                    AzureSettings.getSafeInstance(project).setWebsiteDebugPrep(mp);
                    // check if web app prepared for debugging and process has started
                    if (AzureSettings.getSafeInstance(project).getWebsiteDebugPrep().get(website).booleanValue()
                            && !Utils.isPortAvailable(Integer.parseInt(socketPort))) {
                        ConsoleViewImpl consoleView = new ConsoleViewImpl(project, false);
                        RemoteDebugProcessHandler process = new RemoteDebugProcessHandler(project);
                        consoleView.attachToProcess(process);
                        return new DefaultExecutionResult(consoleView, process);
                    } else {
                        if (AzureSettings.getSafeInstance(project).getWebsiteDebugPrep().get(website)
                                .booleanValue()) {
                            // process not started
                            ApplicationManager.getApplication().invokeLater(new Runnable() {
                                @Override
                                public void run() {
                                    int choice = Messages.showOkCancelDialog(message("processDebug"),
                                            "Azure Web App", Messages.getQuestionIcon());
                                    if (choice == Messages.OK) {
                                        // check is there a need for preparation
                                        ProcessForDebug task = new ProcessForDebug(websiteTemp,
                                                webSiteConfiguration);
                                        try {
                                            task.queue();
                                            Messages.showInfoMessage(message("debugReady"), "Azure Web App");
                                        } catch (Exception e) {
                                            AzurePlugin.log(e.getMessage(), e);
                                        }
                                    }
                                }
                            }, ModalityState.defaultModalityState());
                        } else {
                            // start the process of preparing the web app, in a blocking way
                            if (Utils.isPortAvailable(Integer.parseInt(socketPort))) {
                                ApplicationManager.getApplication().invokeLater(new Runnable() {
                                    @Override
                                    public void run() {
                                        int choice = Messages.showOkCancelDialog(message("remoteDebug"),
                                                "Azure Web App", Messages.getQuestionIcon());
                                        if (choice == Messages.OK) {
                                            // check is there a need for preparation
                                            PrepareForDebug task = new PrepareForDebug(websiteTemp,
                                                    webSiteConfiguration);
                                            try {
                                                task.queue();
                                                Messages.showInfoMessage(message("debugReady"),
                                                        "Azure Web App");
                                            } catch (Exception e) {
                                                AzurePlugin.log(e.getMessage(), e);
                                            }
                                        }
                                    }
                                }, ModalityState.defaultModalityState());
                            } else {
                                ApplicationManager.getApplication().invokeLater(new Runnable() {
                                    @Override
                                    public void run() {
                                        PluginUtil.displayErrorDialog("Azure Web App",
                                                String.format(message("portMsg"), socketPort));
                                    }
                                }, ModalityState.defaultModalityState());
                            }
                        }
                    }
                    break;
                }
            }
        }
    } catch (Exception ex) {
        AzurePlugin.log(ex.getMessage(), ex);
    }
    return null;
}

From source file:com.microsoft.intellij.util.PluginUtil.java

License:Open Source License

public static void displayInfoDialog(String title, String message) {
    Messages.showInfoMessage(message, title);
}

From source file:com.microsoftopentechnologies.intellij.deploy.DeploymentManager.java

License:Apache License

public void deploy(Module selectedModule) throws InterruptedException, DeploymentException {

    DeployDescriptor deploymentDesc = WizardCacheManager.collectConfiguration();

    String deployState = deploymentDesc.getDeployState();
    try {//  w ww  .j  a  va  2  s  .c o  m

        int conditionalProgress = 20;

        HostedService hostedService = deploymentDesc.getHostedService();
        addDeployment(hostedService.getServiceName(), deploymentDesc);

        StorageService storageAccount = deploymentDesc.getStorageAccount();

        WindowsAzureServiceManagement service = WizardCacheManager.createServiceManagementHelper();

        openWindowsAzureActivityLogView(deploymentDesc);

        if (deploymentDesc.getDeployMode() == WindowsAzurePackageType.LOCAL) {
            deployToLocalEmulator(selectedModule, deploymentDesc);
            notifyProgress(deploymentDesc.getDeploymentId(), null, 100, OperationStatus.Succeeded,
                    message("deplCompleted"));
            return;
        }

        // need to improve this check (maybe hostedSerivce.isExisting())?
        if (hostedService.getUri() == null || hostedService.getUri().toString().isEmpty()) { // the hosted service was not yet created.
            notifyProgress(deploymentDesc.getDeploymentId(), null, 5, OperationStatus.InProgress,
                    String.format("%s - %s", message("createHostedService"), hostedService.getServiceName()));
            createHostedService(hostedService.getServiceName(), hostedService.getServiceName(),
                    hostedService.getProperties().getLocation(),
                    hostedService.getProperties().getDescription());
            conditionalProgress -= 5;
        }

        // same goes here
        if (storageAccount.getUrl() == null || storageAccount.getUrl().isEmpty()) { // the storage account was not yet created
            notifyProgress(deploymentDesc.getDeploymentId(), null, 10, OperationStatus.InProgress,
                    String.format("%s - %s", message("createStorageAccount"), storageAccount.getServiceName()));
            createStorageAccount(storageAccount.getServiceName(), storageAccount.getServiceName(),
                    storageAccount.getStorageAccountProperties().getLocation(),
                    storageAccount.getStorageAccountProperties().getDescription());
            conditionalProgress -= 10;
        }

        checkContainerExistance();

        // upload certificates
        if (deploymentDesc.getCertList() != null) {
            List<CertificateUpload> certList = deploymentDesc.getCertList().getList();
            if (certList != null && certList.size() > 0) {
                for (int i = 0; i < certList.size(); i++) {
                    CertificateUpload cert = certList.get(i);
                    DeploymentManagerUtilMethods.uploadCertificateIfNeededGeneric(service, deploymentDesc,
                            cert.getPfxPath(), cert.getPfxPwd());
                    notifyProgress(deploymentDesc.getDeploymentId(), null, 0, OperationStatus.InProgress,
                            String.format("%s%s", message("deplUploadCert"), cert.getName()));
                }
            }
        }

        if (deploymentDesc.getRemoteDesktopDescriptor().isEnabled()) {

            notifyProgress(deploymentDesc.getDeploymentId(), null, conditionalProgress,
                    OperationStatus.InProgress, message("deplConfigRdp"));

            DeploymentManagerUtilMethods.configureRemoteDesktop(deploymentDesc,
                    WizardCacheManager.getCurrentDeployConfigFile(), String.format("%s%s%s",
                            PathManager.getPluginsPath(), File.separator, AzurePlugin.PLUGIN_ID));
        } else {
            notifyProgress(deploymentDesc.getDeploymentId(), null, conditionalProgress,
                    OperationStatus.InProgress, message("deplConfigRdp"));
        }

        Notifier notifier = new NotifierImp();

        String targetCspckgName = createCspckTargetName(deploymentDesc);

        notifyProgress(deploymentDesc.getDeploymentId(), null, 20, OperationStatus.InProgress,
                message("uploadingServicePackage"));

        DeploymentManagerUtilMethods.uploadPackageService(WizardCacheManager.createStorageServiceHelper(),
                deploymentDesc.getCspkgFile(), targetCspckgName,
                message("eclipseDeployContainer").toLowerCase(), deploymentDesc, notifier);

        notifyProgress(deploymentDesc.getDeploymentId(), null, 20, OperationStatus.InProgress,
                message("creatingDeployment"));

        String storageAccountURL = deploymentDesc.getStorageAccount().getStorageAccountProperties()
                .getEndpoints().get(0).toString();

        String cspkgUrl = String.format("%s%s/%s", storageAccountURL,
                message("eclipseDeployContainer").toLowerCase(), targetCspckgName);
        /*
         * To make deployment name unique attach time stamp
         * to the deployment name.
         */
        DateFormat dateFormat = new SimpleDateFormat("yyyyMMddHHmmss");
        String deploymentName = String.format("%s%s%s", hostedService.getServiceName(), deployState,
                dateFormat.format(new Date()));
        String requestId = DeploymentManagerUtilMethods.createDeployment(deploymentDesc, service, cspkgUrl,
                deploymentName);
        OperationStatus status = waitForStatus(deploymentDesc.getConfiguration(), service, requestId);

        DeploymentManagerUtilMethods.deletePackage(WizardCacheManager.createStorageServiceHelper(),
                message("eclipseDeployContainer").toLowerCase(), targetCspckgName, notifier);
        notifyProgress(deploymentDesc.getDeploymentId(), null, 0, OperationStatus.InProgress,
                message("deletePackage"));

        notifyProgress(deploymentDesc.getDeploymentId(), null, 20, OperationStatus.InProgress,
                message("waitingForDeployment"));

        DeploymentGetResponse deployment = waitForDeployment(deploymentDesc.getConfiguration(),
                hostedService.getServiceName(), service, deploymentName);

        boolean displayHttpsLink = deploymentDesc.getDisplayHttpsLink();

        final String url = displayHttpsLink ? deployment.getUri().toString().replaceAll("http://", "https://")
                : deployment.getUri().toString();
        notifyProgress(deploymentDesc.getDeploymentId(),
                displayHttpsLink ? deployment.getUri().toString().replaceAll("http://", "https://")
                        : deployment.getUri().toString(),
                20, status, deployment.getStatus().toString());
        ApplicationManager.getApplication().invokeLater(new Runnable() {
            @Override
            public void run() {
                Messages.showInfoMessage("<html>Deployment can be accessed at:<br><a href=\"" + url + "\">"
                        + url + "</a></html>", "Deployment Completed");
            }
        });
        if (deploymentDesc.isStartRdpOnDeploy()) {
            String pluginFolder = String.format("%s%s%s", PathManager.getPluginsPath(), File.separator,
                    AzurePlugin.PLUGIN_ID);
            WindowsAzureRestUtils.getInstance().launchRDP(deployment,
                    deploymentDesc.getRemoteDesktopDescriptor().getUserName(), pluginFolder);
        }
    } catch (Throwable t) {
        String msg = (t != null ? t.getMessage() : "");
        if (!msg.startsWith(OperationStatus.Failed.toString())) {
            msg = OperationStatus.Failed.toString() + " : " + msg;
        }
        notifyProgress(deploymentDesc.getDeploymentId(), null, 100, OperationStatus.Failed, msg,
                deploymentDesc.getDeploymentId(), deployState);
        if (t instanceof DeploymentException) {
            throw (DeploymentException) t;
        }
        throw new DeploymentException(msg, t);
    }
}

From source file:com.targetprocess.intellij.config.TargetProcessConfigurableForm.java

License:Open Source License

public TargetProcessConfigurableForm() {
    myTestButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            boolean result = false;
            Messages.showInfoMessage(result ? "success" : "cannot-login", result ? "success" : "failure");
        }/*  w  ww  . j ava  2s.c  o m*/
    });
}

From source file:com.twitter.intellij.pants.ui.PantsProjectRefresh.java

License:Apache License

@Override
public void actionPerformed(AnActionEvent e) {
    Project project = e.getProject();/*from ww w  .  ja v  a2s . com*/
    if (project == null) {
        Messages.showInfoMessage("Project not found.", "Error");
        return;
    }
    PantsUtil.refreshAllProjects(project);
}