Browse Source

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

paid
richie 5 years ago committed by Gogs
parent
commit
1a0df16808
  1. 3
      src/main/java/com/fr/plugin/db/redis/core/DataWrapper.java
  2. 4
      src/main/java/com/fr/plugin/db/redis/core/RedisDatabaseConnection.java
  3. 6
      src/main/java/com/fr/plugin/db/redis/core/RedisScriptTableData.java
  4. 6
      src/main/java/com/fr/plugin/db/redis/core/RedisTableData.java
  5. 6
      src/main/java/com/fr/plugin/db/redis/core/RedisTableDataModel.java
  6. 1
      src/main/java/com/fr/plugin/db/redis/core/pool/RedisConnectionPoolConfig.java
  7. 4
      src/main/java/com/fr/plugin/db/redis/help/Files.java
  8. 1
      src/main/java/com/fr/plugin/db/redis/ui/RedisBaseTableDataPane.java
  9. 4
      src/main/java/com/fr/plugin/db/redis/ui/RedisQueryPane.java
  10. 4
      src/main/java/com/fr/plugin/db/redis/ui/RedisScriptTableDataPane.java
  11. 4
      src/main/java/com/fr/plugin/db/redis/ui/RedisTableDataPane.java
  12. 4
      src/main/java/com/fr/plugin/db/redis/ui/value/IntegerEditor.java

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

@ -6,6 +6,7 @@ import com.fanruan.api.util.IOKit;
import com.fanruan.api.script.ScriptKit; import com.fanruan.api.script.ScriptKit;
import com.fanruan.api.util.StringKit; import com.fanruan.api.util.StringKit;
import com.fr.workspace.WorkContext; import com.fr.workspace.WorkContext;
import com.fanruan.api.runtime.EnvKit;
import javax.script.ScriptEngine; import javax.script.ScriptEngine;
import javax.script.ScriptException; import javax.script.ScriptException;
@ -98,6 +99,6 @@ public class DataWrapper<T> {
} }
private String readAndRenderScriptFile(String filePath) { private String readAndRenderScriptFile(String filePath) {
return filePath.replaceFirst("\\$ENV_HOME", WorkContext.getCurrent().getPath()); return filePath.replaceFirst("\\$ENV_HOME", EnvKit.getCurrent().getPath());
} }
} }

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

