|
|
|
@ -10,16 +10,20 @@ import com.fr.design.gui.storybook.StoryBoard;
|
|
|
|
|
import com.fr.design.menu.DottedSeparator; |
|
|
|
|
import com.fr.design.menu.NameSeparator; |
|
|
|
|
|
|
|
|
|
import javax.swing.Icon; |
|
|
|
|
import javax.swing.JMenu; |
|
|
|
|
import javax.swing.JMenuItem; |
|
|
|
|
import javax.swing.JPopupMenu; |
|
|
|
|
import javax.swing.KeyStroke; |
|
|
|
|
import javax.swing.MenuElement; |
|
|
|
|
import java.awt.event.KeyEvent; |
|
|
|
|
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; |
|
|
|
|
import static com.fr.design.gui.syntax.ui.rtextarea.RTADefaultInputMap.DEFAULT_MODIFIER; |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 弹窗组件 |
|
|
|
@ -36,14 +40,19 @@ public class PopupMenuStoryBoard extends StoryBoard {
|
|
|
|
|
column(70, |
|
|
|
|
cell(new UIButton("点击展示弹窗")).with(it -> { |
|
|
|
|
UIPopupMenu popupMenu = new UIPopupMenu(); |
|
|
|
|
popupMenu.add(new UIMenuItem("test1", new LazyIcon("edit"))); |
|
|
|
|
popupMenu.add(new UIMenuItem("test1")); |
|
|
|
|
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"))); |
|
|
|
|
UIMenuItem menuItem = new UIMenuItem("test4", new LazyIcon("cellOtherAttr")); |
|
|
|
|
menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_N, DEFAULT_MODIFIER)); |
|
|
|
|
popupMenu.add(menuItem); |
|
|
|
|
popupMenu.add(new DottedSeparator().createMenuItem()); |
|
|
|
|
popupMenu.add(new UIMenuItem("test5", new LazyIcon("cellExpandAttr"))); |
|
|
|
|
JMenu test5 = new JMenu("test5"); |
|
|
|
|
test5.setIcon(new LazyIcon("cellExpandAttr")); |
|
|
|
|
popupMenu.add(test5); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
it.addMouseListener(new MouseAdapter() { |
|
|
|
|
|
|
|
|
@ -57,14 +66,18 @@ public class PopupMenuStoryBoard extends StoryBoard {
|
|
|
|
|
|
|
|
|
|
cell(new UIButton("点击展示菜单栏弹窗")).with(it -> { |
|
|
|
|
UIPopupMenu popupMenu = new UIPopupMenu(); |
|
|
|
|
popupMenu.add(new UIMenuItem("test1", new LazyIcon("edit"))); |
|
|
|
|
popupMenu.add(new UIMenuItem("test1")); |
|
|
|
|
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"))); |
|
|
|
|
UIMenuItem menuItem = new UIMenuItem("test4", new LazyIcon("cellOtherAttr")); |
|
|
|
|
menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_N, DEFAULT_MODIFIER)); |
|
|
|
|
popupMenu.add(menuItem); |
|
|
|
|
popupMenu.add(new DottedSeparator().createMenuItem()); |
|
|
|
|
popupMenu.add(new UIMenuItem("test5", new LazyIcon("cellExpandAttr"))); |
|
|
|
|
JMenu test5 = new JMenu("test5"); |
|
|
|
|
test5.setIcon(new LazyIcon("cellExpandAttr")); |
|
|
|
|
popupMenu.add(test5); |
|
|
|
|
|
|
|
|
|
it.addMouseListener(new MouseAdapter() { |
|
|
|
|
|
|
|
|
@ -90,11 +103,19 @@ public class PopupMenuStoryBoard extends StoryBoard {
|
|
|
|
|
for (MenuElement subElement : subElements) { |
|
|
|
|
if (subElement instanceof JMenu) { |
|
|
|
|
JMenu jMenu = (JMenu) subElement; |
|
|
|
|
Icon icon = jMenu.getIcon(); |
|
|
|
|
if (icon instanceof LazyIcon && jMenu.getSelectedIcon() == null) { |
|
|
|
|
jMenu.setSelectedIcon(((LazyIcon) icon).white()); |
|
|
|
|
} |
|
|
|
|
JPopupMenu childPopupMenu = jMenu.getPopupMenu(); |
|
|
|
|
setStyle(jMenu, FineUIStyle.MENU_TOOL_BAR); |
|
|
|
|
setToolBarClientProperty(childPopupMenu); |
|
|
|
|
} else if (subElement instanceof JMenuItem) { |
|
|
|
|
JMenuItem jMenuItem = (JMenuItem) subElement; |
|
|
|
|
Icon icon = jMenuItem.getIcon(); |
|
|
|
|
if (icon instanceof LazyIcon && jMenuItem.getSelectedIcon() == null) { |
|
|
|
|
jMenuItem.setSelectedIcon(((LazyIcon) icon).white()); |
|
|
|
|
} |
|
|
|
|
setStyle(jMenuItem, FineUIStyle.MENU_ITEM_TOOL_BAR); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|