|
|
|
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
|
|
|
|
* @version 10.0
|
|
|
|
* Created by richie on 2019-03-18
|
|
|
|
*/
|
|
|
|
public class RedisScriptPane extends BasicPane {
|
|
|
|
|
|
|
|
private ValueEditorPane dbIndexEditor;
|
|
|
|
private UIDictionaryComboBox<EngineType> engineTypeComboBox;
|
|
|
|
private UISyntaxTextArea scriptTextPane;
|
|
|
|
|
|
|
|
public RedisScriptPane() {
|
|
|
|
|
|
|
|
setLayout(new BorderLayout());
|
|
|
|
|
|
|
|
scriptTextPane = new UISyntaxTextArea();
|
|
|
|
|
|
|
|
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, 300)},
|
|
|
|
};
|
|
|
|
|
|
|
|
double p = TableLayoutKit.PREFERRED;
|
|
|
|
double f = TableLayoutKit.FILL;
|
|
|
|
|
|
|
|
double[] rowSize = {p, p, p, p};
|
|
|
|
double[] columnSize = {p, f};
|
|
|
|
|
|
|
|
add(TableLayoutKit.createTableLayoutPane(coms, rowSize, columnSize));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
protected String title4PopupWindow() {
|
|
|
|
return "Script";
|
|
|
|
}
|
|
|
|
|
|
|
|
public OrderValue getOrderValue() {
|
|
|
|
return (OrderValue) dbIndexEditor.update();
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setOrderValue(OrderValue orderValue) {
|
|
|
|
dbIndexEditor.populate(orderValue);
|
|
|
|
}
|
|
|
|
|
|
|
|
public EngineType getEngineType() {
|
|
|
|
return engineTypeComboBox.getSelectedItem();
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setEngineType(EngineType engineType) {
|
|
|
|
this.engineTypeComboBox.setSelectedItem(engineType);
|
|
|
|
}
|
|
|
|
|
|
|
|
public String getScript() {
|
|
|
|
return scriptTextPane.getText();
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setScript(String script) {
|
|
|
|
scriptTextPane.setText(script);
|
|
|
|
}
|
|
|
|
}
|