From 24c327ec8874d012746dbdfa770e5f6015cc5ce6 Mon Sep 17 00:00:00 2001 From: richie Date: Thu, 15 Nov 2018 14:35:13 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=87=E6=A1=A3=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- plugin.xml | 4 +-- pom.xml | 7 +++++ .../plugin/db/redis/core/RedisTableData.java | 26 ++++--------------- .../db/redis/core/RedisTableDataModel.java | 7 +++-- .../redis/ui/RedisDBConnectionChosePane.java | 8 +++--- .../fr/plugin/db/redis/ui/RedisQueryPane.java | 10 ++++--- .../db/redis/ui/RedisTableDataPane.java | 12 +++------ .../db/redis/ui/value/FormulaEditor.java | 3 ++- .../plugin/db/redis/locale/redis.properties | 6 ++++- .../db/redis/locale/redis_zh_CN.properties | 3 ++- 10 files changed, 40 insertions(+), 46 deletions(-) diff --git a/plugin.xml b/plugin.xml index 89c8d91..76e51c2 100755 --- a/plugin.xml +++ b/plugin.xml @@ -18,12 +18,10 @@ - - - + \ No newline at end of file diff --git a/pom.xml b/pom.xml index 667c936..6b7a55f 100644 --- a/pom.xml +++ b/pom.xml @@ -11,6 +11,13 @@ jar demo-tabledata-redis + + + redis.clients + jedis + 2.9.0 + + ${project.basedir}/../webroot/WEB-INF/plugins/plugin-com.fr.solution.plugin.db.redis.v10-1.0/classes diff --git a/src/main/java/com/fr/plugin/db/redis/core/RedisTableData.java b/src/main/java/com/fr/plugin/db/redis/core/RedisTableData.java index f078d41..8edf946 100755 --- a/src/main/java/com/fr/plugin/db/redis/core/RedisTableData.java +++ b/src/main/java/com/fr/plugin/db/redis/core/RedisTableData.java @@ -11,8 +11,11 @@ import com.fr.file.DatasourceManager; import com.fr.general.Inter; import com.fr.general.data.DataModel; import com.fr.general.xml.GeneralXMLTools; +import com.fr.intelli.record.Focus; +import com.fr.intelli.record.Original; import com.fr.plugin.ExtraClassManager; import com.fr.plugin.db.redis.core.order.OrderValue; +import com.fr.record.analyzer.EnableMetrics; import com.fr.script.Calculator; import com.fr.stable.ArrayUtils; import com.fr.stable.ParameterProvider; @@ -26,25 +29,9 @@ import java.util.HashMap; import java.util.Map; +@EnableMetrics public class RedisTableData extends AbstractParameterTableData { - private static final FunctionProcessor REDIS = new AbstractFunctionProcessor() { - - @Override - public int getId() { - return FunctionHelper.generateFunctionID(RedisConstants.PLUGIN_ID); - } - - @Override - public String getLocaleKey() { - return "Plugin-Redis_DB"; - } - - @Override - public String toString() { - return Inter.getLocText("Plugin-Redis_DB"); - } - }; private Connection database; private OrderValue dbIndex; @@ -85,11 +72,8 @@ public class RedisTableData extends AbstractParameterTableData { } @Override + @Focus(id = RedisConstants.PLUGIN_ID, text = "Plugin-Redis_DB", source = Original.PLUGIN) public DataModel createDataModel(Calculator calculator, int rowCount) { - FunctionProcessor processor = ExtraClassManager.getInstance().getFunctionProcessor(); - if (processor != null) { - processor.recordFunction(REDIS); - } Parameter[] ps = Parameter.providers2Parameter(getParameters(calculator)); if (database instanceof NameDatabaseConnection) { String name = ((NameDatabaseConnection) database).getName(); diff --git a/src/main/java/com/fr/plugin/db/redis/core/RedisTableDataModel.java b/src/main/java/com/fr/plugin/db/redis/core/RedisTableDataModel.java index a13eb33..f5fd901 100755 --- a/src/main/java/com/fr/plugin/db/redis/core/RedisTableDataModel.java +++ b/src/main/java/com/fr/plugin/db/redis/core/RedisTableDataModel.java @@ -1,10 +1,9 @@ package com.fr.plugin.db.redis.core; -import com.fr.base.FRContext; import com.fr.base.Parameter; import com.fr.data.AbstractDataModel; -import com.fr.general.FRLogger; import com.fr.general.data.TableDataException; +import com.fr.log.FineLoggerFactory; import com.fr.plugin.PluginLicense; import com.fr.plugin.PluginLicenseManager; import com.fr.plugin.db.redis.core.visit.VisitorFactory; @@ -12,7 +11,7 @@ import com.fr.script.Calculator; import com.fr.stable.StringUtils; import redis.clients.jedis.Jedis; -import java.util.*; +import java.util.List; public class RedisTableDataModel extends AbstractDataModel { @@ -37,7 +36,7 @@ public class RedisTableDataModel extends AbstractDataModel { if (redisClient == null) { redisClient = mc.createRedisClient(); redisClient.select(dbIndex); - FRContext.getLogger().info("Connect to redis and select database:" + dbIndex); + FineLoggerFactory.getLogger().info("Connect to redis and select database:" + dbIndex); } try { DataWrapper wrapper = VisitorFactory.getKeyValueResult(calculator, ps, redisClient, query, rowCount); diff --git a/src/main/java/com/fr/plugin/db/redis/ui/RedisDBConnectionChosePane.java b/src/main/java/com/fr/plugin/db/redis/ui/RedisDBConnectionChosePane.java index 7cee2b0..6f9c08b 100755 --- a/src/main/java/com/fr/plugin/db/redis/ui/RedisDBConnectionChosePane.java +++ b/src/main/java/com/fr/plugin/db/redis/ui/RedisDBConnectionChosePane.java @@ -6,9 +6,11 @@ import com.fr.design.data.datapane.connect.ConnectionComboBoxPanel; import com.fr.design.dialog.BasicPane; import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.itextfield.PlaceholderTextField; +import com.fr.design.i18n.Toolkit; import com.fr.design.utils.gui.GUICoreUtils; import com.fr.file.DatasourceManager; import com.fr.general.Inter; +import com.fr.log.FineLoggerFactory; import com.fr.plugin.db.redis.ui.event.DataLoadedListener; import com.fr.plugin.db.redis.core.RedisDatabaseConnection; import com.fr.stable.ArrayUtils; @@ -50,11 +52,11 @@ public class RedisDBConnectionChosePane extends BasicPane { JList list = new JList(listModel); keysPatternTextField = new PlaceholderTextField(10); - keysPatternTextField.setPlaceholder(Inter.getLocText("Plugin-Redis_Keys_Pattern")); + keysPatternTextField.setPlaceholder(Toolkit.i18nText("Plugin-Redis_Keys_Pattern")); JPanel centerPane = new JPanel(new BorderLayout()); - UIButton searchButton = new UIButton(Inter.getLocText("Plugin-Redis_Keys_Pattern_Search")); + UIButton searchButton = new UIButton(Toolkit.i18nText("Plugin-Redis_Keys_Pattern_Search")); searchButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { @@ -112,7 +114,7 @@ public class RedisDBConnectionChosePane extends BasicPane { } fireDataLoaded(keys); } catch (Exception e) { - FRContext.getLogger().error(e.getMessage(), e); + FineLoggerFactory.getLogger().error(e.getMessage(), e); } } }.execute(); diff --git a/src/main/java/com/fr/plugin/db/redis/ui/RedisQueryPane.java b/src/main/java/com/fr/plugin/db/redis/ui/RedisQueryPane.java index ae726f7..0e57229 100755 --- a/src/main/java/com/fr/plugin/db/redis/ui/RedisQueryPane.java +++ b/src/main/java/com/fr/plugin/db/redis/ui/RedisQueryPane.java @@ -9,12 +9,14 @@ import com.fr.design.gui.ilable.ActionLabel; import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.syntax.ui.rsyntaxtextarea.SyntaxConstants; import com.fr.design.gui.syntax.ui.rtextarea.RTextScrollPane; +import com.fr.design.i18n.Toolkit; import com.fr.design.layout.TableLayout; import com.fr.design.layout.TableLayoutHelper; import com.fr.design.utils.gui.GUICoreUtils; import com.fr.general.FRLogger; import com.fr.general.Inter; import com.fr.general.SiteCenter; +import com.fr.log.FineLoggerFactory; import com.fr.plugin.db.redis.core.order.OrderValue; import com.fr.plugin.db.redis.ui.value.IndexValuePaneFactory; @@ -37,21 +39,21 @@ public class RedisQueryPane extends BasicPane { dbIndexEditor = IndexValuePaneFactory.createValueEditorPane(); - ActionLabel helpLabel = new ActionLabel(Inter.getLocText("Plugin-Redis_Help")); + ActionLabel helpLabel = new ActionLabel(Toolkit.i18nText("Plugin-Redis_Help")); helpLabel.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { try { Desktop.getDesktop().browse(URI.create(SiteCenter.getInstance().acquireUrlByKind("help.redis"))); } catch (IOException e1) { - FRLogger.getLogger().error(e1.getMessage(), e1); + FineLoggerFactory.getLogger().error(e1.getMessage(), e1); } } }); Component[][] coms = new Component[][]{ - {new UILabel(Inter.getLocText("Plugin-Redis_DB_Index") + ":"), dbIndexEditor}, - {GUICoreUtils.createBorderLayoutPane(new UILabel(Inter.getLocText("Plugin-Redis_Query_Condition") + ":"), BorderLayout.NORTH), createConditionTextPane(sqlTextPane)} + {new UILabel(Toolkit.i18nText("Plugin-Redis_DB_Index") + ":"), dbIndexEditor}, + {GUICoreUtils.createBorderLayoutPane(new UILabel(Toolkit.i18nText("Plugin-Redis_Query_Condition") + ":"), BorderLayout.NORTH), createConditionTextPane(sqlTextPane)} }; double p = TableLayout.PREFERRED; diff --git a/src/main/java/com/fr/plugin/db/redis/ui/RedisTableDataPane.java b/src/main/java/com/fr/plugin/db/redis/ui/RedisTableDataPane.java index 3ef3d2a..4490af6 100755 --- a/src/main/java/com/fr/plugin/db/redis/ui/RedisTableDataPane.java +++ b/src/main/java/com/fr/plugin/db/redis/ui/RedisTableDataPane.java @@ -1,7 +1,6 @@ package com.fr.plugin.db.redis.ui; import com.fr.base.BaseUtils; -import com.fr.base.Parameter; import com.fr.base.ParameterHelper; import com.fr.data.impl.NameDatabaseConnection; import com.fr.design.actions.UpdateAction; @@ -11,6 +10,7 @@ import com.fr.design.gui.itableeditorpane.ParameterTableModel; import com.fr.design.gui.itableeditorpane.UITableEditAction; import com.fr.design.gui.itableeditorpane.UITableEditorPane; import com.fr.design.gui.itoolbar.UIToolbar; +import com.fr.design.i18n.Toolkit; import com.fr.design.menu.ToolBarDef; import com.fr.general.ComparatorUtils; import com.fr.general.Inter; @@ -25,16 +25,12 @@ import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.FocusEvent; import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collections; -import java.util.HashSet; import java.util.List; -import java.util.Set; public class RedisTableDataPane extends AbstractTableDataPane { - private static final String PREVIEW_BUTTON = Inter.getLocText("Preview"); - private static final String REFRESH_BUTTON = Inter.getLocText("Refresh"); + private static final String PREVIEW_BUTTON = Toolkit.i18nText("Plugin-Redis_Preview"); + private static final String REFRESH_BUTTON = Toolkit.i18nText("Plugin-Redis_Refresh"); private RedisDBConnectionChosePane chosePane; @@ -100,7 +96,7 @@ public class RedisTableDataPane extends AbstractTableDataPane { @Override protected String title4PopupWindow() { - return Inter.getLocText("DS-Database_Query"); + return Toolkit.i18nText("Plugin-Redis_Query"); } private void refresh() { diff --git a/src/main/java/com/fr/plugin/db/redis/ui/value/FormulaEditor.java b/src/main/java/com/fr/plugin/db/redis/ui/value/FormulaEditor.java index 3846cf5..4d1f6d7 100644 --- a/src/main/java/com/fr/plugin/db/redis/ui/value/FormulaEditor.java +++ b/src/main/java/com/fr/plugin/db/redis/ui/value/FormulaEditor.java @@ -6,6 +6,7 @@ import com.fr.design.editor.editor.Editor; import com.fr.design.formula.FormulaFactory; import com.fr.design.formula.UIFormula; import com.fr.design.gui.itextfield.UITextField; +import com.fr.design.i18n.Toolkit; import com.fr.design.layout.FRGUIPaneFactory; import com.fr.plugin.db.redis.core.order.impl.FormulaOrderValue; @@ -26,7 +27,7 @@ public class FormulaEditor extends Editor { * Constructor. */ public FormulaEditor() { - this("公式"); + this(Toolkit.i18nText("Plugin-Redis_Formula")); } public FormulaEditor(String name) { diff --git a/src/main/resources/com/fr/plugin/db/redis/locale/redis.properties b/src/main/resources/com/fr/plugin/db/redis/locale/redis.properties index c2ee961..3441097 100755 --- a/src/main/resources/com/fr/plugin/db/redis/locale/redis.properties +++ b/src/main/resources/com/fr/plugin/db/redis/locale/redis.properties @@ -7,4 +7,8 @@ Plugin-Redis_DB=RedisDB Plugin-Redis_Help=Help Doc Plugin-Redis_Keys_Pattern=Keys Pattern Plugin-Redis_Keys_Pattern_Search=Search -Plugin-Redis_DB_Index=DB Index \ No newline at end of file +Plugin-Redis_DB_Index=DB Index +Plugin-Redis_Preview=Preview +Plugin-Redis_Refresh=Refresh +Plugin-Redis_Formula=Formula +Plugin-Redis_Query=Query \ No newline at end of file diff --git a/src/main/resources/com/fr/plugin/db/redis/locale/redis_zh_CN.properties b/src/main/resources/com/fr/plugin/db/redis/locale/redis_zh_CN.properties index b35836e..dfcd6dd 100755 --- a/src/main/resources/com/fr/plugin/db/redis/locale/redis_zh_CN.properties +++ b/src/main/resources/com/fr/plugin/db/redis/locale/redis_zh_CN.properties @@ -7,4 +7,5 @@ Plugin-Redis_DB=RedisDB\u6570\u636E\u96C6 Plugin-Redis_Help=\u5E2E\u52A9\u6587\u6863 Plugin-Redis_Keys_Pattern=\u952E\u503C\u7684\u6B63\u5219\u8868\u8FBE\u5F0F Plugin-Redis_Keys_Pattern_Search=\u641C\u7D22 -Plugin-Redis_DB_Index=\u6570\u636E\u5E93\u7F16\u53F7 \ No newline at end of file +Plugin-Redis_DB_Index=\u6570\u636E\u5E93\u7F16\u53F7 +Plugin-Redis_Preview=\u9884\u89C8 \ No newline at end of file