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.
149 lines
5.2 KiB
149 lines
5.2 KiB
2 years ago
|
package com.fr.plugin.pielinecomb.ui;
|
||
|
|
||
|
import com.fr.design.gui.ibutton.UIButton;
|
||
|
import com.fr.design.gui.icombobox.UIComboBox;
|
||
|
import com.fr.design.gui.itextarea.UITextArea;
|
||
|
import com.fr.design.gui.itextfield.UITextField;
|
||
|
import com.fr.design.i18n.Toolkit;
|
||
|
import com.fr.design.layout.TableLayout;
|
||
|
import com.fr.design.layout.TableLayoutHelper;
|
||
|
import com.fr.json.JSONObject;
|
||
|
import com.fr.plugin.pielinecomb.vo.CustomJsonObject;
|
||
|
import com.fr.plugin.pielinecomb.vo.ItemLabelJson;
|
||
|
import com.fr.van.chart.designer.AbstractVanChartScrollPane;
|
||
|
import com.fr.van.chart.designer.TableLayout4VanChartHelper;
|
||
|
|
||
|
import javax.swing.*;
|
||
|
import java.awt.*;
|
||
|
import java.awt.event.ActionEvent;
|
||
|
import java.awt.event.ActionListener;
|
||
|
|
||
|
/**
|
||
|
* @author duan.jingliang
|
||
|
*/
|
||
|
public class PieLabelCondCreator extends AbstractVanChartScrollPane<CustomJsonObject> {
|
||
|
|
||
|
private UITextArea condition;
|
||
|
|
||
|
private PieLabelStylePane pieLabelStylePane;
|
||
|
|
||
|
|
||
|
@Override
|
||
|
protected JPanel createContentPane() {
|
||
|
return new ContentPane();
|
||
|
}
|
||
|
|
||
|
@Override
|
||
|
public void populateBean(CustomJsonObject json) {
|
||
|
JSONObject chartConf = null;
|
||
|
if (null != json) {
|
||
|
chartConf = json.get();
|
||
|
}
|
||
|
if (null != chartConf) {
|
||
|
this.pieLabelStylePane.populateBean(chartConf);
|
||
|
this.condition.setText(chartConf.getString("condition"));
|
||
|
}
|
||
|
}
|
||
|
|
||
|
@Override
|
||
|
public CustomJsonObject updateBean() {
|
||
|
JSONObject chartConf = JSONObject.create();
|
||
|
|
||
|
chartConf.put("condition", this.condition.getText());
|
||
|
|
||
|
JSONObject pieLabel = this.pieLabelStylePane.update();
|
||
|
chartConf.mergeIn(pieLabel);
|
||
|
|
||
|
ItemLabelJson json = new ItemLabelJson();
|
||
|
chartConf.put("title", json.getTilte());
|
||
|
json.put(chartConf);
|
||
|
|
||
|
return json;
|
||
|
}
|
||
|
|
||
|
@Override
|
||
|
protected String title4PopupWindow() {
|
||
|
return Toolkit.i18nText("Plugin-BmwGantt-Cond-condTaskBgTitle");
|
||
|
}
|
||
|
|
||
|
protected class ContentPane extends JPanel {
|
||
|
public ContentPane() {
|
||
|
initComponents();
|
||
|
}
|
||
|
|
||
|
private void initComponents() {
|
||
|
this.setLayout(new BorderLayout());
|
||
|
|
||
|
JPanel condPane = createConditionPane();
|
||
|
JPanel linePane = createLinePane();
|
||
|
|
||
|
double p = TableLayout.PREFERRED;
|
||
|
double f = TableLayout.FILL;
|
||
|
double[] columnSize = {f};
|
||
|
double[] rowSize = {p, p, p};
|
||
|
Component[][] acomponents = new Component[][]{
|
||
|
new Component[]{condPane},
|
||
|
new Component[]{linePane}
|
||
|
};
|
||
|
|
||
|
JPanel panel = TableLayoutHelper.createTableLayoutPane(acomponents, rowSize, columnSize);
|
||
|
this.add(panel, BorderLayout.CENTER);
|
||
|
this.setVisible(true);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
private JPanel createLinePane() {
|
||
|
this.pieLabelStylePane = new PieLabelStylePane();
|
||
|
return TableLayout4VanChartHelper.createExpandablePaneWithTitle(Toolkit.i18nText("Plugin-Pielinecomb-TitleStyle"), this.pieLabelStylePane);
|
||
|
}
|
||
|
|
||
|
private JPanel createConditionPane() {
|
||
|
condition = new UITextArea(3, 6);
|
||
|
final UITextField value = new UITextField();
|
||
|
final UIComboBox filed = new UIComboBox(new String[]{"分类名", "系列名", "数值"});
|
||
|
final UIComboBox cond = new UIComboBox(new String[]{"==", "!=", ">", ">=", "<", "<="});
|
||
|
|
||
|
UIButton add = new UIButton(Toolkit.i18nText("Plugin-Pielinecomb-Cond-AddCondtion"));
|
||
|
UIButton clear = new UIButton(Toolkit.i18nText("Plugin-Pielinecomb-Cond-clearButton"));
|
||
|
|
||
|
double p = TableLayout.PREFERRED;
|
||
|
double f = TableLayout.FILL;
|
||
|
Component[][] components = new Component[][]{
|
||
|
new Component[]{filed, cond, value, add, clear}
|
||
|
};
|
||
|
JPanel condPane = TableLayout4VanChartHelper.createGapTableLayoutPane(components, new double[]{p, p}, new double[]{p, p, f, p, p});
|
||
|
|
||
|
Component[][] comp1 = new Component[][]{
|
||
|
new Component[]{condition}
|
||
|
};
|
||
|
JPanel areaPane = TableLayout4VanChartHelper.createGapTableLayoutPane(comp1, new double[]{p}, new double[]{f});
|
||
|
|
||
|
Component[][] comp = new Component[][]{
|
||
|
new Component[]{condPane},
|
||
|
new Component[]{areaPane}
|
||
|
};
|
||
|
JPanel sumPane = TableLayout4VanChartHelper.createGapTableLayoutPane(comp, new double[]{p, p}, new double[]{f});
|
||
|
|
||
|
condition.setEnabled(false);
|
||
|
add.addActionListener(new ActionListener() {
|
||
|
@Override
|
||
|
public void actionPerformed(ActionEvent e) {
|
||
|
String srcStr = condition.getText();
|
||
|
if (null != srcStr && !"".equals(srcStr)) {
|
||
|
srcStr += " && ";
|
||
|
}
|
||
|
String condstr = "'{" + filed.getSelectedItem() + "}' " + cond.getSelectedItem() + " '" + value.getText() + "'";
|
||
|
condition.setText(srcStr + condstr);
|
||
|
}
|
||
|
});
|
||
|
clear.addActionListener(new ActionListener() {
|
||
|
@Override
|
||
|
public void actionPerformed(ActionEvent e) {
|
||
|
condition.setText("");
|
||
|
}
|
||
|
});
|
||
|
return TableLayout4VanChartHelper.createExpandablePaneWithTitle(Toolkit.i18nText("Plugin-Pielinecomb-condition"), sumPane);
|
||
|
}
|
||
|
|
||
|
}
|