This repository has been archived by the owner on Feb 9, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 227
/
AboutTab.java
178 lines (148 loc) · 5.83 KB
/
AboutTab.java
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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
/*
* PS3 Media Server, for streaming any medias to your PS3.
* Copyright (C) 2008 A.Brochard
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; version 2
* of the License only.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package net.pms.newgui;
import com.jgoodies.forms.builder.PanelBuilder;
import com.jgoodies.forms.layout.CellConstraints;
import com.jgoodies.forms.layout.FormLayout;
import net.pms.Messages;
import net.pms.PMS;
import net.pms.util.PropertiesUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.imageio.ImageIO;
import javax.swing.*;
import java.awt.*;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.awt.image.BufferedImage;
import java.io.IOException;
public class AboutTab {
private static final Logger LOGGER = LoggerFactory.getLogger(AboutTab.class);
private ImagePanel imagePanel;
private JLabel jl;
private JProgressBar jpb;
public JProgressBar getJpb() {
return jpb;
}
public JLabel getJl() {
return jl;
}
public ImagePanel getImagePanel() {
return imagePanel;
}
public JComponent build() {
FormLayout layout = new FormLayout(
"0:grow, pref, 0:grow",
"pref, 3dlu, pref, 3dlu, pref, 12dlu, pref, 3dlu, pref, 3dlu, pref, 3dlu, pref, 3dlu, p, 3dlu, p");
PanelBuilder builder = new PanelBuilder(layout);
builder.setDefaultDialogBorder();
builder.setOpaque(true);
CellConstraints cc = new CellConstraints();
String projectName = PropertiesUtil.getProjectProperties().get("project.name");
final LinkMouseListener pms3Link = new LinkMouseListener(projectName + " " + PMS.getVersion(),
"http://www.ps3mediaserver.org/");
JLabel lPms3Link = builder.addLabel(pms3Link.getLabel(), cc.xy(2, 1, "center, fill"));
lPms3Link.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
lPms3Link.addMouseListener(pms3Link);
// Create a build name from the available git properties
String commitId = PropertiesUtil.getProjectProperties().get("git.commit.id");
String commitTime = PropertiesUtil.getProjectProperties().get("git.commit.time");
String shortCommitId = commitId.substring(0, 9);
String commitUrl = "https://github.com/ps3mediaserver/ps3mediaserver/commit/" + commitId;
String buildLabel = Messages.getString("LinksTab.6") + " " + shortCommitId + " (" + commitTime + ")";
final LinkMouseListener commitLink = new LinkMouseListener(buildLabel, commitUrl);
JLabel lCommitLink = builder.addLabel(commitLink.getLabel(), cc.xy(2, 3, "center, fill"));
lCommitLink.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
lCommitLink.addMouseListener(commitLink);
imagePanel = buildImagePanel();
builder.add(imagePanel, cc.xy(2, 5, "center, fill"));
builder.addLabel(Messages.getString("LinksTab.5"), cc.xy(2, 7, "center, fill"));
final LinkMouseListener ffmpegLink = new LinkMouseListener("FFmpeg",
"http://ffmpeg.mplayerhq.hu");
JLabel lFfmpegLink = builder.addLabel(ffmpegLink.getLabel(), cc.xy(2, 9, "center, fill"));
lFfmpegLink.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
lFfmpegLink.addMouseListener(ffmpegLink);
final LinkMouseListener mplayerLink = new LinkMouseListener("MPlayer",
"http://www.mplayerhq.hu");
JLabel lMplayerLink = builder.addLabel(mplayerLink.getLabel(), cc.xy(2, 11, "center, fill"));
lMplayerLink.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
lMplayerLink.addMouseListener(mplayerLink);
final LinkMouseListener vlcLink = new LinkMouseListener("VLC media player",
"http://www.videolan.org/vlc/");
JLabel lVlcLink = builder.addLabel(vlcLink.getLabel(), cc.xy(2, 13, "center, fill"));
lVlcLink.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
lVlcLink.addMouseListener(vlcLink);
final LinkMouseListener mediaInfoLink = new LinkMouseListener("MediaInfo",
"http://mediainfo.sourceforge.net/en");
JLabel lMediaInfoLink = builder.addLabel(mediaInfoLink.getLabel(), cc.xy(2, 15, "center, fill"));
lMediaInfoLink.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
lMediaInfoLink.addMouseListener(mediaInfoLink);
JScrollPane scrollPane = new JScrollPane(builder.getPanel());
scrollPane.setBorder(BorderFactory.createEmptyBorder());
return scrollPane;
}
private static class LinkMouseListener implements MouseListener {
private final String name;
private final String link;
public LinkMouseListener(String n, String l) {
name = n;
link = l;
}
public String getLabel() {
final StringBuilder sb = new StringBuilder();
sb.append("<html>");
sb.append("<a href=\"");
sb.append(link);
sb.append("\">");
sb.append(name);
sb.append("</a>");
sb.append("</html>");
return sb.toString();
}
@Override
public void mouseClicked(MouseEvent e) {
try {
PMS.get().getRegistry().browseURI(link);
} catch (Exception e1) {
LOGGER.debug("Caught exception", e1);
}
}
@Override
public void mouseEntered(MouseEvent e) {
}
@Override
public void mouseExited(MouseEvent e) {
}
@Override
public void mousePressed(MouseEvent e) {
}
@Override
public void mouseReleased(MouseEvent e) {
}
}
public ImagePanel buildImagePanel() {
BufferedImage bi = null;
try {
bi = ImageIO.read(LooksFrame.class.getResourceAsStream("/resources/images/logo.png"));
} catch (IOException e) {
LOGGER.debug("Caught exception", e);
}
return new ImagePanel(bi);
}
}