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.
110 lines
3.6 KiB
110 lines
3.6 KiB
package com.fr.plugin.db.redis.ui; |
|
|
|
import com.fanruan.api.design.ui.container.BasicPane; |
|
import com.fanruan.api.layout.LayoutKit; |
|
import com.fanruan.api.design.DesignKit; |
|
import com.fanruan.api.log.LogKit; |
|
import com.fr.design.data.datapane.sqlpane.SQLEditPane; |
|
import com.fr.design.editor.ValueEditorPane; |
|
import com.fr.design.gui.ilable.ActionLabel; |
|
import com.fr.design.gui.ilable.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.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; |
|
|
|
import java.awt.*; |
|
import java.awt.event.ActionEvent; |
|
import java.awt.event.ActionListener; |
|
import java.io.IOException; |
|
import java.net.URI; |
|
|
|
|
|
public class RedisQueryPane extends BasicPane { |
|
|
|
private SQLEditPane sqlTextPane; |
|
private ValueEditorPane dbIndexEditor; |
|
private RSyntaxTextArea scriptTextPane; |
|
|
|
public RedisQueryPane() { |
|
setLayout(new BorderLayout()); |
|
|
|
sqlTextPane = new SQLEditPane(); |
|
|
|
scriptTextPane = new RSyntaxTextArea(); |
|
|
|
dbIndexEditor = IndexValuePaneFactory.createValueEditorPane(); |
|
|
|
ActionLabel helpLabel = new ActionLabel(Toolkit.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) { |
|
LogKit.error(e1.getMessage(), e1); |
|
} |
|
} |
|
}); |
|
|
|
DescriptionTextArea descriptionArea = new DescriptionTextArea(); |
|
descriptionArea.setWrapStyleWord(true); |
|
descriptionArea.setLineWrap(true); |
|
|
|
descriptionArea.setText(Toolkit.i18nText("Plugin-Redis_Script_Text_Description")); |
|
|
|
Component[][] coms = new Component[][]{ |
|
{new UILabel(Toolkit.i18nText("Plugin-Redis_DB_Index") + ":"), dbIndexEditor}, |
|
{DesignKit.createBorderLayoutPane(new UILabel(Toolkit.i18nText("Plugin-Redis_Query_Condition") + ":"), BorderLayout.NORTH), |
|
RedisDesignUtils.createConditionTextPane(sqlTextPane, SyntaxConstants.SYNTAX_STYLE_SQL, 300)} |
|
}; |
|
|
|
// {GUICoreUtils.createBorderLayoutPane(new UILabel(Toolkit.i18nText("Plugin-Redis_Script_Text") + ":"), BorderLayout.NORTH), |
|
// RedisDesignUtils.createConditionTextPane(scriptTextPane, SyntaxConstants.SYNTAX_STYLE_JAVASCRIPT, 200) |
|
// } |
|
|
|
double p = LayoutKit.PREFERRED; |
|
double f = LayoutKit.FILL; |
|
|
|
double[] rowSize = {p, p}; |
|
double[] columnSize = {p, f}; |
|
|
|
add(DesignKit.createTableLayoutPane(coms, rowSize, columnSize)); |
|
} |
|
|
|
|
|
|
|
@Override |
|
protected String title4PopupWindow() { |
|
return "Query"; |
|
} |
|
|
|
public String getQuery() { |
|
return sqlTextPane.getText(); |
|
} |
|
|
|
public void setQuery(String query) { |
|
sqlTextPane.setText(query); |
|
} |
|
|
|
public OrderValue getOrderValue() { |
|
return (OrderValue) dbIndexEditor.update(); |
|
} |
|
|
|
public void setOrderValue(OrderValue orderValue) { |
|
dbIndexEditor.populate(orderValue); |
|
} |
|
|
|
public String getScript() { |
|
return scriptTextPane.getText(); |
|
} |
|
|
|
public void setScript(String script) { |
|
scriptTextPane.setText(script); |
|
} |
|
} |