From 47535eae3e76579ad1069cbf0f36297ee87e5955 Mon Sep 17 00:00:00 2001 From: renekton Date: Fri, 9 Aug 2024 10:18:31 +0800 Subject: [PATCH 1/5] =?UTF-8?q?=E9=9D=A2=E5=8C=85=E5=B1=91=E7=BB=84?= =?UTF-8?q?=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../design/gui/frpane/FineBreadcrumbPane.java | 153 ++++++++++++++++++ .../theme/TemplateThemeGridPagesPane.java | 18 +-- .../java/com/fr/file/FILEChooserPane.java | 18 ++- 3 files changed, 174 insertions(+), 15 deletions(-) create mode 100644 designer-base/src/main/java/com/fr/design/gui/frpane/FineBreadcrumbPane.java diff --git a/designer-base/src/main/java/com/fr/design/gui/frpane/FineBreadcrumbPane.java b/designer-base/src/main/java/com/fr/design/gui/frpane/FineBreadcrumbPane.java new file mode 100644 index 0000000000..29313ca232 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/gui/frpane/FineBreadcrumbPane.java @@ -0,0 +1,153 @@ +package com.fr.design.gui.frpane; + +import com.fine.swing.ui.layout.Row; +import com.fine.theme.utils.FineUIScale; +import com.fine.theme.utils.FineUIStyle; +import com.fr.design.gui.ibutton.UIButton; +import com.fr.design.gui.ilable.UILabel; +import com.fr.file.FILE; +import com.fr.general.ComparatorUtils; + +import javax.swing.BorderFactory; +import java.awt.Color; +import java.awt.Component; +import java.awt.Dimension; +import java.awt.Insets; + +public class FineBreadcrumbPane extends Row { + + private static final int SEP_HEIGHT = 20; + + private static final int BUTTON_HEIGHT = 20; + + private static final int MAX_BUTTON_WIDTH = FineUIScale.scale(150); + + private BreadcrumbButton currentCrumb; + + public void setRootButton(T text, final BreadcrumbBackListener backListener) { + clear(); + currentCrumb = new BreadcrumbButton<>(getText(text), text); + add(currentCrumb); + final int index = getComponentCount(); + addBreadcrumbListener(currentCrumb, index, backListener); + repaint(); + + } + + public void addCrumb(final T text, final BreadcrumbBackListener backListener) { + if (currentCrumb != null) { + if (text instanceof FILE) { + FILE file = (FILE) text; + if (ComparatorUtils.equals(currentCrumb.getContent(), file) || !file.isDirectory()) { + return; + } + if (file.getParent().equals(((FILE)currentCrumb.getContent()).getParent())) { + remove(currentCrumb); + currentCrumb = new BreadcrumbButton<>(getText(text), text); + final int index = getComponentCount(); + addBreadcrumbListener(currentCrumb, index, backListener); + repaint(); + return; + } + } + currentCrumb.setSelected(false); + currentCrumb.setForeground(Color.GRAY); + add(createSeparator()); + } + final BreadcrumbButton breadcrumb = createBreadcrumb(text); + add(breadcrumb); + currentCrumb = breadcrumb; + final int index = getComponentCount(); + addBreadcrumbListener(breadcrumb, index, backListener); + } + + private void removeTailCrumbs(int from) { + Component[] components = getComponents(); + for (int i = from; i < components.length; i++) { + remove(components[i]); + } + currentCrumb = (BreadcrumbButton) components[from-1]; + revalidate(); + repaint(); + } + + public void clear() { + removeAll(); + currentCrumb = null; + } + + protected Component createSeparator() { + UILabel separator = new UILabel("/"); + separator.setBorder(BorderFactory.createEmptyBorder(0, 2, 0, 2)); + separator.setPreferredSize(new Dimension(separator.getPreferredSize().width, FineUIScale.scale(SEP_HEIGHT))); + + return separator; + } + + protected BreadcrumbButton createBreadcrumb(T content) { + BreadcrumbButton button = new BreadcrumbButton(getText(content), content); + button.setPreferredSize(new Dimension(Math.min(button.getPreferredSize().width, MAX_BUTTON_WIDTH), FineUIScale.scale(BUTTON_HEIGHT))); + button.setSelected(true); + button.setForeground(Color.black); + return button; + } + + private void addBreadcrumbListener(BreadcrumbButton breadcrumb, int index, BreadcrumbBackListener backListener) { + breadcrumb.addActionListener(e -> { + removeTailCrumbs(index); + breadcrumb.setSelected(true); + breadcrumb.setForeground(Color.BLACK); + if (breadcrumb != currentCrumb) { + currentCrumb = breadcrumb; + } + if (backListener != null) { + backListener.onBreadcrumbBack(breadcrumb.getContent()); + } + }); + } + + private String getText(T text) { + if (text instanceof String) { + return (String) text; + } else if (text instanceof FILE){ + return ((FILE)text).getName(); + } + return (String) text; + } + + public static class BreadcrumbButton extends UIButton { + + private T content; + + public BreadcrumbButton(String text, T content) { + super(text); + BreadcrumbButton.this.content = content; + setMargin(new Insets(0, 0, 0, 0)); + setBorder(BorderFactory.createEmptyBorder()); + FineUIStyle.setStyle(BreadcrumbButton.this, FineUIStyle.PLAIN_BUTTON); + setBorderPainted(false); + setOpaque(false); + } + + @Override + public Insets getMargin() { + Insets insets = super.getMargin(); + if (insets != null) { + insets.set(0, 0, 0, 0); + } + return insets; + } + + protected T getContent() { + return content; + } + + protected void setContent(T content) { + this.content = content; + } + } + + public interface BreadcrumbBackListener { + void onBreadcrumbBack(T text); + } +} diff --git a/designer-base/src/main/java/com/fr/design/mainframe/theme/TemplateThemeGridPagesPane.java b/designer-base/src/main/java/com/fr/design/mainframe/theme/TemplateThemeGridPagesPane.java index 704f9c1a35..720e5db8bc 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/theme/TemplateThemeGridPagesPane.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/theme/TemplateThemeGridPagesPane.java @@ -12,6 +12,7 @@ import com.fr.design.dialog.BasicPane; import com.fr.design.event.ChangeEvent; import com.fr.design.event.ChangeListener; import com.fr.design.file.HistoryTemplateListCache; +import com.fr.design.gui.frpane.FineBreadcrumbPane; import com.fr.design.gui.frpane.FineTabbedPane; import com.fr.design.gui.ibutton.UIButton; import com.fr.design.i18n.Toolkit; @@ -53,7 +54,7 @@ import java.util.Set; */ public class TemplateThemeGridPagesPane extends JPanel { public static final String COMPLETE_BUTTON = "theme_button_complete"; - private BreadcrumbBar breadcrumbBar; + private FineBreadcrumbPane breadcrumbBar; private JPanel contentPane; private CardLayout cardLayout; @@ -75,7 +76,7 @@ public class TemplateThemeGridPagesPane extends JPanel { setLayout(new BorderLayout()); setBorder(BorderFactory.createEmptyBorder(10, 10, 0, 10)); - breadcrumbBar = new BreadcrumbBar(); + breadcrumbBar = new FineBreadcrumbPane(); breadcrumbBar.setBorder(BorderFactory.createEmptyBorder(0, 0, 10, 0)); add(breadcrumbBar, BorderLayout.NORTH); @@ -104,14 +105,11 @@ public class TemplateThemeGridPagesPane extends JPanel { pageChangeListener.onPageChangeListener(); } breadcrumbBar.clear(); - breadcrumbBar.addCrumb(themeUsingPane.getTitle(), new BreadcrumbBar.BreadcrumbBackListener() { - @Override - public void onBreadcrumbBack(String text) { - cardLayout.show(contentPane, themeUsingPane.getTitle()); - currentTemplateThemeGridPagePane = themeUsingPane; - if (pageChangeListener != null) { - pageChangeListener.onPageChangeListener(); - } + breadcrumbBar.addCrumb(themeUsingPane.getTitle(), text -> { + cardLayout.show(contentPane, themeUsingPane.getTitle()); + currentTemplateThemeGridPagePane = themeUsingPane; + if (pageChangeListener != null) { + pageChangeListener.onPageChangeListener(); } }); } diff --git a/designer-base/src/main/java/com/fr/file/FILEChooserPane.java b/designer-base/src/main/java/com/fr/file/FILEChooserPane.java index 5830f16d9a..023d7d2854 100644 --- a/designer-base/src/main/java/com/fr/file/FILEChooserPane.java +++ b/designer-base/src/main/java/com/fr/file/FILEChooserPane.java @@ -18,6 +18,7 @@ import com.fr.design.env.DesignerWorkspaceType; import com.fr.design.file.HistoryTemplateListPane; import com.fr.design.file.NodeAuthProcessor; import com.fr.design.fun.ReportSupportedFileUIProvider; +import com.fr.design.gui.frpane.FineBreadcrumbPane; import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.ibutton.UIButtonUI; import com.fr.design.gui.icombobox.UIComboBox; @@ -154,6 +155,7 @@ public class FILEChooserPane extends BasicPane { private FILEFilter filter; private LocationButtonPane locationBtnPane; // 显示location的Panel + private FineBreadcrumbPane locationBreadcrumbPane; private UIButton mkdirButton; private JList placesList; // File.listRoots() + Env + Favourite @@ -305,7 +307,7 @@ public class FILEChooserPane extends BasicPane { JPanel locationPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); // locationPane.setLayout(FRGUIPaneFactory.createBorderLayout()); - locationPane.add(locationBtnPane = new LocationButtonPane(), BorderLayout.CENTER); + locationPane.add(locationBreadcrumbPane = new FineBreadcrumbPane(), BorderLayout.CENTER); mkdirButton = initMkdirButton(); locationPane.add(mkdirButton, BorderLayout.EAST); @@ -348,6 +350,9 @@ public class FILEChooserPane extends BasicPane { Object selValue = placesList.getSelectedValue(); if (selValue instanceof FILE) { setSelectedDirectory((FILE) selValue); + locationBreadcrumbPane.setRootButton(selValue, text -> { + setSelectedDirectory((FILE) selValue); + }); } } }); @@ -418,6 +423,9 @@ public class FILEChooserPane extends BasicPane { setFileTextField((FILE) selValue); fileNameTextField.addDocumentListener(); } else { + locationBreadcrumbPane.addCrumb(selValue, text -> { + setSelectedDirectory((FILE) selValue); + }); setSelectedDirectory((FILE) selValue); if (!((FILE) selValue).isDirectory()) { doOK(); @@ -566,7 +574,7 @@ public class FILEChooserPane extends BasicPane { } private void doCancel() { - this.locationBtnPane.setPopDir(null); + //this.locationBtnPane.setPopDir(null); dialogExit(); } @@ -1096,7 +1104,9 @@ public class FILEChooserPane extends BasicPane { } private void setTopPath(String path) { - this.locationBtnPane.setTopPath(path); + this.locationBreadcrumbPane.setRootButton(path, text -> { + //setSelectedDirectory(text); + }); } @@ -1161,8 +1171,6 @@ public class FILEChooserPane extends BasicPane { } currentDirectory = dir; - - this.locationBtnPane.populate(currentDirectory); this.mkdirButton.setEnabled(currentDirectory != null); refreshSubFileListModel(); From 6c7b869bd9b0bb29506b07a79066bdc647514d3e Mon Sep 17 00:00:00 2001 From: renekton Date: Fri, 9 Aug 2024 19:11:23 +0800 Subject: [PATCH 2/5] =?UTF-8?q?=E9=9D=A2=E5=8C=85=E5=B1=91=E7=BB=84?= =?UTF-8?q?=E4=BB=B6=E5=88=9D=E5=AE=9E=E7=8E=B0=EF=BC=8C=E8=87=AA=E5=8A=A8?= =?UTF-8?q?=E7=BC=A9=E6=94=BE=EF=BC=8C=E7=9B=AE=E5=BD=95=E6=81=A2=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../design/gui/frpane/FineBreadcrumbPane.java | 221 +++++++++++++++--- .../theme/TemplateThemeGridPagesPane.java | 23 +- .../java/com/fr/file/FILEChooserPane.java | 15 +- .../light/ui/laf/FineLightLaf.properties | 8 + 4 files changed, 214 insertions(+), 53 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/gui/frpane/FineBreadcrumbPane.java b/designer-base/src/main/java/com/fr/design/gui/frpane/FineBreadcrumbPane.java index 29313ca232..a633f7111c 100644 --- a/designer-base/src/main/java/com/fr/design/gui/frpane/FineBreadcrumbPane.java +++ b/designer-base/src/main/java/com/fr/design/gui/frpane/FineBreadcrumbPane.java @@ -3,17 +3,25 @@ package com.fr.design.gui.frpane; import com.fine.swing.ui.layout.Row; import com.fine.theme.utils.FineUIScale; import com.fine.theme.utils.FineUIStyle; +import com.fine.theme.utils.FineUIUtils; +import com.finebi.cbb.utils.StringUtils; import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.ilable.UILabel; import com.fr.file.FILE; import com.fr.general.ComparatorUtils; import javax.swing.BorderFactory; -import java.awt.Color; import java.awt.Component; import java.awt.Dimension; import java.awt.Insets; +import java.util.ArrayList; +import java.util.List; +/** + * @author Renekton + * @since 2024/08/08 + * @param + */ public class FineBreadcrumbPane extends Row { private static final int SEP_HEIGHT = 20; @@ -22,39 +30,119 @@ public class FineBreadcrumbPane extends Row { private static final int MAX_BUTTON_WIDTH = FineUIScale.scale(150); + private static final String DEFAULT_SEP = "/"; + private BreadcrumbButton currentCrumb; - public void setRootButton(T text, final BreadcrumbBackListener backListener) { - clear(); - currentCrumb = new BreadcrumbButton<>(getText(text), text); - add(currentCrumb); - final int index = getComponentCount(); - addBreadcrumbListener(currentCrumb, index, backListener); - repaint(); + private List breadcrumbs; + + private int componentWidth; + + private int hidingIndex; + private String sep; + + public FineBreadcrumbPane() { + this(DEFAULT_SEP); + } + + /** + * 可传入分隔符号 + */ + public FineBreadcrumbPane(String sep) { + this.sep = sep; + this.breadcrumbs = new ArrayList<>(); + this.componentWidth = 0; + this.hidingIndex = -1; } - public void addCrumb(final T text, final BreadcrumbBackListener backListener) { + /** + * 初始化节点 + * @param data 节点数据 + * @param backListener 节点点击关联动作 + */ + public void init(T data, final BreadcrumbBackListener backListener) { if (currentCrumb != null) { - if (text instanceof FILE) { - FILE file = (FILE) text; - if (ComparatorUtils.equals(currentCrumb.getContent(), file) || !file.isDirectory()) { - return; + return; + } + if (data instanceof FILE) { + FILE file = (FILE) data; + List files = new ArrayList<>(); + while (file != null) { + + if (StringUtils.isEmpty(file.getName())) { + break; } - if (file.getParent().equals(((FILE)currentCrumb.getContent()).getParent())) { - remove(currentCrumb); - currentCrumb = new BreadcrumbButton<>(getText(text), text); - final int index = getComponentCount(); - addBreadcrumbListener(currentCrumb, index, backListener); - repaint(); - return; + if (file.isDirectory()) { + files.add(file); } + file = file.getParent(); } + int size = files.size(); + currentCrumb = new BreadcrumbButton<>(getRootdata((T) files.get(size-1)), files.get(size-1)); + add(currentCrumb); + final int index = getComponentCount(); + addBreadcrumbListener(currentCrumb, index, backListener); + for (int i = size-2; i >= 0; i--) { + addCrumb((T) files.get(i), backListener); + } + } else if (data instanceof String) { + currentCrumb = new BreadcrumbButton<>(getRootdata(data), data); + add(currentCrumb); + final int index = getComponentCount(); + addBreadcrumbListener(currentCrumb, index, backListener); + } + repaint(); + + } + + /** + * 根节点重置 + * @param data 节点内容 + * @param backListener + */ + public void reset(T data, final BreadcrumbBackListener backListener) { + if (currentCrumb != null && ComparatorUtils.equals(data, currentCrumb.getContent())) { + return; + } + clear(); + init(data, backListener); + + } + + /** + * 添加节点 + * @param data + * @param backListener + */ + public void addCrumb(final T data, final BreadcrumbBackListener backListener) { + + if (currentCrumb != null) { currentCrumb.setSelected(false); - currentCrumb.setForeground(Color.GRAY); + currentCrumb.setForeground(FineUIUtils.getUIColor("Button.breadcrumbForeground", "Button.breadcrumbForeground")); add(createSeparator()); } - final BreadcrumbButton breadcrumb = createBreadcrumb(text); + final BreadcrumbButton breadcrumb = createBreadcrumb(data); + int currentWidth = componentWidth + breadcrumb.getPreferredSize().width; + if (this.getVisibleRect().width != 0 && currentWidth > this.getVisibleRect().width) { + // 大于可见宽度,隐藏前面的目录 + for (int i = hidingIndex+1; i < breadcrumbs.size(); i++) { + int width = breadcrumbs.get(i).getPreferredSize().width; + breadcrumbs.get(i).setVisible(false); + hidingIndex = i; + currentWidth -= width; + if (currentWidth < this.getVisibleRect().width) { + if (breadcrumbs.get(i+1) instanceof UILabel) { + breadcrumbs.get(i+1).setVisible(false); + hidingIndex = i+1; + componentWidth = currentWidth - breadcrumb.getPreferredSize().width - breadcrumbs.get(i+1).getPreferredSize().width; + } else { + componentWidth = currentWidth - breadcrumb.getPreferredSize().width; + } + break; + } + } + } add(breadcrumb); currentCrumb = breadcrumb; final int index = getComponentCount(); @@ -71,13 +159,30 @@ public class FineBreadcrumbPane extends Row { repaint(); } + @Override + public void remove(Component comp) { + componentWidth -= comp.getPreferredSize().getWidth(); + breadcrumbs.remove(comp); + super.remove(comp); + } + + @Override + public Component add(Component comp) { + componentWidth += comp.getPreferredSize().getWidth(); + breadcrumbs.add(comp); + return super.add(comp); + } + public void clear() { + removeAll(); currentCrumb = null; + componentWidth = 0; + breadcrumbs.clear(); } protected Component createSeparator() { - UILabel separator = new UILabel("/"); + UILabel separator = new UILabel(sep); separator.setBorder(BorderFactory.createEmptyBorder(0, 2, 0, 2)); separator.setPreferredSize(new Dimension(separator.getPreferredSize().width, FineUIScale.scale(SEP_HEIGHT))); @@ -85,18 +190,48 @@ public class FineBreadcrumbPane extends Row { } protected BreadcrumbButton createBreadcrumb(T content) { - BreadcrumbButton button = new BreadcrumbButton(getText(content), content); + BreadcrumbButton button = new BreadcrumbButton(getdata(content), content); button.setPreferredSize(new Dimension(Math.min(button.getPreferredSize().width, MAX_BUTTON_WIDTH), FineUIScale.scale(BUTTON_HEIGHT))); button.setSelected(true); - button.setForeground(Color.black); + button.setForeground(FineUIUtils.getUIColor("Button.breadcrumbSelectedForeground", "Button.breadcrumbSelectedForeground")); return button; } + /** + * 节点点击事件 + * @param breadcrumb + * @param index + * @param backListener + */ private void addBreadcrumbListener(BreadcrumbButton breadcrumb, int index, BreadcrumbBackListener backListener) { breadcrumb.addActionListener(e -> { removeTailCrumbs(index); + // 存在隐藏目录,弹出部分隐藏目录 + if (hidingIndex >= 0) { + int currentWidth = componentWidth; + for (int i = hidingIndex; i >= 0; i--) { + currentWidth += breadcrumbs.get(i).getPreferredSize().width; + if (currentWidth <= this.getVisibleRect().width) { + breadcrumbs.get(i).setVisible(true); + } else { + hidingIndex = i; + if (breadcrumbs.get(i+1) instanceof UILabel) { + currentWidth -= breadcrumbs.get(i+1).getPreferredSize().width; + breadcrumbs.get(i+1).setVisible(false); + hidingIndex = i+1; + } + componentWidth = currentWidth - breadcrumbs.get(i).getPreferredSize().width; + break; + } + } + if (currentWidth <= this.getVisibleRect().width) { + hidingIndex = -1; + componentWidth = currentWidth; + } + } + breadcrumb.setSelected(true); - breadcrumb.setForeground(Color.BLACK); + breadcrumb.setForeground(FineUIUtils.getUIColor("Button.breadcrumbSelectedForeground", "Button.breadcrumbSelectedForeground")); if (breadcrumb != currentCrumb) { currentCrumb = breadcrumb; } @@ -106,21 +241,36 @@ public class FineBreadcrumbPane extends Row { }); } - private String getText(T text) { - if (text instanceof String) { - return (String) text; - } else if (text instanceof FILE){ - return ((FILE)text).getName(); + private String getRootdata(T data) { + if (data instanceof String) { + return (String) data; + } else if (data instanceof FILE){ + FILE file = (FILE) data; + if (file.getPath().endsWith("/") || file.getPath().endsWith("\\")) { + return file.getPath().replaceAll("[/\\\\]+", ""); + } else if (file.getPath().contains("/") || file.getPath().contains("\\")) { + return file.getPath().replaceAll("[/\\\\]+", sep); + } + return ((FILE)data).getPath(); } - return (String) text; + return (String) data; + } + + private String getdata(T data) { + if (data instanceof String) { + return (String) data; + } else if (data instanceof FILE){ + return ((FILE)data).getName(); + } + return (String) data; } public static class BreadcrumbButton extends UIButton { private T content; - public BreadcrumbButton(String text, T content) { - super(text); + public BreadcrumbButton(String data, T content) { + super(data); BreadcrumbButton.this.content = content; setMargin(new Insets(0, 0, 0, 0)); setBorder(BorderFactory.createEmptyBorder()); @@ -148,6 +298,7 @@ public class FineBreadcrumbPane extends Row { } public interface BreadcrumbBackListener { - void onBreadcrumbBack(T text); + void onBreadcrumbBack(T data); } + } diff --git a/designer-base/src/main/java/com/fr/design/mainframe/theme/TemplateThemeGridPagesPane.java b/designer-base/src/main/java/com/fr/design/mainframe/theme/TemplateThemeGridPagesPane.java index 720e5db8bc..ee2322e602 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/theme/TemplateThemeGridPagesPane.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/theme/TemplateThemeGridPagesPane.java @@ -1,5 +1,6 @@ package com.fr.design.mainframe.theme; +import com.fine.theme.utils.FineUIScale; import com.fr.base.ScreenResolution; import com.fr.base.theme.FormTheme; import com.fr.base.theme.FormThemeConfig; @@ -21,6 +22,8 @@ import com.fr.design.mainframe.JTemplate; import com.fr.design.mainframe.theme.dialog.TemplateThemeDialog; import com.fr.design.mainframe.theme.provider.ThemeManageActionProvider; import com.fr.design.mainframe.theme.ui.BreadcrumbBar; +import com.fr.file.FILE; +import com.fr.general.ComparatorUtils; import com.fr.stable.ArrayUtils; import com.fr.stable.unit.FU; import com.fr.third.javax.annotation.Nullable; @@ -36,6 +39,7 @@ import java.awt.CardLayout; import java.awt.Color; import java.awt.Component; import java.awt.Container; +import java.awt.Dimension; import java.awt.Graphics; import java.awt.Graphics2D; import java.awt.RenderingHints; @@ -77,7 +81,7 @@ public class TemplateThemeGridPagesPane extends JPanel { setBorder(BorderFactory.createEmptyBorder(10, 10, 0, 10)); breadcrumbBar = new FineBreadcrumbPane(); - breadcrumbBar.setBorder(BorderFactory.createEmptyBorder(0, 0, 10, 0)); + breadcrumbBar.setPreferredSize(new Dimension(this.getPreferredSize().width, FineUIScale.scale(20))); add(breadcrumbBar, BorderLayout.NORTH); contentPane = new JPanel(); @@ -105,13 +109,14 @@ public class TemplateThemeGridPagesPane extends JPanel { pageChangeListener.onPageChangeListener(); } breadcrumbBar.clear(); - breadcrumbBar.addCrumb(themeUsingPane.getTitle(), text -> { - cardLayout.show(contentPane, themeUsingPane.getTitle()); - currentTemplateThemeGridPagePane = themeUsingPane; - if (pageChangeListener != null) { - pageChangeListener.onPageChangeListener(); - } - }); + breadcrumbBar.addCrumb(themeUsingPane.getTitle(), + data -> { + cardLayout.show(contentPane, themeUsingPane.getTitle()); + currentTemplateThemeGridPagePane = themeUsingPane; + if (pageChangeListener != null) { + pageChangeListener.onPageChangeListener(); + } + }); } } @@ -122,7 +127,7 @@ public class TemplateThemeGridPagesPane extends JPanel { if (pageChangeListener != null) { pageChangeListener.onPageChangeListener(); } - breadcrumbBar.addCrumb(themeManagingPane.getTitle(), null); + breadcrumbBar.addCrumb(themeManagingPane.getTitle(),null); } } diff --git a/designer-base/src/main/java/com/fr/file/FILEChooserPane.java b/designer-base/src/main/java/com/fr/file/FILEChooserPane.java index 023d7d2854..0d35aa843d 100644 --- a/designer-base/src/main/java/com/fr/file/FILEChooserPane.java +++ b/designer-base/src/main/java/com/fr/file/FILEChooserPane.java @@ -350,9 +350,7 @@ public class FILEChooserPane extends BasicPane { Object selValue = placesList.getSelectedValue(); if (selValue instanceof FILE) { setSelectedDirectory((FILE) selValue); - locationBreadcrumbPane.setRootButton(selValue, text -> { - setSelectedDirectory((FILE) selValue); - }); + locationBreadcrumbPane.reset(selValue, data -> setSelectedDirectory((FILE) data)); } } }); @@ -365,6 +363,7 @@ public class FILEChooserPane extends BasicPane { Object selValue = placesList.getSelectedValue(); if (selValue instanceof FILE) { setSelectedDirectory((FILE) selValue); + locationBreadcrumbPane.reset(selValue, data -> setSelectedDirectory((FILE) data)); } } }); @@ -423,9 +422,8 @@ public class FILEChooserPane extends BasicPane { setFileTextField((FILE) selValue); fileNameTextField.addDocumentListener(); } else { - locationBreadcrumbPane.addCrumb(selValue, text -> { - setSelectedDirectory((FILE) selValue); - }); + locationBreadcrumbPane.addCrumb(selValue, + data -> setSelectedDirectory((FILE) data)); setSelectedDirectory((FILE) selValue); if (!((FILE) selValue).isDirectory()) { doOK(); @@ -1104,9 +1102,7 @@ public class FILEChooserPane extends BasicPane { } private void setTopPath(String path) { - this.locationBreadcrumbPane.setRootButton(path, text -> { - //setSelectedDirectory(text); - }); + this.locationBreadcrumbPane.init(path, null); } @@ -1160,6 +1156,7 @@ public class FILEChooserPane extends BasicPane { } setSelectedDirectory(dir); + locationBreadcrumbPane.reset(dir, text -> setSelectedDirectory((FILE) text)); } /* diff --git a/designer-base/src/main/resources/com/fine/theme/light/ui/laf/FineLightLaf.properties b/designer-base/src/main/resources/com/fine/theme/light/ui/laf/FineLightLaf.properties index 35bc2aa9fe..26ee4ddebd 100644 --- a/designer-base/src/main/resources/com/fine/theme/light/ui/laf/FineLightLaf.properties +++ b/designer-base/src/main/resources/com/fine/theme/light/ui/laf/FineLightLaf.properties @@ -1189,6 +1189,9 @@ Center.arc=10 #---- CellOtherSetPane ---- CellOtherSetPane.height=$Component.defaultHeight +Button.breadcrumbForeground = #8F999F +Button.breadcrumbSelectedForeground = #000000 + #---- Styles ------------------------------------------------------------------ #---- inTextField ---- @@ -1343,3 +1346,8 @@ CellOtherSetPane.height=$Component.defaultHeight background: null;\ track: fade(@background, 0%); \ hoverTrackColor : fade(@background, 0%) + +[style]Button.breadcrumbButton = \ + background: null;\ + foreground: null; \ + From 2882415a331d2b9cb200b7981e3d2c573a123378 Mon Sep 17 00:00:00 2001 From: renekton Date: Fri, 9 Aug 2024 19:48:37 +0800 Subject: [PATCH 3/5] =?UTF-8?q?=E5=A2=9E=E5=8A=A0buttonUI=E6=82=AC?= =?UTF-8?q?=E6=B5=AE=E8=83=8C=E6=99=AF=E5=92=8C=E7=82=B9=E5=87=BB=E8=83=8C?= =?UTF-8?q?=E6=99=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/com/fine/theme/utils/FineUIStyle.java | 1 + .../java/com/fr/design/gui/frpane/FineBreadcrumbPane.java | 8 +++++++- .../com/fine/theme/light/ui/laf/FineLightLaf.properties | 6 ++++-- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/designer-base/src/main/java/com/fine/theme/utils/FineUIStyle.java b/designer-base/src/main/java/com/fine/theme/utils/FineUIStyle.java index d2b64bea31..e85aff674a 100644 --- a/designer-base/src/main/java/com/fine/theme/utils/FineUIStyle.java +++ b/designer-base/src/main/java/com/fine/theme/utils/FineUIStyle.java @@ -42,6 +42,7 @@ public interface FineUIStyle { String PURE_LIST = "pureList"; String PURE_TREE = "pureTree"; String PASTEL_BUTTON = "pastelButton"; + String BREADCRUMB_BUTTON = "breadcrumbButton"; /** diff --git a/designer-base/src/main/java/com/fr/design/gui/frpane/FineBreadcrumbPane.java b/designer-base/src/main/java/com/fr/design/gui/frpane/FineBreadcrumbPane.java index a633f7111c..f95a699510 100644 --- a/designer-base/src/main/java/com/fr/design/gui/frpane/FineBreadcrumbPane.java +++ b/designer-base/src/main/java/com/fr/design/gui/frpane/FineBreadcrumbPane.java @@ -81,6 +81,8 @@ public class FineBreadcrumbPane extends Row { int size = files.size(); currentCrumb = new BreadcrumbButton<>(getRootdata((T) files.get(size-1)), files.get(size-1)); add(currentCrumb); + currentCrumb.setSelected(true); + currentCrumb.setForeground(FineUIUtils.getUIColor("Button.breadcrumbSelectedForeground", "Button.breadcrumbSelectedForeground")); final int index = getComponentCount(); addBreadcrumbListener(currentCrumb, index, backListener); for (int i = size-2; i >= 0; i--) { @@ -274,7 +276,7 @@ public class FineBreadcrumbPane extends Row { BreadcrumbButton.this.content = content; setMargin(new Insets(0, 0, 0, 0)); setBorder(BorderFactory.createEmptyBorder()); - FineUIStyle.setStyle(BreadcrumbButton.this, FineUIStyle.PLAIN_BUTTON); + FineUIStyle.setStyle(BreadcrumbButton.this, FineUIStyle.BREADCRUMB_BUTTON); setBorderPainted(false); setOpaque(false); } @@ -297,6 +299,10 @@ public class FineBreadcrumbPane extends Row { } } + /** + * 节点点击关联动作监听器 + * @param + */ public interface BreadcrumbBackListener { void onBreadcrumbBack(T data); } diff --git a/designer-base/src/main/resources/com/fine/theme/light/ui/laf/FineLightLaf.properties b/designer-base/src/main/resources/com/fine/theme/light/ui/laf/FineLightLaf.properties index 26ee4ddebd..4a5fb7d79a 100644 --- a/designer-base/src/main/resources/com/fine/theme/light/ui/laf/FineLightLaf.properties +++ b/designer-base/src/main/resources/com/fine/theme/light/ui/laf/FineLightLaf.properties @@ -1349,5 +1349,7 @@ Button.breadcrumbSelectedForeground = #000000 [style]Button.breadcrumbButton = \ background: null;\ - foreground: null; \ - + foreground: #8F999F; \ + hoverBackground: #E6E9EF; \ + pressedBackground: #DADEE7; \ + selectedBackground: null From 8d5731c6a75d8a7a5c21d90dffb325aa641b046d Mon Sep 17 00:00:00 2001 From: renekton Date: Mon, 12 Aug 2024 18:05:09 +0800 Subject: [PATCH 4/5] =?UTF-8?q?popupMenuUI=E9=87=8D=E5=86=99=EF=BC=8C?= =?UTF-8?q?=E6=B2=A1icon=E5=8E=BB=E9=99=A4icon=E7=BB=98=E7=94=BB=EF=BC=9B?= =?UTF-8?q?=E6=82=AC=E6=B5=AE=E5=85=83=E7=B4=A0=E6=82=AC=E6=B5=AE=E8=89=B2?= =?UTF-8?q?/=E8=BE=B9=E6=A1=86=E5=A2=9E=E5=8A=A0=EF=BC=8C=E9=97=B4?= =?UTF-8?q?=E8=B7=9D=E8=B0=83=E6=95=B4=E7=AD=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fine/theme/light/ui/FineMenuItemUI.java | 37 +++++++++++++++++++ .../design/gui/frpane/HyperlinkGroupPane.java | 24 ++++++++++++ .../design/gui/icombobox/FRTreeComboBox.java | 5 ++- .../design/gui/imenu/UIMenuEastAttrItem.java | 2 +- .../component/NumberEditorValidatePane.java | 10 ++--- .../light/ui/laf/FineLightLaf.properties | 4 ++ .../chart/gui/type/ChartImagePane.java | 13 ++++--- .../fr/design/mainframe/AbstractAttrPane.java | 5 ++- .../fr/design/mainframe/ReportFloatPane.java | 2 +- .../floatquick/FloatStringQuickEditor.java | 2 +- 10 files changed, 86 insertions(+), 18 deletions(-) diff --git a/designer-base/src/main/java/com/fine/theme/light/ui/FineMenuItemUI.java b/designer-base/src/main/java/com/fine/theme/light/ui/FineMenuItemUI.java index 4e47d1587e..615a44f581 100644 --- a/designer-base/src/main/java/com/fine/theme/light/ui/FineMenuItemUI.java +++ b/designer-base/src/main/java/com/fine/theme/light/ui/FineMenuItemUI.java @@ -2,11 +2,19 @@ package com.fine.theme.light.ui; import com.fine.theme.icon.LazyIcon; import com.fine.theme.utils.FineClientProperties; +import com.formdev.flatlaf.ui.FlatMenuItemRenderer; import com.formdev.flatlaf.ui.FlatMenuItemUI; +import javax.swing.Icon; import javax.swing.JComponent; +import javax.swing.JMenuItem; import javax.swing.plaf.ComponentUI; +import java.awt.Color; + +import java.awt.Font; + import java.awt.Graphics; +import java.awt.Rectangle; /** * menuItem UI类 @@ -29,6 +37,11 @@ public class FineMenuItemUI extends FlatMenuItemUI { return new FineMenuItemUI(); } + @Override + protected FlatMenuItemRenderer createRenderer() { + return new FineMenuItemRenderer(menuItem, checkIcon, arrowIcon, acceleratorFont, acceleratorDelimiter); + } + @Override public void paint(Graphics g, JComponent c) { super.paint(g, c); @@ -40,4 +53,28 @@ public class FineMenuItemUI extends FlatMenuItemUI { icon.paintIcon(c, g, c.getWidth() - rightMargin - iconSize, (c.getHeight() - iconSize) / 2); } } + + static class FineMenuItemRenderer extends FlatMenuItemRenderer { + protected FineMenuItemRenderer(JMenuItem menuItem, Icon checkIcon, Icon arrowIcon, + Font acceleratorFont, String acceleratorDelimiter ) + { + super(menuItem, checkIcon, arrowIcon, acceleratorFont, acceleratorDelimiter); + } + + @Override + protected void paintText( Graphics g, Rectangle textRect, String text, Color selectionForeground, Color disabledForeground ) { + if (!isTopLevelMenu(menuItem) && menuItem.getIcon() == null) { + textRect.x -= minimumIconSize.width; + } + super.paintText(g, textRect, text, selectionForeground, disabledForeground); + } + + @Override + protected void paintIcon(Graphics g, Rectangle iconRect, Icon icon, Color checkBackground, Color selectionBackground) { + if (menuItem.getIcon() != null) { + super.paintIcon(g, iconRect, icon, checkBackground, selectionBackground); + } + } + + } } diff --git a/designer-base/src/main/java/com/fr/design/gui/frpane/HyperlinkGroupPane.java b/designer-base/src/main/java/com/fr/design/gui/frpane/HyperlinkGroupPane.java index 0a8e4769a9..979c3f973f 100644 --- a/designer-base/src/main/java/com/fr/design/gui/frpane/HyperlinkGroupPane.java +++ b/designer-base/src/main/java/com/fr/design/gui/frpane/HyperlinkGroupPane.java @@ -1,12 +1,17 @@ package com.fr.design.gui.frpane; +import com.fine.theme.utils.FineUIScale; +import com.formdev.flatlaf.ui.FlatUIUtils; import com.fr.design.ExtraDesignClassManager; +import com.fr.design.border.FineBorderFactory; import com.fr.design.designer.TargetComponent; import com.fr.design.file.HistoryTemplateListCache; import com.fr.design.fun.HyperlinkProvider; import com.fr.design.gui.controlpane.NameableCreator; import com.fr.design.gui.controlpane.UIListControlPane; +import com.fr.design.gui.itoolbar.UIToolbar; import com.fr.design.module.DesignModuleFactory; +import com.fr.design.widget.FRWidgetFactory; import com.fr.general.GeneralContext; import com.fr.general.NameObject; @@ -20,10 +25,16 @@ import com.fr.plugin.observer.PluginEventListener; import com.fr.stable.ListMap; import com.fr.stable.Nameable; +import javax.swing.JPanel; +import java.awt.Color; +import java.awt.Dimension; import java.util.ArrayList; import java.util.Map; import java.util.Set; +import static com.fine.swing.ui.layout.Layouts.cell; +import static com.fine.swing.ui.layout.Layouts.row; + /** * 超级链接 界面. * @@ -91,6 +102,19 @@ public abstract class HyperlinkGroupPane extends UIListControlPane { return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Add_Hyperlink"); } + @Override + protected JPanel getLeftTopPane(UIToolbar topToolBar) { + return row(10, + cell(FRWidgetFactory.createLineWrapLabel(getAddItemText())), + cell(topToolBar).with(it -> { + it.setPreferredSize(new Dimension(0, FineUIScale.scale(24))); + it.setBorderPainted(true); + it.setBorder(FineBorderFactory.createWrappedRoundBorder()); + it.setBackground(FlatUIUtils.getUIColor("fill.normal", Color.WHITE)); + }).weight(1.0) + ).getComponent(); + } + public void populate(NameJavaScriptGroup hyperlinkArray) { java.util.List list = new ArrayList<>(); if (hyperlinkArray != null) { diff --git a/designer-base/src/main/java/com/fr/design/gui/icombobox/FRTreeComboBox.java b/designer-base/src/main/java/com/fr/design/gui/icombobox/FRTreeComboBox.java index bec751e26a..6f8589a104 100644 --- a/designer-base/src/main/java/com/fr/design/gui/icombobox/FRTreeComboBox.java +++ b/designer-base/src/main/java/com/fr/design/gui/icombobox/FRTreeComboBox.java @@ -21,6 +21,7 @@ import javax.swing.JScrollPane; import javax.swing.JTree; import javax.swing.MenuSelectionManager; import javax.swing.SwingUtilities; +import javax.swing.UIManager; import javax.swing.event.DocumentEvent; import javax.swing.event.DocumentListener; import javax.swing.event.PopupMenuListener; @@ -358,7 +359,9 @@ public class FRTreeComboBox extends UIComboBox { public TreePopup(JComboBox comboBox) { this.comboBox = (FRTreeComboBox) comboBox; - this.setBorder(BorderFactory.createLineBorder(Color.black)); + this.setBackground(UIManager.getColor("PopupMenu.background")); + + this.setBorder(UIManager.getBorder( "PopupMenu.border" )); this.setLayout(FRGUIPaneFactory.createBorderLayout()); this.setLightWeightPopupEnabled(comboBox .isLightWeightPopupEnabled()); diff --git a/designer-base/src/main/java/com/fr/design/gui/imenu/UIMenuEastAttrItem.java b/designer-base/src/main/java/com/fr/design/gui/imenu/UIMenuEastAttrItem.java index 78f0ae06fa..e85284c717 100644 --- a/designer-base/src/main/java/com/fr/design/gui/imenu/UIMenuEastAttrItem.java +++ b/designer-base/src/main/java/com/fr/design/gui/imenu/UIMenuEastAttrItem.java @@ -43,7 +43,7 @@ public class UIMenuEastAttrItem extends JMenuItem { @Override public String getText() { - return StringUtils.BLANK + super.getText(); + return super.getText(); } private class UIMenuItemEastAttrUI extends BasicMenuItemUI { diff --git a/designer-base/src/main/java/com/fr/design/widget/component/NumberEditorValidatePane.java b/designer-base/src/main/java/com/fr/design/widget/component/NumberEditorValidatePane.java index 3bd408b90c..38cc90db87 100644 --- a/designer-base/src/main/java/com/fr/design/widget/component/NumberEditorValidatePane.java +++ b/designer-base/src/main/java/com/fr/design/widget/component/NumberEditorValidatePane.java @@ -70,12 +70,10 @@ public class NumberEditorValidatePane extends JPanel { this.allowNegativeCheckBox.addActionListener(allowNegativeListener); this.setMaxValueCheckBox = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Need_Max_Value"), false); this.maxValueSpinner = new UISpinner(-Double.MAX_VALUE, Double.MAX_VALUE, 1D, 0D); - this.maxValueSpinner.setSize(this.decimalLength.getSize()); this.setMaxValueCheckBox.addActionListener(setMaxListener); this.maxValueSpinner.addChangeListener(maxValueChangeListener); this.setMinValueCheckBox = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Need_Min_Value"), false); this.minValueSpinner = new UISpinner(-Double.MAX_VALUE, Double.MAX_VALUE, 1D, 0D); - this.minValueSpinner.setSize(this.decimalLength.getSize()); this.setMinValueCheckBox.addActionListener(setMinListener); this.minValueSpinner.addChangeListener(minValueChangeListener); initErrorMsgPane(); @@ -92,11 +90,11 @@ public class NumberEditorValidatePane extends JPanel { cell(allowDecimalsCheckBox), cell(limitNumberPane), cell(allowNegativeCheckBox), - row( - cell(setMaxValueCheckBox).weight(1.2), cell(maxValueSpinner).weight(3) + row(10, + cell(setMaxValueCheckBox).weight(1.8), cell(maxValueSpinner).weight(3) ), - row( - cell(setMinValueCheckBox).weight(1.2), cell(minValueSpinner).weight(3) + row(10, + cell(setMinValueCheckBox).weight(1.8), cell(minValueSpinner).weight(3) ), cell(errorMsgBorderPane) ).getComponent()); diff --git a/designer-base/src/main/resources/com/fine/theme/light/ui/laf/FineLightLaf.properties b/designer-base/src/main/resources/com/fine/theme/light/ui/laf/FineLightLaf.properties index 4a5fb7d79a..2cdcc0d096 100644 --- a/designer-base/src/main/resources/com/fine/theme/light/ui/laf/FineLightLaf.properties +++ b/designer-base/src/main/resources/com/fine/theme/light/ui/laf/FineLightLaf.properties @@ -1192,6 +1192,10 @@ CellOtherSetPane.height=$Component.defaultHeight Button.breadcrumbForeground = #8F999F Button.breadcrumbSelectedForeground = #000000 +chart.normalBorderColor = #DADEE7 +chart.hoverBorderColor = #2576EF +chart.selectedBorderColor = #2576EF + #---- Styles ------------------------------------------------------------------ #---- inTextField ---- diff --git a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/type/ChartImagePane.java b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/type/ChartImagePane.java index e150466ecc..5bbea51697 100644 --- a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/type/ChartImagePane.java +++ b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/type/ChartImagePane.java @@ -1,5 +1,7 @@ package com.fr.design.mainframe.chart.gui.type; +import com.fine.theme.utils.FineUIStyle; +import com.fine.theme.utils.FineUIUtils; import com.fr.design.chart.series.PlotStyle.ChartSelectDemoPane; import com.fr.design.constants.UIConstants; import com.fr.design.gui.ilable.UILabel; @@ -19,7 +21,6 @@ public class ChartImagePane extends ChartSelectDemoPane { private static final long serialVersionUID = -2785128245790568603L; private static final int IMAGE_WIDTH = 56; private static final int IMAGE_HIGTH = 50; - private static final Color ENTER_COLOR = new Color(216, 242, 253); private boolean isDrawRightLine = false; public boolean isDoubleClicked = false; @@ -30,7 +31,7 @@ public class ChartImagePane extends ChartSelectDemoPane { addMouseListener(this); this.setToolTipText(tipName); - this.setBorder(BorderFactory.createMatteBorder(0, 0, 0, isDrawRightLine ? 1 : 0, UIConstants.SELECT_TAB)); + this.setBorder(BorderFactory.createMatteBorder(0, 0, 0, isDrawRightLine ? 1 : 0, FineUIUtils.getUIColor("chart.normalBorderColor", "chart.normalBorderColor"))); this.setBackground(UIConstants.TOOLBARUI_BACKGROUND); this.setPreferredSize(getScaledDimension()); } @@ -58,7 +59,7 @@ public class ChartImagePane extends ChartSelectDemoPane { this.setToolTipText(tipName); - this.setBorder(BorderFactory.createMatteBorder(0, 0, 0, isDrawRightLine ? 1 : 0, UIConstants.SELECT_TAB)); + this.setBorder(BorderFactory.createMatteBorder(0, 0, 0, isDrawRightLine ? 1 : 0, FineUIUtils.getUIColor("chart.normalBorderColor", "chart.normalBorderColor"))); this.setBackground(UIConstants.TOOLBARUI_BACKGROUND); this.setPreferredSize(getScaledDimension()); @@ -87,11 +88,11 @@ public class ChartImagePane extends ChartSelectDemoPane { */ public void checkBorder() { if (!isRollOver && !isPressing) { - this.setBorder(BorderFactory.createMatteBorder(0, 0, 0, isDrawRightLine ? 1 : 0, UIConstants.SELECT_TAB)); + this.setBorder(BorderFactory.createMatteBorder(1, 1, 1, isDrawRightLine ? 1 : 0, FineUIUtils.getUIColor("chart.normalBorderColor", "chart.normalBorderColor"))); } else if (isRollOver && !isPressing) { - this.setBorder(BorderFactory.createMatteBorder(2, 2, 2, 2, ENTER_COLOR)); + this.setBorder(BorderFactory.createMatteBorder(1, 1, 1, 1, FineUIUtils.getUIColor("chart.hoverBorderColor", "chart.hoverBorderColor"))); } else { - this.setBorder(BorderFactory.createMatteBorder(2, 2, 2, 2, UIConstants.FLESH_BLUE)); + this.setBorder(BorderFactory.createMatteBorder(2, 2, 2, 2, FineUIUtils.getUIColor("chart.selectedBorderColor", "chart.selectedBorderColor"))); } } diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/AbstractAttrPane.java b/designer-realize/src/main/java/com/fr/design/mainframe/AbstractAttrPane.java index ea888a0b6f..b6bd0f164b 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/AbstractAttrPane.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/AbstractAttrPane.java @@ -96,10 +96,11 @@ public abstract class AbstractAttrPane extends AbstractAttrNoScrollPane { public void layoutContainer(Container parent) { maxHeight = getMaxHeight(); int beginY = 0; - if ((MAXVALUE - scrollBar.getVisibleAmount()) != 0) { + int len = MAXVALUE - scrollBar.getVisibleAmount(); + if (len != 0) { int preferredHeight = leftContentPane.getPreferredSize().height; int value = scrollBar.getValue(); - beginY = value * (preferredHeight - maxHeight) / (MAXVALUE - scrollBar.getVisibleAmount()); + beginY = value * (preferredHeight - maxHeight) / len; } int width = parent.getWidth(); int height = parent.getHeight(); diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/ReportFloatPane.java b/designer-realize/src/main/java/com/fr/design/mainframe/ReportFloatPane.java index 2c4b48106b..0a33581c93 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/ReportFloatPane.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/ReportFloatPane.java @@ -49,7 +49,7 @@ public class ReportFloatPane extends Column { } private void initComponent() { - setBorder(new ScaledEmptyBorder(10, 10, 10, 10)); + setBorder(new ScaledEmptyBorder(10, 10, 0, 10)); setSpacing(10); initInsertToolBar(); this.add( diff --git a/designer-realize/src/main/java/com/fr/quickeditor/floatquick/FloatStringQuickEditor.java b/designer-realize/src/main/java/com/fr/quickeditor/floatquick/FloatStringQuickEditor.java index 06d9380b54..2e67822760 100644 --- a/designer-realize/src/main/java/com/fr/quickeditor/floatquick/FloatStringQuickEditor.java +++ b/designer-realize/src/main/java/com/fr/quickeditor/floatquick/FloatStringQuickEditor.java @@ -59,7 +59,7 @@ public class FloatStringQuickEditor extends FloatQuickEditor { formulaButton.setVisible(false); this.setLayout(new BorderLayout()); this.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); - add(row(10, + add(row(4, cell(stringTextField).weight(1), cell(formulaButton) ).getComponent(), BorderLayout.NORTH); From 5cc3e4ffacf4837cc473fac8f0cfae112319d4a8 Mon Sep 17 00:00:00 2001 From: renekton Date: Mon, 12 Aug 2024 19:03:54 +0800 Subject: [PATCH 5/5] =?UTF-8?q?popupMenuUI=E9=87=8D=E5=86=99=EF=BC=8C?= =?UTF-8?q?=E6=B2=A1icon=E5=8E=BB=E9=99=A4icon=E7=BB=98=E7=94=BB=EF=BC=9B?= =?UTF-8?q?=E6=82=AC=E6=B5=AE=E5=85=83=E7=B4=A0=E6=82=AC=E6=B5=AE=E8=89=B2?= =?UTF-8?q?/=E8=BE=B9=E6=A1=86=E5=A2=9E=E5=8A=A0=EF=BC=8C=E9=97=B4?= =?UTF-8?q?=E8=B7=9D=E8=B0=83=E6=95=B4=E7=AD=89=EF=BC=9B=E8=8B=B1=E6=96=87?= =?UTF-8?q?=E7=89=88=E6=9C=AC=E5=90=AF=E5=8A=A8=E5=A4=B1=E8=B4=A5=E4=BF=AE?= =?UTF-8?q?=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../design/gui/frpane/FineBreadcrumbPane.java | 310 ------------------ .../theme/TemplateThemeGridPagesPane.java | 31 +- .../java/com/fr/file/FILEChooserPane.java | 15 +- 3 files changed, 19 insertions(+), 337 deletions(-) delete mode 100644 designer-base/src/main/java/com/fr/design/gui/frpane/FineBreadcrumbPane.java diff --git a/designer-base/src/main/java/com/fr/design/gui/frpane/FineBreadcrumbPane.java b/designer-base/src/main/java/com/fr/design/gui/frpane/FineBreadcrumbPane.java deleted file mode 100644 index f95a699510..0000000000 --- a/designer-base/src/main/java/com/fr/design/gui/frpane/FineBreadcrumbPane.java +++ /dev/null @@ -1,310 +0,0 @@ -package com.fr.design.gui.frpane; - -import com.fine.swing.ui.layout.Row; -import com.fine.theme.utils.FineUIScale; -import com.fine.theme.utils.FineUIStyle; -import com.fine.theme.utils.FineUIUtils; -import com.finebi.cbb.utils.StringUtils; -import com.fr.design.gui.ibutton.UIButton; -import com.fr.design.gui.ilable.UILabel; -import com.fr.file.FILE; -import com.fr.general.ComparatorUtils; - -import javax.swing.BorderFactory; -import java.awt.Component; -import java.awt.Dimension; -import java.awt.Insets; -import java.util.ArrayList; -import java.util.List; - -/** - * @author Renekton - * @since 2024/08/08 - * @param - */ -public class FineBreadcrumbPane extends Row { - - private static final int SEP_HEIGHT = 20; - - private static final int BUTTON_HEIGHT = 20; - - private static final int MAX_BUTTON_WIDTH = FineUIScale.scale(150); - - private static final String DEFAULT_SEP = "/"; - - private BreadcrumbButton currentCrumb; - - private List breadcrumbs; - - private int componentWidth; - - private int hidingIndex; - - private String sep; - - public FineBreadcrumbPane() { - this(DEFAULT_SEP); - } - - /** - * 可传入分隔符号 - */ - public FineBreadcrumbPane(String sep) { - this.sep = sep; - this.breadcrumbs = new ArrayList<>(); - this.componentWidth = 0; - this.hidingIndex = -1; - } - - /** - * 初始化节点 - * @param data 节点数据 - * @param backListener 节点点击关联动作 - */ - public void init(T data, final BreadcrumbBackListener backListener) { - if (currentCrumb != null) { - return; - } - if (data instanceof FILE) { - FILE file = (FILE) data; - List files = new ArrayList<>(); - while (file != null) { - - if (StringUtils.isEmpty(file.getName())) { - break; - } - if (file.isDirectory()) { - files.add(file); - } - file = file.getParent(); - } - int size = files.size(); - currentCrumb = new BreadcrumbButton<>(getRootdata((T) files.get(size-1)), files.get(size-1)); - add(currentCrumb); - currentCrumb.setSelected(true); - currentCrumb.setForeground(FineUIUtils.getUIColor("Button.breadcrumbSelectedForeground", "Button.breadcrumbSelectedForeground")); - final int index = getComponentCount(); - addBreadcrumbListener(currentCrumb, index, backListener); - for (int i = size-2; i >= 0; i--) { - addCrumb((T) files.get(i), backListener); - } - } else if (data instanceof String) { - currentCrumb = new BreadcrumbButton<>(getRootdata(data), data); - add(currentCrumb); - final int index = getComponentCount(); - addBreadcrumbListener(currentCrumb, index, backListener); - } - repaint(); - - } - - /** - * 根节点重置 - * @param data 节点内容 - * @param backListener - */ - public void reset(T data, final BreadcrumbBackListener backListener) { - if (currentCrumb != null && ComparatorUtils.equals(data, currentCrumb.getContent())) { - return; - } - clear(); - init(data, backListener); - - } - - /** - * 添加节点 - * @param data - * @param backListener - */ - public void addCrumb(final T data, final BreadcrumbBackListener backListener) { - - if (currentCrumb != null) { - currentCrumb.setSelected(false); - currentCrumb.setForeground(FineUIUtils.getUIColor("Button.breadcrumbForeground", "Button.breadcrumbForeground")); - add(createSeparator()); - } - final BreadcrumbButton breadcrumb = createBreadcrumb(data); - int currentWidth = componentWidth + breadcrumb.getPreferredSize().width; - if (this.getVisibleRect().width != 0 && currentWidth > this.getVisibleRect().width) { - // 大于可见宽度,隐藏前面的目录 - for (int i = hidingIndex+1; i < breadcrumbs.size(); i++) { - int width = breadcrumbs.get(i).getPreferredSize().width; - breadcrumbs.get(i).setVisible(false); - hidingIndex = i; - currentWidth -= width; - if (currentWidth < this.getVisibleRect().width) { - if (breadcrumbs.get(i+1) instanceof UILabel) { - breadcrumbs.get(i+1).setVisible(false); - hidingIndex = i+1; - componentWidth = currentWidth - breadcrumb.getPreferredSize().width - breadcrumbs.get(i+1).getPreferredSize().width; - } else { - componentWidth = currentWidth - breadcrumb.getPreferredSize().width; - } - break; - } - } - } - add(breadcrumb); - currentCrumb = breadcrumb; - final int index = getComponentCount(); - addBreadcrumbListener(breadcrumb, index, backListener); - } - - private void removeTailCrumbs(int from) { - Component[] components = getComponents(); - for (int i = from; i < components.length; i++) { - remove(components[i]); - } - currentCrumb = (BreadcrumbButton) components[from-1]; - revalidate(); - repaint(); - } - - @Override - public void remove(Component comp) { - componentWidth -= comp.getPreferredSize().getWidth(); - breadcrumbs.remove(comp); - super.remove(comp); - } - - @Override - public Component add(Component comp) { - componentWidth += comp.getPreferredSize().getWidth(); - breadcrumbs.add(comp); - return super.add(comp); - } - - public void clear() { - - removeAll(); - currentCrumb = null; - componentWidth = 0; - breadcrumbs.clear(); - } - - protected Component createSeparator() { - UILabel separator = new UILabel(sep); - separator.setBorder(BorderFactory.createEmptyBorder(0, 2, 0, 2)); - separator.setPreferredSize(new Dimension(separator.getPreferredSize().width, FineUIScale.scale(SEP_HEIGHT))); - - return separator; - } - - protected BreadcrumbButton createBreadcrumb(T content) { - BreadcrumbButton button = new BreadcrumbButton(getdata(content), content); - button.setPreferredSize(new Dimension(Math.min(button.getPreferredSize().width, MAX_BUTTON_WIDTH), FineUIScale.scale(BUTTON_HEIGHT))); - button.setSelected(true); - button.setForeground(FineUIUtils.getUIColor("Button.breadcrumbSelectedForeground", "Button.breadcrumbSelectedForeground")); - return button; - } - - /** - * 节点点击事件 - * @param breadcrumb - * @param index - * @param backListener - */ - private void addBreadcrumbListener(BreadcrumbButton breadcrumb, int index, BreadcrumbBackListener backListener) { - breadcrumb.addActionListener(e -> { - removeTailCrumbs(index); - // 存在隐藏目录,弹出部分隐藏目录 - if (hidingIndex >= 0) { - int currentWidth = componentWidth; - for (int i = hidingIndex; i >= 0; i--) { - currentWidth += breadcrumbs.get(i).getPreferredSize().width; - if (currentWidth <= this.getVisibleRect().width) { - breadcrumbs.get(i).setVisible(true); - } else { - hidingIndex = i; - if (breadcrumbs.get(i+1) instanceof UILabel) { - currentWidth -= breadcrumbs.get(i+1).getPreferredSize().width; - breadcrumbs.get(i+1).setVisible(false); - hidingIndex = i+1; - } - componentWidth = currentWidth - breadcrumbs.get(i).getPreferredSize().width; - break; - } - } - if (currentWidth <= this.getVisibleRect().width) { - hidingIndex = -1; - componentWidth = currentWidth; - } - } - - breadcrumb.setSelected(true); - breadcrumb.setForeground(FineUIUtils.getUIColor("Button.breadcrumbSelectedForeground", "Button.breadcrumbSelectedForeground")); - if (breadcrumb != currentCrumb) { - currentCrumb = breadcrumb; - } - if (backListener != null) { - backListener.onBreadcrumbBack(breadcrumb.getContent()); - } - }); - } - - private String getRootdata(T data) { - if (data instanceof String) { - return (String) data; - } else if (data instanceof FILE){ - FILE file = (FILE) data; - if (file.getPath().endsWith("/") || file.getPath().endsWith("\\")) { - return file.getPath().replaceAll("[/\\\\]+", ""); - } else if (file.getPath().contains("/") || file.getPath().contains("\\")) { - return file.getPath().replaceAll("[/\\\\]+", sep); - } - return ((FILE)data).getPath(); - } - return (String) data; - } - - private String getdata(T data) { - if (data instanceof String) { - return (String) data; - } else if (data instanceof FILE){ - return ((FILE)data).getName(); - } - return (String) data; - } - - public static class BreadcrumbButton extends UIButton { - - private T content; - - public BreadcrumbButton(String data, T content) { - super(data); - BreadcrumbButton.this.content = content; - setMargin(new Insets(0, 0, 0, 0)); - setBorder(BorderFactory.createEmptyBorder()); - FineUIStyle.setStyle(BreadcrumbButton.this, FineUIStyle.BREADCRUMB_BUTTON); - setBorderPainted(false); - setOpaque(false); - } - - @Override - public Insets getMargin() { - Insets insets = super.getMargin(); - if (insets != null) { - insets.set(0, 0, 0, 0); - } - return insets; - } - - protected T getContent() { - return content; - } - - protected void setContent(T content) { - this.content = content; - } - } - - /** - * 节点点击关联动作监听器 - * @param - */ - public interface BreadcrumbBackListener { - void onBreadcrumbBack(T data); - } - -} diff --git a/designer-base/src/main/java/com/fr/design/mainframe/theme/TemplateThemeGridPagesPane.java b/designer-base/src/main/java/com/fr/design/mainframe/theme/TemplateThemeGridPagesPane.java index ee2322e602..704f9c1a35 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/theme/TemplateThemeGridPagesPane.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/theme/TemplateThemeGridPagesPane.java @@ -1,6 +1,5 @@ package com.fr.design.mainframe.theme; -import com.fine.theme.utils.FineUIScale; import com.fr.base.ScreenResolution; import com.fr.base.theme.FormTheme; import com.fr.base.theme.FormThemeConfig; @@ -13,7 +12,6 @@ import com.fr.design.dialog.BasicPane; import com.fr.design.event.ChangeEvent; import com.fr.design.event.ChangeListener; import com.fr.design.file.HistoryTemplateListCache; -import com.fr.design.gui.frpane.FineBreadcrumbPane; import com.fr.design.gui.frpane.FineTabbedPane; import com.fr.design.gui.ibutton.UIButton; import com.fr.design.i18n.Toolkit; @@ -22,8 +20,6 @@ import com.fr.design.mainframe.JTemplate; import com.fr.design.mainframe.theme.dialog.TemplateThemeDialog; import com.fr.design.mainframe.theme.provider.ThemeManageActionProvider; import com.fr.design.mainframe.theme.ui.BreadcrumbBar; -import com.fr.file.FILE; -import com.fr.general.ComparatorUtils; import com.fr.stable.ArrayUtils; import com.fr.stable.unit.FU; import com.fr.third.javax.annotation.Nullable; @@ -39,7 +35,6 @@ import java.awt.CardLayout; import java.awt.Color; import java.awt.Component; import java.awt.Container; -import java.awt.Dimension; import java.awt.Graphics; import java.awt.Graphics2D; import java.awt.RenderingHints; @@ -58,7 +53,7 @@ import java.util.Set; */ public class TemplateThemeGridPagesPane extends JPanel { public static final String COMPLETE_BUTTON = "theme_button_complete"; - private FineBreadcrumbPane breadcrumbBar; + private BreadcrumbBar breadcrumbBar; private JPanel contentPane; private CardLayout cardLayout; @@ -80,8 +75,8 @@ public class TemplateThemeGridPagesPane extends JPanel { setLayout(new BorderLayout()); setBorder(BorderFactory.createEmptyBorder(10, 10, 0, 10)); - breadcrumbBar = new FineBreadcrumbPane(); - breadcrumbBar.setPreferredSize(new Dimension(this.getPreferredSize().width, FineUIScale.scale(20))); + breadcrumbBar = new BreadcrumbBar(); + breadcrumbBar.setBorder(BorderFactory.createEmptyBorder(0, 0, 10, 0)); add(breadcrumbBar, BorderLayout.NORTH); contentPane = new JPanel(); @@ -109,14 +104,16 @@ public class TemplateThemeGridPagesPane extends JPanel { pageChangeListener.onPageChangeListener(); } breadcrumbBar.clear(); - breadcrumbBar.addCrumb(themeUsingPane.getTitle(), - data -> { - cardLayout.show(contentPane, themeUsingPane.getTitle()); - currentTemplateThemeGridPagePane = themeUsingPane; - if (pageChangeListener != null) { - pageChangeListener.onPageChangeListener(); - } - }); + breadcrumbBar.addCrumb(themeUsingPane.getTitle(), new BreadcrumbBar.BreadcrumbBackListener() { + @Override + public void onBreadcrumbBack(String text) { + cardLayout.show(contentPane, themeUsingPane.getTitle()); + currentTemplateThemeGridPagePane = themeUsingPane; + if (pageChangeListener != null) { + pageChangeListener.onPageChangeListener(); + } + } + }); } } @@ -127,7 +124,7 @@ public class TemplateThemeGridPagesPane extends JPanel { if (pageChangeListener != null) { pageChangeListener.onPageChangeListener(); } - breadcrumbBar.addCrumb(themeManagingPane.getTitle(),null); + breadcrumbBar.addCrumb(themeManagingPane.getTitle(), null); } } diff --git a/designer-base/src/main/java/com/fr/file/FILEChooserPane.java b/designer-base/src/main/java/com/fr/file/FILEChooserPane.java index 0d35aa843d..5830f16d9a 100644 --- a/designer-base/src/main/java/com/fr/file/FILEChooserPane.java +++ b/designer-base/src/main/java/com/fr/file/FILEChooserPane.java @@ -18,7 +18,6 @@ import com.fr.design.env.DesignerWorkspaceType; import com.fr.design.file.HistoryTemplateListPane; import com.fr.design.file.NodeAuthProcessor; import com.fr.design.fun.ReportSupportedFileUIProvider; -import com.fr.design.gui.frpane.FineBreadcrumbPane; import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.ibutton.UIButtonUI; import com.fr.design.gui.icombobox.UIComboBox; @@ -155,7 +154,6 @@ public class FILEChooserPane extends BasicPane { private FILEFilter filter; private LocationButtonPane locationBtnPane; // 显示location的Panel - private FineBreadcrumbPane locationBreadcrumbPane; private UIButton mkdirButton; private JList placesList; // File.listRoots() + Env + Favourite @@ -307,7 +305,7 @@ public class FILEChooserPane extends BasicPane { JPanel locationPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); // locationPane.setLayout(FRGUIPaneFactory.createBorderLayout()); - locationPane.add(locationBreadcrumbPane = new FineBreadcrumbPane(), BorderLayout.CENTER); + locationPane.add(locationBtnPane = new LocationButtonPane(), BorderLayout.CENTER); mkdirButton = initMkdirButton(); locationPane.add(mkdirButton, BorderLayout.EAST); @@ -350,7 +348,6 @@ public class FILEChooserPane extends BasicPane { Object selValue = placesList.getSelectedValue(); if (selValue instanceof FILE) { setSelectedDirectory((FILE) selValue); - locationBreadcrumbPane.reset(selValue, data -> setSelectedDirectory((FILE) data)); } } }); @@ -363,7 +360,6 @@ public class FILEChooserPane extends BasicPane { Object selValue = placesList.getSelectedValue(); if (selValue instanceof FILE) { setSelectedDirectory((FILE) selValue); - locationBreadcrumbPane.reset(selValue, data -> setSelectedDirectory((FILE) data)); } } }); @@ -422,8 +418,6 @@ public class FILEChooserPane extends BasicPane { setFileTextField((FILE) selValue); fileNameTextField.addDocumentListener(); } else { - locationBreadcrumbPane.addCrumb(selValue, - data -> setSelectedDirectory((FILE) data)); setSelectedDirectory((FILE) selValue); if (!((FILE) selValue).isDirectory()) { doOK(); @@ -572,7 +566,7 @@ public class FILEChooserPane extends BasicPane { } private void doCancel() { - //this.locationBtnPane.setPopDir(null); + this.locationBtnPane.setPopDir(null); dialogExit(); } @@ -1102,7 +1096,7 @@ public class FILEChooserPane extends BasicPane { } private void setTopPath(String path) { - this.locationBreadcrumbPane.init(path, null); + this.locationBtnPane.setTopPath(path); } @@ -1156,7 +1150,6 @@ public class FILEChooserPane extends BasicPane { } setSelectedDirectory(dir); - locationBreadcrumbPane.reset(dir, text -> setSelectedDirectory((FILE) text)); } /* @@ -1168,6 +1161,8 @@ public class FILEChooserPane extends BasicPane { } currentDirectory = dir; + + this.locationBtnPane.populate(currentDirectory); this.mkdirButton.setEnabled(currentDirectory != null); refreshSubFileListModel();