1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
|
21 |
|
package jalview.gui; |
22 |
|
|
23 |
|
import jalview.util.MessageManager; |
24 |
|
|
25 |
|
import java.awt.FlowLayout; |
26 |
|
import java.awt.Font; |
27 |
|
|
28 |
|
import javax.swing.BoxLayout; |
29 |
|
import javax.swing.JButton; |
30 |
|
import javax.swing.JComponent; |
31 |
|
import javax.swing.JLabel; |
32 |
|
import javax.swing.JPanel; |
33 |
|
import javax.swing.JTextField; |
34 |
|
|
35 |
|
|
36 |
|
|
37 |
|
|
|
|
| 0% |
Uncovered Elements: 31 (31) |
Complexity: 7 |
Complexity Density: 0.3 |
|
38 |
|
public class EditNameDialog |
39 |
|
{ |
40 |
|
private static final Font COURIER_12 = new Font("Courier", Font.PLAIN, |
41 |
|
12); |
42 |
|
JTextField id; |
43 |
|
|
44 |
|
JTextField description; |
45 |
|
|
46 |
|
JButton ok = new JButton(MessageManager.getString("action.accept")); |
47 |
|
|
48 |
|
JButton cancel = new JButton(MessageManager.getString("action.cancel")); |
49 |
|
|
50 |
|
private JPanel panel; |
51 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
52 |
0 |
public String getName()... |
53 |
|
{ |
54 |
0 |
return id.getText(); |
55 |
|
} |
56 |
|
|
|
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
57 |
0 |
public String getDescription()... |
58 |
|
{ |
59 |
0 |
if (description.getText().length() < 1) |
60 |
|
{ |
61 |
0 |
return null; |
62 |
|
} |
63 |
|
else |
64 |
|
{ |
65 |
0 |
return description.getText(); |
66 |
|
} |
67 |
|
} |
68 |
|
|
69 |
|
|
70 |
|
|
71 |
|
|
72 |
|
@param |
73 |
|
@param |
74 |
|
@param |
75 |
|
@param |
76 |
|
|
|
|
| 0% |
Uncovered Elements: 19 (19) |
Complexity: 3 |
Complexity Density: 0.18 |
|
77 |
0 |
public EditNameDialog(String name, String desc, String label1,... |
78 |
|
String label2) |
79 |
|
{ |
80 |
0 |
panel = new JPanel(); |
81 |
0 |
panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS)); |
82 |
0 |
JPanel namePanel = new JPanel(new FlowLayout(FlowLayout.RIGHT)); |
83 |
0 |
JPanel descriptionPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT)); |
84 |
0 |
panel.add(namePanel); |
85 |
0 |
panel.add(descriptionPanel); |
86 |
|
|
87 |
0 |
JLabel nameLabel = new JLabel(label1); |
88 |
0 |
nameLabel.setFont(COURIER_12); |
89 |
0 |
namePanel.add(nameLabel); |
90 |
|
|
91 |
0 |
id = new JTextField(name, 40); |
92 |
0 |
namePanel.add(id); |
93 |
|
|
94 |
0 |
description = new JTextField(desc, 40); |
95 |
|
|
96 |
|
|
97 |
|
|
98 |
|
|
99 |
0 |
if (desc != null || label2 != null) |
100 |
|
{ |
101 |
0 |
JLabel descLabel = new JLabel(label2); |
102 |
0 |
descLabel.setFont(COURIER_12); |
103 |
0 |
descriptionPanel.add(descLabel); |
104 |
0 |
descriptionPanel.add(description); |
105 |
|
} |
106 |
|
} |
107 |
|
|
108 |
|
|
109 |
|
|
110 |
|
|
111 |
|
@param |
112 |
|
|
|
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
113 |
0 |
public void showDialog(JComponent parent, String title,... |
114 |
|
Runnable action) |
115 |
|
{ |
116 |
0 |
Object[] options = new Object[] { MessageManager.getString("action.ok"), |
117 |
|
MessageManager.getString("action.cancel") }; |
118 |
0 |
JvOptionPane.newOptionDialog(parent).setResponseHandler(0, action) |
119 |
|
.showInternalDialog(panel, title, |
120 |
|
JvOptionPane.YES_NO_CANCEL_OPTION, |
121 |
|
JvOptionPane.PLAIN_MESSAGE, null, options, |
122 |
|
MessageManager.getString("action.ok")); |
123 |
|
} |
124 |
|
} |