|
|
|
@ -1,17 +1,27 @@
|
|
|
|
|
package com.fr.plugin.db.redis.ui; |
|
|
|
|
|
|
|
|
|
import com.fanruan.api.design.DesignKit; |
|
|
|
|
import com.fanruan.api.design.ui.component.UIButton; |
|
|
|
|
import com.fanruan.api.design.ui.component.UIDictionaryComboBox; |
|
|
|
|
import com.fanruan.api.design.ui.component.UILabel; |
|
|
|
|
import com.fanruan.api.design.ui.component.code.SyntaxConstants; |
|
|
|
|
import com.fanruan.api.design.ui.component.code.UISyntaxTextArea; |
|
|
|
|
import com.fanruan.api.design.ui.container.BasicPane; |
|
|
|
|
import com.fanruan.api.design.ui.editor.ValueEditorPane; |
|
|
|
|
import com.fanruan.api.design.ui.layout.TableLayoutKit; |
|
|
|
|
import com.fanruan.api.design.util.GUICoreKit; |
|
|
|
|
import com.fanruan.api.log.LogKit; |
|
|
|
|
import com.fanruan.api.util.IOKit; |
|
|
|
|
import com.fr.plugin.db.redis.core.order.OrderValue; |
|
|
|
|
import com.fr.plugin.db.redis.core.script.EngineType; |
|
|
|
|
import com.fr.plugin.db.redis.ui.value.IndexValuePaneFactory; |
|
|
|
|
import com.fr.plugin.db.redis.util.RedisDesignUtils; |
|
|
|
|
|
|
|
|
|
import java.awt.*; |
|
|
|
|
import java.awt.event.ActionEvent; |
|
|
|
|
import java.awt.event.ActionListener; |
|
|
|
|
import java.io.IOException; |
|
|
|
|
import java.net.URI; |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* @author richie |
|
|
|
@ -21,6 +31,7 @@ import java.awt.*;
|
|
|
|
|
public class RedisScriptPane extends BasicPane { |
|
|
|
|
|
|
|
|
|
private ValueEditorPane dbIndexEditor; |
|
|
|
|
private UIDictionaryComboBox<EngineType> engineTypeComboBox; |
|
|
|
|
private UISyntaxTextArea scriptTextPane; |
|
|
|
|
|
|
|
|
|
public RedisScriptPane() { |
|
|
|
@ -31,16 +42,41 @@ public class RedisScriptPane extends BasicPane {
|
|
|
|
|
|
|
|
|
|
dbIndexEditor = IndexValuePaneFactory.createValueEditorPane(); |
|
|
|
|
|
|
|
|
|
engineTypeComboBox = new UIDictionaryComboBox<EngineType>( |
|
|
|
|
new EngineType[]{ |
|
|
|
|
EngineType.V8, EngineType.JAVA |
|
|
|
|
}, |
|
|
|
|
new String[]{ |
|
|
|
|
DesignKit.i18nText("Plugin-Redis_Script_Engine_Type_V8"), |
|
|
|
|
DesignKit.i18nText("Plugin-Redis_Script_Engine_Type_Default") |
|
|
|
|
} |
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
UIButton helpButton = new UIButton(); |
|
|
|
|
helpButton.setIcon(IOKit.readIcon("/com/fr/plugin/db/redis/images/help.png")); |
|
|
|
|
helpButton.addActionListener(new ActionListener() { |
|
|
|
|
@Override |
|
|
|
|
public void actionPerformed(ActionEvent e) { |
|
|
|
|
try { |
|
|
|
|
Desktop.getDesktop().browse(URI.create("https://help.finereport.com/doc-view-1957.html")); |
|
|
|
|
} catch (IOException ex) { |
|
|
|
|
LogKit.error(ex.getMessage(), ex); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
Component[][] coms = new Component[][]{ |
|
|
|
|
{new UILabel(DesignKit.i18nText("Plugin-Redis_DB_Index") + ":"), dbIndexEditor}, |
|
|
|
|
{new UILabel(DesignKit.i18nText("Plugin-Redis_Script_Engine_Type") + ":"), |
|
|
|
|
GUICoreKit.createBorderLayoutPane(engineTypeComboBox, BorderLayout.CENTER, helpButton, BorderLayout.EAST)}, |
|
|
|
|
{new UILabel(DesignKit.i18nText("Plugin-Redis_Script_Query_Text") + ":"), |
|
|
|
|
RedisDesignUtils.createConditionTextPane(scriptTextPane, SyntaxConstants.SYNTAX_STYLE_JAVASCRIPT, 350)}, |
|
|
|
|
RedisDesignUtils.createConditionTextPane(scriptTextPane, SyntaxConstants.SYNTAX_STYLE_JAVASCRIPT, 300)}, |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
double p = TableLayoutKit.PREFERRED; |
|
|
|
|
double f = TableLayoutKit.FILL; |
|
|
|
|
|
|
|
|
|
double[] rowSize = {p, p, p}; |
|
|
|
|
double[] rowSize = {p, p, p, p}; |
|
|
|
|
double[] columnSize = {p, f}; |
|
|
|
|
|
|
|
|
|
add(TableLayoutKit.createTableLayoutPane(coms, rowSize, columnSize)); |
|
|
|
@ -60,6 +96,14 @@ public class RedisScriptPane extends BasicPane {
|
|
|
|
|
dbIndexEditor.populate(orderValue); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public EngineType getEngineType() { |
|
|
|
|
return engineTypeComboBox.getSelectedItem(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public void setEngineType(EngineType engineType) { |
|
|
|
|
this.engineTypeComboBox.setSelectedItem(engineType); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public String getScript() { |
|
|
|
|
return scriptTextPane.getText(); |
|
|
|
|
} |
|
|
|
|