Browse Source

Pull request #13507: REPORT-99485 悬浮元素按钮绘制布局调整

Merge in DESIGN/design from ~VITO/c-design:newui to newui

* commit '7352c53c4851b06746e8e339d300ebd9c6141804':
  无jira任务 代码质量
  REPORT-99485 悬浮元素FloatStringQuickEditor布局调整
  无jira任务 跟上个
  REPORT-99485 数据集添加按钮更新
  REPORT-99485 悬浮元素按钮绘制布局调整
newui
vito-刘恒霖 11 months ago
parent
commit
52b962a16c
  1. 2
      designer-base/src/main/java/com/fine/theme/light/ui/FineLightIconSet.java
  2. 31
      designer-base/src/main/java/com/fr/design/menu/MenuDef.java
  3. 6
      designer-base/src/main/resources/com/fine/theme/icon/toolbar/add_popup.svg
  4. 6
      designer-base/src/main/resources/com/fine/theme/icon/toolbar/add_popup_disable.svg
  5. 86
      designer-realize/src/main/java/com/fr/design/mainframe/ReportFloatPane.java
  6. 68
      designer-realize/src/main/java/com/fr/quickeditor/floatquick/FloatStringQuickEditor.java

2
designer-base/src/main/java/com/fine/theme/light/ui/FineLightIconSet.java

