2 * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8.2)
3 * Copyright (C) 2014 The Jalview Authors
5 * This file is part of Jalview.
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.
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.
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.
21 package jalview.jbgui;
23 import jalview.gui.JvSwingUtils;
24 import jalview.util.MessageManager;
27 import java.awt.event.*;
37 public class GCutAndPasteHtmlTransfer extends JInternalFrame
39 protected JEditorPane textarea = new JEditorPane("text/html", "");
41 protected JScrollPane scrollPane = new JScrollPane();
43 BorderLayout borderLayout1 = new BorderLayout();
45 JMenuBar editMenubar = new JMenuBar();
47 JMenu editMenu = new JMenu();
49 JMenuItem copyItem = new JMenuItem();
51 protected JCheckBoxMenuItem displaySource = new JCheckBoxMenuItem();
53 BorderLayout borderLayout2 = new BorderLayout();
55 protected JPanel inputButtonPanel = new JPanel();
57 protected JButton ok = new JButton();
59 JButton cancel = new JButton();
61 JMenuItem close = new JMenuItem();
63 JMenuItem selectAll = new JMenuItem();
65 JMenu jMenu1 = new JMenu();
67 JMenuItem save = new JMenuItem();
70 * Creates a new GCutAndPasteTransfer object.
72 public GCutAndPasteHtmlTransfer()
76 setJMenuBar(editMenubar);
90 private void jbInit() throws Exception
92 scrollPane.setBorder(null);
93 ok.setFont(JvSwingUtils.getLabelFont());
94 ok.setText(MessageManager.getString("label.new_window"));
95 ok.addActionListener(new ActionListener()
97 public void actionPerformed(ActionEvent e)
99 ok_actionPerformed(e);
102 cancel.setText(MessageManager.getString("action.close"));
103 cancel.addActionListener(new ActionListener()
105 public void actionPerformed(ActionEvent e)
107 cancel_actionPerformed(e);
110 textarea.setBorder(null);
111 close.setText(MessageManager.getString("action.close"));
112 close.addActionListener(new ActionListener()
114 public void actionPerformed(ActionEvent e)
116 cancel_actionPerformed(e);
119 close.setAccelerator(javax.swing.KeyStroke.getKeyStroke(
120 java.awt.event.KeyEvent.VK_W, Toolkit.getDefaultToolkit()
121 .getMenuShortcutKeyMask(), false));
122 selectAll.setText(MessageManager.getString("action.select_all"));
123 selectAll.setAccelerator(javax.swing.KeyStroke.getKeyStroke(
124 java.awt.event.KeyEvent.VK_A, Toolkit.getDefaultToolkit()
125 .getMenuShortcutKeyMask(), false));
126 selectAll.addActionListener(new ActionListener()
128 public void actionPerformed(ActionEvent e)
130 selectAll_actionPerformed(e);
133 jMenu1.setText(MessageManager.getString("action.file"));
134 save.setText(MessageManager.getString("action.save"));
135 save.setAccelerator(javax.swing.KeyStroke.getKeyStroke(
136 java.awt.event.KeyEvent.VK_S, Toolkit.getDefaultToolkit()
137 .getMenuShortcutKeyMask(), false));
138 save.addActionListener(new ActionListener()
140 public void actionPerformed(ActionEvent e)
142 save_actionPerformed(e);
145 copyItem.setAccelerator(javax.swing.KeyStroke.getKeyStroke(
146 java.awt.event.KeyEvent.VK_C, Toolkit.getDefaultToolkit()
147 .getMenuShortcutKeyMask(), false));
149 editMenubar.add(jMenu1);
150 editMenubar.add(editMenu);
151 textarea.setFont(new java.awt.Font("Monospaced", Font.PLAIN, 12));
152 textarea.addMouseListener(new java.awt.event.MouseAdapter()
154 public void mousePressed(MouseEvent e)
156 textarea_mousePressed(e);
159 editMenu.setText(MessageManager.getString("action.edit"));
160 copyItem.setText(MessageManager.getString("action.copy"));
161 copyItem.addActionListener(new ActionListener()
163 public void actionPerformed(ActionEvent e)
165 copyItem_actionPerformed(e);
168 displaySource.setText(MessageManager
169 .getString("action.show_html_source"));
170 displaySource.setToolTipText(MessageManager
171 .getString("label.select_copy_raw_html"));
172 displaySource.addActionListener(new ActionListener()
176 public void actionPerformed(ActionEvent arg0)
178 toggleHtml_actionPerformed(arg0);
181 editMenu.add(displaySource);
182 this.getContentPane().setLayout(borderLayout2);
183 scrollPane.setBorder(null);
184 scrollPane.getViewport().add(textarea, null);
185 editMenu.add(selectAll);
186 editMenu.add(copyItem);
187 this.getContentPane().add(scrollPane, java.awt.BorderLayout.CENTER);
188 inputButtonPanel.add(ok);
189 inputButtonPanel.add(cancel);
194 protected void toggleHtml_actionPerformed(ActionEvent arg0)
196 // TODO Auto-generated method stub
206 public void textarea_mousePressed(MouseEvent e)
217 public void copyItem_actionPerformed(ActionEvent e)
227 public void ok_actionPerformed(ActionEvent e)
237 public void cancel_actionPerformed(ActionEvent e)
241 public void selectAll_actionPerformed(ActionEvent e)
243 textarea.selectAll();
246 public void save_actionPerformed(ActionEvent e)