log skeleton generation errors and don't show it to user

This commit is contained in:
Ekaterina Tuzova
2014-08-16 15:01:05 +04:00
parent 7dc2967de5
commit f27cd2c1b7
3 changed files with 22 additions and 169 deletions
@@ -20,7 +20,6 @@ import com.google.common.collect.Lists;
import com.intellij.codeInsight.daemon.DaemonCodeAnalyzer;
import com.intellij.execution.ExecutionException;
import com.intellij.notification.Notification;
import com.intellij.notification.NotificationListener;
import com.intellij.notification.NotificationType;
import com.intellij.notification.Notifications;
import com.intellij.openapi.application.ApplicationManager;
@@ -35,6 +34,7 @@ import com.intellij.openapi.util.Pair;
import com.intellij.openapi.util.Ref;
import com.intellij.openapi.util.SystemInfo;
import com.intellij.openapi.util.io.FileUtil;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.openapi.vfs.JarFileSystem;
import com.intellij.openapi.vfs.LocalFileSystem;
import com.intellij.openapi.vfs.VirtualFile;
@@ -58,7 +58,6 @@ import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import javax.swing.event.HyperlinkEvent;
import java.awt.*;
import java.io.*;
import java.util.*;
@@ -164,18 +163,27 @@ public class PySkeletonRefresher {
else {
message = PyBundle.message("sdk.errorlog.$0.mods.fail.in.$1.sdks", module_errors, errors.size());
}
Notifications.Bus.notify(
new Notification(
PythonSdkType.SKELETONS_TOPIC, PyBundle.message("sdk.some.skeletons.failed"), message,
NotificationType.WARNING,
new NotificationListener() {
@Override
public void hyperlinkUpdate(@NotNull Notification notification, @NotNull HyperlinkEvent event) {
new SkeletonErrorsDialog(errors, failedSdks).setVisible(true);
}
}
)
);
logErrors(errors, failedSdks, message);
}
}
private static void logErrors(@NotNull final Map<String, List<String>> errors, @NotNull final List<String> failedSdks,
@NotNull final String message) {
LOG.warn(PyBundle.message("sdk.some.skeletons.failed"));
LOG.warn(message);
if (failedSdks.size() > 0) {
LOG.warn(PyBundle.message("sdk.error.dialog.failed.sdks"));
LOG.warn(StringUtil.join(failedSdks, ", "));
}
if (errors.size() > 0) {
LOG.warn(PyBundle.message("sdk.error.dialog.failed.modules"));
for (String sdkName : errors.keySet()) {
for (String moduleName : errors.get(sdkName)) {
LOG.warn(moduleName);
}
}
}
}
@@ -1,61 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="com.jetbrains.python.sdk.skeletons.SkeletonErrorsDialog">
<grid id="cbd77" binding="contentPane" layout-manager="GridLayoutManager" row-count="1" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="10" left="10" bottom="10" right="10"/>
<constraints>
<xy x="48" y="54" width="436" height="409"/>
</constraints>
<properties/>
<border type="none"/>
<children>
<grid id="94766" layout-manager="GridLayoutManager" row-count="2" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="1" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
<border type="none"/>
<children>
<grid id="9538f" layout-manager="GridLayoutManager" row-count="1" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
<border type="none"/>
<children>
<component id="e7465" class="javax.swing.JButton" binding="buttonOK">
<constraints>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="OK"/>
</properties>
</component>
</children>
</grid>
<scrollpane id="d5fbd" class="com.intellij.ui.components.JBScrollPane" binding="myScroller">
<constraints>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="7" hsize-policy="7" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
<border type="none"/>
<children>
<component id="10d56" class="javax.swing.JTextPane" binding="myMessagePane">
<constraints/>
<properties>
<editable value="false"/>
<enabled value="true"/>
</properties>
<clientProperties>
<JEditorPane.honorDisplayProperties class="java.lang.Boolean" value="true"/>
<caretAspectRatio class="java.lang.Float" value="0.04"/>
</clientProperties>
</component>
</children>
</scrollpane>
</children>
</grid>
</children>
</grid>
</form>
@@ -1,94 +0,0 @@
/*
* Copyright 2000-2013 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.jetbrains.python.sdk.skeletons;
import com.intellij.ui.components.JBScrollPane;
import com.jetbrains.python.PyBundle;
import javax.swing.*;
import javax.swing.border.EmptyBorder;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.List;
import java.util.Map;
public class SkeletonErrorsDialog extends JDialog {
private JPanel contentPane;
private JButton buttonOK;
private JBScrollPane myScroller;
private JTextPane myMessagePane;
public SkeletonErrorsDialog(Map<String, List<String>> errors, List<String> failed_sdks) {
setContentPane(contentPane);
setModal(true);
getRootPane().setDefaultButton(buttonOK);
buttonOK.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
dispose();
}
});
// fill data
myMessagePane.setContentType("text/html");
myMessagePane.setBorder(new EmptyBorder(0, 0, 0, 0));
StringBuilder sb = new StringBuilder("<html><body style='margin: 4pt;' ");
final Color foreground = getParent().getForeground();
final Color background = getParent().getBackground();
if (foreground != null && background != null) {
sb.append("text='").append(getHTMLColor(foreground)).append("' ");
sb.append("bgcolor='").append(getHTMLColor(background)).append("'");
}
sb.append(">");
if (failed_sdks.size() > 0) {
sb.append("<h1>").append(PyBundle.message("sdk.error.dialog.failed.sdks")).append("</h1>");
sb.append("<ul>");
for (String sdk_name : failed_sdks) {
sb.append("<li>").append(sdk_name).append("</li>");
}
sb.append("</ul><br>");
}
if (errors.size() > 0) {
sb.append("<h1>").append(PyBundle.message("sdk.error.dialog.failed.modules")).append("</h1>");
for (String sdk_name : errors.keySet()) {
sb.append("<b>").append(sdk_name).append("</b><br>");
sb.append("<ul>");
for (String module_name : errors.get(sdk_name)) {
sb.append("<li>").append(module_name).append("</li>");
}
sb.append("</ul>");
}
sb.append(PyBundle.message("sdk.error.dialog.were.blacklisted"));
}
sb.append("</body></html>");
myMessagePane.setText(sb.toString());
setTitle(PyBundle.message("sdk.error.dialog.problems"));
pack();
setLocationRelativeTo(getParent());
}
private static String getHTMLColor(Color color) {
StringBuilder sb = new StringBuilder("#");
sb.append(Integer.toHexString(color.getRGB() & 0xffffff));
return sb.toString();
}
}