Revision: 6242
http://squirrel-sql.svn.sourceforge.net/squirrel-sql/?rev=6242&view=rev
Author: wis775
Date: 2011-04-25 19:39:21 +0000 (Mon, 25 Apr 2011)
Log Message:
-----------
New function: Copy as WIKI table.
Provides a way, to copy the selection of a result table as WIKI text into the clipboard. This is a generic implementation, which does not provide any WIKI specific configuration. At the global preferences tab "WIKI table", the user can configure a specific configuration as a template. The user-specific configuration is saved in a own file.
Modified Paths:
--------------
trunk/sql12/app/src/main/java/net/sourceforge/squirrel_sql/client/Application.java
trunk/sql12/app/src/main/java/net/sourceforge/squirrel_sql/client/IApplication.java
trunk/sql12/app/src/main/java/net/sourceforge/squirrel_sql/client/preferences/GeneralPreferencesPanel.java
trunk/sql12/app/src/main/java/net/sourceforge/squirrel_sql/client/preferences/GlobalPreferencesSheet.java
trunk/sql12/app/src/main/java/net/sourceforge/squirrel_sql/client/preferences/PreferenceType.java
trunk/sql12/app/src/main/java/net/sourceforge/squirrel_sql/client/util/ApplicationFiles.java
trunk/sql12/app/src/main/resources/net/sourceforge/squirrel_sql/client/I18NStrings.properties
trunk/sql12/app/src/main/resources/net/sourceforge/squirrel_sql/client/preferences/I18NStrings.properties
trunk/sql12/doc/src/main/resources/changes.txt
trunk/sql12/fw/src/main/java/net/sourceforge/squirrel_sql/fw/gui/TablePopupMenu.java
trunk/sql12/fw/src/main/resources/net/sourceforge/squirrel_sql/fw/gui/I18NStrings.properties
trunk/sql12/fw/src/main/resources/net/sourceforge/squirrel_sql/fw/gui/action/I18NStrings.properties
Added Paths:
-----------
trunk/sql12/app/src/main/java/net/sourceforge/squirrel_sql/client/preferences/WikiTablePreferencesPanel.java
trunk/sql12/app/src/main/java/net/sourceforge/squirrel_sql/client/preferences/WikiTablePreferencesTab.java
trunk/sql12/fw/src/main/java/net/sourceforge/squirrel_sql/fw/gui/action/TableCopyWikiCommand.java
trunk/sql12/fw/src/main/java/net/sourceforge/squirrel_sql/fw/gui/action/wikiTable/
trunk/sql12/fw/src/main/java/net/sourceforge/squirrel_sql/fw/gui/action/wikiTable/CopyWikiTableAction.java
trunk/sql12/fw/src/main/java/net/sourceforge/squirrel_sql/fw/gui/action/wikiTable/CopyWikiTableActionFactory.java
trunk/sql12/fw/src/main/java/net/sourceforge/squirrel_sql/fw/gui/action/wikiTable/GenericWikiTableConfigurationBean.java
trunk/sql12/fw/src/main/java/net/sourceforge/squirrel_sql/fw/gui/action/wikiTable/GenericWikiTableTransformer.java
trunk/sql12/fw/src/main/java/net/sourceforge/squirrel_sql/fw/gui/action/wikiTable/ICopyWikiTableActionFactory.java
trunk/sql12/fw/src/main/java/net/sourceforge/squirrel_sql/fw/gui/action/wikiTable/ITableActionCallback.java
trunk/sql12/fw/src/main/java/net/sourceforge/squirrel_sql/fw/gui/action/wikiTable/IWikiTableConfiguration.java
trunk/sql12/fw/src/main/java/net/sourceforge/squirrel_sql/fw/gui/action/wikiTable/IWikiTableConfigurationFactory.java
trunk/sql12/fw/src/main/java/net/sourceforge/squirrel_sql/fw/gui/action/wikiTable/IWikiTableTransformer.java
trunk/sql12/fw/src/main/java/net/sourceforge/squirrel_sql/fw/gui/action/wikiTable/WikiTableConfigurationFactory.java
trunk/sql12/fw/src/main/java/net/sourceforge/squirrel_sql/fw/gui/action/wikiTable/WikiTableConfigurationStorage.java
trunk/sql12/fw/src/main/java/net/sourceforge/squirrel_sql/fw/gui/action/wikiTable/WikiTableSelection.java
trunk/sql12/fw/src/main/resources/net/sourceforge/squirrel_sql/fw/gui/action/wikiTable/
trunk/sql12/fw/src/main/resources/net/sourceforge/squirrel_sql/fw/gui/action/wikiTable/I18NStrings.properties
trunk/sql12/fw/src/test/java/net/sourceforge/squirrel_sql/fw/gui/action/wikiTable/
trunk/sql12/fw/src/test/java/net/sourceforge/squirrel_sql/fw/gui/action/wikiTable/AbstractWikiTableExporterTest.java
trunk/sql12/fw/src/test/java/net/sourceforge/squirrel_sql/fw/gui/action/wikiTable/CopyWikiTableActionFactoryTest.java
trunk/sql12/fw/src/test/java/net/sourceforge/squirrel_sql/fw/gui/action/wikiTable/GenericWikiTableConfigurationBeanTest.java
trunk/sql12/fw/src/test/java/net/sourceforge/squirrel_sql/fw/gui/action/wikiTable/WikiTableConfigurationFactoryTest.java
Modified: trunk/sql12/app/src/main/java/net/sourceforge/squirrel_sql/client/Application.java
===================================================================
--- trunk/sql12/app/src/main/java/net/sourceforge/squirrel_sql/client/Application.java 2011-04-23 20:44:03 UTC (rev 6241)
+++ trunk/sql12/app/src/main/java/net/sourceforge/squirrel_sql/client/Application.java 2011-04-25 19:39:21 UTC (rev 6242)
@@ -75,6 +75,10 @@
import net.sourceforge.squirrel_sql.fw.datasetviewer.CellImportExportInfoSaver;
import net.sourceforge.squirrel_sql.fw.datasetviewer.cellcomponent.DTProperties;
import net.sourceforge.squirrel_sql.fw.gui.ErrorDialog;
+import net.sourceforge.squirrel_sql.fw.gui.action.wikiTable.IWikiTableConfiguration;
+import net.sourceforge.squirrel_sql.fw.gui.action.wikiTable.IWikiTableConfigurationFactory;
+import net.sourceforge.squirrel_sql.fw.gui.action.wikiTable.WikiTableConfigurationFactory;
+import net.sourceforge.squirrel_sql.fw.gui.action.wikiTable.WikiTableConfigurationStorage;
import net.sourceforge.squirrel_sql.fw.sql.SQLDriverManager;
import net.sourceforge.squirrel_sql.fw.util.BareBonesBrowserLaunch;
import net.sourceforge.squirrel_sql.fw.util.BaseException;
@@ -149,6 +153,11 @@
/** Application level SQL History. */
private SQLHistory _sqlHistory;
+
+ /**
+ * Configuration factory for WIKI tables.
+ */
+ private IWikiTableConfigurationFactory wikiTableConfigFactory = WikiTableConfigurationFactory.getInstance();
/** Current type of JDBC debug logging that we are doing. */
private int _jdbcDebugType = SquirrelPreferences.IJdbcDebugTypes.NONE;
@@ -272,6 +281,9 @@
// Save options selected for DataType-specific properties
saveDataTypePreferences();
+
+ // Save user specific WIKI configurations
+ saveUserSpecificWikiConfigurations();
_prefs.save();
}
@@ -778,6 +790,10 @@
// i18n[Application.splash.loaddatatypeprops=Loading Data Type Properties...]
indicateNewStartupTask(splash, s_stringMgr.getString("Application.splash.loaddatatypeprops"));
loadDTProperties();
+
+ // i18n[Application.splash.loadsqlhistory=Loading user specific WIKI configurations...]
+ indicateNewStartupTask(splash, s_stringMgr.getString("Application.splash.loadUserSpecificWikiConfiguration"));
+ loadUserSpecificWikiTableConfigurations();
// i18n[Application.splash.showmainwindow=Showing main window...]
indicateNewStartupTask(splash, s_stringMgr.getString("Application.splash.showmainwindow"));
@@ -886,6 +902,43 @@
}
}
}
+
+ /**
+ * Load the configurations for WIKI tables.
+ * @see WikiTableConfigurationStorage
+ */
+ @SuppressWarnings("unchecked")
+ private void loadUserSpecificWikiTableConfigurations()
+ {
+ try
+ {
+ WikiTableConfigurationStorage data;
+
+ XMLBeanReader doc = new XMLBeanReader();
+ doc.load(new ApplicationFiles().getUserSpecificWikiConfigurationsFile());
+ Iterator it = doc.iterator();
+ if (it.hasNext()){
+ data = (WikiTableConfigurationStorage) it.next();
+ wikiTableConfigFactory.replaceUserSpecificConfigurations(data.configurationsAsList());
+ }
+ }
+ catch (FileNotFoundException ignore)
+ {
+ // History file not found for user - first time user ran pgm.
+ }
+ catch (Exception ex)
+ {
+ // i18n[Application.error.loadsqlhistory=Unable to load SQL history from persistant storage.]
+ s_log.error(s_stringMgr.getString("Application.error.loadUserSpecificWikiConfiguration"), ex);
+ }
+ finally
+ {
+ if (_sqlHistory == null)
+ {
+ _sqlHistory = new SQLHistory();
+ }
+ }
+ }
/**
* Save application level SQL history for current user.
@@ -917,6 +970,25 @@
s_log.error(s_stringMgr.getString("Application.error.savesqlhistory"), ex);
}
}
+
+ /**
+ * Save user specific configurations for WIKI tables
+ */
+ private void saveUserSpecificWikiConfigurations()
+ {
+ // Get the history into an array.
+ try
+ {
+ WikiTableConfigurationStorage data = new WikiTableConfigurationStorage(wikiTableConfigFactory.getUserSpecificConfigurations());
+
+ XMLBeanWriter wtr = new XMLBeanWriter(data);
+ wtr.save(new ApplicationFiles().getUserSpecificWikiConfigurationsFile());
+ }
+ catch (Exception ex)
+ {
+ s_log.error(s_stringMgr.getString("Application.error.saveUserSpecificWikiConfiguration"), ex);
+ }
+ }
/**
* Load the options previously selected by user for import/export of data in various Cells.
@@ -1106,6 +1178,9 @@
case EDITWHERECOL_PREFERENCES:
saveEditWhereColsInfo();
break;
+ case WIKI_CONFIGURATION:
+ saveUserSpecificWikiConfigurations();
+ break;
default:
s_log.error("Unknown preference type: " + preferenceType);
}
@@ -1243,5 +1318,17 @@
public void setShutdownTimer(IShutdownTimer shutdownTimer)
{
_shutdownTimer = shutdownTimer;
+ }
+
+ /**
+ * @see net.sourceforge.squirrel_sql.client.IApplication#getWikiTableConfigFactory()
+ */
+ @Override
+ public IWikiTableConfigurationFactory getWikiTableConfigFactory() {
+ return wikiTableConfigFactory;
+ }
+
+ public void setWikiTableConfigFactory(IWikiTableConfigurationFactory wikiTableConfigFactory) {
+ this.wikiTableConfigFactory = wikiTableConfigFactory;
}
}
Modified: trunk/sql12/app/src/main/java/net/sourceforge/squirrel_sql/client/IApplication.java
===================================================================
--- trunk/sql12/app/src/main/java/net/sourceforge/squirrel_sql/client/IApplication.java 2011-04-23 20:44:03 UTC (rev 6241)
+++ trunk/sql12/app/src/main/java/net/sourceforge/squirrel_sql/client/IApplication.java 2011-04-25 19:39:21 UTC (rev 6242)
@@ -23,13 +23,9 @@
import javax.swing.JComponent;
import javax.swing.JMenu;
-import net.sourceforge.squirrel_sql.client.gui.db.DataCache;
-import net.sourceforge.squirrel_sql.fw.sql.SQLDriverManager;
-import net.sourceforge.squirrel_sql.fw.util.IMessageHandler;
-import net.sourceforge.squirrel_sql.fw.util.TaskThreadPool;
-
import net.sourceforge.squirrel_sql.client.action.ActionCollection;
import net.sourceforge.squirrel_sql.client.gui.WindowManager;
+import net.sourceforge.squirrel_sql.client.gui.db.DataCache;
import net.sourceforge.squirrel_sql.client.gui.desktopcontainer.DesktopStyle;
import net.sourceforge.squirrel_sql.client.gui.mainframe.MainFrame;
import net.sourceforge.squirrel_sql.client.plugin.IPlugin;
@@ -40,6 +36,10 @@
import net.sourceforge.squirrel_sql.client.session.ISQLEntryPanelFactory;
import net.sourceforge.squirrel_sql.client.session.SessionManager;
import net.sourceforge.squirrel_sql.client.session.mainpanel.SQLHistory;
+import net.sourceforge.squirrel_sql.fw.gui.action.wikiTable.IWikiTableConfigurationFactory;
+import net.sourceforge.squirrel_sql.fw.sql.SQLDriverManager;
+import net.sourceforge.squirrel_sql.fw.util.IMessageHandler;
+import net.sourceforge.squirrel_sql.fw.util.TaskThreadPool;
/**
* Defines the API to do callbacks on the application.
*/
@@ -237,4 +237,13 @@
void removeApplicationListener(ApplicationListener l);
+
+ /**
+ * Returns a factory for WIKI table configurations.
+ * This factory is managing the system and user-specific configurations for WIKI tables.
+ * @return A factory for WIKI table configurations.
+ * @see IWikiTableConfigurationFactory
+ */
+ IWikiTableConfigurationFactory getWikiTableConfigFactory();
+
}
Modified: trunk/sql12/app/src/main/java/net/sourceforge/squirrel_sql/client/preferences/GeneralPreferencesPanel.java
===================================================================
--- trunk/sql12/app/src/main/java/net/sourceforge/squirrel_sql/client/preferences/GeneralPreferencesPanel.java 2011-04-23 20:44:03 UTC (rev 6241)
+++ trunk/sql12/app/src/main/java/net/sourceforge/squirrel_sql/client/preferences/GeneralPreferencesPanel.java 2011-04-25 19:39:21 UTC (rev 6242)
@@ -21,23 +21,31 @@
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;
+import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
-import java.awt.event.ActionEvent;
import java.util.ArrayList;
-import javax.swing.*;
+import javax.swing.BorderFactory;
+import javax.swing.BoxLayout;
+import javax.swing.ButtonGroup;
+import javax.swing.JCheckBox;
+import javax.swing.JComboBox;
+import javax.swing.JLabel;
+import javax.swing.JPanel;
+import javax.swing.JRadioButton;
+import javax.swing.JScrollPane;
+import javax.swing.JTextField;
import javax.swing.border.EmptyBorder;
-import org.apache.commons.lang.StringUtils;
-
import net.sourceforge.squirrel_sql.client.ApplicationArguments;
import net.sourceforge.squirrel_sql.client.IApplication;
import net.sourceforge.squirrel_sql.client.util.ApplicationFiles;
import net.sourceforge.squirrel_sql.fw.util.LocaleUtils;
import net.sourceforge.squirrel_sql.fw.util.StringManager;
import net.sourceforge.squirrel_sql.fw.util.StringManagerFactory;
-import net.sourceforge.squirrel_sql.fw.util.StringUtilities;
+import org.apache.commons.lang.StringUtils;
+
class GeneralPreferencesPanel implements IGlobalPreferencesPanel
{
/** Internationalized strings for this class. */
Modified: trunk/sql12/app/src/main/java/net/sourceforge/squirrel_sql/client/preferences/GlobalPreferencesSheet.java
===================================================================
--- trunk/sql12/app/src/main/java/net/sourceforge/squirrel_sql/client/preferences/GlobalPreferencesSheet.java 2011-04-23 20:44:03 UTC (rev 6241)
+++ trunk/sql12/app/src/main/java/net/sourceforge/squirrel_sql/client/preferences/GlobalPreferencesSheet.java 2011-04-25 19:39:21 UTC (rev 6242)
@@ -308,6 +308,7 @@
_panels.add(new ProxyPreferencesPanel());
_panels.add(new DataTypePreferencesPanel());
_panels.add(new UpdatePreferencesTab());
+ _panels.add(new WikiTablePreferencesTab());
// Go thru all loaded plugins asking for panels.
PluginInfo[] plugins = _app.getPluginManager().getPluginInformation();
Modified: trunk/sql12/app/src/main/java/net/sourceforge/squirrel_sql/client/preferences/PreferenceType.java
===================================================================
--- trunk/sql12/app/src/main/java/net/sourceforge/squirrel_sql/client/preferences/PreferenceType.java 2011-04-23 20:44:03 UTC (rev 6241)
+++ trunk/sql12/app/src/main/java/net/sourceforge/squirrel_sql/client/preferences/PreferenceType.java 2011-04-25 19:39:21 UTC (rev 6242)
@@ -31,5 +31,6 @@
DATATYPE_PREFERENCES,
CELLIMPORTEXPORT_PREFERENCES,
SQLHISTORY,
- EDITWHERECOL_PREFERENCES
+ EDITWHERECOL_PREFERENCES,
+ WIKI_CONFIGURATION
}
Added: trunk/sql12/app/src/main/java/net/sourceforge/squirrel_sql/client/preferences/WikiTablePreferencesPanel.java
===================================================================
--- trunk/sql12/app/src/main/java/net/sourceforge/squirrel_sql/client/preferences/WikiTablePreferencesPanel.java (rev 0)
+++ trunk/sql12/app/src/main/java/net/sourceforge/squirrel_sql/client/preferences/WikiTablePreferencesPanel.java 2011-04-25 19:39:21 UTC (rev 6242)
@@ -0,0 +1,816 @@
+/*
+ * 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.client.preferences;
+
+import java.awt.BorderLayout;
+import java.awt.Component;
+import java.awt.Dimension;
+import java.awt.FlowLayout;
+import java.awt.GridBagConstraints;
+import java.awt.GridBagLayout;
+import java.awt.Insets;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.awt.event.FocusEvent;
+import java.awt.event.FocusListener;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.swing.BorderFactory;
+import javax.swing.DefaultListModel;
+import javax.swing.JButton;
+import javax.swing.JCheckBox;
+import javax.swing.JLabel;
+import javax.swing.JList;
+import javax.swing.JPanel;
+import javax.swing.JScrollPane;
+import javax.swing.JTable;
+import javax.swing.JTextArea;
+import javax.swing.JTextField;
+import javax.swing.ListSelectionModel;
+import javax.swing.SwingConstants;
+import javax.swing.SwingUtilities;
+import javax.swing.event.ListSelectionEvent;
+import javax.swing.event.ListSelectionListener;
+
+import net.sourceforge.squirrel_sql.client.IApplication;
+import net.sourceforge.squirrel_sql.fw.gui.action.wikiTable.GenericWikiTableConfigurationBean;
+import net.sourceforge.squirrel_sql.fw.gui.action.wikiTable.IWikiTableConfiguration;
+import net.sourceforge.squirrel_sql.fw.gui.action.wikiTable.IWikiTableConfigurationFactory;
+import net.sourceforge.squirrel_sql.fw.gui.action.wikiTable.WikiTableConfigurationFactory;
+import net.sourceforge.squirrel_sql.fw.util.StringManager;
+import net.sourceforge.squirrel_sql.fw.util.StringManagerFactory;
+
+import org.apache.commons.lang.StringUtils;
+
+/**
+ * Preferences panel for WIKI table configurations
+ * @author Stefan Willinger
+ *
+ */
+public class WikiTablePreferencesPanel extends JPanel {
+
+ /** Internationalized strings for this class. */
+ private static final StringManager s_stringMgr =
+ StringManagerFactory.getStringManager(WikiTablePreferencesPanel.class);
+
+ private final Insets LABEL_INSETS = new Insets(2, 28, 6, 0);
+
+ private final Insets FIELD_INSETS = new Insets(2, 8, 6, 28);
+
+
+ private IWikiTableConfigurationFactory wikiTableConfigFactory = WikiTableConfigurationFactory.getInstance();
+
+
+ private IApplication application;
+
+
+ // Components of the detail panel
+
+ private JLabel nameLable = null;
+
+ private JTextField name = null;
+
+ private JLabel tableStartTagLabel = null;
+
+ private JTextField tableStartTag = null;
+
+ private JLabel headerStartTagLabel = null;
+
+ private JTextField headerStartTag = null;
+
+ private JLabel headerCellTagLabel = null;
+
+ private JTextField headerCellTag = null;
+
+ private JLabel headerEndTagLabel = null;
+
+ private JTextField headerEndTag = null;
+
+ private JLabel rowStartTagLabel = null;
+
+ private JTextField rowStartTag = null;
+
+ private JLabel cellTagLabel = null;
+
+ private JTextField cellTag = null;
+
+ private JLabel rowEndTagLabel = null;
+
+ private JTextField rowEndTag = null;
+
+ private JLabel tableEndTagLabel = null;
+
+ private JTextField tableEndTag = null;
+
+ private JLabel noWikiTagLabel = null;
+
+ private JTextField noWikiTag = null;
+
+ private DefaultListModel wikiConfigListModel = null;
+
+ private JList wikiConfigList;
+
+ private JButton newButton;
+
+ private JButton copyButton;
+
+ private JButton deleteButton;
+
+ private JTable exampleTable;
+
+ private JTextArea exampleText;
+
+ private IWikiTableConfiguration currentConfigurationInView;
+
+ private JCheckBox enabled;
+
+
+
+ public WikiTablePreferencesPanel()
+ {
+ super(new GridBagLayout());
+ createUserInterface();
+ }
+
+
+ /**
+ * Creates the user Interface
+ */
+ private void createUserInterface()
+ {
+ JPanel jp = new JPanel(new GridBagLayout());
+
+ GridBagConstraints gbc = new GridBagConstraints();
+ gbc.fill = GridBagConstraints.BOTH;
+ gbc.insets = new Insets(4, 4, 4, 4);
+ gbc.gridx = 0;
+ gbc.gridy = 0;
+ gbc.weightx = 0;
+ gbc.weighty = 1;
+ jp.add(createOverviewPanel(), gbc);
+
+ gbc.gridy = 1;
+ gbc.weighty = 0;
+ gbc.fill = GridBagConstraints.HORIZONTAL;
+ jp.add(createNotePanel(), gbc);
+
+ gbc.weightx = 1;
+ gbc.weighty = 1;
+ gbc.gridheight=2;
+ gbc.gridy = 0;
+ gbc.gridx =1;
+ gbc.fill = GridBagConstraints.BOTH;
+
+ jp.add(createDetailPanel(), gbc);
+
+
+ gbc.weightx = 1;
+ gbc.weighty = 1;
+ gbc.gridheight=2;
+ gbc.gridy = 0;
+ gbc.gridx =2;
+ gbc.fill = GridBagConstraints.BOTH;
+
+ jp.add(createExamplePanel(), gbc);
+
+ JScrollPane sp = new JScrollPane(jp);
+ gbc = new GridBagConstraints();
+ gbc.fill=GridBagConstraints.BOTH;
+ gbc.weightx=1;
+ gbc.weighty=1;
+ add(sp,gbc);
+
+ }
+
+ /**
+ * Create the component, which shows a example.
+ * The example contains a {@link JTable} and a {@link JTextField}. If the user change a element of the configuration, then the example will be updated.
+ * So we can provide a feedback of the result immediately.
+ */
+ private Component createExamplePanel() {
+ JPanel jp = new JPanel(new GridBagLayout());
+ jp.setBorder(BorderFactory.createTitledBorder(s_stringMgr.getString("WikiTablePreferencesPanel.titleExample"))); //$NON-NLS-1$
+
+ GridBagConstraints gbc = new GridBagConstraints();
+
+
+ String[][] rowData = new String[][]{
+ {s_stringMgr.getString("WikiTablePreferencesPanel.austria"), s_stringMgr.getString("WikiTablePreferencesPanel.vienna")}, //$NON-NLS-1$ //$NON-NLS-2$
+ {s_stringMgr.getString("WikiTablePreferencesPanel.italy"), s_stringMgr.getString("WikiTablePreferencesPanel.rome")} //$NON-NLS-1$ //$NON-NLS-2$
+ };
+
+ String[] columnNames = new String[]{s_stringMgr.getString("WikiTablePreferencesPanel.country"), s_stringMgr.getString("WikiTablePreferencesPanel.captial")}; //$NON-NLS-1$ //$NON-NLS-2$
+
+ exampleTable = new JTable(rowData, columnNames);
+ exampleTable.setMinimumSize(new Dimension(10,10));
+
+ JScrollPane sp = new JScrollPane(exampleTable);
+ sp.setPreferredSize(new Dimension(100,50));
+
+ gbc.fill=GridBagConstraints.BOTH;
+ gbc.weighty=1;
+ gbc.weighty=0.1;
+ jp.add(sp, gbc);
+
+
+ gbc.gridx=0;
+ gbc.gridy=1;
+ gbc.fill=GridBagConstraints.HORIZONTAL;
+ gbc.weighty=0;
+ gbc.weightx=0;
+ jp.add(new JLabel(s_stringMgr.getString("WikiTablePreferencesPanel.titleResultExample")), gbc); //$NON-NLS-1$
+
+
+ exampleText = new JTextArea(15,20);
+ exampleText.setWrapStyleWord(true);
+ exampleText.setEditable(false);
+ exampleText.setLineWrap(false);
+
+
+ gbc.gridy=2;
+ gbc.fill=GridBagConstraints.BOTH;
+ gbc.weighty=1;
+ gbc.weightx=1;
+
+ sp = new JScrollPane(exampleText);
+ jp.add(sp, gbc);
+
+ return jp;
+ }
+
+
+ /**
+ * Create the panel with a small help text for the user.
+ * This panel indicates, which variables are allowed.
+ */
+ private Component createNotePanel() {
+ JPanel jp = new JPanel();
+ jp.setBorder(BorderFactory.createTitledBorder("Note")); //$NON-NLS-1$
+
+
+ String text = "<html><body>"+ //$NON-NLS-1$
+ s_stringMgr.getString("WikiTablePreferencesPanel.hintValueVariable") + //$NON-NLS-1$
+ "<br />" + //$NON-NLS-1$
+ s_stringMgr.getString("WikiTablePreferencesPanel.hintNewLine") + //$NON-NLS-1$
+ "</body></html>"; //$NON-NLS-1$
+ JLabel label = new JLabel(text);
+
+ jp.add(label);
+
+ return jp;
+ }
+
+
+ /**
+ * The overview panel contains a list of all available configurations.
+ * There are some methods provided for creating, copying or deleting configurations.
+ * @return
+ */
+ private Component createOverviewPanel() {
+ JPanel jp = new JPanel(new BorderLayout());
+ jp.setBorder(BorderFactory.createTitledBorder(s_stringMgr.getString("WikiTablePreferencesPanel.titleOverview"))); //$NON-NLS-1$
+
+ wikiConfigListModel = new DefaultListModel();
+
+ wikiConfigList = new JList(wikiConfigListModel);
+ wikiConfigList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
+ wikiConfigList.addListSelectionListener(new ListSelectionListener() {
+ @Override
+ public void valueChanged(ListSelectionEvent e) {
+ SwingUtilities.invokeLater(new Runnable() {
+
+ @Override
+ public void run() {
+ IWikiTableConfiguration selectedValue = (IWikiTableConfiguration) wikiConfigList.getSelectedValue();
+ showDataFor(selectedValue);
+ if(selectedValue != null){
+ copyButton.setEnabled(true);
+ }else{
+ copyButton.setEnabled(false);
+ }
+ }
+ });
+
+ }
+ });
+
+ JScrollPane sp = new JScrollPane(wikiConfigList);
+
+ JPanel buttonPanel = new JPanel(new FlowLayout());
+ newButton = new JButton(s_stringMgr.getString("WikiTablePreferencesPanel.new")); //$NON-NLS-1$
+ newButton.addActionListener(new ActionListener() {
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ IWikiTableConfiguration newConfig = new GenericWikiTableConfigurationBean();
+ addNewConfigToList(newConfig);
+ }
+
+ private void addNewConfigToList(IWikiTableConfiguration newConfig) {
+ wikiConfigListModel.addElement(newConfig);
+ wikiConfigList.setSelectedValue(newConfig, true);
+ }
+ });
+ buttonPanel.add(newButton);
+
+ copyButton = new JButton(s_stringMgr.getString("WikiTablePreferencesPanel.copy")); //$NON-NLS-1$
+ copyButton.addActionListener(new ActionListener() {
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ IWikiTableConfiguration newConfig = ((IWikiTableConfiguration)wikiConfigList.getSelectedValue()).copyAsUserSpecific();
+
+ int suffix = 0;
+
+ String originalName = newConfig.getName();
+
+ do{
+ suffix++;
+ newConfig.setName(originalName+"_"+suffix); //$NON-NLS-1$
+ }while(!isUniqueName(newConfig));
+
+
+ addNewConfigToList(newConfig);
+ }
+
+
+ });
+
+ buttonPanel.add(copyButton);
+
+ deleteButton = new JButton(s_stringMgr.getString("WikiTablePreferencesPanel.delete")); //$NON-NLS-1$
+ deleteButton.addActionListener(new ActionListener() {
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ int selectedIndex = wikiConfigList.getSelectedIndex();
+ wikiConfigList.setSelectedIndex(0);
+ wikiConfigListModel.remove(selectedIndex);
+ // we always have at least on item - the build in configuration
+// wikiConfigList.invalidate();
+ }
+ });
+ buttonPanel.add(deleteButton);
+
+ jp.add(sp, BorderLayout.CENTER);
+ jp.add(buttonPanel, BorderLayout.SOUTH);
+
+ return jp;
+ }
+
+
+ /**
+ * The detail panel contains all information of a specific configuration.
+ * The user can edit the configuration in this panel.
+ */
+ private JPanel createDetailPanel(){
+ JPanel jp = new JPanel(new GridBagLayout());
+ jp.setBorder(BorderFactory.createTitledBorder(s_stringMgr.getString("WikiTablePreferencesPanel.titleDetailPanel"))); //$NON-NLS-1$
+ jp.setMinimumSize(new Dimension(400,50));
+
+ final GridBagConstraints gbc = new GridBagConstraints();
+
+ int row= 0;
+
+ setLabelConstraints(gbc, row);
+ nameLable = new JLabel(s_stringMgr.getString("WikiTablePreferencesPanel.name"), SwingConstants.RIGHT); //$NON-NLS-1$
+ jp.add(nameLable, gbc);
+
+ setFieldConstraints(gbc, row);
+ name = new JTextField(30);
+ jp.add(name, gbc);
+
+ setLabelConstraints(gbc, ++row);
+ tableStartTagLabel = new JLabel(s_stringMgr.getString("WikiTablePreferencesPanel.tableStartTag"), SwingConstants.RIGHT); //$NON-NLS-1$
+ jp.add(tableStartTagLabel, gbc);
+
+ setFieldConstraints(gbc, row);
+ tableStartTag = new JTextField(30);
+ jp.add(tableStartTag, gbc);
+
+
+ setLabelConstraints(gbc, ++row);
+ headerStartTagLabel = new JLabel(s_stringMgr.getString("WikiTablePreferencesPanel.headerStartTag"), SwingConstants.RIGHT); //$NON-NLS-1$
+ jp.add(headerStartTagLabel, gbc);
+
+ setFieldConstraints(gbc, row);
+ headerStartTag = new JTextField(30);
+ jp.add(headerStartTag, gbc);
+
+ setLabelConstraints(gbc, ++row);
+ headerCellTagLabel = new JLabel(s_stringMgr.getString("WikiTablePreferencesPanel.headerCellTag"), SwingConstants.RIGHT); //$NON-NLS-1$
+ jp.add(headerCellTagLabel, gbc);
+
+ setFieldConstraints(gbc, row);
+ headerCellTag = new JTextField(30);
+ jp.add(headerCellTag, gbc);
+
+ setLabelConstraints(gbc, ++row);
+ headerEndTagLabel = new JLabel(s_stringMgr.getString("WikiTablePreferencesPanel.headerEndTag"), SwingConstants.RIGHT); //$NON-NLS-1$
+ jp.add(headerEndTagLabel, gbc);
+
+ setFieldConstraints(gbc, row);
+ headerEndTag = new JTextField(30);
+ jp.add(headerEndTag, gbc);
+
+ setLabelConstraints(gbc, ++row);
+ rowStartTagLabel = new JLabel(s_stringMgr.getString("WikiTablePreferencesPanel.rowStartTag"), SwingConstants.RIGHT); //$NON-NLS-1$
+ jp.add(rowStartTagLabel, gbc);
+
+ setFieldConstraints(gbc, row);
+ rowStartTag = new JTextField(30);
+ jp.add(rowStartTag, gbc);
+
+ setLabelConstraints(gbc, ++row);
+ cellTagLabel = new JLabel(s_stringMgr.getString("WikiTablePreferencesPanel.cellTag"), SwingConstants.RIGHT); //$NON-NLS-1$
+ jp.add(cellTagLabel, gbc);
+
+ setFieldConstraints(gbc, row);
+ cellTag = new JTextField(30);
+ jp.add(cellTag, gbc);
+
+ setLabelConstraints(gbc, ++row);
+ rowEndTagLabel = new JLabel(s_stringMgr.getString("WikiTablePreferencesPanel.rowEndTag"), SwingConstants.RIGHT); //$NON-NLS-1$
+ jp.add(rowEndTagLabel, gbc);
+
+ setFieldConstraints(gbc, row);
+ rowEndTag = new JTextField(30);
+ jp.add(rowEndTag, gbc);
+
+ setLabelConstraints(gbc, ++row);
+ tableEndTagLabel = new JLabel(s_stringMgr.getString("WikiTablePreferencesPanel.tableEndTag"), SwingConstants.RIGHT); //$NON-NLS-1$
+ jp.add(tableEndTagLabel, gbc);
+
+ setFieldConstraints(gbc, row);
+ tableEndTag = new JTextField(30);
+ jp.add(tableEndTag, gbc);
+
+ setLabelConstraints(gbc, ++row);
+ noWikiTagLabel = new JLabel(s_stringMgr.getString("WikiTablePreferencesPanel.noWikiTag"), SwingConstants.RIGHT); //$NON-NLS-1$
+ jp.add(noWikiTagLabel, gbc);
+
+ setFieldConstraints(gbc, row);
+ noWikiTag = new JTextField(30);
+ jp.add(noWikiTag, gbc);
+
+ setLabelConstraints(gbc, ++row);
+ noWikiTagLabel = new JLabel(s_stringMgr.getString("WikiTablePreferencesPanel.enabled"), SwingConstants.RIGHT); //$NON-NLS-1$
+ jp.add(noWikiTagLabel, gbc);
+
+ setFieldConstraints(gbc, row);
+ enabled = new JCheckBox();
+ jp.add(enabled, gbc);
+
+ addFocusLostListeners();
+
+ return jp;
+ }
+
+
+ /**
+ * Adds a {@link FocusListener} for the focus lost event to all input fields of the detail panel.
+ * This listener updated the configuration and the example.
+ */
+ private void addFocusLostListeners() {
+ name.addFocusListener(new DetailConfigFocusLostListener(){
+ @Override
+ public void setValue(IWikiTableConfiguration config) throws IllegalArgumentException {
+ String newName = name.getText();
+ config.setName(newName);
+
+ if(!isUniqueName(config)){
+ throw new IllegalArgumentException(s_stringMgr.getString("WikiTablePreferencesPanel.errorConfigNotUnique")); //$NON-NLS-1$
+ }
+ }
+ });
+
+
+ tableStartTag.addFocusListener(new DetailConfigFocusLostListener(){
+ @Override
+ public void setValue(IWikiTableConfiguration config) throws IllegalArgumentException {
+ config.setTableStartTag(tableStartTag.getText());
+ }
+ });
+
+ headerStartTag.addFocusListener(new DetailConfigFocusLostListener(){
+ @Override
+ public void setValue(IWikiTableConfiguration config) throws IllegalArgumentException {
+ config.setHeaderStartTag(headerStartTag.getText());
+ }
+ });
+
+ headerCellTag.addFocusListener(new DetailConfigFocusLostListener(){
+ @Override
+ public void setValue(IWikiTableConfiguration config) throws IllegalArgumentException {
+ config.setHeaderCell(headerCellTag.getText());
+ }
+ });
+
+ headerEndTag.addFocusListener(new DetailConfigFocusLostListener(){
+ @Override
+ public void setValue(IWikiTableConfiguration config) throws IllegalArgumentException {
+ config.setHeaderEndTag(headerEndTag.getText());
+ }
+ });
+
+ rowStartTag.addFocusListener(new DetailConfigFocusLostListener(){
+ @Override
+ public void setValue(IWikiTableConfiguration config) throws IllegalArgumentException {
+ config.setRowStartTag(rowStartTag.getText());
+ }
+ });
+
+ cellTag.addFocusListener(new DetailConfigFocusLostListener(){
+ @Override
+ public void setValue(IWikiTableConfiguration config) throws IllegalArgumentException {
+ config.setDataCell(cellTag.getText());
+ }
+ });
+
+ rowEndTag.addFocusListener(new DetailConfigFocusLostListener(){
+ @Override
+ public void setValue(IWikiTableConfiguration config) throws IllegalArgumentException {
+ config.setRowEndTag(rowEndTag.getText());
+ }
+ });
+
+ tableEndTag.addFocusListener(new DetailConfigFocusLostListener(){
+ @Override
+ public void setValue(IWikiTableConfiguration config) throws IllegalArgumentException {
+ config.setTableEndTag(tableEndTag.getText());
+ }
+ });
+
+ noWikiTag.addFocusListener(new DetailConfigFocusLostListener(){
+ @Override
+ public void setValue(IWikiTableConfiguration config) throws IllegalArgumentException {
+ config.setNoWikiTag(noWikiTag.getText());
+ }
+ });
+
+ enabled.addActionListener(new ActionListener() {
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ IWikiTableConfiguration config = currentConfigurationInView;
+ config.setEnabled(enabled.isSelected());
+ }
+ });
+
+ }
+
+
+ private void setLabelConstraints(GridBagConstraints gbc, int gridy)
+ {
+ gbc.gridx = 0;
+ gbc.gridy = gridy;
+// gbc.gridwidth = 0;
+ gbc.weightx = 0;
+ gbc.insets = LABEL_INSETS;
+ gbc.fill = GridBagConstraints.NONE;
+ gbc.anchor = GridBagConstraints.EAST;
+ }
+
+ private void setFieldConstraints(GridBagConstraints gbc, int gridy)
+ {
+ gbc.gridx = 1;
+ gbc.gridy = gridy;
+// gbc.gridwidth = 0;
+ gbc.weightx = 1;
+ gbc.insets = FIELD_INSETS;
+ gbc.fill = GridBagConstraints.HORIZONTAL;
+ gbc.anchor = GridBagConstraints.WEST;
+
+ }
+
+ public IApplication getApplication() {
+ return application;
+ }
+
+ public void setApplication(IApplication app) {
+ this.application = app;
+ }
+
+ /**
+ * Adds all available configurations to this page
+ * @param squirrelPreferences
+ */
+ public void loadData(SquirrelPreferences squirrelPreferences) {
+
+ List<IWikiTableConfiguration> configurations = wikiTableConfigFactory.getConfigurations();
+
+ for (IWikiTableConfiguration configuration : configurations) {
+ wikiConfigListModel.addElement(configuration);
+ }
+
+ wikiConfigList.setSelectedIndex(0);
+
+ IWikiTableConfiguration selectedValue = (IWikiTableConfiguration)wikiConfigList.getSelectedValue();
+ showDataFor(selectedValue);
+ if(selectedValue == null){
+ this.copyButton.setEnabled(false);
+ }
+
+ }
+
+
+ /**
+ * Shows the data of a specific configuration in the detail panel
+ * @param selectedValue
+ */
+ private void showDataFor(IWikiTableConfiguration selectedValue) {
+ if(selectedValue != null){
+ this.currentConfigurationInView = selectedValue;
+ fillDetailPane(selectedValue);
+ showExample(selectedValue);
+ }else{
+ this.currentConfigurationInView = null;
+ enableInputFields(false);
+ }
+ }
+
+ /**
+ * Disable all input fields
+ */
+ private void enableInputFields(boolean enabled) {
+ this.name.setEnabled(enabled);
+ this.tableStartTag.setEnabled(enabled);
+ this.headerStartTag.setEnabled(enabled);
+ this.headerCellTag.setEnabled(enabled);
+ this.headerEndTag.setEnabled(enabled);
+ this.rowStartTag.setEnabled(enabled);
+ this.cellTag.setEnabled(enabled);
+ this.rowEndTag.setEnabled(enabled);
+ this.tableEndTag.setEnabled(enabled);
+ this.noWikiTag.setEnabled(enabled);
+ this.deleteButton.setEnabled(enabled);
+
+ if(currentConfigurationInView != null){
+ this.enabled.setEnabled(true);
+ }else{
+ this.enabled.setEnabled(false);
+ }
+ }
+
+
+ /**
+ * Shows the example for a specific configuration
+ */
+ private void showExample(IWikiTableConfiguration selectedValue) {
+ // select all rows
+ exampleTable.changeSelection(0, 0, false, false);
+ exampleTable.changeSelection(exampleTable.getRowCount()-1, exampleTable.getColumnCount()-1, true, true);
+
+
+ String example = selectedValue.createTransformer().transform(this.exampleTable);
+ this.exampleText.setText(example);
+ }
+
+
+ /**
+ * Fills the detail pane with the values of the selected configuration
+ * @param selectedValue
+ */
+ private void fillDetailPane(IWikiTableConfiguration config) {
+
+ this.name.setText(config.getName());
+
+ this.tableStartTag.setText(config.getTableStartTag());
+
+ this.headerStartTag.setText(config.getHeaderStartTag());
+
+ this.headerCellTag.setText(config.getHeaderCell());
+
+ this.headerEndTag.setText(config.getHeaderEndTag());
+
+ this.rowStartTag.setText(config.getRowStartTag());
+
+ this.cellTag.setText(config.getDataCell());
+
+ this.rowEndTag.setText(config.getRowEndTag());
+
+ this.tableEndTag.setText(config.getTableEndTag());
+
+ this.noWikiTag.setText(config.getNoWikiTag());
+
+ this.enabled.setSelected(config.isEnabled());
+
+ enableInputFields(!config.isReadOnly());
+ }
+
+ /**
+ * Adds a new configuration to the list.
+ */
+ private void addNewConfigToList(IWikiTableConfiguration newConfig) {
+ wikiConfigListModel.addElement(newConfig);
+ wikiConfigList.setSelectedValue(newConfig, true);
+ }
+
+ /**
+ * checks, if the name of a configuration is unique in the system.
+ */
+ private boolean isUniqueName(IWikiTableConfiguration config) {
+ boolean unique;
+ Object[] configArray = wikiConfigListModel.toArray();
+ unique = true;
+ for (Object conf : configArray) {
+ // This must be a check, if the references are identical.
+ if(conf != conf){
+ if(StringUtils.equalsIgnoreCase(config.getName(), ((IWikiTableConfiguration) conf).getName())){
+ unique = false;
+ }
+ }
+ }
+ return unique;
+ }
+
+ private abstract class DetailConfigFocusLostListener implements FocusListener{
+
+ /* (non-Javadoc)
+ * @see java.awt.event.FocusListener#focusGained(java.awt.event.FocusEvent)
+ */
+ @Override
+ public void focusGained(FocusEvent envent) {
+ // nothing
+
+ }
+
+ /* (non-Javadoc)
+ * @see java.awt.event.FocusListener#focusLost(java.awt.event.FocusEvent)
+ */
+ @Override
+ public void focusLost(final FocusEvent event) {
+ if(!event.isTemporary()){
+ IWikiTableConfiguration config = currentConfigurationInView;
+ try{
+ setValue(config);
+ }catch (IllegalArgumentException e) {
+ application.showErrorDialog(e.getMessage());
+ JTextField textField = (JTextField) event.getComponent();
+ String text = textField.getText();
+ System.out.println(text);
+ SwingUtilities.invokeLater(new Runnable() {
+
+ @Override
+ public void run() {
+ event.getComponent().requestFocus();
+ }
+ });
+ }
+ showExample(config);
+ }
+
+ }
+
+ public abstract void setValue(IWikiTableConfiguration config) throws IllegalArgumentException;
+
+ }
+
+ /**
+ * Puts the configurations back into the {@link IWikiTableConfigurationFactory}.
+ * @see IWikiTableConfigurationFactory#replaceUserSpecificConfigurations(List)
+ * @param squirrelPreferences
+ */
+ public void applyChanges() {
+
+ Object[] array = wikiConfigListModel.toArray();
+
+ List<IWikiTableConfiguration> userSpecific = new ArrayList<IWikiTableConfiguration>();
+ List<IWikiTableConfiguration> buildIn = new ArrayList<IWikiTableConfiguration>();
+ for (Object object : array) {
+ IWikiTableConfiguration config = (IWikiTableConfiguration) object;
+ if(config.isReadOnly() == false){
+ userSpecific.add(config);
+ }else{
+ buildIn.add(config);
+ }
+ }
+
+ wikiTableConfigFactory.replaceUserSpecificConfigurations(userSpecific);
+ wikiTableConfigFactory.replaceBuilInConfiguration(buildIn);
+ }
+
+
+ public IWikiTableConfigurationFactory getWikiTableConfigFactory() {
+ return wikiTableConfigFactory;
+ }
+
+
+ public void setWikiTableConfigFactory(IWikiTableConfigurationFactory wikiTableConfigFactory) {
+ this.wikiTableConfigFactory = wikiTableConfigFactory;
+ }
+
+}
Property changes on: trunk/sql12/app/src/main/java/net/sourceforge/squirrel_sql/client/preferences/WikiTablePreferencesPanel.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: trunk/sql12/app/src/main/java/net/sourceforge/squirrel_sql/client/preferences/WikiTablePreferencesTab.java
===================================================================
--- trunk/sql12/app/src/main/java/net/sourceforge/squirrel_sql/client/preferences/WikiTablePreferencesTab.java (rev 0)
+++ trunk/sql12/app/src/main/java/net/sourceforge/squirrel_sql/client/preferences/WikiTablePreferencesTab.java 2011-04-25 19:39:21 UTC (rev 6242)
@@ -0,0 +1,129 @@
+/*
+ * 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.client.preferences;
+
+import java.awt.Component;
+
+import net.sourceforge.squirrel_sql.client.IApplication;
+import net.sourceforge.squirrel_sql.fw.util.StringManager;
+import net.sourceforge.squirrel_sql.fw.util.StringManagerFactory;
+
+/**
+ * Preferences for WIKI table configurations.
+ * @author Stefan Willinger
+ *
+ */
+public class WikiTablePreferencesTab implements IGlobalPreferencesPanel {
+
+ /** Internationalized strings for this class. */
+ private static final StringManager s_stringMgr = StringManagerFactory
+ .getStringManager(WikiTablePreferencesTab.class);
+
+ static interface i18n {
+
+ // i18n[WikiTablePreferencesTab.title=Wiki Table]
+ String TITLE = s_stringMgr.getString("WikiTablePreferencesTab.title");
+
+ // i18n[WikiTablePreferencesTab.hint=Configure exports for a Wiki table]
+ String HINT = s_stringMgr.getString("WikiTablePreferencesTab.hint");
+
+ }
+
+ private WikiTablePreferencesPanel myPanel;
+ private IApplication app;
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see net.sourceforge.squirrel_sql.client.util.IOptionPanel#applyChanges()
+ */
+ @Override
+ public void applyChanges() {
+ myPanel.applyChanges();
+ app.savePreferences(PreferenceType.WIKI_CONFIGURATION);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see net.sourceforge.squirrel_sql.client.util.IOptionPanel#getTitle()
+ */
+ @Override
+ public String getTitle() {
+ return i18n.TITLE;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see net.sourceforge.squirrel_sql.client.util.IOptionPanel#getHint()
+ */
+ @Override
+ public String getHint() {
+ return i18n.HINT;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * net.sourceforge.squirrel_sql.client.util.IOptionPanel#getPanelComponent()
+ */
+ @Override
+ public Component getPanelComponent() {
+ if (myPanel == null){
+ myPanel = new WikiTablePreferencesPanel();
+ }
+ return myPanel;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * net.sourceforge.squirrel_sql.client.preferences.IGlobalPreferencesPanel
+ * #initialize(net.sourceforge.squirrel_sql.client.IApplication)
+ */
+ @Override
+ public void initialize(IApplication app) {
+ if (app == null){
+ throw new IllegalArgumentException("Null IApplication passed");
+ }
+
+ this.app = app;
+
+ WikiTablePreferencesPanel panel = (WikiTablePreferencesPanel)getPanelComponent();
+ panel.setApplication(app);
+ panel.loadData(app.getSquirrelPreferences());
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * net.sourceforge.squirrel_sql.client.preferences.IGlobalPreferencesPanel
+ * #uninitialize(net.sourceforge.squirrel_sql.client.IApplication)
+ */
+ @Override
+ public void uninitialize(IApplication app) {
+ // nothing
+
+ }
+
+}
Property changes on: trunk/sql12/app/src/main/java/net/sourceforge/squirrel_sql/client/preferences/WikiTablePreferencesTab.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Modified: trunk/sql12/app/src/main/java/net/sourceforge/squirrel_sql/client/util/ApplicationFiles.java
===================================================================
--- trunk/sql12/app/src/main/java/net/sourceforge/squirrel_sql/client/util/ApplicationFiles.java 2011-04-23 20:44:03 UTC (rev 6241)
+++ trunk/sql12/app/src/main/java/net/sourceforge/squirrel_sql/client/util/ApplicationFiles.java 2011-04-25 19:39:21 UTC (rev 6242)
@@ -365,4 +365,12 @@
{
return new File(_squirrelHomeDir.getPath() + File.separator + "lib" + File.separator + "fw.jar");
}
+
+ /**
+ * @return serialized List containing user specific configurations for WIKI tables.
+ */
+ public File getUserSpecificWikiConfigurationsFile()
+ {
+ return new File(_userSettingsDir + File.separator + "userSpecificWikiTableConfigurations.xml");
+ }
}
Modified: trunk/sql12/app/src/main/resources/net/sourceforge/squirrel_sql/client/I18NStrings.properties
===================================================================
--- trunk/sql12/app/src/main/resources/net/sourceforge/squirrel_sql/client/I18NStrings.properties 2011-04-23 20:44:03 UTC (rev 6241)
+++ trunk/sql12/app/src/main/resources/net/sourceforge/squirrel_sql/client/I18NStrings.properties 2011-04-25 19:39:21 UTC (rev 6242)
@@ -10,10 +10,12 @@
Application.error.loadcellselections=Unable to load Cell Import/Export selections from persistant storage.
Application.error.loadcolsinfo=Unable to load Edit 'Where' Columns selections.
Application.error.loaddatatypeprops=Unable to load DataType Properties selections from persistant storage.
+Application.error.loadUserSpecificWikiConfiguration=Unable to load WIKI configurations from persistent storage.
Application.error.menuadding=Cannot add items to menus prior to menu being created.
Application.error.savecolsinfo=Unable to write Edit Where Cols options to persistant storage.
Application.error.savedatatypeprops=Unable to write DataType properties to persistant storage.
Application.error.savesqlhistory=Unable to write SQL queries to persistent storage.
+Application.error.saveUserSpecificWikiConfiguration=Unable to write user specific WIKI configurations to persistent storage.
Application.error.setlaf=Error setting LAF
Application.error.showhelpwindow=Error showing help window
Application.error.unsupportedJDKVersion=SQuirreL needs JDK 1.4.x or higher. You are using JDK {0} at {1}
@@ -42,6 +44,7 @@
Application.splash.loadinguseracc=Loading user specified accelerators and mnemonics...
Application.splash.loadplugintime=Plugin {0} created in {1} ms, loaded in {2} ms, initialized in {3} ms, total {4} ms.
Application.splash.loadsqlhistory=Loading SQL history...
+Application.splash.loadUserSpecificWikiConfiguration=Loading user specific WIKI configurations...
Application.splash.notloadingplugins=No plugins are to be loaded...
Application.splash.uifactoryinit=Initializing UI factories...
Application.splash.showmainwindow=Showing main window...
Modified: trunk/sql12/app/src/main/resources/net/sourceforge/squirrel_sql/client/preferences/I18NStrings.properties
===================================================================
--- trunk/sql12/app/src/main/resources/net/sourceforge/squirrel_sql/client/preferences/I18NStrings.properties 2011-04-23 20:44:03 UTC (rev 6241)
+++ trunk/sql12/app/src/main/resources/net/sourceforge/squirrel_sql/client/preferences/I18NStrings.properties 2011-04-25 19:39:21 UTC (rev 6242)
@@ -103,7 +103,39 @@
UpdatePreferencesTab.hint=Software Update Settings
UpdatePreferencesTab.title=Update
+WikiTablePreferencesTab.title=Wiki Table
+WikiTablePreferencesTab.hint=Configure exports for a Wiki table
+WikiTablePreferencesPanel.austria=Austria
+WikiTablePreferencesPanel.captial=Capital
+WikiTablePreferencesPanel.cellTag=Cell tag
+WikiTablePreferencesPanel.copy=Copy
+WikiTablePreferencesPanel.country=Country
+WikiTablePreferencesPanel.delete=Delete
+WikiTablePreferencesPanel.errorConfigNotUnique=The name of a configuration must be unique\!
+WikiTablePreferencesPanel.headerCellTag=Header cell tag
+WikiTablePreferencesPanel.headerEndTag=Header end tag
+WikiTablePreferencesPanel.headerStartTag=Header start tag
+WikiTablePreferencesPanel.hintNewLine=%N = a new line
+WikiTablePreferencesPanel.hintValueVariable=%V = value of the cell or header
+WikiTablePreferencesPanel.italy=Italy
+WikiTablePreferencesPanel.name=Name
+WikiTablePreferencesPanel.new=New
+WikiTablePreferencesPanel.noWikiTag=No Wiki tag
+WikiTablePreferencesPanel.enabled=Enabled
+WikiTablePreferencesPanel.rome=Rome
+WikiTablePreferencesPanel.rowEndTag=Row end tag
+WikiTablePreferencesPanel.rowStartTag=Row start tag
+WikiTablePreferencesPanel.tableEndTag=Table end tag
+WikiTablePreferencesPanel.tableStartTag=Table start tag
+WikiTablePreferencesPanel.titleDetailPanel=Wiki table configuration
+WikiTablePreferencesPanel.titleExample=Example
+WikiTablePreferencesPanel.titleOverview=Overview
+WikiTablePreferencesPanel.titleResultExample=Resulting Wiki text:
+WikiTablePreferencesPanel.vienna=Vienna
+
+
+
GeneralPreferencesPanel.tabbedStyle=Use tabbed layout (needs restart)
GeneralPreferencesPanel.useScrollableTabbedPanesForSessionTabs=Use scrollable tabbed panes for Session tabs (needs restart)
GeneralPreferencesPanel.internalFrameStyle=Use MDI/Internal Frame layout (needs restart)
Modified: trunk/sql12/doc/src/main/resources/changes.txt
===================================================================
--- trunk/sql12/doc/src/main/resources/changes.txt 2011-04-23 20:44:03 UTC (rev 6241)
+++ trunk/sql12/doc/src/main/resources/changes.txt 2011-04-25 19:39:21 UTC (rev 6242)
@@ -7,6 +7,10 @@
Enhancements:
+Export as WIKI table:
+ Squirrel is now able, to copy the selection of a result table as WIKI text into the clipboard. (Right click on the result table => Copy as WIKI table)
+ At the new preferences panel "Global Preferences => Wiki Tables", the user can configure individual templates for the WIKI syntax.
+
Detached result windows now can be rerun.
Feature Request 3185630: SQL Panel layout:
Modified: trunk/sql12/fw/src/main/java/net/sourceforge/squirrel_sql/fw/gui/TablePopupMenu.java
===================================================================
--- trunk/sql12/fw/src/main/java/net/sourceforge/squirrel_sql/fw/gui/TablePopupMenu.java 2011-04-23 20:44:03 UTC (rev 6241)
+++ trunk/sql12/fw/src/main/java/net/sourceforge/squirrel_sql/fw/gui/TablePopupMenu.java 2011-04-25 19:39:21 UTC (rev 6242)
@@ -27,6 +27,10 @@
import javax.swing.*;
import net.sourceforge.squirrel_sql.fw.gui.action.*;
+import net.sourceforge.squirrel_sql.fw.gui.action.wikiTable.CopyWikiTableActionFactory;
+import net.sourceforge.squirrel_sql.fw.gui.action.wikiTable.ICopyWikiTableActionFactory;
+import net.sourceforge.squirrel_sql.fw.gui.action.wikiTable.ITableActionCallback;
+import net.sourceforge.squirrel_sql.fw.gui.action.wikiTable.IWikiTableConfiguration;
import net.sourceforge.squirrel_sql.fw.util.StringManager;
import net.sourceforge.squirrel_sql.fw.util.StringManagerFactory;
import net.sourceforge.squirrel_sql.fw.datasetviewer.IDataSetUpdateableModel;
@@ -53,13 +57,14 @@
int COPY_IN_STATEMENT = 3;
int COPY_WHERE_STATEMENT = 4;
int COPY_UPDATE_STATEMENT = 5;
- int COPY_INSERT_STATEMENT = 6;
+ int COPY_INSERT_STATEMENT = 6;
int EXPORT_CSV = 7;
int SELECT_ALL = 8;
- int ADJUST_ALL_COL_WIDTHS_ACTION = 9;
- int ALWAYS_ADJUST_ALL_COL_WIDTHS_ACTION = 10;
- int SHOW_ROW_NUMBERS = 11;
- int LAST_ENTRY = 12;
+ int ADJUST_ALL_COL_WIDTHS_ACTION = 9;
+ int ALWAYS_ADJUST_ALL_COL_WIDTHS_ACTION = 10;
+ int SHOW_ROW_NUMBERS = 11;
+ int COPY_WIKI = 12;
+ int LAST_ENTRY = 13;
}
private static final KeyStroke COPY_STROKE = KeyStroke.getKeyStroke(KeyEvent.VK_C, KeyEvent.CTRL_DOWN_MASK);
@@ -75,6 +80,7 @@
private CopyAction _copy = new CopyAction();
private CopyWithHeadersAction _copyWithHeaders = new CopyWithHeadersAction();
private CopyHtmlAction _copyHtml = new CopyHtmlAction();
+
private CopyInStatementAction _copyInStatement = new CopyInStatementAction();
private CopyWhereStatementAction _copyWhereStatement = new CopyWhereStatementAction();
private CopyUpdateStatementAction _copyUpdateStatement = new CopyUpdateStatementAction();
@@ -99,6 +105,8 @@
// pointer to the viewer
// This is needed for insert and delete operations
private DataSetViewerTablePanel _viewer = null;
+
+ private ICopyWikiTableActionFactory copyWikiTableActionFactory = CopyWikiTableActionFactory.getInstance();
/**
* Constructor used when caller wants to be able to make table editable.
@@ -123,6 +131,13 @@
_menuItems[IOptionTypes.COPY].setAccelerator(COPY_STROKE);
_menuItems[IOptionTypes.COPY_WITH_HEADERS] = add(_copyWithHeaders);
_menuItems[IOptionTypes.COPY_HTML] = add(_copyHtml);
+
+ _menuItems[IOptionTypes.COPY_WIKI] = add(copyWikiTableActionFactory.createMenueItem(new ITableActionCallback() {
+ @Override
+ public JTable getJTable() {
+ return _table;
+ }
+ }));
_menuItems[IOptionTypes.COPY_IN_STATEMENT] = add(_copyInStatement);
_menuItems[IOptionTypes.COPY_WHERE_STATEMENT] = add(_copyWhereStatement);
_menuItems[IOptionTypes.COPY_UPDATE_STATEMENT] = add(_copyUpdateStatement);
@@ -309,6 +324,8 @@
}
}
}
+
+
private class CopyInStatementAction extends BaseAction
{
Added: trunk/sql12/fw/src/main/java/net/sourceforge/squirrel_sql/fw/gui/action/TableCopyWikiCommand.java
===================================================================
--- trunk/sql12/fw/src/main/java/net/sourceforge/squirrel_sql/fw/gui/action/TableCopyWikiCommand.java (rev 0)
+++ trunk/sql12/fw/src/main/java/net/sourceforge/squirrel_sql/fw/gui/action/TableCopyWikiCommand.java 2011-04-25 19:39:21 UTC (rev 6242)
@@ -0,0 +1,103 @@
+/*
+ * 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.fw.gui.action;
+
+import java.awt.Toolkit;
+import java.awt.datatransfer.Clipboard;
+
+import javax.swing.JTable;
+
+import net.sourceforge.squirrel_sql.fw.gui.action.wikiTable.IWikiTableConfiguration;
+import net.sourceforge.squirrel_sql.fw.gui.action.wikiTable.IWikiTableTransformer;
+import net.sourceforge.squirrel_sql.fw.gui.action.wikiTable.WikiTableSelection;
+import net.sourceforge.squirrel_sql.fw.util.ICommand;
+import net.sourceforge.squirrel_sql.fw.util.StringManager;
+import net.sourceforge.squirrel_sql.fw.util.StringManagerFactory;
+import net.sourceforge.squirrel_sql.fw.util.log.ILogger;
+import net.sourceforge.squirrel_sql.fw.util.log.LoggerController;
+
+/**
+ * This command gets the current selected text from a <TT>JTable</TT>, formats
+ * it as WIKI table and places it on the system clipboard.
+ * @see IWikiTableConfiguration
+ * @see IWikiTableTransformer
+ * @author Stefan Willinger
+ *
+ */
+public class TableCopyWikiCommand implements ICommand {
+
+ private static ILogger s_log = LoggerController.createLogger(TableCopyWikiCommand.class);
+
+ /**
+ * Configuration to use.
+ */
+ private IWikiTableConfiguration config = null;
+
+ /**
+ * The table, where the data will get from.
+ */
+ private JTable table = null;
+
+ private WikiTableSelection selection = null;
+
+ private static final StringManager s_stringMgr = StringManagerFactory
+ .getStringManager(TableCopyWikiCommand.class);
+
+ /**
+ * Create a new Command.
+ *
+ * @param _table
+ */
+ public TableCopyWikiCommand(JTable aTable, IWikiTableConfiguration wikiConfig) {
+ super();
+ if (aTable == null) {
+ throw new IllegalArgumentException("JTable == null");
+ }
+ if (wikiConfig == null) {
+ throw new IllegalArgumentException("wikiConfig == null");
+ }
+
+ this.table = aTable;
+ this.config = wikiConfig;
+ try {
+ this.selection = new WikiTableSelection();
+ } catch (ClassNotFoundException e) {
+ String msg = s_stringMgr.getString("TableCopyWikiCommand.error.flavors");
+ s_log.error(msg, e);
+ }
+
+ }
+
+ /**
+ * Performs the action.
+ *
+ * @see net.sourceforge.squirrel_sql.fw.util.ICommand#execute()
+ */
+ @Override
+ public void execute() {
+
+ String result = this.config.createTransformer().transform(table);
+ if (result != null) {
+ selection.setData(result);
+ Clipboard cb = Toolkit.getDefaultToolkit().getSystemClipboard();
+ cb.setContents(selection, null);
+ }
+ }
+
+}
Property changes on: trunk/sql12/fw/src/main/java/net/sourceforge/squirrel_sql/fw/gui/action/TableCopyWikiCommand.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: trunk/sql12/fw/src/main/java/net/sourceforge/squirrel_sql/fw/gui/action/wikiTable/CopyWikiTableAction.java
===================================================================
--- trunk/sql12/fw/src/main/java/net/sourceforge/squirrel_sql/fw/gui/action/wikiTable/CopyWikiTableAction.java (rev 0)
+++ trunk/sql12/fw/src/main/java/net/sourceforge/squirrel_sql/fw/gui/action/wikiTable/CopyWikiTableAction.java 2011-04-25 19:39:21 UTC (rev 6242)
@@ -0,0 +1,75 @@
+/*
+ * 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.fw.gui.action.wikiTable;
+
+import java.awt.event.ActionEvent;
+
+import javax.swing.JTable;
+
+import net.sourceforge.squirrel_sql.fw.gui.action.BaseAction;
+import net.sourceforge.squirrel_sql.fw.gui.action.TableCopyWikiCommand;
+
+/**
+ * Action, for copying the selection of a {@link JTable} as WIKI text into the clipboard.
+ * @see IWikiTableConfiguration
+ * @see IWikiTableTransformer
+ * @see ITableActionCallback
+ * @author Stefan Willinger
+ *
+ */
+public class CopyWikiTableAction extends BaseAction{
+ private static final long serialVersionUID = -6527002300678829186L;
+ /**
+ * WIKI specific configuration for this action.
+ */
+ private IWikiTableConfiguration config;
+
+
+ /**
+ * A callback which provides the {@link JTable}
+ */
+ private ITableActionCallback callback;
+
+
+ /**
+ * Constructor for the Action.
+ * @param titel String representing the name of the action
+ * @param config WIKI specific configuration to use.
+ * @param callback Callback, which provides the JTable.
+ */
+ public CopyWikiTable...
[truncated message content] |