blob: f6c6b45ceb44086d356d6f647de9223730ad61fc (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
|
/*
* 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();
}
}
|