com.intellij.notification.NotificationType Java Examples

The following examples show how to use com.intellij.notification.NotificationType. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: QueryKBServerTask.java    From KodeBeagle with Apache License 2.0 6 votes vote down vote up
@Override
public final void run(@NotNull final ProgressIndicator indicator) {
    try {
        long startTime = System.nanoTime();
        doBackEndWork(indicator);
        long endTime = System.nanoTime();
        double timeToFetchResults = (endTime - startTime) / CONVERT_TO_SECONDS;

        String notificationTitle = String.format(FORMAT, QUERIED,
                windowObjects.getKbAPIURL(), FOR);
        int resultCount = searchUtils.getResultCount();
        if (resultCount > 0) {
            String notificationContent = " "
                    + getResultNotificationMessage(resultCount,
                    searchUtils.getTotalHitsCount(), timeToFetchResults);
            notification = KBNotification.getInstance()
                    .notifyBalloon(notificationTitle + notificationContent,
                            NotificationType.INFORMATION);
        }
    } catch (RuntimeException rte) {
        KBNotification.getInstance().error(rte);
        rte.printStackTrace();
        httpErrorMsg = rte.getMessage();
        isFailed = true;
    }
}
 
Example #2
Source File: HaskellToolsConfigurable.java    From intellij-haskforce with Apache License 2.0 6 votes vote down vote up
/**
 * Heuristically finds the version number. Current implementation is the
 * identity function since cabal plays nice.
 */
@Nullable
private static String getVersion(String cmd, String versionFlag) {
    return ExecUtil.readCommandLine(null, cmd, versionFlag).fold(
        new AbstractFunction1<ExecUtil.ExecError, String>() {
            @Override
            public String apply(ExecUtil.ExecError e) {
                NotificationUtil.displaySimpleNotification(
                    NotificationType.ERROR, null, "Haskell Tools", e.getMessage()
                );
                return null;
            }
        },
        new AbstractFunction1<String, String>() {
            @Override
            public String apply(String s) {
                return s;
            }
        }
    );
}
 
Example #3
Source File: GraphQLConfigManager.java    From js-graphql-intellij-plugin with MIT License 6 votes vote down vote up
public void createAndOpenConfigFile(VirtualFile configBaseDir, Boolean openEditor, Consumer<OutputStream> outputStreamConsumer) {
    ApplicationManager.getApplication().runWriteAction(() -> {
        try {
            final VirtualFile configFile = configBaseDir.createChildData(this, GRAPHQLCONFIG);
            try (OutputStream stream = configFile.getOutputStream(this)) {
                outputStreamConsumer.accept(stream);
            }
            if (openEditor) {
                UIUtil.invokeLaterIfNeeded(() -> {
                    FileEditorManager.getInstance(myProject).openFile(configFile, true, true);
                });
            }
        } catch (IOException e) {
            Notifications.Bus.notify(new Notification("GraphQL", "Unable to create " + GRAPHQLCONFIG, "Unable to create file '" + GRAPHQLCONFIG + "' in directory '" + configBaseDir.getPath() + "': " + e.getMessage(), NotificationType.ERROR));
        }
    });
}
 
