JSD-4334 GIS地图集成
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.
 
 

300 lines
14 KiB

package com.fr.plugin.shdcmap.ui;
import com.fr.design.beans.BasicBeanPane;
import com.fr.design.dialog.BasicPane;
import com.fr.design.gui.icheckbox.UICheckBox;
import com.fr.design.gui.icontainer.UIScrollPane;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.gui.ispinner.UISpinner;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.layout.TableLayout;
import com.fr.design.layout.TableLayoutHelper;
import com.fr.design.scrollruler.ModLineBorder;
import com.fr.design.style.color.ColorSelectBox;
import com.fr.stable.StringUtils;
import javax.swing.*;
import javax.swing.border.Border;
import javax.swing.border.MatteBorder;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import javax.swing.plaf.ColorUIResource;
import java.awt.*;
import java.util.HashMap;
import java.util.Map;
/**
* @author duan.jingliang
* @create 2019/9/6
* 设计器配置界面
* 配置父格关系、公式关系、死循环关系的功能开关,及样式配置。
*/
public class RelationSettingPane extends BasicBeanPane<String> {
private static final ColorUIResource BORDER_COLOR = new ColorUIResource(168, 172, 180);
private static final Border TIP_BORDER = BorderFactory.createEmptyBorder(10, 4, 4, 4);
private static final Border DIALOG_BORDER = BorderFactory.createEmptyBorder(0, 6, 4, 6);
private static final Border INNER_LEFT_BORDER = BorderFactory.createEmptyBorder(15, 35, 15, 0);
private UICheckBox formulaCheckBox = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Relation_Setting_Formula"), true);
private UICheckBox parentCheckBox = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Relation_Setting_Parent"), true);
private UICheckBox leftParentCheckBox = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Relation_Setting_Left_Parent"), true);
private UICheckBox topParentCheckBox = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Relation_Setting_Top_Paren"), true);
private UISpinner parentCount = new UISpinner(1, 20, 1, 5);
private final double p = TableLayout.PREFERRED;
private final double f = TableLayout.FILL;
private final String checkedValue = "1";
private final String uncheckedValue = "0";
private ColorSelectBox parentBgColor = new ColorSelectBox(100);
private ColorSelectBox parentTextColor = new ColorSelectBox(100);;
private ColorSelectBox formulaBgColor = new ColorSelectBox(100);
private ColorSelectBox formulaTextColor = new ColorSelectBox(100);
private UICheckBox endlessLoopCheckBox = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Relation_Setting_Endless_Loop"), true);
private ColorSelectBox endlessLoopColor = new ColorSelectBox(100);
public RelationSettingPane() {
setLayout(FRGUIPaneFactory.createBorderLayout());
UILabel titleLabel = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Relation_Setting_Explain"));
titleLabel.setBorder(TIP_BORDER);
add(titleLabel, "North");
UIScrollPane detailScrollPane = new UIScrollPane(initDetailPane());
detailScrollPane.setBorder(new MatteBorder(1, 1, 1, 1, BORDER_COLOR));
add(detailScrollPane, "Center");
setBorder(DIALOG_BORDER);
checkEndlessEnabled();
}
@Override
public void populateBean(String o) {
}
@Override
public String updateBean() {
return "hello";
}
private JPanel initDetailPane() {
UILabel outerBorder = new UILabel("");
outerBorder.setBorder(INNER_LEFT_BORDER);
// 父格关系设置面板
JPanel parentSettingPanel = FRGUIPaneFactory.createNColumnGridInnerContainer_S_Pane(1);
parentSettingPanel.setBorder(BorderFactory.createTitledBorder(new ModLineBorder(1), com.fr.design.i18n.Toolkit.i18nText("Relation_Setting_Parent_Group")));
JPanel parentSettingCompsPanel = getParentSettingCompsPanel();
parentSettingCompsPanel.setBorder(INNER_LEFT_BORDER);
parentSettingPanel.add(parentSettingCompsPanel);
// 公式关系设置面板
JPanel formulaSettingPanel = FRGUIPaneFactory.createNColumnGridInnerContainer_Pane(1, 2, 2);
formulaSettingPanel.setBorder(BorderFactory.createTitledBorder(new ModLineBorder(1), com.fr.design.i18n.Toolkit.i18nText("Relation_Setting_Formula_Group")));
JPanel formulaSettingCompsPanel = getFormulaSettingCompsPanel();
formulaSettingCompsPanel.setBorder(INNER_LEFT_BORDER);
formulaSettingPanel.add(formulaSettingCompsPanel);
// 死循环设置面板
JPanel endlessLoopSettingPanel = FRGUIPaneFactory.createNColumnGridInnerContainer_Pane(1, 2, 2);
endlessLoopSettingPanel.setBorder(BorderFactory.createTitledBorder(new ModLineBorder(1), com.fr.design.i18n.Toolkit.i18nText("Relation_Setting_EndlessLoop_Group")));
JPanel endlessLoopSettingCompsPanel = getEndlessLoopSettingCompsPanel();
endlessLoopSettingCompsPanel.setBorder(INNER_LEFT_BORDER);
endlessLoopSettingPanel.add(endlessLoopSettingCompsPanel);
Component[][] arrayOfComponent = {{outerBorder}, {parentSettingPanel}, {formulaSettingPanel}, {endlessLoopSettingPanel}};
return TableLayoutHelper.createGapTableLayoutPane(arrayOfComponent, new double[]{p, p, p, p}, new double[]{p},1.0D, 1.0D);
}
protected JPanel getParentSettingCompsPanel() {
//this.parentCount.setValue(Integer.valueOf(RelationSetting.getInstance().getParentCount()));
if (uncheckedValue.equals(0)) {
this.parentCheckBox.setSelected(false);
this.parentCount.setEnabled(false);
this.leftParentCheckBox.setSelected(false);
this.leftParentCheckBox.setEnabled(false);
this.topParentCheckBox.setSelected(false);
this.topParentCheckBox.setEnabled(false);
}
String parentBgColorStr = ""; //RelationSetting.getInstance().get("parentBgColor");
String parentTextColorStr = ""; //RelationSetting.getInstance().get("parentTextColor");
if (StringUtils.isNotEmpty(parentBgColorStr)) {
this.parentBgColor.setSelectObject(MapUtil.toColor(parentBgColorStr));
} else {
this.parentBgColor.setSelectObject(MapUtil.toColor("#00ccff"));
}
if (StringUtils.isNotEmpty(parentTextColorStr)) {
this.parentTextColor.setSelectObject(MapUtil.toColor(parentTextColorStr));
} else {
this.parentTextColor.setSelectObject(MapUtil.toColor("#ffffff"));
}
this.parentCheckBox.addChangeListener(new ChangeListener() {
@Override
public void stateChanged(ChangeEvent paramAnonymousChangeEvent) {
if (RelationSettingPane.this.parentCheckBox.isSelected()) {
RelationSettingPane.this.parentCount.setEnabled(true);
RelationSettingPane.this.leftParentCheckBox.setEnabled(true);
RelationSettingPane.this.topParentCheckBox.setEnabled(true);
} else {
RelationSettingPane.this.parentCount.setEnabled(false);
RelationSettingPane.this.leftParentCheckBox.setSelected(false);
RelationSettingPane.this.leftParentCheckBox.setEnabled(false);
RelationSettingPane.this.topParentCheckBox.setSelected(false);
RelationSettingPane.this.topParentCheckBox.setEnabled(false);
}
RelationSettingPane.this.checkEndlessEnabled();
}
});
Component[][] settingComps = {
{this.parentCheckBox, null},
{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Relation_Setting_ParentCount") + ":", 4), this.parentCount},
{this.leftParentCheckBox, this.topParentCheckBox}
};
JPanel settingPane = TableLayoutHelper.createGapTableLayoutPane(settingComps, new double[]{p, p, p}, new double[]{p, p}, 6.0D, 6.0D);
Component[][] styleComps = new Component[][]{
new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Relation_Setting_ParentStyle_BgColor")),
this.parentBgColor,
new UILabel(com.fr.design.i18n.Toolkit.i18nText("Relation_Setting_ParentStyle_TextColor")),
this.parentTextColor
}
};
JPanel stylePane = TableLayoutHelper.createGapTableLayoutPane(styleComps, new double[]{p}, new double[]{p, p, p, p}, 6.0D, 6.0D);
Component[][] comps = new Component[][]{
{settingPane},
{stylePane}
};
return TableLayoutHelper.createGapTableLayoutPane(comps, new double[]{p, p}, new double[]{p}, 6.0D, 6.0D);
}
private JPanel getFormulaSettingCompsPanel() {
String formulaBgColorStr = ""; // = RelationSetting.getInstance().get("formulaBgColor");
if (StringUtils.isNotEmpty(formulaBgColorStr)) {
this.formulaBgColor.setSelectObject(MapUtil.toColor(formulaBgColorStr));
} else {
this.formulaBgColor.setSelectObject(MapUtil.toColor("#00ccff"));
}
String formulaTextColorStr = ""; //RelationSetting.getInstance().get("formulaTextColor");
if (StringUtils.isNotEmpty(formulaTextColorStr)) {
this.formulaTextColor.setSelectObject(MapUtil.toColor(formulaTextColorStr));
} else {
this.formulaTextColor.setSelectObject(MapUtil.toColor("#ffffff"));
}
this.formulaCheckBox.addChangeListener(new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
RelationSettingPane.this.checkEndlessEnabled();
}
});
Component[][] settingComps = new Component[][]{
new Component[]{this.formulaCheckBox, null}
};
JPanel settingPane = TableLayoutHelper.createGapTableLayoutPane(settingComps, new double[]{p}, new double[]{p, p}, 6.0D, 6.0D);
Component[][] styleComps = new Component[][]{
new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Relation_Setting_ParentStyle_BgColor")),
this.formulaBgColor,
new UILabel(com.fr.design.i18n.Toolkit.i18nText("Relation_Setting_ParentStyle_TextColor")),
this.formulaTextColor
}
};
JPanel stylePane = TableLayoutHelper.createGapTableLayoutPane(styleComps, new double[]{p}, new double[]{p, p, p, p}, 6.0D, 6.0D);
Component[][] comps = new Component[][]{
{settingPane},
{stylePane}
};
return TableLayoutHelper.createGapTableLayoutPane(comps, new double[]{p, p}, new double[]{p}, 6.0D, 6.0D);
}
private JPanel getEndlessLoopSettingCompsPanel() {
Component[][] components = new Component[][]{
new Component[]{this.endlessLoopCheckBox, null},
new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Relation_Setting_ParentStyle_EndLoopColor")), this.endlessLoopColor}
};
return TableLayoutHelper.createGapTableLayoutPane(components, new double[]{p, p}, new double[]{p, p}, 6.0D, 6.0D);
}
public void doWithProcess() {
//RelationSetting.getInstance().saveRelationSetting(getParentSwitch(), getLeftParentSwitch(), getTopParentSwitch(), getParentCount(), getFormulaSwitch());
Map<String, String> confMap = new HashMap(10);
confMap.put("parentBgColor", MapUtil.toHex(this.parentBgColor.getSelectObject()));
confMap.put("parentTextColor", MapUtil.toHex(this.parentTextColor.getSelectObject()));
confMap.put("formulaBgColor", MapUtil.toHex(this.formulaBgColor.getSelectObject()));
confMap.put("formulaTextColor", MapUtil.toHex(this.formulaTextColor.getSelectObject()));
confMap.put("endlessLoop", getEndlessLoopSwitch());
confMap.put("endlessLoopColor", MapUtil.toHex(this.endlessLoopColor.getSelectObject()));
//RelationSetting.getInstance().saveRelationSetting(confMap);
}
private void checkEndlessEnabled() {
if (!this.parentCheckBox.isSelected() && !this.formulaCheckBox.isSelected()) {
this.endlessLoopCheckBox.setEnabled(false);
this.endlessLoopColor.setEnabled(false);
} else {
this.endlessLoopCheckBox.setEnabled(true);
this.endlessLoopColor.setEnabled(true);
}
}
private String getEndlessLoopSwitch() {
String str = "0";
if (this.endlessLoopCheckBox.isSelected()) {
str = "1";
}
return str;
}
private int getParentCount() {
Double countDouble = this.parentCount.getValue();
return countDouble.intValue();
}
private String getParentSwitch() {
String str = "0";
boolean isOpenSwitch = (this.parentCheckBox.isSelected()) && ((this.topParentCheckBox.isSelected()) || (this.leftParentCheckBox.isSelected()));
if (isOpenSwitch) {
str = "1";
}
return str;
}
private String getTopParentSwitch() {
String str = "0";
if (this.topParentCheckBox.isSelected()) {
str = "1";
}
return str;
}
private String getLeftParentSwitch() {
String str = "0";
if (this.leftParentCheckBox.isSelected()) {
str = "1";
}
return str;
}
private String getFormulaSwitch() {
String str = "0";
if (this.formulaCheckBox.isSelected()) {
str = "1";
}
return str;
}
@Override
protected String title4PopupWindow() {
return com.fr.design.i18n.Toolkit.i18nText("Relation_Setting_Name");
}
}