1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
|
21 |
|
package jalview.jbgui; |
22 |
|
|
23 |
|
import java.awt.BorderLayout; |
24 |
|
import java.awt.Font; |
25 |
|
import java.awt.event.ActionEvent; |
26 |
|
import java.awt.event.ActionListener; |
27 |
|
import java.awt.event.MouseEvent; |
28 |
|
|
29 |
|
import javax.swing.JButton; |
30 |
|
import javax.swing.JCheckBoxMenuItem; |
31 |
|
import javax.swing.JEditorPane; |
32 |
|
import javax.swing.JInternalFrame; |
33 |
|
import javax.swing.JMenu; |
34 |
|
import javax.swing.JMenuBar; |
35 |
|
import javax.swing.JMenuItem; |
36 |
|
import javax.swing.JPanel; |
37 |
|
import javax.swing.JScrollPane; |
38 |
|
import javax.swing.text.EditorKit; |
39 |
|
import javax.swing.text.html.HTMLEditorKit; |
40 |
|
|
41 |
|
import jalview.gui.JvSwingUtils; |
42 |
|
import jalview.util.MessageManager; |
43 |
|
|
44 |
|
|
45 |
|
|
46 |
|
|
47 |
|
@author |
48 |
|
@version |
49 |
|
|
|
|
| 0% |
Uncovered Elements: 79 (79) |
Complexity: 21 |
Complexity Density: 0.36 |
|
50 |
|
public class GCutAndPasteHtmlTransfer extends JInternalFrame |
51 |
|
{ |
52 |
|
protected JEditorPane textarea = new JEditorPane("text/html", ""); |
53 |
|
|
54 |
|
protected JScrollPane scrollPane = new JScrollPane(); |
55 |
|
|
56 |
|
BorderLayout borderLayout1 = new BorderLayout(); |
57 |
|
|
58 |
|
JMenuBar editMenubar = new JMenuBar(); |
59 |
|
|
60 |
|
JMenu editMenu = new JMenu(); |
61 |
|
|
62 |
|
JMenuItem copyItem = new JMenuItem(); |
63 |
|
|
64 |
|
protected JCheckBoxMenuItem displaySource = new JCheckBoxMenuItem(); |
65 |
|
|
66 |
|
BorderLayout borderLayout2 = new BorderLayout(); |
67 |
|
|
68 |
|
protected JPanel inputButtonPanel = new JPanel(); |
69 |
|
|
70 |
|
protected JButton ok = new JButton(); |
71 |
|
|
72 |
|
JButton cancel = new JButton(); |
73 |
|
|
74 |
|
JMenuItem close = new JMenuItem(); |
75 |
|
|
76 |
|
JMenuItem selectAll = new JMenuItem(); |
77 |
|
|
78 |
|
JMenu jMenu1 = new JMenu(); |
79 |
|
|
80 |
|
JMenuItem save = new JMenuItem(); |
81 |
|
|
82 |
|
|
83 |
|
|
84 |
|
|
|
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 2 |
Complexity Density: 0.4 |
|
85 |
0 |
public GCutAndPasteHtmlTransfer()... |
86 |
|
{ |
87 |
0 |
try |
88 |
|
{ |
89 |
0 |
textarea.setEditorKit(new HTMLEditorKit()); |
90 |
0 |
setJMenuBar(editMenubar); |
91 |
0 |
jbInit(); |
92 |
|
} catch (Exception e) |
93 |
|
{ |
94 |
0 |
e.printStackTrace(); |
95 |
|
} |
96 |
|
} |
97 |
|
|
98 |
|
|
99 |
|
|
100 |
|
|
101 |
|
@throws |
102 |
|
|
103 |
|
|
|
|
| 0% |
Uncovered Elements: 40 (40) |
Complexity: 1 |
Complexity Density: 0.03 |
|
104 |
0 |
private void jbInit() throws Exception... |
105 |
|
{ |
106 |
0 |
setFrameIcon(null); |
107 |
0 |
scrollPane.setBorder(null); |
108 |
0 |
ok.setFont(JvSwingUtils.getLabelFont()); |
109 |
0 |
ok.setText(MessageManager.getString("label.new_window")); |
110 |
0 |
ok.addActionListener(new ActionListener() |
111 |
|
{ |
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
112 |
0 |
@Override... |
113 |
|
public void actionPerformed(ActionEvent e) |
114 |
|
{ |
115 |
0 |
ok_actionPerformed(e); |
116 |
|
} |
117 |
|
}); |
118 |
0 |
cancel.setText(MessageManager.getString("action.close")); |
119 |
0 |
cancel.addActionListener(new ActionListener() |
120 |
|
{ |
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
121 |
0 |
@Override... |
122 |
|
public void actionPerformed(ActionEvent e) |
123 |
|
{ |
124 |
0 |
cancel_actionPerformed(e); |
125 |
|
} |
126 |
|
}); |
127 |
0 |
textarea.setBorder(null); |
128 |
0 |
close.setText(MessageManager.getString("action.close")); |
129 |
0 |
close.addActionListener(new ActionListener() |
130 |
|
{ |
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
131 |
0 |
@Override... |
132 |
|
public void actionPerformed(ActionEvent e) |
133 |
|
{ |
134 |
0 |
cancel_actionPerformed(e); |
135 |
|
} |
136 |
|
}); |
137 |
0 |
close.setAccelerator( |
138 |
|
javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_W, |
139 |
|
jalview.util.ShortcutKeyMaskExWrapper |
140 |
|
.getMenuShortcutKeyMaskEx(), |
141 |
|
false)); |
142 |
0 |
selectAll.setText(MessageManager.getString("action.select_all")); |
143 |
0 |
selectAll |
144 |
|
.setAccelerator( |
145 |
|
javax.swing.KeyStroke |
146 |
|
.getKeyStroke(java.awt.event.KeyEvent.VK_A, |
147 |
|
jalview.util.ShortcutKeyMaskExWrapper |
148 |
|
.getMenuShortcutKeyMaskEx(), |
149 |
|
false)); |
150 |
0 |
selectAll.addActionListener(new ActionListener() |
151 |
|
{ |
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
152 |
0 |
@Override... |
153 |
|
public void actionPerformed(ActionEvent e) |
154 |
|
{ |
155 |
0 |
selectAll_actionPerformed(e); |
156 |
|
} |
157 |
|
}); |
158 |
0 |
jMenu1.setText(MessageManager.getString("action.file")); |
159 |
0 |
save.setText(MessageManager.getString("action.save")); |
160 |
0 |
save.setAccelerator( |
161 |
|
javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_S, |
162 |
|
jalview.util.ShortcutKeyMaskExWrapper |
163 |
|
.getMenuShortcutKeyMaskEx(), |
164 |
|
false)); |
165 |
0 |
save.addActionListener(new ActionListener() |
166 |
|
{ |
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
167 |
0 |
@Override... |
168 |
|
public void actionPerformed(ActionEvent e) |
169 |
|
{ |
170 |
0 |
save_actionPerformed(e); |
171 |
|
} |
172 |
|
}); |
173 |
0 |
copyItem.setAccelerator( |
174 |
|
javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_C, |
175 |
|
jalview.util.ShortcutKeyMaskExWrapper |
176 |
|
.getMenuShortcutKeyMaskEx(), |
177 |
|
false)); |
178 |
|
|
179 |
0 |
editMenubar.add(jMenu1); |
180 |
0 |
editMenubar.add(editMenu); |
181 |
0 |
textarea.setFont(new java.awt.Font("Monospaced", Font.PLAIN, 12)); |
182 |
0 |
textarea.addMouseListener(new java.awt.event.MouseAdapter() |
183 |
|
{ |
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
184 |
0 |
@Override... |
185 |
|
public void mousePressed(MouseEvent e) |
186 |
|
{ |
187 |
0 |
textarea_mousePressed(e); |
188 |
|
} |
189 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
190 |
0 |
@Override... |
191 |
|
public void mouseReleased(MouseEvent e) |
192 |
|
{ |
193 |
0 |
textarea_mousePressed(e); |
194 |
|
} |
195 |
|
}); |
196 |
0 |
editMenu.setText(MessageManager.getString("action.edit")); |
197 |
0 |
copyItem.setText(MessageManager.getString("action.copy")); |
198 |
0 |
copyItem.addActionListener(new ActionListener() |
199 |
|
{ |
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
200 |
0 |
@Override... |
201 |
|
public void actionPerformed(ActionEvent e) |
202 |
|
{ |
203 |
0 |
copyItem_actionPerformed(e); |
204 |
|
} |
205 |
|
}); |
206 |
0 |
displaySource |
207 |
|
.setText(MessageManager.getString("action.show_html_source")); |
208 |
0 |
displaySource.setToolTipText( |
209 |
|
MessageManager.getString("label.select_copy_raw_html")); |
210 |
0 |
displaySource.addActionListener(new ActionListener() |
211 |
|
{ |
212 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
213 |
0 |
@Override... |
214 |
|
public void actionPerformed(ActionEvent arg0) |
215 |
|
{ |
216 |
0 |
toggleHtml_actionPerformed(arg0); |
217 |
|
} |
218 |
|
}); |
219 |
0 |
editMenu.add(displaySource); |
220 |
0 |
this.getContentPane().setLayout(borderLayout2); |
221 |
0 |
scrollPane.setBorder(null); |
222 |
0 |
scrollPane.getViewport().add(textarea, null); |
223 |
0 |
editMenu.add(selectAll); |
224 |
0 |
editMenu.add(copyItem); |
225 |
0 |
this.getContentPane().add(scrollPane, java.awt.BorderLayout.CENTER); |
226 |
0 |
inputButtonPanel.add(ok); |
227 |
0 |
inputButtonPanel.add(cancel); |
228 |
0 |
jMenu1.add(save); |
229 |
0 |
jMenu1.add(close); |
230 |
|
} |
231 |
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
232 |
0 |
protected void toggleHtml_actionPerformed(ActionEvent arg0)... |
233 |
|
{ |
234 |
|
|
235 |
|
|
236 |
|
} |
237 |
|
|
238 |
|
|
239 |
|
|
240 |
|
|
241 |
|
@param |
242 |
|
|
243 |
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
244 |
0 |
public void textarea_mousePressed(MouseEvent e)... |
245 |
|
{ |
246 |
|
|
247 |
|
} |
248 |
|
|
249 |
|
|
250 |
|
|
251 |
|
|
252 |
|
@param |
253 |
|
|
254 |
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
255 |
0 |
public void copyItem_actionPerformed(ActionEvent e)... |
256 |
|
{ |
257 |
|
} |
258 |
|
|
259 |
|
|
260 |
|
|
261 |
|
|
262 |
|
@param |
263 |
|
|
264 |
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
265 |
0 |
public void ok_actionPerformed(ActionEvent e)... |
266 |
|
{ |
267 |
|
} |
268 |
|
|
269 |
|
|
270 |
|
|
271 |
|
|
272 |
|
@param |
273 |
|
|
274 |
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
275 |
0 |
public void cancel_actionPerformed(ActionEvent e)... |
276 |
|
{ |
277 |
|
} |
278 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
279 |
0 |
public void selectAll_actionPerformed(ActionEvent e)... |
280 |
|
{ |
281 |
0 |
textarea.selectAll(); |
282 |
|
} |
283 |
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
284 |
0 |
public void save_actionPerformed(ActionEvent e)... |
285 |
|
{ |
286 |
|
|
287 |
|
} |
288 |
|
|
289 |
|
|
290 |
|
|
291 |
|
|
292 |
|
|
293 |
|
@param |
294 |
|
@see |
295 |
|
|
|
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
296 |
0 |
public void addStylesheetRule(String rule)... |
297 |
|
{ |
298 |
0 |
EditorKit editorKit = textarea.getEditorKit(); |
299 |
0 |
if (editorKit != null) |
300 |
|
{ |
301 |
0 |
((HTMLEditorKit) editorKit).getStyleSheet().addRule(rule); |
302 |
|
} |
303 |
|
} |
304 |
|
} |