Browse Source

Pull request #13487: REPORT-107973 翻新上下文菜单弹窗

Merge in DESIGN/design from ~LEO.QIN/design:newui to newui

* commit 'af5775815287bd35b08fe7cf27303bebb2bfd563':
  REPORT-107973 回退透明按钮
  REPORT-107973 翻新上下文菜单弹窗。透明按钮
  REPORT-107973 翻新上下文菜单弹窗
newui
Leo.Qin-覃宇攀 10 months ago
parent
commit
24b410bd9d
  1. 41
      designer-base/src/main/java/com/fine/theme/light/ui/FineMenuItemUI.java
  2. 40
      designer-base/src/main/java/com/fine/theme/light/ui/FineMenuUI.java
  3. 70
      designer-base/src/main/java/com/fine/theme/light/ui/FinePopupMenuSeparatorUI.java
  4. 3
      designer-base/src/main/java/com/fine/theme/light/ui/FinePopupMenuUI.java
  5. 4
      designer-base/src/main/java/com/fine/theme/utils/FineClientProperties.java
  6. 4
      designer-base/src/main/java/com/fine/theme/utils/FineUIStyle.java
  7. 1
      designer-base/src/main/java/com/fr/design/data/datapane/TableDataTreePane.java
  8. 3
      designer-base/src/main/java/com/fr/design/gui/imenu/UILockMenuItem.java
  9. 2
      designer-base/src/main/java/com/fr/design/gui/imenu/UIMenuItem.java
  10. 28
      designer-base/src/main/java/com/fr/design/menu/DottedSeparator.java
  11. 24
      designer-base/src/main/java/com/fr/design/menu/LineSeparator.java
  12. 38
      designer-base/src/main/java/com/fr/design/menu/MenuDef.java
  13. 13
      designer-base/src/main/java/com/fr/design/menu/NameSeparator.java
  14. 1
      designer-base/src/main/java/com/fr/design/menu/SnapChatUpdateAction.java
  15. 6
      designer-base/src/main/resources/com/fine/theme/light/ui/laf/FineLaf.properties
  16. 42
      designer-base/src/main/resources/com/fine/theme/light/ui/laf/FineLightLaf.properties
  17. 103
      designer-base/src/test/java/com/fr/design/gui/storybook/components/PopupMenuStoryBoard.java
  18. 2
      designer-realize/src/main/java/com/fr/grid/selection/CellSelection.java
  19. 5
      designer-realize/src/main/java/com/fr/grid/selection/Selection.java

41
designer-base/src/main/java/com/fine/theme/light/ui/FineMenuItemUI.java

@ -0,0 +1,41 @@
package com.fine.theme.light.ui;
import com.fine.theme.utils.FineClientProperties;
import com.formdev.flatlaf.ui.FlatMenuItemUI;
import com.fr.design.editlock.EditLockUtils;
import javax.swing.JComponent;
import javax.swing.plaf.ComponentUI;
import java.awt.Graphics;
/**
* menuItem UI类
*
* @author Leo.Qin
* @since 11.0
* Created on 2024/1/8
*/
public class FineMenuItemUI extends FlatMenuItemUI {
int iconSize = 16;
int rightMargin = 10;
/**
* 创建UI
*
* @param c
* @return
*/
public static ComponentUI createUI(JComponent c) {
return new FineMenuItemUI();
}
@Override
public void paint(Graphics g, JComponent c) {
super.paint(g, c);
Object itemType = c.getClientProperty(FineClientProperties.MENU_ITEM_TYPE);
if (FineClientProperties.MENU_ITEM_TYPE_LOCK.equals(itemType)) {
g.drawImage(EditLockUtils.LOCKED_IMAGE, c.getWidth() - rightMargin - iconSize, (c.getHeight() - iconSize) / 2, iconSize, iconSize, null);
}
}
}

40
designer-base/src/main/java/com/fine/theme/light/ui/FineMenuUI.java

@ -0,0 +1,40 @@
package com.fine.theme.light.ui;
import com.fine.theme.icon.LazyIcon;
import com.formdev.flatlaf.ui.FlatMenuUI;
import javax.swing.JComponent;
import javax.swing.plaf.ComponentUI;
import java.awt.Graphics;
/**
* 弹窗菜单UI
*
* @author Leo.Qin
* @since 11.0
* Created on 2024/1/8
*/
public class FineMenuUI extends FlatMenuUI {
/**
* 创建UI
*
* @param c
* @return
*/
public static ComponentUI createUI(JComponent c) {
return new FineMenuUI();
}
@Override
protected void installDefaults() {
arrowIcon = new LazyIcon("triangle_right");
super.installDefaults();
}
@Override
public void paint(Graphics g, JComponent c) {
super.paint(g, c);
}
}

