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
|
package org.openslx.dozmod.gui.window;
import java.awt.Frame;
import java.awt.GridBagConstraints;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.BorderFactory;
import javax.swing.Box;
import javax.swing.BoxLayout;
import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextArea;
import org.openslx.dozmod.Branding;
import org.openslx.dozmod.gui.Gui;
import org.openslx.dozmod.gui.helper.GridManager;
import org.openslx.dozmod.gui.helper.I18n;
import org.openslx.dozmod.gui.helper.UiFeedback;
import org.openslx.dozmod.util.DesktopEnvironment;
import org.openslx.dozmod.util.DesktopEnvironment.Link;
/**
* Class for showing window with button to open registration page in browser.
*/
public class BwIdmLinkWindow extends JDialog implements UiFeedback {
/**
* Version for serialization.
*/
private static final long serialVersionUID = 2120246234601011414L;
protected JButton btnLink;
protected JButton OkButton;
/**
* Don't use this, use static function open instead!
*/
public BwIdmLinkWindow(Frame modalParent) {
super(modalParent, I18n.WINDOW.getString("BwIdmLink.Dialog.title"),
modalParent != null ? ModalityType.APPLICATION_MODAL : ModalityType.MODELESS);
final BwIdmLinkWindow me = this;
setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
// panel for the border.
JPanel contentPanel = new JPanel();
contentPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
add(contentPanel);
GridManager grid = new GridManager(contentPanel, 1);
// infotext
JLabel infoLabel = new JLabel(I18n.WINDOW.getString("BwIdmLink.Label.info.text", Branding.getServiceName()));
infoLabel.setBorder(BorderFactory.createTitledBorder(I18n.WINDOW.getString("BwIdmLink.Label.info.title")));
grid.add(infoLabel).fill(true, true).expand(true, true).anchor(GridBagConstraints.CENTER);
grid.nextRow();
// button for opening the link
btnLink = new JButton(I18n.WINDOW.getString("BwIdmLink.Button.link.text"));
btnLink.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
DesktopEnvironment.openWebpage(Link.REGISTER_BWIDM);
}
});
grid.add(btnLink).anchor(GridBagConstraints.CENTER).fill(false, false).expand(false, false);
grid.nextRow();
// text area for copying the link if needed.
JTextArea linkText = new JTextArea(Link.REGISTER_BWIDM.uri.toString());
linkText.setEditable(false);
grid.add(linkText).anchor(GridBagConstraints.CENTER).fill(false, false).expand(false, false);
grid.nextRow();
// Ok button on the bottom
JPanel bottomPane = new JPanel();
bottomPane.setLayout(new BoxLayout(bottomPane, BoxLayout.LINE_AXIS));
bottomPane.add(Box.createHorizontalGlue());
// close/ok button
OkButton = new JButton(I18n.WINDOW.getString("BwIdmLink.Button.ok.text"));
OkButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
me.dispose();
}
});
bottomPane.add(OkButton);
grid.add(bottomPane).fill(true, false).expand(true, false);
grid.nextRow();
grid.finish(false);
// Scale window with font
setMinimumSize(Gui.getScaledDimension(500, 250));
setPreferredSize(getMinimumSize());
setLocationRelativeTo(modalParent);
}
/**
* Open a new window for showing the registration page in browser.
*
* @param modalParent the parent of the window.
*/
public static void open(Frame modalParent) {
new BwIdmLinkWindow(modalParent).setVisible(true);
}
@Override
public boolean wantConfirmQuit() {
return false;
}
@Override
public void escapePressed() {
dispose();
}
}
|