| 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 java.awt.FlowLayout; |
| 24 |
|
import java.awt.Font; |
| 25 |
|
|
| 26 |
|
import javax.swing.BoxLayout; |
| 27 |
|
import javax.swing.JButton; |
| 28 |
|
import javax.swing.JComponent; |
| 29 |
|
import javax.swing.JLabel; |
| 30 |
|
import javax.swing.JPanel; |
| 31 |
|
import javax.swing.JTextField; |
| 32 |
|
|
| 33 |
|
import jalview.util.MessageManager; |
| 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 |
|
|
| 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: 17 (17) |
Complexity: 3 |
Complexity Density: 0.2 |
|
| 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 |
|
|
| 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 |
|
|
| 104 |
0 |
descriptionPanel.add(descLabel); |
| 105 |
0 |
descriptionPanel.add(description); |
| 106 |
|
} |
| 107 |
|
} |
| 108 |
|
|
| 109 |
|
|
| 110 |
|
|
| 111 |
|
|
| 112 |
|
@param |
| 113 |
|
|
| |
|
| 0% |
Uncovered Elements: 4 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
|
| 114 |
0 |
public void showDialog(JComponent parent, String title, Runnable action)... |
| 115 |
|
{ |
| 116 |
0 |
String ok = MessageManager.getString("action.ok"); |
| 117 |
0 |
String cancel = MessageManager.getString("action.cancel"); |
| 118 |
0 |
String[] options = new String[] { ok, cancel }; |
| 119 |
|
|
| 120 |
0 |
JvOptionPane.newOptionDialog(parent) |
| 121 |
|
.setResponseHandler(JvOptionPane.OK_OPTION, action) |
| 122 |
|
.showInternalDialog(panel, title, JvOptionPane.OK_CANCEL_OPTION, |
| 123 |
|
JvOptionPane.PLAIN_MESSAGE, null, options, ok); |
| 124 |
|
|
| 125 |
|
|
| 126 |
|
|
| 127 |
|
|
| 128 |
|
|
| 129 |
|
|
| 130 |
|
|
| 131 |
|
|
| 132 |
|
|
| 133 |
|
} |
| 134 |
|
} |