70
designer-base/src/main/java/com/fine/theme/light/ui/FinePopupMenuSeparatorUI.java

@ -0,0 +1,70 @@
package com.fine.theme.light.ui;
import com.fine.theme.utils.FineUIUtils;
import com.formdev.flatlaf.ui.FlatPopupMenuSeparatorUI;
import com.formdev.flatlaf.ui.FlatUIUtils;
import javax.swing.JComponent;
import javax.swing.JSeparator;
import javax.swing.plaf.ComponentUI;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Insets;
import java.awt.geom.Rectangle2D;
import static com.formdev.flatlaf.util.UIScale.scale;
/**
* popup弹窗分割线UI
*
* @author Leo.Qin
* @since 11.0
* Created on 2024/1/8
*/
public class FinePopupMenuSeparatorUI extends FlatPopupMenuSeparatorUI {
protected Insets insets;
/**
* @param shared
* @since 2
*/
protected FinePopupMenuSeparatorUI(boolean shared) {
super(shared);
}
/**
* 创建UI类
*
* @param c
* @return
*/
public static ComponentUI createUI(JComponent c) {
return new FinePopupMenuSeparatorUI(false);
}
@Override
protected void installDefaults(JSeparator s) {
super.installDefaults(s);
insets = FineUIUtils.getAndScaleUIInsets("PopupMenuSeparator.Insets", new Insets(0, 10, 0, 10));
}
@Override
public void paint(Graphics g, JComponent c) {
Graphics2D g2 = (Graphics2D) g.create();
try {
FlatUIUtils.setRenderingHints(g2);
g2.setColor(c.getForeground());
float width = scale((float) stripeWidth);
float indent = scale((float) stripeIndent);
if (((JSeparator) c).getOrientation() == JSeparator.VERTICAL) {
g2.fill(new Rectangle2D.Float(indent, insets.left, width - (insets.left + insets.right), c.getHeight()));
} else {
g2.fill(new Rectangle2D.Float(insets.left, indent, c.getWidth() - (insets.left + insets.right), width));
}
} finally {
g2.dispose();
}
}
}

3
designer-base/src/main/java/com/fine/theme/light/ui/FinePopupMenuUI.java