Example #4
Source File: AemdcPanel.java    From aem-ide-tooling-4-intellij with Apache License 2.0 6 votes vote down vote up
public boolean showDialog() {
    // First check if the aemdc configuration file exists. If not but there is a lazybones configuration
    // try auto configuration first
    VirtualFile aemdcConfigPropertiesFile = project.getBaseDir().findChild(AEMDC_CONFIG_PROPERTIES);
    if(aemdcConfigPropertiesFile == null) {
        if(project.getBaseDir().findChild(LAZYBONES_FOLDER) != null) {
            // Ask the user if he wants to auto configure from the lazybones configuration
            int response = ComponentProvider.getComponent(project, MessageManager.class).showAlertWithOptions(
                NotificationType.INFORMATION,
                "dialog.aemdc.do.auto.configuration"
            );
            if(response == 1) {
                try {
                    RunnableCompanion.main(new String[]{"-temp=" + project.getBasePath(), "config"});
                } catch(IOException e) {
                    ComponentProvider.getComponent(project, MessageManager.class).showAlertWithArguments(NotificationType.ERROR, "dialog.aemdc.failed.auto.configuration");
                }
            }
        }
    }
    SlingServerTreeSelectionHandler slingServerTreeSelectionHandler = ComponentProvider.getComponent(project, SlingServerTreeSelectionHandler.class);
    ServerConfiguration serverConfiguration = slingServerTreeSelectionHandler.getCurrentConfiguration();
    AemdcConfigurationDialog dialog = new AemdcConfigurationDialog(project, serverConfiguration);
    return dialog.showAndGet();
}
 
Example #5
Source File: ServerConnectionManager.java    From aem-ide-tooling-4-intellij with Apache License 2.0 6 votes vote down vote up
public void checkModules(OsgiClient osgiClient) {
    ServerConfiguration serverConfiguration = selectionHandler.getCurrentConfiguration();
    if(serverConfiguration != null) {
        ServerConfiguration.SynchronizationStatus status = ServerConfiguration.SynchronizationStatus.upToDate;
        boolean allSynchronized = true;
        if(checkBinding(serverConfiguration, new ProgressHandlerImpl("Check Bindings"))) {
            int moduleCount = serverConfiguration.getModuleList().size();
            float steps = (float) (0.9 / moduleCount);
            for(Module module : serverConfiguration.getModuleList()) {
                boolean sync = checkModule(osgiClient, module);
                // Any out of sync marks the project out of sync
                if(!sync) {
                    status = ServerConfiguration.SynchronizationStatus.outdated;
                }
            }
        } else {
            status = ServerConfiguration.SynchronizationStatus.failed;
        }
        updateStatus(serverConfiguration.getName(), status);
    } else {
        messageManager.sendNotification("deploy.module.no.configuration.selected", NotificationType.WARNING);
    }
}
 
Example #6
Source File: GitHubErrorReporter.java    From IntelliJDeodorant with MIT License 6 votes vote down vote up
@Override
public void consume(SubmittedReportInfo reportInfo) {
    myOriginalConsumer.consume(reportInfo);

    if (reportInfo.getStatus().equals(SubmittedReportInfo.SubmissionStatus.FAILED)) {
        ReportMessages.GROUP.createNotification(
                ReportMessages.ERROR_REPORT,
                reportInfo.getLinkText(),
                NotificationType.ERROR,
                NotificationListener.URL_OPENING_LISTENER).setImportant(false).notify(myProject);
    } else {
        ReportMessages.GROUP.createNotification(
                ReportMessages.ERROR_REPORT,
                reportInfo.getLinkText(),
                NotificationType.INFORMATION,
                NotificationListener.URL_OPENING_LISTENER).setImportant(false).notify(myProject);
    }
}
 
Example #7
Source File: MessageManager.java    From aem-ide-tooling-4-intellij with Apache License 2.0 6 votes vote down vote up
public void showAlert(@NotNull final NotificationType type, @NotNull final String title, @NotNull final String message) {
    // Make sure the Message is also placed inside the Log Console
    sendNotification(title, message, type);
    invokeAndWait(
        new InvokableRunner() {
            @Override
            public void run() {
                Messages.showDialog(
                    myProject,
                    message,
                    title,
                    new String[]{Messages.OK_BUTTON},
                    0,
                    getIcon(type)
                );
            }
        }
    );
}
 
