Browse Source

REPORT-107973 翻新上下文菜单弹窗

newui
Leo.Qin 10 months ago
parent
commit
0c9c0b11e9
  1. 50
      designer-base/src/main/java/com/fine/theme/light/ui/FineMenuItemUI.java
  2. 49
      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. 9
      designer-base/src/main/java/com/fine/theme/light/ui/FinePopupMenuUI.java
  5. 6
      designer-base/src/main/java/com/fine/theme/utils/FineClientProperties.java
  6. 1
      designer-base/src/main/java/com/fr/design/data/datapane/TableDataTreePane.java
  7. 3
      designer-base/src/main/java/com/fr/design/gui/imenu/UILockMenuItem.java
  8. 2
      designer-base/src/main/java/com/fr/design/gui/imenu/UIMenuItem.java
  9. 28
      designer-base/src/main/java/com/fr/design/menu/DottedSeparator.java
  10. 24
      designer-base/src/main/java/com/fr/design/menu/LineSeparator.java
  11. 38
      designer-base/src/main/java/com/fr/design/menu/MenuDef.java
  12. 13
      designer-base/src/main/java/com/fr/design/menu/NameSeparator.java
  13. 1
      designer-base/src/main/java/com/fr/design/menu/SnapChatUpdateAction.java
  14. 6
      designer-base/src/main/resources/com/fine/theme/light/ui/laf/FineLaf.properties
  15. 36
      designer-base/src/main/resources/com/fine/theme/light/ui/laf/FineLightLaf.properties
  16. 102
      designer-base/src/test/java/com/fr/design/gui/storybook/components/PopupMenuStoryBoard.java
  17. 2
      designer-realize/src/main/java/com/fr/grid/selection/CellSelection.java
  18. 5
      designer-realize/src/main/java/com/fr/grid/selection/Selection.java

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

@ -0,0 +1,50 @@
package com.fine.theme.light.ui;
import com.fine.theme.utils.FineClientProperties;
import com.fine.theme.utils.FineUIUtils;
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) {
Object clientProperty = c.getClientProperty(FineClientProperties.POPUP_MENU_TYPE);
if (FineClientProperties.POPUP_MENU_TYPE_TOOL_BAR.equals(clientProperty)) {
selectionBackground = FineUIUtils.getUIColor("Menu.toolbar.selectionBackground", "Menu.selectionBackground");
selectionForeground = FineUIUtils.getUIColor("Menu.toolbar.selectionForeground", "Menu.selectionForeground");
acceleratorForeground = FineUIUtils.getUIColor("Menu.toolbar.acceleratorForeground", "Menu.acceleratorForeground");
acceleratorSelectionForeground = FineUIUtils.getUIColor("Menu.toolbar.acceleratorSelectionForeground", "Menu.acceleratorSelectionForeground");
}
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);
}
}
}

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

@ -0,0 +1,49 @@
package com.fine.theme.light.ui;
import com.fine.theme.icon.LazyIcon;
import com.fine.theme.utils.FineClientProperties;
import com.fine.theme.utils.FineUIUtils;
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) {
Object clientProperty = c.getClientProperty(FineClientProperties.POPUP_MENU_TYPE);
if (FineClientProperties.POPUP_MENU_TYPE_TOOL_BAR.equals(clientProperty)) {
selectionBackground = FineUIUtils.getUIColor("MenuItem.toolbar.selectionBackground", "MenuItem.selectionBackground");
selectionForeground = FineUIUtils.getUIColor("MenuItem.toolbar.selectionForeground", "MenuItem.selectionForeground");
acceleratorForeground = FineUIUtils.getUIColor("MenuItem.toolbar.acceleratorForeground", "MenuItem.acceleratorForeground");
acceleratorSelectionForeground = FineUIUtils.getUIColor("MenuItem.toolbar.acceleratorSelectionForeground", "MenuItem.acceleratorSelectionForeground");
}
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();
}
}
}

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