@ -19,7 +19,7 @@ import java.awt.geom.RoundRectangle2D;
*/ */
public class FinePopupMenuUI extends FlatPopupMenuUI { public class FinePopupMenuUI extends FlatPopupMenuUI {
private int arc; private int arc;
private final int DEFAULT_ARC = 5; private final int DEFAULT_ARC = 10;
/** /**
* 创建UI * 创建UI
@ -39,6 +39,7 @@ public class FinePopupMenuUI extends FlatPopupMenuUI {
@Override @Override
public void paint(Graphics g, JComponent c) { public void paint(Graphics g, JComponent c) {
// 绘制圆角矩形作为弹窗背景 // 绘制圆角矩形作为弹窗背景
Graphics2D g2d = (Graphics2D) g; Graphics2D g2d = (Graphics2D) g;
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);

4
designer-base/src/main/java/com/fine/theme/utils/FineClientProperties.java

@ -17,6 +17,10 @@ public interface FineClientProperties extends FlatClientProperties {
String BUTTON_TYPE_LEFT_ROUND_RECT = "leftRoundRect"; String BUTTON_TYPE_LEFT_ROUND_RECT = "leftRoundRect";
String BUTTON_TYPE_RIGHT_ROUND_RECT = "rightRoundRect"; String BUTTON_TYPE_RIGHT_ROUND_RECT = "rightRoundRect";
//--------------------------- PopupMenu -----------------------
String MENU_ITEM_TYPE = "MenuItemType";
String MENU_ITEM_TYPE_LOCK = "lock";
String BUTTON_GROUP_POSITION = "group_position"; String BUTTON_GROUP_POSITION = "group_position";
int GROUP_BUTTON_POSITION_INNER = 0; int GROUP_BUTTON_POSITION_INNER = 0;

4
designer-base/src/main/java/com/fine/theme/utils/FineUIStyle.java

@ -27,6 +27,10 @@ public interface FineUIStyle {
String BRAND_COLOR_LABEL = "brandColorLabel"; String BRAND_COLOR_LABEL = "brandColorLabel";
String BUTTON_TAB_ACTION = "tabAction"; String BUTTON_TAB_ACTION = "tabAction";
String MENU_TOOL_BAR = "menuToolBar";
String MENU_ITEM_TOOL_BAR = "menuItemToolBar";
String POPUP_MENU_TOOL_BAR = "popupMenuToolBar";
/** /**
* 添加组件的样式类类似css该方法会接在原样式后方 * 添加组件的样式类类似css该方法会接在原样式后方

1
designer-base/src/main/java/com/fr/design/data/datapane/TableDataTreePane.java

@ -182,7 +182,6 @@ public class TableDataTreePane extends BasicTableDataTreePane {
popupMenu.add(copyAction.createMenuItem()); popupMenu.add(copyAction.createMenuItem());
popupMenu.add(pasteAction.createMenuItem()); popupMenu.add(pasteAction.createMenuItem());
popupMenu.add(removeAction.createMenuItem()); popupMenu.add(removeAction.createMenuItem());
popupMenu.addSeparator();
// 监听 // 监听
tableDataTree.addMouseListener(new MouseAdapter() { tableDataTree.addMouseListener(new MouseAdapter() {
@Override @Override

3
designer-base/src/main/java/com/fr/design/gui/imenu/UILockMenuItem.java

@ -1,5 +1,6 @@
package com.fr.design.gui.imenu; package com.fr.design.gui.imenu;
import com.fine.theme.utils.FineClientProperties;
import com.fr.design.editlock.EditLockChangeEvent; import com.fr.design.editlock.EditLockChangeEvent;
import com.fr.design.editlock.EditLockChangeListener; import com.fr.design.editlock.EditLockChangeListener;
import com.fr.report.LockItem; import com.fr.report.LockItem;
@ -32,7 +33,7 @@ public class UILockMenuItem extends UIMenuItem implements EditLockChangeListener
this.lockedTooltips = lockedTooltips; this.lockedTooltips = lockedTooltips;
this.normalTooltips = normalTooltips; this.normalTooltips = normalTooltips;
this.lockItem = lockItem; this.lockItem = lockItem;
setUI(new UILockMenuItemUI()); this.putClientProperty(FineClientProperties.MENU_ITEM_TYPE, FineClientProperties.MENU_ITEM_TYPE_LOCK);
} }
public LockItem getLockItem() { public LockItem getLockItem() {

2
designer-base/src/main/java/com/fr/design/gui/imenu/UIMenuItem.java

@ -8,7 +8,7 @@ import javax.swing.JMenuItem;
public class UIMenuItem extends JMenuItem{ public class UIMenuItem extends JMenuItem{
public UIMenuItem() { public UIMenuItem() {
this(StringUtils.BLANK); this(StringUtils.EMPTY);
} }
public UIMenuItem(String string) { public UIMenuItem(String string) {

28
designer-base/src/main/java/com/fr/design/menu/DottedSeparator.java

@ -1,12 +1,15 @@
package com.fr.design.menu; package com.fr.design.menu;
import com.fine.theme.utils.FineUIUtils;
import com.fr.design.actions.UpdateAction; import com.fr.design.actions.UpdateAction;
import com.fr.design.gui.imenu.UIMenuItem; import com.fr.design.gui.imenu.UIMenuItem;
import javax.swing.UIManager;
import java.awt.BasicStroke; import java.awt.BasicStroke;
import java.awt.Dimension; import java.awt.Dimension;
import java.awt.Graphics; import java.awt.Graphics;
import java.awt.Graphics2D; import java.awt.Graphics2D;
import java.awt.Insets;
import java.awt.Stroke; import java.awt.Stroke;
import java.awt.event.ActionEvent; import java.awt.event.ActionEvent;
@ -42,31 +45,32 @@ public class DottedSeparator extends UpdateAction {
} }
private class MenuItem extends UIMenuItem { private class MenuItem extends UIMenuItem {
private final Insets insets;
private final int height;
public MenuItem() { public MenuItem() {
this.setUI(null); this.setEnabled(false);
this.removeAll(); this.removeAll();
insets = FineUIUtils.getAndScaleUIInsets("PopupMenuSeparator.Insets", new Insets(0, 10, 0, 10));
height = FineUIUtils.getAndScaleInt("PopupMenuSeparator.height", 5);
} }
public void paint(Graphics g) { public void paint(Graphics g) {
int w = this.getWidth(); int w = this.getWidth();
int h = this.getHeight(); int h = this.getHeight();
Graphics2D g2d = (Graphics2D)g; Graphics2D g2d = (Graphics2D)g;
g2d.setColor(getBackground()); g2d.setColor(UIManager.getColor("Separator.background"));
g2d.fillRect(0, 0, w, h);
g2d.setColor(getForeground());
Stroke bs = new BasicStroke(1f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_ROUND, 2f, new float[] { 3, 1 }, 0); Stroke bs = new BasicStroke(1f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_ROUND, 2f, new float[] { 3, 1 }, 0);
g2d.setStroke(bs); g2d.setStroke(bs);
g2d.drawLine(30, h / 2+1, w-4, h / 2+1); g2d.drawLine(insets.left, h / 2 + 1, w - insets.right, h / 2 + 1);
this.setForeground(getForeground());
super.paint(g);
}
public Dimension getSize() {
return new Dimension(super.getSize().width, 8);
} }
@Override
public Dimension getPreferredSize() { public Dimension getPreferredSize() {
return new Dimension(super.getPreferredSize().width, 8); return new Dimension(super.getPreferredSize().width, height);
} }
} }

24
designer-base/src/main/java/com/fr/design/menu/LineSeparator.java

@ -4,9 +4,6 @@ import com.fr.design.actions.UpdateAction;
import com.fr.design.gui.imenu.UIMenuItem; import com.fr.design.gui.imenu.UIMenuItem;
import java.awt.Color; import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.event.ActionEvent; import java.awt.event.ActionEvent;
/** /**
@ -47,28 +44,7 @@ public class LineSeparator extends UpdateAction{
private class MenuItem extends UIMenuItem { private class MenuItem extends UIMenuItem {
public MenuItem() { public MenuItem() {
this.setUI(null);
this.removeAll(); this.removeAll();
} }
public void paint(Graphics g) {
int w = this.getWidth();
int h = this.getHeight();
Graphics2D g2d = (Graphics2D)g;
g2d.setColor(getBackground());
g2d.fillRect(0, 0, w, h);
g2d.setColor(getForeground());
g2d.drawLine(4, h / 2+1, w-4, h / 2+1);
// this.setForeground(color);
super.paint(g);
}
public Dimension getSize() {
return new Dimension(super.getSize().width, 8);
}
public Dimension getPreferredSize() {
return new Dimension(super.getPreferredSize().width, 8);
}
} }
} }

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

@ -1,6 +1,7 @@
package com.fr.design.menu; package com.fr.design.menu;
import com.fine.theme.icon.LazyIcon; import com.fine.theme.icon.LazyIcon;
import com.fine.theme.utils.FineUIStyle;
import com.fr.base.svg.IconUtils; import com.fr.base.svg.IconUtils;
import com.fr.design.file.HistoryTemplateListCache; import com.fr.design.file.HistoryTemplateListCache;
import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.ibutton.UIButton;
@ -17,8 +18,10 @@ import com.fr.stable.StringUtils;
import javax.swing.Icon; import javax.swing.Icon;
import javax.swing.JMenu; import javax.swing.JMenu;
import javax.swing.JMenuItem;
import javax.swing.JPopupMenu; import javax.swing.JPopupMenu;
import javax.swing.JToolBar; import javax.swing.JToolBar;
import javax.swing.MenuElement;
import javax.swing.event.MenuEvent; import javax.swing.event.MenuEvent;
import javax.swing.event.MenuListener; import javax.swing.event.MenuListener;
import java.awt.Component; import java.awt.Component;
@ -32,6 +35,8 @@ import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Set; import java.util.Set;
import static com.fine.theme.utils.FineUIStyle.setStyle;
/** /**
* Define Menu. * Define Menu.
*/ */
@ -311,7 +316,13 @@ public class MenuDef extends ShortCut {
*/ */
public void updateMenu() { public void updateMenu() {
//peter:这个方法用来产生JMenu的孩子控件,但是不update,action. //peter:这个方法用来产生JMenu的孩子控件,但是不update,action.
this.updatePopupMenu(this.createJMenu().getPopupMenu()); UIMenu jMenu = this.createJMenu();
JPopupMenu jPopupMenu = jMenu.getPopupMenu();
this.updatePopupMenu(jPopupMenu);
if (jMenu instanceof UIHeadMenu) {
setToolBarClientProperty(jPopupMenu);
}
//peter:需要设置JMenu的enabled属性. //peter:需要设置JMenu的enabled属性.
if (createdJMenu != null) { if (createdJMenu != null) {
@ -320,6 +331,26 @@ public class MenuDef extends ShortCut {
} }
} }
private void setToolBarClientProperty(JPopupMenu jPopupMenu) {
setStyle(jPopupMenu, FineUIStyle.POPUP_MENU_TOOL_BAR);
MenuElement[] subElements = jPopupMenu.getSubElements();
for (MenuElement subElement : subElements) {
if (subElement instanceof JMenu) {
JMenu jMenu = (JMenu) subElement;
setStyle(jMenu, FineUIStyle.MENU_TOOL_BAR);
JPopupMenu childPopupMenu = jMenu.getPopupMenu();
setToolBarClientProperty(childPopupMenu);
} else if (subElement instanceof JMenuItem) {
JMenuItem jMenuItem = (JMenuItem) subElement;
setStyle(jMenuItem, FineUIStyle.MENU_ITEM_TOOL_BAR);
}
}
}
public void updateEnable() { public void updateEnable() {
setEnabled(checkEnable()); setEnabled(checkEnable());
} }
@ -350,8 +381,11 @@ public class MenuDef extends ShortCut {
} }
nec_seperator = false; nec_seperator = false;
} }
if (shortcut instanceof LineSeparator) {
popupMenu.addSeparator();
} else {
shortcut.intoJPopupMenu(popupMenu); shortcut.intoJPopupMenu(popupMenu);
}
isFirstItem = false; isFirstItem = false;
} }

