Search in sources :

Example 76 with Notification

use of com.intellij.notification.Notification in project intellij-plugins by JetBrains.

the class LibraryManager method registerModule.

@NotNull
public ProjectComponentReferenceCounter registerModule(@NotNull final Module module, ProblemsHolder problemsHolder, boolean collectLocalStyleHolders) throws InitException {
    final Project project = module.getProject();
    final StringRegistry.StringWriter stringWriter = new StringRegistry.StringWriter(16384);
    stringWriter.startChange();
    final AssetCounter assetCounter = new AssetCounter();
    final LibraryCollector libraryCollector = new LibraryCollector(this, new LibraryStyleInfoCollector(assetCounter, problemsHolder, module, stringWriter), module);
    final Client client;
    try {
        final AccessToken token = ReadAction.start();
        try {
            libraryCollector.collect(module);
        } finally {
            token.finish();
        }
        client = Client.getInstance();
        if (stringWriter.hasChanges()) {
            client.updateStringRegistry(stringWriter);
        } else {
            stringWriter.commit();
        }
    } catch (Throwable e) {
        stringWriter.rollback();
        throw new InitException(e, "error.collect.libraries");
    }
    assert !libraryCollector.sdkLibraries.isEmpty();
    final FlexLibrarySet flexLibrarySet = getOrCreateFlexLibrarySet(libraryCollector, assetCounter);
    final InfoMap<Project, ProjectInfo> registeredProjects = client.getRegisteredProjects();
    ProjectInfo info = registeredProjects.getNullableInfo(project);
    if (info == null) {
        info = new ProjectInfo(project);
        registeredProjects.add(info);
        client.openProject(project);
        DesignerApplicationManager.getInstance().projectRegistered(project);
    }
    LibrarySet librarySet;
    if (libraryCollector.externalLibraries.isEmpty()) {
        librarySet = null;
    } else {
        final String key = createKey(libraryCollector.externalLibraries, false);
        librarySet = librarySets.get(key);
        if (librarySet == null) {
            final SortResult sortResult = sortLibraries(new LibrarySorter(), libraryCollector, flexLibrarySet.contains, key, false);
            librarySet = new LibrarySet(sortResult.id, flexLibrarySet, sortResult.libraries);
            registerLibrarySet(key, librarySet);
        }
    }
    final ModuleInfo moduleInfo = new ModuleInfo(module, librarySet == null ? flexLibrarySet : librarySet, ModuleInfoUtil.isApp(module));
    final ProjectComponentReferenceCounter projectComponentReferenceCounter = new ProjectComponentReferenceCounter();
    if (collectLocalStyleHolders) {
        // client.registerModule finalize it
        stringWriter.startChange();
        try {
            moduleInfo.setLocalStyleHolders(ModuleInfoUtil.collectLocalStyle(moduleInfo, libraryCollector.getFlexSdkVersion(), stringWriter, problemsHolder, projectComponentReferenceCounter, assetCounter));
        } catch (Throwable e) {
            stringWriter.rollback();
            throw new InitException(e, "error.collect.local.style.holders");
        }
    }
    client.registerModule(project, moduleInfo, stringWriter);
    client.fillAssetClassPoolIfNeed(flexLibrarySet);
    module.getMessageBus().connect(moduleInfo).subscribe(ProjectTopics.PROJECT_ROOTS, new ModuleRootListener() {

        @Override
        public void rootsChanged(ModuleRootEvent event) {
            new Notification(FlashUIDesignerBundle.message("plugin.name"), FlashUIDesignerBundle.message("plugin.name"), "Please reopen your project to update on library changes.", NotificationType.WARNING).notify(project);
        }
    });
    return projectComponentReferenceCounter;
}
Also used : ModuleRootListener(com.intellij.openapi.roots.ModuleRootListener) Notification(com.intellij.notification.Notification) StringRegistry(com.intellij.flex.uiDesigner.io.StringRegistry) ProjectComponentReferenceCounter(com.intellij.flex.uiDesigner.mxml.ProjectComponentReferenceCounter) Project(com.intellij.openapi.project.Project) AccessToken(com.intellij.openapi.application.AccessToken) ModuleRootEvent(com.intellij.openapi.roots.ModuleRootEvent) SortResult(com.intellij.flex.uiDesigner.libraries.LibrarySorter.SortResult) NotNull(org.jetbrains.annotations.NotNull)