Example #8
Source File: Settings.java    From weex-language-support with MIT License 6 votes vote down vote up
@Override
public void apply() throws ConfigurationException {
    try {
        PropertiesComponent.getInstance().setValue(KEY_RULES_PATH, rulesPath.getText());
        if (!TextUtils.isEmpty(rulesPath.getText())) {
            load(rulesPath.getText());
            DirectiveLint.prepare();
        } else {
            DirectiveLint.reset();
        }
    } catch (Exception e) {
        ProjectUtil.guessCurrentProject(select).getMessageBus().syncPublisher(Notifications.TOPIC).notify(
                new Notification(Notifications.SYSTEM_MESSAGES_GROUP_ID,
                        "Weex language support - bad rules",
                        e.toString(),
                        NotificationType.ERROR));
    }
    savePaths();
}
 
Example #9
Source File: LatteIndexUtil.java    From intellij-latte with MIT License 6 votes vote down vote up
private static void tryPerformReadLock(Project[] projects, @NotNull Notification notification) {
    if (LatteIdeHelper.holdsReadLock()) {
        notification.expire();
        showWaring(projects);
        return;
    }

    for (Project project : projects) {
        if (!reinitializeDefaultConfig(project)) {
            return;
        }
    }

    notification.expire();

    LatteIdeHelper.doNotify("Latte plugin settings", "Configuration was reloaded", NotificationType.INFORMATION, null);
}
 
Example #10
Source File: ServerConnectionManager.java    From aem-ide-tooling-4-intellij with Apache License 2.0 6 votes vote down vote up
public void deployModules(final DataContext dataContext, boolean force, final ProgressHandler progressHandler)
{
    ServerConfiguration serverConfiguration = selectionHandler.getCurrentConfiguration();
    if(serverConfiguration != null) {
        checkBinding(serverConfiguration, progressHandler);
        List<Module> moduleList = serverConfiguration.getModuleList();
        ProgressHandler progressHandlerSubTask = progressHandler.startSubTasks(moduleList.size(), "Check Bindings");
        double i = 0;
        for(ServerConfiguration.Module module: moduleList) {
            progressHandlerSubTask.next("Deploy Module: " + module.getName());
            deployModule(dataContext, module, force, progressHandlerSubTask);
            i += 1;
        }
    } else {
        messageManager.sendNotification("deploy.modules.no.configuration.selected", NotificationType.WARNING);
    }
}
 
Example #11
Source File: ToolKey.java    From intellij-haskforce with Apache License 2.0 5 votes vote down vote up
public static long getGhcModiResponseTimeout(@NotNull Project project) {
    String timeout = getGhcModiResponseTimeoutString(project);
    if (timeout == null) return GHC_MODI_RESPONSE_TIMEOUT_DEFAULT;
    try {
        return Long.parseLong(timeout);
    } catch (NumberFormatException e) {
        String message = "Invalid " + GHC_MODI_RESPONSE_TIMEOUT_KEY + " value '" + timeout + "'"
                       + "; defaulting to " + GHC_MODI_RESPONSE_TIMEOUT_DEFAULT;
        LOG.warn(message);
        NotificationUtil.displaySimpleNotification(NotificationType.WARNING, project, "Configuration", message);
        return GHC_MODI_RESPONSE_TIMEOUT_DEFAULT;
    }
}
 
