forked from fanruan/demo-tabledata-redis
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
76 lines
2.2 KiB
76 lines
2.2 KiB
package com.fr.plugin.db.redis.ui; |
|
|
|
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.fanruan.api.util.StringKit; |
|
|
|
import javax.swing.*; |
|
import java.util.List; |
|
|
|
/** |
|
* @author richie |
|
* @version 10.0 |
|
* Created by richie on 2019-03-18 |
|
*/ |
|
public class RedisScriptTableDataPane extends RedisBaseTableDataPane<RedisScriptTableData> { |
|
|
|
private RedisScriptPane scriptPane; |
|
|
|
public RedisScriptTableDataPane() { |
|
super(); |
|
} |
|
|
|
@Override |
|
protected JComponent createQueryPane() { |
|
if (scriptPane == null) { |
|
scriptPane = new RedisScriptPane(); |
|
} |
|
return scriptPane; |
|
} |
|
|
|
@Override |
|
protected String[] paramTexts() { |
|
return new String[] {scriptPane.getScript()}; |
|
} |
|
|
|
@Override |
|
public OrderValue getOrderValue() { |
|
return scriptPane.getOrderValue(); |
|
} |
|
|
|
@Override |
|
public void populateBean(RedisScriptTableData tableData) { |
|
if (tableData == null) { |
|
return; |
|
} |
|
Calculator c = Calculator.createCalculator(); |
|
|
|
editorPane.populate(tableData.getParameters(c)); |
|
|
|
chosePane.populateConnection(tableData.getDatabase()); |
|
|
|
scriptPane.setScript(tableData.getScript()); |
|
|
|
scriptPane.setOrderValue(tableData.getOrderValue()); |
|
} |
|
|
|
@Override |
|
public RedisScriptTableData updateBean() { |
|
RedisScriptTableData tableData = new RedisScriptTableData(); |
|
String connectionName = chosePane.getSelectRedisConnectionName(); |
|
if (StringKit.isNotEmpty(connectionName)) { |
|
tableData.setDatabase(new NameDatabaseConnection(connectionName)); |
|
} |
|
List<ParameterProvider> parameterList = editorPane.update(); |
|
ParameterProvider[] parameters = parameterList.toArray(new ParameterProvider[parameterList.size()]); |
|
tableData.setParameters(parameters); |
|
|
|
tableData.setScript(scriptPane.getScript()); |
|
tableData.setOrderValue(scriptPane.getOrderValue()); |
|
|
|
return tableData; |
|
} |
|
}
|
|
|