Clover icon

Coverage Report

  1. Project Clover database Thu Nov 7 2024 17:01:39 GMT
  2. Package jalview.jbgui

File GCutAndPasteHtmlTransfer.java

 

Coverage histogram

../../img/srcFileCovDistChart0.png
0% of files have more coverage

Code metrics

2
58
19
1
304
203
21
0.36
3.05
19
1.11

Classes

Class Line # Actions
GCutAndPasteHtmlTransfer 50 58 21
0.00%
 

Contributing tests

No tests hitting this source file were found.

Source view

1    /*
2    * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
3    * Copyright (C) $$Year-Rel$$ The Jalview Authors
4    *
5    * This file is part of Jalview.
6    *
7    * Jalview is free software: you can redistribute it and/or
8    * modify it under the terms of the GNU General Public License
9    * as published by the Free Software Foundation, either version 3
10    * of the License, or (at your option) any later version.
11    *
12    * Jalview is distributed in the hope that it will be useful, but
13    * WITHOUT ANY WARRANTY; without even the implied warranty
14    * of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15    * PURPOSE. See the GNU General Public License for more details.
16    *
17    * You should have received a copy of the GNU General Public License
18    * along with Jalview. If not, see <http://www.gnu.org/licenses/>.
19    * The Jalview Authors are detailed in the 'AUTHORS' file.
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    * DOCUMENT ME!
46    *
47    * @author $author$
48    * @version $Revision$
49    */
 
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    * Creates a new GCutAndPasteTransfer object.
84    */
 
85  0 toggle 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    * DOCUMENT ME!
100    *
101    * @throws Exception
102    * DOCUMENT ME!
103    */
 
104  0 toggle 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    {
 
112  0 toggle @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    {
 
121  0 toggle @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    {
 
131  0 toggle @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    {
 
152  0 toggle @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    {
 
167  0 toggle @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    {
 
184  0 toggle @Override
185    public void mousePressed(MouseEvent e)
186    {
187  0 textarea_mousePressed(e);
188    }
189   
 
190  0 toggle @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    {
 
200  0 toggle @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   
 
213  0 toggle @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   
 
232  0 toggle protected void toggleHtml_actionPerformed(ActionEvent arg0)
233    {
234    // TODO Auto-generated method stub
235   
236    }
237   
238    /**
239    * DOCUMENT ME!
240    *
241    * @param e
242    * DOCUMENT ME!
243    */
 
244  0 toggle public void textarea_mousePressed(MouseEvent e)
245    {
246   
247    }
248   
249    /**
250    * DOCUMENT ME!
251    *
252    * @param e
253    * DOCUMENT ME!
254    */
 
255  0 toggle public void copyItem_actionPerformed(ActionEvent e)
256    {
257    }
258   
259    /**
260    * DOCUMENT ME!
261    *
262    * @param e
263    * DOCUMENT ME!
264    */
 
265  0 toggle public void ok_actionPerformed(ActionEvent e)
266    {
267    }
268   
269    /**
270    * DOCUMENT ME!
271    *
272    * @param e
273    * DOCUMENT ME!
274    */
 
275  0 toggle public void cancel_actionPerformed(ActionEvent e)
276    {
277    }
278   
 
279  0 toggle public void selectAll_actionPerformed(ActionEvent e)
280    {
281  0 textarea.selectAll();
282    }
283   
 
284  0 toggle public void save_actionPerformed(ActionEvent e)
285    {
286   
287    }
288   
289    /**
290    * Adds the given stylesheet rule to the Html editor. However note that CSS
291    * support is limited.
292    *
293    * @param rule
294    * @see javax.swing.text.html.CSS
295    */
 
296  0 toggle 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    }