Search in sources :

Example 91 with Notification

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

the class SvnExecutableChecker method validateLocale.

@Nullable
private Notification validateLocale() throws SvnBindException {
    ProcessOutput versionOutput = getVersionClient().runCommand(false);
    Notification result = null;
    Matcher matcher = INVALID_LOCALE_WARNING_PATTERN.matcher(versionOutput.getStderr());
    if (matcher.find()) {
        LOG.info(matcher.group());
        result = new ExecutableNotValidNotification(prepareDescription(UIUtil.getHtmlBody(matcher.group()), false), NotificationType.WARNING);
    } else if (!isEnglishOutput(versionOutput.getStdout())) {
        LOG.info("\"svn --version\" command contains non-English output " + versionOutput.getStdout());
        result = new ExecutableNotValidNotification(prepareDescription(SvnBundle.message("non.english.locale.detected.warning"), false), NotificationType.WARNING);
    }
    return result;
}
Also used : Matcher(java.util.regex.Matcher) ProcessOutput(com.intellij.execution.process.ProcessOutput) Notification(com.intellij.notification.Notification) Nullable(org.jetbrains.annotations.Nullable)

Example 92 with Notification

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

the class SvnExecutableChecker method validate.

@Override
@Nullable
protected Notification validate(@NotNull String executable) {
    Notification result = createDefaultNotification();
    // Necessary executable path will be taken from settings while command execution
    final Version version = getConfiguredClientVersion();
    if (version != null) {
        try {
            result = validateVersion(version);
            if (result == null) {
                result = validateLocale();
            }
        } catch (Throwable e) {
            LOG.info(e);
        }
    }
    return result;
}
Also used : Version(com.intellij.openapi.util.Version) Notification(com.intellij.notification.Notification) Nullable(org.jetbrains.annotations.Nullable)

Example 93 with Notification

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

the class StudyProjectComponent method projectOpened.

@Override
public void projectOpened() {
    Course course = StudyTaskManager.getInstance(myProject).getCourse();
    // Check if user has javafx lib in his JDK. Now bundled JDK doesn't have this lib inside.
    if (StudyUtils.hasJavaFx()) {
        Platform.setImplicitExit(false);
    }
    if (course != null && !course.isAdaptive() && !course.isUpToDate()) {
        final Notification notification = new Notification("Update.course", "Course Updates", "Course is ready to <a href=\"update\">update</a>", NotificationType.INFORMATION, new NotificationListener() {

            @Override
            public void hyperlinkUpdate(@NotNull Notification notification, @NotNull HyperlinkEvent event) {
                FileEditorManagerEx.getInstanceEx(myProject).closeAllFiles();
                ProgressManager.getInstance().runProcessWithProgressSynchronously(() -> {
                    ProgressManager.getInstance().getProgressIndicator().setIndeterminate(true);
                    return execCancelable(() -> {
                        updateCourse();
                        return true;
                    });
                }, "Updating Course", true, myProject);
                EduUtils.synchronize();
                course.setUpdated();
            }
        });
        notification.notify(myProject);
    }
    StudyUtils.registerStudyToolWindow(course, myProject);
    StartupManager.getInstance(myProject).runWhenProjectIsInitialized(() -> ApplicationManager.getApplication().invokeLater((DumbAwareRunnable) () -> ApplicationManager.getApplication().runWriteAction((DumbAwareRunnable) () -> {
        Course course1 = StudyTaskManager.getInstance(myProject).getCourse();
        if (course1 != null) {
            UISettings instance = UISettings.getInstance();
            instance.setHideToolStripes(false);
            instance.fireUISettingsChanged();
            registerShortcuts();
            EduUsagesCollector.projectTypeOpened(course1.isAdaptive() ? EduNames.ADAPTIVE : EduNames.STUDY);
        }
    })));
    myBusConnection = ApplicationManager.getApplication().getMessageBus().connect();
    myBusConnection.subscribe(EditorColorsManager.TOPIC, new EditorColorsListener() {

        @Override
        public void globalSchemeChange(EditorColorsScheme scheme) {
            final StudyToolWindow toolWindow = StudyUtils.getStudyToolWindow(myProject);
            if (toolWindow != null) {
                toolWindow.updateFonts(myProject);
            }
        }
    });
}
Also used : EditorColorsListener(com.intellij.openapi.editor.colors.EditorColorsListener) HyperlinkEvent(javax.swing.event.HyperlinkEvent) UISettings(com.intellij.ide.ui.UISettings) EditorColorsScheme(com.intellij.openapi.editor.colors.EditorColorsScheme) StudyToolWindow(com.jetbrains.edu.learning.ui.StudyToolWindow) StudyProjectGenerator.flushCourse(com.jetbrains.edu.learning.courseGeneration.StudyProjectGenerator.flushCourse) Notification(com.intellij.notification.Notification) DumbAwareRunnable(com.intellij.openapi.project.DumbAwareRunnable) NotificationListener(com.intellij.notification.NotificationListener)

Example 94 with Notification

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

the class StudyProjectComponent method updateCourse.

