diff --git a/designer-base/src/main/java/com/fr/design/condition/ConditionAttributesPane.java b/designer-base/src/main/java/com/fr/design/condition/ConditionAttributesPane.java index 781c57b05..6ca4ed680 100644 --- a/designer-base/src/main/java/com/fr/design/condition/ConditionAttributesPane.java +++ b/designer-base/src/main/java/com/fr/design/condition/ConditionAttributesPane.java @@ -15,8 +15,9 @@ import javax.swing.JComponent; import javax.swing.JPanel; import javax.swing.JScrollPane; import java.awt.Dimension; -import java.util.HashMap; import java.util.Iterator; +import java.util.Map; +import java.util.LinkedHashMap; @Open public abstract class ConditionAttributesPane extends BasicBeanPane { @@ -27,7 +28,7 @@ public abstract class ConditionAttributesPane extends BasicBeanPane { protected LiteConditionPane liteConditionPane; - protected java.util.Map classPaneMap = new HashMap(); + protected Map classPaneMap = new LinkedHashMap<>(); //可用的Actions. protected java.util.List useAbleActionList = new java.util.ArrayList(); @@ -70,7 +71,7 @@ public abstract class ConditionAttributesPane extends BasicBeanPane { selectedItemScrollPane.setMinimumSize(new Dimension((int) selectedItemScrollPane.getPreferredSize().getWidth(), MIN_HEIGHT)); propertyChangePane.add(selectedItemScrollPane); } - + public void updateBean(T ob) { updateMenuDef(); } diff --git a/designer-base/src/main/java/com/fr/design/formula/FormulaTextField.java b/designer-base/src/main/java/com/fr/design/formula/FormulaTextField.java index 6294a7a3b..36cabec6b 100644 --- a/designer-base/src/main/java/com/fr/design/formula/FormulaTextField.java +++ b/designer-base/src/main/java/com/fr/design/formula/FormulaTextField.java @@ -18,8 +18,6 @@ public class FormulaTextField extends DictionaryTextField { private static final String EMPTY_STRING = "="; - private static final BaseFormula EMPTY_FORMULA = BaseFormula.createFormulaBuilder().build(EMPTY_STRING); - public FormulaTextField() { } @@ -64,10 +62,10 @@ public class FormulaTextField extends DictionaryTextField { @Override public void setValue(BaseFormula value) { - this.value = value; - if (this.value == null) { - this.value = createDefault(); + if (value == null) { + value = createDefault(); } + this.value = value; } /** @@ -94,7 +92,8 @@ public class FormulaTextField extends DictionaryTextField { if (StringUtils.isNotEmpty(text)) { return BaseFormula.createFormulaBuilder().build(text); } else { - return EMPTY_FORMULA; + //防止默认值被修改, 每一次创建都是不一样的。 + return BaseFormula.createFormulaBuilder().build(EMPTY_STRING); } } } diff --git a/designer-chart/src/main/java/com/fr/van/chart/box/VanChartBoxPlotTooltipPane.java b/designer-chart/src/main/java/com/fr/van/chart/box/VanChartBoxPlotTooltipPane.java index 4ad21d0d8..a68eb5596 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/box/VanChartBoxPlotTooltipPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/box/VanChartBoxPlotTooltipPane.java @@ -2,6 +2,7 @@ package com.fr.van.chart.box; import com.fr.chart.chartattr.Plot; import com.fr.plugin.chart.base.AttrTooltip; +import com.fr.plugin.chart.box.VanChartBoxPlot; import com.fr.plugin.chart.box.attr.AttrBoxTooltip; import com.fr.van.chart.designer.style.VanChartStylePane; import com.fr.van.chart.designer.style.tooltip.VanChartPlotTooltipPane; @@ -13,7 +14,8 @@ public class VanChartBoxPlotTooltipPane extends VanChartPlotTooltipPane { } protected void initTooltipContentPane(Plot plot) { - tooltipContentPane = new VanChartBoxTooltipContentPane(parent, VanChartBoxPlotTooltipPane.this); + boolean isDetailed = ((VanChartBoxPlot) plot).isDetailed(); + tooltipContentPane = new VanChartBoxTooltipContentPane(parent, VanChartBoxPlotTooltipPane.this, isDetailed); } protected AttrTooltip getAttrTooltip() { @@ -23,4 +25,8 @@ public class VanChartBoxPlotTooltipPane extends VanChartPlotTooltipPane { protected boolean hasTooltipSeriesType() { return false; } + + public void checkContentVisible(boolean isDetailed) { + ((VanChartBoxTooltipContentPane) tooltipContentPane).checkFormatVisible(isDetailed); + } } diff --git a/designer-chart/src/main/java/com/fr/van/chart/box/VanChartBoxTooltipContentPane.java b/designer-chart/src/main/java/com/fr/van/chart/box/VanChartBoxTooltipContentPane.java index 2b449785e..8831b5049 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/box/VanChartBoxTooltipContentPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/box/VanChartBoxTooltipContentPane.java @@ -1,6 +1,8 @@ package com.fr.van.chart.box; import com.fr.design.i18n.Toolkit; +import com.fr.design.layout.TableLayout; +import com.fr.design.layout.TableLayoutHelper; import com.fr.plugin.chart.base.AttrTooltipContent; import com.fr.plugin.chart.box.attr.AttrBoxTooltipContent; import com.fr.van.chart.designer.component.VanChartTooltipContentPane; @@ -10,10 +12,13 @@ import com.fr.van.chart.designer.component.format.VanChartFormatPaneWithCheckBox import com.fr.van.chart.designer.style.VanChartStylePane; import javax.swing.JPanel; +import java.awt.BorderLayout; import java.awt.Component; public class VanChartBoxTooltipContentPane extends VanChartTooltipContentPane { + private boolean detailed; + private VanChartFormatPaneWithCheckBox number; private VanChartFormatPaneWithCheckBox max; private VanChartFormatPaneWithCheckBox q3; @@ -22,8 +27,12 @@ public class VanChartBoxTooltipContentPane extends VanChartTooltipContentPane { private VanChartFormatPaneWithCheckBox min; private VanChartFormatPaneWithCheckBox outlier; - public VanChartBoxTooltipContentPane(VanChartStylePane parent, JPanel showOnPane) { + private JPanel dataNumberPane; + private JPanel dataOutlierPane; + + public VanChartBoxTooltipContentPane(VanChartStylePane parent, JPanel showOnPane, boolean isDetailed) { super(parent, showOnPane); + this.detailed = isDetailed; } protected void initFormatPane(VanChartStylePane parent, JPanel showOnPane) { @@ -67,22 +76,81 @@ public class VanChartBoxTooltipContentPane extends VanChartTooltipContentPane { }; } + protected JPanel createCommonPanel() { + JPanel commonPanel = new JPanel(new BorderLayout()); + + commonPanel.add(createCateAndSeriesPane(), BorderLayout.NORTH); + commonPanel.add(createDataNumberPane(), BorderLayout.CENTER); + commonPanel.add(createDataDetailPane(), BorderLayout.SOUTH); + + checkFormatVisible(detailed); + + return commonPanel; + } + protected double[] getRowSize(double p) { - return new double[]{p, p, p, p, p, p, p, p, p}; + return new double[]{p, p, p, p, p, p, p, p, p, p, p, p}; } - protected Component[][] getPaneComponents() { - return new Component[][]{ + private JPanel createCateAndSeriesPane() { + double p = TableLayout.PREFERRED; + double f = TableLayout.FILL; + + double[] columnSize = {f, p}; + double[] rowSize = {p, p}; + + Component[][] cateAndSeries = new Component[][]{ new Component[]{categoryNameFormatPane, null}, - new Component[]{seriesNameFormatPane, null}, + new Component[]{seriesNameFormatPane, null} + }; + + return TableLayoutHelper.createTableLayoutPane(cateAndSeries, rowSize, columnSize); + } + + private JPanel createDataNumberPane() { + double p = TableLayout.PREFERRED; + double f = TableLayout.FILL; + + double[] columnSize = {f, p}; + double[] rowSize = {p, p}; + + Component[][] dataNumber = new Component[][]{ + new Component[]{null, null}, new Component[]{number, null}, + }; + + dataNumberPane = TableLayoutHelper.createTableLayoutPane(dataNumber, rowSize, columnSize); + + return dataNumberPane; + } + + private JPanel createDataDetailPane() { + double p = TableLayout.PREFERRED; + double f = TableLayout.FILL; + double[] columnSize = {f, p}; + + JPanel detailPane = new JPanel(new BorderLayout()); + + Component[][] dataDetail = new Component[][]{ + new Component[]{null, null}, new Component[]{max, null}, new Component[]{q3, null}, new Component[]{median, null}, new Component[]{q1, null}, - new Component[]{min, null}, - new Component[]{outlier, null} + new Component[]{min, null} }; + + Component[][] dataOutlier = new Component[][]{ + new Component[]{null, null}, + new Component[]{outlier, null}, + }; + + dataOutlierPane = TableLayoutHelper.createTableLayoutPane(dataOutlier, new double[]{p, p}, columnSize); + + detailPane.add(TableLayoutHelper.createTableLayoutPane(dataDetail, new double[]{p, p, p, p, p, p}, columnSize), BorderLayout.NORTH); + detailPane.add(dataOutlierPane, BorderLayout.CENTER); + + return detailPane; } public boolean isDirty() { @@ -146,4 +214,11 @@ public class VanChartBoxTooltipContentPane extends VanChartTooltipContentPane { outlier.update(boxTooltipContent.getOutlier()); } } + + public void checkFormatVisible(boolean detailed) { + this.detailed = detailed; + + dataNumberPane.setVisible(detailed); + dataOutlierPane.setVisible(detailed); + } } diff --git a/designer-chart/src/main/java/com/fr/van/chart/box/VanChartBoxTooltipPane.java b/designer-chart/src/main/java/com/fr/van/chart/box/VanChartBoxTooltipPane.java index 5d485c31d..955f97453 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/box/VanChartBoxTooltipPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/box/VanChartBoxTooltipPane.java @@ -1,6 +1,10 @@ package com.fr.van.chart.box; +import com.fr.chart.base.DataSeriesCondition; import com.fr.chart.chartattr.Plot; +import com.fr.plugin.chart.attr.plot.VanChartPlot; +import com.fr.plugin.chart.base.AttrTooltip; +import com.fr.plugin.chart.box.VanChartBoxPlot; import com.fr.van.chart.designer.style.VanChartStylePane; import com.fr.van.chart.designer.style.tooltip.VanChartPlotTooltipPane; import com.fr.van.chart.designer.style.tooltip.VanChartTooltipPane; @@ -14,4 +18,18 @@ public class VanChartBoxTooltipPane extends VanChartTooltipPane { protected VanChartPlotTooltipPane getTooltipPane(Plot plot) { return new VanChartBoxPlotTooltipPane(plot, parent); } + + public void populateTooltipPane(Plot plot) { + DataSeriesCondition attr = ((VanChartPlot) plot).getAttrTooltipFromConditionCollection(); + VanChartPlotTooltipPane tooltipPane = getPlotTooltipPane(); + + if (tooltipPane instanceof VanChartBoxPlotTooltipPane) { + tooltipPane.populate((AttrTooltip) attr); + + VanChartBoxPlotTooltipPane boxPlotTooltipPane = (VanChartBoxPlotTooltipPane) tooltipPane; + VanChartBoxPlot boxPlot = (VanChartBoxPlot) plot; + + boxPlotTooltipPane.checkContentVisible(boxPlot.isDetailed()); + } + } } diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartTooltipContentPane.java b/designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartTooltipContentPane.java index af03afbe9..5920dd969 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartTooltipContentPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartTooltipContentPane.java @@ -42,6 +42,7 @@ public class VanChartTooltipContentPane extends BasicBeanPane { this.parent = parent; } + public VanChartPlotTooltipPane getPlotTooltipPane() { + return tooltipPane; + } + @Override protected JPanel createContentPane() { JPanel contentPane = new JPanel(new BorderLayout()); @@ -48,7 +53,10 @@ public class VanChartTooltipPane extends AbstractVanChartScrollPane { parent.initAllListeners(); } - Plot plot = this.chart.getPlot(); + populateTooltipPane(this.chart.getPlot()); + } + + public void populateTooltipPane(Plot plot) { DataSeriesCondition attr = ((VanChartPlot)plot).getAttrTooltipFromConditionCollection(); if(tooltipPane != null) { tooltipPane.populate((AttrTooltip)attr); @@ -74,7 +82,7 @@ public class VanChartTooltipPane extends AbstractVanChartScrollPane { @Override public String title4PopupWindow() { - return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Tooltip"); + return Toolkit.i18nText("Fine-Design_Chart_Tooltip"); } protected VanChartPlotTooltipPane getTooltipPane(Plot plot) { diff --git a/designer-form/src/main/java/com/fr/design/designer/creator/cardlayout/XCardSwitchButton.java b/designer-form/src/main/java/com/fr/design/designer/creator/cardlayout/XCardSwitchButton.java index f0e23b977..335c05b97 100644 --- a/designer-form/src/main/java/com/fr/design/designer/creator/cardlayout/XCardSwitchButton.java +++ b/designer-form/src/main/java/com/fr/design/designer/creator/cardlayout/XCardSwitchButton.java @@ -258,10 +258,25 @@ public class XCardSwitchButton extends XButton { int ey = e.getY(); //获取tab布局的位置,鼠标相对于tab按钮的位置 - XLayoutContainer mainLayout = cardLayout.getBackupParent(); + Container mainLayout = cardLayout.getBackupParent(); Point point = mainLayout.getLocation(); - double mainX = point.getX(); - double mainY = point.getY(); + int y = 0; + int x = 0; + //遍历一下,不然是相对位置,嵌套后位置不对 + while (mainLayout.getParent() != null){ + if(mainLayout instanceof XWCardLayout){ + y += mainLayout.getY(); + } + + mainLayout = mainLayout.getParent(); + + if(mainLayout instanceof XWCardMainBorderLayout){ + x += mainLayout.getX(); + y += mainLayout.getY(); + } + } + double mainX = point.getX() + x; + double mainY = point.getY() + y; // 参数界面对坐标的影响 JForm jform = (JForm) HistoryTemplateListPane.getInstance().getCurrentEditingTemplate(); diff --git a/designer-form/src/main/java/com/fr/design/mainframe/EditingMouseListener.java b/designer-form/src/main/java/com/fr/design/mainframe/EditingMouseListener.java index 3ef72242a..d8234c2b1 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/EditingMouseListener.java +++ b/designer-form/src/main/java/com/fr/design/mainframe/EditingMouseListener.java @@ -79,6 +79,9 @@ public class EditingMouseListener extends MouseInputAdapter { //备份开始拖动的位置和大小 private Rectangle dragBackupBounds; + private int pressX; + private int pressY; + /** * 获取最小移动距离 * @@ -141,6 +144,8 @@ public class EditingMouseListener extends MouseInputAdapter { public void mousePressed(MouseEvent e) { int oldX = e.getX(); int oldY = e.getY(); + pressX = oldX; + pressY = oldY; offsetEventPoint(e); if (!stopEditing()) { return; @@ -189,6 +194,7 @@ public class EditingMouseListener extends MouseInputAdapter { * @param e 鼠标事件 */ public void mouseReleased(MouseEvent e) { + MouseEvent transEvent = new MouseEvent(e.getComponent(), MouseEvent.MOUSE_CLICKED, e.getWhen(), e.getModifiers(), e.getX(), e.getY(), e.getXOnScreen(), e.getYOnScreen(), e.getClickCount(), e.isPopupTrigger(), e.getButton()); int oldX = e.getX(); int oldY = e.getY(); offsetEventPoint(e); @@ -213,6 +219,12 @@ public class EditingMouseListener extends MouseInputAdapter { lastPressEvent = null; lastXCreator = null; e.translatePoint(oldX - e.getX(), oldY - e.getY()); + if (pressX != oldX || pressY != oldY) { + // click只有在mouseReleased和mousePressed前后x/y坐标相等时才会被触发在mouseReleased之后 + // 但是当使用者来回点击切换时 存在mouseReleased和mousePressed前后x/y坐标不相等的情况 即鼠标按下去的位置和鼠标释放的位置不相等 存在偏移 + // 当这种偏移很小时 看起来就好像是点击了 实际上是手抖了或者鼠标轻微滑动了 所以这里对这种情况要有容错处理 + mouseClicked(transEvent); + } } private void mouseDraggingRelease(MouseEvent e) { diff --git a/designer-form/src/main/java/com/fr/design/parameter/ParameterPropertyPane.java b/designer-form/src/main/java/com/fr/design/parameter/ParameterPropertyPane.java index e3d5f46e4..ddab3a305 100644 --- a/designer-form/src/main/java/com/fr/design/parameter/ParameterPropertyPane.java +++ b/designer-form/src/main/java/com/fr/design/parameter/ParameterPropertyPane.java @@ -1,5 +1,6 @@ package com.fr.design.parameter; +import com.fr.base.Parameter; import com.fr.design.constants.UIConstants; import com.fr.design.designer.creator.XCreator; import com.fr.design.designer.creator.XWParameterLayout; @@ -124,7 +125,8 @@ public class ParameterPropertyPane extends JPanel{ hideInJForm = jt instanceof JForm && !(creator instanceof XWParameterLayout || creator.getParent() instanceof XWParameterLayout); } catch (NullPointerException ex) { - hideInJForm = toolbarPane.updateBean().length <= 0; + Parameter[] parameters = toolbarPane.updateBean(); + hideInJForm = parameters == null || parameters.length <= 0; } if (isVisible && toolbarPane.hasSelectedLabelItem() && !hideInJForm) { addParaPane.setVisible(true); diff --git a/designer-realize/src/main/java/com/fr/design/dscolumn/DSColumnAdvancedPane.java b/designer-realize/src/main/java/com/fr/design/dscolumn/DSColumnAdvancedPane.java index 58636917c..b1273ce58 100644 --- a/designer-realize/src/main/java/com/fr/design/dscolumn/DSColumnAdvancedPane.java +++ b/designer-realize/src/main/java/com/fr/design/dscolumn/DSColumnAdvancedPane.java @@ -410,10 +410,10 @@ public class DSColumnAdvancedPane extends BasicPane { private static class JFormulaField extends JPanel { private CellElement cellElement; private FormulaTextField formulaTextField; - private BaseFormula defaultFormula; + private String defaultValue; public JFormulaField(String defaultValue) { - this.defaultFormula = BaseFormula.createFormulaBuilder().build(defaultValue); + this.defaultValue = defaultValue; this.setLayout(FRGUIPaneFactory.createBoxFlowLayout()); UILabel bottomLabel = new UILabel("="); @@ -421,6 +421,7 @@ public class DSColumnAdvancedPane extends BasicPane { this.add(bottomLabel); formulaTextField = new FormulaTextField(24); this.add(formulaTextField); + BaseFormula defaultFormula = BaseFormula.createFormulaBuilder().build(this.defaultValue); formulaTextField.setValueAndText(defaultFormula, true); UIButton bottomFrmulaButton = new UIButton("..."); @@ -480,6 +481,7 @@ public class DSColumnAdvancedPane extends BasicPane { public void doOk() { BaseFormula valueFormula = formulaPane.update(); if (valueFormula.getContent().length() <= 1) { + BaseFormula defaultFormula = BaseFormula.createFormulaBuilder().build(defaultValue); formulaTextField.setValueAndText(defaultFormula, true); } else { formulaTextField.setValueAndText(valueFormula, true); diff --git a/designer-realize/src/main/java/com/fr/quickeditor/cellquick/CellDSColumnEditor.java b/designer-realize/src/main/java/com/fr/quickeditor/cellquick/CellDSColumnEditor.java index d9b8f1e7a..248a274f5 100644 --- a/designer-realize/src/main/java/com/fr/quickeditor/cellquick/CellDSColumnEditor.java +++ b/designer-realize/src/main/java/com/fr/quickeditor/cellquick/CellDSColumnEditor.java @@ -646,7 +646,6 @@ public class CellDSColumnEditor extends CellQuickEditor { */ public class ResultSetSortConfigPane extends JPanel { private static final String DEFAULT_VALUE = "="; - private final BaseFormula DEFAULT_FORMULA = BaseFormula.createFormulaBuilder().build(); private JPanel contentPane; private UIButtonGroup sortTypePane; private JFormulaField formulaField; @@ -723,7 +722,8 @@ public class CellDSColumnEditor extends CellQuickEditor { } BaseFormula baseFormula = dSColumn.getSortFormulaObject(); if (baseFormula == null) { - this.formulaField.populateFormula(DEFAULT_FORMULA); + BaseFormula defaultFormula = BaseFormula.createFormulaBuilder().build(); + this.formulaField.populateFormula(defaultFormula); } else { this.formulaField.populateFormula(baseFormula); } @@ -1064,11 +1064,12 @@ public class CellDSColumnEditor extends CellQuickEditor { public class JFormulaField extends JPanel { private CellElement cellElement; private FormulaTextField formulaTextField; - private BaseFormula defaultFormula; + private String defaultValue; public JFormulaField(String defaultValue) { - - this.defaultFormula = BaseFormula.createFormulaBuilder().build(defaultValue); + + this.defaultValue = defaultValue; + BaseFormula defaultFormula = BaseFormula.createFormulaBuilder().build(this.defaultValue); formulaTextField = new FormulaTextField(); formulaTextField.setValueAndText(defaultFormula, false); @@ -1145,6 +1146,7 @@ public class CellDSColumnEditor extends CellQuickEditor { public void doOk() { BaseFormula valueFormula = formulaPane.update(); if (valueFormula.getContent().length() <= 1) { + BaseFormula defaultFormula = BaseFormula.createFormulaBuilder().build(defaultValue); formulaTextField.setValueAndText(defaultFormula, false); } else { formulaTextField.setValueAndText(valueFormula, false); @@ -1164,8 +1166,7 @@ public class CellDSColumnEditor extends CellQuickEditor { */ public class CustomValuePane extends JPanel { private static final String DEFAULT_VALUE = "=$$$"; - private final BaseFormula DEFAULT_FORMULA = BaseFormula.createFormulaBuilder().build(DEFAULT_VALUE); - + private JFormulaField formulaField; public CustomValuePane() { @@ -1188,7 +1189,8 @@ public class CellDSColumnEditor extends CellQuickEditor { if (valueFormula != null) { formulaField.populateFormula(valueFormula); } else { - formulaField.populateFormula(DEFAULT_FORMULA); + BaseFormula defaultFormula = BaseFormula.createFormulaBuilder().build(DEFAULT_VALUE); + formulaField.populateFormula(defaultFormula); } formulaField.populateElement(cellElement); @@ -1201,7 +1203,7 @@ public class CellDSColumnEditor extends CellQuickEditor { Object value = cellElement.getValue(); if (value instanceof DSColumn) { DSColumn dSColumn = (DSColumn) (cellElement.getValue()); - dSColumn.setResultObject(this.formulaField.getFormula()); + dSColumn.setResultObject(StringUtils.isEmpty(this.formulaField.getFormulaText()) ? null : this.formulaField.getFormula()); } } }