@ -1,5 +1,6 @@
package com.fine.theme.light.ui;
import com.fine.theme.utils.FineClientProperties;
import com.fine.theme.utils.FineUIUtils;
import com.formdev.flatlaf.ui.FlatPopupMenuUI;
@ -19,7 +20,7 @@ import java.awt.geom.RoundRectangle2D;
*/
public class FinePopupMenuUI extends FlatPopupMenuUI {
private int arc;
private final int DEFAULT_ARC = 5;
private final int DEFAULT_ARC = 10;
/**
* 创建UI
@ -39,6 +40,12 @@ public class FinePopupMenuUI extends FlatPopupMenuUI {
@Override
public void paint(Graphics g, JComponent c) {
Object clientProperty = c.getClientProperty(FineClientProperties.POPUP_MENU_TYPE);
if (clientProperty != null && clientProperty.equals(FineClientProperties.POPUP_MENU_TYPE_TOOL_BAR)) {
c.setBackground(FineUIUtils.getUIColor("PopupMenu.toolbar.background", "PopupMenu.background"));
}
// 绘制圆角矩形作为弹窗背景
Graphics2D g2d = (Graphics2D) g;
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);

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

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

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(pasteAction.createMenuItem());
popupMenu.add(removeAction.createMenuItem());
popupMenu.addSeparator();
// 监听
tableDataTree.addMouseListener(new MouseAdapter() {
@Override

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

@ -1,5 +1,6 @@
package com.fr.design.gui.imenu;
import com.fine.theme.utils.FineClientProperties;
import com.fr.design.editlock.EditLockChangeEvent;
import com.fr.design.editlock.EditLockChangeListener;
import com.fr.report.LockItem;
@ -32,7 +33,7 @@ public class UILockMenuItem extends UIMenuItem implements EditLockChangeListener
this.lockedTooltips = lockedTooltips;
this.normalTooltips = normalTooltips;
this.lockItem = lockItem;
setUI(new UILockMenuItemUI());
this.putClientProperty(FineClientProperties.MENU_ITEM_TYPE, FineClientProperties.MENU_ITEM_TYPE_LOCK);
}
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 UIMenuItem() {
this(StringUtils.BLANK);
this(StringUtils.EMPTY);
}
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;
import com.fine.theme.utils.FineUIUtils;
import com.fr.design.actions.UpdateAction;
import com.fr.design.gui.imenu.UIMenuItem;
import javax.swing.UIManager;
import java.awt.BasicStroke;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Insets;
import java.awt.Stroke;
import java.awt.event.ActionEvent;
@ -42,31 +45,32 @@ public class DottedSeparator extends UpdateAction {
}
private class MenuItem extends UIMenuItem {
private final Insets insets;
private final int height;
public MenuItem() {
this.setUI(null);
this.setEnabled(false);
this.removeAll();
insets = FineUIUtils.getAndScaleUIInsets("PopupMenuSeparator.Insets", new Insets(0, 10, 0, 10));
height = FineUIUtils.getAndScaleInt("PopupMenuSeparator.height", 5);
}
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.setColor(UIManager.getColor("Separator.background"));
Stroke bs = new BasicStroke(1f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_ROUND, 2f, new float[] { 3, 1 }, 0);
g2d.setStroke(bs);
g2d.drawLine(30, h / 2+1, w-4, h / 2+1);
this.setForeground(getForeground());
super.paint(g);
}
public Dimension getSize() {
return new Dimension(super.getSize().width, 8);
g2d.drawLine(insets.left, h / 2 + 1, w - insets.right, h / 2 + 1);
}
@Override
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 java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.event.ActionEvent;
/**
@ -47,28 +44,7 @@ public class LineSeparator extends UpdateAction{
private class MenuItem extends UIMenuItem {
public MenuItem() {
this.setUI(null);
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;
import com.fine.theme.icon.LazyIcon;
import com.fine.theme.utils.FineClientProperties;
import com.fr.base.svg.IconUtils;
import com.fr.design.file.HistoryTemplateListCache;
import com.fr.design.gui.ibutton.UIButton;
@ -17,8 +18,10 @@ import com.fr.stable.StringUtils;
import javax.swing.Icon;
import javax.swing.JMenu;
import javax.swing.JMenuItem;
import javax.swing.JPopupMenu;
import javax.swing.JToolBar;
import javax.swing.MenuElement;
import javax.swing.event.MenuEvent;
import javax.swing.event.MenuListener;
import java.awt.Component;
@ -311,7 +314,13 @@ public class MenuDef extends ShortCut {
*/
public void updateMenu() {
//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属性.
if (createdJMenu != null) {
@ -320,6 +329,26 @@ public class MenuDef extends ShortCut {
}
}
private void setToolBarClientProperty(JPopupMenu jPopupMenu) {
jPopupMenu.putClientProperty(FineClientProperties.POPUP_MENU_TYPE, FineClientProperties.POPUP_MENU_TYPE_TOOL_BAR);
MenuElement[] subElements = jPopupMenu.getSubElements();
for (MenuElement subElement : subElements) {
if (subElement instanceof JMenu) {
JMenu jMenu = (JMenu) subElement;
jMenu.putClientProperty(FineClientProperties.POPUP_MENU_TYPE, FineClientProperties.POPUP_MENU_TYPE_TOOL_BAR);
JPopupMenu childPopupMenu = jMenu.getPopupMenu();
setToolBarClientProperty(childPopupMenu);
} else if (subElement instanceof JMenuItem) {
JMenuItem jMenuItem = (JMenuItem) subElement;
jMenuItem.putClientProperty(FineClientProperties.POPUP_MENU_TYPE, FineClientProperties.POPUP_MENU_TYPE_TOOL_BAR);
}
}
}
public void updateEnable() {
setEnabled(checkEnable());
}
@ -350,8 +379,11 @@ public class MenuDef extends ShortCut {
}
nec_seperator = false;
}
shortcut.intoJPopupMenu(popupMenu);
if (shortcut instanceof LineSeparator) {
popupMenu.addSeparator();
} else {
shortcut.intoJPopupMenu(popupMenu);
}
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.imenu.UIMenuItem;
import javax.swing.UIManager;
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.FontMetrics;
@ -44,21 +45,12 @@ public class NameSeparator extends UpdateAction {
private class MenuItem extends UIMenuItem {
public MenuItem(String text) {
this.setUI(null);
this.setEnabled(false);
this.removeAll();
this.setLayout(new BorderLayout());
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() {
return new Dimension(super.getSize().width, 20);
}
@ -85,6 +77,7 @@ public class NameSeparator extends UpdateAction {
for (int i = 0; i < str.length(); 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);
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);
// 设置名字用作单元测
menuItem.setName(getName());
menuItem.setUI(new SnapChatMenuItemUI(this));
object = menuItem;
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
LabelUI=com.formdev.flatlaf.ui.FlatLabelUI
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
MenuItemUI=com.formdev.flatlaf.ui.FlatMenuItemUI
MenuItemUI=com.fine.theme.light.ui.FineMenuItemUI
OptionPaneUI=com.formdev.flatlaf.ui.FlatOptionPaneUI
PanelUI=com.formdev.flatlaf.ui.FlatPanelUI
PasswordFieldUI=com.formdev.flatlaf.ui.FlatPasswordFieldUI
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
RadioButtonUI=com.formdev.flatlaf.ui.FlatRadioButtonUI
RadioButtonMenuItemUI=com.formdev.flatlaf.ui.FlatRadioButtonMenuItemUI

36
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.click=#DADEE7
fill.normal=#FFFFFF
fill.gray=#F2F4F8
fill.disabled=#F2F4F8
border.divider=#DADEE7
tooltip.normal=#3F506A
@ -447,13 +448,17 @@ Menu.icon.disabledArrowColor = @buttonDisabledArrowColor
Menu.border = com.formdev.flatlaf.ui.FlatMenuItemBorder
Menu.arrowIcon = com.formdev.flatlaf.icons.FlatMenuArrowIcon
Menu.checkIcon = null
Menu.margin = @menuItemMargin
Menu.margin=3,10,3,10
Menu.submenuPopupOffsetX = {scaledInteger}-4
Menu.submenuPopupOffsetY = {scaledInteger}-4
Menu.opaque = false
Menu.borderPainted = true
Menu.background = @menuBackground
Menu.selectionBackground=$fill.hover
Menu.toolbar.selectionBackground=$brand.normal
Menu.toolbar.selectionForeground=$text.white
Menu.toolbar.acceleratorForeground=@foreground
Menu.toolbar.acceleratorSelectionForeground=$text.white
#---- MenuBar ----
@ -471,25 +476,31 @@ MenuBar.selectionArc = $MenuItem.selectionArc
MenuItem.border = com.formdev.flatlaf.ui.FlatMenuItemBorder
MenuItem.arrowIcon = com.formdev.flatlaf.icons.FlatMenuItemArrowIcon
MenuItem.checkIcon = null
MenuItem.margin=0,10,0,10
MenuItem.margin=3,10,3,10
MenuItem.opaque = false
MenuItem.borderPainted = true
MenuItem.verticallyAlignText = true
MenuItem.background = @menuBackground
MenuItem.checkBackground = @menuCheckBackground
MenuItem.checkMargins = 2,2,2,2
MenuItem.minimumWidth = 72
MenuItem.minimumWidth=150
MenuItem.minimumIconSize = 16,16
MenuItem.iconTextGap = 6
MenuItem.textAcceleratorGap = 24
MenuItem.textNoAcceleratorGap = 6
MenuItem.acceleratorArrowGap=4
MenuItem.acceleratorDelimiter = "+"
MenuItem.acceleratorForeground=@foreground
MenuItem.acceleratorSelectionForeground=@foreground
MenuItem.toolbar.acceleratorForeground=@foreground
MenuItem.toolbar.acceleratorSelectionForeground=$text.white
[mac]MenuItem.acceleratorDelimiter = ""
MenuItem.selectionInsets = 0,0,0,0
MenuItem.selectionArc = 0
MenuItem.selectionBackground=$brand.normal
MenuItem.selectionForeground=$text.white
MenuItem.selectionInsets=0,4,0,4
MenuItem.selectionArc=4
MenuItem.selectionBackground=$fill.hover
MenuItem.selectionForeground=@foreground
MenuItem.toolbar.selectionBackground=$brand.normal
MenuItem.toolbar.selectionForeground=$text.white
MenuItem.disabledForeground=fade(@foreground,29%)
# for MenuItem.selectionType = underline
@ -497,6 +508,8 @@ MenuItem.underlineSelectionBackground = @menuHoverBackground
MenuItem.underlineSelectionCheckBackground = @menuCheckBackground
MenuItem.underlineSelectionColor = @accentUnderlineColor
MenuItem.underlineSelectionHeight = 3
#---- Separator ----
Separator.background=$border.divider
#---- OptionPane ----
@ -557,16 +570,17 @@ PopupMenu.border=com.fine.theme.light.ui.FinePopupMenuBorder
PopupMenu.borderInsets=10,0,10,0
PopupMenu.borderCornerRadius = $Popup.borderCornerRadius
PopupMenu.background=$background.normal
PopupMenu.toolbar.background=$fill.gray
PopupMenu.scrollArrowColor = @buttonArrowColor
PopupMenu.borderColor=$border.divider
PopupMenu.hoverScrollArrowBackground = darken(@background,5%)
PopupMenu.arc=$Component.arc
PopupMenu.arc=10
#---- PopupMenuSeparator ----
PopupMenuSeparator.height = 9
PopupMenuSeparator.height=5
PopupMenuSeparator.stripeWidth = 1
PopupMenuSeparator.stripeIndent=2
PopupMenuSeparator.Insets=0,10,0,10
#---- ProgressBar ----

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

@ -0,0 +1,102 @@
package com.fr.design.gui.storybook.components;
import com.fine.theme.icon.LazyIcon;
import com.fine.theme.utils.FineClientProperties;
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;
/**
* 弹窗组件
*
* @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) {
jPopupMenu.putClientProperty(FineClientProperties.POPUP_MENU_TYPE, FineClientProperties.POPUP_MENU_TYPE_TOOL_BAR);
MenuElement[] subElements = jPopupMenu.getSubElements();
for (MenuElement subElement : subElements) {
if (subElement instanceof JMenu) {
JMenu jMenu = (JMenu) subElement;
jMenu.putClientProperty(FineClientProperties.POPUP_MENU_TYPE, FineClientProperties.POPUP_MENU_TYPE_TOOL_BAR);
JPopupMenu childPopupMenu = jMenu.getPopupMenu();
setToolBarClientProperty(childPopupMenu);
} else if (subElement instanceof JMenuItem) {
JMenuItem jMenuItem = (JMenuItem) subElement;
jMenuItem.putClientProperty(FineClientProperties.POPUP_MENU_TYPE, FineClientProperties.POPUP_MENU_TYPE_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.getClearMenu(ePane));
popup.addSeparator();
addExtraMenu(ePane, 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
*/
public void addExtraMenu(ElementCasePane ePane, UIPopupMenu popupMenu) {
boolean existExtraMenu = false;
Set<RightSelectionHandlerProvider> selectionHandlerProviders = ExtraDesignClassManager.getInstance().getArray(RightSelectionHandlerProvider.XML_TAG);
for (RightSelectionHandlerProvider handler : selectionHandlerProviders) {
if (handler.accept(this)) {
existExtraMenu = true;
handler.dmlMenu(ePane, popupMenu);
}
}
if (existExtraMenu) {
popupMenu.addSeparator();
}
}
public abstract boolean clear(ElementCasePane.Clear type, ElementCasePane ePane);

Loading…
Cancel
Save