Example 77 with Notification

use of com.intellij.notification.Notification in project intellij-plugins by JetBrains.

the class ValidateFlashConfigurationsPrecompileTask method suggestParallelCompilationIfNeeded.

private void suggestParallelCompilationIfNeeded(final Project project, final Collection<Pair<Module, FlexBuildConfiguration>> modulesAndBCsToCompile) {
    if (myParallelCompilationSuggested)
        return;
    if (CompilerWorkspaceConfiguration.getInstance(project).PARALLEL_COMPILATION)
        return;
    if (modulesAndBCsToCompile.size() < 2)
        return;
    if (!independentBCsExist(modulesAndBCsToCompile))
        return;
    final NotificationListener listener = new NotificationListener() {

        public void hyperlinkUpdate(@NotNull final Notification notification, @NotNull final HyperlinkEvent event) {
            notification.expire();
            if ("enable".equals(event.getDescription())) {
                CompilerWorkspaceConfiguration.getInstance(project).PARALLEL_COMPILATION = true;
                final NotificationListener listener1 = new NotificationListener() {

                    public void hyperlinkUpdate(@NotNull final Notification notification, @NotNull final HyperlinkEvent event) {
                        notification.expire();
                        ShowSettingsUtil.getInstance().showSettingsDialog(project, CompilerBundle.message("compiler.configurable.display.name"));
                    }
                };
                new Notification(FLASH_COMPILER_GROUP_ID, FlexBundle.message("parallel.compilation.enabled"), FlexBundle.message("see.settings.compiler"), NotificationType.INFORMATION, listener1).notify(project);
            } else if ("open".equals(event.getDescription())) {
                ShowSettingsUtil.getInstance().showSettingsDialog(project, CompilerBundle.message("compiler.configurable.display.name"));
            }
        }
    };
    new Notification(FLASH_COMPILER_GROUP_ID, FlexBundle.message("parallel.compilation.hint.title"), FlexBundle.message("parallel.compilation.hint"), NotificationType.INFORMATION, listener).notify(project);
    myParallelCompilationSuggested = true;
}
Also used : HyperlinkEvent(javax.swing.event.HyperlinkEvent) NotNull(org.jetbrains.annotations.NotNull) Notification(com.intellij.notification.Notification) NotificationListener(com.intellij.notification.NotificationListener)

Example 78 with Notification

use of com.intellij.notification.Notification in project intellij-community by JetBrains.

the class IdeMessagePanel method showErrorNotification.

private void showErrorNotification(@Nullable String notificationText, @NotNull Project project) {
    Notification notification = new Notification("", AllIcons.Ide.FatalError, notificationText == null ? ERROR_TITLE : "", null, notificationText == null ? "" : notificationText, NotificationType.ERROR, null);
    if (notificationText == null) {
        notification.addAction(new NotificationAction(ERROR_LINK) {

            @Override
            public void actionPerformed(@NotNull AnActionEvent e, @NotNull Notification notification) {
                notification.expire();
                _openFatals(null);
            }
        });
    }
    BalloonLayout layout = myFrame.getBalloonLayout();
    assert layout != null;
    BalloonLayoutData layoutData = BalloonLayoutData.createEmpty();
    layoutData.fadeoutTime = 5000;
    layoutData.fillColor = new JBColor(0XF5E6E7, 0X593D41);
    layoutData.borderColor = new JBColor(0XE0A8A9, 0X73454B);
    assert myBalloon == null;
    myBalloon = NotificationsManagerImpl.createBalloon(myFrame, notification, false, false, new Ref<>(layoutData), project);
    Disposer.register(myBalloon, () -> myBalloon = null);
    layout.add(myBalloon);
}
Also used : Ref(com.intellij.openapi.util.Ref) BalloonLayout(com.intellij.ui.BalloonLayout) NotificationAction(com.intellij.notification.NotificationAction) BalloonLayoutData(com.intellij.ui.BalloonLayoutData) JBColor(com.intellij.ui.JBColor) AnActionEvent(com.intellij.openapi.actionSystem.AnActionEvent) Notification(com.intellij.notification.Notification)

