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