13
designer-base/src/main/java/com/fr/design/menu/NameSeparator.java

@ -5,6 +5,7 @@ import com.fr.design.actions.UpdateAction;
import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.ilable.UILabel;
import com.fr.design.gui.imenu.UIMenuItem; import com.fr.design.gui.imenu.UIMenuItem;
import javax.swing.UIManager;
import java.awt.BorderLayout; import java.awt.BorderLayout;
import java.awt.Dimension; import java.awt.Dimension;
import java.awt.FontMetrics; import java.awt.FontMetrics;
@ -44,21 +45,12 @@ public class NameSeparator extends UpdateAction {
private class MenuItem extends UIMenuItem { private class MenuItem extends UIMenuItem {
public MenuItem(String text) { public MenuItem(String text) {
this.setUI(null); this.setEnabled(false);
this.removeAll(); this.removeAll();
this.setLayout(new BorderLayout()); this.setLayout(new BorderLayout());
this.add(new CustomerLable(text, UILabel.LEFT), BorderLayout.CENTER); this.add(new CustomerLable(text, UILabel.LEFT), BorderLayout.CENTER);
} }
public void paint(Graphics g) {
int w = this.getWidth();
int h = this.getHeight();
Graphics2D g2d = (Graphics2D)g;
g2d.setColor(getBackground());
g2d.fillRect(0, 0, w, h);
super.paint(g);
}
public Dimension getSize() { public Dimension getSize() {
return new Dimension(super.getSize().width, 20); return new Dimension(super.getSize().width, 20);
} }
@ -85,6 +77,7 @@ public class NameSeparator extends UpdateAction {
for (int i = 0; i < str.length(); i++) { for (int i = 0; i < str.length(); i++) {
strwidth = strwidth + fm.charWidth(str.charAt(i)); strwidth = strwidth + fm.charWidth(str.charAt(i));
} }
g2d.setColor(UIManager.getColor("Separator.background"));
g2d.drawLine(strwidth + 4, h / 2+2, w, h / 2+2); g2d.drawLine(strwidth + 4, h / 2+2, w, h / 2+2);
super.paint(g); super.paint(g);
} }

1
designer-base/src/main/java/com/fr/design/menu/SnapChatUpdateAction.java

@ -57,7 +57,6 @@ public abstract class SnapChatUpdateAction extends UpdateAction implements SnapC
UIMenuItem menuItem = new UIMenuItem(this); UIMenuItem menuItem = new UIMenuItem(this);
// 设置名字用作单元测 // 设置名字用作单元测
menuItem.setName(getName()); menuItem.setName(getName());
menuItem.setUI(new SnapChatMenuItemUI(this));
object = menuItem; object = menuItem;
this.putValue(UIMenuItem.class.getName(), object); this.putValue(UIMenuItem.class.getName(), object);

6
designer-base/src/main/resources/com/fine/theme/light/ui/laf/FineLaf.properties

@ -13,14 +13,14 @@ FormattedTextFieldUI=com.formdev.flatlaf.ui.FlatFormattedTextFieldUI
InternalFrameUI=com.formdev.flatlaf.ui.FlatInternalFrameUI InternalFrameUI=com.formdev.flatlaf.ui.FlatInternalFrameUI
LabelUI=com.formdev.flatlaf.ui.FlatLabelUI LabelUI=com.formdev.flatlaf.ui.FlatLabelUI
ListUI=com.formdev.flatlaf.ui.FlatListUI ListUI=com.formdev.flatlaf.ui.FlatListUI
MenuUI=com.formdev.flatlaf.ui.FlatMenuUI MenuUI=com.fine.theme.light.ui.FineMenuUI
MenuBarUI=com.formdev.flatlaf.ui.FlatMenuBarUI MenuBarUI=com.formdev.flatlaf.ui.FlatMenuBarUI
MenuItemUI=com.formdev.flatlaf.ui.FlatMenuItemUI MenuItemUI=com.fine.theme.light.ui.FineMenuItemUI
OptionPaneUI=com.formdev.flatlaf.ui.FlatOptionPaneUI OptionPaneUI=com.formdev.flatlaf.ui.FlatOptionPaneUI
PanelUI=com.formdev.flatlaf.ui.FlatPanelUI PanelUI=com.formdev.flatlaf.ui.FlatPanelUI
PasswordFieldUI=com.formdev.flatlaf.ui.FlatPasswordFieldUI PasswordFieldUI=com.formdev.flatlaf.ui.FlatPasswordFieldUI
PopupMenuUI=com.fine.theme.light.ui.FinePopupMenuUI PopupMenuUI=com.fine.theme.light.ui.FinePopupMenuUI
PopupMenuSeparatorUI=com.formdev.flatlaf.ui.FlatPopupMenuSeparatorUI PopupMenuSeparatorUI=com.fine.theme.light.ui.FinePopupMenuSeparatorUI
ProgressBarUI=com.formdev.flatlaf.ui.FlatProgressBarUI ProgressBarUI=com.formdev.flatlaf.ui.FlatProgressBarUI
RadioButtonUI=com.formdev.flatlaf.ui.FlatRadioButtonUI RadioButtonUI=com.formdev.flatlaf.ui.FlatRadioButtonUI
RadioButtonMenuItemUI=com.formdev.flatlaf.ui.FlatRadioButtonMenuItemUI RadioButtonMenuItemUI=com.formdev.flatlaf.ui.FlatRadioButtonMenuItemUI

42
designer-base/src/main/resources/com/fine/theme/light/ui/laf/FineLightLaf.properties

@ -135,6 +135,7 @@ text.highlight=fade(@foreground, 90%)
fill.hover=#E6E9EF fill.hover=#E6E9EF
fill.click=#DADEE7 fill.click=#DADEE7
fill.normal=#FFFFFF fill.normal=#FFFFFF
fill.gray=#F2F4F8
fill.disabled=#F2F4F8 fill.disabled=#F2F4F8
border.divider=#DADEE7 border.divider=#DADEE7
tooltip.normal=#3F506A tooltip.normal=#3F506A
@ -447,13 +448,16 @@ Menu.icon.disabledArrowColor = @buttonDisabledArrowColor
Menu.border = com.formdev.flatlaf.ui.FlatMenuItemBorder Menu.border = com.formdev.flatlaf.ui.FlatMenuItemBorder
Menu.arrowIcon = com.formdev.flatlaf.icons.FlatMenuArrowIcon Menu.arrowIcon = com.formdev.flatlaf.icons.FlatMenuArrowIcon
Menu.checkIcon = null Menu.checkIcon = null
Menu.margin = @menuItemMargin Menu.margin=3,10,3,10
Menu.submenuPopupOffsetX = {scaledInteger}-4 Menu.submenuPopupOffsetX = {scaledInteger}-4
Menu.submenuPopupOffsetY = {scaledInteger}-4 Menu.submenuPopupOffsetY = {scaledInteger}-4
Menu.opaque = false Menu.opaque = false
Menu.borderPainted = true Menu.borderPainted = true
Menu.background = @menuBackground Menu.background = @menuBackground
Menu.selectionBackground=$fill.hover
#Menu.selectionForeground=$text.white
#Menu.acceleratorForeground=@foreground
#Menu.acceleratorSelectionForeground=$text.white
#---- MenuBar ---- #---- MenuBar ----
@ -471,25 +475,27 @@ MenuBar.selectionArc = $MenuItem.selectionArc
MenuItem.border = com.formdev.flatlaf.ui.FlatMenuItemBorder MenuItem.border = com.formdev.flatlaf.ui.FlatMenuItemBorder
MenuItem.arrowIcon = com.formdev.flatlaf.icons.FlatMenuItemArrowIcon MenuItem.arrowIcon = com.formdev.flatlaf.icons.FlatMenuItemArrowIcon
MenuItem.checkIcon = null MenuItem.checkIcon = null
MenuItem.margin=0,10,0,10 MenuItem.margin=3,10,3,10
MenuItem.opaque = false MenuItem.opaque = false
MenuItem.borderPainted = true MenuItem.borderPainted = true
MenuItem.verticallyAlignText = true MenuItem.verticallyAlignText = true
MenuItem.background = @menuBackground MenuItem.background = @menuBackground
MenuItem.checkBackground = @menuCheckBackground MenuItem.checkBackground = @menuCheckBackground
MenuItem.checkMargins = 2,2,2,2 MenuItem.checkMargins = 2,2,2,2
MenuItem.minimumWidth = 72 MenuItem.minimumWidth=150
MenuItem.minimumIconSize = 16,16 MenuItem.minimumIconSize = 16,16
MenuItem.iconTextGap = 6 MenuItem.iconTextGap = 6
MenuItem.textAcceleratorGap = 24 MenuItem.textAcceleratorGap = 24
MenuItem.textNoAcceleratorGap = 6 MenuItem.textNoAcceleratorGap = 6
MenuItem.acceleratorArrowGap=4 MenuItem.acceleratorArrowGap=4
MenuItem.acceleratorDelimiter = "+" MenuItem.acceleratorDelimiter = "+"
MenuItem.acceleratorForeground=@foreground
MenuItem.acceleratorSelectionForeground=@foreground
[mac]MenuItem.acceleratorDelimiter = "" [mac]MenuItem.acceleratorDelimiter = ""
MenuItem.selectionInsets = 0,0,0,0 MenuItem.selectionInsets=0,4,0,4
MenuItem.selectionArc = 0 MenuItem.selectionArc=4
MenuItem.selectionBackground=$brand.normal MenuItem.selectionBackground=$fill.hover
MenuItem.selectionForeground=$text.white MenuItem.selectionForeground=@foreground
MenuItem.disabledForeground=fade(@foreground,29%) MenuItem.disabledForeground=fade(@foreground,29%)
# for MenuItem.selectionType = underline # for MenuItem.selectionType = underline
@ -497,6 +503,8 @@ MenuItem.underlineSelectionBackground = @menuHoverBackground
MenuItem.underlineSelectionCheckBackground = @menuCheckBackground MenuItem.underlineSelectionCheckBackground = @menuCheckBackground
MenuItem.underlineSelectionColor = @accentUnderlineColor MenuItem.underlineSelectionColor = @accentUnderlineColor
MenuItem.underlineSelectionHeight = 3 MenuItem.underlineSelectionHeight = 3
#---- Separator ----
Separator.background=$border.divider
#---- OptionPane ---- #---- OptionPane ----
@ -560,13 +568,13 @@ PopupMenu.background=$background.normal
PopupMenu.scrollArrowColor = @buttonArrowColor PopupMenu.scrollArrowColor = @buttonArrowColor
PopupMenu.borderColor=$border.divider PopupMenu.borderColor=$border.divider
PopupMenu.hoverScrollArrowBackground = darken(@background,5%) PopupMenu.hoverScrollArrowBackground = darken(@background,5%)
PopupMenu.arc=$Component.arc PopupMenu.arc=10
#---- PopupMenuSeparator ---- #---- PopupMenuSeparator ----
PopupMenuSeparator.height=5
PopupMenuSeparator.height = 9
PopupMenuSeparator.stripeWidth = 1 PopupMenuSeparator.stripeWidth = 1
PopupMenuSeparator.stripeIndent=2 PopupMenuSeparator.stripeIndent=2
PopupMenuSeparator.Insets=0,10,0,10
#---- ProgressBar ---- #---- ProgressBar ----
@ -1257,6 +1265,18 @@ CellOtherSetPane.height=$Component.defaultHeight
[style]ToggleButton.inToolbarGroup = \ [style]ToggleButton.inToolbarGroup = \
margin : 4,4,4,4; \ margin : 4,4,4,4; \
background : #fff background : #fff
[style]Menu.menuToolBar=\
selectionBackground : $brand.normal; \
selectionForeground : $text.white; \
acceleratorForeground : @foreground; \
acceleratorSelectionForeground : $text.white
[style]MenuItem.menuItemToolBar=\
selectionBackground : $brand.normal; \
selectionForeground : $text.white; \
acceleratorForeground : @foreground; \
acceleratorSelectionForeground : $text.white
[style]PopupMenu.popupMenuToolBar=\
background: $fill.gray
#---- clearButton ---- #---- clearButton ----
# for clear/cancel button in text fields # for clear/cancel button in text fields

103
designer-base/src/test/java/com/fr/design/gui/storybook/components/PopupMenuStoryBoard.java

@ -0,0 +1,103 @@
package com.fr.design.gui.storybook.components;
import com.fine.theme.icon.LazyIcon;
import com.fine.theme.utils.FineUIStyle;
import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.gui.imenu.UIMenuItem;
import com.fr.design.gui.imenu.UIPopupMenu;
import com.fr.design.gui.storybook.Story;
import com.fr.design.gui.storybook.StoryBoard;
import com.fr.design.menu.DottedSeparator;
import com.fr.design.menu.NameSeparator;
import javax.swing.JMenu;
import javax.swing.JMenuItem;
import javax.swing.JPopupMenu;
import javax.swing.MenuElement;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import static com.fine.swing.ui.layout.Layouts.cell;
import static com.fine.swing.ui.layout.Layouts.column;
import static com.fine.theme.utils.FineUIStyle.setStyle;
/**
* 弹窗组件
*
* @author Leo.Qin
* @since 11.0
* Created on 2024/1/8
*/
@Story
public class PopupMenuStoryBoard extends StoryBoard {
public PopupMenuStoryBoard() {
super("弹窗");
add(
column(70,
cell(new UIButton("点击展示弹窗")).with(it -> {
UIPopupMenu popupMenu = new UIPopupMenu();
popupMenu.add(new UIMenuItem("test1", new LazyIcon("edit")));
popupMenu.add(new UIMenuItem("test2", new LazyIcon("cellHyperLinkAttr")));
popupMenu.addSeparator();
popupMenu.add(new UIMenuItem("test3", new LazyIcon("cellClear")));
popupMenu.add(new NameSeparator("分割线").createMenuItem());
popupMenu.add(new UIMenuItem("test4", new LazyIcon("cellOtherAttr")));
popupMenu.add(new DottedSeparator().createMenuItem());
popupMenu.add(new UIMenuItem("test5", new LazyIcon("cellExpandAttr")));
it.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
popupMenu.show(it, e.getX(), e.getY());
}
});
}),
cell(new UIButton("点击展示菜单栏弹窗")).with(it -> {
UIPopupMenu popupMenu = new UIPopupMenu();
popupMenu.add(new UIMenuItem("test1", new LazyIcon("edit")));
popupMenu.add(new UIMenuItem("test2", new LazyIcon("cellHyperLinkAttr")));
popupMenu.addSeparator();
popupMenu.add(new UIMenuItem("test3", new LazyIcon("cellClear")));
popupMenu.add(new NameSeparator("分割线").createMenuItem());
popupMenu.add(new UIMenuItem("test4", new LazyIcon("cellOtherAttr")));
popupMenu.add(new DottedSeparator().createMenuItem());
popupMenu.add(new UIMenuItem("test5", new LazyIcon("cellExpandAttr")));
it.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
popupMenu.show(it, e.getX(), e.getY());
}
});
setToolBarClientProperty(popupMenu);
})
)
);
}
private void setToolBarClientProperty(JPopupMenu jPopupMenu) {
setStyle(jPopupMenu, FineUIStyle.POPUP_MENU_TOOL_BAR);
MenuElement[] subElements = jPopupMenu.getSubElements();
for (MenuElement subElement : subElements) {
if (subElement instanceof JMenu) {
JMenu jMenu = (JMenu) subElement;
JPopupMenu childPopupMenu = jMenu.getPopupMenu();
setStyle(jMenu, FineUIStyle.MENU_TOOL_BAR);
setToolBarClientProperty(childPopupMenu);
} else if (subElement instanceof JMenuItem) {
JMenuItem jMenuItem = (JMenuItem) subElement;
setStyle(jMenuItem, FineUIStyle.MENU_ITEM_TOOL_BAR);
}
}
}
}

