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