private void updateCourse() {
    final Course currentCourse = StudyTaskManager.getInstance(myProject).getCourse();
    final CourseInfo info = CourseInfo.fromCourse(currentCourse);
    if (info == null)
        return;
    final File resourceDirectory = new File(currentCourse.getCourseDirectory());
    if (resourceDirectory.exists()) {
        FileUtil.delete(resourceDirectory);
    }
    final Course course = EduStepicConnector.getCourse(myProject, info);
    if (course == null)
        return;
    flushCourse(course);
    course.initCourse(false);
    StudyLanguageManager manager = StudyUtils.getLanguageManager(course);
    if (manager == null) {
        LOG.info("Study Language Manager is null for " + course.getLanguageById().getDisplayName());
        return;
    }
    final ArrayList<Lesson> updatedLessons = new ArrayList<>();
    int lessonIndex = 0;
    for (Lesson lesson : course.getLessons()) {
        lessonIndex += 1;
        Lesson studentLesson = currentCourse.getLesson(lesson.getId());
        final String lessonDirName = EduNames.LESSON + String.valueOf(lessonIndex);
        final File lessonDir = new File(myProject.getBasePath(), lessonDirName);
        if (!lessonDir.exists()) {
            final File fromLesson = new File(resourceDirectory, lessonDirName);
            try {
                FileUtil.copyDir(fromLesson, lessonDir);
            } catch (IOException e) {
                LOG.warn("Failed to copy lesson " + fromLesson.getPath());
            }
            lesson.setIndex(lessonIndex);
            lesson.initLesson(currentCourse, false);
            for (int i = 1; i <= lesson.getTaskList().size(); i++) {
                Task task = lesson.getTaskList().get(i - 1);
                task.setIndex(i);
            }
            updatedLessons.add(lesson);
            continue;
        }
        studentLesson.setIndex(lessonIndex);
        updatedLessons.add(studentLesson);
        int index = 0;
        final ArrayList<Task> tasks = new ArrayList<>();
        for (Task task : lesson.getTaskList()) {
            index += 1;
            final Task studentTask = studentLesson.getTask(task.getStepId());
            if (studentTask != null && StudyStatus.Solved.equals(studentTask.getStatus())) {
                studentTask.setIndex(index);
                tasks.add(studentTask);
                continue;
            }
            task.initTask(studentLesson, false);
            task.setIndex(index);
            final String taskDirName = EduNames.TASK + String.valueOf(index);
            final File toTask = new File(lessonDir, taskDirName);
            final String taskPath = FileUtil.join(resourceDirectory.getPath(), lessonDirName, taskDirName);
            final File taskDir = new File(taskPath);
            if (!taskDir.exists())
                return;
            final File[] taskFiles = taskDir.listFiles();
            if (taskFiles == null)
                continue;
            for (File fromFile : taskFiles) {
                copyFile(fromFile, new File(toTask, fromFile.getName()));
            }
            tasks.add(task);
        }
        studentLesson.updateTaskList(tasks);
    }
    currentCourse.setLessons(updatedLessons);
    final Notification notification = new Notification("Update.course", "Course update", "Current course is synchronized", NotificationType.INFORMATION);
    notification.notify(myProject);
}
Also used : ArrayList(java.util.ArrayList) IOException(java.io.IOException) CourseInfo(com.jetbrains.edu.learning.courseFormat.CourseInfo) Notification(com.intellij.notification.Notification) StudyProjectGenerator.flushCourse(com.jetbrains.edu.learning.courseGeneration.StudyProjectGenerator.flushCourse) VirtualFile(com.intellij.openapi.vfs.VirtualFile) File(java.io.File)

Example 95 with Notification

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

the class GitRebaseProcess method notifySuccess.

private void notifySuccess(@NotNull Map<GitRepository, GitSuccessfulRebase> successful, final MultiMap<GitRepository, GitRebaseUtils.CommitInfo> skippedCommits) {
    String rebasedBranch = getCommonCurrentBranchNameIfAllTheSame(myRebaseSpec.getAllRepositories());
    List<SuccessType> successTypes = map(successful.values(), GitSuccessfulRebase::getSuccessType);
    SuccessType commonType = getItemIfAllTheSame(successTypes, SuccessType.REBASED);
    GitRebaseParams params = myRebaseSpec.getParams();
    String baseBranch = params == null ? null : notNull(params.getNewBase(), params.getUpstream());
    if ("HEAD".equals(baseBranch)) {
        baseBranch = getItemIfAllTheSame(myRebaseSpec.getInitialBranchNames().values(), baseBranch);
    }
    String message = commonType.formatMessage(rebasedBranch, baseBranch, params != null && params.getBranch() != null);
    message += mentionSkippedCommits(skippedCommits);
    myNotifier.notifyMinorInfo("Rebase Successful", message, new NotificationListener.Adapter() {

        @Override
        protected void hyperlinkActivated(@NotNull Notification notification, @NotNull HyperlinkEvent e) {
            handlePossibleCommitLinks(e.getDescription(), skippedCommits);
        }
    });
}
Also used : HyperlinkEvent(javax.swing.event.HyperlinkEvent) GitRebaseParams(git4idea.branch.GitRebaseParams) SuccessType(git4idea.rebase.GitSuccessfulRebase.SuccessType) 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