2
designer-realize/src/main/java/com/fr/grid/selection/CellSelection.java

@ -506,8 +506,6 @@ public class CellSelection extends Selection {
popup.add(DeprecatedActionManager.getDeleteMenu(ePane)); popup.add(DeprecatedActionManager.getDeleteMenu(ePane));
popup.add(DeprecatedActionManager.getClearMenu(ePane)); popup.add(DeprecatedActionManager.getClearMenu(ePane));
popup.addSeparator();
addExtraMenu(ePane, popup); addExtraMenu(ePane, popup);
return popup; return popup;
} }

5
designer-realize/src/main/java/com/fr/grid/selection/Selection.java

@ -70,12 +70,17 @@ public abstract class Selection implements FCloneable, Serializable , Selectable
* @param popupMenu * @param popupMenu
*/ */
public void addExtraMenu(ElementCasePane ePane, UIPopupMenu popupMenu) { public void addExtraMenu(ElementCasePane ePane, UIPopupMenu popupMenu) {
boolean existExtraMenu = false;
Set<RightSelectionHandlerProvider> selectionHandlerProviders = ExtraDesignClassManager.getInstance().getArray(RightSelectionHandlerProvider.XML_TAG); Set<RightSelectionHandlerProvider> selectionHandlerProviders = ExtraDesignClassManager.getInstance().getArray(RightSelectionHandlerProvider.XML_TAG);
for (RightSelectionHandlerProvider handler : selectionHandlerProviders) { for (RightSelectionHandlerProvider handler : selectionHandlerProviders) {
if (handler.accept(this)) { if (handler.accept(this)) {
existExtraMenu = true;
handler.dmlMenu(ePane, popupMenu); handler.dmlMenu(ePane, popupMenu);
} }
} }
if (existExtraMenu) {
popupMenu.addSeparator();
}
} }
public abstract boolean clear(ElementCasePane.Clear type, ElementCasePane ePane); public abstract boolean clear(ElementCasePane.Clear type, ElementCasePane ePane);

Loading…
Cancel
Save