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.
94 lines
3.2 KiB
94 lines
3.2 KiB
7 years ago
|
package com.fr.plugin.db.redis.ui;
|
||
|
|
||
|
import com.fr.design.border.UIRoundedBorder;
|
||
|
import com.fr.design.constants.UIConstants;
|
||
|
import com.fr.design.data.datapane.sqlpane.SQLEditPane;
|
||
|
import com.fr.design.dialog.BasicPane;
|
||
|
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.syntax.ui.rsyntaxtextarea.SyntaxConstants;
|
||
|
import com.fr.design.gui.syntax.ui.rtextarea.RTextScrollPane;
|
||
|
import com.fr.design.layout.TableLayout;
|
||
|
import com.fr.design.layout.TableLayoutHelper;
|
||
|
import com.fr.design.utils.gui.GUICoreUtils;
|
||
|
import com.fr.general.FRLogger;
|
||
|
import com.fr.general.Inter;
|
||
|
import com.fr.general.SiteCenter;
|
||
|
import com.fr.plugin.db.redis.core.order.OrderValue;
|
||
|
import com.fr.plugin.db.redis.ui.value.IndexValuePaneFactory;
|
||
|
|
||
|
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;
|
||
|
|
||
|
public RedisQueryPane() {
|
||
|
setLayout(new BorderLayout());
|
||
|
|
||
|
sqlTextPane = new SQLEditPane();
|
||
|
|
||
|
dbIndexEditor = IndexValuePaneFactory.createValueEditorPane();
|
||
|
|
||
|
ActionLabel helpLabel = new ActionLabel(Inter.getLocText("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) {
|
||
|
FRLogger.getLogger().error(e1.getMessage(), e1);
|
||
|
}
|
||
|
}
|
||
|
});
|
||
|
|
||
|
Component[][] coms = new Component[][]{
|
||
|
{new UILabel(Inter.getLocText("Plugin-Redis_DB_Index") + ":"), dbIndexEditor},
|
||
|
{GUICoreUtils.createBorderLayoutPane(new UILabel(Inter.getLocText("Plugin-Redis_Query_Condition") + ":"), BorderLayout.NORTH), createConditionTextPane(sqlTextPane)}
|
||
|
};
|
||
|
|
||
|
double p = TableLayout.PREFERRED;
|
||
|
double f = TableLayout.FILL;
|
||
|
|
||
|
double[] rowSize = {p, p};
|
||
|
double[] columnSize = {p, f};
|
||
|
|
||
|
add(TableLayoutHelper.createTableLayoutPane(coms, rowSize, columnSize));
|
||
|
}
|
||
|
|
||
|
private RTextScrollPane createConditionTextPane(SQLEditPane sqlTextPane) {
|
||
|
sqlTextPane.setSyntaxEditingStyle(SyntaxConstants.SYNTAX_STYLE_SQL);
|
||
|
RTextScrollPane sqlTextScrollPane = new RTextScrollPane(sqlTextPane);
|
||
|
sqlTextScrollPane.setBorder(new UIRoundedBorder(UIConstants.LINE_COLOR, 1, UIConstants.ARC));
|
||
|
sqlTextScrollPane.setPreferredSize(new Dimension(680, 300));
|
||
|
return sqlTextScrollPane;
|
||
|
}
|
||
|
|
||
|
@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);
|
||
|
}
|
||
|
}
|