Browse Source

Merge branch 'release/10.0' of https://code.fineres.com/scm/~qinghui.liu/design into release/10.0

feature/big-screen
Qinghui.Liu 4 years ago
parent
commit
10af1e9785
  1. 100
      designer-base/src/main/java/com/fr/design/formula/FormulaTextField.java
  2. 25
      designer-base/src/main/java/com/fr/design/formula/SortFormulaPane.java
  3. 45
      designer-base/src/main/java/com/fr/design/gui/itextfield/DictionaryTextField.java
  4. 4
      designer-base/src/main/java/com/fr/design/os/impl/PMDialogAction.java
  5. 28
      designer-base/src/test/java/com/fr/design/formula/FormulaTextFieldTest.java
  6. 26
      designer-form/src/main/java/com/fr/design/designer/creator/cardlayout/XCardSwitchButton.java
  7. 2
      designer-form/src/main/java/com/fr/design/mainframe/EditingMouseListener.java
  8. 8
      designer-form/src/main/java/com/fr/design/mainframe/FormDesigner.java
  9. 86
      designer-realize/src/main/java/com/fr/design/dscolumn/DSColumnAdvancedPane.java
  10. 10
      designer-realize/src/main/java/com/fr/design/parameter/ParameterDefinitePane.java
  11. 72
      designer-realize/src/main/java/com/fr/quickeditor/cellquick/CellDSColumnEditor.java

100
designer-base/src/main/java/com/fr/design/formula/FormulaTextField.java

@ -1,100 +0,0 @@
package com.fr.design.formula;
import com.fr.base.BaseFormula;
import com.fr.design.gui.itextfield.DictionaryTextField;
import com.fr.stable.StringUtils;
import javax.swing.text.Document;
/**
* 公式展示时使用
* 展示 String.
* 但实际保存的是 BaseFormula
* 从而保留公式的形态
*
* created by Harrison on 2020/08/03
**/
public class FormulaTextField extends DictionaryTextField<BaseFormula> {
private static final String EMPTY_STRING = "=";
private static final BaseFormula EMPTY_FORMULA = BaseFormula.createFormulaBuilder().build(EMPTY_STRING);
public FormulaTextField() {
}
public FormulaTextField(int columns) {
super(columns);
}
public FormulaTextField(String text, int columns, BaseFormula value) {
super(text, columns, value);
}
public FormulaTextField(String text, BaseFormula value) {
super(text, value);
}
public FormulaTextField(Document doc, String text, int columns, BaseFormula value) {
super(doc, text, columns, value);
}
@Override
public BaseFormula getValue() {
if (this.value == null) {
this.value = createDefault();
}
//保持联动
linkValueByText();
return value;
}
private void linkValueByText() {
String content = getText();
this.value.setContent(content);
}
/**
* 设置值时会将展示的公式值一同设置进去
*
* @param value 公式值
*/
@Override
public void setValue(BaseFormula value) {
this.value = value;
if (this.value == null) {
this.value = createDefault();
}
}
/**
* 是需要设置不带 = 还是带 =
*
* @param value
* @param isPure 带不带 = , = 不带 =
*/
public void setValueAndText(BaseFormula value, boolean isPure) {
setValue(value);
String content = null;
if (isPure) {
content = this.value.getPureContent();
} else {
content = this.value.getContent();
}
setText(content);
}
private BaseFormula createDefault() {
String text = getText();
if (StringUtils.isNotEmpty(text)) {
return BaseFormula.createFormulaBuilder().build(text);
} else {
return EMPTY_FORMULA;
}
}
}

25
designer-base/src/main/java/com/fr/design/formula/SortFormulaPane.java

