Browse Source

查key的时候可以选数据库

master
richie 5 years ago
parent
commit
b119c21410
  1. 5
      plugin.xml
  2. 10
      src/main/java/com/fr/plugin/db/redis/core/RedisDatabaseConnection.java
  3. 14
      src/main/java/com/fr/plugin/db/redis/ui/RedisDBConnectionChosePane.java
  4. 1
      src/main/resources/com/fr/plugin/db/redis/locale/redis.properties
  5. 1
      src/main/resources/com/fr/plugin/db/redis/locale/redis_en_US.properties
  6. 9
      src/main/resources/com/fr/plugin/db/redis/locale/redis_zh_CN.properties

5
plugin.xml

@ -3,12 +3,13 @@
<id>com.fr.solution.plugin.db.redis.v10</id> <id>com.fr.solution.plugin.db.redis.v10</id>
<name><![CDATA[Redis数据集]]></name> <name><![CDATA[Redis数据集]]></name>
<active>yes</active> <active>yes</active>
<version>7.3.1</version> <version>7.3.2</version>
<env-version>10.0</env-version> <env-version>10.0</env-version>
<jartime>2019-03-29</jartime> <jartime>2020-01-20</jartime>
<vendor>richie</vendor> <vendor>richie</vendor>
<description><![CDATA[可以连接Redis数据库,支持哈希表、列表、集合以及有序集合]]></description> <description><![CDATA[可以连接Redis数据库,支持哈希表、列表、集合以及有序集合]]></description>
<change-notes><![CDATA[ <change-notes><![CDATA[
[2020-06-05]搜索key的时候可以选择不同的数据库。<br>
[2020-04-26]修复插件被标记为需要付费的问题。<br/> [2020-04-26]修复插件被标记为需要付费的问题。<br/>
[2020-04-21]修复redis集群下的一个问题。<br/> [2020-04-21]修复redis集群下的一个问题。<br/>
[2019-10-30]适配新服务器数据集接口,在决策平台可以直接定义<br/> [2019-10-30]适配新服务器数据集接口,在决策平台可以直接定义<br/>

10
src/main/java/com/fr/plugin/db/redis/core/RedisDatabaseConnection.java

@ -9,6 +9,7 @@ import com.fanruan.api.util.StringKit;
import com.fanruan.api.util.TypeKit; import com.fanruan.api.util.TypeKit;
import com.fr.config.holder.Conf; import com.fr.config.holder.Conf;
import com.fr.data.impl.Connection; import com.fr.data.impl.Connection;
import com.fr.plugin.db.redis.core.accessor.EmbedRedis;
import com.fr.plugin.db.redis.core.emb.Redis; import com.fr.plugin.db.redis.core.emb.Redis;
import com.fr.stable.xml.XMLPrintWriter; import com.fr.stable.xml.XMLPrintWriter;
import com.fr.stable.xml.XMLableReader; import com.fr.stable.xml.XMLableReader;
@ -79,7 +80,14 @@ public class RedisDatabaseConnection extends BaseConnection {
return ArrayKit.EMPTY_STRING_ARRAY; return ArrayKit.EMPTY_STRING_ARRAY;
} else { } else {
Redis redis = createRedisClient(); Redis redis = createRedisClient();
Set<String> keys = redis.getClient().keys(args[0]); EmbedRedis embedRedis = redis.getClient();
int len = ArrayKit.getLength(args);
if (len > 1) {
int dbIndex = Integer.parseInt(args[1]);
embedRedis.select(dbIndex);
}
Set<String> keys = embedRedis.keys(args[0]);
String[] array = keys.toArray(new String[0]); String[] array = keys.toArray(new String[0]);
redis.close(); redis.close();
return array; return array;

14
src/main/java/com/fr/plugin/db/redis/ui/RedisDBConnectionChosePane.java

@ -1,5 +1,7 @@
package com.fr.plugin.db.redis.ui; package com.fr.plugin.db.redis.ui;
import com.fanruan.api.design.ui.component.UIIntNumberField;
import com.fanruan.api.design.ui.component.UILabel;
import com.fanruan.api.design.work.ConnectionComboBoxPanel; import com.fanruan.api.design.work.ConnectionComboBoxPanel;
import com.fr.data.impl.Connection; import com.fr.data.impl.Connection;
import com.fr.data.operator.DataOperator; import com.fr.data.operator.DataOperator;
@ -29,6 +31,7 @@ public class RedisDBConnectionChosePane extends BasicPane {
private DefaultListModel listModel = new DefaultListModel(); private DefaultListModel listModel = new DefaultListModel();
private List<DataLoadedListener> listeners = new ArrayList<DataLoadedListener>(); private List<DataLoadedListener> listeners = new ArrayList<DataLoadedListener>();
private UIPlaceholderTextField keysPatternTextField; private UIPlaceholderTextField keysPatternTextField;
private UIIntNumberField dbIndexNumberField;
public RedisDBConnectionChosePane() { public RedisDBConnectionChosePane() {
setLayout(new BorderLayout(4, 4)); setLayout(new BorderLayout(4, 4));
@ -51,6 +54,10 @@ public class RedisDBConnectionChosePane extends BasicPane {
keysPatternTextField = new UIPlaceholderTextField(10); keysPatternTextField = new UIPlaceholderTextField(10);
keysPatternTextField.setPlaceholder(DesignKit.i18nText("Plugin-Redis_Keys_Pattern")); keysPatternTextField.setPlaceholder(DesignKit.i18nText("Plugin-Redis_Keys_Pattern"));
dbIndexNumberField = new UIIntNumberField();
dbIndexNumberField.setColumns(2);
dbIndexNumberField.setInt(0);
JPanel centerPane = new JPanel(new BorderLayout()); JPanel centerPane = new JPanel(new BorderLayout());
UIButton searchButton = new UIButton(DesignKit.i18nText("Plugin-Redis_Keys_Pattern_Search")); UIButton searchButton = new UIButton(DesignKit.i18nText("Plugin-Redis_Keys_Pattern_Search"));
@ -63,6 +70,10 @@ public class RedisDBConnectionChosePane extends BasicPane {
centerPane.add(GUICoreKit.createBorderLayoutPane( centerPane.add(GUICoreKit.createBorderLayoutPane(
keysPatternTextField, BorderLayout.CENTER, keysPatternTextField, BorderLayout.CENTER,
GUICoreKit.createBorderLayoutPane(
new UILabel(DesignKit.i18nText("Plugin-Redis_DB_Simple_Index")), BorderLayout.WEST,
dbIndexNumberField, BorderLayout.CENTER
), BorderLayout.WEST,
searchButton, BorderLayout.EAST), BorderLayout.NORTH); searchButton, BorderLayout.EAST), BorderLayout.NORTH);
centerPane.add(list, BorderLayout.CENTER); centerPane.add(list, BorderLayout.CENTER);
@ -97,7 +108,8 @@ public class RedisDBConnectionChosePane extends BasicPane {
if (StringKit.isEmpty(keysPattern)) { if (StringKit.isEmpty(keysPattern)) {
return ArrayKit.EMPTY_STRING_ARRAY; return ArrayKit.EMPTY_STRING_ARRAY;
} else { } else {
return DataOperator.getInstance().getTableSummary(connection, keysPattern); String dbIndex = String.valueOf(dbIndexNumberField.getInt());
return DataOperator.getInstance().getTableSummary(connection, keysPattern, dbIndex);
} }
} }

1
src/main/resources/com/fr/plugin/db/redis/locale/redis.properties

@ -9,6 +9,7 @@ Plugin-Redis_Help=Help Doc
Plugin-Redis_Keys_Pattern=Keys Pattern Plugin-Redis_Keys_Pattern=Keys Pattern
Plugin-Redis_Keys_Pattern_Search=Search Plugin-Redis_Keys_Pattern_Search=Search
Plugin-Redis_DB_Index=DB Index Plugin-Redis_DB_Index=DB Index
Plugin-Redis_DB_Simple_Index=Index
Plugin-Redis_Preview=Preview Plugin-Redis_Preview=Preview
Plugin-Redis_Refresh=Refresh Plugin-Redis_Refresh=Refresh
Plugin-Redis_Formula=Formula Plugin-Redis_Formula=Formula

1
src/main/resources/com/fr/plugin/db/redis/locale/redis_en_US.properties

@ -9,6 +9,7 @@ Plugin-Redis_Help=Help Doc
Plugin-Redis_Keys_Pattern=Keys Pattern Plugin-Redis_Keys_Pattern=Keys Pattern
Plugin-Redis_Keys_Pattern_Search=Search Plugin-Redis_Keys_Pattern_Search=Search
Plugin-Redis_DB_Index=DB Index Plugin-Redis_DB_Index=DB Index
Plugin-Redis_DB_Simple_Index=Index
Plugin-Redis_Preview=Preview Plugin-Redis_Preview=Preview
Plugin-Redis_Refresh=Refresh Plugin-Redis_Refresh=Refresh
Plugin-Redis_Formula=Formula Plugin-Redis_Formula=Formula

9
src/main/resources/com/fr/plugin/db/redis/locale/redis_zh_CN.properties

@ -9,6 +9,7 @@ Plugin-Redis_Help=\u5E2E\u52A9\u6587\u6863
Plugin-Redis_Keys_Pattern=\u952E\u503C\u7684\u6B63\u5219\u8868\u8FBE\u5F0F Plugin-Redis_Keys_Pattern=\u952E\u503C\u7684\u6B63\u5219\u8868\u8FBE\u5F0F
Plugin-Redis_Keys_Pattern_Search=\u641C\u7D22 Plugin-Redis_Keys_Pattern_Search=\u641C\u7D22
Plugin-Redis_DB_Index=\u6570\u636E\u5E93\u7F16\u53F7 Plugin-Redis_DB_Index=\u6570\u636E\u5E93\u7F16\u53F7
Plugin-Redis_DB_Simple_Index=\u7F16\u53F7
Plugin-Redis_Preview=\u9884\u89C8 Plugin-Redis_Preview=\u9884\u89C8
Plugin-Redis_Refresh=\u5237\u65B0 Plugin-Redis_Refresh=\u5237\u65B0
Plugin-Redis_Formula=\u516C\u5F0F Plugin-Redis_Formula=\u516C\u5F0F
@ -38,9 +39,9 @@ Plugin-Redis_Cluster_Config_Description=1\u3001\u4F7F\u7528\u9017\u53F7\u5206\u5
Plugin-Redis_Script_Engine_Type=\u811A\u672C\u5F15\u64CE Plugin-Redis_Script_Engine_Type=\u811A\u672C\u5F15\u64CE
Plugin-Redis_Script_Engine_Type_Default=\u9ED8\u8BA4 Plugin-Redis_Script_Engine_Type_Default=\u9ED8\u8BA4
Plugin-Redis_Script_Engine_Type_V8=V8\u9AD8\u901F\u5F15\u64CE Plugin-Redis_Script_Engine_Type_V8=V8\u9AD8\u901F\u5F15\u64CE
Plugin-Redis_Proxy_Private_Key_Path_Mark=\u8bf7\u8f93\u5165\u670d\u52a1\u5668\u6587\u4ef6\u8def\u5f84 Plugin-Redis_Proxy_Private_Key_Path_Mark=\u8BF7\u8F93\u5165\u670D\u52A1\u5668\u6587\u4EF6\u8DEF\u5F84
Plugin-Redis_Connection_Form_OriginalCharsetName= \u7f16\u7801 Plugin-Redis_Connection_Form_OriginalCharsetName= \u7F16\u7801
Plugin-Redis_Check_Integer=\u8bf7\u8f93\u5165\u4e0d\u5c0f\u4e8e\u0030\u7684\u6574\u6570 Plugin-Redis_Check_Integer=\u8BF7\u8F93\u5165\u4E0D\u5C0F\u4E8E0\u7684\u6574\u6570
Plugin-Redis_Parameter_Insert=\u63D2\u5165 Plugin-Redis_Parameter_Insert=\u63D2\u5165
Plugin-Redis_Parameter_Delete=\u5220\u9664 Plugin-Redis_Parameter_Delete=\u5220\u9664
Plugin-Redis_Parameter_Move_Up=\u4E0A\u79FB Plugin-Redis_Parameter_Move_Up=\u4E0A\u79FB
@ -57,5 +58,5 @@ Plugin-Redis_Parameter_Type_Boolean=\u5E03\u5C14\u578B
Plugin-Redis_Parameter_Type_Formula=\u516C\u5F0F Plugin-Redis_Parameter_Type_Formula=\u516C\u5F0F
Plugin-Redis_Parameter_Delete_Confirm=\u4F60\u786E\u5B9A\u51B3\u5B9A\u5220\u9664\u9009\u4E2D\u7684\u9879\uFF1F Plugin-Redis_Parameter_Delete_Confirm=\u4F60\u786E\u5B9A\u51B3\u5B9A\u5220\u9664\u9009\u4E2D\u7684\u9879\uFF1F
Plugin-Redis_Parameter_Delete_Alert=\u5F53\u524D\u5217\u8868\u4E3A\u7A7A\u6216\u8005\u4F60\u6CA1\u6709\u9009\u4E2D\u4EFB\u4F55\u9879 Plugin-Redis_Parameter_Delete_Alert=\u5F53\u524D\u5217\u8868\u4E3A\u7A7A\u6216\u8005\u4F60\u6CA1\u6709\u9009\u4E2D\u4EFB\u4F55\u9879
Plugin-Redis_View=\u89c6\u56fe Plugin-Redis_View=\u89C6\u56FE
Plugin-Redis_Table=\u8868 Plugin-Redis_Table=\u8868
Loading…
Cancel
Save