Browse Source

REPORT-99485 悬浮元素FloatStringQuickEditor布局调整

newui
vito 1 year ago
parent
commit
ed16a19191
  1. 31
      designer-base/src/main/java/com/fr/design/menu/MenuDef.java
  2. 62
      designer-realize/src/main/java/com/fr/quickeditor/floatquick/FloatStringQuickEditor.java

31
designer-base/src/main/java/com/fr/design/menu/MenuDef.java

@ -137,12 +137,12 @@ public class MenuDef extends ShortCut {
* 设置不可用图标时,注意传递路径问题,若路径为"view_normal.svg",请传递"view",不带后缀 * 设置不可用图标时,注意传递路径问题,若路径为"view_normal.svg",请传递"view",不带后缀
* 读取disable图标的文件名应当为"xxx_disabled.svg",也是项目中的svg命名规范 * 读取disable图标的文件名应当为"xxx_disabled.svg",也是项目中的svg命名规范
* 注意必须是svg图标路径才能使用此函数设置正常和禁用状态 * 注意必须是svg图标路径才能使用此函数设置正常和禁用状态
* */
* */
public void setDisabledIcon(String iconPath, boolean needDisabled) { public void setDisabledIcon(String iconPath, boolean needDisabled) {
this.iconPath = iconPath; this.iconPath = iconPath;
this.needDisabled = needDisabled; this.needDisabled = needDisabled;
} }
public int getShortCutCount() { public int getShortCutCount() {
return this.shortcutList.size(); return this.shortcutList.size();
} }
@ -226,6 +226,29 @@ public class MenuDef extends ShortCut {
return createdButton; return createdButton;
} }
/**
* 添加常规按钮
*
* @return 按钮
*/
public UIButton createNormalButton() {
if (createdButton == null) {
if (icon != null) {
createdButton = new UIButton(icon);
} else if (iconPath != null) {
createdButton = new UIButton(IconUtils.readIcon(iconPath));
} else {
createdButton = new UIButton(name);
}
// 添加名字以作自动化测试
createdButton.setName(name);
createdButton.setToolTipText(tooltip);
createdButton.addMouseListener(mouseListener);
}
return createdButton;
}
public void setTooltip(String text) { public void setTooltip(String text) {
this.tooltip = text; this.tooltip = text;
} }
@ -260,7 +283,7 @@ public class MenuDef extends ShortCut {
UIMenu createdJMenu; UIMenu createdJMenu;
if (hasScrollSubMenu) { if (hasScrollSubMenu) {
createdJMenu = new UIScrollMenu(this.getName()); createdJMenu = new UIScrollMenu(this.getName());
} else if (isHeadMenu){ } else if (isHeadMenu) {
createdJMenu = new UIHeadMenu(this.getName()); createdJMenu = new UIHeadMenu(this.getName());
} else { } else {
createdJMenu = new UIMenu(this.getName()); createdJMenu = new UIMenu(this.getName());
@ -349,8 +372,6 @@ public class MenuDef extends ShortCut {
} }
public void updateEnable() { public void updateEnable() {
setEnabled(checkEnable()); setEnabled(checkEnable());
} }

62
designer-realize/src/main/java/com/fr/quickeditor/floatquick/FloatStringQuickEditor.java

@ -1,39 +1,34 @@
package com.fr.quickeditor.floatquick; package com.fr.quickeditor.floatquick;
import com.fine.theme.icon.LazyIcon;
import com.fr.base.BaseFormula; import com.fr.base.BaseFormula;
import com.fr.base.BaseUtils;
import com.fr.base.Style; import com.fr.base.Style;
import com.fr.base.TextFormat; import com.fr.base.TextFormat;
import com.fr.design.constants.UIConstants;
import com.fr.design.file.HistoryTemplateListPane; import com.fr.design.file.HistoryTemplateListPane;
import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.gui.itextarea.UITextArea;
import com.fr.design.mainframe.ElementCasePane; import com.fr.design.mainframe.ElementCasePane;
import com.fr.design.utils.DesignUtils;
import com.fr.quickeditor.FloatQuickEditor; import com.fr.quickeditor.FloatQuickEditor;
import com.fr.report.ReportHelper; import com.fr.report.ReportHelper;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
import javax.swing.BorderFactory; import javax.swing.BorderFactory;
import javax.swing.JPanel;
import javax.swing.JTextArea;
import javax.swing.event.DocumentEvent; import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener; import javax.swing.event.DocumentListener;
import java.awt.BorderLayout; import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension; import static com.fine.swing.ui.layout.Layouts.cell;
import java.awt.Insets; import static com.fine.swing.ui.layout.Layouts.row;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
public class FloatStringQuickEditor extends FloatQuickEditor { public class FloatStringQuickEditor extends FloatQuickEditor {
private JTextArea stringTextField; private final UITextArea stringTextField;
private UIButton formulaButton; private final UIButton formulaButton;
// august:如果是原来编辑的是公式,要保留公式里的这些属性,不然在公式和字符串转化时,就会丢失这些属性设置 // august:如果是原来编辑的是公式,要保留公式里的这些属性,不然在公式和字符串转化时,就会丢失这些属性设置
private boolean reserveInResult = false; private boolean reserveInResult = false;
private boolean reserveOnWriteOrAnaly = true; private boolean reserveOnWriteOrAnaly = true;
private DocumentListener documentListener = new DocumentListener() { private final DocumentListener documentListener = new DocumentListener() {
@Override @Override
public void insertUpdate(DocumentEvent e) { public void insertUpdate(DocumentEvent e) {
@ -54,36 +49,19 @@ public class FloatStringQuickEditor extends FloatQuickEditor {
public FloatStringQuickEditor() { public FloatStringQuickEditor() {
super(); super();
stringTextField = new JTextArea(); stringTextField = new UITextArea();
initTextField();
formulaButton = new UIButton(); formulaButton = new UIButton();
formulaButton.setPreferredSize(new Dimension(25, 23)); formulaButton.setIcon(new LazyIcon("formula"));
formulaButton.setIcon(BaseUtils.readIcon("/com/fr/design/images/m_insert/formula.png")); formulaButton.addActionListener(e -> ((ElementCasePane<?>) HistoryTemplateListPane.getInstance()
ActionListener getFormulaActionListener = new ActionListener() { .getCurrentEditingTemplate().getCurrentElementCasePane())
@Override .getGrid().startEditing());
public void actionPerformed(ActionEvent e) {
((ElementCasePane) HistoryTemplateListPane.getInstance().getCurrentEditingTemplate().getCurrentElementCasePane()).getGrid().startEditing();
}
};
formulaButton.addActionListener(getFormulaActionListener);
JPanel pane = new JPanel(new BorderLayout(5, 0));
pane.add(stringTextField, BorderLayout.CENTER);
pane.add(formulaButton, BorderLayout.EAST);
pane.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 5));
formulaButton.setVisible(false); formulaButton.setVisible(false);
this.setLayout(new BorderLayout()); this.setLayout(new BorderLayout());
this.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); this.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
this.add(pane, BorderLayout.NORTH); add(row(10,
} cell(stringTextField).weight(1),
cell(formulaButton)
private void initTextField() { ).getComponent(), BorderLayout.NORTH);
stringTextField.setFont(DesignUtils.getDefaultGUIFont());
stringTextField.setOpaque(true);
stringTextField.setLineWrap(true);
stringTextField.setWrapStyleWord(true);
stringTextField.setMargin(new Insets(5, 5, 5, 5));
stringTextField.setBorder(BorderFactory.createLineBorder(UIConstants.POP_DIALOG_BORDER));
stringTextField.setBackground(Color.WHITE);
} }
@ -92,19 +70,17 @@ public class FloatStringQuickEditor extends FloatQuickEditor {
String str; String str;
Object value = null; Object value = null;
//处理撤销时npe //处理撤销时npe
if (floatElement != null){ if (floatElement != null) {
value = floatElement.getValue(); value = floatElement.getValue();
} }
if (value == null) { if (value == null) {
str = StringUtils.EMPTY; str = StringUtils.EMPTY;
} else if (value instanceof BaseFormula) { } else if (value instanceof BaseFormula) {
//MoMeak: 没拆文本框和公式所以需要这么个玩意
formulaButton.setVisible(true); formulaButton.setVisible(true);
BaseFormula formula = (BaseFormula) value; BaseFormula formula = (BaseFormula) value;
str = formula.getContent(); str = formula.getContent();
stringTextField.setLineWrap(false); stringTextField.setLineWrap(false);
this.setBorder(BorderFactory.createEmptyBorder(10, 75, 10, 10));
reserveInResult = formula.isReserveInResult(); reserveInResult = formula.isReserveInResult();
reserveOnWriteOrAnaly = formula.isReserveOnWriteOrAnaly(); reserveOnWriteOrAnaly = formula.isReserveOnWriteOrAnaly();
} else { } else {
@ -121,7 +97,7 @@ public class FloatStringQuickEditor extends FloatQuickEditor {
private void changeReportPaneCell(String tmpText) { private void changeReportPaneCell(String tmpText) {
if (tmpText != null && (tmpText.length() > 0 && tmpText.charAt(0) == '=')) { if (tmpText != null && (!tmpText.isEmpty() && tmpText.charAt(0) == '=')) {
BaseFormula textFormula = BaseFormula.createFormulaBuilder().build(tmpText); BaseFormula textFormula = BaseFormula.createFormulaBuilder().build(tmpText);
textFormula.setReserveInResult(reserveInResult); textFormula.setReserveInResult(reserveInResult);
textFormula.setReserveOnWriteOrAnaly(reserveOnWriteOrAnaly); textFormula.setReserveOnWriteOrAnaly(reserveOnWriteOrAnaly);

Loading…
Cancel
Save