Example #12
Source File: MuleSchemaProvider.java    From mule-intellij-plugins with Apache License 2.0 5 votes vote down vote up
@Override
public Set<String> getLocations(@NotNull @NonNls final String namespace, @NotNull final XmlFile context) throws ProcessCanceledException {
    Set<String> locations = new HashSet<>();
    final Module module = ModuleUtil.findModuleForPsiElement(context);
    if (module == null) {
        return null;
    }
    try {
        final Map<String, XmlFile> schemas = getSchemas(module);
        for (Map.Entry<String, XmlFile> entry : schemas.entrySet()) {
            final String s = getNamespace(entry.getValue(), context.getProject());
            if (s != null && s.equals(namespace)) {
                if (!entry.getKey().contains("mule-httpn.xsd")) {
                    locations.add(entry.getKey()); //Observe the formatting rules
                    XmlFile schemaFile = entry.getValue();
                    try {
                        String url = schemaFile.getVirtualFile().getUrl();
                        if (url != null) {
                            if (url.startsWith("jar://"))
                                url = url.substring(6);
                            ExternalResourceManager.getInstance().addResource(namespace, url);
                        }
                    } catch (Throwable ex) {
                        Notifications.Bus.notify(new Notification("Schema Provider", "Schema Provider", ex.toString(),
                                NotificationType.ERROR));
                    }
                }
            }
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
    return locations;
}
 
Example #13
Source File: ToolKey.java    From intellij-haskforce with Apache License 2.0 5 votes vote down vote up
public static long getGhcModiKillIdleTimeout(@NotNull Project project) {
    final String timeout = PropertiesComponent.getInstance(project).getValue(GHC_MODI_KILL_IDLE_TIMEOUT_KEY);
    if (timeout == null || timeout.isEmpty()) return GHC_MODI_KILL_IDLE_TIMEOUT_DEFAULT;
    try {
        return Long.parseLong(timeout);
    } catch (NumberFormatException e) {
        String message = "Invalid " + GHC_MODI_KILL_IDLE_TIMEOUT_KEY + " value '" + timeout + "'"
                       + "; default to " + GHC_MODI_KILL_IDLE_TIMEOUT_DEFAULT;
        LOG.warn(message);
        NotificationUtil.displaySimpleNotification(NotificationType.WARNING, project, "Configuration", message);
        return GHC_MODI_KILL_IDLE_TIMEOUT_DEFAULT;
    }
}
 
Example #14
Source File: HeadlessValueEvaluationCallback.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public void errorOccurred(@Nonnull String errorMessage) {
  try {
    String message = XDebuggerBundle.message("load.value.task.error", errorMessage);
    XDebugSessionImpl.NOTIFICATION_GROUP.createNotification(message, NotificationType.ERROR).notify(myNode.getTree().getProject());
  }
  finally {
    evaluationComplete(errorMessage);
  }
}
 
Example #15
Source File: NotificationUtils.java    From freeline with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * show a Notification
 *
 * @param message
 * @param type
 */
public static void showNotification(final String message,
                                    final NotificationType type) {
    ApplicationManager.getApplication().invokeLater(new Runnable() {
        @Override
        public void run() {
            Notification notification =
                    NOTIFICATION_GROUP.createNotification(TITLE, message, type, null);
            Notifications.Bus.notify(notification);
        }
    });
}
 
Example #16
Source File: LatteIndexUtil.java    From intellij-latte with MIT License 5 votes vote down vote up
public static void notifyRemovedFiles(List<Project> projects) {
    LatteIdeHelper.doNotify(
            "Latte plugin settings",
            "File latte-intellij.xml was removed. You can refresh configurations.",
            NotificationType.INFORMATION,
            null,
            new NotificationAction("Refresh Configuration") {
                @Override
                public void actionPerformed(@NotNull AnActionEvent e, @NotNull Notification notification) {
                    tryPerform(projects.toArray(new Project[0]), notification);
                }
            }
    );
}
 
Example #17
Source File: BuckBuildNotification.java    From Buck-IntelliJ-Plugin with Apache License 2.0 5 votes vote down vote up
public static BuckBuildNotification createBuildFailedNotification(
    String buildCommand,
    String description) {
  String title = "Buck " + buildCommand + " failed";
  return new BuckBuildNotification(
      NOTIFICATION_GROUP_ID.getDisplayId(),
      title, description,
      NotificationType.ERROR);
}
 
Example #18
Source File: KBNotification.java    From KodeBeagle with Apache License 2.0 5 votes vote down vote up
public Notification notifyInvasive(final String content,
                                         final NotificationType type) {
    expire();
    prevNotification =
            notificationsInvasive.createNotification(RefreshActionBase.KODEBEAGLE, content,
                    type, null);
    prevNotification.notify(windowObjects.getProject());
    return prevNotification;
}
 
Example #19
Source File: NotificationUtil.java    From intellij-haskforce with Apache License 2.0 5 votes vote down vote up
public static void displayToolsNotification(@NotNull NotificationType type,
                                            @NotNull Project project,
                                            @NotNull String title,
                                            @NotNull String message) {
    Notifications.Bus.notify(new Notification(
            title, title,
            replaceNewlines(message) + "<br/><a href='configureHaskellTools'>Configure</a>",
            type, new HaskellToolsNotificationListener(project)), project);
}
 
Example #20
Source File: RTProjectComponent.java    From react-templates-plugin with MIT License 5 votes vote down vote up
private void validationFailed(String msg) {
        NotificationListener notificationListener = new NotificationListener() {
            @Override
            public void hyperlinkUpdate(@NotNull Notification notification, @NotNull HyperlinkEvent event) {
//                ESLintInspection.showSettings(project);
            }
        };
        String errorMessage = msg + FIX_CONFIG_HREF;
        showInfoNotification(errorMessage, NotificationType.WARNING, notificationListener);
        LOG.debug(msg);
        settingValidStatus = false;
    }
 
Example #21
Source File: Spectacle.java    From Intellij-Plugin with Apache License 2.0 5 votes vote down vote up
private void install() {
    if (installing) {
        Notifications.Bus.notify(new Notification("Installing", "Installation in progress...", "Installing Plugin: Spectacle", NotificationType.INFORMATION));
        return;
    }
    installing = true;
    ProgressManager.getInstance().run(new Task.Backgroundable(this.project, "Installing Plugin : Spectacle", false) {
        public void run(@NotNull ProgressIndicator progressIndicator) {
            progressIndicator.setIndeterminate(true);
            progressIndicator.setText("Installing plugin : Spectacle");
            try {
                ProcessBuilder processBuilder = new ProcessBuilder(settings.getGaugePath(), Constants.INSTALL, NAME);
                GaugeUtil.setGaugeEnvironmentsTo(processBuilder, settings);
                Process process = processBuilder.start();
                int exitCode = process.waitFor();
                installing = false;
                if (exitCode != 0)
                    throw new RuntimeException(GaugeUtil.getOutput(process.getInputStream(), "\n"));
                Notifications.Bus.notify(new Notification("Successful", "Installation Completed", "Installation of plugin Spectacle is completed successfully", NotificationType.INFORMATION));
            } catch (Exception e) {
                LOG.debug(e);
                Notification notification = new Notification("Error", "Installation Failed", e.getMessage(), NotificationType.ERROR);
                Notifications.Bus.notify(notification, project);
            }
            progressIndicator.cancel();
        }
    });
}
 
Example #22
Source File: LatteIndexUtil.java    From intellij-latte with MIT License 5 votes vote down vote up
public static Notification notifyDefaultReparse(Project project) {
    return LatteIdeHelper.doNotify(
            "Latte configuration reloaded",
            "Latte plugin installed configuration files to your .idea folder. It needs reparse files. (this should only happen if the first installation of new plugin version)",
            NotificationType.WARNING,
            project,
            true,
            new NotificationAction("Reparse Latte Files") {
                @Override
                public void actionPerformed(@NotNull AnActionEvent e, @NotNull Notification current) {
                    tryPerformReadLock(new Project[]{project}, current);
                }
            }
    );
}
 
Example #23
Source File: ConsoleLogModel.java    From aem-ide-tooling-4-intellij with Apache License 2.0 5 votes vote down vote up
void addNotification(Notification notification) {
    long stamp = System.currentTimeMillis();
    if(myProject != null) {
        SlingServerTreeSelectionHandler selectionHandler = ComponentProvider.getComponent(myProject, SlingServerTreeSelectionHandler.class);
        if(selectionHandler != null) {
            ServerConfiguration serverConfiguration = selectionHandler.getCurrentConfiguration();
            ServerConfiguration.LogFilter logFilter = serverConfiguration != null ? serverConfiguration.getLogFilter() : ServerConfiguration.LogFilter.info;
            switch(logFilter) {
                case debug:
                    add(notification);
                    break;
                case info:
                    if(!(notification instanceof DebugNotification)) {
                        add(notification);
                    }
                    break;
                case warning:
                    if(notification.getType() != NotificationType.INFORMATION) {
                        add(notification);
                    }
                    break;
                case error:
                default:
                    if(notification.getType() == NotificationType.ERROR) {
                        add(notification);
                    }
                    break;
            }
        }
        myStamps.put(notification, stamp);
        myStatuses.put(notification, ConsoleLog.formatForLog(notification, "").status);
        setStatusMessage(notification, stamp);
        fireModelChanged();
    }
}
 
Example #24
Source File: UnusedImportsAction.java    From needsmoredojo with Apache License 2.0 5 votes vote down vote up
public static void removeUnusedImports(PsiFile psiFile)
{
    final UnusedImportsRemover detector = new UnusedImportsRemover();
    final List<UnusedImportBlockEntry> results = detector.filterUsedModules(psiFile, ServiceManager.getService(psiFile.getProject(), DojoSettings.class).getRuiImportExceptions());

    int numDeleted = 0;

    for(UnusedImportBlockEntry entry : results)
    {
        if(entry.getDefines() == null || entry.getParameters() == null || entry.getDefines().size() == 0 || entry.getParameters().size() == 0)
        {
            continue;
        }

        UnusedImportsRemover.RemovalResult result = detector.removeUnusedParameters(entry.getParameters(), entry.getDefines());
        numDeleted += result.getElementsToDelete().size();

        if(result.getElementsToDelete().size() > 0)
        {
            Notifications.Bus.notify(new Notification("needsmoredojo", "Remove Unused Imports", result.getDeletedElementNames(), NotificationType.INFORMATION));
        }
    }

    if(numDeleted == 0)
    {
        Notifications.Bus.notify(new Notification("needsmoredojo", "Remove Unused Imports", "No unused imports were detected to delete", NotificationType.INFORMATION));
    }
}
 
Example #25
Source File: CheckForNewExercises.java    From tmc-intellij with MIT License 5 votes vote down vote up
private void createNotificationForNewExercises(Project project, SettingsTmc settings) {
    ErrorMessageService.TMC_NOTIFICATION
            .createNotification(
                    "New exercises!",
                    "New exercises found for "
                            + settings.getCourseName()
                            + ". \n<a href=/>Click here to download them<a>",
                    NotificationType.INFORMATION,
                    (notification, hyperlinkEvent) ->
                            new DownloadExerciseAction().downloadExercises(project, false))
            .notify(project);
}
 
Example #26
Source File: EditorBackgroundListener.java    From intellij-background-chibichara with MIT License 5 votes vote down vote up
public void refreshBackgroundImageBorder() {
    if (editorComponent != null) {
        try {
            editorComponent.setBorder(getBackgroundImageBorder());
        } catch (Exception e) {
            Notifications.Bus.notify(new Notification(
                    "BackgroundChibiChara",
                    e.toString(), "error loading background image",
                    NotificationType.ERROR
            ));
        }
    }
}
 
Example #27
Source File: GhcMod.java    From intellij-haskforce with Apache License 2.0 5 votes vote down vote up
@Nullable
public static String exec(@NotNull Project project, @NotNull String workingDirectory, @NotNull String ghcModPath,
                          @NotNull String command, @NotNull String ghcModFlags, String... params) {
    if (!validateGhcVersion(project, ghcModPath, ghcModFlags)) return null;
    GeneralCommandLine commandLine = new GeneralCommandLine(ghcModPath);
    GhcModUtil.updateEnvironment(project, commandLine.getEnvironment());
    ParametersList parametersList = commandLine.getParametersList();
    parametersList.addParametersString(ghcModFlags);
    parametersList.add(command);
    parametersList.addAll(params);
    // setWorkDirectory is deprecated but is needed to work with IntelliJ 13 which does not have withWorkDirectory.
    commandLine.setWorkDirectory(workingDirectory);
    // Make sure we can actually see the errors.
    commandLine.setRedirectErrorStream(true);
    HaskellToolsConsole toolConsole = HaskellToolsConsole.get(project);
    toolConsole.writeInput(ToolKey.GHC_MOD_KEY, "Using working directory: " + workingDirectory);
    toolConsole.writeInput(ToolKey.GHC_MOD_KEY, commandLine.getCommandLineString());
    Either<ExecUtil.ExecError, String> result = ExecUtil.readCommandLine(commandLine);
    if (result.isLeft()) {
        //noinspection ThrowableResultOfMethodCallIgnored
        ExecUtil.ExecError e = EitherUtil.unsafeGetLeft(result);
        toolConsole.writeError(ToolKey.GHC_MOD_KEY, e.getMessage());
        NotificationUtil.displayToolsNotification(
            NotificationType.ERROR, project, "ghc-mod", e.getMessage()
        );
        return null;
    }
    String out = EitherUtil.unsafeGetRight(result);
    toolConsole.writeOutput(ToolKey.GHC_MOD_KEY, out);
    return out;
}
 
Example #28
Source File: BsCompilerImpl.java    From reasonml-idea-plugin with MIT License 5 votes vote down vote up
private boolean isDisabled() {
    if (m_disabled == null) {
        m_disabled = Boolean.getBoolean("reasonBsbDisabled");
        if (m_disabled) {
            // Possible but you should NEVER do that
            Notifications.Bus.notify(new ORNotification("Bsb", "Bucklescript is disabled", NotificationType.WARNING));
        }
    }

    return m_disabled;
}
 
Example #29
Source File: FlatWelcomePanel.java    From consulo with Apache License 2.0 5 votes vote down vote up
private JComponent createEventsLink() {
  final Ref<ActionLink> actionLinkRef = new Ref<>();
  final JComponent panel = createActionLink("Events", AllIcons.Ide.Notification.NoEvents, actionLinkRef, new AnAction() {
    @RequiredUIAccess
    @Override
    public void actionPerformed(@Nonnull AnActionEvent e) {
      ((WelcomeDesktopBalloonLayoutImpl)myFlatWelcomeFrame.getBalloonLayout()).showPopup();
    }
  });
  panel.setVisible(false);
  myEventListener = types -> {
    NotificationType type1 = null;
    for (NotificationType t : types) {
      if (NotificationType.ERROR == t) {
        type1 = NotificationType.ERROR;
        break;
      }
      if (NotificationType.WARNING == t) {
        type1 = NotificationType.WARNING;
      }
      else if (type1 == null && NotificationType.INFORMATION == t) {
        type1 = NotificationType.INFORMATION;
      }
    }

    actionLinkRef.get().setIcon(TargetAWT.to(IdeNotificationArea.createIconWithNotificationCount(type1, types.size())));
    panel.setVisible(true);
  };
  myEventLocation = () -> {
    Point location = SwingUtilities.convertPoint(panel, 0, 0, getRootPane().getLayeredPane());
    return new Point(location.x, location.y + 5);
  };
  return panel;
}
 
Example #30
Source File: Notifier.java    From EclipseCodeFormatter with Apache License 2.0 5 votes vote down vote up
public void notifyFailedFormatting(PsiFile psiFile, boolean formattedByIntelliJ, final String reason) {
	String content;
	if (!formattedByIntelliJ) {
		content = psiFile.getName() + " failed to format with Eclipse Code Formatter. " + reason + "\n";
	} else {
		content = psiFile.getName() + " failed to format with IntelliJ code formatter.\n" + reason;
	}
	Notification notification = ProjectComponent.GROUP_DISPLAY_ID_ERROR.createNotification(content,
			NotificationType.ERROR);
	showNotification(notification, psiFile.getProject());
}