use of com.intellij.notification.Notification in project intellij-community by JetBrains.
the class AbstractLayoutCodeProcessor method handleFileTooBigException.
protected void handleFileTooBigException(Logger logger, FilesTooBigForDiffException e, @NotNull PsiFile file) {
logger.info("Error while calculating changed ranges for: " + file.getVirtualFile(), e);
if (!ApplicationManager.getApplication().isUnitTestMode()) {
Notification notification = new Notification(ApplicationBundle.message("reformat.changed.text.file.too.big.notification.groupId"), ApplicationBundle.message("reformat.changed.text.file.too.big.notification.title"), ApplicationBundle.message("reformat.changed.text.file.too.big.notification.text", file.getName()), NotificationType.INFORMATION);
notification.notify(file.getProject());
}
}
use of com.intellij.notification.Notification in project intellij-community by JetBrains.
the class ChangeListStorageImpl method notifyUser.
public static void notifyUser(String message) {
final String logFile = PathManager.getLogPath();
/*String createIssuePart = "<br>" +
"<br>" +
"Please attach log files from <a href=\"file\">" + logFile + "</a><br>" +
"to the <a href=\"url\">YouTrack issue</a>";*/
Notifications.Bus.notify(new Notification(Notifications.SYSTEM_MESSAGES_GROUP_ID, "Local History is broken", message, /*+ createIssuePart*/
NotificationType.ERROR, new NotificationListener() {
@Override
public void hyperlinkUpdate(@NotNull Notification notification, @NotNull HyperlinkEvent event) {
if (event.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
if ("url".equals(event.getDescription())) {
BrowserUtil.browse("http://youtrack.jetbrains.net/issue/IDEA-71270");
} else {
File file = new File(logFile);
ShowFilePathAction.openFile(file);
}
}
}
}), null);
}
use of com.intellij.notification.Notification in project intellij-community by JetBrains.
the class ModuleManagerComponent method showUnknownModuleTypeNotification.
@Override
protected void showUnknownModuleTypeNotification(@NotNull List<Module> modulesWithUnknownTypes) {
if (!ApplicationManager.getApplication().isHeadlessEnvironment() && !modulesWithUnknownTypes.isEmpty()) {
String message;
if (modulesWithUnknownTypes.size() == 1) {
message = ProjectBundle.message("module.unknown.type.single.error", modulesWithUnknownTypes.get(0).getName(), ModuleType.get(modulesWithUnknownTypes.get(0)).getId());
} else {
StringBuilder modulesBuilder = new StringBuilder();
for (final Module module : modulesWithUnknownTypes) {
modulesBuilder.append("<br>\"");
modulesBuilder.append(module.getName()).append("\" (type '").append(ModuleType.get(module).getId()).append("')");
}
modulesBuilder.append("<br>");
message = ProjectBundle.message("module.unknown.type.multiple.error", modulesBuilder.toString());
}
// it is not modal warning at all
//Messages.showWarningDialog(myProject, message, ProjectBundle.message("module.unknown.type.title"));
Notifications.Bus.notify(new Notification("Module Manager", ProjectBundle.message("module.unknown.type.title"), message, NotificationType.WARNING), myProject);
}
}
use of com.intellij.notification.Notification in project intellij-community by JetBrains.
the class InternetAttachSourceProvider method getActions.
@NotNull
@Override
public Collection<AttachSourcesAction> getActions(List<LibraryOrderEntry> orderEntries, @Nullable PsiFile psiFile) {
final VirtualFile jar = getJarByPsiFile(psiFile);
if (jar == null)
return Collections.emptyList();
final String jarName = jar.getNameWithoutExtension();
int index = jarName.lastIndexOf('-');
if (index == -1)
return Collections.emptyList();
final String version = jarName.substring(index + 1);
final String artifactId = jarName.substring(0, index);
if (!ARTIFACT_IDENTIFIER.matcher(version).matches() || !ARTIFACT_IDENTIFIER.matcher(artifactId).matches()) {
return Collections.emptyList();
}
final Set<Library> libraries = new HashSet<>();
for (LibraryOrderEntry orderEntry : orderEntries) {
ContainerUtil.addIfNotNull(libraries, orderEntry.getLibrary());
}
if (libraries.isEmpty())
return Collections.emptyList();
final String sourceFileName = jarName + "-sources.jar";
for (Library library : libraries) {
for (VirtualFile file : library.getFiles(OrderRootType.SOURCES)) {
if (file.getPath().contains(sourceFileName)) {
if (isRootInExistingFile(file)) {
// Sources already attached, but source-jar doesn't contain current class.
return Collections.emptyList();
}
}
}
}
final File libSourceDir = getLibrarySourceDir();
final File sourceFile = new File(libSourceDir, sourceFileName);
if (sourceFile.exists()) {
return Collections.singleton(new LightAttachSourcesAction() {
@Override
public String getName() {
return "Attach downloaded source";
}
@Override
public String getBusyText() {
return getName();
}
@Override
public ActionCallback perform(List<LibraryOrderEntry> orderEntriesContainingFile) {
attachSourceJar(sourceFile, libraries);
return ActionCallback.DONE;
}
});
}
return Collections.singleton(new LightAttachSourcesAction() {
@Override
public String getName() {
return "Download...";
}
@Override
public String getBusyText() {
return "Searching...";
}
@Override
public ActionCallback perform(List<LibraryOrderEntry> orderEntriesContainingFile) {
final Task task = new Task.Modal(psiFile.getProject(), "Searching source...", true) {
@Override
public void run(@NotNull final ProgressIndicator indicator) {
String artifactUrl = null;
SourceSearcher[] searchers = { new MavenCentralSourceSearcher(), new SonatypeSourceSearcher() };
for (SourceSearcher searcher : searchers) {
try {
artifactUrl = searcher.findSourceJar(indicator, artifactId, version, jar);
} catch (SourceSearchException e) {
LOG.warn(e);
showMessage("Downloading failed", e.getMessage(), NotificationType.ERROR);
continue;
}
if (artifactUrl != null)
break;
}
if (artifactUrl == null) {
showMessage("Sources not found", "Sources for '" + jarName + ".jar' not found", NotificationType.WARNING);
return;
}
if (!(libSourceDir.isDirectory() || libSourceDir.mkdirs())) {
showMessage("Downloading failed", "Failed to create directory to store sources: " + libSourceDir, NotificationType.ERROR);
return;
}
try {
File tmpDownload = FileUtil.createTempFile(libSourceDir, "download.", ".tmp", false, false);
HttpRequests.request(artifactUrl).saveToFile(tmpDownload, indicator);
if (!sourceFile.exists() && !tmpDownload.renameTo(sourceFile)) {
LOG.warn("Failed to rename file " + tmpDownload + " to " + sourceFileName);
}
} catch (IOException e) {
LOG.warn(e);
showMessage("Downloading failed", "Connection problem. See log for more details.", NotificationType.ERROR);
}
}
@Override
public void onSuccess() {
attachSourceJar(sourceFile, libraries);
}
private void showMessage(String title, String message, NotificationType notificationType) {
new Notification("Source searcher", title, message, notificationType).notify(getProject());
}
};
task.queue();
return ActionCallback.DONE;
}
});
}
use of com.intellij.notification.Notification in project intellij-community by JetBrains.
the class IvyAttachSourceProvider method getActions.
@NotNull
@Override
public Collection<AttachSourcesAction> getActions(List<LibraryOrderEntry> orderEntries, PsiFile psiFile) {
VirtualFile jar = getJarByPsiFile(psiFile);
if (jar == null)
return Collections.emptyList();
VirtualFile jarsDir = jar.getParent();
if (jarsDir == null || !jarsDir.getName().equals("jars"))
return Collections.emptyList();
VirtualFile artifactDir = jarsDir.getParent();
if (artifactDir == null)
return Collections.emptyList();
String jarNameWithoutExt = jar.getNameWithoutExtension();
String artifactName = artifactDir.getName();
if (!jarNameWithoutExt.startsWith(artifactName) || !jarNameWithoutExt.substring(artifactName.length()).startsWith("-")) {
return Collections.emptyList();
}
String version = jarNameWithoutExt.substring(artifactName.length() + 1);
//noinspection SpellCheckingInspection
VirtualFile propertiesFile = artifactDir.findChild("ivydata-" + version + ".properties");
if (propertiesFile == null)
return Collections.emptyList();
Library library = getLibraryFromOrderEntriesList(orderEntries);
if (library == null)
return Collections.emptyList();
String sourceFileName = artifactName + '-' + version + "-sources.jar";
VirtualFile sources = artifactDir.findChild("sources");
if (sources != null) {
VirtualFile srcFile = sources.findChild(sourceFileName);
if (srcFile != null) {
// File already downloaded.
VirtualFile jarRoot = JarFileSystem.getInstance().getJarRootForLocalFile(srcFile);
if (jarRoot == null || ArrayUtil.contains(jarRoot, (Object[]) library.getFiles(OrderRootType.SOURCES))) {
// Sources already attached.
return Collections.emptyList();
}
return Collections.singleton(new AttachExistingSourceAction(jarRoot, library, "Attache sources from Ivy repository"));
}
}
String url = extractUrl(propertiesFile, artifactName);
if (StringUtil.isEmptyOrSpaces(url))
return Collections.emptyList();
return Collections.singleton(new DownloadSourcesAction(psiFile.getProject(), "Downloading Ivy Sources", url) {
@Override
protected void storeFile(byte[] content) {
try {
VirtualFile existingSourcesFolder = sources;
if (existingSourcesFolder == null) {
existingSourcesFolder = artifactDir.createChildDirectory(this, "sources");
}
VirtualFile srcFile = existingSourcesFolder.createChildData(this, sourceFileName);
srcFile.setBinaryContent(content);
addSourceFile(JarFileSystem.getInstance().getJarRootForLocalFile(srcFile), library);
} catch (IOException e) {
String message = "Failed to save " + artifactDir.getPath() + "/sources/" + sourceFileName;
new Notification(myMessageGroupId, "IO Error", message, NotificationType.ERROR).notify(myProject);
LOG.warn(e);
}
}
});
}
Aggregations