@ -7,13 +7,12 @@ import com.fr.design.dialog.DialogActionAdapter;
import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.gui.icombobox.SortOrderComboBox; import com.fr.design.gui.icombobox.SortOrderComboBox;
import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.ilable.UILabel;
import com.fr.design.gui.itextfield.UITextField;
import com.fr.design.utils.gui.GUICoreUtils; import com.fr.design.utils.gui.GUICoreUtils;
import javax.swing.JComponent;
import javax.swing.JPanel; import javax.swing.*;
import javax.swing.SwingUtilities; import java.awt.*;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.event.ActionEvent; import java.awt.event.ActionEvent;
import java.awt.event.ActionListener; import java.awt.event.ActionListener;
@ -21,7 +20,7 @@ public abstract class SortFormulaPane extends JPanel {
protected static final String InsetText = " "; protected static final String InsetText = " ";
protected SortOrderComboBox sortOrderComboBox; protected SortOrderComboBox sortOrderComboBox;
protected FormulaTextField sortFormulaTextField; protected UITextField sortFormulaTextField;
// 屏蔽掉“自定义比较规则”和“选择”按钮,只显示公式输入文本和公式按钮 // 屏蔽掉“自定义比较规则”和“选择”按钮,只显示公式输入文本和公式按钮
protected UIButton sortFormulaTextFieldButton; protected UIButton sortFormulaTextFieldButton;
@ -36,7 +35,7 @@ public abstract class SortFormulaPane extends JPanel {
} }
}); });
sortFormulaTextField = new FormulaTextField(16); sortFormulaTextField = new UITextField(16);
//Lance:添加一公式编辑器按钮 //Lance:添加一公式编辑器按钮
sortFormulaTextFieldButton = new UIButton("..."); sortFormulaTextFieldButton = new UIButton("...");
sortFormulaTextFieldButton.setToolTipText(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Formula") + "..."); sortFormulaTextFieldButton.setToolTipText(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Formula") + "...");
@ -56,15 +55,17 @@ public abstract class SortFormulaPane extends JPanel {
public abstract void formulaAction(); public abstract void formulaAction();
public void showFormulaDialog(String[] displayNames) { public void showFormulaDialog(String[] displayNames) {
BaseFormula value = sortFormulaTextField.getValue(); String text = sortFormulaTextField.getText();
final UIFormula formulaPane = FormulaFactory.createFormulaPaneWhenReserveFormula(); final UIFormula formulaPane = FormulaFactory.createFormulaPaneWhenReserveFormula();
formulaPane.populate(value, new CustomVariableResolver(displayNames, true)); formulaPane.populate(BaseFormula.createFormulaBuilder().build(text), new CustomVariableResolver(displayNames, true));
formulaPane.showLargeWindow(SwingUtilities.getWindowAncestor(SortFormulaPane.this), formulaPane.showLargeWindow(SwingUtilities.getWindowAncestor(SortFormulaPane.this),
new DialogActionAdapter() { new DialogActionAdapter() {
public void doOk() { public void doOk() {
BaseFormula fm = formulaPane.update(); BaseFormula fm = formulaPane.update();
if (fm != null) { if (fm.getContent().length() <= 1) {
sortFormulaTextField.setValueAndText(fm, true); sortFormulaTextField.setText("");
} else {
sortFormulaTextField.setText(fm.getContent().substring(1));
} }
} }
}).setVisible(true); }).setVisible(true);

45
designer-base/src/main/java/com/fr/design/gui/itextfield/DictionaryTextField.java

@ -1,45 +0,0 @@
package com.fr.design.gui.itextfield;
import javax.swing.text.Document;
/**
* 文字 ui.
* 保存实际值展示值
* 允许实际值和展示值不同
*
* created by Harrison on 2020/08/03
**/
public class DictionaryTextField<T> extends UITextField {
protected T value;
public DictionaryTextField() {
}
public DictionaryTextField(int columns) {
super(columns);
}
public DictionaryTextField(String text, int columns, T value) {
super(text, columns);
this.value = value;
}
public DictionaryTextField(String text, T value) {
super(text);
this.value = value;
}
public DictionaryTextField(Document doc, String text, int columns, T value) {
super(doc, text, columns);
this.value = value;
}
public T getValue() {
return value;
}
public void setValue(T value) {
this.value = value;
}
}

4
designer-base/src/main/java/com/fr/design/os/impl/PMDialogAction.java

@ -17,11 +17,11 @@ public class PMDialogAction implements OSBasedAction {
private static String PLUGIN_MANAGER_ROUTE = "#management/plugin"; private static String PLUGIN_MANAGER_ROUTE = "#management/plugin";
@Override @Override
public void execute(Object... objects) { public void execute(Object... objects) {
if(Arch.getArch() == Arch.ARM){ if(Arch.getArch() == Arch.ARM || OperatingSystem.isLinux()){
DesignUtils.visitEnvServerByParameters( PLUGIN_MANAGER_ROUTE,null,null); DesignUtils.visitEnvServerByParameters( PLUGIN_MANAGER_ROUTE,null,null);
return; return;
} }
if (ServerPreferenceConfig.getInstance().isUseOptimizedUPM() && !OperatingSystem.isLinux()) { if (ServerPreferenceConfig.getInstance().isUseOptimizedUPM()) {
UpmFinder.showUPMDialog(); UpmFinder.showUPMDialog();
} else { } else {
WebViewDlgHelper.createPluginDialog(); WebViewDlgHelper.createPluginDialog();

28
designer-base/src/test/java/com/fr/design/formula/FormulaTextFieldTest.java

@ -1,28 +0,0 @@
package com.fr.design.formula;
import com.fr.base.BaseFormula;
import org.junit.Assert;
import org.junit.Test;
import static org.junit.Assert.*;
public class FormulaTextFieldTest {
@Test
public void testSet() {
FormulaTextField field = new FormulaTextField();
BaseFormula aaaa = BaseFormula.createFormulaBuilder().build("aaaa");
field.setValueAndText(aaaa, true);
Assert.assertEquals("aaaa", field.getText());
field.setValueAndText(aaaa, false);
Assert.assertEquals("=aaaa", field.getText());
field.setText("bbbb");
BaseFormula formula = field.getValue();
Assert.assertEquals("bbbb", formula.getPureContent());
}
}

26
designer-form/src/main/java/com/fr/design/designer/creator/cardlayout/XCardSwitchButton.java

@ -202,7 +202,8 @@ public class XCardSwitchButton extends XButton {
jPopupMenu.add(prev); jPopupMenu.add(prev);
jPopupMenu.add(next); jPopupMenu.add(next);
jPopupMenu.add(end); jPopupMenu.add(end);
GUICoreUtils.showPopupMenu(jPopupMenu, editingMouseListener.getDesigner(), e.getX(), e.getY()); FormDesigner designer = editingMouseListener.getDesigner();
GUICoreUtils.showPopupMenu(jPopupMenu, editingMouseListener.getDesigner(), designer.getOriginX(e.getX()), designer.getOriginY(e.getY()));
} }
@Override @Override
@ -251,17 +252,32 @@ public class XCardSwitchButton extends XButton {
//是否进入点击关闭按钮区域 //是否进入点击关闭按钮区域
private boolean isSelectedClose(MouseEvent e, FormDesigner designer){ private boolean isSelectedClose(MouseEvent e, FormDesigner designer){
int diff = designer.getArea().getHorScrollBar().getValue(); int diff = designer.getHorizontalScaleValue();
// mouse position // mouse position
int ex = e.getX() + diff; int ex = e.getX() + diff;
int ey = e.getY(); int ey = e.getY();
//获取tab布局的位置,鼠标相对于tab按钮的位置 //获取tab布局的位置,鼠标相对于tab按钮的位置
XLayoutContainer mainLayout = cardLayout.getBackupParent(); Container mainLayout = cardLayout.getBackupParent();
Point point = mainLayout.getLocation(); Point point = mainLayout.getLocation();
double mainX = point.getX(); int y = 0;
double mainY = point.getY(); 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(); JForm jform = (JForm) HistoryTemplateListPane.getInstance().getCurrentEditingTemplate();

2
designer-form/src/main/java/com/fr/design/mainframe/EditingMouseListener.java

@ -607,7 +607,7 @@ public class EditingMouseListener extends MouseInputAdapter {
if (e.getButton() == MouseEvent.BUTTON3) { if (e.getButton() == MouseEvent.BUTTON3) {
UIPopupMenu cellPopupMenu = creator.createPopupMenu(designer); UIPopupMenu cellPopupMenu = creator.createPopupMenu(designer);
if (cellPopupMenu != UIPopupMenu.EMPTY) { if (cellPopupMenu != UIPopupMenu.EMPTY) {
GUICoreUtils.showPopupMenu(cellPopupMenu, designer, e.getX(), e.getY()); GUICoreUtils.showPopupMenu(cellPopupMenu, designer, oldX, oldY);
} }
} }
creator.doLayout(); creator.doLayout();

8
designer-form/src/main/java/com/fr/design/mainframe/FormDesigner.java

@ -1611,6 +1611,14 @@ public class FormDesigner extends TargetComponent<Form> implements TreeSelection
return (int) ((y - this.getPaintY()) / this.getScale()); return (int) ((y - this.getPaintY()) / this.getScale());
} }
public int getOriginX(int x) {
return (int) (x * this.getScale() + this.getPaintX());
}
public int getOriginY(int y) {
return (int) (y * this.getScale() + this.getPaintY());
}
public int getHorizontalScaleValue() { public int getHorizontalScaleValue() {
return (int) (this.getArea().getHorizontalValue() / this.scale); return (int) (this.getArea().getHorizontalValue() / this.scale);

86
designer-realize/src/main/java/com/fr/design/dscolumn/DSColumnAdvancedPane.java

@ -7,7 +7,6 @@ import com.fr.design.dialog.BasicPane;
import com.fr.design.dialog.DialogActionAdapter; import com.fr.design.dialog.DialogActionAdapter;
import com.fr.design.formula.CustomVariableResolver; import com.fr.design.formula.CustomVariableResolver;
import com.fr.design.formula.FormulaFactory; import com.fr.design.formula.FormulaFactory;
import com.fr.design.formula.FormulaTextField;
import com.fr.design.formula.SortFormulaPane; import com.fr.design.formula.SortFormulaPane;
import com.fr.design.formula.UIFormula; import com.fr.design.formula.UIFormula;
import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.ibutton.UIButton;
@ -26,17 +25,8 @@ import com.fr.report.cell.cellattr.CellExpandAttr;
import com.fr.report.cell.cellattr.core.group.DSColumn; import com.fr.report.cell.cellattr.core.group.DSColumn;
import com.fr.report.cell.cellattr.core.group.SelectCount; import com.fr.report.cell.cellattr.core.group.SelectCount;
import javax.swing.BorderFactory; import javax.swing.*;
import javax.swing.Box; import java.awt.*;
import javax.swing.JComponent;
import javax.swing.JPanel;
import javax.swing.SwingUtilities;
import java.awt.BorderLayout;
import java.awt.CardLayout;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.Font;
import java.awt.event.ActionEvent; import java.awt.event.ActionEvent;
import java.awt.event.ActionListener; import java.awt.event.ActionListener;
@ -231,7 +221,7 @@ public class DSColumnAdvancedPane extends BasicPane {
return; return;
} }
Object value = cellElement.getValue(); Object value = cellElement.getValue();
if (!(value instanceof DSColumn)) { if (value == null || !(value instanceof DSColumn)) {
return; return;
} }
@ -248,7 +238,7 @@ public class DSColumnAdvancedPane extends BasicPane {
this.cellElement = cellElement; this.cellElement = cellElement;
Object value = cellElement.getValue(); Object value = cellElement.getValue();
if (!(value instanceof DSColumn)) { if (value == null || !(value instanceof DSColumn)) {
return; return;
} }
DSColumn dSColumn = (DSColumn) value; DSColumn dSColumn = (DSColumn) value;
@ -256,8 +246,8 @@ public class DSColumnAdvancedPane extends BasicPane {
int sort = dSColumn.getOrder(); int sort = dSColumn.getOrder();
this.sortOrderComboBox.setSortOrder(new SortOrder(sort)); this.sortOrderComboBox.setSortOrder(new SortOrder(sort));
BaseFormula sortFormulaObject = dSColumn.getSortFormulaObject(); String sortFormula = dSColumn.getSortFormula();
sortFormulaTextField.setValueAndText(sortFormulaObject, true); sortFormulaTextField.setText(sortFormula);
} }
public void update(CellElement cellElement) { public void update(CellElement cellElement) {
@ -273,7 +263,15 @@ public class DSColumnAdvancedPane extends BasicPane {
dSColumn.setOrder(this.sortOrderComboBox.getSortOrder().getOrder()); dSColumn.setOrder(this.sortOrderComboBox.getSortOrder().getOrder());
//lance:sort formula //lance:sort formula
dSColumn.setSortFormulaObject(sortFormulaTextField.getValue()); String sText = null;
if (!(sortFormulaTextField.getText() == null || sortFormulaTextField.getText().trim().equals("") || sortFormulaTextField.getText().trim().equals("$$$"))) {
sText = new String(sortFormulaTextField.getText());
}
if (!(sText == null || sText.length() < 1)) {
dSColumn.setSortFormula(sText);
} else {
dSColumn.setSortFormula(null);
}
} }
} }
@ -369,9 +367,9 @@ public class DSColumnAdvancedPane extends BasicPane {
int selectCountType = selectCount.getType(); int selectCountType = selectCount.getType();
this.selectCountComboBox.setSelectedIndex(selectCountType); this.selectCountComboBox.setSelectedIndex(selectCountType);
if (selectCountType == TOP.getValue()) { if (selectCountType == TOP.getValue()) {
this.topFormulaPane.populateFormula(selectCount.getFormulaObject()); this.topFormulaPane.populate(selectCount.getFormulaCount());
} else if (selectCountType == BOTTOM.getValue()) { } else if (selectCountType == BOTTOM.getValue()) {
this.bottomFormulaPane.populateFormula(selectCount.getFormulaObject()); this.bottomFormulaPane.populate(selectCount.getFormulaCount());
} else if (selectCountType == SPECIFY.getValue()) { } else if (selectCountType == SPECIFY.getValue()) {
this.serialTextField.setText(selectCount.getSerial()); this.serialTextField.setText(selectCount.getSerial());
} }
@ -397,9 +395,9 @@ public class DSColumnAdvancedPane extends BasicPane {
dSColumn.setSelectCount(selectCount); dSColumn.setSelectCount(selectCount);
selectCount.setType(selectCountSelectIndex); selectCount.setType(selectCountSelectIndex);
if (selectCountSelectIndex == TOP.getValue()) { if (selectCountSelectIndex == TOP.getValue()) {
selectCount.setFormulaObject(this.topFormulaPane.getFormula()); selectCount.setFormulaCount(this.topFormulaPane.getFormulaText());
} else if (selectCountSelectIndex == BOTTOM.getValue()) { } else if (selectCountSelectIndex == BOTTOM.getValue()) {
selectCount.setFormulaObject(this.bottomFormulaPane.getFormula()); selectCount.setFormulaCount(this.bottomFormulaPane.getFormulaText());
} else if (selectCountSelectIndex == SPECIFY.getValue()) { } else if (selectCountSelectIndex == SPECIFY.getValue()) {
selectCount.setSerial(this.serialTextField.getText()); selectCount.setSerial(this.serialTextField.getText());
} }
@ -409,19 +407,19 @@ public class DSColumnAdvancedPane extends BasicPane {
private static class JFormulaField extends JPanel { private static class JFormulaField extends JPanel {
private CellElement cellElement; private CellElement cellElement;
private FormulaTextField formulaTextField; private UITextField formulaTextField;
private BaseFormula defaultFormula; private String defaultValue;
public JFormulaField(String defaultValue) { public JFormulaField(String defaultValue) {
this.defaultFormula = BaseFormula.createFormulaBuilder().build(defaultValue); this.defaultValue = defaultValue;
this.setLayout(FRGUIPaneFactory.createBoxFlowLayout()); this.setLayout(FRGUIPaneFactory.createBoxFlowLayout());
UILabel bottomLabel = new UILabel("="); UILabel bottomLabel = new UILabel("=");
bottomLabel.setFont(new Font("Dialog", Font.BOLD, 12)); bottomLabel.setFont(new Font("Dialog", Font.BOLD, 12));
this.add(bottomLabel); this.add(bottomLabel);
formulaTextField = new FormulaTextField(24); formulaTextField = new UITextField(24);
this.add(formulaTextField); this.add(formulaTextField);
formulaTextField.setValueAndText(defaultFormula, true); formulaTextField.setText(defaultValue);
UIButton bottomFrmulaButton = new UIButton("..."); UIButton bottomFrmulaButton = new UIButton("...");
this.add(bottomFrmulaButton); this.add(bottomFrmulaButton);
@ -441,24 +439,16 @@ public class DSColumnAdvancedPane extends BasicPane {
public String getFormulaText() { public String getFormulaText() {
return this.formulaTextField.getText(); return this.formulaTextField.getText();
} }
public void populateFormula(BaseFormula baseFormula) {
this.formulaTextField.setValueAndText(baseFormula, true);
}
public BaseFormula getFormula() {
return this.formulaTextField.getValue();
}
private ActionListener formulaButtonActionListener = new ActionListener() { private ActionListener formulaButtonActionListener = new ActionListener() {
public void actionPerformed(ActionEvent evt) { public void actionPerformed(ActionEvent evt) {
BaseFormula valueFormula = BaseFormula.createFormulaBuilder().build();
BaseFormula valueFormula = formulaTextField.getValue(); String text = formulaTextField.getText();
if (valueFormula == null) { if (text == null || text.length() <= 0) {
valueFormula = BaseFormula.createFormulaBuilder().build(); valueFormula.setContent(defaultValue);
} else {
valueFormula.setContent(text);
} }
final UIFormula formulaPane = FormulaFactory.createFormulaPaneWhenReserveFormula(); final UIFormula formulaPane = FormulaFactory.createFormulaPaneWhenReserveFormula();
@ -467,7 +457,7 @@ public class DSColumnAdvancedPane extends BasicPane {
return; return;
} }
Object value = cellElement.getValue(); Object value = cellElement.getValue();
if (!(value instanceof DSColumn)) { if (value == null || !(value instanceof DSColumn)) {
return; return;
} }
DSColumn dsColumn = (DSColumn) value; DSColumn dsColumn = (DSColumn) value;
@ -480,9 +470,9 @@ public class DSColumnAdvancedPane extends BasicPane {
public void doOk() { public void doOk() {
BaseFormula valueFormula = formulaPane.update(); BaseFormula valueFormula = formulaPane.update();
if (valueFormula.getContent().length() <= 1) { if (valueFormula.getContent().length() <= 1) {
formulaTextField.setValueAndText(defaultFormula, true); formulaTextField.setText(defaultValue);
} else { } else {
formulaTextField.setValueAndText(valueFormula, true); formulaTextField.setText(valueFormula.getContent().substring(1));
} }
} }
}).setVisible(true); }).setVisible(true);
@ -513,12 +503,12 @@ public class DSColumnAdvancedPane extends BasicPane {
DSColumn dSColumn = (DSColumn) value; DSColumn dSColumn = (DSColumn) value;
//formula //formula
BaseFormula valueFormula = dSColumn.getResultObject(); String valueFormula = dSColumn.getResult();
if (valueFormula == null) { if (valueFormula == null) {
valueFormula = BaseFormula.createFormulaBuilder().build("$$$"); valueFormula = "$$$";
} }
formulaField.populateElement(cellElement); formulaField.populateElement(cellElement);
formulaField.populateFormula(valueFormula); formulaField.populate(valueFormula);
} }
public void update(CellElement cellElement) { public void update(CellElement cellElement) {
@ -526,13 +516,13 @@ public class DSColumnAdvancedPane extends BasicPane {
return; return;
} }
Object value = cellElement.getValue(); Object value = cellElement.getValue();
if (!(value instanceof DSColumn)) { if (value == null || !(value instanceof DSColumn)) {
return; return;
} }
DSColumn dSColumn = (DSColumn) (cellElement.getValue()); DSColumn dSColumn = (DSColumn) (cellElement.getValue());
//formula //formula
dSColumn.setResultObject(this.formulaField.getFormula()); dSColumn.setResult(this.formulaField.getFormulaText());
} }
} }

10
designer-realize/src/main/java/com/fr/design/parameter/ParameterDefinitePane.java

@ -425,6 +425,9 @@ public class ParameterDefinitePane extends JPanel implements ToolBarMenuDockPlus
if (propertyChangeListener != null) { if (propertyChangeListener != null) {
propertyChangeListener.propertyChange(); propertyChangeListener.propertyChange();
} }
if (workBook != null) {
workBook.setAutoHeightForCenterPane();
}
} }
/** /**
@ -445,6 +448,9 @@ public class ParameterDefinitePane extends JPanel implements ToolBarMenuDockPlus
if (propertyChangeListener != null) { if (propertyChangeListener != null) {
propertyChangeListener.propertyChange(); propertyChangeListener.propertyChange();
} }
if (workBook != null) {
workBook.setAutoHeightForCenterPane();
}
} }
/** /**
@ -467,7 +473,9 @@ public class ParameterDefinitePane extends JPanel implements ToolBarMenuDockPlus
if (propertyChangeListener != null) { if (propertyChangeListener != null) {
propertyChangeListener.propertyChange(); propertyChangeListener.propertyChange();
} }
workBook.setAutoHeightForCenterPane(); if (workBook != null) {
workBook.setAutoHeightForCenterPane();
}
} }
/** /**

72
designer-realize/src/main/java/com/fr/quickeditor/cellquick/CellDSColumnEditor.java

@ -12,7 +12,6 @@ import com.fr.design.dscolumn.SelectedDataColumnPane;
import com.fr.design.event.UIObserverListener; import com.fr.design.event.UIObserverListener;
import com.fr.design.formula.CustomVariableResolver; import com.fr.design.formula.CustomVariableResolver;
import com.fr.design.formula.FormulaFactory; import com.fr.design.formula.FormulaFactory;
import com.fr.design.formula.FormulaTextField;
import com.fr.design.formula.UIFormula; import com.fr.design.formula.UIFormula;
import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.gui.ibutton.UIButtonGroup; import com.fr.design.gui.ibutton.UIButtonGroup;
@ -646,7 +645,6 @@ public class CellDSColumnEditor extends CellQuickEditor {
*/ */
public class ResultSetSortConfigPane extends JPanel { public class ResultSetSortConfigPane extends JPanel {
private static final String DEFAULT_VALUE = "="; private static final String DEFAULT_VALUE = "=";
private final BaseFormula DEFAULT_FORMULA = BaseFormula.createFormulaBuilder().build();
private JPanel contentPane; private JPanel contentPane;
private UIButtonGroup sortTypePane; private UIButtonGroup sortTypePane;
private JFormulaField formulaField; private JFormulaField formulaField;
@ -721,11 +719,11 @@ public class CellDSColumnEditor extends CellQuickEditor {
centerPane.setPreferredSize(new Dimension(156, 20)); centerPane.setPreferredSize(new Dimension(156, 20));
TableLayoutHelper.modifyTableLayoutIndexVGap(contentPane, 2, VGAP); TableLayoutHelper.modifyTableLayoutIndexVGap(contentPane, 2, VGAP);
} }
BaseFormula baseFormula = dSColumn.getSortFormulaObject(); String sortFormula = dSColumn.getSortFormula();
if (baseFormula == null) { if (sortFormula != null && sortFormula.length() >= 1) {
this.formulaField.populateFormula(DEFAULT_FORMULA); this.formulaField.populate(sortFormula);
} else { } else {
this.formulaField.populateFormula(baseFormula); this.formulaField.populate(DEFAULT_VALUE);
} }
} }
} }
@ -742,7 +740,7 @@ public class CellDSColumnEditor extends CellQuickEditor {
if (value instanceof DSColumn) { if (value instanceof DSColumn) {
DSColumn dSColumn = (DSColumn) value; DSColumn dSColumn = (DSColumn) value;
dSColumn.setOrder(this.sortTypePane.getSelectedIndex()); dSColumn.setOrder(this.sortTypePane.getSelectedIndex());
dSColumn.setSortFormulaObject(this.formulaField.getFormula()); dSColumn.setSortFormula(this.formulaField.getFormulaText());
} }
} }
} }
@ -776,7 +774,6 @@ public class CellDSColumnEditor extends CellQuickEditor {
*/ */
public class ResultSetFilterConfigPane extends JPanel { public class ResultSetFilterConfigPane extends JPanel {
private static final String DEFAULT_VALUE = "="; private static final String DEFAULT_VALUE = "=";
private final BaseFormula DEFAULT_FORMULA = BaseFormula.createFormulaBuilder().build(DEFAULT_VALUE);
private JPanel contentPane; private JPanel contentPane;
private UIComboBox rsComboBox; private UIComboBox rsComboBox;
@ -921,8 +918,8 @@ public class CellDSColumnEditor extends CellQuickEditor {
CardLayout setCardPaneLayout = (CardLayout) setCardPane.getLayout(); CardLayout setCardPaneLayout = (CardLayout) setCardPane.getLayout();
CardLayout tipCardPaneLayout = (CardLayout) tipCardPane.getLayout(); CardLayout tipCardPaneLayout = (CardLayout) tipCardPane.getLayout();
// 重置默认值 // 重置默认值
this.topFormulaPane.populateFormula(DEFAULT_FORMULA); this.topFormulaPane.populate(DEFAULT_VALUE);
this.bottomFormulaPane.populateFormula(DEFAULT_FORMULA); this.bottomFormulaPane.populate(DEFAULT_VALUE);
this.serialTextField.setText(StringUtils.EMPTY); this.serialTextField.setText(StringUtils.EMPTY);
if (selectCount != null) { if (selectCount != null) {
@ -930,7 +927,7 @@ public class CellDSColumnEditor extends CellQuickEditor {
this.rsComboBox.setSelectedIndex(selectCountType); this.rsComboBox.setSelectedIndex(selectCountType);
switch (FilterTypeEnum.getFilterByValue(selectCountType)) { switch (FilterTypeEnum.getFilterByValue(selectCountType)) {
case TOP: case TOP:
this.topFormulaPane.populateFormula(selectCount.getFormulaObject()); this.topFormulaPane.populate(selectCount.getFormulaCount());
//前N个 //前N个
setCardPaneLayout.show(setCardPane, TOP.name()); setCardPaneLayout.show(setCardPane, TOP.name());
tipCardPaneLayout.show(tipCardPane, TOP.name()); tipCardPaneLayout.show(tipCardPane, TOP.name());
@ -941,7 +938,7 @@ public class CellDSColumnEditor extends CellQuickEditor {
TableLayoutHelper.modifyTableLayoutIndexVGap(contentPane, 4, 0); TableLayoutHelper.modifyTableLayoutIndexVGap(contentPane, 4, 0);
break; break;
case BOTTOM: case BOTTOM:
this.bottomFormulaPane.populateFormula(selectCount.getFormulaObject()); this.bottomFormulaPane.populate(selectCount.getFormulaCount());
//后N个 //后N个
setCardPaneLayout.show(setCardPane, BOTTOM.name()); setCardPaneLayout.show(setCardPane, BOTTOM.name());
tipCardPaneLayout.show(tipCardPane, BOTTOM.name()); tipCardPaneLayout.show(tipCardPane, BOTTOM.name());
@ -1022,9 +1019,9 @@ public class CellDSColumnEditor extends CellQuickEditor {
dSColumn.setSelectCount(selectCount); dSColumn.setSelectCount(selectCount);
//noinspection Duplicates //noinspection Duplicates
if (selectedFilterIndex == TOP.getValue()) { if (selectedFilterIndex == TOP.getValue()) {
selectCount.setFormulaObject(this.topFormulaPane.getFormula()); selectCount.setFormulaCount(this.topFormulaPane.getFormulaText());
} else if (selectedFilterIndex == BOTTOM.getValue()) { } else if (selectedFilterIndex == BOTTOM.getValue()) {
selectCount.setFormulaObject(this.bottomFormulaPane.getFormula()); selectCount.setFormulaCount(this.bottomFormulaPane.getFormulaText());
} else if (selectedFilterIndex == SPECIFY.getValue()) { } else if (selectedFilterIndex == SPECIFY.getValue()) {
selectCount.setSerial(this.serialTextField.getText()); selectCount.setSerial(this.serialTextField.getText());
} }
@ -1063,15 +1060,14 @@ public class CellDSColumnEditor extends CellQuickEditor {
*/ */
public class JFormulaField extends JPanel { public class JFormulaField extends JPanel {
private CellElement cellElement; private CellElement cellElement;
private FormulaTextField formulaTextField; private UITextField formulaTextField;
private BaseFormula defaultFormula; private String defaultValue;
public JFormulaField(String defaultValue) { public JFormulaField(String defaultValue) {
this.defaultFormula = BaseFormula.createFormulaBuilder().build(defaultValue); this.defaultValue = defaultValue;
formulaTextField = new FormulaTextField(); formulaTextField = new UITextField();
formulaTextField.setValueAndText(defaultFormula, false); formulaTextField.setText(defaultValue);
JPanel textFieldPane = new JPanel(new BorderLayout()); JPanel textFieldPane = new JPanel(new BorderLayout());
textFieldPane.add(formulaTextField, BorderLayout.CENTER); textFieldPane.add(formulaTextField, BorderLayout.CENTER);
textFieldPane.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 5)); textFieldPane.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 5));
@ -1098,16 +1094,6 @@ public class CellDSColumnEditor extends CellQuickEditor {
public String getFormulaText() { public String getFormulaText() {
return this.formulaTextField.getText().trim(); return this.formulaTextField.getText().trim();
} }
public void populateFormula(BaseFormula baseFormula) {
this.formulaTextField.setValueAndText(baseFormula, false);
}
public BaseFormula getFormula() {
return this.formulaTextField.getValue();
}
/** /**
* 添加事件监听器 * 添加事件监听器
@ -1128,14 +1114,16 @@ public class CellDSColumnEditor extends CellQuickEditor {
private ActionListener formulaButtonActionListener = new ActionListener() { private ActionListener formulaButtonActionListener = new ActionListener() {
@Override @Override
public void actionPerformed(ActionEvent evt) { public void actionPerformed(ActionEvent evt) {
BaseFormula valueFormula = BaseFormula.createFormulaBuilder().build();
BaseFormula valueFormula = formulaTextField.getValue(); String text = formulaTextField.getText();
if (valueFormula == null) { if (text == null || text.length() <= 0) {
valueFormula = BaseFormula.createFormulaBuilder().build(); valueFormula.setContent(defaultValue);
} else {
valueFormula.setContent(text);
} }
final UIFormula formulaPane = FormulaFactory.createFormulaPaneWhenReserveFormula(); final UIFormula formulaPane = FormulaFactory.createFormulaPaneWhenReserveFormula();
if (cellElement != null) { if (cellElement != null) {
final Object value = cellElement.getValue(); Object value = cellElement.getValue();
if (value instanceof DSColumn) { if (value instanceof DSColumn) {
DSColumn dsColumn = (DSColumn) value; DSColumn dsColumn = (DSColumn) value;
String[] displayNames = DesignTableDataManager.getSelectedColumnNames(DesignTableDataManager.getEditingTableDataSource(), dsColumn.getDSName()); String[] displayNames = DesignTableDataManager.getSelectedColumnNames(DesignTableDataManager.getEditingTableDataSource(), dsColumn.getDSName());
@ -1145,9 +1133,9 @@ public class CellDSColumnEditor extends CellQuickEditor {
public void doOk() { public void doOk() {
BaseFormula valueFormula = formulaPane.update(); BaseFormula valueFormula = formulaPane.update();
if (valueFormula.getContent().length() <= 1) { if (valueFormula.getContent().length() <= 1) {
formulaTextField.setValueAndText(defaultFormula, false); formulaTextField.setText(defaultValue);
} else { } else {
formulaTextField.setValueAndText(valueFormula, false); formulaTextField.setText(valueFormula.getContent());
} }
} }
}).setVisible(true); }).setVisible(true);
@ -1164,7 +1152,6 @@ public class CellDSColumnEditor extends CellQuickEditor {
*/ */
public class CustomValuePane extends JPanel { public class CustomValuePane extends JPanel {
private static final String DEFAULT_VALUE = "=$$$"; private static final String DEFAULT_VALUE = "=$$$";
private final BaseFormula DEFAULT_FORMULA = BaseFormula.createFormulaBuilder().build(DEFAULT_VALUE);
private JFormulaField formulaField; private JFormulaField formulaField;
@ -1184,11 +1171,11 @@ public class CellDSColumnEditor extends CellQuickEditor {
if (value instanceof DSColumn) { if (value instanceof DSColumn) {
DSColumn dSColumn = (DSColumn) value; DSColumn dSColumn = (DSColumn) value;
//formula //formula
BaseFormula valueFormula = dSColumn.getResultObject(); String valueFormula = dSColumn.getResult();
if (valueFormula != null) { if (valueFormula != null) {
formulaField.populateFormula(valueFormula); formulaField.populate(valueFormula);
} else { } else {
formulaField.populateFormula(DEFAULT_FORMULA); formulaField.populate(DEFAULT_VALUE);
} }
formulaField.populateElement(cellElement); formulaField.populateElement(cellElement);
@ -1201,7 +1188,8 @@ public class CellDSColumnEditor extends CellQuickEditor {
Object value = cellElement.getValue(); Object value = cellElement.getValue();
if (value instanceof DSColumn) { if (value instanceof DSColumn) {
DSColumn dSColumn = (DSColumn) (cellElement.getValue()); DSColumn dSColumn = (DSColumn) (cellElement.getValue());
dSColumn.setResultObject(this.formulaField.getFormula()); dSColumn.setResult(StringUtils.isEmpty(this.formulaField.getFormulaText()) ?
null : this.formulaField.getFormulaText());
} }
} }
} }

Loading…
Cancel
Save