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 |
|
package jalview.gui; |
27 |
|
|
28 |
|
import java.awt.Container; |
29 |
|
import java.beans.PropertyVetoException; |
30 |
|
import java.util.Vector; |
31 |
|
|
32 |
|
import javax.swing.DefaultDesktopManager; |
33 |
|
import javax.swing.DesktopManager; |
34 |
|
import javax.swing.JInternalFrame; |
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 |
|
|
|
|
| 0% |
Uncovered Elements: 90 (90) |
Complexity: 27 |
Complexity Density: 0.52 |
|
65 |
|
public class AquaInternalFrameManager extends DefaultDesktopManager |
66 |
|
{ |
67 |
|
|
68 |
|
|
69 |
|
|
70 |
|
|
71 |
|
|
72 |
|
JInternalFrame fCurrentFrame; |
73 |
|
|
74 |
|
JInternalFrame fInitialFrame; |
75 |
|
|
76 |
|
|
77 |
|
|
78 |
|
|
79 |
|
|
80 |
|
|
81 |
|
|
82 |
|
|
83 |
|
Vector<JInternalFrame> fChildFrames = new Vector<>(1); |
84 |
|
|
85 |
|
|
86 |
|
|
87 |
|
|
88 |
|
|
89 |
|
private DesktopManager ourManager; |
90 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
91 |
0 |
public AquaInternalFrameManager(DesktopManager desktopManager)... |
92 |
|
{ |
93 |
0 |
ourManager = desktopManager; |
94 |
|
} |
95 |
|
|
|
|
| 0% |
Uncovered Elements: 11 (11) |
Complexity: 3 |
Complexity Density: 0.43 |
|
96 |
0 |
@Override... |
97 |
|
public void closeFrame(final JInternalFrame f) |
98 |
|
{ |
99 |
0 |
if (f == fCurrentFrame) |
100 |
|
{ |
101 |
0 |
boolean mostRecentFrame = fChildFrames |
102 |
|
.indexOf(f) == fChildFrames.size() - 1; |
103 |
0 |
if (!mostRecentFrame) |
104 |
|
{ |
105 |
0 |
activateNextFrame(); |
106 |
|
} |
107 |
|
else |
108 |
|
{ |
109 |
0 |
activatePreviousFrame(); |
110 |
|
} |
111 |
|
} |
112 |
0 |
fChildFrames.removeElement(f); |
113 |
0 |
super.closeFrame(f); |
114 |
|
} |
115 |
|
|
|
|
| 0% |
Uncovered Elements: 4 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
|
116 |
0 |
@Override... |
117 |
|
public void deiconifyFrame(final JInternalFrame f) |
118 |
|
{ |
119 |
0 |
JInternalFrame.JDesktopIcon desktopIcon; |
120 |
|
|
121 |
0 |
desktopIcon = f.getDesktopIcon(); |
122 |
|
|
123 |
|
|
124 |
0 |
f.reshape(desktopIcon.getX(), desktopIcon.getY(), f.getWidth(), |
125 |
|
f.getHeight()); |
126 |
0 |
ourManager.deiconifyFrame(f); |
127 |
|
} |
128 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
129 |
0 |
void addIcon(final Container c,... |
130 |
|
final JInternalFrame.JDesktopIcon desktopIcon) |
131 |
|
{ |
132 |
0 |
c.add(desktopIcon); |
133 |
|
} |
134 |
|
|
135 |
|
|
136 |
|
|
137 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
138 |
0 |
@Override... |
139 |
|
public void iconifyFrame(final JInternalFrame f) |
140 |
|
{ |
141 |
0 |
ourManager.iconifyFrame(f); |
142 |
|
} |
143 |
|
|
144 |
|
|
|
|
| 0% |
Uncovered Elements: 22 (22) |
Complexity: 9 |
Complexity Density: 0.75 |
|
145 |
0 |
@Override... |
146 |
|
public void activateFrame(final JInternalFrame f) |
147 |
|
{ |
148 |
0 |
try |
149 |
|
{ |
150 |
0 |
if (f != null) |
151 |
|
{ |
152 |
0 |
super.activateFrame(f); |
153 |
|
} |
154 |
|
|
155 |
|
|
156 |
0 |
if (fChildFrames.indexOf(f) != -1) |
157 |
|
{ |
158 |
0 |
fChildFrames.remove(f); |
159 |
|
} |
160 |
0 |
fChildFrames.addElement(f); |
161 |
|
|
162 |
0 |
if (fCurrentFrame != null && f != fCurrentFrame) |
163 |
|
{ |
164 |
0 |
if (fCurrentFrame.isSelected()) |
165 |
|
{ |
166 |
0 |
fCurrentFrame.setSelected(false); |
167 |
|
} |
168 |
|
} |
169 |
|
|
170 |
0 |
if (f != null && !f.isSelected()) |
171 |
|
{ |
172 |
0 |
f.setSelected(true); |
173 |
|
} |
174 |
|
|
175 |
0 |
fCurrentFrame = f; |
176 |
|
} catch (final PropertyVetoException e) |
177 |
|
{ |
178 |
|
} |
179 |
|
} |
180 |
|
|
|
|
| 0% |
Uncovered Elements: 36 (36) |
Complexity: 8 |
Complexity Density: 0.36 |
|
181 |
0 |
private void switchFrame(final boolean next)... |
182 |
|
{ |
183 |
0 |
if (fCurrentFrame == null) |
184 |
|
{ |
185 |
|
|
186 |
0 |
if (fInitialFrame != null) |
187 |
|
{ |
188 |
0 |
activateFrame(fInitialFrame); |
189 |
|
} |
190 |
0 |
return; |
191 |
|
} |
192 |
|
|
193 |
0 |
final int count = fChildFrames.size(); |
194 |
0 |
if (count <= 1) |
195 |
|
{ |
196 |
|
|
197 |
0 |
return; |
198 |
|
} |
199 |
|
|
200 |
0 |
final int currentIndex = fChildFrames.indexOf(fCurrentFrame); |
201 |
0 |
if (currentIndex == -1) |
202 |
|
{ |
203 |
|
|
204 |
0 |
fCurrentFrame = null; |
205 |
0 |
return; |
206 |
|
} |
207 |
|
|
208 |
0 |
int nextIndex; |
209 |
0 |
if (next) |
210 |
|
{ |
211 |
0 |
nextIndex = currentIndex + 1; |
212 |
0 |
if (nextIndex == count) |
213 |
|
{ |
214 |
0 |
nextIndex = 0; |
215 |
|
} |
216 |
|
} |
217 |
|
else |
218 |
|
{ |
219 |
0 |
nextIndex = currentIndex - 1; |
220 |
0 |
if (nextIndex == -1) |
221 |
|
{ |
222 |
0 |
nextIndex = count - 1; |
223 |
|
} |
224 |
|
} |
225 |
0 |
final JInternalFrame f = fChildFrames.elementAt(nextIndex); |
226 |
0 |
activateFrame(f); |
227 |
0 |
fCurrentFrame = f; |
228 |
|
} |
229 |
|
|
230 |
|
|
231 |
|
|
232 |
|
|
233 |
|
|
234 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
235 |
0 |
public void activateNextFrame()... |
236 |
|
{ |
237 |
0 |
switchFrame(true); |
238 |
|
} |
239 |
|
|
240 |
|
|
241 |
|
|
242 |
|
|
|
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
243 |
0 |
public void activateNextFrame(final JInternalFrame f)... |
244 |
|
{ |
245 |
0 |
fInitialFrame = f; |
246 |
0 |
switchFrame(true); |
247 |
|
} |
248 |
|
|
249 |
|
|
250 |
|
|
251 |
|
|
252 |
|
|
253 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
254 |
0 |
public void activatePreviousFrame()... |
255 |
|
{ |
256 |
0 |
switchFrame(false); |
257 |
|
} |
258 |
|
} |