From 90bd695b0d14afe31dfb79e4d25a50e6dd7e63c6 Mon Sep 17 00:00:00 2001 From: zheng Date: Thu, 11 Oct 2018 14:54:52 +0800 Subject: [PATCH 1/6] =?UTF-8?q?CHART-2982=20gis=E8=BD=AE=E6=92=AD=E5=9B=BE?= =?UTF-8?q?=20=E4=BF=AE=E6=94=B9typepane=20update=E6=97=B6=E5=80=99?= =?UTF-8?q?=E4=BC=9A=E6=9B=BF=E6=8D=A2=E9=BB=98=E8=AE=A4chart?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/fr/design/mainframe/chart/gui/ChartTypePane.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/ChartTypePane.java b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/ChartTypePane.java index e847f190c6..5f9dd9a15b 100644 --- a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/ChartTypePane.java +++ b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/ChartTypePane.java @@ -152,8 +152,9 @@ public class ChartTypePane extends AbstractChartAttrPane{ try{ Chart newDefaultChart = (Chart)((AbstractChartTypePane)getSelectedPane()).getDefaultChart().clone(); - if(!chart.accept(newDefaultChart.getClass())){ - //vanChart 和 chart 之间切换 + if (!ComparatorUtils.equals(chart.getClass(), newDefaultChart.getClass())) { + //vanChart 和 chart 之间切换 + //不同chart之间切换 editingCollection.removeNameObject(editingCollection.getSelectedIndex()); editingCollection.addChart(newDefaultChart); chart = newDefaultChart; From 3c9a20bd9e22fb5da318675540a13ad20eb7e6d5 Mon Sep 17 00:00:00 2001 From: "Mata.Li" Date: Fri, 12 Oct 2018 14:34:42 +0800 Subject: [PATCH 2/6] REPORT-11193 --- .../gui/icombocheckbox/UICheckListPopup.java | 234 +++++++++++++ .../gui/icombocheckbox/UIComboCheckBox.java | 330 ++++++++++++++++++ .../com/fr/design/icon/IconPathConstants.java | 4 + .../buttonicon/control_checkbox_normal.png | Bin 0 -> 164 bytes .../buttonicon/control_checkbox_part.png | Bin 0 -> 200 bytes .../buttonicon/control_checkbox_selected.png | Bin 0 -> 337 bytes 6 files changed, 568 insertions(+) create mode 100644 designer-base/src/main/java/com/fr/design/gui/icombocheckbox/UICheckListPopup.java create mode 100644 designer-base/src/main/java/com/fr/design/gui/icombocheckbox/UIComboCheckBox.java create mode 100644 designer-base/src/main/resources/com/fr/design/images/buttonicon/control_checkbox_normal.png create mode 100644 designer-base/src/main/resources/com/fr/design/images/buttonicon/control_checkbox_part.png create mode 100644 designer-base/src/main/resources/com/fr/design/images/buttonicon/control_checkbox_selected.png diff --git a/designer-base/src/main/java/com/fr/design/gui/icombocheckbox/UICheckListPopup.java b/designer-base/src/main/java/com/fr/design/gui/icombocheckbox/UICheckListPopup.java new file mode 100644 index 0000000000..2884e2279b --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/gui/icombocheckbox/UICheckListPopup.java @@ -0,0 +1,234 @@ +package com.fr.design.gui.icombocheckbox; + +import com.fr.base.BaseUtils; +import com.fr.design.constants.UIConstants; +import com.fr.design.gui.icontainer.UIScrollPane; +import com.fr.design.gui.ilable.UILabel; +import com.fr.design.gui.imenu.UIPopupMenu; +import com.fr.design.icon.IconPathConstants; +import com.fr.design.layout.FRGUIPaneFactory; + +import javax.swing.*; +import java.awt.*; +import java.awt.event.*; +import java.util.ArrayList; +import java.util.List; + +public class UICheckListPopup extends UIPopupMenu { + private List listeners = new ArrayList(); + private List checkBoxList = new ArrayList(); + + private Object[] values; + private JPanel checkboxPane; + private UIScrollPane jScrollPane; + private Color mouseEnteredColor = UIConstants.CHECKBOX_HOVER_SELECTED; + private int maxDisplayNumber = 8; + + public static final String COMMIT_EVENT = "commit"; + public static final String SELECT_ALL = com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Choose_All"); + private static final int CHECKBOX_HEIGHT = 25; + + public UICheckListPopup(Object[] value) { + super(); + values = value; + initComponent(); + } + + public void setMouseEnteredColor(Color color) { + this.mouseEnteredColor = color; + } + + public void setMaxDisplayNumber(int maxDisplayNumber) { + this.maxDisplayNumber = maxDisplayNumber; + //全选加在第一个位置 + addCheckboxValues(values); + } + + private void initComponent() { + checkboxPane = new JPanel(); + checkboxPane.setLayout(new GridLayout(checkBoxList.size(), 1, 0, 0)); + checkboxPane.setBackground(Color.WHITE); + jScrollPane = new UIScrollPane(checkboxPane); + + this.setLayout(new BorderLayout()); + this.add(jScrollPane, BorderLayout.CENTER); + + addCheckboxValues(values); + } + + public void addCheckboxValues(Object[] value) { + checkboxPane.removeAll(); + checkBoxList.clear(); + + //全选加在第一个位置 + addOneCheckValue(SELECT_ALL); + for (Object checkValue : value) { + addOneCheckValue(checkValue); + } + addSelectListener(); + + jScrollPane.setPreferredSize(new Dimension(200, checkBoxList.size() * CHECKBOX_HEIGHT + 10)); + //超过1页的数量时显示滚动条 + if (checkBoxList.size() > maxDisplayNumber) { + jScrollPane.setPreferredSize(new Dimension(200, maxDisplayNumber * CHECKBOX_HEIGHT)); + } + checkboxPane.repaint(); + jScrollPane.repaint(); + } + + private void addOneCheckValue(Object checkValue) { + JPanel checkPane = FRGUIPaneFactory.createNormalFlowInnerContainer_S_Pane(); + checkPane.setPreferredSize(new Dimension(185, CHECKBOX_HEIGHT)); + final JCheckBox temp = createCheckbox(); + final UILabel label = new UILabel(checkValue.toString()); + label.setBackground(Color.WHITE); + label.setPreferredSize(new Dimension(156, 20)); + checkPane.setBackground(Color.WHITE); + checkPane.add(temp); + checkPane.add(label); + addMouseListener(temp, label); + + checkBoxList.add(temp); + checkboxPane.add(checkPane); + } + + private JCheckBox createCheckbox() { + JCheckBox checkBox = new JCheckBox(); + checkBox.setPreferredSize(new Dimension(20, 20)); + checkBox.setBackground(Color.WHITE); + checkBox.setIcon(BaseUtils.readIcon(IconPathConstants.CHECKBOX_NORMAL)); + checkBox.setSelectedIcon(BaseUtils.readIcon(IconPathConstants.CHECKBOX_SELECTED)); + + return checkBox; + } + + /** + * 设置鼠标事件,鼠标进入时背景色变换 + * + * @param checkBox + * @param label + */ + private void addMouseListener(final JCheckBox checkBox, final UILabel label) { + label.addMouseListener(new MouseAdapter() { + public void mouseExited(MouseEvent e) { + label.setBackground(Color.WHITE); + } + + public void mouseEntered(MouseEvent e) { + label.setOpaque(true); + label.setBackground(mouseEnteredColor); + } + + @Override + public void mouseClicked(MouseEvent e) { + checkBox.doClick(); + } + }); + } + + /** + * 单选框选中事件 + */ + private void addSelectListener() { + for (int i = 0; i < checkBoxList.size(); i++) { + JCheckBox checkBox = checkBoxList.get(i); + if (i == 0) { + checkBox.addItemListener(new ItemListener() { + public void itemStateChanged(ItemEvent e) { + //全选checkbox事件 + doSelectAll(checkBoxList.get(0).isSelected()); + } + }); + } else { + checkBox.addItemListener(new ItemListener() { + public void itemStateChanged(ItemEvent e) { + //do半选判断放在commit事件里 + commit(); + } + }); + } + } + } + + /** + * 全选 + * + * @param isSelected 选中是true,未选是false + */ + private void doSelectAll(boolean isSelected) { + for (int i = 1; i < checkBoxList.size(); i++) { + //全选和反全选都不考虑全选按钮本身 + if (!SELECT_ALL.equals(checkBoxList.get(i).getText())) + checkBoxList.get(i).setSelected(isSelected); + } + } + + /** + * 获取所有选中的值 + * + * @return + */ + public Object[] getSelectedValues() { + List selectedValues = new ArrayList(); + int selectCount = 0; + + for (int i = 1; i < checkBoxList.size(); i++) { + if (checkBoxList.get(i).isSelected()) { + selectedValues.add(values[i - 1]); + selectCount++; + } + } + //全选半选切换 + switchSelectIcon(selectCount); + + return selectedValues.toArray(new Object[selectedValues.size()]); + } + + + /** + * 切换全选半选图片 + */ + private void switchSelectIcon(int selectCount) { + JCheckBox checkBox = checkBoxList.get(0); + if (selectCount == 0) { + checkBox.setIcon(BaseUtils.readIcon(IconPathConstants.CHECKBOX_NORMAL)); + } else if (selectCount < checkBoxList.size() - 1) { + //虽然有选中,但是要判断此时全选状态去换图标 + if (checkBoxList.get(0).isSelected()) { + checkBox.setSelectedIcon(BaseUtils.readIcon(IconPathConstants.CHECKBOX_HATFSELECT)); + } else { + checkBox.setIcon(BaseUtils.readIcon(IconPathConstants.CHECKBOX_HATFSELECT)); + } + } else { + //全选了,图标要换回来 + checkBox.setSelectedIcon(BaseUtils.readIcon(IconPathConstants.CHECKBOX_SELECTED)); + } + } + + public void commit() { + fireActionPerformed(new ActionEvent(this, 0, COMMIT_EVENT)); + } + + @Override + public Insets getInsets() { + return new Insets(0, 0, 0, 0); + } + + public void addActionListener(ActionListener listener) { + if (!listeners.contains(listener)) + listeners.add(listener); + } + + public void removeActionListener(ActionListener listener) { + if (listeners.contains(listener)) { + listeners.remove(listener); + } + } + + protected void fireActionPerformed(ActionEvent e) { + for (ActionListener l : listeners) { + l.actionPerformed(e); + } + } + +} diff --git a/designer-base/src/main/java/com/fr/design/gui/icombocheckbox/UIComboCheckBox.java b/designer-base/src/main/java/com/fr/design/gui/icombocheckbox/UIComboCheckBox.java new file mode 100644 index 0000000000..11cfeb6fe4 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/gui/icombocheckbox/UIComboCheckBox.java @@ -0,0 +1,330 @@ +package com.fr.design.gui.icombocheckbox; + +import com.fr.base.BaseUtils; +import com.fr.design.event.GlobalNameListener; +import com.fr.design.event.GlobalNameObserver; +import com.fr.design.event.UIObserver; +import com.fr.design.event.UIObserverListener; +import com.fr.design.gui.ibutton.UIButton; +import com.fr.design.gui.itextfield.UITextField; +import com.fr.design.icon.IconPathConstants; +import com.fr.design.layout.FRGUIPaneFactory; +import com.fr.stable.StringUtils; + +import javax.swing.*; +import java.awt.*; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; +import java.util.ArrayList; +import java.util.List; + +/** + * 设计器下拉复选框组件 + * 支持全选、半选 + * 可以设置悬停颜色、一页最多显示单选框个数 + * 可以省略显示 + */ +public class UIComboCheckBox extends JComponent implements UIObserver, GlobalNameObserver { + //下拉框的值 + private Object[] values; + //已经选中的值 + private Object[] selectedValues; + + private List listeners = new ArrayList(); + private UICheckListPopup popup; + private UITextField editor; + private UIButton arrowButton; + //选中的值之间显示的分隔符 + private String valueSperator; + private static final String DEFAULT_VALUE_SPERATOR = ","; + private static final String OMIT_TEXT = "..."; + + private UIObserverListener uiObserverListener; + private GlobalNameListener globalNameListener = null; + private String multiComboName = StringUtils.EMPTY; + private boolean showOmitText = true; + + public UIComboCheckBox(Object[] value) { + this(value, DEFAULT_VALUE_SPERATOR); + } + + /** + * 自定义分隔符的复选框 + * + * @param value + * @param valueSperator + */ + public UIComboCheckBox(Object[] value, String valueSperator) { + values = value; + this.valueSperator = valueSperator; + initComponent(); + } + + /** + * 设置鼠标悬停的背景色 + * + * @param color + */ + public void setCheckboxEnteredColor(Color color) { + this.popup.setMouseEnteredColor(color); + } + + /** + * 设置弹出框最多显示单选的个数,超过显示滚动条 + */ + public void setPopupMaxDisplayNumber(int maxDisplayNumber) { + this.popup.setMaxDisplayNumber(maxDisplayNumber); + } + + /** + * 是否要超过文本框长度后显示省略号 + * + * @param isShowOmitText + */ + public void isShowOmitText(boolean isShowOmitText) { + this.showOmitText = isShowOmitText; + } + + private void initComponent() { + this.setLayout(new FlowLayout(FlowLayout.LEFT, 0, 0)); + this.popup = new UICheckListPopup(values); + this.popup.addActionListener(new PopupAction()); + this.editor = createEditor(); + this.arrowButton = createArrowButton(); + this.add(editor); + this.add(arrowButton); + setText(); + } + + private UIButton createArrowButton() { + final UIButton arrowBtn = new UIButton(); + arrowBtn.setNormalPainted(false); + arrowBtn.setPreferredSize(new Dimension(20, 5)); + arrowBtn.setBackground(new Color(218, 218, 218)); + arrowBtn.setOpaque(true); + arrowBtn.setIcon(getIcon()); + arrowBtn.setExtraPainted(false); + addPopupListener(arrowBtn); + arrowBtn.addMouseListener(new MouseAdapter() { + @Override + public void mouseEntered(MouseEvent e) { + arrowBtn.setBackground(new Color(200, 200, 200)); + } + + @Override + public void mouseExited(MouseEvent e) { + arrowBtn.setBackground(new Color(218, 218, 218)); + } + }); + + return arrowBtn; + } + + private UITextField createEditor() { + UITextField editor = new UITextField(); + editor.setEditable(false); + editor.setPreferredSize(new Dimension(180, 20)); + addPopupListener(editor); + + return editor; + } + + /** + * 弹出框事件 + * + * @param component + */ + private void addPopupListener(Component component) { + component.addMouseListener(new MouseAdapter() { + public void mouseClicked(MouseEvent e) { + togglePopup(); + } + }); + + } + + /** + * 刷新复选框的列表值 + * + * @param value + */ + public void refreshCombo(Object[] value) { + this.values = value; + this.popup.addCheckboxValues(value); + } + + /** + * 获取复选框选中的值 + * + * @return 复选框选中的值 + */ + public Object[] getSelectedValues() { + return popup.getSelectedValues(); + } + + private class PopupAction implements ActionListener { + + public void actionPerformed(ActionEvent e) { + if (e.getActionCommand().equals(UICheckListPopup.COMMIT_EVENT)) { + selectedValues = popup.getSelectedValues(); + setText(); + //把事件继续传递出去 + fireActionPerformed(e); + } + } + } + + private void togglePopup() { + if (this.arrowButton.isEnabled()) { + popup.show(this, 0, getHeight()); + } + } + + /** + * 清除文本框 + */ + public void clearText() { + editor.setText(StringUtils.EMPTY); + } + + /** + * 获取文本框内容 + */ + public String getText() { + return editor.getText(); + } + + /** + * 文本框设置显示值 + */ + private void setText() { + StringBuilder builder = new StringBuilder(); + if (selectedValues != null) { + for (Object value : selectedValues) { + builder.append(value); + builder.append(valueSperator); + } + } + //去掉末尾多余的逗号 + String text = builder.length() > 0 ? builder.substring(0, builder.length() - 1) : StringUtils.EMPTY; + //计算加省略号后的文本 + editor.setText(this.showOmitText ? omitEditorText(editor, text) : text); + } + + /** + * 根据字体大小计算得到省略后的文字 + * + * @param textEditor + * @param text + * @return 省略后的文字 + */ + private static String omitEditorText(UITextField textEditor, String text) { + char[] omitChars = OMIT_TEXT.toCharArray(); + //获取字体的大小 + FontMetrics fontMetrics = textEditor.getFontMetrics(textEditor.getFont()); + //计算省略号的长度 + int omitLength = fontMetrics.charsWidth(omitChars, 0, omitChars.length); + String omitText = StringUtils.EMPTY; + char[] chars = text.toCharArray(); + + for (int i = 1; i <= chars.length; i++) { + //如果原文本+省略号长度超过文本框 + if (fontMetrics.charsWidth(chars, 0, i) + omitLength > textEditor.getPreferredSize().getWidth()) { + //从第i-1的位置截断再拼上省略号 + omitText = text.substring(0, i - 2) + OMIT_TEXT; + break; + } + } + + return omitText == StringUtils.EMPTY ? text : omitText; + } + + /** + * 给组件登记一个观察者监听事件 + * + * @param listener 观察者监听事件 + */ + @Override + public void registerChangeListener(UIObserverListener listener) { + this.uiObserverListener = listener; + } + + + @Override + public void setGlobalName(String name) { + multiComboName = name; + } + + /** + * 组件是否需要响应添加的观察者事件 + * + * @return 如果需要响应观察者事件则返回true,否则返回false + */ + @Override + public boolean shouldResponseChangeListener() { + return true; + } + + /** + * 注册观察者监听事件 + * + * @param listener 观察者监听事件 + */ + @Override + public void registerNameListener(GlobalNameListener listener) { + globalNameListener = listener; + } + + private Icon getIcon() { + return BaseUtils.readIcon(IconPathConstants.ARROW_ICON_PATH); + } + + /** + * 组件是否需要响应观察者事件 + * + * @return 如果需要响应观察者事件则返回true,否则返回false + */ + @Override + public boolean shouldResponseNameListener() { + return true; + } + + public void addActionListener(ActionListener listener) { + if (!listeners.contains(listener)) + listeners.add(listener); + } + + public void removeActionListener(ActionListener listener) { + if (listeners.contains(listener)) + listeners.remove(listener); + } + + protected void fireActionPerformed(ActionEvent e) { + for (ActionListener l : listeners) { + l.actionPerformed(e); + } + } + + /** + * 简单的测试demo + * @param args + */ + public static void main(String args[]) { + UIComboCheckBox comboBox = new UIComboCheckBox(new Object[] + {"MATA", "HANA", "KAKA", "KUKA", "INFI", "LILY", "RIBO", "CUBE", "MATA", "HANA", "KAKA", "KUKA"}); + + comboBox.isShowOmitText(false); + comboBox.setPopupMaxDisplayNumber(6); + + JPanel jPanel = FRGUIPaneFactory.createNormalFlowInnerContainer_S_Pane(); + jPanel.add(comboBox); + + JFrame jFrame = new JFrame(); + jFrame.setVisible(true); + jFrame.setSize(600, 400); + jFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + jFrame.add(jPanel, BorderLayout.CENTER); + } +} diff --git a/designer-base/src/main/java/com/fr/design/icon/IconPathConstants.java b/designer-base/src/main/java/com/fr/design/icon/IconPathConstants.java index 9a670fa4c6..e01aa5251a 100644 --- a/designer-base/src/main/java/com/fr/design/icon/IconPathConstants.java +++ b/designer-base/src/main/java/com/fr/design/icon/IconPathConstants.java @@ -33,4 +33,8 @@ public class IconPathConstants { public static final String XMLA_ICON_PATH = "/com/fr/design/images/data/cube.png"; public static final String FORBID_ICON_PATH = "/com/fr/web/images/form/forbid.png"; public static final String EDIT_ICON_PATH = "/com/fr/design/images/control/newEdit.png"; + public static final String ARROW_ICON_PATH = "com/fr/design/images/buttonicon/arrow.png"; + public static final String CHECKBOX_NORMAL = "com/fr/design/images/buttonicon/control_checkbox_normal.png"; + public static final String CHECKBOX_SELECTED = "com/fr/design/images/buttonicon/control_checkbox_selected.png"; + public static final String CHECKBOX_HATFSELECT = "com/fr/design/images/buttonicon/control_checkbox_part.png"; } diff --git a/designer-base/src/main/resources/com/fr/design/images/buttonicon/control_checkbox_normal.png b/designer-base/src/main/resources/com/fr/design/images/buttonicon/control_checkbox_normal.png new file mode 100644 index 0000000000000000000000000000000000000000..9aeac2db177320ba7cacae76f6a36852137c3fbe GIT binary patch literal 164 zcmeAS@N?(olHy`uVBq!ia0vp@Ak4uAB#T}@sR2@q#X;^)4C~IxyaaOMJY5_^G(?kQ zHYT+m{r~^}bHl6CrK78B`t<2j&Wyx_iXR^qKKuCi_;bU?90fP# z6D||1CRC|49ZL>0Sj8!&QNqI!aEalV$+Q~>M3`1GtE(1Wl4Ee_(q+>t-17`*6N9I# KpUXO@geCyEjX47V literal 0 HcmV?d00001 diff --git a/designer-base/src/main/resources/com/fr/design/images/buttonicon/control_checkbox_part.png b/designer-base/src/main/resources/com/fr/design/images/buttonicon/control_checkbox_part.png new file mode 100644 index 0000000000000000000000000000000000000000..10fff7cc1450e1c6cc2fd069610ad8e8c851d49c GIT binary patch literal 200 zcmeAS@N?(olHy`uVBq!ia0vp@Ak4uAB#T}@sR2@q#X;^)4C~IxyaaNZJY5_^G(?k2 zX8k_?`Tzd?nPx$3rR#lR45f=bej9e^Z&oUvlti{WPq3uc*4lUoW|%l`{!ezN@6s?41B^wj0R># z28I{|kWw&^fwN#D=rmA0Lzx{j!|_M|;Zg)O727g1JpatVaQ7XNnsO|d88k#085W=a z3%3QtfZJ4L!^|KjfRIZvW@hl$Vq)k#_?O`?!V<6o7MQYaH~%qA_h)68eflp0Co9n7 zhRh60FZ^Y={T59JPy<}kjo1GfcHjBOkY@!Ey8r$k!@_f@&VpG0cOFOpWXrp6{~7-N z`_Iq?bk?7LFlDGT+$NCl*Ix__(@y+lP!MEfxcLUtSum|2O;3Oro+9?$!(lv32T(l| jC@n!XB7||Xz-bQv)`(Bkjygt300000NkvXXu0mjfdP9u? literal 0 HcmV?d00001 From 85d7fb705c910b49916da3db89bf2d57d6ad2d70 Mon Sep 17 00:00:00 2001 From: "Mata.Li" Date: Fri, 12 Oct 2018 14:36:30 +0800 Subject: [PATCH 3/6] REPORT-11193 --- .../java/com/fr/design/gui/icombocheckbox/UICheckListPopup.java | 1 - 1 file changed, 1 deletion(-) diff --git a/designer-base/src/main/java/com/fr/design/gui/icombocheckbox/UICheckListPopup.java b/designer-base/src/main/java/com/fr/design/gui/icombocheckbox/UICheckListPopup.java index 2884e2279b..a0f4420743 100644 --- a/designer-base/src/main/java/com/fr/design/gui/icombocheckbox/UICheckListPopup.java +++ b/designer-base/src/main/java/com/fr/design/gui/icombocheckbox/UICheckListPopup.java @@ -40,7 +40,6 @@ public class UICheckListPopup extends UIPopupMenu { public void setMaxDisplayNumber(int maxDisplayNumber) { this.maxDisplayNumber = maxDisplayNumber; - //全选加在第一个位置 addCheckboxValues(values); } From e668acc1e88f84f1abd6f1f39aceef0fe81aafe0 Mon Sep 17 00:00:00 2001 From: "Wim.Zhai" Date: Sun, 14 Oct 2018 22:56:20 +0800 Subject: [PATCH 4/6] =?UTF-8?q?CHART-2808=20=E6=96=B0=E5=A2=9E=E4=B8=80?= =?UTF-8?q?=E6=96=B9=E6=B3=95=EF=BC=8C=E4=BF=AE=E6=94=B9=E5=8C=BA=E9=97=B4?= =?UTF-8?q?=E9=85=8D=E7=BD=AE=E5=A4=84=E9=BB=98=E8=AE=A4=E5=90=8D=E7=A7=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../component/SectionIntervalConfigPaneWithOutNum.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/designer-chart/src/main/java/com/fr/van/chart/range/component/SectionIntervalConfigPaneWithOutNum.java b/designer-chart/src/main/java/com/fr/van/chart/range/component/SectionIntervalConfigPaneWithOutNum.java index e8342aad5c..cad289f100 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/range/component/SectionIntervalConfigPaneWithOutNum.java +++ b/designer-chart/src/main/java/com/fr/van/chart/range/component/SectionIntervalConfigPaneWithOutNum.java @@ -3,6 +3,7 @@ package com.fr.van.chart.range.component; import com.fr.chart.chartglyph.MapHotAreaColor; import com.fr.design.gui.frpane.AbstractAttrNoScrollPane; import com.fr.design.gui.ilable.BoldFontTextLabel; +import com.fr.design.i18n.Toolkit; import com.fr.design.mainframe.chart.gui.style.series.MapColorPickerPaneWithFormula; import com.fr.van.chart.designer.TableLayout4VanChartHelper; @@ -19,6 +20,10 @@ import java.awt.Dimension; public class SectionIntervalConfigPaneWithOutNum extends MapColorPickerPaneWithFormula { private BoldFontTextLabel numLabel; + public String getNameOfSubRange() { + return Toolkit.i18nText("Fine-Design_Chart_Range_Num"); + } + public SectionIntervalConfigPaneWithOutNum(AbstractAttrNoScrollPane container) { super(container); getDesignTypeButtonGroup().addChangeListener(new ChangeListener() { @@ -49,12 +54,12 @@ public class SectionIntervalConfigPaneWithOutNum extends MapColorPickerPaneWithF @Override protected Component[][] createComponents() { - numLabel = new BoldFontTextLabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Value_Divided_Stage")); + numLabel = new BoldFontTextLabel(Toolkit.i18nText("Fine-Design_Chart_Value_Divided_Stage")); setRegionVisible(false); return new Component[][]{ - new Component[]{new BoldFontTextLabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Range_Num")), getDesignTypeButtonGroup()}, + new Component[]{new BoldFontTextLabel(getNameOfSubRange()), getDesignTypeButtonGroup()}, new Component[]{numLabel, getRegionNumPane()}, }; } From 80279fe9539c4dc8012a9a13062aec1abe22a45b Mon Sep 17 00:00:00 2001 From: "yaoh.wu" Date: Tue, 16 Oct 2018 10:53:58 +0800 Subject: [PATCH 5/6] =?UTF-8?q?REPORT-11690=20=E3=80=90=E9=9B=86=E7=BE=A4?= =?UTF-8?q?=E3=80=91=E3=80=90=E8=BF=9C=E7=A8=8B=E8=AE=BE=E8=AE=A1=E3=80=91?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=9C=8D=E5=8A=A1=E5=99=A8=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E9=9B=86=E5=BC=82=E5=B8=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../tabledatapane/DBTableDataPane.java | 682 +++++++++--------- 1 file changed, 349 insertions(+), 333 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/data/tabledata/tabledatapane/DBTableDataPane.java b/designer-base/src/main/java/com/fr/design/data/tabledata/tabledatapane/DBTableDataPane.java index 37ba914661..d441d51160 100644 --- a/designer-base/src/main/java/com/fr/design/data/tabledata/tabledatapane/DBTableDataPane.java +++ b/designer-base/src/main/java/com/fr/design/data/tabledata/tabledatapane/DBTableDataPane.java @@ -1,7 +1,6 @@ package com.fr.design.data.tabledata.tabledatapane; import com.fr.base.BaseUtils; -import com.fr.base.FRContext; import com.fr.base.Parameter; import com.fr.base.ParameterHelper; import com.fr.data.core.db.TableProcedure; @@ -35,17 +34,25 @@ import com.fr.design.menu.SeparatorDef; import com.fr.design.menu.ToolBarDef; import com.fr.design.utils.gui.GUICoreUtils; import com.fr.general.ComparatorUtils; - import com.fr.general.sql.SqlUtils; +import com.fr.log.FineLoggerFactory; import com.fr.script.Calculator; import com.fr.stable.ArrayUtils; import com.fr.stable.ParameterProvider; import com.fr.stable.StringUtils; -import javax.swing.*; +import javax.swing.BorderFactory; +import javax.swing.Box; +import javax.swing.BoxLayout; +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import javax.swing.JSplitPane; +import javax.swing.JToolBar; import javax.swing.text.BadLocationException; import javax.swing.text.Document; -import java.awt.*; +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.Dimension; import java.awt.event.ActionEvent; import java.awt.event.FocusEvent; import java.awt.event.FocusListener; @@ -53,334 +60,343 @@ import java.util.ArrayList; import java.util.List; public class DBTableDataPane extends AbstractTableDataPane { - private static final int BOTTOM = 6; - private static final String PREVIEW_BUTTON = com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Preview"); + private static final int BOTTOM = 6; + private static final String PREVIEW_BUTTON = com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Preview"); private static final String REFRESH_BUTTON = com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Refresh"); - private ConnectionTableProcedurePane connectionTableProcedurePane; - private UITableEditorPane editorPane; - - private DBTableDataMenuHandler dbTableDataMenuHandler; - private SQLEditPane sqlTextPane; - private UICheckBox isShareCheckBox; - private MaxMemRowCountPanel maxPanel; - private String pageQuery = null; - private DBTableData dbTableData; - - private void init() { - this.setLayout(new BorderLayout(4, 4)); - - sqlTextPane = new SQLEditPane(); - sqlTextPane.setSyntaxEditingStyle(SyntaxConstants.SYNTAX_STYLE_SQL); - - ParameterTableModel model = new ParameterTableModel() { - @Override - public UITableEditAction[] createAction() { - return (UITableEditAction[]) ArrayUtils.add(super.createDBTableAction(), new RefreshAction()); - } - }; - editorPane = new UITableEditorPane(model); - - // 左边的Panel,上面是选择DatabaseConnection的ComboBox,下面DatabaseConnection对应的Table - connectionTableProcedurePane = new ConnectionTableProcedurePane() { - @Override - protected void filter(Connection connection, String conName, List nameList) { - connection.addConnection(nameList, conName, new Class[]{JDBCDatabaseConnection.class, JNDIDatabaseConnection.class}); - } - }; - connectionTableProcedurePane.addDoubleClickListener(new DoubleClickSelectedNodeOnTreeListener() { - - @Override - public void actionPerformed(TableProcedure target) { - Document document = sqlTextPane.getDocument(); - try { - document.insertString(sqlTextPane.getCaretPosition(), target.toString(), null); - } catch (BadLocationException e) { - FRContext.getLogger().error(e.getMessage(), e); - } - // 这里开始作色,本来可以给sqlTextPane添加DocumentListener来实现的, - // 后来发现insertString的时候,锁定了JTextPane,不能调用setXXX来作色,先这样了. -// sqlTextPane.syntaxTexts(); - sqlTextPane.requestFocus(); - } - }); - sqlTextPane.addFocusListener(new FocusListener() { - public void focusGained(FocusEvent e) { - // unsupport - } - - public void focusLost(FocusEvent e) { - if (isPreviewOrRefreshButton(e)) { - checkParameter(); - } - } - }); - } - - - private void initMainSplitPane() { - Box box = new Box(BoxLayout.Y_AXIS); - - - JPanel northPane = new JPanel(new BorderLayout(4, 4)); - JToolBar editToolBar = createToolBar(); - northPane.add(editToolBar, BorderLayout.CENTER); - northPane.setBorder(BorderFactory.createEmptyBorder(0, 0, BOTTOM, 0)); - - RTextScrollPane sqlTextScrollPane = new RTextScrollPane(sqlTextPane); - sqlTextScrollPane.setLineNumbersEnabled(true); - sqlTextScrollPane.setBorder(new UIRoundedBorder(UIConstants.LINE_COLOR, 1, UIConstants.ARC)); - sqlTextScrollPane.setPreferredSize(new Dimension(680, 600)); - - JPanel paraMeanPane = new JPanel(new BorderLayout()); - paraMeanPane.setPreferredSize(new Dimension(680, 90)); - UILabel paraMean = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Datasource_Param_DES")); - paraMeanPane.add(paraMean, BorderLayout.CENTER); - - - box.add(northPane); - box.add(sqlTextScrollPane); - box.add(paraMeanPane); - box.add(editorPane); - - JPanel sqlSplitPane = new JPanel(new BorderLayout(4, 4)); - sqlSplitPane.add(box, BorderLayout.CENTER); - - - box.setMinimumSize(new Dimension(310, 400)); - // 使用SplitPane - JSplitPane mainSplitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, true, connectionTableProcedurePane, sqlSplitPane); - mainSplitPane.setBorder(BorderFactory.createLineBorder(GUICoreUtils.getTitleLineBorderColor())); - mainSplitPane.setOneTouchExpandable(true); - this.add(mainSplitPane, BorderLayout.CENTER); - } - - public DBTableDataPane() { - init(); - initMainSplitPane(); - } - - - - private boolean isPreviewOrRefreshButton (FocusEvent e) { - if (e.getOppositeComponent() != null) { - String name = e.getOppositeComponent().getName(); - return ComparatorUtils.equals(name, PREVIEW_BUTTON) || ComparatorUtils.equals(name, REFRESH_BUTTON); - } - return false; - } - - @Override - protected String title4PopupWindow() { - return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_DS-Database_Query"); - } - - private void refresh() { - String[] paramTexts = new String[2]; - paramTexts[0] = SqlUtils.tryPureSqlText(sqlTextPane.getText()); - paramTexts[1] = SqlUtils.tryPureSqlText(pageQuery); - List existParameterList = editorPane.update(); - Parameter[] ps = existParameterList == null ? new Parameter[0] : existParameterList.toArray(new Parameter[existParameterList.size()]); - - editorPane.populate(ParameterHelper.analyzeAndUnionSameParameters(paramTexts, ps)); - } - - private JToolBar createToolBar() { - // p:工具栏. - ToolBarDef toolBarDef = new ToolBarDef(); - toolBarDef.addShortCut(new PreviewAction()); - toolBarDef.addShortCut(SeparatorDef.DEFAULT); - toolBarDef.addShortCut(new EditPageQueryAction()); - dbTableDataMenuHandler = ExtraDesignClassManager.getInstance().getSingle(DBTableDataMenuHandler.MARK_STRING); - if (dbTableDataMenuHandler != null) { - toolBarDef.addShortCut(SeparatorDef.DEFAULT); - toolBarDef.addShortCut(dbTableDataMenuHandler.createQueryAction()); - } - isShareCheckBox = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Is_Share_DBTableData")); - isShareCheckBox.setBackground(Color.WHITE); - maxPanel = new MaxMemRowCountPanel(); - maxPanel.setBorder(null); - UIToolbar editToolBar = ToolBarDef.createJToolBar(); - toolBarDef.updateToolBar(editToolBar); - editToolBar.add(isShareCheckBox); - editToolBar.add(maxPanel); - return editToolBar; - } - - private void checkParameter() { - String[] paramTexts = new String[2]; - paramTexts[0] = sqlTextPane.getText(); - paramTexts[1] = pageQuery; - Parameter[] parameters = ParameterHelper.analyze4Parameters(paramTexts, false); - - if (parameters.length < 1 && editorPane.update().size() < 1) { - return; - } - boolean isIn = true; - List list = editorPane.update(); - List name = new ArrayList(); - for (int i = 0; i < list.size(); i++) { - name.add(list.get(i).getName()); - } - for (int i = 0; i < parameters.length; i++) { - if (!name.contains(parameters[i].getName())) { - isIn = false; - break; - } - } - if (list.size() == parameters.length && isIn) { - return; - } - // bug:34175 删了是否刷新对话框, 均直接刷新 - refresh(); - } - - @Override - public void populateBean(DBTableData dbtabledata) { - this.dbTableData = dbtabledata; - if (dbTableDataMenuHandler != null) { - dbTableDataMenuHandler.populate(dbtabledata); - } - ParameterProvider[] parameters = null; - - Calculator c = Calculator.createCalculator(); - - parameters = dbtabledata.getParameters(c); - editorPane.populate(parameters); - - com.fr.data.impl.Connection db = null; - String query = null; - boolean isShare = false; - int maxMemeryRow = -1; - - db = dbtabledata.getDatabase(); - query = dbtabledata.getQuery(); - isShare = dbtabledata.isShare(); - maxMemeryRow = dbtabledata.getMaxMemRowCount(); - this.pageQuery = dbtabledata.getPageQuerySql(); - this.connectionTableProcedurePane.setSelectedDatabaseConnection(db); - this.sqlTextPane.setText(query); - this.sqlTextPane.requestFocus(); - this.sqlTextPane.moveCaretPosition(this.sqlTextPane.getCaretPosition()); - - isShareCheckBox.setSelected(isShare); - maxPanel.setValue(maxMemeryRow); - } - - @Override - public DBTableData updateBean() { - String dbName = this.connectionTableProcedurePane.getSelectedDatabaseConnnectonName(); - if (StringUtils.isBlank(dbName) || StringUtils.isBlank(this.sqlTextPane.getText())) { - try { - throw new Exception(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Connect_SQL_Cannot_Null") + "."); - } catch (Exception e) { - // JOptionPane.showMessageDialog(DBTableDataPane.this, - // com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Connect_SQL_Cannot_Null") + "."); - } - } - - List parameterList = editorPane.update(); - Parameter[] parameters = parameterList.toArray(new Parameter[parameterList.size()]); - - dbTableData.setDatabase(new NameDatabaseConnection(dbName)); - - // p:必须先设置Parameters数组,因为setQuery里面会自动设置的 - - dbTableData.setParameters(parameters); - dbTableData.setQuery(this.sqlTextPane.getText()); - - dbTableData.setShare(isShareCheckBox.isSelected()); - dbTableData.setMaxMemRowCount(maxPanel.getValue()); - dbTableData.setPageQuerySql(this.pageQuery); - if (dbTableDataMenuHandler != null) { - dbTableDataMenuHandler.update(); - } - return dbTableData; - } - - protected class RefreshAction extends UITableEditAction { - public RefreshAction() { - this.setName(REFRESH_BUTTON); - this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/control/refresh.png")); - } - - public void actionPerformed(ActionEvent e) { - refresh(); - } - - @Override - public void checkEnabled() { - // unsupport - } - } - - private class PreviewAction extends UpdateAction { - public PreviewAction() { - this.setName(PREVIEW_BUTTON); - this.setMnemonic('P'); - this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/m_file/preview.png")); - } - - public void actionPerformed(ActionEvent evt) { - checkParameter(); - PreviewTablePane.previewTableData(DBTableDataPane.this.updateBean()); - } - } - - private class EditPageQueryAction extends UpdateAction { - public EditPageQueryAction() { - this.setName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Layer_Page_Report_Page_Query")); - this.setMnemonic('L'); - this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/m_file/text.png")); - } - - public void actionPerformed(ActionEvent e) { - final QueryPane pane = new QueryPane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Layer_Page_Report_Define_Page_Query_SQL")); - pane.populate(pageQuery); - BasicDialog dialog = pane.showWindow(DesignerContext.getDesignerFrame()); - dialog.addDialogActionListener(new DialogActionAdapter() { - public void doOk() { - pageQuery = pane.update(); - checkParameter(); - } - }); - dialog.setVisible(true); - } - } - - private class QueryPane extends BasicPane { - private SQLEditPane pageQueryPane; - private String title; - - public QueryPane(String title) { - this.title = title; - this.initComponents(); - } - - public void initComponents() { - this.setLayout(new BorderLayout()); - pageQueryPane = new SQLEditPane(); - this.add(new JScrollPane(pageQueryPane)); - } - - public void populate(String text) { - if (StringUtils.isBlank(text)) { - return; - } - pageQueryPane.setText(text); - } - - public String update() { - String text = pageQueryPane.getText(); - if (StringUtils.isBlank(text)) { - return null; - } else { - return text; - } - } - - @Override - protected String title4PopupWindow() { - return title; - } - } + private ConnectionTableProcedurePane connectionTableProcedurePane; + private UITableEditorPane editorPane; + + private DBTableDataMenuHandler dbTableDataMenuHandler; + private SQLEditPane sqlTextPane; + private UICheckBox isShareCheckBox; + private MaxMemRowCountPanel maxPanel; + private String pageQuery = null; + private DBTableData dbTableData; + + private void init() { + this.setLayout(new BorderLayout(4, 4)); + + sqlTextPane = new SQLEditPane(); + sqlTextPane.setSyntaxEditingStyle(SyntaxConstants.SYNTAX_STYLE_SQL); + + ParameterTableModel model = new ParameterTableModel() { + @Override + public UITableEditAction[] createAction() { + return ArrayUtils.add(super.createDBTableAction(), new RefreshAction()); + } + }; + editorPane = new UITableEditorPane(model); + + // 左边的Panel,上面是选择DatabaseConnection的ComboBox,下面DatabaseConnection对应的Table + connectionTableProcedurePane = new ConnectionTableProcedurePane() { + @Override + protected void filter(Connection connection, String conName, List nameList) { + + connection.addConnection(nameList, conName, new Class[]{JDBCDatabaseConnection.class, JNDIDatabaseConnection.class}); + } + }; + connectionTableProcedurePane.addDoubleClickListener(new DoubleClickSelectedNodeOnTreeListener() { + + @Override + public void actionPerformed(TableProcedure target) { + Document document = sqlTextPane.getDocument(); + try { + document.insertString(sqlTextPane.getCaretPosition(), target.toString(), null); + } catch (BadLocationException e) { + FineLoggerFactory.getLogger().error(e.getMessage(), e); + } + // 这里开始作色,本来可以给sqlTextPane添加DocumentListener来实现的, + // 后来发现insertString的时候,锁定了JTextPane,不能调用setXXX来作色,先这样了. + // sqlTextPane.syntaxTexts(); + sqlTextPane.requestFocus(); + } + }); + sqlTextPane.addFocusListener(new FocusListener() { + @Override + public void focusGained(FocusEvent e) { + // do nothing + } + + @Override + public void focusLost(FocusEvent e) { + if (isPreviewOrRefreshButton(e)) { + checkParameter(); + } + } + }); + } + + + private void initMainSplitPane() { + Box box = new Box(BoxLayout.Y_AXIS); + + + JPanel northPane = new JPanel(new BorderLayout(4, 4)); + JToolBar editToolBar = createToolBar(); + northPane.add(editToolBar, BorderLayout.CENTER); + northPane.setBorder(BorderFactory.createEmptyBorder(0, 0, BOTTOM, 0)); + + RTextScrollPane sqlTextScrollPane = new RTextScrollPane(sqlTextPane); + sqlTextScrollPane.setLineNumbersEnabled(true); + sqlTextScrollPane.setBorder(new UIRoundedBorder(UIConstants.LINE_COLOR, 1, UIConstants.ARC)); + sqlTextScrollPane.setPreferredSize(new Dimension(680, 600)); + + JPanel paraMeanPane = new JPanel(new BorderLayout()); + paraMeanPane.setPreferredSize(new Dimension(680, 90)); + UILabel paraMean = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Datasource_Param_DES")); + paraMeanPane.add(paraMean, BorderLayout.CENTER); + + + box.add(northPane); + box.add(sqlTextScrollPane); + box.add(paraMeanPane); + box.add(editorPane); + + JPanel sqlSplitPane = new JPanel(new BorderLayout(4, 4)); + sqlSplitPane.add(box, BorderLayout.CENTER); + + + box.setMinimumSize(new Dimension(300, 400)); + // 防止数据连接名过长时影响 split pane 分割效果 + connectionTableProcedurePane.setMinimumSize(new Dimension(250, 400)); + connectionTableProcedurePane.setMaximumSize(new Dimension(500, 400)); + // 使用SplitPane + JSplitPane mainSplitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, true, connectionTableProcedurePane, sqlSplitPane); + mainSplitPane.setBorder(BorderFactory.createLineBorder(GUICoreUtils.getTitleLineBorderColor())); + mainSplitPane.setOneTouchExpandable(true); + this.add(mainSplitPane, BorderLayout.CENTER); + } + + public DBTableDataPane() { + init(); + initMainSplitPane(); + } + + + private boolean isPreviewOrRefreshButton(FocusEvent e) { + if (e.getOppositeComponent() != null) { + String name = e.getOppositeComponent().getName(); + return ComparatorUtils.equals(name, PREVIEW_BUTTON) || ComparatorUtils.equals(name, REFRESH_BUTTON); + } + return false; + } + + @Override + protected String title4PopupWindow() { + return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_DS-Database_Query"); + } + + private void refresh() { + String[] paramTexts = new String[2]; + paramTexts[0] = SqlUtils.tryPureSqlText(sqlTextPane.getText()); + paramTexts[1] = SqlUtils.tryPureSqlText(pageQuery); + List existParameterList = editorPane.update(); + Parameter[] ps = existParameterList == null ? new Parameter[0] : existParameterList.toArray(new Parameter[existParameterList.size()]); + + editorPane.populate(ParameterHelper.analyzeAndUnionSameParameters(paramTexts, ps)); + } + + private JToolBar createToolBar() { + // p:工具栏. + ToolBarDef toolBarDef = new ToolBarDef(); + toolBarDef.addShortCut(new PreviewAction()); + toolBarDef.addShortCut(SeparatorDef.DEFAULT); + toolBarDef.addShortCut(new EditPageQueryAction()); + dbTableDataMenuHandler = ExtraDesignClassManager.getInstance().getSingle(DBTableDataMenuHandler.MARK_STRING); + if (dbTableDataMenuHandler != null) { + toolBarDef.addShortCut(SeparatorDef.DEFAULT); + toolBarDef.addShortCut(dbTableDataMenuHandler.createQueryAction()); + } + isShareCheckBox = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Is_Share_DBTableData")); + isShareCheckBox.setBackground(Color.WHITE); + maxPanel = new MaxMemRowCountPanel(); + maxPanel.setBorder(null); + UIToolbar editToolBar = ToolBarDef.createJToolBar(); + toolBarDef.updateToolBar(editToolBar); + editToolBar.add(isShareCheckBox); + editToolBar.add(maxPanel); + return editToolBar; + } + + private void checkParameter() { + String[] paramTexts = new String[2]; + paramTexts[0] = sqlTextPane.getText(); + paramTexts[1] = pageQuery; + Parameter[] parameters = ParameterHelper.analyze4Parameters(paramTexts, false); + + if (parameters.length < 1 && editorPane.update().size() < 1) { + return; + } + boolean isIn = true; + List list = editorPane.update(); + List name = new ArrayList(); + for (int i = 0; i < list.size(); i++) { + name.add(list.get(i).getName()); + } + for (int i = 0; i < parameters.length; i++) { + if (!name.contains(parameters[i].getName())) { + isIn = false; + break; + } + } + if (list.size() == parameters.length && isIn) { + return; + } + // bug:34175 删了是否刷新对话框, 均直接刷新 + refresh(); + } + + @Override + public void populateBean(DBTableData dbtabledata) { + this.dbTableData = dbtabledata; + if (dbTableDataMenuHandler != null) { + dbTableDataMenuHandler.populate(dbtabledata); + } + ParameterProvider[] parameters = null; + + Calculator c = Calculator.createCalculator(); + + parameters = dbtabledata.getParameters(c); + editorPane.populate(parameters); + + com.fr.data.impl.Connection db = null; + String query = null; + boolean isShare = false; + int maxMemeryRow = -1; + + db = dbtabledata.getDatabase(); + query = dbtabledata.getQuery(); + isShare = dbtabledata.isShare(); + maxMemeryRow = dbtabledata.getMaxMemRowCount(); + this.pageQuery = dbtabledata.getPageQuerySql(); + this.connectionTableProcedurePane.setSelectedDatabaseConnection(db); + this.sqlTextPane.setText(query); + this.sqlTextPane.requestFocus(); + this.sqlTextPane.moveCaretPosition(this.sqlTextPane.getCaretPosition()); + + isShareCheckBox.setSelected(isShare); + maxPanel.setValue(maxMemeryRow); + } + + @Override + public DBTableData updateBean() { + String dbName = this.connectionTableProcedurePane.getSelectedDatabaseConnnectonName(); + if (StringUtils.isBlank(dbName) || StringUtils.isBlank(this.sqlTextPane.getText())) { + try { + throw new Exception(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Connect_SQL_Cannot_Null") + "."); + } catch (Exception ignore) { + // JOptionPane.showMessageDialog(DBTableDataPane.this, + // com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Connect_SQL_Cannot_Null") + "."); + } + } + + List parameterList = editorPane.update(); + Parameter[] parameters = parameterList.toArray(new Parameter[parameterList.size()]); + + dbTableData.setDatabase(new NameDatabaseConnection(dbName)); + + // p:必须先设置Parameters数组,因为setQuery里面会自动设置的 + + dbTableData.setParameters(parameters); + dbTableData.setQuery(this.sqlTextPane.getText()); + + dbTableData.setShare(isShareCheckBox.isSelected()); + dbTableData.setMaxMemRowCount(maxPanel.getValue()); + dbTableData.setPageQuerySql(this.pageQuery); + if (dbTableDataMenuHandler != null) { + dbTableDataMenuHandler.update(); + } + return dbTableData; + } + + protected class RefreshAction extends UITableEditAction { + public RefreshAction() { + this.setName(REFRESH_BUTTON); + this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/control/refresh.png")); + } + + @Override + public void actionPerformed(ActionEvent e) { + refresh(); + } + + @Override + public void checkEnabled() { + // do nothing + } + } + + private class PreviewAction extends UpdateAction { + public PreviewAction() { + this.setName(PREVIEW_BUTTON); + this.setMnemonic('P'); + this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/m_file/preview.png")); + } + + @Override + public void actionPerformed(ActionEvent evt) { + checkParameter(); + PreviewTablePane.previewTableData(DBTableDataPane.this.updateBean()); + } + } + + private class EditPageQueryAction extends UpdateAction { + public EditPageQueryAction() { + this.setName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Layer_Page_Report_Page_Query")); + this.setMnemonic('L'); + this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/m_file/text.png")); + } + + @Override + public void actionPerformed(ActionEvent e) { + final QueryPane pane = new QueryPane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Layer_Page_Report_Define_Page_Query_SQL")); + pane.populate(pageQuery); + BasicDialog dialog = pane.showWindow(DesignerContext.getDesignerFrame()); + dialog.addDialogActionListener(new DialogActionAdapter() { + @Override + public void doOk() { + pageQuery = pane.update(); + checkParameter(); + } + }); + dialog.setVisible(true); + } + } + + private class QueryPane extends BasicPane { + private SQLEditPane pageQueryPane; + private String title; + + public QueryPane(String title) { + this.title = title; + this.initComponents(); + } + + public void initComponents() { + this.setLayout(new BorderLayout()); + pageQueryPane = new SQLEditPane(); + this.add(new JScrollPane(pageQueryPane)); + } + + public void populate(String text) { + if (StringUtils.isBlank(text)) { + return; + } + pageQueryPane.setText(text); + } + + public String update() { + String text = pageQueryPane.getText(); + if (StringUtils.isBlank(text)) { + return null; + } else { + return text; + } + } + + @Override + protected String title4PopupWindow() { + return title; + } + } } From 4d9e1fb8bc669f01c6b6e1dc448f5820f7f7cc50 Mon Sep 17 00:00:00 2001 From: zheng Date: Tue, 16 Oct 2018 11:57:48 +0800 Subject: [PATCH 6/6] =?UTF-8?q?CHART-3211=20=E7=AC=AC=E4=B8=89=E6=96=B9?= =?UTF-8?q?=E5=9B=BE=E8=A1=A8=E6=8F=92=E4=BB=B6=E6=9C=89=E4=BA=9B=E6=B2=A1?= =?UTF-8?q?=E6=9C=89type=20pane?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/fr/design/ChartTypeInterfaceManager.java | 6 ++++++ .../chart/fun/impl/AbstractIndependentChartsUI.java | 8 +++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/designer-chart/src/main/java/com/fr/design/ChartTypeInterfaceManager.java b/designer-chart/src/main/java/com/fr/design/ChartTypeInterfaceManager.java index 5d54adff73..a01fc0ce58 100644 --- a/designer-chart/src/main/java/com/fr/design/ChartTypeInterfaceManager.java +++ b/designer-chart/src/main/java/com/fr/design/ChartTypeInterfaceManager.java @@ -61,6 +61,7 @@ import com.fr.plugin.injectable.PluginModule; import com.fr.plugin.injectable.PluginSingleInjection; import com.fr.plugin.solution.closeable.CloseableContainedMap; import com.fr.stable.ArrayUtils; +import com.fr.stable.AssistUtils; import com.fr.stable.StringUtils; import com.fr.stable.plugin.ExtraChartDesignClassManagerProvider; import com.fr.van.chart.area.AreaIndependentVanChartInterface; @@ -107,6 +108,8 @@ public class ChartTypeInterfaceManager implements ExtraChartDesignClassManagerPr private static Map idAndPriorityMap = new HashMap(); + public static final String TYPE_PANE_DEFAULT_TITLE = "DEFAULT_NAME"; + public synchronized static ChartTypeInterfaceManager getInstance() { return classManager; @@ -260,6 +263,9 @@ public class ChartTypeInterfaceManager implements ExtraChartDesignClassManagerPr String plotID = entry.getKey(); AbstractChartTypePane pane = entry.getValue().getPlotTypePane(); + if (AssistUtils.equals(pane.title4PopupWindow(), TYPE_PANE_DEFAULT_TITLE)) { + continue; + } pane.setPlotID(plotID); paneList.add(pane); diff --git a/designer-chart/src/main/java/com/fr/design/chart/fun/impl/AbstractIndependentChartsUI.java b/designer-chart/src/main/java/com/fr/design/chart/fun/impl/AbstractIndependentChartsUI.java index 6e9ef2f03c..19244a3fdd 100644 --- a/designer-chart/src/main/java/com/fr/design/chart/fun/impl/AbstractIndependentChartsUI.java +++ b/designer-chart/src/main/java/com/fr/design/chart/fun/impl/AbstractIndependentChartsUI.java @@ -1,6 +1,7 @@ package com.fr.design.chart.fun.impl; import com.fr.chart.chartattr.Plot; +import com.fr.design.ChartTypeInterfaceManager; import com.fr.design.beans.BasicBeanPane; import com.fr.design.chart.fun.IndependentChartUIProvider; import com.fr.design.condition.ConditionAttributesPane; @@ -40,7 +41,12 @@ public abstract class AbstractIndependentChartsUI extends AbstractProvider imple @Override public AbstractChartTypePane getPlotTypePane() { - return new PiePlotPane(); + return new PiePlotPane() { + @Override + public String title4PopupWindow() { + return ChartTypeInterfaceManager.TYPE_PANE_DEFAULT_TITLE; + } + }; } @Override