X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fjbgui%2FGCutAndPasteHtmlTransfer.java;h=ef09b6a87a3b1d2c8e69c5c0b299823091510f50;hb=a7169b1c72607f3c9357195b4999869650a2a891;hp=2daa22e67da18fde4f5ed2d1282e1ceaf1c7ba09;hpb=a8f483d04205bb8273ee311c12968b7e86d205fa;p=jalview.git
diff --git a/src/jalview/jbgui/GCutAndPasteHtmlTransfer.java b/src/jalview/jbgui/GCutAndPasteHtmlTransfer.java
index 2daa22e..ef09b6a 100644
--- a/src/jalview/jbgui/GCutAndPasteHtmlTransfer.java
+++ b/src/jalview/jbgui/GCutAndPasteHtmlTransfer.java
@@ -1,31 +1,46 @@
/*
- * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8.2)
- * Copyright (C) 2014 The Jalview Authors
+ * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
+ * Copyright (C) $$Year-Rel$$ The Jalview Authors
*
* This file is part of Jalview.
*
* Jalview is free software: you can redistribute it and/or
* modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
+ * as published by the Free Software Foundation, either version 3
+ * of the License, or (at your option) any later version.
*
* Jalview is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
- * You should have received a copy of the GNU General Public License along with Jalview. If not, see .
+ * You should have received a copy of the GNU General Public License
+ * along with Jalview. If not, see .
* The Jalview Authors are detailed in the 'AUTHORS' file.
*/
package jalview.jbgui;
+import java.awt.BorderLayout;
+import java.awt.Font;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.awt.event.MouseEvent;
+
+import javax.swing.JButton;
+import javax.swing.JCheckBoxMenuItem;
+import javax.swing.JEditorPane;
+import javax.swing.JInternalFrame;
+import javax.swing.JMenu;
+import javax.swing.JMenuBar;
+import javax.swing.JMenuItem;
+import javax.swing.JPanel;
+import javax.swing.JScrollPane;
+import javax.swing.text.EditorKit;
+import javax.swing.text.html.HTMLEditorKit;
+
import jalview.gui.JvSwingUtils;
import jalview.util.MessageManager;
-import java.awt.*;
-import java.awt.event.*;
-
-import javax.swing.*;
-
/**
* DOCUMENT ME!
*
@@ -71,6 +86,7 @@ public class GCutAndPasteHtmlTransfer extends JInternalFrame
{
try
{
+ textarea.setEditorKit(new HTMLEditorKit());
setJMenuBar(editMenubar);
jbInit();
} catch (Exception e)
@@ -87,11 +103,13 @@ public class GCutAndPasteHtmlTransfer extends JInternalFrame
*/
private void jbInit() throws Exception
{
+ setFrameIcon(null);
scrollPane.setBorder(null);
ok.setFont(JvSwingUtils.getLabelFont());
ok.setText(MessageManager.getString("label.new_window"));
ok.addActionListener(new ActionListener()
{
+ @Override
public void actionPerformed(ActionEvent e)
{
ok_actionPerformed(e);
@@ -100,6 +118,7 @@ public class GCutAndPasteHtmlTransfer extends JInternalFrame
cancel.setText(MessageManager.getString("action.close"));
cancel.addActionListener(new ActionListener()
{
+ @Override
public void actionPerformed(ActionEvent e)
{
cancel_actionPerformed(e);
@@ -109,20 +128,28 @@ public class GCutAndPasteHtmlTransfer extends JInternalFrame
close.setText(MessageManager.getString("action.close"));
close.addActionListener(new ActionListener()
{
+ @Override
public void actionPerformed(ActionEvent e)
{
cancel_actionPerformed(e);
}
});
- close.setAccelerator(javax.swing.KeyStroke.getKeyStroke(
- java.awt.event.KeyEvent.VK_W, Toolkit.getDefaultToolkit()
- .getMenuShortcutKeyMask(), false));
+ close.setAccelerator(
+ javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_W,
+ jalview.util.ShortcutKeyMaskExWrapper
+ .getMenuShortcutKeyMaskEx(),
+ false));
selectAll.setText(MessageManager.getString("action.select_all"));
- selectAll.setAccelerator(javax.swing.KeyStroke.getKeyStroke(
- java.awt.event.KeyEvent.VK_A, Toolkit.getDefaultToolkit()
- .getMenuShortcutKeyMask(), false));
+ selectAll
+ .setAccelerator(
+ javax.swing.KeyStroke
+ .getKeyStroke(java.awt.event.KeyEvent.VK_A,
+ jalview.util.ShortcutKeyMaskExWrapper
+ .getMenuShortcutKeyMaskEx(),
+ false));
selectAll.addActionListener(new ActionListener()
{
+ @Override
public void actionPerformed(ActionEvent e)
{
selectAll_actionPerformed(e);
@@ -130,42 +157,56 @@ public class GCutAndPasteHtmlTransfer extends JInternalFrame
});
jMenu1.setText(MessageManager.getString("action.file"));
save.setText(MessageManager.getString("action.save"));
- save.setAccelerator(javax.swing.KeyStroke.getKeyStroke(
- java.awt.event.KeyEvent.VK_S, Toolkit.getDefaultToolkit()
- .getMenuShortcutKeyMask(), false));
+ save.setAccelerator(
+ javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_S,
+ jalview.util.ShortcutKeyMaskExWrapper
+ .getMenuShortcutKeyMaskEx(),
+ false));
save.addActionListener(new ActionListener()
{
+ @Override
public void actionPerformed(ActionEvent e)
{
save_actionPerformed(e);
}
});
- copyItem.setAccelerator(javax.swing.KeyStroke.getKeyStroke(
- java.awt.event.KeyEvent.VK_C, Toolkit.getDefaultToolkit()
- .getMenuShortcutKeyMask(), false));
+ copyItem.setAccelerator(
+ javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_C,
+ jalview.util.ShortcutKeyMaskExWrapper
+ .getMenuShortcutKeyMaskEx(),
+ false));
editMenubar.add(jMenu1);
editMenubar.add(editMenu);
textarea.setFont(new java.awt.Font("Monospaced", Font.PLAIN, 12));
textarea.addMouseListener(new java.awt.event.MouseAdapter()
{
+ @Override
public void mousePressed(MouseEvent e)
{
textarea_mousePressed(e);
}
+
+ @Override
+ public void mouseReleased(MouseEvent e)
+ {
+ textarea_mousePressed(e);
+ }
});
editMenu.setText(MessageManager.getString("action.edit"));
copyItem.setText(MessageManager.getString("action.copy"));
copyItem.addActionListener(new ActionListener()
{
+ @Override
public void actionPerformed(ActionEvent e)
{
copyItem_actionPerformed(e);
}
});
- displaySource.setText(MessageManager.getString("action.show_html_source"));
displaySource
- .setToolTipText(MessageManager.getString("label.select_copy_raw_html"));
+ .setText(MessageManager.getString("action.show_html_source"));
+ displaySource.setToolTipText(
+ MessageManager.getString("label.select_copy_raw_html"));
displaySource.addActionListener(new ActionListener()
{
@@ -244,4 +285,20 @@ public class GCutAndPasteHtmlTransfer extends JInternalFrame
{
}
+
+ /**
+ * Adds the given stylesheet rule to the Html editor. However note that CSS
+ * support is limited.
+ *
+ * @param rule
+ * @see javax.swing.text.html.CSS
+ */
+ public void addStylesheetRule(String rule)
+ {
+ EditorKit editorKit = textarea.getEditorKit();
+ if (editorKit != null)
+ {
+ ((HTMLEditorKit) editorKit).getStyleSheet().addRule(rule);
+ }
+ }
}