Browse Source

Pull request #13552: REPORT-111995 UI翻新:滚动面板 + 弹出面板处理

Merge in DESIGN/design from ~LEVY.XIE/design:newui to newui

* commit '824b8953a4d1fd508c7edde6cbc608955b823b69':
  REPORT-111995 弹出面板适配DPI缩放
  REPORT-111995 提供仅悬浮时显示滚动条的滚动面板组件
newui
Levy.Xie-解安森 10 months ago
parent
commit
442be68970
  1. 73
      designer-base/src/main/java/com/fine/theme/light/ui/CollapsibleScrollBarLayerUI.java
  2. 17
      designer-base/src/main/java/com/fine/theme/utils/FineUIUtils.java
  3. 32
      designer-base/src/main/java/com/fr/design/data/datapane/management/search/pane/TableDataSearchRemindPane.java
  4. 22
      designer-base/src/main/java/com/fr/design/dialog/BasicDialog.java
  5. 5
      designer-base/src/main/java/com/fr/design/formula/FormulaPane.java
  6. 29
      designer-base/src/main/java/com/fr/design/mainframe/manager/search/searcher/control/pane/TemplateSearchRemindPane.java

73
designer-base/src/main/java/com/fine/theme/light/ui/CollapsibleScrollBarLayerUI.java

@ -0,0 +1,73 @@
package com.fine.theme.light.ui;
import com.fr.design.gui.icontainer.UIScrollPane;
import javax.swing.JComponent;
import javax.swing.JLayer;
import javax.swing.JScrollPane;
import javax.swing.ScrollPaneConstants;
import javax.swing.plaf.LayerUI;
import java.awt.AWTEvent;
import java.awt.Component;
import java.awt.event.MouseEvent;
/**
* 滚动面板的装饰层UI支持滚动条仅当悬浮时显示
* 使用见工具类: {@link com.fine.theme.utils.FineUIUtils#createCollapsibleScrollBarLayer(Component)}
*
* @author Levy.Xie
* @since 11.0
* Created on 2024/01/25
*/
public class CollapsibleScrollBarLayerUI extends LayerUI<UIScrollPane> {
private final int verticalPolicy;
private final int horizontalPolicy;
public CollapsibleScrollBarLayerUI() {
this(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
}
public CollapsibleScrollBarLayerUI(int verticalPolicy, int horizontalPolicy) {
this.verticalPolicy = verticalPolicy;
this.horizontalPolicy = horizontalPolicy;
}
@Override
public void installUI(JComponent c) {
super.installUI(c);
if (c instanceof JLayer) {
((JLayer<?>) c).setLayerEventMask(AWTEvent.MOUSE_EVENT_MASK);
}
}
@Override
public void uninstallUI(JComponent c) {
if (c instanceof JLayer) {
((JLayer<?>) c).setLayerEventMask(0);
}
super.uninstallUI(c);
}
@Override
protected void processMouseEvent(MouseEvent e, JLayer<? extends UIScrollPane> l) {
JScrollPane view = l.getView();
switch (e.getID()) {
case MouseEvent.MOUSE_ENTERED:
// 在鼠标进入时恢复滚动条显示策略
if (view != null) {
view.setVerticalScrollBarPolicy(verticalPolicy);
view.setHorizontalScrollBarPolicy(horizontalPolicy);
}
break;
case MouseEvent.MOUSE_EXITED:
// 在鼠标退出时隐藏滚动条
if (view != null) {
view.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_NEVER);
view.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
}
break;
default:
break;
}
}
}

17
designer-base/src/main/java/com/fine/theme/utils/FineUIUtils.java

@ -1,12 +1,16 @@
package com.fine.theme.utils;
import com.fine.theme.light.ui.CollapsibleScrollBarLayerUI;
import com.formdev.flatlaf.ui.FlatUIUtils;
import com.fr.design.border.FineBorderFactory;
import com.fr.design.gui.icontainer.UIScrollPane;
import com.fr.stable.os.OperatingSystem;
import com.fr.value.AtomicClearableLazyValue;
import javax.swing.UIManager;
import javax.swing.JLabel;
import javax.swing.JLayer;
import javax.swing.ScrollPaneConstants;
import javax.swing.UIManager;
import java.awt.Color;
import java.awt.Component;
import java.awt.Composite;
@ -376,4 +380,15 @@ public class FineUIUtils {
FineUIStyle.setStyle(label, FineUIStyle.LABEL_BOLD);
}
/**
* 创建一个UIScrollPane的装饰层内部的ScrollPane仅当悬浮时显示滚动条
*
* @param c 组件
* @return UIScrollPane的装饰层
*/
public static JLayer<UIScrollPane> createCollapsibleScrollBarLayer(Component c) {
return new JLayer<>(new UIScrollPane(c, ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER),
new CollapsibleScrollBarLayerUI());
}
}

32
designer-base/src/main/java/com/fr/design/data/datapane/management/search/pane/TableDataSearchRemindPane.java