Example 79 with Notification

use of com.intellij.notification.Notification in project intellij-community by JetBrains.

the class DefaultIdeaErrorLogger method processMappingFailed.

private static void processMappingFailed(IdeaLoggingEvent event) throws InterruptedException, InvocationTargetException {
    if (!ourMappingFailedNotificationPosted && SystemInfo.isWindows && SystemInfo.is32Bit) {
        ourMappingFailedNotificationPosted = true;
        @SuppressWarnings("ThrowableResultOfMethodCallIgnored") String exceptionMessage = event.getThrowable().getMessage();
        String text = exceptionMessage + "<br>Possible cause: unable to allocate continuous memory chunk of necessary size.<br>" + "Reducing JVM maximum heap size (-Xmx) may help.";
        Notifications.Bus.notify(new Notification("Memory", "Memory Mapping Failed", text, NotificationType.WARNING), null);
    }
}
Also used : Notification(com.intellij.notification.Notification)

Example 80 with Notification

use of com.intellij.notification.Notification in project intellij-community by JetBrains.

the class ProjectLoadingErrorsNotifierImpl method fireNotifications.

private void fireNotifications() {
    final MultiMap<ConfigurationErrorType, ConfigurationErrorDescription> descriptionsMap = new MultiMap<>();
    synchronized (myLock) {
        if (myErrors.isEmpty())
            return;
        descriptionsMap.putAllValues(myErrors);
        myErrors.clear();
    }
    for (final ConfigurationErrorType type : descriptionsMap.keySet()) {
        final Collection<ConfigurationErrorDescription> descriptions = descriptionsMap.get(type);
        if (descriptions.isEmpty())
            continue;
        final String invalidElements = getInvalidElementsString(type, descriptions);
        final String errorText = ProjectBundle.message("error.message.configuration.cannot.load") + " " + invalidElements + " <a href=\"\">Details...</a>";
        Notifications.Bus.notify(new Notification("Project Loading Error", "Error Loading Project", errorText, NotificationType.ERROR, new NotificationListener() {

            @Override
            public void hyperlinkUpdate(@NotNull Notification notification, @NotNull HyperlinkEvent event) {
                final List<ConfigurationErrorDescription> validDescriptions = ContainerUtil.findAll(descriptions, errorDescription -> errorDescription.isValid());
                if (RemoveInvalidElementsDialog.showDialog(myProject, CommonBundle.getErrorTitle(), type, invalidElements, validDescriptions)) {
                    notification.expire();
                }
            }
        }), myProject);
    }
}
Also used : MultiMap(com.intellij.util.containers.MultiMap) HyperlinkEvent(javax.swing.event.HyperlinkEvent) ConfigurationErrorDescription(com.intellij.openapi.module.ConfigurationErrorDescription) ConfigurationErrorType(com.intellij.openapi.module.ConfigurationErrorType) NotNull(org.jetbrains.annotations.NotNull) Notification(com.intellij.notification.Notification) NotificationListener(com.intellij.notification.NotificationListener)

Aggregations

Notification (com.intellij.notification.Notification)114 HyperlinkEvent (javax.swing.event.HyperlinkEvent)34 NotNull (org.jetbrains.annotations.NotNull)34 NotificationListener (com.intellij.notification.NotificationListener)33 Project (com.intellij.openapi.project.Project)20 VirtualFile (com.intellij.openapi.vfs.VirtualFile)11 File (java.io.File)11 IOException (java.io.IOException)11 ProgressIndicator (com.intellij.openapi.progress.ProgressIndicator)8 Nullable (org.jetbrains.annotations.Nullable)8 Task (com.intellij.openapi.progress.Task)7 Module (com.intellij.openapi.module.Module)6 ExecutionException (com.intellij.execution.ExecutionException)4 NotificationAction (com.intellij.notification.NotificationAction)4 NotificationType (com.intellij.notification.NotificationType)4 AnActionEvent (com.intellij.openapi.actionSystem.AnActionEvent)4 Application (com.intellij.openapi.application.Application)3 Library (com.intellij.openapi.roots.libraries.Library)3 ActionCallback (com.intellij.openapi.util.ActionCallback)3 ArrayList (java.util.ArrayList)3