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;
}
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;
}
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);
}
}
});
}
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);
}
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);
}
});
}
Aggregations