2 * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
3 * Copyright (C) $$Year-Rel$$ 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;
26 import java.awt.BorderLayout;
28 import java.awt.Toolkit;
29 import java.awt.event.ActionEvent;
30 import java.awt.event.ActionListener;
31 import java.awt.event.MouseEvent;
33 import javax.swing.JButton;
34 import javax.swing.JCheckBoxMenuItem;
35 import javax.swing.JEditorPane;
36 import javax.swing.JInternalFrame;
37 import javax.swing.JMenu;
38 import javax.swing.JMenuBar;
39 import javax.swing.JMenuItem;
40 import javax.swing.JPanel;
41 import javax.swing.JScrollPane;
49 public class GCutAndPasteHtmlTransfer extends JInternalFrame
51 protected JEditorPane textarea = new JEditorPane("text/html", "");
53 protected JScrollPane scrollPane = new JScrollPane();
55 BorderLayout borderLayout1 = new BorderLayout();
57 JMenuBar editMenubar = new JMenuBar();
59 JMenu editMenu = new JMenu();
61 JMenuItem copyItem = new JMenuItem();
63 protected JCheckBoxMenuItem displaySource = new JCheckBoxMenuItem();
65 BorderLayout borderLayout2 = new BorderLayout();
67 protected JPanel inputButtonPanel = new JPanel();
69 protected JButton ok = new JButton();
71 JButton cancel = new JButton();
73 JMenuItem close = new JMenuItem();
75 JMenuItem selectAll = new JMenuItem();
77 JMenu jMenu1 = new JMenu();
79 JMenuItem save = new JMenuItem();
82 * Creates a new GCutAndPasteTransfer object.
84 public GCutAndPasteHtmlTransfer()
88 setJMenuBar(editMenubar);
102 private void jbInit() throws Exception
104 scrollPane.setBorder(null);
105 ok.setFont(JvSwingUtils.getLabelFont());
106 ok.setText(MessageManager.getString("label.new_window"));
107 ok.addActionListener(new ActionListener()
110 public void actionPerformed(ActionEvent e)
112 ok_actionPerformed(e);
115 cancel.setText(MessageManager.getString("action.close"));
116 cancel.addActionListener(new ActionListener()
119 public void actionPerformed(ActionEvent e)
121 cancel_actionPerformed(e);
124 textarea.setBorder(null);
125 close.setText(MessageManager.getString("action.close"));
126 close.addActionListener(new ActionListener()
129 public void actionPerformed(ActionEvent e)
131 cancel_actionPerformed(e);
134 close.setAccelerator(javax.swing.KeyStroke.getKeyStroke(
135 java.awt.event.KeyEvent.VK_W, Toolkit.getDefaultToolkit()
136 .getMenuShortcutKeyMask(), false));
137 selectAll.setText(MessageManager.getString("action.select_all"));
138 selectAll.setAccelerator(javax.swing.KeyStroke.getKeyStroke(
139 java.awt.event.KeyEvent.VK_A, Toolkit.getDefaultToolkit()
140 .getMenuShortcutKeyMask(), false));
141 selectAll.addActionListener(new ActionListener()
144 public void actionPerformed(ActionEvent e)
146 selectAll_actionPerformed(e);
149 jMenu1.setText(MessageManager.getString("action.file"));
150 save.setText(MessageManager.getString("action.save"));
151 save.setAccelerator(javax.swing.KeyStroke.getKeyStroke(
152 java.awt.event.KeyEvent.VK_S, Toolkit.getDefaultToolkit()
153 .getMenuShortcutKeyMask(), false));
154 save.addActionListener(new ActionListener()
157 public void actionPerformed(ActionEvent e)
159 save_actionPerformed(e);
162 copyItem.setAccelerator(javax.swing.KeyStroke.getKeyStroke(
163 java.awt.event.KeyEvent.VK_C, Toolkit.getDefaultToolkit()
164 .getMenuShortcutKeyMask(), false));
166 editMenubar.add(jMenu1);
167 editMenubar.add(editMenu);
168 textarea.setFont(new java.awt.Font("Monospaced", Font.PLAIN, 12));
169 textarea.addMouseListener(new java.awt.event.MouseAdapter()
172 public void mousePressed(MouseEvent e)
174 textarea_mousePressed(e);
178 public void mouseReleased(MouseEvent e)
180 textarea_mousePressed(e);
183 editMenu.setText(MessageManager.getString("action.edit"));
184 copyItem.setText(MessageManager.getString("action.copy"));
185 copyItem.addActionListener(new ActionListener()
188 public void actionPerformed(ActionEvent e)
190 copyItem_actionPerformed(e);
193 displaySource.setText(MessageManager
194 .getString("action.show_html_source"));
195 displaySource.setToolTipText(MessageManager
196 .getString("label.select_copy_raw_html"));
197 displaySource.addActionListener(new ActionListener()
201 public void actionPerformed(ActionEvent arg0)
203 toggleHtml_actionPerformed(arg0);
206 editMenu.add(displaySource);
207 this.getContentPane().setLayout(borderLayout2);
208 scrollPane.setBorder(null);
209 scrollPane.getViewport().add(textarea, null);
210 editMenu.add(selectAll);
211 editMenu.add(copyItem);
212 this.getContentPane().add(scrollPane, java.awt.BorderLayout.CENTER);
213 inputButtonPanel.add(ok);
214 inputButtonPanel.add(cancel);
219 protected void toggleHtml_actionPerformed(ActionEvent arg0)
221 // TODO Auto-generated method stub
231 public void textarea_mousePressed(MouseEvent e)
242 public void copyItem_actionPerformed(ActionEvent e)
252 public void ok_actionPerformed(ActionEvent e)
262 public void cancel_actionPerformed(ActionEvent e)
266 public void selectAll_actionPerformed(ActionEvent e)
268 textarea.selectAll();
271 public void save_actionPerformed(ActionEvent e)