Browse Source

Merge branch 'master' of zhaojunzhe/demo-tabledata-redis into master

paid
richie 5 years ago committed by Gogs
parent
commit
7060bee95e
  1. BIN
      lib/finekit-10.0-20190828.jar
  2. 24
      pom.xml
  3. 4
      src/main/java/com/fr/plugin/db/redis/RedisConnectionImpl.java
  4. 4
      src/main/java/com/fr/plugin/db/redis/RedisScriptTableDataDefine.java
  5. 20
      src/main/java/com/fr/plugin/db/redis/core/DataWrapper.java
  6. 44
      src/main/java/com/fr/plugin/db/redis/core/RedisDatabaseConnection.java
  7. 22
      src/main/java/com/fr/plugin/db/redis/core/RedisNode.java
  8. 20
      src/main/java/com/fr/plugin/db/redis/core/RedisPool.java
  9. 32
      src/main/java/com/fr/plugin/db/redis/core/RedisScriptTableData.java
  10. 40
      src/main/java/com/fr/plugin/db/redis/core/RedisTableData.java
  11. 12
      src/main/java/com/fr/plugin/db/redis/core/RedisTableDataModel.java
  12. 10
      src/main/java/com/fr/plugin/db/redis/core/order/OrderValue.java
  13. 27
      src/main/java/com/fr/plugin/db/redis/core/order/impl/FormulaOrderValue.java
  14. 2
      src/main/java/com/fr/plugin/db/redis/core/order/impl/NumberOrderValue.java
  15. 20
      src/main/java/com/fr/plugin/db/redis/core/pool/RedisConnectionPoolConfig.java
  16. 26
      src/main/java/com/fr/plugin/db/redis/core/pool/RedisConnectionProxyConfig.java
  17. 6
      src/main/java/com/fr/plugin/db/redis/core/visit/AbstractVisitor.java
  18. 2
      src/main/java/com/fr/plugin/db/redis/core/visit/Visitor.java
  19. 2
      src/main/java/com/fr/plugin/db/redis/core/visit/VisitorFactory.java
  20. 2
      src/main/java/com/fr/plugin/db/redis/core/visit/impl/GetVisitor.java
  21. 2
      src/main/java/com/fr/plugin/db/redis/core/visit/impl/HashGetVisitor.java
  22. 2
      src/main/java/com/fr/plugin/db/redis/core/visit/impl/HashKeysVisitor.java
  23. 2
      src/main/java/com/fr/plugin/db/redis/core/visit/impl/HashMGetVisitor.java
  24. 2
      src/main/java/com/fr/plugin/db/redis/core/visit/impl/HashVisitor.java
  25. 2
      src/main/java/com/fr/plugin/db/redis/core/visit/impl/KeysVisitor.java
  26. 2
      src/main/java/com/fr/plugin/db/redis/core/visit/impl/ListVisitor.java
  27. 6
      src/main/java/com/fr/plugin/db/redis/core/visit/impl/MGetVisitor.java
  28. 2
      src/main/java/com/fr/plugin/db/redis/core/visit/impl/SetVisitor.java
  29. 2
      src/main/java/com/fr/plugin/db/redis/core/visit/impl/ZRangeVisitor.java
  30. 7
      src/main/java/com/fr/plugin/db/redis/help/Console.java
  31. 9
      src/main/java/com/fr/plugin/db/redis/help/Files.java
  32. 7
      src/main/java/com/fr/plugin/db/redis/help/client/BaseRedisClient.java
  33. 18
      src/main/java/com/fr/plugin/db/redis/help/client/RedisNashornClient.java
  34. 16
      src/main/java/com/fr/plugin/db/redis/help/client/RedisV8Client.java
  35. 43
      src/main/java/com/fr/plugin/db/redis/ui/RedisBaseTableDataPane.java
  36. 47
      src/main/java/com/fr/plugin/db/redis/ui/RedisConnectionPane.java
  37. 42
      src/main/java/com/fr/plugin/db/redis/ui/RedisDBConnectionChosePane.java
  38. 43
      src/main/java/com/fr/plugin/db/redis/ui/RedisQueryPane.java
  39. 30
      src/main/java/com/fr/plugin/db/redis/ui/RedisScriptPane.java
  40. 6
      src/main/java/com/fr/plugin/db/redis/ui/RedisScriptTableDataPane.java
  41. 10
      src/main/java/com/fr/plugin/db/redis/ui/RedisTableDataPane.java
  42. 36
      src/main/java/com/fr/plugin/db/redis/ui/pool/RedisConnectionPoolConfigPane.java
  43. 45
      src/main/java/com/fr/plugin/db/redis/ui/proxy/RedisConnectionProxyConfigPane.java
  44. 18
      src/main/java/com/fr/plugin/db/redis/ui/value/FormulaEditor.java
  45. 6
      src/main/java/com/fr/plugin/db/redis/ui/value/IndexValuePaneFactory.java
  46. 14
      src/main/java/com/fr/plugin/db/redis/ui/value/IntegerEditor.java
  47. 12
      src/main/java/com/fr/plugin/db/redis/util/RedisDesignUtils.java
  48. 10
      src/main/java/com/fr/plugin/db/redis/util/RedisUtils.java

BIN
lib/finekit-10.0-20190828.jar

Binary file not shown.

24
pom.xml

@ -42,4 +42,28 @@
</plugin>
</plugins>
</build>
<repositories>
<repository>
<id>fanruan</id>
<name>fanruan</name>
<url>http://mvn.finedevelop.com/repository/maven-public/</url>
<snapshots>
<enabled>true</enabled>
<updatePolicy>always</updatePolicy>
<checksumPolicy>warn</checksumPolicy>
</snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>fanruan</id>
<name>fanruan</name>
<url>http://mvn.finedevelop.com/repository/maven-public/</url>
<snapshots>
<enabled>true</enabled>
<updatePolicy>always</updatePolicy>
<checksumPolicy>warn</checksumPolicy>
</snapshots>
</pluginRepository>
</pluginRepositories>
</project>

4
src/main/java/com/fr/plugin/db/redis/RedisConnectionImpl.java

