| 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.Container; |
| 26 |
|
import java.awt.Dimension; |
| 27 |
|
import java.awt.Rectangle; |
| 28 |
|
import java.awt.event.ActionEvent; |
| 29 |
|
import java.awt.event.ActionListener; |
| 30 |
|
import java.awt.event.WindowAdapter; |
| 31 |
|
import java.awt.event.WindowEvent; |
| 32 |
|
|
| 33 |
|
import javax.swing.JButton; |
| 34 |
|
import javax.swing.JDialog; |
| 35 |
|
import javax.swing.JPanel; |
| 36 |
|
|
| 37 |
|
|
| 38 |
|
|
| 39 |
|
|
| 40 |
|
|
| 41 |
|
|
| 42 |
|
@author |
| 43 |
|
|
| 44 |
|
|
| |
|
| 61% |
Uncovered Elements: 16 (41) |
Complexity: 10 |
Complexity Density: 0.33 |
|
| 45 |
|
public abstract class JalviewDialog extends JPanel |
| 46 |
|
{ |
| 47 |
|
|
| 48 |
|
protected JDialog frame; |
| 49 |
|
|
| 50 |
|
protected JButton ok = new JButton(); |
| 51 |
|
|
| 52 |
|
protected JButton cancel = new JButton(); |
| 53 |
|
|
| 54 |
|
boolean block = false; |
| 55 |
|
|
| |
|
| 60% |
Uncovered Elements: 2 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
| 56 |
8 |
public void waitForInput()... |
| 57 |
|
{ |
| 58 |
8 |
if (!block) |
| 59 |
|
{ |
| 60 |
8 |
new Thread(new Runnable() |
| 61 |
|
{ |
| 62 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 63 |
8 |
@Override... |
| 64 |
|
public void run() |
| 65 |
|
{ |
| 66 |
8 |
frame.setVisible(true); |
| 67 |
|
} |
| 68 |
|
|
| 69 |
|
}).start(); |
| 70 |
|
} |
| 71 |
|
else |
| 72 |
|
{ |
| 73 |
0 |
frame.setVisible(true); |
| 74 |
|
} |
| 75 |
|
} |
| 76 |
|
|
| |
|
| 90% |
Uncovered Elements: 2 (20) |
Complexity: 2 |
Complexity Density: 0.11 |
|
| 77 |
8 |
protected void initDialogFrame(Container content, boolean modal,... |
| 78 |
|
boolean block, String title, int width, int height) |
| 79 |
|
{ |
| 80 |
|
|
| 81 |
8 |
frame = new JDialog(Desktop.instance, modal); |
| 82 |
8 |
frame.setTitle(title); |
| 83 |
8 |
if (Desktop.instance != null) |
| 84 |
|
{ |
| 85 |
8 |
Rectangle deskr = Desktop.instance.getBounds(); |
| 86 |
8 |
frame.setBounds(new Rectangle((int) (deskr.getCenterX() - width / 2), |
| 87 |
|
(int) (deskr.getCenterY() - height / 2), width, height)); |
| 88 |
|
} |
| 89 |
|
else |
| 90 |
|
{ |
| 91 |
0 |
frame.setSize(width, height); |
| 92 |
|
} |
| 93 |
8 |
int minWidth = width - 100; |
| 94 |
8 |
int minHeight = height - 100; |
| 95 |
8 |
frame.setMinimumSize(new Dimension(minWidth, minHeight)); |
| 96 |
8 |
frame.setContentPane(content); |
| 97 |
8 |
this.block = block; |
| 98 |
|
|
| 99 |
8 |
ok.setOpaque(false); |
| 100 |
8 |
ok.setText(MessageManager.getString("action.ok")); |
| 101 |
8 |
ok.addActionListener(new ActionListener() |
| 102 |
|
{ |
| |
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
| 103 |
0 |
@Override... |
| 104 |
|
public void actionPerformed(ActionEvent e) |
| 105 |
|
{ |
| 106 |
0 |
okPressed(); |
| 107 |
0 |
closeDialog(); |
| 108 |
|
} |
| 109 |
|
}); |
| 110 |
8 |
cancel.setOpaque(false); |
| 111 |
8 |
cancel.setText(MessageManager.getString("action.cancel")); |
| 112 |
8 |
cancel.addActionListener(new ActionListener() |
| 113 |
|
{ |
| |
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
| 114 |
0 |
@Override... |
| 115 |
|
public void actionPerformed(ActionEvent e) |
| 116 |
|
{ |
| 117 |
0 |
cancelPressed(); |
| 118 |
0 |
closeDialog(); |
| 119 |
|
} |
| 120 |
|
}); |
| 121 |
8 |
frame.addWindowListener(new WindowAdapter() |
| 122 |
|
{ |
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 123 |
0 |
@Override... |
| 124 |
|
public void windowClosing(WindowEvent e) |
| 125 |
|
{ |
| 126 |
|
|
| 127 |
0 |
closeDialog(); |
| 128 |
|
} |
| 129 |
|
}); |
| 130 |
|
} |
| 131 |
|
|
| 132 |
|
|
| 133 |
|
|
| 134 |
|
|
| |
|
| 0% |
Uncovered Elements: 3 (3) |
Complexity: 2 |
Complexity Density: 0.67 |
|
| 135 |
0 |
protected void closeDialog()... |
| 136 |
|
{ |
| 137 |
0 |
try |
| 138 |
|
{ |
| 139 |
0 |
raiseClosed(); |
| 140 |
0 |
frame.dispose(); |
| 141 |
|
} catch (Exception ex) |
| 142 |
|
{ |
| 143 |
|
} |
| 144 |
|
} |
| 145 |
|
|
| 146 |
|
protected abstract void raiseClosed(); |
| 147 |
|
|
| 148 |
|
protected abstract void okPressed(); |
| 149 |
|
|
| 150 |
|
protected abstract void cancelPressed(); |
| 151 |
|
|
| 152 |
|
} |