@ -8,7 +8,7 @@ import com.fanruan.api.i18n.I18nKit;
import com.fr.plugin.db.redis.core.emb.Redis; import com.fr.plugin.db.redis.core.emb.Redis;
import com.fanruan.api.security.SecurityKit; import com.fanruan.api.security.SecurityKit;
import com.fanruan.api.util.ArrayKit; import com.fanruan.api.util.ArrayKit;
import com.fanruan.api.util.ReflectKit; import com.fanruan.api.util.TypeKit;
import com.fanruan.api.util.StringKit; import com.fanruan.api.util.StringKit;
import com.fr.stable.xml.XMLPrintWriter; import com.fr.stable.xml.XMLPrintWriter;
import com.fr.stable.xml.XMLableReader; import com.fr.stable.xml.XMLableReader;
@ -105,7 +105,7 @@ public class RedisDatabaseConnection extends AbstractDatabaseConnection {
@Override @Override
public void addConnection(List<String> list, String connectionName, Class<? extends Connection>[] acceptTypes) { public void addConnection(List<String> list, String connectionName, Class<? extends Connection>[] acceptTypes) {
for (Class<? extends com.fr.data.impl.Connection> accept : acceptTypes) { for (Class<? extends com.fr.data.impl.Connection> accept : acceptTypes) {
if (ReflectKit.classInstanceOf(getClass(), accept)) { if (TypeKit.classInstanceOf(getClass(), accept)) {
list.add(connectionName); list.add(connectionName);
break; break;
} }

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

@ -7,7 +7,7 @@ import com.fr.config.holder.factory.XmlHolders;
import com.fr.data.AbstractParameterTableData; import com.fr.data.AbstractParameterTableData;
import com.fanruan.api.xml.XmlKit; import com.fanruan.api.xml.XmlKit;
import com.fr.data.impl.Connection; import com.fr.data.impl.Connection;
import com.fanruan.api.database.nameDatabase.NameDatabaseConnection; import com.fanruan.api.database.nameDatabase.NameReference;
import com.fanruan.api.data.ConnectionKit; import com.fanruan.api.data.ConnectionKit;
import com.fr.general.data.DataModel; import com.fr.general.data.DataModel;
import com.fanruan.api.xml.XmlKit; import com.fanruan.api.xml.XmlKit;
@ -77,8 +77,8 @@ public class RedisScriptTableData extends AbstractParameterTableData {
long start = System.currentTimeMillis(); long start = System.currentTimeMillis();
Parameter[] ps = Parameter.providers2Parameter(getParameters(calculator)); Parameter[] ps = Parameter.providers2Parameter(getParameters(calculator));
Connection connection = database.get(); Connection connection = database.get();
if (connection instanceof NameDatabaseConnection) { if (connection instanceof NameReference) {
String name = ((NameDatabaseConnection) connection).getName(); String name = ((NameReference) connection).getName();
RedisDatabaseConnection rc = ConnectionKit.getConnection(name, RedisDatabaseConnection.class); RedisDatabaseConnection rc = ConnectionKit.getConnection(name, RedisDatabaseConnection.class);
if (rc != null) { if (rc != null) {
OrderValue orderValue = dbIndex.get(); OrderValue orderValue = dbIndex.get();

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

@ -7,7 +7,7 @@ import com.fr.config.holder.factory.XmlHolders;
import com.fr.data.AbstractParameterTableData; import com.fr.data.AbstractParameterTableData;
import com.fanruan.api.xml.XmlKit; import com.fanruan.api.xml.XmlKit;
import com.fr.data.impl.Connection; import com.fr.data.impl.Connection;
import com.fanruan.api.database.nameDatabase.NameDatabaseConnection; import com.fanruan.api.database.nameDatabase.NameReference;
import com.fanruan.api.data.ConnectionKit; import com.fanruan.api.data.ConnectionKit;
import com.fr.general.data.DataModel; import com.fr.general.data.DataModel;
import com.fanruan.api.xml.XmlKit; import com.fanruan.api.xml.XmlKit;
@ -87,8 +87,8 @@ public class RedisTableData extends AbstractParameterTableData {
long start = System.currentTimeMillis(); long start = System.currentTimeMillis();
Parameter[] ps = Parameter.providers2Parameter(getParameters(calculator)); Parameter[] ps = Parameter.providers2Parameter(getParameters(calculator));
Connection connection = database.get(); Connection connection = database.get();
if (connection instanceof NameDatabaseConnection) { if (connection instanceof NameReference) {
String name = ((NameDatabaseConnection) connection).getName(); String name = ((NameReference) connection).getName();
RedisDatabaseConnection rc = ConnectionKit.getConnection(name, RedisDatabaseConnection.class); RedisDatabaseConnection rc = ConnectionKit.getConnection(name, RedisDatabaseConnection.class);
if (rc != null) { if (rc != null) {
OrderValue orderValue = dbIndex.get(); OrderValue orderValue = dbIndex.get();

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

@ -3,8 +3,7 @@ package com.fr.plugin.db.redis.core;
import com.fr.stable.ParameterProvider; import com.fr.stable.ParameterProvider;
import com.fr.data.AbstractDataModel; import com.fr.data.AbstractDataModel;
import com.fanruan.api.log.LogKit; import com.fanruan.api.log.LogKit;
import com.fr.plugin.PluginLicense; import com.fanruan.api.runtime.PluginKit;
import com.fr.plugin.PluginLicenseManager;
import com.fr.plugin.db.redis.core.emb.Redis; import com.fr.plugin.db.redis.core.emb.Redis;
import com.fr.plugin.db.redis.core.visit.VisitorFactory; import com.fr.plugin.db.redis.core.visit.VisitorFactory;
import com.fr.plugin.db.redis.util.RedisUtils; import com.fr.plugin.db.redis.util.RedisUtils;
@ -19,8 +18,7 @@ public class RedisTableDataModel extends AbstractDataModel {
private List<List<Object>> data; private List<List<Object>> data;
public RedisTableDataModel(Calculator calculator, Parameter[] ps, RedisDatabaseConnection mc, int dbIndex, String query, String script, int rowCount) { public RedisTableDataModel(Calculator calculator, Parameter[] ps, RedisDatabaseConnection mc, int dbIndex, String query, String script, int rowCount) {
PluginLicense pluginLicense = PluginLicenseManager.getInstance().getPluginLicenseByID(RedisConstants.PLUGIN_ID); if (PluginKit.isCurrentPluginAvailable()) {
if (pluginLicense.isAvailable()) {
initRedisData(calculator, ps, mc, dbIndex, query, script, rowCount); initRedisData(calculator, ps, mc, dbIndex, query, script, rowCount);
} else { } else {
throw new RuntimeException("Redis Plugin License Expired!"); throw new RuntimeException("Redis Plugin License Expired!");

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

@ -5,7 +5,6 @@ import com.fanruan.api.conf.BaseConfiguration;
import com.fanruan.api.conf.HolderKit; import com.fanruan.api.conf.HolderKit;
import com.fr.config.holder.Conf; import com.fr.config.holder.Conf;
import javax.xml.ws.Holder;
/** /**
* @author richie * @author richie

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

@ -2,7 +2,7 @@ package com.fr.plugin.db.redis.help;
import com.eclipsesource.v8.V8; import com.eclipsesource.v8.V8;
import com.fanruan.api.util.IOKit; import com.fanruan.api.util.IOKit;
import com.fanruan.api.consts.EncodeConstantsKit; import com.fanruan.api.macro.EncodeConstants;
import java.io.InputStream; import java.io.InputStream;
import java.io.UnsupportedEncodingException; import java.io.UnsupportedEncodingException;
@ -25,7 +25,7 @@ public class Files {
InputStream in = IOKit.read(filePath); InputStream in = IOKit.read(filePath);
if (in != null) { if (in != null) {
try { try {
v8.executeVoidScript(IOKit.inputStream2String(in, EncodeConstantsKit.ENCODING_UTF_8)); v8.executeVoidScript(IOKit.inputStream2String(in, EncodeConstants.ENCODING_UTF_8));
} catch (UnsupportedEncodingException ignore) { } catch (UnsupportedEncodingException ignore) {
} }

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

@ -13,6 +13,7 @@ import com.fanruan.api.design.ui.component.table.UITableEditorPane;
import com.fanruan.api.design.ui.component.UIToolbar; import com.fanruan.api.design.ui.component.UIToolbar;
import com.fanruan.api.design.DesignKit; import com.fanruan.api.design.DesignKit;
import com.fr.design.menu.ToolBarDef; import com.fr.design.menu.ToolBarDef;
import com.fanruan.api.design.ui.toolbar.ToolBarDef;
import com.fr.plugin.db.redis.core.order.OrderValue; import com.fr.plugin.db.redis.core.order.OrderValue;
import com.fanruan.api.util.ArrayKit; import com.fanruan.api.util.ArrayKit;
import com.fr.stable.ParameterProvider; import com.fr.stable.ParameterProvider;

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

@ -12,7 +12,7 @@ import com.fr.design.gui.itextarea.DescriptionTextArea;
import com.fanruan.api.design.ui.component.code.UISyntaxTextArea; import com.fanruan.api.design.ui.component.code.UISyntaxTextArea;
import com.fanruan.api.design.ui.component.code.SyntaxConstants; import com.fanruan.api.design.ui.component.code.SyntaxConstants;
import com.fanruan.api.design.DesignKit; import com.fanruan.api.design.DesignKit;
import com.fr.general.SiteCenter; import com.fanruan.api.net.CloudKit;
import com.fr.plugin.db.redis.core.order.OrderValue; import com.fr.plugin.db.redis.core.order.OrderValue;
import com.fr.plugin.db.redis.ui.value.IndexValuePaneFactory; import com.fr.plugin.db.redis.ui.value.IndexValuePaneFactory;
import com.fr.plugin.db.redis.util.RedisDesignUtils; import com.fr.plugin.db.redis.util.RedisDesignUtils;
@ -44,7 +44,7 @@ public class RedisQueryPane extends BasicPane {
@Override @Override
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
try { try {
Desktop.getDesktop().browse(URI.create(SiteCenter.getInstance().acquireUrlByKind("help.redis"))); Desktop.getDesktop().browse(URI.create(CloudKit.acquireUrlByKind("help.redis")));
} catch (IOException e1) { } catch (IOException e1) {
LogKit.error(e1.getMessage(), e1); LogKit.error(e1.getMessage(), e1);
} }

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

@ -1,6 +1,6 @@
package com.fr.plugin.db.redis.ui; package com.fr.plugin.db.redis.ui;
import com.fanruan.api.database.nameDatabase.NameDatabaseConnection; import com.fanruan.api.database.nameDatabase.NameReference;
import com.fr.plugin.db.redis.core.RedisScriptTableData; import com.fr.plugin.db.redis.core.RedisScriptTableData;
import com.fr.plugin.db.redis.core.order.OrderValue; import com.fr.plugin.db.redis.core.order.OrderValue;
import com.fr.script.Calculator; import com.fr.script.Calculator;
@ -62,7 +62,7 @@ public class RedisScriptTableDataPane extends RedisBaseTableDataPane<RedisScript
RedisScriptTableData tableData = new RedisScriptTableData(); RedisScriptTableData tableData = new RedisScriptTableData();
String connectionName = chosePane.getSelectRedisConnectionName(); String connectionName = chosePane.getSelectRedisConnectionName();
if (StringKit.isNotEmpty(connectionName)) { if (StringKit.isNotEmpty(connectionName)) {
tableData.setDatabase(new NameDatabaseConnection(connectionName)); tableData.setDatabase(new NameReference(connectionName));
} }
List<ParameterProvider> parameterList = editorPane.update(); List<ParameterProvider> parameterList = editorPane.update();
ParameterProvider[] parameters = parameterList.toArray(new ParameterProvider[parameterList.size()]); ParameterProvider[] parameters = parameterList.toArray(new ParameterProvider[parameterList.size()]);

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

@ -1,7 +1,7 @@
package com.fr.plugin.db.redis.ui; package com.fr.plugin.db.redis.ui;
import com.fanruan.api.design.DesignKit; import com.fanruan.api.design.DesignKit;
import com.fanruan.api.database.nameDatabase.NameDatabaseConnection; import com.fanruan.api.database.nameDatabase.NameReference;
import com.fr.plugin.db.redis.core.RedisTableData; import com.fr.plugin.db.redis.core.RedisTableData;
import com.fr.plugin.db.redis.core.order.OrderValue; import com.fr.plugin.db.redis.core.order.OrderValue;
import com.fr.script.Calculator; import com.fr.script.Calculator;
@ -69,7 +69,7 @@ public class RedisTableDataPane extends RedisBaseTableDataPane<RedisTableData> {
String connectionName = chosePane.getSelectRedisConnectionName(); String connectionName = chosePane.getSelectRedisConnectionName();
if (StringKit.isNotEmpty(connectionName)) { if (StringKit.isNotEmpty(connectionName)) {
tableData.setDatabase(new NameDatabaseConnection(connectionName)); tableData.setDatabase(new NameReference(connectionName));
} }
List<ParameterProvider> parameterList = editorPane.update(); List<ParameterProvider> parameterList = editorPane.update();

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

@ -6,7 +6,7 @@ import com.fanruan.api.design.ui.component.UIIntNumberField;
import com.fanruan.api.design.ui.component.UITextField; import com.fanruan.api.design.ui.component.UITextField;
import com.fanruan.api.design.util.GUICoreKit; import com.fanruan.api.design.util.GUICoreKit;
import com.fr.plugin.db.redis.core.order.impl.NumberOrderValue; import com.fr.plugin.db.redis.core.order.impl.NumberOrderValue;
import com.fr.stable.StringUtils; import com.fanruan.api.util.StringKit;
import java.awt.*; import java.awt.*;
import java.awt.event.KeyAdapter; import java.awt.event.KeyAdapter;
@ -19,7 +19,7 @@ public class IntegerEditor extends Editor<NumberOrderValue> {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
protected UIIntNumberField numberField; // text field. protected UIIntNumberField numberField; // text field.
protected String oldValue = StringUtils.EMPTY; protected String oldValue = StringKit.EMPTY;
/** /**
* Constructor. * Constructor.

Loading…
Cancel
Save