@ -178,7 +178,7 @@ public class FineLightIconSet extends AbstractIconSet {
new SvgIconSource("tool_more", "com/fine/theme/icon/toolbar/more.svg", true),
new SvgIconSource("tool_more_hover", "com/fine/theme/icon/toolbar/more_hover.svg"),
new SvgIconSource("tool_config", "com/fine/theme/icon/toolbar/config.svg", true),
new SvgIconSource("add_popup", "com/fine/theme/icon/toolbar/add_popup.svg", true, 24),
new SvgIconSource("add_popup", "com/fine/theme/icon/toolbar/add_popup.svg", true),
// 参数面板
new SvgIconSource("param_edit", "com/fine/theme/icon/param/edit.svg", true, 24),

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",不带后缀
* 读取disable图标的文件名应当为"xxx_disabled.svg",也是项目中的svg命名规范
* 注意必须是svg图标路径才能使用此函数设置正常和禁用状态
*
* */
*/
public void setDisabledIcon(String iconPath, boolean needDisabled) {
this.iconPath = iconPath;
this.needDisabled = needDisabled;
}
public int getShortCutCount() {
return this.shortcutList.size();
}
@ -226,6 +226,29 @@ public class MenuDef extends ShortCut {
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) {
this.tooltip = text;
}
@ -260,7 +283,7 @@ public class MenuDef extends ShortCut {
UIMenu createdJMenu;
if (hasScrollSubMenu) {
createdJMenu = new UIScrollMenu(this.getName());
} else if (isHeadMenu){
} else if (isHeadMenu) {
createdJMenu = new UIHeadMenu(this.getName());
} else {
createdJMenu = new UIMenu(this.getName());
@ -349,8 +372,6 @@ public class MenuDef extends ShortCut {
}
public void updateEnable() {
setEnabled(checkEnable());
}

6
designer-base/src/main/resources/com/fine/theme/icon/toolbar/add_popup.svg

@ -1,4 +1,4 @@
<svg width="24" height="25" viewBox="0 0 24 25" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M11.4 13.1L11.4 18.4C11.4 18.7314 11.6686 19 12 19C12.3314 19 12.6 18.7314 12.6 18.4V13.1H17.9C18.2314 13.1 18.5 12.8314 18.5 12.5C18.5 12.1686 18.2314 11.9 17.9 11.9H12.6V6.6C12.6 6.26863 12.3314 6 12 6C11.6686 6 11.4 6.26863 11.4 6.6L11.4 11.9H6.1C5.76863 11.9 5.5 12.1686 5.5 12.5C5.5 12.8314 5.76863 13.1 6.1 13.1H11.4Z" fill="#0A1C38" fill-opacity="0.9"/>
<path d="M18.1425 21.5C18.0158 21.5 17.9523 21.3468 18.042 21.2571L20.7571 18.542C20.8468 18.4523 21 18.5158 21 18.6425V21.1C21 21.3209 20.8209 21.5 20.6 21.5H18.1425Z" fill="#0A1C38" fill-opacity="0.9"/>
<svg width="18" height="18" viewBox="0 0 18 18" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M7.4 8.6L7.4 13.9C7.4 14.2314 7.66863 14.5 8 14.5V14.5C8.33137 14.5 8.6 14.2314 8.6 13.9V8.6H13.9C14.2314 8.6 14.5 8.33137 14.5 8V8C14.5 7.66863 14.2314 7.4 13.9 7.4H8.6V2.1C8.6 1.76863 8.33137 1.5 8 1.5V1.5C7.66863 1.5 7.4 1.76863 7.4 2.1L7.4 7.4H2.1C1.76863 7.4 1.5 7.66863 1.5 8V8C1.5 8.33137 1.76863 8.6 2.1 8.6H7.4Z" fill="#0A1C38" fill-opacity="0.9"/>
<path d="M14.1425 17C14.0158 17 13.9523 16.8468 14.042 16.7571L16.7571 14.042C16.8468 13.9523 17 14.0158 17 14.1425V16.6C17 16.8209 16.8209 17 16.6 17H14.1425Z" fill="#0A1C38" fill-opacity="0.9"/>
</svg>

Before

Width:  |  Height:  |  Size: 678 B

After

Width:  |  Height:  |  Size: 667 B

6
designer-base/src/main/resources/com/fine/theme/icon/toolbar/add_popup_disable.svg

@ -1,4 +1,4 @@
<svg width="24" height="25" viewBox="0 0 24 25" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M11.4 13.1L11.4 18.4C11.4 18.7314 11.6686 19 12 19C12.3314 19 12.6 18.7314 12.6 18.4V13.1H17.9C18.2314 13.1 18.5 12.8314 18.5 12.5C18.5 12.1686 18.2314 11.9 17.9 11.9H12.6V6.6C12.6 6.26863 12.3314 6 12 6C11.6686 6 11.4 6.26863 11.4 6.6L11.4 11.9H6.1C5.76863 11.9 5.5 12.1686 5.5 12.5C5.5 12.8314 5.76863 13.1 6.1 13.1H11.4Z" fill="#0A1C38" fill-opacity="0.29"/>
<path d="M18.1425 21.5C18.0158 21.5 17.9523 21.3468 18.042 21.2571L20.7571 18.542C20.8468 18.4523 21 18.5158 21 18.6425V21.1C21 21.3209 20.8209 21.5 20.6 21.5H18.1425Z" fill="#0A1C38" fill-opacity="0.29"/>
<svg width="18" height="18" viewBox="0 0 18 18" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M7.4 8.6L7.4 13.9C7.4 14.2314 7.66863 14.5 8 14.5V14.5C8.33137 14.5 8.6 14.2314 8.6 13.9V8.6H13.9C14.2314 8.6 14.5 8.33137 14.5 8V8C14.5 7.66863 14.2314 7.4 13.9 7.4H8.6V2.1C8.6 1.76863 8.33137 1.5 8 1.5V1.5C7.66863 1.5 7.4 1.76863 7.4 2.1L7.4 7.4H2.1C1.76863 7.4 1.5 7.66863 1.5 8V8C1.5 8.33137 1.76863 8.6 2.1 8.6H7.4Z" fill="#0A1C38" fill-opacity="0.29"/>
<path d="M14.1425 17C14.0158 17 13.9523 16.8468 14.042 16.7571L16.7571 14.042C16.8468 13.9523 17 14.0158 17 14.1425V16.6C17 16.8209 16.8209 17 16.6 17H14.1425Z" fill="#0A1C38" fill-opacity="0.29"/>
</svg>

Before

Width:  |  Height:  |  Size: 680 B

After

Width:  |  Height:  |  Size: 677 B

86
designer-realize/src/main/java/com/fr/design/mainframe/ReportFloatPane.java

@ -1,29 +1,30 @@
package com.fr.design.mainframe;
import com.fine.swing.ui.layout.Column;
import com.fine.theme.icon.LazyIcon;
import com.formdev.flatlaf.util.ScaledEmptyBorder;
import com.fr.design.actions.UpdateAction;
import com.fr.design.actions.core.ActionFactory;
import com.fr.design.constants.UIConstants;
import com.fr.design.file.HistoryTemplateListPane;
import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.gui.itoolbar.UIToolbar;
import com.fr.design.layout.TableLayout;
import com.fr.design.layout.TableLayoutHelper;
import com.fr.design.i18n.Toolkit;
import com.fr.design.menu.KeySetUtils;
import com.fr.design.menu.MenuDef;
import javax.swing.BorderFactory;
import javax.swing.JComponent;
import javax.swing.JPanel;
import java.awt.BorderLayout;
import java.awt.Component;
import java.awt.Dimension;
import static com.fine.swing.ui.layout.Layouts.cell;
import static com.fine.swing.ui.layout.Layouts.row;
/**
* 悬浮元素
* Created by MoMeak on 2017/7/27.
*
* @author vito
* @since 9.0
* Created on 2017/7/27.
*/
public class ReportFloatPane extends JPanel {
public class ReportFloatPane extends Column {
private static ReportFloatPane THIS;
private MenuDef insertFloatMenu;
@ -48,72 +49,35 @@ public class ReportFloatPane extends JPanel {
}
private void initComponent() {
this.setLayout(new BorderLayout());
UIToolbar topToolBar = new UIToolbar();
topToolBar.setLayout(new BorderLayout());
setBorder(new ScaledEmptyBorder(10, 10, 10, 10));
setSpacing(10);
initInsertToolBar();
topToolBar.setPreferredSize(new Dimension(155,20));
topToolBar.add(createButtonUI(), BorderLayout.CENTER);
topToolBar.setBorder(BorderFactory.createEmptyBorder(-1, -1, -1, -1));
this.add(
row(10,
cell(new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Add_FloatElement"))),
cell(createButtonUI()).weight(1.0)
)
);
JPanel toolBarPane = new JPanel(new BorderLayout());
toolBarPane.add(topToolBar, BorderLayout.CENTER);
toolBarPane.setBorder(BorderFactory.createLineBorder(UIConstants.POP_DIALOG_BORDER));
toolBarPane.setPreferredSize(new Dimension(155,20));
UILabel emptyLabel = new UILabel();
emptyLabel.setBorder(BorderFactory.createEmptyBorder(0, 4, 0, 0));
double p = TableLayout.PREFERRED;
double f = TableLayout.FILL;
double[] columnSize = {p, p, p, f};
double[] rowSize = {p};
Component[][] components = new Component[][]{
new Component[]{new UILabel(), new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Add_FloatElement")), emptyLabel, toolBarPane},
};
JPanel leftTopPane = TableLayoutHelper.createTableLayoutPane(components, rowSize, columnSize);
leftTopPane.setBorder(BorderFactory.createEmptyBorder(12, 5, 0, 15));
this.add(leftTopPane, BorderLayout.NORTH);
}
private void initInsertToolBar() {
insertFloatMenu = new MenuDef(true);
insertFloatMenu.setName(KeySetUtils.INSERT_FLOAT.getMenuKeySetName());
insertFloatMenu.setTooltip(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_T_Insert_Float"));
insertFloatMenu.setIconPath("com/fr/design/images/control/addPopup.png");
insertFloatMenu.setTooltip(Toolkit.i18nText("Fine-Design_Report_T_Insert_Float"));
insertFloatMenu.setIcon(new LazyIcon("add"));
JTemplate editingTemplate = HistoryTemplateListPane.getInstance().getCurrentEditingTemplate();
JComponent currentElementCasePane = editingTemplate.getCurrentElementCasePane();
if (currentElementCasePane != null) {
insertFloatMenu.clearShortCuts();
UpdateAction[] actions = ActionFactory.createFloatInsertAction(ElementCasePane.class, currentElementCasePane);
for (int i = 0; i < actions.length; i++) {
insertFloatMenu.addShortCut(actions[i]);
for (UpdateAction action : actions) {
insertFloatMenu.addShortCut(action);
}
}
}
private UIButton createButtonUI() {
UIButton createdButton = insertFloatMenu.createUIButton();
// 此按钮单独抽出,不应使用工具栏外观
// if (!createdButton.isOpaque()) {
// createdButton.setOpaque(true);
// createdButton.setNormalPainted(true);
// createdButton.setBorderPaintedOnlyWhenPressed(false);
// }
return createdButton;
}
public static void main(String[] args) {
// JFrame jf = new JFrame("test");
// jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
// JPanel content = (JPanel) jf.getContentPane();
// content.setLayout(new BorderLayout());
// content.add(ReportFloatPane.getInstance(), BorderLayout.CENTER);
// GUICoreUtils.centerWindow(jf);
// jf.setSize(250, 400);
// jf.setVisible(true);
return insertFloatMenu.createNormalButton();
}
}

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

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