@ -1,12 +1,12 @@
package com.fr.plugin.db.redis;
import com.fr.data.impl.Connection;
import com.fr.design.beans.BasicBeanPane;
import com.fanruan.api.design.ui.container.BasicBeanPane;
import com.fr.design.fun.impl.AbstractConnectionProvider;
import com.fr.plugin.db.redis.core.RedisDatabaseConnection;
import com.fr.plugin.db.redis.ui.RedisConnectionPane;
public class RedisConnectionImpl extends AbstractConnectionProvider {
public class RedisConnectionImpl extends AbstractConnectionProvider {
@Override
public int currentAPILevel() {

4
src/main/java/com/fr/plugin/db/redis/RedisScriptTableDataDefine.java

@ -4,9 +4,9 @@ import com.fr.base.TableData;
import com.fr.design.data.tabledata.tabledatapane.AbstractTableDataPane;
import com.fr.design.fun.ServerTableDataDefineProvider;
import com.fr.design.fun.impl.AbstractTableDataDefineProvider;
import com.fr.locale.InterProviderFactory;
import com.fr.plugin.db.redis.core.RedisScriptTableData;
import com.fr.plugin.db.redis.ui.RedisScriptTableDataPane;
import com.fanruan.api.i18n.I18nKit;
/**
* @author richie
@ -37,7 +37,7 @@ public class RedisScriptTableDataDefine extends AbstractTableDataDefineProvider
@Override
public String nameForTableData() {
return InterProviderFactory.getProvider().getLocText("Plugin-Redis_Script_Table_Data");
return I18nKit.getLocText("Plugin-Redis_Script_Table_Data");
}
@Override

20
src/main/java/com/fr/plugin/db/redis/core/DataWrapper.java

@ -1,10 +1,10 @@
package com.fr.plugin.db.redis.core;
import com.fr.general.GeneralUtils;
import com.fr.general.IOUtils;
import com.fr.log.FineLoggerFactory;
import com.fr.script.ScriptFactory;
import com.fr.stable.StringUtils;
import com.fanruan.api.util.GeneralKit;
import com.fanruan.api.log.LogKit;
import com.fanruan.api.util.IOKit;
import com.fanruan.api.script.ScriptKit;
import com.fanruan.api.util.StringKit;
import com.fr.workspace.WorkContext;
import javax.script.ScriptEngine;
@ -46,21 +46,21 @@ public class DataWrapper<T> {
}
public void transform(String script) throws ScriptException {
if (StringUtils.isBlank(script)) {
if (StringKit.isBlank(script)) {
return;
}
String scriptText = null;
if (script.startsWith("file:///")) {
try {
FileInputStream in = new FileInputStream(new File(readAndRenderScriptFile(script)));
scriptText = IOUtils.inputStream2String(in);
scriptText = IOKit.inputStream2String(in);
} catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
LogKit.error(e.getMessage(), e);
}
} else {
scriptText = String.format("(function(){%s})()", script);
}
ScriptEngine scriptEngine = ScriptFactory.newScriptEngine();
ScriptEngine scriptEngine = ScriptKit.newScriptEngine();
scriptEngine.put("$content", data);
scriptEngine.put("$column", columnNames);
Object r = scriptEngine.eval(scriptText);
@ -70,7 +70,7 @@ public class DataWrapper<T> {
Object vector = map.get("column");
List<String> names = new ArrayList<String>();
for (Object name : ((Map)vector).values()) {
names.add(GeneralUtils.objectToString(name));
names.add(GeneralKit.objectToString(name));
}
columnNames = names.toArray(new String[0]);
Object content = map.get("content");

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

@ -1,19 +1,19 @@
package com.fr.plugin.db.redis.core;
import com.fr.config.holder.Conf;
import com.fr.config.holder.factory.Holders;
import com.fr.config.holder.impl.ColConf;
import cpm.fanruan.api.conf.HolderKit;
import com.fanruan.api.conf.impl.ColConf;
import com.fr.data.impl.AbstractDatabaseConnection;
import com.fr.data.impl.Connection;
import com.fr.locale.InterProviderFactory;
import com.fanruan.api.i18n.I18nKit;
import com.fr.plugin.db.redis.core.emb.Redis;
import com.fr.security.SecurityToolbox;
import com.fr.stable.ArrayUtils;
import com.fr.stable.StableUtils;
import com.fr.stable.StringUtils;
import com.fanruan.api.security.SecurityKit;
import com.fanruan.api.util.ArrayKit;
import com.fanruan.api.util.ReflectKit;
import com.fanruan.api.util.StringKit;
import com.fr.stable.xml.XMLPrintWriter;
import com.fr.stable.xml.XMLableReader;
import com.fr.third.redis.clients.jedis.Jedis;
import com.fr.config.holder.Conf;
import java.util.ArrayList;
import java.util.Collection;
@ -24,9 +24,9 @@ public class RedisDatabaseConnection extends AbstractDatabaseConnection {
private static final int DEFAULT_REDIS_PORT = 6379;
private Conf<String> host = Holders.simple(StringUtils.EMPTY);
private Conf<Integer> port = Holders.simple(DEFAULT_REDIS_PORT);
private Conf<String> password = Holders.simple(StringUtils.EMPTY);
private Conf<String> host = HolderKit.simple(StringKit.EMPTY);
private Conf<Integer> port = HolderKit.simple(DEFAULT_REDIS_PORT);
private Conf<String> password = HolderKit.simple(StringKit.EMPTY);
public RedisDatabaseConnection() {
@ -82,8 +82,8 @@ public class RedisDatabaseConnection extends AbstractDatabaseConnection {
@Override
public String[] summary(String... args) {
if (ArrayUtils.isEmpty(args)) {
return ArrayUtils.EMPTY_STRING_ARRAY;
if (ArrayKit.isEmpty(args)) {
return ArrayKit.EMPTY_STRING_ARRAY;
} else {
Redis redis = createRedisClient();
Set<String> keys = redis.getClient().keys(args[0]);
@ -96,16 +96,16 @@ public class RedisDatabaseConnection extends AbstractDatabaseConnection {
@Override
public String connectMessage(boolean status) {
if (status) {
return InterProviderFactory.getProvider().getLocText("Plugin-Redis_Connection_Successfully") + "!";
return I18nKit.getLocText("Plugin-Redis_Connection_Successfully") + "!";
} else {
return InterProviderFactory.getProvider().getLocText("Plugin-Redis_Connection_Failed") + "!";
return I18nKit.getLocText("Plugin-Redis_Connection_Failed") + "!";
}
}
@Override
public void addConnection(List<String> list, String connectionName, Class<? extends Connection>[] acceptTypes) {
for (Class<? extends com.fr.data.impl.Connection> accept : acceptTypes) {
if (StableUtils.classInstanceOf(getClass(), accept)) {
if (ReflectKit.classInstanceOf(getClass(), accept)) {
list.add(connectionName);
break;
}
@ -143,11 +143,11 @@ public class RedisDatabaseConnection extends AbstractDatabaseConnection {
if (reader.isChildNode()) {
String tagName = reader.getTagName();
if ("Attr".equals(tagName)) {
setHost(reader.getAttrAsString("host", StringUtils.EMPTY));
setHost(reader.getAttrAsString("host", StringKit.EMPTY));
setPort(reader.getAttrAsInt("port", DEFAULT_REDIS_PORT));
String pwd = reader.getAttrAsString("password", StringUtils.EMPTY);
if (StringUtils.isNotEmpty(pwd)) {
setPassword(SecurityToolbox.encrypt(pwd));
String pwd = reader.getAttrAsString("password", StringKit.EMPTY);
if (StringKit.isNotEmpty(pwd)) {
setPassword(SecurityKit.encrypt(pwd));
}
}
}
@ -159,8 +159,8 @@ public class RedisDatabaseConnection extends AbstractDatabaseConnection {
writer.startTAG("Attr");
writer.attr("host", getHost());
writer.attr("port", getPort());
if (StringUtils.isNotEmpty(getPassword())) {
writer.attr("password", SecurityToolbox.decrypt(getPassword()));
if (StringKit.isNotEmpty(getPassword())) {
writer.attr("password", SecurityKit.decrypt(getPassword()));
}
writer.end();
}

22
src/main/java/com/fr/plugin/db/redis/core/RedisNode.java

@ -1,23 +1,23 @@
package com.fr.plugin.db.redis.core;
import com.fanruan.api.conf.HolderKit;
import com.fanruan.api.conf.BaseUniqueKey;
import com.fanruan.api.util.AssistKit;
import com.fanruan.api.util.StringKit;
import com.fr.config.holder.Conf;
import com.fr.config.holder.factory.Holders;
import com.fr.config.utils.UniqueKey;
import com.fr.stable.AssistUtils;
import com.fr.stable.StringUtils;
/**
* @author richie
* @version 10.0
* Created by richie on 2019-03-22
*/
public class RedisNode extends UniqueKey {
public class RedisNode extends BaseUniqueKey {
public static final int DEFAULT_REDIS_PORT = 6379;
private Conf<String> host = Holders.simple(StringUtils.EMPTY);
private Conf<Integer> port = Holders.simple(DEFAULT_REDIS_PORT);
private Conf<String> password = Holders.simple(StringUtils.EMPTY);
private Conf<String> host = HolderKit.simple(StringKit.EMPTY);
private Conf<Integer> port = HolderKit.simple(DEFAULT_REDIS_PORT);
private Conf<String> password = HolderKit.simple(StringKit.EMPTY);
public RedisNode(String host, int port, String password) {
this.setHost(host);
@ -52,14 +52,14 @@ public class RedisNode extends UniqueKey {
@Override
public boolean equals(Object obj) {
return obj instanceof RedisNode
&& AssistUtils.equals(((RedisNode) obj).getHost(), getHost())
&& AssistKit.equals(((RedisNode) obj).getHost(), getHost())
&& ((RedisNode) obj).getPort() == getPort()
&& AssistUtils.equals(((RedisNode) obj).getPassword(), getPassword());
&& AssistKit.equals(((RedisNode) obj).getPassword(), getPassword());
}
@Override
public int hashCode() {
return AssistUtils.hashCode(getHost(), getPort(), getPassword());
return AssistKit.hashCode(getHost(), getPort(), getPassword());
}
@Override

20
src/main/java/com/fr/plugin/db/redis/core/RedisPool.java

@ -2,7 +2,7 @@ package com.fr.plugin.db.redis.core;
import com.fr.config.Configuration;
import com.fr.config.holder.ConfigChangeListener;
import com.fr.log.FineLoggerFactory;
import com.fanruan.api.log.LogKit;
import com.fr.plugin.db.redis.core.emb.Redis;
import com.fr.plugin.db.redis.core.emb.impl.ProxyRedis;
import com.fr.plugin.db.redis.core.emb.impl.SimpleRedis;
@ -11,12 +11,10 @@ import com.fr.plugin.db.redis.core.pool.RedisConnectionProxyConfig;
import com.fr.ssh.jsch.JSch;
import com.fr.ssh.jsch.JSchException;
import com.fr.ssh.jsch.Session;
import com.fr.stable.StringUtils;
import com.fanruan.api.util.StringKit;
import com.fr.third.redis.clients.jedis.Jedis;
import com.fr.third.redis.clients.jedis.JedisCluster;
import com.fr.third.redis.clients.jedis.JedisPool;
import com.fr.third.redis.clients.jedis.JedisPoolConfig;
import com.fr.transaction.Configurations;
import com.fanruan.api.redis.pool.JedisPool;
import com.fanruan.api.redis.pool.JedisPoolConfig;
import com.fr.transaction.ValidateProxy;
import java.util.Map;
@ -60,7 +58,7 @@ public class RedisPool {
try {
return createJedisBySSH(host, port, password);
} catch (JSchException e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
LogKit.error(e.getMessage(), e);
}
} else {
String feature = host + ":" + port + "@" + password;
@ -109,7 +107,7 @@ public class RedisPool {
config.setTestWhileIdle(false);
//逐出扫描的时间间隔(毫秒) 如果为负数,则不运行逐出线程, 默认-1
config.setTimeBetweenEvictionRunsMillis(-1);
if (StringUtils.isNotBlank(password)) {
if (StringKit.isNotBlank(password)) {
return new JedisPool(config, host, port, poolConfig.getTimeout(), password);
} else {
return new JedisPool(config, host, port, poolConfig.getTimeout());
@ -119,11 +117,11 @@ public class RedisPool {
private Redis createJedisBySSH(String host, int port, String password) throws JSchException {
RedisConnectionProxyConfig proxyConfig = RedisConnectionProxyConfig.getInstance();
JSch jsch = new JSch();
if (StringUtils.isNotBlank(proxyConfig.getPrivateKeyPath())) {
if (StringKit.isNotBlank(proxyConfig.getPrivateKeyPath())) {
jsch.addIdentity(proxyConfig.getPrivateKeyPath());
}
Session session = jsch.getSession(proxyConfig.getUsername(), proxyConfig.getHost(), proxyConfig.getPort());
if (StringUtils.isNotBlank(proxyConfig.getPassword())) {
if (StringKit.isNotBlank(proxyConfig.getPassword())) {
session.setPassword(proxyConfig.getPassword());
}
session.setConfig("StrictHostKeyChecking", "no");
@ -133,7 +131,7 @@ public class RedisPool {
Jedis jedis = new Jedis(host, newPort);
if (StringUtils.isNotBlank(password)) {
if (StringKit.isNotBlank(password)) {
jedis.auth(password);
}
return new ProxyRedis(session, jedis);

32
src/main/java/com/fr/plugin/db/redis/core/RedisScriptTableData.java

@ -1,28 +1,28 @@
package com.fr.plugin.db.redis.core;
import com.fr.base.Parameter;
import com.fr.stable.ParameterProvider;
import com.fr.base.TableData;
import com.fr.config.holder.Conf;
import com.fr.config.holder.factory.Holders;
import com.fanruan.api.conf.HolderKit;
import com.fr.config.holder.factory.XmlHolders;
import com.fr.data.AbstractParameterTableData;
import com.fr.data.core.DataCoreXmlUtils;
import com.fanruan.api.xml.XmlKit;
import com.fr.data.impl.Connection;
import com.fr.data.impl.NameDatabaseConnection;
import com.fr.file.DatasourceManager;
import com.fanruan.api.database.nameDatabase.NameDatabaseConnection;
import com.fanruan.api.data.ConnectionKit;
import com.fr.general.data.DataModel;
import com.fr.general.xml.GeneralXMLTools;
import com.fanruan.api.xml.XmlKit;
import com.fr.intelli.record.Focus;
import com.fr.log.FineLoggerFactory;
import com.fanruan.api.log.LogKit;
import com.fr.plugin.db.redis.core.order.OrderValue;
import com.fr.plugin.db.redis.core.order.impl.NumberOrderValue;
import com.fr.plugin.db.redis.util.RedisUtils;
import com.fr.record.analyzer.EnableMetrics;
import com.fr.script.Calculator;
import com.fr.stable.ParameterProvider;
import com.fr.stable.StringUtils;
import com.fanruan.api.util.StringKit;
import com.fr.stable.xml.XMLPrintWriter;
import com.fr.stable.xml.XMLableReader;
import com.fr.config.holder.Conf;
/**
* @author richie
@ -34,9 +34,9 @@ public class RedisScriptTableData extends AbstractParameterTableData {
private static final long serialVersionUID = 1525853354993816818L;
private Conf<Connection> database = Holders.obj(null, Connection.class);
private Conf<Connection> database = HolderKit.obj(null, Connection.class);
private Conf<OrderValue> dbIndex = XmlHolders.obj(new NumberOrderValue(0), OrderValue.class, OrderValue.XML_TAG);
private Conf<String> script = Holders.simple(StringUtils.EMPTY);
private Conf<String> script = HolderKit.simple(StringKit.EMPTY);
public void setDatabase(Connection c) {
this.database.set(c);
@ -79,7 +79,7 @@ public class RedisScriptTableData extends AbstractParameterTableData {
Connection connection = database.get();
if (connection instanceof NameDatabaseConnection) {
String name = ((NameDatabaseConnection) connection).getName();
RedisDatabaseConnection rc = DatasourceManager.getProviderInstance().getConnection(name, RedisDatabaseConnection.class);
RedisDatabaseConnection rc = ConnectionKit.getConnection(name, RedisDatabaseConnection.class);
if (rc != null) {
OrderValue orderValue = dbIndex.get();
DataModel model = new RedisScriptTableDataModel(rc,
@ -101,13 +101,13 @@ public class RedisScriptTableData extends AbstractParameterTableData {
String tmpVal;
if (OrderValue.XML_TAG.equals(tmpName)) {
OrderValue orderValue = (OrderValue) GeneralXMLTools.readXMLable(reader);
OrderValue orderValue = (OrderValue) XmlKit.readXMLable(reader);
if (orderValue != null) {
setOrderValue(orderValue);
}
} else if (com.fr.data.impl.Connection.XML_TAG.equals(tmpName)) {
if (reader.getAttrAsString("class", null) != null) {
com.fr.data.impl.Connection con = DataCoreXmlUtils.readXMLConnection(reader);
com.fr.data.impl.Connection con = XmlKit.readXMLConnection(reader);
this.setDatabase(con);
}
} else if ("Script".equals(tmpName)) {
@ -122,9 +122,9 @@ public class RedisScriptTableData extends AbstractParameterTableData {
@Override
public void writeXML(XMLPrintWriter writer) {
super.writeXML(writer);
GeneralXMLTools.writeXMLable(writer, dbIndex.get(), OrderValue.XML_TAG);
XmlKit.writeXMLable(writer, dbIndex.get(), OrderValue.XML_TAG);
if (this.database.get() != null) {
DataCoreXmlUtils.writeXMLConnection(writer, this.database.get());
XmlKit.writeXMLConnection(writer, this.database.get());
}
writer.startTAG("Script").textNode(getScript()).end();
}

40
src/main/java/com/fr/plugin/db/redis/core/RedisTableData.java

@ -1,31 +1,31 @@
package com.fr.plugin.db.redis.core;
import com.fr.base.Parameter;
import com.fr.stable.ParameterProvider;
import com.fr.base.TableData;
import com.fr.base.TemplateUtils;
import com.fr.config.holder.Conf;
import com.fr.config.holder.factory.Holders;
import com.fanruan.api.conf.HolderKit;
import com.fr.config.holder.factory.XmlHolders;
import com.fr.data.AbstractParameterTableData;
import com.fr.data.core.DataCoreXmlUtils;
import com.fanruan.api.xml.XmlKit;
import com.fr.data.impl.Connection;
import com.fr.data.impl.NameDatabaseConnection;
import com.fr.file.DatasourceManager;
import com.fanruan.api.database.nameDatabase.NameDatabaseConnection;
import com.fanruan.api.data.ConnectionKit;
import com.fr.general.data.DataModel;
import com.fr.general.xml.GeneralXMLTools;
import com.fanruan.api.xml.XmlKit;
import com.fr.intelli.record.Focus;
import com.fr.intelli.record.Original;
import com.fr.log.FineLoggerFactory;
import com.fanruan.api.log.LogKit;
import com.fr.plugin.db.redis.core.order.OrderValue;
import com.fr.plugin.db.redis.core.order.impl.NumberOrderValue;
import com.fr.plugin.db.redis.util.RedisUtils;
import com.fr.record.analyzer.EnableMetrics;
import com.fr.script.Calculator;
import com.fr.stable.ArrayUtils;
import com.fanruan.api.util.ArrayKit;
import com.fanruan.api.util.StringKit;
import com.fr.stable.ParameterProvider;
import com.fr.stable.StringUtils;
import com.fr.stable.xml.XMLPrintWriter;
import com.fr.stable.xml.XMLableReader;
import com.fr.config.holder.Conf;
import java.util.HashMap;
import java.util.Map;
@ -35,10 +35,10 @@ import java.util.Map;
public class RedisTableData extends AbstractParameterTableData {
private static final long serialVersionUID = 7017455818551800001L;
private Conf<Connection> database = Holders.obj(null, Connection.class);
private Conf<Connection> database = HolderKit.obj(null, Connection.class);
private Conf<OrderValue> dbIndex = XmlHolders.obj(new NumberOrderValue(0), OrderValue.class, OrderValue.XML_TAG);
private Conf<String> query = Holders.simple(StringUtils.EMPTY);
private Conf<String> script = Holders.simple(StringUtils.EMPTY);
private Conf<String> query = HolderKit.simple(StringKit.EMPTY);
private Conf<String> script = HolderKit.simple(StringKit.EMPTY);
public void setDatabase(Connection c) {
this.database.set(c);
@ -89,7 +89,7 @@ public class RedisTableData extends AbstractParameterTableData {
Connection connection = database.get();
if (connection instanceof NameDatabaseConnection) {
String name = ((NameDatabaseConnection) connection).getName();
RedisDatabaseConnection rc = DatasourceManager.getProviderInstance().getConnection(name, RedisDatabaseConnection.class);
RedisDatabaseConnection rc = ConnectionKit.getConnection(name, RedisDatabaseConnection.class);
if (rc != null) {
OrderValue orderValue = dbIndex.get();
DataModel model = new RedisTableDataModel(calculator, ps, rc,
@ -97,7 +97,7 @@ public class RedisTableData extends AbstractParameterTableData {
RedisUtils.calculateQuery(query.get(), ps),
RedisUtils.calculateQuery(script.get(), ps),
rowCount);
FineLoggerFactory.getLogger().info("Build data model spend time {} ms.", System.currentTimeMillis() - start);
LogKit.info("Build data model spend time {} ms.", System.currentTimeMillis() - start);
return model;
}
}
@ -114,13 +114,13 @@ public class RedisTableData extends AbstractParameterTableData {
String tmpVal;
if (OrderValue.XML_TAG.equals(tmpName)) {
OrderValue orderValue = (OrderValue) GeneralXMLTools.readXMLable(reader);
OrderValue orderValue = (OrderValue) XmlKit.readXMLable(reader);
if (orderValue != null) {
setOrderValue(orderValue);
}
} else if (com.fr.data.impl.Connection.XML_TAG.equals(tmpName)) {
if (reader.getAttrAsString("class", null) != null) {
com.fr.data.impl.Connection con = DataCoreXmlUtils.readXMLConnection(reader);
com.fr.data.impl.Connection con = XmlKit.readXMLConnection(reader);
this.setDatabase(con);
}
} else if ("Query".equals(tmpName)) {
@ -140,9 +140,9 @@ public class RedisTableData extends AbstractParameterTableData {
@Override
public void writeXML(XMLPrintWriter writer) {
super.writeXML(writer);
GeneralXMLTools.writeXMLable(writer, dbIndex.get(), OrderValue.XML_TAG);
XmlKit.writeXMLable(writer, dbIndex.get(), OrderValue.XML_TAG);
if (this.database.get() != null) {
DataCoreXmlUtils.writeXMLConnection(writer, this.database.get());
XmlKit.writeXMLConnection(writer, this.database.get());
}
writer.startTAG("Query").textNode(getQuery()).end();
writer.startTAG("Script").textNode(getScript()).end();

12
src/main/java/com/fr/plugin/db/redis/core/RedisTableDataModel.java

@ -1,15 +1,15 @@
package com.fr.plugin.db.redis.core;
import com.fr.base.Parameter;
import com.fr.stable.ParameterProvider;
import com.fr.data.AbstractDataModel;
import com.fr.log.FineLoggerFactory;
import com.fanruan.api.log.LogKit;
import com.fr.plugin.PluginLicense;
import com.fr.plugin.PluginLicenseManager;
import com.fr.plugin.db.redis.core.emb.Redis;
import com.fr.plugin.db.redis.core.visit.VisitorFactory;
import com.fr.plugin.db.redis.util.RedisUtils;
import com.fr.script.Calculator;
import com.fr.stable.StringUtils;
import com.fanruan.api.util.StringKit;
import com.fr.third.redis.clients.jedis.Jedis;
import java.util.List;
@ -28,16 +28,16 @@ public class RedisTableDataModel extends AbstractDataModel {
}
private synchronized void initRedisData(Calculator calculator, Parameter[] ps, RedisDatabaseConnection mc, int dbIndex, String query, String script, int rowCount) {
if (StringUtils.isEmpty(query)) {
if (StringKit.isEmpty(query)) {
return;
}
Redis redis = mc.createRedisClient();
redis.getClient().select(dbIndex);
FineLoggerFactory.getLogger().info("Connect to redis and select database:" + dbIndex);
LogKit.info("Connect to redis and select database:" + dbIndex);
try {
long start = System.currentTimeMillis();
DataWrapper<Object> wrapper = VisitorFactory.getKeyValueResult(calculator, ps, redis.getClient(), query, rowCount);
FineLoggerFactory.getLogger().info("Fetch data from redis spend time {} ms.", System.currentTimeMillis() - start);
LogKit.info("Fetch data from redis spend time {} ms.", System.currentTimeMillis() - start);
wrapper.transform(script);
data = wrapper.getData();
columnNames = wrapper.getColumnNames();

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

@ -1,15 +1,15 @@
package com.fr.plugin.db.redis.core.order;
import com.fr.base.Parameter;
import com.fr.config.utils.UniqueKey;
import com.fr.general.GeneralUtils;
import com.fr.stable.ParameterProvider;
import com.fanruan.api.conf.BaseUniqueKey;
import com.fanruan.api.util.GeneralKit;
import com.fr.script.Calculator;
import com.fr.stable.ParameterProvider;
import com.fr.stable.xml.XMLPrintWriter;
import com.fr.stable.xml.XMLable;
import com.fr.stable.xml.XMLableReader;
public abstract class OrderValue extends UniqueKey implements XMLable {
public abstract class OrderValue extends BaseUniqueKey implements XMLable {
private static final long serialVersionUID = -5421898153556627638L;
@ -36,7 +36,7 @@ public abstract class OrderValue extends UniqueKey implements XMLable {
@Override
public void writeXML(XMLPrintWriter writer) {
writer.startTAG("Attr");
writer.attr("value", GeneralUtils.objectToString(getValue()));
writer.attr("value", GeneralKit.objectToString(getValue()));
writer.end();
}

27
src/main/java/com/fr/plugin/db/redis/core/order/impl/FormulaOrderValue.java

@ -1,16 +1,17 @@
package com.fr.plugin.db.redis.core.order.impl;
import com.fr.base.BaseFormula;
import com.fr.base.Parameter;
import com.fr.base.ParameterHelper;
import com.fr.base.ParameterMapNameSpace;
import com.fr.general.GeneralUtils;
import com.fr.log.FineLoggerFactory;
import com.fanruan.api.cal.FormulaKit;
import com.fr.stable.ParameterProvider;
import com.fanruan.api.cal.ParameterKit;
import com.fanruan.api.util.GeneralKit;
import com.fanruan.api.log.LogKit;
import com.fr.plugin.db.redis.core.order.OrderValue;
import com.fr.script.Calculator;
import com.fr.stable.ParameterProvider;
import com.fr.stable.StringUtils;
import com.fr.stable.UtilEvalError;
import com.fanruan.api.util.StringKit;
import com.fanruan.api.cal.ParameterKit;
import com.fanruan.api.util.err.UtilEvalError;
import com.fr.stable.script.NameSpace;
import com.fr.stable.xml.XMLableReader;
@ -37,12 +38,12 @@ public class FormulaOrderValue extends OrderValue {
@Override
public int toIndex(Calculator cal, Parameter[] ps) {
NameSpace nameSpace = ParameterMapNameSpace.create(ps);
NameSpace nameSpace = ParameterKit.createParameterProvider(ps);
cal.pushNameSpace(nameSpace);
try {
return GeneralUtils.objectToNumber(formula.eval(cal)).intValue();
return GeneralKit.objectToNumber(formula.eval(cal)).intValue();
} catch (UtilEvalError u) {
FineLoggerFactory.getLogger().error(u.getMessage(), u);
LogKit.error(u.getMessage(), u);
} finally {
cal.removeNameSpace(nameSpace);
}
@ -54,16 +55,16 @@ public class FormulaOrderValue extends OrderValue {
if (formula == null) {
return new ParameterProvider[0];
}
return ParameterHelper.analyze4ParametersFromFormula(formula.getContent());
return ParameterKit.analyze4ParametersFromFormula(formula.getContent());
}
@Override
public void readValue(XMLableReader reader) {
this.formula = BaseFormula.createFormulaBuilder().build(reader.getAttrAsString("value", StringUtils.EMPTY));
this.formula = FormulaKit.newFormula(reader.getAttrAsString("value", StringKit.EMPTY));
}
@Override
public String toString() {
return formula == null ? StringUtils.EMPTY : formula.getPureContent();
return formula == null ? StringKit.EMPTY : formula.getPureContent();
}
}

2
src/main/java/com/fr/plugin/db/redis/core/order/impl/NumberOrderValue.java

@ -1,6 +1,6 @@
package com.fr.plugin.db.redis.core.order.impl;
import com.fr.base.Parameter;
import com.fr.stable.ParameterProvider;
import com.fr.plugin.db.redis.core.order.OrderValue;
import com.fr.script.Calculator;
import com.fr.stable.xml.XMLableReader;

20
src/main/java/com/fr/plugin/db/redis/core/pool/RedisConnectionPoolConfig.java

@ -1,16 +1,18 @@
package com.fr.plugin.db.redis.core.pool;
import com.fr.config.ConfigContext;
import com.fr.config.DefaultConfiguration;
import com.fanruan.api.conf.BaseConfiguration;
import com.fanruan.api.conf.HolderKit;
import com.fr.config.holder.Conf;
import com.fr.config.holder.factory.Holders;
import javax.xml.ws.Holder;
/**
* @author richie
* @version 10.0
* Created by richie on 2019-03-21
*/
public class RedisConnectionPoolConfig extends DefaultConfiguration {
public class RedisConnectionPoolConfig extends BaseConfiguration {
private static volatile RedisConnectionPoolConfig instance = null;
@ -26,12 +28,12 @@ public class RedisConnectionPoolConfig extends DefaultConfiguration {
private static final int MAX_WAIT = -1;
private static final int TIME_OUT = 100 * 1000;
private Conf<Integer> maxTotal = Holders.simple(MAX_TOTAL);
private Conf<Integer> maxWait = Holders.simple(MAX_WAIT);
private Conf<Integer> maxIdle = Holders.simple(MAX_IDLE);
private Conf<Boolean> blockWhenExhausted = Holders.simple(true);
private Conf<Boolean> lifo = Holders.simple(true);
private Conf<Integer> timeout = Holders.simple(TIME_OUT);
private Conf<Integer> maxTotal = HolderKit.simple(MAX_TOTAL);
private Conf<Integer> maxWait = HolderKit.simple(MAX_WAIT);
private Conf<Integer> maxIdle = HolderKit.simple(MAX_IDLE);
private Conf<Boolean> blockWhenExhausted = HolderKit.simple(true);
private Conf<Boolean> lifo = HolderKit.simple(true);
private Conf<Integer> timeout = HolderKit.simple(TIME_OUT);
public int getMaxTotal() {
return maxTotal.get();

26
src/main/java/com/fr/plugin/db/redis/core/pool/RedisConnectionProxyConfig.java

@ -1,18 +1,18 @@
package com.fr.plugin.db.redis.core.pool;
import com.fr.config.ConfigContext;
import com.fr.config.DefaultConfiguration;
import com.fanruan.api.conf.BaseConfiguration;
import com.fanruan.api.conf.HolderKit;
import com.fanruan.api.security.SecurityKit;
import com.fanruan.api.util.StringKit;
import com.fr.config.holder.Conf;
import com.fr.config.holder.factory.Holders;
import com.fr.security.SecurityToolbox;
import com.fr.stable.StringUtils;
/**
* @author richie
* @version 10.0
* Created by richie on 2019-03-21
*/
public class RedisConnectionProxyConfig extends DefaultConfiguration {
public class RedisConnectionProxyConfig extends BaseConfiguration {
private static volatile RedisConnectionProxyConfig instance = null;
@ -23,17 +23,17 @@ public class RedisConnectionProxyConfig extends DefaultConfiguration {
return instance;
}
private Conf<Boolean> open = Holders.simple(false);
private Conf<Boolean> open = HolderKit.simple(false);
private Conf<String> host = Holders.simple(StringUtils.EMPTY);
private Conf<String> host = HolderKit.simple(StringKit.EMPTY);
private Conf<Integer> port = Holders.simple(22);
private Conf<Integer> port = HolderKit.simple(22);
private Conf<String> username = Holders.simple(StringUtils.EMPTY);
private Conf<String> username = HolderKit.simple(StringKit.EMPTY);
private Conf<String> password = Holders.simple(StringUtils.EMPTY);
private Conf<String> password = HolderKit.simple(StringKit.EMPTY);
private Conf<String> privateKeyPath = Holders.simple(StringUtils.EMPTY);
private Conf<String> privateKeyPath = HolderKit.simple(StringKit.EMPTY);
public boolean isOpen() {
@ -70,11 +70,11 @@ public class RedisConnectionProxyConfig extends DefaultConfiguration {
public String getPassword() {
String text = password.get();
return SecurityToolbox.decrypt(text);
return SecurityKit.decrypt(text);
}
public void setPassword(String password) {
this.password.set(SecurityToolbox.encrypt(password));
this.password.set(SecurityKit.encrypt(password));
}
public String getPrivateKeyPath() {

6
src/main/java/com/fr/plugin/db/redis/core/visit/AbstractVisitor.java

@ -1,10 +1,10 @@
package com.fr.plugin.db.redis.core.visit;
import com.fr.base.Parameter;
import com.fr.stable.ParameterProvider;
import com.fr.plugin.db.redis.core.DataWrapper;
import com.fr.plugin.db.redis.core.RedisConstants;
import com.fr.script.Calculator;
import com.fr.stable.StringUtils;
import com.fanruan.api.util.StringKit;
import com.fr.third.redis.clients.jedis.Jedis;
/**
@ -23,6 +23,6 @@ public abstract class AbstractVisitor<T> implements Visitor<T> {
}
protected String trimCommand(String cmd) {
return StringUtils.trim(cmd);
return StringKit.trim(cmd);
}
}

2
src/main/java/com/fr/plugin/db/redis/core/visit/Visitor.java

@ -1,6 +1,6 @@
package com.fr.plugin.db.redis.core.visit;
import com.fr.base.Parameter;
import com.fr.stable.ParameterProvider;
import com.fr.plugin.db.redis.core.DataWrapper;
import com.fr.script.Calculator;
import com.fr.third.redis.clients.jedis.Jedis;

2
src/main/java/com/fr/plugin/db/redis/core/visit/VisitorFactory.java

@ -1,6 +1,6 @@
package com.fr.plugin.db.redis.core.visit;
import com.fr.base.Parameter;
import com.fr.stable.ParameterProvider;
import com.fr.plugin.db.redis.core.DataWrapper;
import com.fr.plugin.db.redis.core.visit.impl.*;
import com.fr.script.Calculator;

2
src/main/java/com/fr/plugin/db/redis/core/visit/impl/GetVisitor.java

@ -1,6 +1,6 @@
package com.fr.plugin.db.redis.core.visit.impl;
import com.fr.base.Parameter;
import com.fr.stable.ParameterProvider;
import com.fr.plugin.db.redis.core.visit.AbstractVisitor;
import com.fr.script.Calculator;
import com.fr.third.redis.clients.jedis.Jedis;

2
src/main/java/com/fr/plugin/db/redis/core/visit/impl/HashGetVisitor.java

@ -1,6 +1,6 @@
package com.fr.plugin.db.redis.core.visit.impl;
import com.fr.base.Parameter;
import com.fr.stable.ParameterProvider;
import com.fr.plugin.db.redis.core.visit.AbstractVisitor;
import com.fr.script.Calculator;
import com.fr.third.redis.clients.jedis.Jedis;

2
src/main/java/com/fr/plugin/db/redis/core/visit/impl/HashKeysVisitor.java

@ -1,6 +1,6 @@
package com.fr.plugin.db.redis.core.visit.impl;
import com.fr.base.Parameter;
import com.fr.stable.ParameterProvider;
import com.fr.plugin.db.redis.core.visit.AbstractVisitor;
import com.fr.script.Calculator;
import com.fr.third.redis.clients.jedis.Jedis;

2
src/main/java/com/fr/plugin/db/redis/core/visit/impl/HashMGetVisitor.java

@ -1,6 +1,6 @@
package com.fr.plugin.db.redis.core.visit.impl;
import com.fr.base.Parameter;
import com.fr.stable.ParameterProvider;
import com.fr.plugin.db.redis.core.visit.AbstractVisitor;
import com.fr.script.Calculator;
import com.fr.third.redis.clients.jedis.Jedis;

2
src/main/java/com/fr/plugin/db/redis/core/visit/impl/HashVisitor.java

@ -1,6 +1,6 @@
package com.fr.plugin.db.redis.core.visit.impl;
import com.fr.base.Parameter;
import com.fr.stable.ParameterProvider;
import com.fr.plugin.db.redis.core.visit.AbstractVisitor;
import com.fr.script.Calculator;
import com.fr.third.redis.clients.jedis.Jedis;

2
src/main/java/com/fr/plugin/db/redis/core/visit/impl/KeysVisitor.java

@ -1,6 +1,6 @@
package com.fr.plugin.db.redis.core.visit.impl;
import com.fr.base.Parameter;
import com.fr.stable.ParameterProvider;
import com.fr.plugin.db.redis.core.visit.AbstractVisitor;
import com.fr.script.Calculator;
import com.fr.third.redis.clients.jedis.Jedis;

2
src/main/java/com/fr/plugin/db/redis/core/visit/impl/ListVisitor.java

@ -1,6 +1,6 @@
package com.fr.plugin.db.redis.core.visit.impl;
import com.fr.base.Parameter;
import com.fr.stable.ParameterProvider;
import com.fr.base.TableData;
import com.fr.plugin.db.redis.core.visit.AbstractVisitor;
import com.fr.script.Calculator;

6
src/main/java/com/fr/plugin/db/redis/core/visit/impl/MGetVisitor.java

@ -1,9 +1,9 @@
package com.fr.plugin.db.redis.core.visit.impl;
import com.fr.base.Parameter;
import com.fr.stable.ParameterProvider;
import com.fr.plugin.db.redis.core.visit.AbstractVisitor;
import com.fr.script.Calculator;
import com.fr.stable.ArrayUtils;
import com.fanruan.api.util.ArrayKit;
import com.fr.third.redis.clients.jedis.Jedis;
import java.util.ArrayList;
@ -19,7 +19,7 @@ public class MGetVisitor extends AbstractVisitor<String> {
if (arr.length < 2) {
throw new IllegalArgumentException("Illegal query:" + query);
}
String[] args = (String[]) ArrayUtils.remove(arr, 0);
String[] args = (String[]) ArrayKit.remove(arr, 0);
List<String> data = client.mget(args);
List<List<String>> result = new ArrayList<List<String>>();
result.add(data);

2
src/main/java/com/fr/plugin/db/redis/core/visit/impl/SetVisitor.java

@ -1,6 +1,6 @@
package com.fr.plugin.db.redis.core.visit.impl;
import com.fr.base.Parameter;
import com.fr.stable.ParameterProvider;
import com.fr.plugin.db.redis.core.visit.AbstractVisitor;
import com.fr.script.Calculator;
import com.fr.third.redis.clients.jedis.Jedis;

2
src/main/java/com/fr/plugin/db/redis/core/visit/impl/ZRangeVisitor.java

@ -1,6 +1,6 @@
package com.fr.plugin.db.redis.core.visit.impl;
import com.fr.base.Parameter;
import com.fr.stable.ParameterProvider;
import com.fr.base.TableData;
import com.fr.plugin.db.redis.core.visit.AbstractVisitor;
import com.fr.script.Calculator;

7
src/main/java/com/fr/plugin/db/redis/help/Console.java

@ -1,6 +1,7 @@
package com.fr.plugin.db.redis.help;
import com.fr.log.FineLoggerFactory;
import com.fanruan.api.log.LogKit;
/**
* @author richie
@ -15,12 +16,12 @@ public class Console {
@ScriptBridge
public void log(Object message) {
FineLoggerFactory.getLogger().info(message == null ? null : message.toString());
LogKit.info(message == null ? null : message.toString());
}
@ScriptBridge
public void error(Object message) {
FineLoggerFactory.getLogger().error(message == null ? null : message.toString());
LogKit.error(message == null ? null : message.toString());
}
@ScriptBridge

9
src/main/java/com/fr/plugin/db/redis/help/Files.java

@ -1,9 +1,8 @@
package com.fr.plugin.db.redis.help;
import com.eclipsesource.v8.V8;
import com.fr.general.IOUtils;
import com.fr.io.utils.ResourceIOUtils;
import com.fr.stable.EncodeConstants;
import com.fanruan.api.util.IOKit;
import com.fanruan.api.consts.EncodeConstantsKit;
import java.io.InputStream;
import java.io.UnsupportedEncodingException;
@ -23,10 +22,10 @@ public class Files {
@ScriptBridge
public void require(String filePath) {
InputStream in = ResourceIOUtils.read(filePath);
InputStream in = IOKit.read(filePath);
if (in != null) {
try {
v8.executeVoidScript(IOUtils.inputStream2String(in, EncodeConstants.ENCODING_UTF_8));
v8.executeVoidScript(IOKit.inputStream2String(in, EncodeConstantsKit.ENCODING_UTF_8));
} catch (UnsupportedEncodingException ignore) {
}

7
src/main/java/com/fr/plugin/db/redis/help/client/BaseRedisClient.java

@ -1,6 +1,7 @@
package com.fr.plugin.db.redis.help.client;
import com.fr.log.FineLoggerFactory;
import com.fanruan.api.log.LogKit;
import com.fr.plugin.db.redis.help.ScriptBridge;
import com.fr.plugin.db.redis.help.RedisClient;
import com.fr.third.redis.clients.jedis.Jedis;
@ -24,7 +25,7 @@ public abstract class BaseRedisClient<A, O> implements RedisClient<A, O> {
try {
return jedis.get(key);
} finally {
FineLoggerFactory.getLogger().info("Fetch data from redis spend time {} ms.", System.currentTimeMillis() - start);
LogKit.info("Fetch data from redis spend time {} ms.", System.currentTimeMillis() - start);
}
}
@ -34,7 +35,7 @@ public abstract class BaseRedisClient<A, O> implements RedisClient<A, O> {
try {
return jedis.hget(key, field);
} finally {
FineLoggerFactory.getLogger().info("Fetch data from redis spend time {} ms.", System.currentTimeMillis() - start);
LogKit.info("Fetch data from redis spend time {} ms.", System.currentTimeMillis() - start);
}
}

18
src/main/java/com/fr/plugin/db/redis/help/client/RedisNashornClient.java

@ -1,7 +1,7 @@
package com.fr.plugin.db.redis.help.client;
import com.fr.base.TableData;
import com.fr.log.FineLoggerFactory;
import com.fanruan.api.log.LogKit;
import com.fr.plugin.db.redis.core.emb.Redis;
import com.fr.plugin.db.redis.help.Console;
import com.fr.plugin.db.redis.help.ScriptBridge;
@ -42,7 +42,7 @@ public class RedisNashornClient extends BaseRedisClient<Object[], Map<Object, Ob
public Object[] hkeys(String key) {
long start = System.currentTimeMillis();
Set<String> set = jedis.keys(key);
FineLoggerFactory.getLogger().info("Fetch data from redis spend time {} ms.", System.currentTimeMillis() - start);
LogKit.info("Fetch data from redis spend time {} ms.", System.currentTimeMillis() - start);
return set.toArray(new String[0]);
}
@ -51,7 +51,7 @@ public class RedisNashornClient extends BaseRedisClient<Object[], Map<Object, Ob
public Object[] hmget(String key, String... fields) {
long start = System.currentTimeMillis();
List<String> list = jedis.hmget(key, fields);
FineLoggerFactory.getLogger().info("Fetch data from redis spend time {} ms.", System.currentTimeMillis() - start);
LogKit.info("Fetch data from redis spend time {} ms.", System.currentTimeMillis() - start);
return list.toArray(new String[0]);
}
@ -60,7 +60,7 @@ public class RedisNashornClient extends BaseRedisClient<Object[], Map<Object, Ob
public Map<Object, Object> hgetAll(String key) {
long start = System.currentTimeMillis();
Map<String, String> map = jedis.hgetAll(key);
FineLoggerFactory.getLogger().info("Fetch data from redis spend time {} ms.", System.currentTimeMillis() - start);
LogKit.info("Fetch data from redis spend time {} ms.", System.currentTimeMillis() - start);
return new TreeMap<Object, Object>(map);
}
@ -69,7 +69,7 @@ public class RedisNashornClient extends BaseRedisClient<Object[], Map<Object, Ob
public Object[] keys(String pattern) {
long start = System.currentTimeMillis();
Set<String> set = jedis.keys(pattern);
FineLoggerFactory.getLogger().info("Fetch data from redis spend time {} ms.", System.currentTimeMillis() - start);
LogKit.info("Fetch data from redis spend time {} ms.", System.currentTimeMillis() - start);
return set.toArray(new String[0]);
}
@ -78,7 +78,7 @@ public class RedisNashornClient extends BaseRedisClient<Object[], Map<Object, Ob
public Object[] lrange(String key, long start, long end) {
long start0 = System.currentTimeMillis();
List<String> list = jedis.lrange(key, start, end);
FineLoggerFactory.getLogger().info("Fetch data from redis spend time {} ms.", System.currentTimeMillis() - start0);
LogKit.info("Fetch data from redis spend time {} ms.", System.currentTimeMillis() - start0);
return list.toArray(new String[0]);
}
@ -92,7 +92,7 @@ public class RedisNashornClient extends BaseRedisClient<Object[], Map<Object, Ob
parameters[i] = String.valueOf(keys[i]);
}
List<String> list = jedis.mget(parameters);
FineLoggerFactory.getLogger().info("Fetch data from redis spend time {} ms.", System.currentTimeMillis() - start);
LogKit.info("Fetch data from redis spend time {} ms.", System.currentTimeMillis() - start);
return list.toArray(new String[0]);
}
@ -101,7 +101,7 @@ public class RedisNashornClient extends BaseRedisClient<Object[], Map<Object, Ob
public Object[] smembers(String key) {
long start = System.currentTimeMillis();
Set<String> set = jedis.smembers(key);
FineLoggerFactory.getLogger().info("Fetch data from redis spend time {} ms.", System.currentTimeMillis() - start);
LogKit.info("Fetch data from redis spend time {} ms.", System.currentTimeMillis() - start);
return set.toArray(new String[0]);
}
@ -150,7 +150,7 @@ public class RedisNashornClient extends BaseRedisClient<Object[], Map<Object, Ob
}
return new SimpleDataModel(columnNames, data, realCount);
} catch (ScriptException e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
LogKit.error(e.getMessage(), e);
}
return null;
}

16
src/main/java/com/fr/plugin/db/redis/help/client/RedisV8Client.java

@ -5,7 +5,7 @@ import com.eclipsesource.v8.V8Array;
import com.eclipsesource.v8.V8Object;
import com.eclipsesource.v8.utils.V8ObjectUtils;
import com.fr.base.TableData;
import com.fr.log.FineLoggerFactory;
import com.fanruan.api.log.LogKit;
import com.fr.plugin.db.redis.core.emb.Redis;
import com.fr.plugin.db.redis.help.Console;
import com.fr.plugin.db.redis.help.Files;
@ -37,7 +37,7 @@ public class RedisV8Client extends BaseRedisClient<V8Array, V8Object> {
public V8Array hkeys(String key) {
long start = System.currentTimeMillis();
Set<String> set = jedis.keys(key);
FineLoggerFactory.getLogger().info("Fetch data from redis spend time {} ms.", System.currentTimeMillis() - start);
LogKit.info("Fetch data from redis spend time {} ms.", System.currentTimeMillis() - start);
return V8ObjectUtils.toV8Array(v8, new ArrayList<String>(set));
}
@ -46,7 +46,7 @@ public class RedisV8Client extends BaseRedisClient<V8Array, V8Object> {
public V8Array hmget(String key, String... fields) {
long start = System.currentTimeMillis();
List<String> list = jedis.hmget(key, fields);
FineLoggerFactory.getLogger().info("Fetch data from redis spend time {} ms.", System.currentTimeMillis() - start);
LogKit.info("Fetch data from redis spend time {} ms.", System.currentTimeMillis() - start);
return V8ObjectUtils.toV8Array(v8, list);
}
@ -55,7 +55,7 @@ public class RedisV8Client extends BaseRedisClient<V8Array, V8Object> {
public V8Object hgetAll(String key) {
long start = System.currentTimeMillis();
Map<String, String> map = jedis.hgetAll(key);
FineLoggerFactory.getLogger().info("Fetch data from redis spend time {} ms.", System.currentTimeMillis() - start);
LogKit.info("Fetch data from redis spend time {} ms.", System.currentTimeMillis() - start);
return V8ObjectUtils.toV8Object(v8, map);
}
@ -64,7 +64,7 @@ public class RedisV8Client extends BaseRedisClient<V8Array, V8Object> {
public V8Array keys(String pattern) {
long start = System.currentTimeMillis();
Set<String> set = jedis.keys(pattern);
FineLoggerFactory.getLogger().info("Fetch data from redis spend time {} ms.", System.currentTimeMillis() - start);
LogKit.info("Fetch data from redis spend time {} ms.", System.currentTimeMillis() - start);
return V8ObjectUtils.toV8Array(v8, new ArrayList<String>(set));
}
@ -73,7 +73,7 @@ public class RedisV8Client extends BaseRedisClient<V8Array, V8Object> {
public V8Array lrange(String key, long start, long end) {
long start0 = System.currentTimeMillis();
List<String> list = jedis.lrange(key, start, end);
FineLoggerFactory.getLogger().info("Fetch data from redis spend time {} ms.", System.currentTimeMillis() - start0);
LogKit.info("Fetch data from redis spend time {} ms.", System.currentTimeMillis() - start0);
return V8ObjectUtils.toV8Array(v8, list);
}
@ -87,7 +87,7 @@ public class RedisV8Client extends BaseRedisClient<V8Array, V8Object> {
parameters[i] = keys.getString(i);
}
List<String> list = jedis.mget(parameters);
FineLoggerFactory.getLogger().info("Fetch data from redis spend time {} ms.", System.currentTimeMillis() - start);
LogKit.info("Fetch data from redis spend time {} ms.", System.currentTimeMillis() - start);
keys.release();
return V8ObjectUtils.toV8Array(v8, list);
}
@ -97,7 +97,7 @@ public class RedisV8Client extends BaseRedisClient<V8Array, V8Object> {
public V8Array smembers(String key) {
long start = System.currentTimeMillis();
Set<String> set = jedis.smembers(key);
FineLoggerFactory.getLogger().info("Fetch data from redis spend time {} ms.", System.currentTimeMillis() - start);
LogKit.info("Fetch data from redis spend time {} ms.", System.currentTimeMillis() - start);
return V8ObjectUtils.toV8Array(v8, new ArrayList<String>(set));
}

43
src/main/java/com/fr/plugin/db/redis/ui/RedisBaseTableDataPane.java

@ -1,19 +1,20 @@
package com.fr.plugin.db.redis.ui;
import com.fr.base.BaseUtils;
import com.fr.base.ParameterHelper;
import com.fanruan.api.util.IOKit;
import com.fanruan.api.cal.ParameterKit;
import com.fanruan.api.design.ui.action.UpdateAction;
import com.fanruan.api.cal.ParameterKit;
import com.fr.base.TableData;
import com.fr.design.actions.UpdateAction;
import com.fr.design.data.datapane.preview.PreviewTablePane;
import com.fanruan.api.design.DesignKit;
import com.fr.design.data.tabledata.tabledatapane.AbstractTableDataPane;
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.fanruan.api.design.ui.component.table.model.ParameterTableModel;
import com.fanruan.api.design.ui.component.table.action.UITableEditAction;
import com.fanruan.api.design.ui.component.table.UITableEditorPane;
import com.fanruan.api.design.ui.component.UIToolbar;
import com.fanruan.api.design.DesignKit;
import com.fr.design.menu.ToolBarDef;
import com.fr.plugin.db.redis.core.order.OrderValue;
import com.fr.stable.ArrayUtils;
import com.fanruan.api.util.ArrayKit;
import com.fr.stable.ParameterProvider;
import javax.swing.*;
@ -28,8 +29,8 @@ import java.util.ArrayList;
*/
public abstract class RedisBaseTableDataPane<T extends TableData> extends AbstractTableDataPane<T> {
private static final String PREVIEW_BUTTON = Toolkit.i18nText("Plugin-Redis_Preview");
private static final String REFRESH_BUTTON = Toolkit.i18nText("Plugin-Redis_Refresh");
private static final String PREVIEW_BUTTON = DesignKit.i18nText("Plugin-Redis_Preview");
private static final String REFRESH_BUTTON = DesignKit.i18nText("Plugin-Redis_Refresh");
protected RedisDBConnectionChosePane chosePane;
@ -50,7 +51,7 @@ public abstract class RedisBaseTableDataPane<T extends TableData> extends Abstra
ParameterTableModel model = new ParameterTableModel() {
@Override
public UITableEditAction[] createAction() {
return ArrayUtils.add(super.createDBTableAction(), new RedisBaseTableDataPane.RefreshAction());
return ArrayKit.add(super.createDBTableAction(), new RedisBaseTableDataPane.RefreshAction());
}
};
editorPane = new UITableEditorPane<ParameterProvider>(model);
@ -81,7 +82,7 @@ public abstract class RedisBaseTableDataPane<T extends TableData> extends Abstra
@Override
protected String title4PopupWindow() {
return Toolkit.i18nText("Plugin-Redis_Query");
return DesignKit.i18nText("Plugin-Redis_Query");
}
protected abstract JComponent createQueryPane();
@ -94,19 +95,19 @@ public abstract class RedisBaseTableDataPane<T extends TableData> extends Abstra
private void refresh() {
String[] paramTexts = paramTexts();
ParameterProvider[] parameters = ParameterHelper.analyze4Parameters(paramTexts, false);
ParameterProvider[] parameters = ParameterKit.analyze4Parameters(paramTexts, false);
ParameterProvider[] providers = getOrderValue().analyze4Parameters();
editorPane.populate(ArrayUtils.addAll(parameters, providers));
editorPane.populate(ArrayKit.addAll(parameters, providers));
}
private void checkParameter() {
String[] paramTexts = paramTexts();
ParameterProvider[] parameters = ParameterHelper.analyze4Parameters(paramTexts, false);
parameters = ArrayUtils.addAll(parameters, getOrderValue().analyze4Parameters());
ParameterProvider[] parameters = ParameterKit.analyze4Parameters(paramTexts, false);
parameters = ArrayKit.addAll(parameters, getOrderValue().analyze4Parameters());
if (parameters.length < 1 && editorPane.update().size() < 1) {
return;
@ -134,12 +135,12 @@ public abstract class RedisBaseTableDataPane<T extends TableData> extends Abstra
public PreviewAction() {
this.setName(PREVIEW_BUTTON);
this.setMnemonic('P');
this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/m_file/preview.png"));
this.setSmallIcon(IOKit.readIcon("/com/fr/design/images/m_file/preview.png"));
}
public void actionPerformed(ActionEvent evt) {
checkParameter();
PreviewTablePane.previewTableData(RedisBaseTableDataPane.this.updateBean());
DesignKit.previewTableData(RedisBaseTableDataPane.this.updateBean());
}
}
@ -147,7 +148,7 @@ public abstract class RedisBaseTableDataPane<T extends TableData> extends Abstra
protected class RefreshAction extends UITableEditAction {
public RefreshAction() {
this.setName(REFRESH_BUTTON);
this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/control/refresh.png"));
this.setSmallIcon(IOKit.readIcon("/com/fr/design/images/control/refresh.png"));
}
public void actionPerformed(ActionEvent e) {

47
src/main/java/com/fr/plugin/db/redis/ui/RedisConnectionPane.java

@ -1,20 +1,19 @@
package com.fr.plugin.db.redis.ui;
import com.fr.design.border.UITitledBorder;
import com.fr.design.data.datapane.connect.DatabaseConnectionPane;
import com.fr.design.dialog.BasicDialog;
import com.fr.design.dialog.DialogActionAdapter;
import com.fr.design.gui.ibutton.UIPasswordField;
import com.fr.design.gui.ilable.ActionLabel;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.gui.itextfield.UIIntNumberField;
import com.fr.design.gui.itextfield.UINumberField;
import com.fr.design.gui.itextfield.UITextField;
import com.fr.design.i18n.Toolkit;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.layout.TableLayout;
import com.fr.design.layout.TableLayoutHelper;
import com.fr.design.utils.gui.GUICoreUtils;
import com.fanruan.api.design.ui.container.DatabaseConnectionPane;
import com.fanruan.api.design.ui.container.BasicDialog;
import com.fanruan.api.design.ui.container.DialogActionAdapter;
import com.fanruan.api.design.ui.component.UIPasswordField;
import com.fanruan.api.design.component.UIActionLabel;
import com.fanruan.api.design.ui.component.UILabel;
import com.fanruan.api.design.ui.component.UIIntNumberField;
import com.fanruan.api.design.ui.component.UINumberField;
import com.fanruan.api.design.ui.component.UITextField;
import com.fanruan.api.design.DesignKit;
import com.fanruan.api.design.util.GUICoreKit;
import com.fanruan.api.design.ui.layout.TableLayoutKit;
import com.fanruan.api.design.util.GUICoreKit;
import com.fr.plugin.db.redis.core.RedisDatabaseConnection;
import com.fr.plugin.db.redis.core.pool.RedisConnectionPoolConfig;
import com.fr.plugin.db.redis.core.pool.RedisConnectionProxyConfig;
@ -51,14 +50,14 @@ public class RedisConnectionPane extends DatabaseConnectionPane<com.fr.plugin.db
globalConfigPane.setLayout(gridLayout);
Component[][] components = new Component[][]{
{new UILabel(Toolkit.i18nText("Plugin-Redis_Host") + ":"), hostTextField},
{new UILabel(Toolkit.i18nText("Plugin-Redis_Port") + ":"), portNumberField},
{new UILabel(Toolkit.i18nText("Plugin-Redis_Password") + ":"), passwordTextField},
{new UILabel(DesignKit.i18nText("Plugin-Redis_Host") + ":"), hostTextField},
{new UILabel(DesignKit.i18nText("Plugin-Redis_Port") + ":"), portNumberField},
{new UILabel(DesignKit.i18nText("Plugin-Redis_Password") + ":"), passwordTextField},
{null, globalConfigPane}
};
ActionLabel poolConfigLabel = new ActionLabel(Toolkit.i18nText("Plugin-Redis_Pool_Config"));
ActionLabel proxyConfigLabel = new ActionLabel(Toolkit.i18nText("Plugin-Redis_Proxy_Config"));
UIActionLabel poolConfigLabel = new UIActionLabel(DesignKit.i18nText("Plugin-Redis_Pool_Config"));
UIActionLabel proxyConfigLabel = new UIActionLabel(DesignKit.i18nText("Plugin-Redis_Proxy_Config"));
poolConfigLabel.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
@ -99,17 +98,17 @@ public class RedisConnectionPane extends DatabaseConnectionPane<com.fr.plugin.db
dialog.setVisible(true);
}
});
globalConfigPane.add(GUICoreUtils.createFlowPane(poolConfigLabel, FlowLayout.LEFT));
globalConfigPane.add(GUICoreUtils.createFlowPane(proxyConfigLabel, FlowLayout.LEFT));
double p = TableLayout.PREFERRED;
globalConfigPane.add(GUICoreKit.createFlowPane(poolConfigLabel, FlowLayout.LEFT));
globalConfigPane.add(GUICoreKit.createFlowPane(proxyConfigLabel, FlowLayout.LEFT));
double p = TableLayoutKit.PREFERRED;
double[] rowSize = new double[]{p, p, p, p, p};
double[] columnSize = new double[]{p, 400};
JPanel settingsUI = TableLayoutHelper.createTableLayoutPane(components, rowSize, columnSize);
JPanel settingsUI = TableLayoutKit.createTableLayoutPane(components, rowSize, columnSize);
settingsUI.setBorder(UITitledBorder.createBorderWithTitle("Redis"));
JPanel centerPane = FRGUIPaneFactory.createNormalFlowInnerContainer_M_Pane();
JPanel centerPane = GUICoreKit.createNormalFlowInnerContainerPane();
centerPane.add(settingsUI);

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

@ -2,18 +2,18 @@ package com.fr.plugin.db.redis.ui;
import com.fr.data.impl.Connection;
import com.fr.data.operator.DataOperator;
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.log.FineLoggerFactory;
import com.fanruan.api.design.ui.container.ConnectionComboBoxPanel;
import com.fanruan.api.design.ui.component.UIButton;
import com.fanruan.api.design.ui.component.UIPlaceholderTextField;
import com.fanruan.api.design.DesignKit;
import com.fanruan.api.data.ConnectionKit;
import com.fr.plugin.db.redis.core.RedisDatabaseConnection;
import com.fr.plugin.db.redis.ui.event.DataLoadedListener;
import com.fr.stable.ArrayUtils;
import com.fr.stable.StringUtils;
import com.fanruan.api.util.ArrayKit;
import com.fanruan.api.util.StringKit;
import com.fanruan.api.log.LogKit;
import com.fanruan.api.design.ui.container.BasicPane;
import com.fanruan.api.design.util.GUICoreKit;
import javax.swing.*;
import java.awt.*;
@ -28,7 +28,7 @@ public class RedisDBConnectionChosePane extends BasicPane {
private ConnectionComboBoxPanel connectionComboBoxPanel;
private DefaultListModel listModel = new DefaultListModel();
private List<DataLoadedListener> listeners = new ArrayList<DataLoadedListener>();
private PlaceholderTextField keysPatternTextField;
private UIPlaceholderTextField keysPatternTextField;
public RedisDBConnectionChosePane() {
setLayout(new BorderLayout(4, 4));
@ -48,12 +48,12 @@ public class RedisDBConnectionChosePane extends BasicPane {
});
JList list = new JList(listModel);
keysPatternTextField = new PlaceholderTextField(10);
keysPatternTextField.setPlaceholder(Toolkit.i18nText("Plugin-Redis_Keys_Pattern"));
keysPatternTextField = new UIPlaceholderTextField(10);
keysPatternTextField.setPlaceholder(DesignKit.i18nText("Plugin-Redis_Keys_Pattern"));
JPanel centerPane = new JPanel(new BorderLayout());
UIButton searchButton = new UIButton(Toolkit.i18nText("Plugin-Redis_Keys_Pattern_Search"));
UIButton searchButton = new UIButton(DesignKit.i18nText("Plugin-Redis_Keys_Pattern_Search"));
searchButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
@ -61,7 +61,7 @@ public class RedisDBConnectionChosePane extends BasicPane {
}
});
centerPane.add(GUICoreUtils.createBorderLayoutPane(
centerPane.add(GUICoreKit.createBorderLayoutPane(
keysPatternTextField, BorderLayout.CENTER,
searchButton, BorderLayout.EAST), BorderLayout.NORTH);
@ -72,12 +72,12 @@ public class RedisDBConnectionChosePane extends BasicPane {
private void loadKeys() {
String name = getSelectRedisConnectionName();
if (StringUtils.isEmpty(name)) {
if (StringKit.isEmpty(name)) {
clearList();
fireDataLoaded(ArrayUtils.EMPTY_STRING_ARRAY);
fireDataLoaded(ArrayKit.EMPTY_STRING_ARRAY);
return;
}
RedisDatabaseConnection connection = DatasourceManager.getProviderInstance().getConnection(name, RedisDatabaseConnection.class);
RedisDatabaseConnection connection = ConnectionKit.getConnection(name, RedisDatabaseConnection.class);
if (connection != null) {
listMatchedPatternKeys(connection);
}
@ -94,8 +94,8 @@ public class RedisDBConnectionChosePane extends BasicPane {
@Override
protected String[] doInBackground() throws Exception {
String keysPattern = keysPatternTextField.getText();
if (StringUtils.isEmpty(keysPattern)) {
return ArrayUtils.EMPTY_STRING_ARRAY;
if (StringKit.isEmpty(keysPattern)) {
return ArrayKit.EMPTY_STRING_ARRAY;
} else {
return DataOperator.getInstance().getTableSummary(connection, keysPattern);
}
@ -110,7 +110,7 @@ public class RedisDBConnectionChosePane extends BasicPane {
}
fireDataLoaded(keys);
} catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
LogKit.error(e.getMessage(), e);
}
}
}.execute();

43
src/main/java/com/fr/plugin/db/redis/ui/RedisQueryPane.java

@ -1,19 +1,18 @@
package com.fr.plugin.db.redis.ui;
import com.fr.design.data.datapane.sqlpane.SQLEditPane;
import com.fr.design.dialog.BasicPane;
import com.fr.design.editor.ValueEditorPane;
import com.fr.design.gui.ilable.ActionLabel;
import com.fr.design.gui.ilable.UILabel;
import com.fanruan.api.design.ui.container.BasicPane;
import com.fanruan.api.layout.TableLayoutKit;
import com.fanruan.api.design.util.GUICoreKit;
import com.fanruan.api.log.LogKit;
import com.fanruan.api.design.container.SQLEditPane;
import com.fanruan.api.design.ui.editor.ValueEditorPane;
import com.fanruan.api.design.component.UIActionLabel;
import com.fanruan.api.design.ui.component.UILabel;
import com.fr.design.gui.itextarea.DescriptionTextArea;
import com.fr.design.gui.syntax.ui.rsyntaxtextarea.RSyntaxTextArea;
import com.fr.design.gui.syntax.ui.rsyntaxtextarea.SyntaxConstants;
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.fanruan.api.design.ui.component.code.UISyntaxTextArea;
import com.fanruan.api.design.ui.component.code.SyntaxConstants;
import com.fanruan.api.design.DesignKit;
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;
import com.fr.plugin.db.redis.util.RedisDesignUtils;
@ -29,25 +28,25 @@ public class RedisQueryPane extends BasicPane {
private SQLEditPane sqlTextPane;
private ValueEditorPane dbIndexEditor;
private RSyntaxTextArea scriptTextPane;
private UISyntaxTextArea scriptTextPane;
public RedisQueryPane() {
setLayout(new BorderLayout());
sqlTextPane = new SQLEditPane();
scriptTextPane = new RSyntaxTextArea();
scriptTextPane = new UISyntaxTextArea();
dbIndexEditor = IndexValuePaneFactory.createValueEditorPane();
ActionLabel helpLabel = new ActionLabel(Toolkit.i18nText("Plugin-Redis_Help"));
UIActionLabel helpLabel = new UIActionLabel(DesignKit.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) {
FineLoggerFactory.getLogger().error(e1.getMessage(), e1);
LogKit.error(e1.getMessage(), e1);
}
}
});
@ -56,11 +55,11 @@ public class RedisQueryPane extends BasicPane {
descriptionArea.setWrapStyleWord(true);
descriptionArea.setLineWrap(true);
descriptionArea.setText(Toolkit.i18nText("Plugin-Redis_Script_Text_Description"));
descriptionArea.setText(DesignKit.i18nText("Plugin-Redis_Script_Text_Description"));
Component[][] coms = new Component[][]{
{new UILabel(Toolkit.i18nText("Plugin-Redis_DB_Index") + ":"), dbIndexEditor},
{GUICoreUtils.createBorderLayoutPane(new UILabel(Toolkit.i18nText("Plugin-Redis_Query_Condition") + ":"), BorderLayout.NORTH),
{new UILabel(DesignKit.i18nText("Plugin-Redis_DB_Index") + ":"), dbIndexEditor},
{GUICoreKit.createBorderLayoutPane(new UILabel(DesignKit.i18nText("Plugin-Redis_Query_Condition") + ":"), BorderLayout.NORTH),
RedisDesignUtils.createConditionTextPane(sqlTextPane, SyntaxConstants.SYNTAX_STYLE_SQL, 300)}
};
@ -68,13 +67,13 @@ public class RedisQueryPane extends BasicPane {
// RedisDesignUtils.createConditionTextPane(scriptTextPane, SyntaxConstants.SYNTAX_STYLE_JAVASCRIPT, 200)
// }
double p = TableLayout.PREFERRED;
double f = TableLayout.FILL;
double p = TableLayoutKit.PREFERRED;
double f = TableLayoutKit.FILL;
double[] rowSize = {p, p};
double[] columnSize = {p, f};
add(TableLayoutHelper.createTableLayoutPane(coms, rowSize, columnSize));
add(GUICoreKit.createTableLayoutPane(coms, rowSize, columnSize));
}

30
src/main/java/com/fr/plugin/db/redis/ui/RedisScriptPane.java

@ -1,13 +1,13 @@
package com.fr.plugin.db.redis.ui;
import com.fr.design.dialog.BasicPane;
import com.fr.design.editor.ValueEditorPane;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.gui.syntax.ui.rsyntaxtextarea.RSyntaxTextArea;
import com.fr.design.gui.syntax.ui.rsyntaxtextarea.SyntaxConstants;
import com.fr.design.i18n.Toolkit;
import com.fr.design.layout.TableLayout;
import com.fr.design.layout.TableLayoutHelper;
import com.fanruan.api.design.ui.container.BasicPane;
import com.fanruan.api.design.util.GUICoreKit;
import com.fanruan.api.layout.TableLayoutKit;
import com.fanruan.api.design.ui.editor.ValueEditorPane;
import com.fanruan.api.design.ui.component.UILabel;
import com.fanruan.api.design.ui.component.code.UISyntaxTextArea;
import com.fanruan.api.design.ui.component.code.SyntaxConstants;
import com.fanruan.api.design.DesignKit;
import com.fr.plugin.db.redis.core.order.OrderValue;
import com.fr.plugin.db.redis.ui.value.IndexValuePaneFactory;
import com.fr.plugin.db.redis.util.RedisDesignUtils;
@ -22,29 +22,29 @@ import java.awt.*;
public class RedisScriptPane extends BasicPane {
private ValueEditorPane dbIndexEditor;
private RSyntaxTextArea scriptTextPane;
private UISyntaxTextArea scriptTextPane;
public RedisScriptPane() {
setLayout(new BorderLayout());
scriptTextPane = new RSyntaxTextArea();
scriptTextPane = new UISyntaxTextArea();
dbIndexEditor = IndexValuePaneFactory.createValueEditorPane();
Component[][] coms = new Component[][]{
{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Plugin-Redis_DB_Index") + ":"), dbIndexEditor},
{new UILabel(Toolkit.i18nText("Plugin-Redis_Script_Query_Text") + ":"),
{new UILabel(DesignKit.i18nText("Plugin-Redis_DB_Index") + ":"), dbIndexEditor},
{new UILabel(DesignKit.i18nText("Plugin-Redis_Script_Query_Text") + ":"),
RedisDesignUtils.createConditionTextPane(scriptTextPane, SyntaxConstants.SYNTAX_STYLE_JAVASCRIPT, 350)},
};
double p = TableLayout.PREFERRED;
double f = TableLayout.FILL;
double p = TableLayoutKit.PREFERRED;
double f = TableLayoutKit.FILL;
double[] rowSize = {p, p, p};
double[] columnSize = {p, f};
add(TableLayoutHelper.createTableLayoutPane(coms, rowSize, columnSize));
add(GUICoreKit.createTableLayoutPane(coms, rowSize, columnSize));
}

6
src/main/java/com/fr/plugin/db/redis/ui/RedisScriptTableDataPane.java

@ -1,11 +1,11 @@
package com.fr.plugin.db.redis.ui;
import com.fr.data.impl.NameDatabaseConnection;
import com.fanruan.api.database.nameDatabase.NameDatabaseConnection;
import com.fr.plugin.db.redis.core.RedisScriptTableData;
import com.fr.plugin.db.redis.core.order.OrderValue;
import com.fr.script.Calculator;
import com.fr.stable.ParameterProvider;
import com.fr.stable.StringUtils;
import com.fanruan.api.util.StringKit;
import javax.swing.*;
import java.util.List;
@ -61,7 +61,7 @@ public class RedisScriptTableDataPane extends RedisBaseTableDataPane<RedisScript
public RedisScriptTableData updateBean() {
RedisScriptTableData tableData = new RedisScriptTableData();
String connectionName = chosePane.getSelectRedisConnectionName();
if (StringUtils.isNotEmpty(connectionName)) {
if (StringKit.isNotEmpty(connectionName)) {
tableData.setDatabase(new NameDatabaseConnection(connectionName));
}
List<ParameterProvider> parameterList = editorPane.update();

10
src/main/java/com/fr/plugin/db/redis/ui/RedisTableDataPane.java

@ -1,12 +1,12 @@
package com.fr.plugin.db.redis.ui;
import com.fr.data.impl.NameDatabaseConnection;
import com.fr.design.i18n.Toolkit;
import com.fanruan.api.design.DesignKit;
import com.fanruan.api.database.nameDatabase.NameDatabaseConnection;
import com.fr.plugin.db.redis.core.RedisTableData;
import com.fr.plugin.db.redis.core.order.OrderValue;
import com.fr.script.Calculator;
import com.fr.stable.ParameterProvider;
import com.fr.stable.StringUtils;
import com.fanruan.api.util.StringKit;
import javax.swing.*;
import java.util.List;
@ -24,7 +24,7 @@ public class RedisTableDataPane extends RedisBaseTableDataPane<RedisTableData> {
@Override
protected String title4PopupWindow() {
return Toolkit.i18nText("Plugin-Redis_Query");
return DesignKit.i18nText("Plugin-Redis_Query");
}
protected JComponent createQueryPane() {
@ -68,7 +68,7 @@ public class RedisTableDataPane extends RedisBaseTableDataPane<RedisTableData> {
RedisTableData tableData = new RedisTableData();
String connectionName = chosePane.getSelectRedisConnectionName();
if (StringUtils.isNotEmpty(connectionName)) {
if (StringKit.isNotEmpty(connectionName)) {
tableData.setDatabase(new NameDatabaseConnection(connectionName));
}

36
src/main/java/com/fr/plugin/db/redis/ui/pool/RedisConnectionPoolConfigPane.java

@ -1,13 +1,13 @@
package com.fr.plugin.db.redis.ui.pool;
import com.fr.design.dialog.BasicPane;
import com.fr.design.gui.icheckbox.UICheckBox;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.gui.itextfield.UIIntNumberField;
import com.fr.design.gui.itextfield.UINumberField;
import com.fr.design.i18n.Toolkit;
import com.fr.design.layout.TableLayout;
import com.fr.design.layout.TableLayoutHelper;
import com.fanruan.api.design.ui.container.BasicPane;
import com.fanruan.api.layout.TableLayoutKit;
import com.fanruan.api.design.util.GUICoreKit;
import com.fanruan.api.design.ui.component.UICheckBox;
import com.fanruan.api.design.ui.component.UILabel;
import com.fanruan.api.design.ui.component.UIIntNumberField;
import com.fanruan.api.design.ui.component.UINumberField;
import com.fanruan.api.design.DesignKit;
import com.fr.plugin.db.redis.core.pool.RedisConnectionPoolConfig;
import javax.swing.*;
@ -43,24 +43,24 @@ public class RedisConnectionPoolConfigPane extends BasicPane {
timeoutNumberField = new UIIntNumberField();
JComponent[][] comps = new JComponent[][]{
{new UILabel(Toolkit.i18nText("Plugin-Redis_Pool_Max_Total") + ":"), maxTotalNumberFiled},
{new UILabel(Toolkit.i18nText("Plugin-Redis_Pool_Max_Wait") + ":"), maxWaitNumberField},
{new UILabel(Toolkit.i18nText("Plugin-Redis_Pool_Max_Idle") + ":"), maxIdleNumberField},
{new UILabel(Toolkit.i18nText("Plugin-Redis_Pool_Block_When_Exhausted") + ":"), blockWhenExhaustedCheckBox},
{new UILabel(Toolkit.i18nText("Plugin-Redis_Pool_Lifo") + ":"), lifoCheckBox},
{new UILabel(Toolkit.i18nText("Plugin-Redis_Pool_Timeout") + ":"), timeoutNumberField}
{new UILabel(DesignKit.i18nText("Plugin-Redis_Pool_Max_Total") + ":"), maxTotalNumberFiled},
{new UILabel(DesignKit.i18nText("Plugin-Redis_Pool_Max_Wait") + ":"), maxWaitNumberField},
{new UILabel(DesignKit.i18nText("Plugin-Redis_Pool_Max_Idle") + ":"), maxIdleNumberField},
{new UILabel(DesignKit.i18nText("Plugin-Redis_Pool_Block_When_Exhausted") + ":"), blockWhenExhaustedCheckBox},
{new UILabel(DesignKit.i18nText("Plugin-Redis_Pool_Lifo") + ":"), lifoCheckBox},
{new UILabel(DesignKit.i18nText("Plugin-Redis_Pool_Timeout") + ":"), timeoutNumberField}
};
double p = TableLayout.PREFERRED;
double f = TableLayout.FILL;
double p = TableLayoutKit.PREFERRED;
double f = TableLayoutKit.FILL;
double[] rowSize = new double[]{p, p, p, p, p, p};
double[] columnSize = new double[]{p, f};
add(TableLayoutHelper.createTableLayoutPane(comps, rowSize, columnSize), BorderLayout.CENTER);
add(GUICoreKit.createTableLayoutPane(comps, rowSize, columnSize), BorderLayout.CENTER);
}
@Override
protected String title4PopupWindow() {
return Toolkit.i18nText("Plugin-Redis_Pool_Config");
return DesignKit.i18nText("Plugin-Redis_Pool_Config");
}
public void populate(RedisConnectionPoolConfig config) {

45
src/main/java/com/fr/plugin/db/redis/ui/proxy/RedisConnectionProxyConfigPane.java

@ -1,16 +1,15 @@
package com.fr.plugin.db.redis.ui.proxy;
import com.fr.design.dialog.BasicPane;
import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.gui.icheckbox.UICheckBox;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.gui.ipasswordfield.UIPassWordField;
import com.fr.design.gui.itextfield.UIIntNumberField;
import com.fr.design.gui.itextfield.UITextField;
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.fanruan.api.design.ui.container.BasicPane;
import com.fanruan.api.layout.TableLayoutKit;
import com.fanruan.api.design.util.GUICoreKit;
import com.fanruan.api.design.ui.component.UIButton;
import com.fanruan.api.design.ui.component.UICheckBox;
import com.fanruan.api.design.ui.component.UILabel;
import com.fanruan.api.design.ui.component.UIPassWordField;
import com.fanruan.api.design.ui.component.UIIntNumberField;
import com.fanruan.api.design.ui.component.UITextField;
import com.fanruan.api.design.DesignKit;
import com.fr.plugin.db.redis.core.pool.RedisConnectionProxyConfig;
import javax.swing.*;
@ -47,22 +46,22 @@ public class RedisConnectionProxyConfigPane extends BasicPane {
passwordTextField = new UIPassWordField();
privateKeyPathTextField = new UITextField();
privateKeyPathTextField.setPlaceholder(Toolkit.i18nText("Plugin-Redis_Proxy_Private_Key_Tip"));
privateKeyPathTextField.setPlaceholder(DesignKit.i18nText("Plugin-Redis_Proxy_Private_Key_Tip"));
UIButton fileSelectButton = new UIButton("...");
UILabel description = new UILabel(Toolkit.i18nText("Plugin-Redis_Proxy_Description"), SwingConstants.CENTER);
UILabel description = new UILabel(DesignKit.i18nText("Plugin-Redis_Proxy_Description"), SwingConstants.CENTER);
JComponent[][] comps = new JComponent[][]{
{new UILabel(Toolkit.i18nText("Plugin-Redis_Proxy_Open") + ":"), GUICoreUtils.createBorderLayoutPane(
{new UILabel(DesignKit.i18nText("Plugin-Redis_Proxy_Open") + ":"), GUICoreKit.createBorderLayoutPane(
openCheckBox, BorderLayout.WEST,
description, BorderLayout.CENTER
)},
{new UILabel(Toolkit.i18nText("Plugin-Redis_Proxy_Host") + ":"), hostTextField},
{new UILabel(Toolkit.i18nText("Plugin-Redis_Proxy_Port") + ":"), portNumberField},
{new UILabel(Toolkit.i18nText("Plugin-Redis_Proxy_Username") + ":"), usernameTextField},
{new UILabel(Toolkit.i18nText("Plugin-Redis_Proxy_Password") + ":"), passwordTextField},
{new UILabel(Toolkit.i18nText("Plugin-Redis_Proxy_Private_Key_Path") + ":"), GUICoreUtils.createBorderLayoutPane(
{new UILabel(DesignKit.i18nText("Plugin-Redis_Proxy_Host") + ":"), hostTextField},
{new UILabel(DesignKit.i18nText("Plugin-Redis_Proxy_Port") + ":"), portNumberField},
{new UILabel(DesignKit.i18nText("Plugin-Redis_Proxy_Username") + ":"), usernameTextField},
{new UILabel(DesignKit.i18nText("Plugin-Redis_Proxy_Password") + ":"), passwordTextField},
{new UILabel(DesignKit.i18nText("Plugin-Redis_Proxy_Private_Key_Path") + ":"), GUICoreKit.createBorderLayoutPane(
privateKeyPathTextField, BorderLayout.CENTER,
fileSelectButton, BorderLayout.EAST
)},
@ -79,18 +78,18 @@ public class RedisConnectionProxyConfigPane extends BasicPane {
}
});
double p = TableLayout.PREFERRED;
double f = TableLayout.FILL;
double p = TableLayoutKit.PREFERRED;
double f = TableLayoutKit.FILL;
double[] rowSize = new double[]{p, p, p, p, p, p};
double[] columnSize = new double[]{p, f};
add(TableLayoutHelper.createTableLayoutPane(comps, rowSize, columnSize), BorderLayout.CENTER);
add(GUICoreKit.createTableLayoutPane(comps, rowSize, columnSize), BorderLayout.CENTER);
}
@Override
protected String title4PopupWindow() {
return Toolkit.i18nText("Plugin-Redis_Proxy_Config");
return DesignKit.i18nText("Plugin-Redis_Proxy_Config");
}
public void populate(RedisConnectionProxyConfig config) {

18
src/main/java/com/fr/plugin/db/redis/ui/value/FormulaEditor.java

@ -1,13 +1,13 @@
package com.fr.plugin.db.redis.ui.value;
import com.fr.base.BaseFormula;
import com.fr.design.dialog.DialogActionAdapter;
import com.fr.design.editor.editor.Editor;
import com.fr.design.formula.FormulaFactory;
import com.fanruan.api.design.ui.container.DialogActionAdapter;
import com.fanruan.api.design.ui.editor.Editor;
import com.fanruan.api.design.ui.factory.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.fanruan.api.design.ui.component.UITextField;
import com.fanruan.api.design.DesignKit;
import com.fanruan.api.design.util.GUICoreKit;
import com.fr.plugin.db.redis.core.order.impl.FormulaOrderValue;
import javax.swing.*;
@ -27,7 +27,7 @@ public class FormulaEditor extends Editor<FormulaOrderValue> {
* Constructor.
*/
public FormulaEditor() {
this(Toolkit.i18nText("Plugin-Redis_Formula"));
this(DesignKit.i18nText("Plugin-Redis_Formula"));
}
public FormulaEditor(String name) {
@ -38,9 +38,9 @@ public class FormulaEditor extends Editor<FormulaOrderValue> {
if (formula != null) {
this.orderValue = formula;
}
this.setLayout(FRGUIPaneFactory.createBorderLayout());
this.setLayout(GUICoreKit.createBorderLayout());
JPanel editPane = FRGUIPaneFactory.createBorderLayout_S_Pane();
JPanel editPane = GUICoreKit.createBorderLayoutPane();
currentTextField = new UITextField(28);
currentTextField.setText(this.orderValue.getValue().getContent());

6
src/main/java/com/fr/plugin/db/redis/ui/value/IndexValuePaneFactory.java

@ -1,8 +1,8 @@
package com.fr.plugin.db.redis.ui.value;
import com.fr.design.editor.ValueEditorPane;
import com.fr.design.editor.ValueEditorPaneFactory;
import com.fr.design.editor.editor.Editor;
import com.fanruan.api.design.ui.editor.ValueEditorPane;
import com.fanruan.api.design.ui.editor.ValueEditorPane;
import com.fanruan.api.design.ui.editor.Editor;
public class IndexValuePaneFactory {

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

@ -1,10 +1,10 @@
package com.fr.plugin.db.redis.ui.value;
import com.fr.base.Utils;
import com.fr.design.editor.editor.Editor;
import com.fr.design.gui.itextfield.UIIntNumberField;
import com.fr.design.gui.itextfield.UITextField;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fanruan.api.util.GeneralKit;
import com.fanruan.api.design.ui.editor.Editor;
import com.fanruan.api.design.ui.component.UIIntNumberField;
import com.fanruan.api.design.ui.component.UITextField;
import com.fanruan.api.design.util.GUICoreKit;
import com.fr.plugin.db.redis.core.order.impl.NumberOrderValue;
import com.fr.stable.StringUtils;
@ -32,7 +32,7 @@ public class IntegerEditor extends Editor<NumberOrderValue> {
* Constructor.
*/
public IntegerEditor(NumberOrderValue value, String name) {
this.setLayout(FRGUIPaneFactory.createBorderLayout());
this.setLayout(GUICoreKit.createBorderLayout());
numberField = new UIIntNumberField();
this.add(numberField, BorderLayout.CENTER);
this.numberField.addKeyListener(textKeyListener);
@ -101,7 +101,7 @@ public class IntegerEditor extends Editor<NumberOrderValue> {
value = new NumberOrderValue(0);
}
this.numberField.setValue(value.getValue());
oldValue = Utils.objectToString(value);
oldValue = GeneralKit.objectToString(value);
}

12
src/main/java/com/fr/plugin/db/redis/util/RedisDesignUtils.java

@ -1,9 +1,9 @@
package com.fr.plugin.db.redis.util;
import com.fr.design.border.UIRoundedBorder;
import com.fr.design.constants.UIConstants;
import com.fr.design.gui.syntax.ui.rsyntaxtextarea.RSyntaxTextArea;
import com.fr.design.gui.syntax.ui.rtextarea.RTextScrollPane;
import com.fanruan.api.design.ui.component.UIRoundedBorder;
import com.fanruan.api.design.macro.UIConstants;
import com.fanruan.api.design.ui.component.code.UISyntaxTextArea;
import com.fanruan.api.design.ui.component.code.UISyntaxTextScrollPane;
import java.awt.*;
@ -13,9 +13,9 @@ import java.awt.*;
* Created by richie on 2019-03-18
*/
public class RedisDesignUtils {
public static RTextScrollPane createConditionTextPane(RSyntaxTextArea editorPane, String type, int height) {
public static UISyntaxTextScrollPane createConditionTextPane(UISyntaxTextArea editorPane, String type, int height) {
editorPane.setSyntaxEditingStyle(type);
RTextScrollPane sqlTextScrollPane = new RTextScrollPane(editorPane);
UISyntaxTextScrollPane sqlTextScrollPane = new UISyntaxTextScrollPane(editorPane);
sqlTextScrollPane.setBorder(new UIRoundedBorder(UIConstants.LINE_COLOR, 1, UIConstants.ARC));
sqlTextScrollPane.setPreferredSize(new Dimension(680, height));
sqlTextScrollPane.setLineNumbersEnabled(false);

10
src/main/java/com/fr/plugin/db/redis/util/RedisUtils.java

@ -1,10 +1,10 @@
package com.fr.plugin.db.redis.util;
import com.eclipsesource.v8.V8Object;
import com.fr.base.Parameter;
import com.fr.base.TemplateUtils;
import com.fr.stable.ParameterProvider;
import com.fanruan.api.util.RenderKit;
import com.fr.plugin.db.redis.help.ScriptBridge;
import com.fr.stable.ArrayUtils;
import com.fanruan.api.util.ArrayKit;
import com.fr.third.redis.clients.jedis.Jedis;
import java.lang.reflect.Method;
@ -27,7 +27,7 @@ public class RedisUtils {
}
public static String calculateQuery(String query, Parameter[] ps) {
if (ArrayUtils.isEmpty(ps)) {
if (ArrayKit.isEmpty(ps)) {
return query;
}
Map<String, Object> map = new HashMap<String, Object>();
@ -35,7 +35,7 @@ public class RedisUtils {
map.put(p.getName(), p.getValue());
}
try {
return TemplateUtils.renderParameter4Tpl(query, map);
return RenderKit.renderParameter4Tpl(query, map);
} catch (Exception e) {
return query;
}

Loading…
Cancel
Save