@ -1,5 +1,7 @@
package com.fr.design.data.datapane.management.search.pane;
import com.fine.theme.utils.FineUIStyle;
import com.fine.theme.utils.FineUIUtils;
import com.fr.base.svg.IconUtils;
import com.fr.design.constants.UIConstants;
import com.fr.design.data.datapane.TableDataTree;
@ -7,23 +9,24 @@ import com.fr.design.data.datapane.management.search.TableDataTreeSearchManager;
import com.fr.design.gui.icontainer.UIScrollPane;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.i18n.Toolkit;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.search.TreeSearchStatus;
import com.fr.design.search.event.TreeSearchStatusChangeEvent;
import com.fr.design.search.event.TreeSearchStatusChangeListener;
import javax.swing.BorderFactory;
import javax.swing.JLayer;
import javax.swing.JPanel;
import javax.swing.SwingConstants;
import java.awt.BorderLayout;
import java.awt.CardLayout;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import static com.fine.swing.ui.layout.Layouts.cell;
import static com.fine.swing.ui.layout.Layouts.column;
import static com.fine.swing.ui.layout.Layouts.flex;
/**
* @author Yvan
*/
@ -81,7 +84,7 @@ public class TableDataSearchRemindPane extends JPanel implements TreeSearchStatu
private class TreePane extends JPanel implements TreeSearchStatusChange {
private UIScrollPane scrollPane;
private JLayer<UIScrollPane> scrollPane;
private JPanel notFoundPane;
@ -97,21 +100,18 @@ public class TableDataSearchRemindPane extends JPanel implements TreeSearchStatu
private void init(TableDataTree tableDataTree) {
scrollPane = new UIScrollPane(tableDataTree);
scrollPane.setBorder(null);
scrollPane = FineUIUtils.createCollapsibleScrollBarLayer(tableDataTree);
notFoundPane = FRGUIPaneFactory.createVerticalFlowLayout_Pane(true, FlowLayout.LEADING, 0, 5);
UILabel emptyPicLabel = new UILabel();
emptyPicLabel.setIcon(IconUtils.readIcon("com/fr/base/images/share/no_match_icon.png"));
emptyPicLabel.setHorizontalAlignment(SwingConstants.CENTER);
emptyPicLabel.setPreferredSize(new Dimension(240, 100));
UILabel textLabel = new UILabel(Toolkit.i18nText("Fine-Design_Tree_Search_Not_Match"), SwingConstants.CENTER);
// textLabel.setForeground(Color.gray);
UILabel textLabel = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Tree_Search_Not_Match"), SwingConstants.CENTER);
FineUIStyle.setStyle(textLabel, FineUIStyle.LABEL_TIP);
textLabel.setHorizontalAlignment(SwingConstants.CENTER);
textLabel.setPreferredSize(new Dimension(240, 20));
notFoundPane.add(emptyPicLabel);
notFoundPane.add(textLabel);
notFoundPane.setBorder(BorderFactory.createEmptyBorder(80, 0, 0, 0));
notFoundPane = column(10,
flex(1), cell(emptyPicLabel), cell(textLabel), flex(1.5)
).getComponent();
cardLayout = new CardLayout();
this.setLayout(cardLayout);
@ -168,7 +168,7 @@ public class TableDataSearchRemindPane extends JPanel implements TreeSearchStatu
this.setLayout(new FlowLayout(FlowLayout.LEFT, 10, 0));
// 初始情况下为Not_Begin
textLabel = new UILabel();
textLabel.setForeground(Color.gray);
FineUIStyle.setStyle(textLabel, FineUIStyle.LABEL_TIP);
stopLabel = new UILabel();
stopLabel.setForeground(UIConstants.NORMAL_BLUE);
stopSearch = new MouseAdapter() {

22
designer-base/src/main/java/com/fr/design/dialog/BasicDialog.java

@ -1,8 +1,11 @@
package com.fr.design.dialog;
import com.fine.theme.utils.FineUIScale;
import com.fr.common.annotations.Open;
import java.awt.*;
import java.awt.Dialog;
import java.awt.Dimension;
import java.awt.Frame;
@Open
public abstract class BasicDialog extends UIDialog {
@ -12,7 +15,7 @@ public abstract class BasicDialog extends UIDialog {
public static final Dimension LARGE = new Dimension(900, 600);
public static final Dimension CHART = new Dimension(760, 560);
public static final Dimension MAP_SIZE = new Dimension(760, 450);
public static final Dimension UPDATE_ONLINE_SIZE = new Dimension(600,300);
public static final Dimension UPDATE_ONLINE_SIZE = new Dimension(600, 300);
public static final Dimension TOOLBAR_SIZE = new Dimension(660, 327);
public BasicDialog(Frame parent) {
@ -40,12 +43,23 @@ public abstract class BasicDialog extends UIDialog {
super(parent, pane, isNeedButtonPane);
}
/**
* 设置对话框大小方法内已进行dpi适配传参无需考虑dpi适配
*
* @param d 对话框尺寸
*/
protected void setBasicDialogSize(Dimension d) {
super.setSize(d.width, d.height);
super.setSize(FineUIScale.scale(d.width), FineUIScale.scale(d.height));
}
/**
* 设置对话框大小方法内已进行dpi适配传参无需考虑dpi适配
*
* @param w 宽度
* @param h 高度
*/
protected void setBasicDialogSize(int w, int h) {
super.setSize(w, h);
setBasicDialogSize(new Dimension(w, h));
}
@Override

5
designer-base/src/main/java/com/fr/design/formula/FormulaPane.java

@ -41,7 +41,6 @@ import com.fr.design.gui.itextarea.UITextArea;
import com.fr.design.gui.itextfield.UITextField;
import com.fr.design.gui.syntax.ui.rsyntaxtextarea.RSyntaxTextArea;
import com.fr.design.gui.syntax.ui.rsyntaxtextarea.SyntaxConstants;
import com.fr.design.i18n.DesignSizeI18nManager;
import com.fr.design.i18n.Toolkit;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.mainframe.DesignerContext;
@ -749,8 +748,8 @@ public class FormulaPane extends BasicPane implements KeyListener, UIFormula {
}
public BasicDialog showLargeWindow(Window window, DialogActionListener l) {
int width = FineUIScale.scale(900);
int height = FineUIScale.scale(600);
int width = 900;
int height = 900;
BasicDialog basicDialog = super.showWindowWithCustomSize(window, l, new Dimension(width, height));
basicDialog.setMinimumSize(new Dimension(width, height));
basicDialog.setResizable(true);

29
designer-base/src/main/java/com/fr/design/mainframe/manager/search/searcher/control/pane/TemplateSearchRemindPane.java

@ -1,5 +1,7 @@
package com.fr.design.mainframe.manager.search.searcher.control.pane;
import com.fine.theme.utils.FineUIStyle;
import com.fine.theme.utils.FineUIUtils;
import com.fr.base.svg.IconUtils;
import com.fr.design.constants.UIConstants;
import com.fr.design.gui.itree.filetree.EnvFileTree;
@ -12,18 +14,20 @@ import com.fr.design.i18n.Toolkit;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.mainframe.manager.search.TemplateTreeSearchManager;
import javax.swing.BorderFactory;
import javax.swing.JLayer;
import javax.swing.JPanel;
import javax.swing.SwingConstants;
import java.awt.BorderLayout;
import java.awt.CardLayout;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.awt.FlowLayout;
import static com.fine.swing.ui.layout.Layouts.cell;
import static com.fine.swing.ui.layout.Layouts.column;
import static com.fine.swing.ui.layout.Layouts.flex;
/**
* 模板搜索提示面板整合了模板树和提示面板
*/
@ -94,7 +98,7 @@ public class TemplateSearchRemindPane extends JPanel implements TreeSearchStatus
private class TreePane extends JPanel implements TemplateSearchRemindPane.TreeSearchStatusChange {
private UIScrollPane scrollPane;
private JLayer<UIScrollPane> scrollPane;
private JPanel notFoundPane;
@ -110,21 +114,18 @@ public class TemplateSearchRemindPane extends JPanel implements TreeSearchStatus
private void init(EnvFileTree templateFileTree) {
scrollPane = new UIScrollPane(templateFileTree);
scrollPane.setBorder(null);
scrollPane = FineUIUtils.createCollapsibleScrollBarLayer(templateFileTree);
notFoundPane = FRGUIPaneFactory.createVerticalFlowLayout_Pane(true, FlowLayout.LEADING, 0, 5);
UILabel emptyPicLabel = new UILabel();
emptyPicLabel.setIcon(IconUtils.readIcon("com/fr/base/images/share/no_match_icon.png"));
emptyPicLabel.setHorizontalAlignment(SwingConstants.CENTER);
emptyPicLabel.setPreferredSize(new Dimension(240, 100));
UILabel textLabel = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Tree_Search_Not_Match"), SwingConstants.CENTER);
textLabel.setForeground(Color.gray);
FineUIStyle.setStyle(textLabel, FineUIStyle.LABEL_TIP);
textLabel.setHorizontalAlignment(SwingConstants.CENTER);
textLabel.setPreferredSize(new Dimension(240, 20));
notFoundPane.add(emptyPicLabel);
notFoundPane.add(textLabel);
notFoundPane.setBorder(BorderFactory.createEmptyBorder(80, 0, 0, 0));
notFoundPane = column(10,
flex(1), cell(emptyPicLabel), cell(textLabel), flex(1.5)
).getComponent();
cardLayout = new CardLayout();
this.setLayout(cardLayout);
@ -181,7 +182,7 @@ public class TemplateSearchRemindPane extends JPanel implements TreeSearchStatus
this.setLayout(new FlowLayout(FlowLayout.LEFT, 10, 0));
// 初始情况下为Not_Begin
textLabel = new UILabel();
textLabel.setForeground(Color.gray);
FineUIStyle.setStyle(textLabel, FineUIStyle.LABEL_TIP);
stopLabel = new UILabel();
stopLabel.setForeground(UIConstants.NORMAL_BLUE);
stopSearch = new MouseAdapter() {

Loading…
Cancel
Save