Revision: 6286
http://squirrel-sql.svn.sourceforge.net/squirrel-sql/?rev=6286&view=rev
Author: wis775
Date: 2011-06-04 08:17:45 +0000 (Sat, 04 Jun 2011)
Log Message:
-----------
Feature Request 1744964: Copy text from the SQL editor panel as rich text.
This functionality is available via the pop-up menu and the tools pop-up. To use this, the RSyntax editor (Syntax Plugin) must be activated.
Modified Paths:
--------------
trunk/sql12/plugins/syntax/src/main/java/net/sourceforge/squirrel_sql/plugins/syntax/SyntaxPlugin.java
trunk/sql12/plugins/syntax/src/main/java/net/sourceforge/squirrel_sql/plugins/syntax/ToolsPopupHandler.java
trunk/sql12/plugins/syntax/src/main/java/net/sourceforge/squirrel_sql/plugins/syntax/rsyntax/RSyntaxSQLEntryPanel.java
trunk/sql12/plugins/syntax/src/main/resources/net/sourceforge/squirrel_sql/plugins/syntax/I18NStrings.properties
trunk/sql12/plugins/syntax/src/main/resources/net/sourceforge/squirrel_sql/plugins/syntax/SyntaxPluginResources.properties
Added Paths:
-----------
trunk/sql12/plugins/syntax/src/main/java/net/sourceforge/squirrel_sql/plugins/syntax/rsyntax/action/
trunk/sql12/plugins/syntax/src/main/java/net/sourceforge/squirrel_sql/plugins/syntax/rsyntax/action/SquirrelCopyAsRtfAction.java
Modified: trunk/sql12/plugins/syntax/src/main/java/net/sourceforge/squirrel_sql/plugins/syntax/SyntaxPlugin.java
===================================================================
--- trunk/sql12/plugins/syntax/src/main/java/net/sourceforge/squirrel_sql/plugins/syntax/SyntaxPlugin.java 2011-06-03 16:53:55 UTC (rev 6285)
+++ trunk/sql12/plugins/syntax/src/main/java/net/sourceforge/squirrel_sql/plugins/syntax/SyntaxPlugin.java 2011-06-04 08:17:45 UTC (rev 6286)
@@ -56,6 +56,7 @@
import net.sourceforge.squirrel_sql.plugins.syntax.netbeans.NetbeansSQLEntryPanel;
import net.sourceforge.squirrel_sql.plugins.syntax.oster.OsterSQLEntryPanel;
import net.sourceforge.squirrel_sql.plugins.syntax.rsyntax.RSyntaxSQLEntryPanel;
+import net.sourceforge.squirrel_sql.plugins.syntax.rsyntax.action.SquirrelCopyAsRtfAction;
/**
* The Ostermiller plugin class. This plugin adds syntax highlighting to the SQL entry area.
@@ -107,6 +108,9 @@
// i18n[SyntaxPlugin.uncomment=uncomment]
String UNCOMMENT = s_stringMgr.getString("SyntaxPlugin.uncomment");
+ // i18n[SyntaxPlugin.copyasrtf=copyasrtf]
+ String COPY_AS_RTF = s_stringMgr.getString("SyntaxPlugin.copyasrtf");;
+
}
/** Logger for this class. */
@@ -242,8 +246,23 @@
_autoCorrectProvider = new AutoCorrectProviderImpl(_userSettingsFolder);
createMenu();
+
+ createAdditionalActions();
}
+ /**
+ * Create some additional actions and add them to the application.
+ * These actions are not part of the menu, but needs to be initialized with the resources of the syntax plugin.
+ * Some of these actions may be depend on a concrete editor.
+ */
+ private void createAdditionalActions() {
+ IApplication app = getApplication();
+ ActionCollection coll = app.getActionCollection();
+
+ coll.add(new SquirrelCopyAsRtfAction(getApplication(), _resources));
+
+ }
+
private void createMenu()
{
IApplication app = getApplication();
@@ -295,7 +314,7 @@
act = new UncommentAction(getApplication(), _resources);
coll.add(act);
_resources.addToMenu(act, menu);
-
+
}
/**
Modified: trunk/sql12/plugins/syntax/src/main/java/net/sourceforge/squirrel_sql/plugins/syntax/ToolsPopupHandler.java
===================================================================
--- trunk/sql12/plugins/syntax/src/main/java/net/sourceforge/squirrel_sql/plugins/syntax/ToolsPopupHandler.java 2011-06-03 16:53:55 UTC (rev 6285)
+++ trunk/sql12/plugins/syntax/src/main/java/net/sourceforge/squirrel_sql/plugins/syntax/ToolsPopupHandler.java 2011-06-04 08:17:45 UTC (rev 6286)
@@ -1,5 +1,10 @@
package net.sourceforge.squirrel_sql.plugins.syntax;
+import java.util.HashMap;
+
+import javax.swing.Action;
+import javax.swing.JComponent;
+
import net.sourceforge.squirrel_sql.client.IApplication;
import net.sourceforge.squirrel_sql.client.action.ActionCollection;
import net.sourceforge.squirrel_sql.client.gui.session.SQLInternalFrame;
@@ -9,18 +14,15 @@
import net.sourceforge.squirrel_sql.client.session.ISQLPanelAPI;
import net.sourceforge.squirrel_sql.fw.util.Resources;
import net.sourceforge.squirrel_sql.plugins.syntax.netbeans.NetbeansSQLEditorPane;
-import net.sourceforge.squirrel_sql.plugins.syntax.ReplaceAction;
import net.sourceforge.squirrel_sql.plugins.syntax.netbeans.SQLKit;
import net.sourceforge.squirrel_sql.plugins.syntax.netbeans.SQLSettingsInitializer;
import net.sourceforge.squirrel_sql.plugins.syntax.rsyntax.SquirreLRSyntaxTextAreaUI;
import net.sourceforge.squirrel_sql.plugins.syntax.rsyntax.SquirrelRSyntaxTextArea;
-import net.sourceforge.squirrel_sql.plugins.syntax.UnmarkAction;
+import net.sourceforge.squirrel_sql.plugins.syntax.rsyntax.action.SquirrelCopyAsRtfAction;
+
import org.fife.ui.rtextarea.RTextAreaEditorKit;
import org.netbeans.editor.BaseKit;
-import javax.swing.*;
-import java.util.HashMap;
-
public class ToolsPopupHandler
{
private SyntaxPlugin _syntaxPugin;
@@ -79,7 +81,8 @@
Action toLowerAction = SquirreLRSyntaxTextAreaUI.getActionForName(rsEdit, RTextAreaEditorKit.rtaLowerSelectionCaseAction);
toLowerAction.putValue(Resources.ACCELERATOR_STRING, SquirreLRSyntaxTextAreaUI.RS_ACCELERATOR_STRING_TO_LOWER_CASE);
tpa.addToToolsPopup(SyntaxPlugin.i18n.TO_LOWER_CASE, toLowerAction);
-
+
+ tpa.addToToolsPopup(SyntaxPlugin.i18n.COPY_AS_RTF,_syntaxPugin.getApplication().getActionCollection().get(SquirrelCopyAsRtfAction.class));
}
}
@@ -126,6 +129,7 @@
toLowerAction.putValue(Resources.ACCELERATOR_STRING, SquirreLRSyntaxTextAreaUI.RS_ACCELERATOR_STRING_TO_LOWER_CASE);
sif.addToToolsPopUp(SyntaxPlugin.i18n.TO_LOWER_CASE, toLowerAction);
+ sif.addToToolsPopUp(SyntaxPlugin.i18n.COPY_AS_RTF,_syntaxPugin.getApplication().getActionCollection().get(SquirrelCopyAsRtfAction.class));
}
}
@@ -169,6 +173,7 @@
toLowerAction.putValue(Resources.ACCELERATOR_STRING, SquirreLRSyntaxTextAreaUI.RS_ACCELERATOR_STRING_TO_LOWER_CASE);
sqlInternalFrame.addToToolsPopUp(SyntaxPlugin.i18n.TO_LOWER_CASE, toLowerAction);
+ sqlInternalFrame.addToToolsPopUp(SyntaxPlugin.i18n.COPY_AS_RTF,_syntaxPugin.getApplication().getActionCollection().get(SquirrelCopyAsRtfAction.class));
}
}
Modified: trunk/sql12/plugins/syntax/src/main/java/net/sourceforge/squirrel_sql/plugins/syntax/rsyntax/RSyntaxSQLEntryPanel.java
===================================================================
--- trunk/sql12/plugins/syntax/src/main/java/net/sourceforge/squirrel_sql/plugins/syntax/rsyntax/RSyntaxSQLEntryPanel.java 2011-06-03 16:53:55 UTC (rev 6285)
+++ trunk/sql12/plugins/syntax/src/main/java/net/sourceforge/squirrel_sql/plugins/syntax/rsyntax/RSyntaxSQLEntryPanel.java 2011-06-04 08:17:45 UTC (rev 6286)
@@ -19,6 +19,21 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
+import java.awt.Font;
+import java.awt.dnd.DropTarget;
+import java.awt.event.MouseListener;
+import java.util.HashMap;
+
+import javax.swing.JScrollPane;
+import javax.swing.SwingUtilities;
+import javax.swing.event.CaretListener;
+import javax.swing.event.UndoableEditListener;
+import javax.swing.text.Document;
+import javax.swing.text.Element;
+import javax.swing.text.JTextComponent;
+import javax.swing.text.PlainDocument;
+import javax.swing.undo.UndoManager;
+
import net.sourceforge.squirrel_sql.client.gui.dnd.FileEditorDropTargetListener;
import net.sourceforge.squirrel_sql.client.session.BaseSQLEntryPanel;
import net.sourceforge.squirrel_sql.client.session.ISQLEntryPanel;
@@ -29,20 +44,8 @@
import net.sourceforge.squirrel_sql.fw.util.log.ILogger;
import net.sourceforge.squirrel_sql.fw.util.log.LoggerController;
import net.sourceforge.squirrel_sql.plugins.syntax.SyntaxPreferences;
+import net.sourceforge.squirrel_sql.plugins.syntax.rsyntax.action.SquirrelCopyAsRtfAction;
-import javax.swing.*;
-import javax.swing.event.CaretListener;
-import javax.swing.event.UndoableEditListener;
-import javax.swing.text.Document;
-import javax.swing.text.Element;
-import javax.swing.text.JTextComponent;
-import javax.swing.text.PlainDocument;
-import javax.swing.undo.UndoManager;
-import java.awt.*;
-import java.awt.dnd.DropTarget;
-import java.awt.event.MouseListener;
-import java.util.HashMap;
-
import org.fife.ui.rtextarea.RTextScrollPane;
@@ -73,25 +76,27 @@
}
_session = session;
- _propertiesWrapper = new RSyntaxPropertiesWrapper(props);
+ _propertiesWrapper = new RSyntaxPropertiesWrapper(props);
_textArea = new SquirrelRSyntaxTextArea(session, prefs, _propertiesWrapper, getIdentifier());
- _textScrollPane = new RTextScrollPane(_textArea);
+ super.addToSQLEntryAreaMenu(session.getApplication().getActionCollection().get(SquirrelCopyAsRtfAction.class));
- _textScrollPane.setLineNumbersEnabled(prefs.isLineNumbersEnabled());
+ _textScrollPane = new RTextScrollPane(_textArea);
+ _textScrollPane.setLineNumbersEnabled(prefs.isLineNumbersEnabled());
- dt = new DropTarget(_textArea, new FileEditorDropTargetListener(session));
+ dt = new DropTarget(_textArea, new FileEditorDropTargetListener(session));
- //////////////////////////////////////////////////////////////////////
- // Dragging inside the text area itself conflicts with file dnd
- // so we disable it. See bug #3006515
- _textArea.setDragEnabled(false);
- //
- ////////////////////////////////////////////////////////////////////
+
+ //////////////////////////////////////////////////////////////////////
+ // Dragging inside the text area itself conflicts with file dnd
+ // so we disable it. See bug #3006515
+ _textArea.setDragEnabled(false);
+ //
+ ////////////////////////////////////////////////////////////////////
}
public int getCaretLineNumber()
Added: trunk/sql12/plugins/syntax/src/main/java/net/sourceforge/squirrel_sql/plugins/syntax/rsyntax/action/SquirrelCopyAsRtfAction.java
===================================================================
--- trunk/sql12/plugins/syntax/src/main/java/net/sourceforge/squirrel_sql/plugins/syntax/rsyntax/action/SquirrelCopyAsRtfAction.java (rev 0)
+++ trunk/sql12/plugins/syntax/src/main/java/net/sourceforge/squirrel_sql/plugins/syntax/rsyntax/action/SquirrelCopyAsRtfAction.java 2011-06-04 08:17:45 UTC (rev 6286)
@@ -0,0 +1,58 @@
+/*
+ * Copyright (C) 2011 Stefan Willinger
+ * wi...@us...
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+package net.sourceforge.squirrel_sql.plugins.syntax.rsyntax.action;
+
+import java.awt.event.ActionEvent;
+
+import org.fife.ui.rsyntaxtextarea.RSyntaxTextAreaEditorKit.CopyAsRtfAction;
+
+import net.sourceforge.squirrel_sql.client.IApplication;
+import net.sourceforge.squirrel_sql.client.action.SquirrelAction;
+import net.sourceforge.squirrel_sql.fw.util.IResources;
+
+/**
+ * A Wrapper for {@link CopyAsRtfAction}.
+ * This wrapper is the simplest way to customize the action properties like name and tooltip.
+ * @author Stefan Willinger
+ *
+ */
+public class SquirrelCopyAsRtfAction extends SquirrelAction {
+
+ private CopyAsRtfAction delegate;
+
+
+ /**
+ * Construct a wrapper for {@link CopyAsRtfAction}
+ * @param app The application
+ * @param rsrc The plugin resources.
+ */
+ public SquirrelCopyAsRtfAction(IApplication app, IResources rsrc) {
+ super(app, rsrc);
+ delegate = new CopyAsRtfAction();
+ }
+
+ /**
+ * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
+ */
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ delegate.actionPerformed(e);
+ }
+
+}
Property changes on: trunk/sql12/plugins/syntax/src/main/java/net/sourceforge/squirrel_sql/plugins/syntax/rsyntax/action/SquirrelCopyAsRtfAction.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Modified: trunk/sql12/plugins/syntax/src/main/resources/net/sourceforge/squirrel_sql/plugins/syntax/I18NStrings.properties
===================================================================
--- trunk/sql12/plugins/syntax/src/main/resources/net/sourceforge/squirrel_sql/plugins/syntax/I18NStrings.properties 2011-06-03 16:53:55 UTC (rev 6285)
+++ trunk/sql12/plugins/syntax/src/main/resources/net/sourceforge/squirrel_sql/plugins/syntax/I18NStrings.properties 2011-06-04 08:17:45 UTC (rev 6286)
@@ -12,6 +12,7 @@
SyntaxPlugin.uncomment=uncomment
SyntaxPlugin.markSelected=markselected
SyntaxPlugin.gotoline=gotoline
+SyntaxPlugin.copyasrtf=copyasrtf
syntax.prefSyntax=Syntax
Modified: trunk/sql12/plugins/syntax/src/main/resources/net/sourceforge/squirrel_sql/plugins/syntax/SyntaxPluginResources.properties
===================================================================
--- trunk/sql12/plugins/syntax/src/main/resources/net/sourceforge/squirrel_sql/plugins/syntax/SyntaxPluginResources.properties 2011-06-03 16:53:55 UTC (rev 6285)
+++ trunk/sql12/plugins/syntax/src/main/resources/net/sourceforge/squirrel_sql/plugins/syntax/SyntaxPluginResources.properties 2011-06-04 08:17:45 UTC (rev 6286)
@@ -62,7 +62,11 @@
action.net.sourceforge.squirrel_sql.plugins.syntax.UncommentAction.name=Uncomment block
action.net.sourceforge.squirrel_sql.plugins.syntax.UncommentAction.tooltip=Uncomment block
+action.net.sourceforge.squirrel_sql.plugins.syntax.rsyntax.action.SquirrelCopyAsRtfAction.image=
+action.net.sourceforge.squirrel_sql.plugins.syntax.rsyntax.action.SquirrelCopyAsRtfAction.name=Copy in RTF
+action.net.sourceforge.squirrel_sql.plugins.syntax.rsyntax.action.SquirrelCopyAsRtfAction.tooltip=Copy in rich text format
+
########
# Menus.
########
@@ -99,7 +103,7 @@
menuitem.net.sourceforge.squirrel_sql.plugins.syntax.ReplaceAction.accelerator=control H
menuitem.net.sourceforge.squirrel_sql.plugins.syntax.ReplaceAction.mnemonic=
-
+tpa.addToToolsPopup(SyntaxPlugin.i18n.COPY_AS_RTF,_syntaxPugin.getApplication().getActionCollection().get(SquirrelCopyAsRtfAction.class));
menuitem.net.sourceforge.squirrel_sql.plugins.syntax.DuplicateLineAction.accelerator=control D
menuitem.net.sourceforge.squirrel_sql.plugins.syntax.DuplicateLineAction.mnemonic=
@@ -109,8 +113,11 @@
menuitem.net.sourceforge.squirrel_sql.plugins.syntax.UncommentAction.accelerator=control shift SUBTRACT
menuitem.net.sourceforge.squirrel_sql.plugins.syntax.UncommentAction.mnemonic=
+menuitem.net.sourceforge.squirrel_sql.plugins.syntax.rsyntax.action.SquirrelCopyAsRtfAction.accelerator
+menuitem.net.sourceforge.squirrel_sql.plugins.syntax.rsyntax.action.SquirrelCopyAsRtfAction.mnemonic
+
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|