author | sla |
Tue, 19 Mar 2013 13:26:42 +0100 | |
changeset 18197 | ae73e4f50e08 |
parent 14342 | 8435a30053c1 |
child 17711 | 3cb70d5832aa |
permissions | -rw-r--r-- |
2 | 1 |
/* |
14342
8435a30053c1
7197491: update copyright year to match last edit in jdk8 jdk repository
alanb
parents:
12851
diff
changeset
|
2 |
* Copyright (c) 2006, 2012, Oracle and/or its affiliates. All rights reserved. |
2 | 3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 |
* |
|
5 |
* This code is free software; you can redistribute it and/or modify it |
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
|
5506 | 7 |
* published by the Free Software Foundation. Oracle designates this |
2 | 8 |
* particular file as subject to the "Classpath" exception as provided |
5506 | 9 |
* by Oracle in the LICENSE file that accompanied this code. |
2 | 10 |
* |
11 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
12 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
13 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
14 |
* version 2 for more details (a copy is included in the LICENSE file that |
|
15 |
* accompanied this code). |
|
16 |
* |
|
17 |
* You should have received a copy of the GNU General Public License version |
|
18 |
* 2 along with this work; if not, write to the Free Software Foundation, |
|
19 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
20 |
* |
|
5506 | 21 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
22 |
* or visit www.oracle.com if you need additional information or have any |
|
23 |
* questions. |
|
2 | 24 |
*/ |
25 |
||
26 |
package sun.tools.jconsole; |
|
27 |
||
28 |
import java.awt.*; |
|
29 |
import java.awt.event.*; |
|
30 |
import java.beans.PropertyVetoException; |
|
31 |
import java.net.URI; |
|
32 |
||
33 |
import javax.swing.*; |
|
34 |
import javax.swing.border.*; |
|
35 |
import javax.swing.event.*; |
|
36 |
||
12851
3334e1c781d0
7017818: NLS: JConsoleResources.java cannot be handled by translation team
egahlin
parents:
5506
diff
changeset
|
37 |
|
2 | 38 |
import static java.awt.BorderLayout.*; |
39 |
import static sun.tools.jconsole.Utilities.*; |
|
40 |
||
41 |
@SuppressWarnings("serial") |
|
42 |
public class AboutDialog extends InternalDialog { |
|
43 |
||
44 |
private static final Color textColor = new Color(87, 88, 89); |
|
45 |
private static final Color bgColor = new Color(232, 237, 241); |
|
46 |
private static final Color borderColor = Color.black; |
|
47 |
||
48 |
private Icon mastheadIcon = |
|
12851
3334e1c781d0
7017818: NLS: JConsoleResources.java cannot be handled by translation team
egahlin
parents:
5506
diff
changeset
|
49 |
new MastheadIcon(Messages.HELP_ABOUT_DIALOG_MASTHEAD_TITLE); |
2 | 50 |
|
51 |
private static AboutDialog aboutDialog; |
|
52 |
||
53 |
private JLabel statusBar; |
|
54 |
private Action closeAction; |
|
55 |
||
56 |
public AboutDialog(JConsole jConsole) { |
|
12851
3334e1c781d0
7017818: NLS: JConsoleResources.java cannot be handled by translation team
egahlin
parents:
5506
diff
changeset
|
57 |
super(jConsole, Messages.HELP_ABOUT_DIALOG_TITLE, false); |
2 | 58 |
|
12851
3334e1c781d0
7017818: NLS: JConsoleResources.java cannot be handled by translation team
egahlin
parents:
5506
diff
changeset
|
59 |
setAccessibleDescription(this, Messages.HELP_ABOUT_DIALOG_ACCESSIBLE_DESCRIPTION); |
2 | 60 |
setDefaultCloseOperation(HIDE_ON_CLOSE); |
61 |
setResizable(false); |
|
62 |
JComponent cp = (JComponent)getContentPane(); |
|
63 |
||
64 |
createActions(); |
|
65 |
||
66 |
JLabel mastheadLabel = new JLabel(mastheadIcon); |
|
67 |
setAccessibleName(mastheadLabel, |
|
12851
3334e1c781d0
7017818: NLS: JConsoleResources.java cannot be handled by translation team
egahlin
parents:
5506
diff
changeset
|
68 |
Messages.HELP_ABOUT_DIALOG_MASTHEAD_ACCESSIBLE_NAME); |
2 | 69 |
|
70 |
JPanel mainPanel = new TPanel(0, 0); |
|
71 |
mainPanel.add(mastheadLabel, NORTH); |
|
72 |
||
73 |
String jConsoleVersion = Version.getVersion(); |
|
74 |
String vmName = System.getProperty("java.vm.name"); |
|
75 |
String vmVersion = System.getProperty("java.vm.version"); |
|
12851
3334e1c781d0
7017818: NLS: JConsoleResources.java cannot be handled by translation team
egahlin
parents:
5506
diff
changeset
|
76 |
String urlStr = Messages.HELP_ABOUT_DIALOG_USER_GUIDE_LINK_URL; |
2 | 77 |
if (isBrowseSupported()) { |
78 |
urlStr = "<a style='color:#35556b' href=\"" + urlStr + "\">" + urlStr + "</a>"; |
|
79 |
} |
|
80 |
||
81 |
JPanel infoAndLogoPanel = new JPanel(new BorderLayout(10, 10)); |
|
82 |
infoAndLogoPanel.setBackground(bgColor); |
|
83 |
||
84 |
String colorStr = String.format("%06x", textColor.getRGB() & 0xFFFFFF); |
|
85 |
JEditorPane helpLink = new JEditorPane("text/html", |
|
86 |
"<html><font color=#"+ colorStr + ">" + |
|
12851
3334e1c781d0
7017818: NLS: JConsoleResources.java cannot be handled by translation team
egahlin
parents:
5506
diff
changeset
|
87 |
Resources.format(Messages.HELP_ABOUT_DIALOG_JCONSOLE_VERSION, jConsoleVersion) + |
3334e1c781d0
7017818: NLS: JConsoleResources.java cannot be handled by translation team
egahlin
parents:
5506
diff
changeset
|
88 |
"<p>" + Resources.format(Messages.HELP_ABOUT_DIALOG_JAVA_VERSION, (vmName +", "+ vmVersion)) + |
3334e1c781d0
7017818: NLS: JConsoleResources.java cannot be handled by translation team
egahlin
parents:
5506
diff
changeset
|
89 |
"<p>" + Resources.format(Messages.HELP_ABOUT_DIALOG_USER_GUIDE_LINK, urlStr) + |
2 | 90 |
"</html>"); |
91 |
helpLink.setOpaque(false); |
|
92 |
helpLink.setEditable(false); |
|
93 |
helpLink.setForeground(textColor); |
|
94 |
mainPanel.setBorder(BorderFactory.createLineBorder(borderColor)); |
|
95 |
infoAndLogoPanel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); |
|
96 |
helpLink.addHyperlinkListener(new HyperlinkListener() { |
|
97 |
public void hyperlinkUpdate(HyperlinkEvent e) { |
|
98 |
if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) { |
|
99 |
browse(e.getDescription()); |
|
100 |
} |
|
101 |
} |
|
102 |
}); |
|
103 |
infoAndLogoPanel.add(helpLink, NORTH); |
|
104 |
||
105 |
ImageIcon brandLogoIcon = new ImageIcon(getClass().getResource("resources/brandlogo.png")); |
|
106 |
JLabel brandLogo = new JLabel(brandLogoIcon, JLabel.LEADING); |
|
107 |
||
108 |
JButton closeButton = new JButton(closeAction); |
|
109 |
||
110 |
JPanel bottomPanel = new TPanel(0, 0); |
|
111 |
JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.TRAILING)); |
|
112 |
buttonPanel.setOpaque(false); |
|
113 |
||
114 |
mainPanel.add(infoAndLogoPanel, CENTER); |
|
115 |
cp.add(bottomPanel, SOUTH); |
|
116 |
||
117 |
infoAndLogoPanel.add(brandLogo, SOUTH); |
|
118 |
||
119 |
buttonPanel.setBorder(new EmptyBorder(2, 12, 2, 12)); |
|
120 |
buttonPanel.add(closeButton); |
|
121 |
bottomPanel.add(buttonPanel, NORTH); |
|
122 |
||
123 |
statusBar = new JLabel(" "); |
|
124 |
bottomPanel.add(statusBar, SOUTH); |
|
125 |
||
126 |
cp.add(mainPanel, NORTH); |
|
127 |
||
128 |
pack(); |
|
129 |
setLocationRelativeTo(jConsole); |
|
130 |
Utilities.updateTransparency(this); |
|
131 |
} |
|
132 |
||
133 |
public void showDialog() { |
|
134 |
statusBar.setText(" "); |
|
135 |
setVisible(true); |
|
136 |
try { |
|
137 |
// Bring to front of other dialogs |
|
138 |
setSelected(true); |
|
139 |
} catch (PropertyVetoException e) { |
|
140 |
// ignore |
|
141 |
} |
|
142 |
} |
|
143 |
||
144 |
private static AboutDialog getAboutDialog(JConsole jConsole) { |
|
145 |
if (aboutDialog == null) { |
|
146 |
aboutDialog = new AboutDialog(jConsole); |
|
147 |
} |
|
148 |
return aboutDialog; |
|
149 |
} |
|
150 |
||
151 |
static void showAboutDialog(JConsole jConsole) { |
|
152 |
getAboutDialog(jConsole).showDialog(); |
|
153 |
} |
|
154 |
||
155 |
static void browseUserGuide(JConsole jConsole) { |
|
12851
3334e1c781d0
7017818: NLS: JConsoleResources.java cannot be handled by translation team
egahlin
parents:
5506
diff
changeset
|
156 |
getAboutDialog(jConsole).browse(Messages.HELP_ABOUT_DIALOG_USER_GUIDE_LINK_URL); |
2 | 157 |
} |
158 |
||
159 |
static boolean isBrowseSupported() { |
|
160 |
return (Desktop.isDesktopSupported() && |
|
161 |
Desktop.getDesktop().isSupported(Desktop.Action.BROWSE)); |
|
162 |
} |
|
163 |
||
164 |
void browse(String urlStr) { |
|
165 |
try { |
|
166 |
Desktop.getDesktop().browse(new URI(urlStr)); |
|
167 |
} catch (Exception ex) { |
|
168 |
showDialog(); |
|
169 |
statusBar.setText(ex.getLocalizedMessage()); |
|
170 |
if (JConsole.isDebug()) { |
|
171 |
ex.printStackTrace(); |
|
172 |
} |
|
173 |
} |
|
174 |
} |
|
175 |
||
176 |
private void createActions() { |
|
12851
3334e1c781d0
7017818: NLS: JConsoleResources.java cannot be handled by translation team
egahlin
parents:
5506
diff
changeset
|
177 |
closeAction = new AbstractAction(Messages.CLOSE) { |
2 | 178 |
public void actionPerformed(ActionEvent ev) { |
179 |
setVisible(false); |
|
180 |
statusBar.setText(""); |
|
181 |
} |
|
182 |
}; |
|
183 |
} |
|
184 |
||
185 |
private static class TPanel extends JPanel { |
|
186 |
TPanel(int hgap, int vgap) { |
|
187 |
super(new BorderLayout(hgap, vgap)); |
|
188 |
setOpaque(false); |
|
189 |
} |
|
190 |
} |
|
191 |
} |