author | chegar |
Sun, 17 Aug 2014 15:54:13 +0100 | |
changeset 25859 | 3317bb8137f4 |
parent 23010 | jdk/src/share/classes/sun/tools/jconsole/AboutDialog.java@6dadb192ad81 |
child 36011 | 77231de79e04 |
permissions | -rw-r--r-- |
2 | 1 |
/* |
23010
6dadb192ad81
8029235: Update copyright year to match last edit in jdk8 jdk repository for 2013
lana
parents:
17711
diff
changeset
|
2 |
* Copyright (c) 2006, 2013, 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 |
||
17711
3cb70d5832aa
8014048: Online user guide of jconsole points incorrect link
nloodin
parents:
14342
diff
changeset
|
37 |
import static sun.misc.Version.jdkMinorVersion; |
12851
3334e1c781d0
7017818: NLS: JConsoleResources.java cannot be handled by translation team
egahlin
parents:
5506
diff
changeset
|
38 |
|
2 | 39 |
import static java.awt.BorderLayout.*; |
40 |
import static sun.tools.jconsole.Utilities.*; |
|
41 |
||
42 |
@SuppressWarnings("serial") |
|
43 |
public class AboutDialog extends InternalDialog { |
|
44 |
||
45 |
private static final Color textColor = new Color(87, 88, 89); |
|
46 |
private static final Color bgColor = new Color(232, 237, 241); |
|
47 |
private static final Color borderColor = Color.black; |
|
48 |
||
49 |
private Icon mastheadIcon = |
|
12851
3334e1c781d0
7017818: NLS: JConsoleResources.java cannot be handled by translation team
egahlin
parents:
5506
diff
changeset
|
50 |
new MastheadIcon(Messages.HELP_ABOUT_DIALOG_MASTHEAD_TITLE); |
2 | 51 |
|
52 |
private static AboutDialog aboutDialog; |
|
53 |
||
54 |
private JLabel statusBar; |
|
55 |
private Action closeAction; |
|
56 |
||
57 |
public AboutDialog(JConsole jConsole) { |
|
12851
3334e1c781d0
7017818: NLS: JConsoleResources.java cannot be handled by translation team
egahlin
parents:
5506
diff
changeset
|
58 |
super(jConsole, Messages.HELP_ABOUT_DIALOG_TITLE, false); |
2 | 59 |
|
12851
3334e1c781d0
7017818: NLS: JConsoleResources.java cannot be handled by translation team
egahlin
parents:
5506
diff
changeset
|
60 |
setAccessibleDescription(this, Messages.HELP_ABOUT_DIALOG_ACCESSIBLE_DESCRIPTION); |
2 | 61 |
setDefaultCloseOperation(HIDE_ON_CLOSE); |
62 |
setResizable(false); |
|
63 |
JComponent cp = (JComponent)getContentPane(); |
|
64 |
||
65 |
createActions(); |
|
66 |
||
67 |
JLabel mastheadLabel = new JLabel(mastheadIcon); |
|
68 |
setAccessibleName(mastheadLabel, |
|
12851
3334e1c781d0
7017818: NLS: JConsoleResources.java cannot be handled by translation team
egahlin
parents:
5506
diff
changeset
|
69 |
Messages.HELP_ABOUT_DIALOG_MASTHEAD_ACCESSIBLE_NAME); |
2 | 70 |
|
71 |
JPanel mainPanel = new TPanel(0, 0); |
|
72 |
mainPanel.add(mastheadLabel, NORTH); |
|
73 |
||
74 |
String jConsoleVersion = Version.getVersion(); |
|
75 |
String vmName = System.getProperty("java.vm.name"); |
|
76 |
String vmVersion = System.getProperty("java.vm.version"); |
|
17711
3cb70d5832aa
8014048: Online user guide of jconsole points incorrect link
nloodin
parents:
14342
diff
changeset
|
77 |
String urlStr = getOnlineDocUrl(); |
2 | 78 |
if (isBrowseSupported()) { |
79 |
urlStr = "<a style='color:#35556b' href=\"" + urlStr + "\">" + urlStr + "</a>"; |
|
80 |
} |
|
81 |
||
82 |
JPanel infoAndLogoPanel = new JPanel(new BorderLayout(10, 10)); |
|
83 |
infoAndLogoPanel.setBackground(bgColor); |
|
84 |
||
85 |
String colorStr = String.format("%06x", textColor.getRGB() & 0xFFFFFF); |
|
86 |
JEditorPane helpLink = new JEditorPane("text/html", |
|
87 |
"<html><font color=#"+ colorStr + ">" + |
|
12851
3334e1c781d0
7017818: NLS: JConsoleResources.java cannot be handled by translation team
egahlin
parents:
5506
diff
changeset
|
88 |
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
|
89 |
"<p>" + Resources.format(Messages.HELP_ABOUT_DIALOG_JAVA_VERSION, (vmName +", "+ vmVersion)) + |
17711
3cb70d5832aa
8014048: Online user guide of jconsole points incorrect link
nloodin
parents:
14342
diff
changeset
|
90 |
"<p>" + urlStr + "</html>"); |
2 | 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) { |
|
17711
3cb70d5832aa
8014048: Online user guide of jconsole points incorrect link
nloodin
parents:
14342
diff
changeset
|
156 |
getAboutDialog(jConsole).browse(getOnlineDocUrl()); |
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 |
||
17711
3cb70d5832aa
8014048: Online user guide of jconsole points incorrect link
nloodin
parents:
14342
diff
changeset
|
185 |
private static String getOnlineDocUrl() { |
3cb70d5832aa
8014048: Online user guide of jconsole points incorrect link
nloodin
parents:
14342
diff
changeset
|
186 |
String version = Integer.toString(jdkMinorVersion()); |
3cb70d5832aa
8014048: Online user guide of jconsole points incorrect link
nloodin
parents:
14342
diff
changeset
|
187 |
return Resources.format(Messages.HELP_ABOUT_DIALOG_USER_GUIDE_LINK_URL, |
3cb70d5832aa
8014048: Online user guide of jconsole points incorrect link
nloodin
parents:
14342
diff
changeset
|
188 |
version); |
3cb70d5832aa
8014048: Online user guide of jconsole points incorrect link
nloodin
parents:
14342
diff
changeset
|
189 |
} |
3cb70d5832aa
8014048: Online user guide of jconsole points incorrect link
nloodin
parents:
14342
diff
changeset
|
190 |
|
2 | 191 |
private static class TPanel extends JPanel { |
192 |
TPanel(int hgap, int vgap) { |
|
193 |
super(new BorderLayout(hgap, vgap)); |
|
194 |
setOpaque(false); |
|
195 |
} |
|
196 |
} |
|
197 |
} |