|
|
@ -3,6 +3,7 @@ package com.fr.design.menu; |
|
|
|
import com.fr.base.BaseUtils; |
|
|
|
import com.fr.base.BaseUtils; |
|
|
|
import com.fr.design.gui.ibutton.UIButton; |
|
|
|
import com.fr.design.gui.ibutton.UIButton; |
|
|
|
import com.fr.design.gui.imenu.UIMenu; |
|
|
|
import com.fr.design.gui.imenu.UIMenu; |
|
|
|
|
|
|
|
import com.fr.design.gui.imenu.UIPopupEastAttrMenu; |
|
|
|
import com.fr.design.gui.imenu.UIPopupMenu; |
|
|
|
import com.fr.design.gui.imenu.UIPopupMenu; |
|
|
|
import com.fr.design.gui.imenu.UIScrollMenu; |
|
|
|
import com.fr.design.gui.imenu.UIScrollMenu; |
|
|
|
import com.fr.design.gui.iscrollbar.UIScrollBar; |
|
|
|
import com.fr.design.gui.iscrollbar.UIScrollBar; |
|
|
@ -13,7 +14,10 @@ import javax.swing.*; |
|
|
|
import javax.swing.event.MenuEvent; |
|
|
|
import javax.swing.event.MenuEvent; |
|
|
|
import javax.swing.event.MenuListener; |
|
|
|
import javax.swing.event.MenuListener; |
|
|
|
import java.awt.*; |
|
|
|
import java.awt.*; |
|
|
|
import java.awt.event.*; |
|
|
|
import java.awt.event.ContainerListener; |
|
|
|
|
|
|
|
import java.awt.event.MouseAdapter; |
|
|
|
|
|
|
|
import java.awt.event.MouseEvent; |
|
|
|
|
|
|
|
import java.awt.event.MouseListener; |
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.List; |
|
|
|
import java.util.List; |
|
|
|
|
|
|
|
|
|
|
@ -22,338 +26,406 @@ import java.util.List; |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public class MenuDef extends ShortCut { |
|
|
|
public class MenuDef extends ShortCut { |
|
|
|
|
|
|
|
|
|
|
|
protected String name; |
|
|
|
private static final int MENU_DEFAULTWDITH = 156; |
|
|
|
protected char mnemonic; |
|
|
|
protected String name; |
|
|
|
protected String iconPath; |
|
|
|
//右侧属性表弹出框重绘
|
|
|
|
protected String tooltip; |
|
|
|
protected Boolean isEastAttr = false; |
|
|
|
//item List.
|
|
|
|
protected char mnemonic; |
|
|
|
private List<ShortCut> shortcutList = new ArrayList<ShortCut>(); |
|
|
|
protected String iconPath; |
|
|
|
// peter:产生的JMenu, UIButton以及enabled变量都是为由MenuDef产生的控件所用的
|
|
|
|
protected String tooltip; |
|
|
|
protected boolean enabled = true; |
|
|
|
//item List.
|
|
|
|
protected UIMenu createdJMenu; |
|
|
|
private List<ShortCut> shortcutList = new ArrayList<ShortCut>(); |
|
|
|
protected UIButton createdButton; |
|
|
|
// peter:产生的JMenu, UIButton以及enabled变量都是为由MenuDef产生的控件所用的
|
|
|
|
protected JPopupMenu popupMenu; |
|
|
|
protected boolean enabled = true; |
|
|
|
private boolean hasScrollSubMenu; |
|
|
|
protected UIMenu createdJMenu; |
|
|
|
|
|
|
|
protected UIButton createdButton; |
|
|
|
private String anchor; |
|
|
|
protected JPopupMenu popupMenu; |
|
|
|
|
|
|
|
private boolean hasScrollSubMenu; |
|
|
|
public MenuDef() { |
|
|
|
|
|
|
|
} |
|
|
|
private String anchor; |
|
|
|
|
|
|
|
|
|
|
|
public MenuDef(String name) { |
|
|
|
public MenuDef() { |
|
|
|
this.setName(name); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public MenuDef(String name) { |
|
|
|
public MenuDef(String name, char mnemonic) { |
|
|
|
this.setName(name); |
|
|
|
this.setName(name); |
|
|
|
} |
|
|
|
this.setMnemonic(mnemonic); |
|
|
|
|
|
|
|
} |
|
|
|
public MenuDef(Boolean rePaint) { |
|
|
|
|
|
|
|
this.setRePaint(rePaint); |
|
|
|
public String getName() { |
|
|
|
} |
|
|
|
return name; |
|
|
|
|
|
|
|
} |
|
|
|
public MenuDef(String name, char mnemonic) { |
|
|
|
|
|
|
|
this.setName(name); |
|
|
|
public void setName(String name) { |
|
|
|
this.setMnemonic(mnemonic); |
|
|
|
this.name = name; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public String getName() { |
|
|
|
public char getMnemonic() { |
|
|
|
return name; |
|
|
|
return mnemonic; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public void setName(String name) { |
|
|
|
public void setMnemonic(char mnemonic) { |
|
|
|
this.name = name; |
|
|
|
this.mnemonic = mnemonic; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public boolean getRePaint() { |
|
|
|
public void setHasScrollSubMenu(boolean scrollSubMenu) { |
|
|
|
return isEastAttr; |
|
|
|
this.hasScrollSubMenu = scrollSubMenu; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public void setRePaint(boolean rePaint) { |
|
|
|
public String getIconPath() { |
|
|
|
this.isEastAttr = rePaint; |
|
|
|
return iconPath; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public char getMnemonic() { |
|
|
|
public void setIconPath(String iconPath) { |
|
|
|
return mnemonic; |
|
|
|
this.iconPath = iconPath; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public void setMnemonic(char mnemonic) { |
|
|
|
public int getShortCutCount() { |
|
|
|
this.mnemonic = mnemonic; |
|
|
|
return this.shortcutList.size(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public void setHasScrollSubMenu(boolean scrollSubMenu) { |
|
|
|
public ShortCut getShortCut(int index) { |
|
|
|
this.hasScrollSubMenu = scrollSubMenu; |
|
|
|
return this.shortcutList.get(index); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public String getIconPath() { |
|
|
|
public String getAnchor() { |
|
|
|
return iconPath; |
|
|
|
return anchor == null ? StringUtils.EMPTY : anchor; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public void setIconPath(String iconPath) { |
|
|
|
public void setAnchor(String anchor) { |
|
|
|
this.iconPath = iconPath; |
|
|
|
this.anchor = anchor; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public int getShortCutCount() { |
|
|
|
public List<ShortCut> getShortcutList() { |
|
|
|
return this.shortcutList.size(); |
|
|
|
return this.shortcutList; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public ShortCut getShortCut(int index) { |
|
|
|
/** |
|
|
|
return this.shortcutList.get(index); |
|
|
|
* 插入菜单项 |
|
|
|
} |
|
|
|
* @param index 插入的位置 |
|
|
|
|
|
|
|
* @param shortCut 菜单信息 |
|
|
|
public String getAnchor() { |
|
|
|
*/ |
|
|
|
return anchor == null ? StringUtils.EMPTY : anchor; |
|
|
|
public void insertShortCut(int index, ShortCut shortCut) { |
|
|
|
} |
|
|
|
int size = this.shortcutList.size(); |
|
|
|
|
|
|
|
index = Math.min(index, size); |
|
|
|
public void setAnchor(String anchor) { |
|
|
|
this.shortcutList.add(index, shortCut); |
|
|
|
this.anchor = anchor; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
public List<ShortCut> getShortcutList() { |
|
|
|
* 用可变参数,方便添加数组 |
|
|
|
return this.shortcutList; |
|
|
|
* @param shortcut 参数 存储菜单项信息 |
|
|
|
} |
|
|
|
*/ |
|
|
|
|
|
|
|
public void addShortCut(ShortCut... shortcut) { |
|
|
|
/** |
|
|
|
for (ShortCut i : shortcut) { |
|
|
|
* 插入菜单项 |
|
|
|
this.shortcutList.add(i); |
|
|
|
* |
|
|
|
} |
|
|
|
* @param index 插入的位置 |
|
|
|
} |
|
|
|
* @param shortCut 菜单信息 |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
public void insertShortCut(int index, ShortCut shortCut) { |
|
|
|
|
|
|
|
int size = this.shortcutList.size(); |
|
|
|
|
|
|
|
index = Math.min(index, size); |
|
|
|
|
|
|
|
this.shortcutList.add(index, shortCut); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 用可变参数,方便添加数组 |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* @param shortcut 参数 存储菜单项信息 |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
public void addShortCut(ShortCut... shortcut) { |
|
|
|
|
|
|
|
for (ShortCut i : shortcut) { |
|
|
|
|
|
|
|
this.shortcutList.add(i); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public void removeShortCut(ShortCut shortCut) { |
|
|
|
public void removeShortCut(ShortCut shortCut) { |
|
|
|
|
|
|
|
|
|
|
|
this.shortcutList.remove(shortCut); |
|
|
|
this.shortcutList.remove(shortCut); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* 清理 |
|
|
|
* 清理 |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public void clearShortCuts() { |
|
|
|
public void clearShortCuts() { |
|
|
|
this.shortcutList.clear(); |
|
|
|
this.shortcutList.clear(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* 生成UIButton |
|
|
|
* 生成UIButton |
|
|
|
* @return 菜单按钮 |
|
|
|
* |
|
|
|
*/ |
|
|
|
* @return 菜单按钮 |
|
|
|
public UIButton createUIButton() { |
|
|
|
*/ |
|
|
|
if (createdButton == null) { |
|
|
|
public UIButton createUIButton() { |
|
|
|
if (iconPath != null) { |
|
|
|
if (createdButton == null) { |
|
|
|
createdButton = new UIButton(BaseUtils.readIcon(iconPath)); |
|
|
|
if (iconPath != null) { |
|
|
|
createdButton.set4ToolbarButton(); |
|
|
|
createdButton = new UIButton(BaseUtils.readIcon(iconPath)); |
|
|
|
} else { |
|
|
|
createdButton.set4ToolbarButton(); |
|
|
|
createdButton = new UIButton(name); |
|
|
|
} else { |
|
|
|
} |
|
|
|
createdButton = new UIButton(name); |
|
|
|
// 添加名字以作自动化测试
|
|
|
|
} |
|
|
|
createdButton.setName(name); |
|
|
|
// 添加名字以作自动化测试
|
|
|
|
createdButton.setToolTipText(tooltip); |
|
|
|
createdButton.setName(name); |
|
|
|
createdButton.addMouseListener(mouseListener); |
|
|
|
createdButton.setToolTipText(tooltip); |
|
|
|
} |
|
|
|
createdButton.addMouseListener(mouseListener); |
|
|
|
|
|
|
|
} |
|
|
|
return createdButton; |
|
|
|
|
|
|
|
} |
|
|
|
return createdButton; |
|
|
|
|
|
|
|
} |
|
|
|
public void setTooltip(String text) { |
|
|
|
|
|
|
|
this.tooltip = text; |
|
|
|
public void setTooltip(String text) { |
|
|
|
} |
|
|
|
this.tooltip = text; |
|
|
|
|
|
|
|
} |
|
|
|
/** |
|
|
|
|
|
|
|
* 生成JMenu |
|
|
|
/** |
|
|
|
* @return 菜单 |
|
|
|
* 生成JMenu |
|
|
|
*/ |
|
|
|
* |
|
|
|
public UIMenu createJMenu() { |
|
|
|
* @return 菜单 |
|
|
|
if (createdJMenu == null) { |
|
|
|
*/ |
|
|
|
if (hasScrollSubMenu) { |
|
|
|
public UIMenu createJMenu() { |
|
|
|
createdJMenu = new UIScrollMenu(this.getName()); |
|
|
|
if (createdJMenu == null) { |
|
|
|
} else { |
|
|
|
if (hasScrollSubMenu) { |
|
|
|
createdJMenu = new UIMenu(this.getName()); |
|
|
|
createdJMenu = new UIScrollMenu(this.getName()); |
|
|
|
} |
|
|
|
} else { |
|
|
|
createdJMenu.setMnemonic(this.getMnemonic()); |
|
|
|
createdJMenu = new UIMenu(this.getName()); |
|
|
|
if (this.iconPath != null) { |
|
|
|
} |
|
|
|
createdJMenu.setIcon(BaseUtils.readIcon(this.iconPath)); |
|
|
|
createdJMenu.setMnemonic(this.getMnemonic()); |
|
|
|
} |
|
|
|
if (this.iconPath != null) { |
|
|
|
createdJMenu.addMenuListener(menuDefListener); |
|
|
|
createdJMenu.setIcon(BaseUtils.readIcon(this.iconPath)); |
|
|
|
ContainerListener listener = getContainerListener(); |
|
|
|
} |
|
|
|
if(listener != null){ |
|
|
|
createdJMenu.addMenuListener(menuDefListener); |
|
|
|
createdJMenu.getPopupMenu().addContainerListener(listener); |
|
|
|
ContainerListener listener = getContainerListener(); |
|
|
|
} |
|
|
|
if (listener != null) { |
|
|
|
} |
|
|
|
createdJMenu.getPopupMenu().addContainerListener(listener); |
|
|
|
|
|
|
|
} |
|
|
|
return createdJMenu; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return createdJMenu; |
|
|
|
protected ContainerListener getContainerListener() { |
|
|
|
} |
|
|
|
return null; |
|
|
|
|
|
|
|
} |
|
|
|
protected ContainerListener getContainerListener() { |
|
|
|
/** |
|
|
|
return null; |
|
|
|
* 生成 JPopupMenu |
|
|
|
} |
|
|
|
* @return 弹出菜单 |
|
|
|
|
|
|
|
*/ |
|
|
|
/** |
|
|
|
public JPopupMenu createJPopupMenu() { |
|
|
|
* 生成 JPopupMenu |
|
|
|
UIMenu menu = createJMenu(); |
|
|
|
* |
|
|
|
updateMenu(); |
|
|
|
* @return 弹出菜单 |
|
|
|
return menu.getPopupMenu(); |
|
|
|
*/ |
|
|
|
} |
|
|
|
public JPopupMenu createJPopupMenu() { |
|
|
|
|
|
|
|
UIMenu menu = createJMenu(); |
|
|
|
/** |
|
|
|
updateMenu(); |
|
|
|
* 设置是否可用 |
|
|
|
return menu.getPopupMenu(); |
|
|
|
* @param b 布尔型 |
|
|
|
} |
|
|
|
*/ |
|
|
|
|
|
|
|
@Override |
|
|
|
/** |
|
|
|
public void setEnabled(boolean b) { |
|
|
|
* 设置是否可用 |
|
|
|
this.enabled = b; |
|
|
|
* |
|
|
|
|
|
|
|
* @param b 布尔型 |
|
|
|
if (createdButton != null) { |
|
|
|
*/ |
|
|
|
createdButton.setEnabled(enabled); |
|
|
|
@Override |
|
|
|
} |
|
|
|
public void setEnabled(boolean b) { |
|
|
|
|
|
|
|
this.enabled = b; |
|
|
|
if (createdJMenu != null) { |
|
|
|
|
|
|
|
createdJMenu.setEnabled(enabled); |
|
|
|
if (createdButton != null) { |
|
|
|
} |
|
|
|
createdButton.setEnabled(enabled); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
if (createdJMenu != null) { |
|
|
|
* 按钮状态 |
|
|
|
createdJMenu.setEnabled(enabled); |
|
|
|
* @return 状态 |
|
|
|
} |
|
|
|
*/ |
|
|
|
} |
|
|
|
@Override |
|
|
|
|
|
|
|
public boolean isEnabled() { |
|
|
|
/** |
|
|
|
return enabled; |
|
|
|
* 按钮状态 |
|
|
|
} |
|
|
|
* |
|
|
|
|
|
|
|
* @return 状态 |
|
|
|
/** |
|
|
|
*/ |
|
|
|
* 更新菜单 |
|
|
|
@Override |
|
|
|
*/ |
|
|
|
public boolean isEnabled() { |
|
|
|
public void updateMenu() { |
|
|
|
return enabled; |
|
|
|
//peter:这个方法用来产生JMenu的孩子控件,但是不update,action.
|
|
|
|
} |
|
|
|
this.updatePopupMenu(this.createJMenu().getPopupMenu()); |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
//peter:需要设置JMenu的enabled属性.
|
|
|
|
* 更新菜单 |
|
|
|
if (createdJMenu != null) { |
|
|
|
*/ |
|
|
|
createdJMenu.setEnabled(createdJMenu.getPopupMenu().getComponentCount() > 0 && enabled); |
|
|
|
public void updateMenu() { |
|
|
|
createdJMenu.repaint(10); |
|
|
|
//peter:这个方法用来产生JMenu的孩子控件,但是不update,action.
|
|
|
|
} |
|
|
|
this.updatePopupMenu(this.createJMenu().getPopupMenu()); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//peter:需要设置JMenu的enabled属性.
|
|
|
|
/** |
|
|
|
if (createdJMenu != null) { |
|
|
|
* 更新菜单 |
|
|
|
createdJMenu.setEnabled(createdJMenu.getPopupMenu().getComponentCount() > 0 && enabled); |
|
|
|
* @param popupMenu 菜单 |
|
|
|
createdJMenu.repaint(10); |
|
|
|
*/ |
|
|
|
} |
|
|
|
protected void updatePopupMenu(JPopupMenu popupMenu) { |
|
|
|
} |
|
|
|
removeComponent(popupMenu); |
|
|
|
|
|
|
|
this.popupMenu = popupMenu; |
|
|
|
/** |
|
|
|
// 一开始是不能插入分隔符的
|
|
|
|
* 更新菜单 |
|
|
|
boolean nec_seperator = false; |
|
|
|
* |
|
|
|
boolean isFirstItem = true; |
|
|
|
* @param popupMenu 菜单 |
|
|
|
int actionCount = this.getShortCutCount(); |
|
|
|
*/ |
|
|
|
for (int i = 0; i < actionCount; i++) { |
|
|
|
protected void updatePopupMenu(JPopupMenu popupMenu) { |
|
|
|
ShortCut shortcut = this.getShortCut(i); |
|
|
|
removeComponent(popupMenu); |
|
|
|
|
|
|
|
this.popupMenu = popupMenu; |
|
|
|
// 如果shortcut是SeparatorDef,先不加,先标记一下nec_seperator为true,等下一个shortcut需要加到PopupMenu时再加
|
|
|
|
// 一开始是不能插入分隔符的
|
|
|
|
if (shortcut instanceof SeparatorDef) { |
|
|
|
boolean nec_seperator = false; |
|
|
|
nec_seperator = true; |
|
|
|
boolean isFirstItem = true; |
|
|
|
continue; |
|
|
|
int actionCount = this.getShortCutCount(); |
|
|
|
} |
|
|
|
for (int i = 0; i < actionCount; i++) { |
|
|
|
if (nec_seperator) { |
|
|
|
ShortCut shortcut = this.getShortCut(i); |
|
|
|
if (!isFirstItem) { |
|
|
|
|
|
|
|
SeparatorDef.DEFAULT.intoJPopupMenu(popupMenu); |
|
|
|
// 如果shortcut是SeparatorDef,先不加,先标记一下nec_seperator为true,等下一个shortcut需要加到PopupMenu时再加
|
|
|
|
} |
|
|
|
if (shortcut instanceof SeparatorDef) { |
|
|
|
nec_seperator = false; |
|
|
|
nec_seperator = true; |
|
|
|
} |
|
|
|
continue; |
|
|
|
|
|
|
|
} |
|
|
|
shortcut.intoJPopupMenu(popupMenu); |
|
|
|
if (nec_seperator) { |
|
|
|
isFirstItem = false; |
|
|
|
if (!isFirstItem) { |
|
|
|
} |
|
|
|
SeparatorDef.DEFAULT.intoJPopupMenu(popupMenu); |
|
|
|
|
|
|
|
} |
|
|
|
if (createdJMenu != null && createdJMenu.getPopupMenu() != null){ |
|
|
|
nec_seperator = false; |
|
|
|
setEnabled(createdJMenu.getPopupMenu().getComponentCount() > 0 && enabled); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
shortcut.intoJPopupMenu(popupMenu); |
|
|
|
|
|
|
|
isFirstItem = false; |
|
|
|
/** |
|
|
|
} |
|
|
|
* 删除所有组件 除了滚动条 |
|
|
|
|
|
|
|
* @param popupMenu 菜单 |
|
|
|
if (createdJMenu != null && createdJMenu.getPopupMenu() != null) { |
|
|
|
*/ |
|
|
|
setEnabled(createdJMenu.getPopupMenu().getComponentCount() > 0 && enabled); |
|
|
|
public void removeComponent(JPopupMenu popupMenu){ |
|
|
|
} |
|
|
|
UIScrollBar uiScrollBar = new UIScrollBar(); |
|
|
|
} |
|
|
|
if(hasScrollSubMenu){ |
|
|
|
|
|
|
|
for(Component comp : popupMenu.getComponents()){ |
|
|
|
/** |
|
|
|
if(comp instanceof UIScrollBar){ |
|
|
|
* 更新右侧属性面板菜单 |
|
|
|
uiScrollBar =(UIScrollBar) comp; |
|
|
|
* |
|
|
|
} |
|
|
|
* @param popupMenu 菜单 |
|
|
|
} |
|
|
|
*/ |
|
|
|
} |
|
|
|
protected void updateEastPopupMenu(JPopupMenu popupMenu) { |
|
|
|
popupMenu.removeAll(); |
|
|
|
removeComponent(popupMenu); |
|
|
|
if(hasScrollSubMenu){ |
|
|
|
this.popupMenu = popupMenu; |
|
|
|
popupMenu.add(uiScrollBar); |
|
|
|
// 一开始是不能插入分隔符的
|
|
|
|
} |
|
|
|
boolean nec_seperator = false; |
|
|
|
} |
|
|
|
boolean isFirstItem = true; |
|
|
|
|
|
|
|
int actionCount = this.getShortCutCount(); |
|
|
|
/** |
|
|
|
for (int i = 0; i < actionCount; i++) { |
|
|
|
* 添加菜单项 |
|
|
|
ShortCut shortcut = this.getShortCut(i); |
|
|
|
* @param menu 菜单 |
|
|
|
|
|
|
|
*/ |
|
|
|
// 如果shortcut是SeparatorDef,先不加,先标记一下nec_seperator为true,等下一个shortcut需要加到PopupMenu时再加
|
|
|
|
@Override |
|
|
|
if (shortcut instanceof SeparatorDef) { |
|
|
|
public void intoJPopupMenu(JPopupMenu menu) { |
|
|
|
nec_seperator = true; |
|
|
|
updateMenu(); |
|
|
|
continue; |
|
|
|
|
|
|
|
} |
|
|
|
menu.add(this.createJMenu()); |
|
|
|
if (nec_seperator) { |
|
|
|
} |
|
|
|
if (!isFirstItem) { |
|
|
|
|
|
|
|
SeparatorDef.DEFAULT.intoJPopupMenu(popupMenu); |
|
|
|
/** |
|
|
|
} |
|
|
|
* 添加 |
|
|
|
nec_seperator = false; |
|
|
|
* @param toolBar 菜单条 |
|
|
|
} |
|
|
|
*/ |
|
|
|
shortcut.intoJPopupMenu(popupMenu); |
|
|
|
@Override |
|
|
|
isFirstItem = false; |
|
|
|
public void intoJToolBar(JToolBar toolBar) { |
|
|
|
} |
|
|
|
toolBar.add(this.createUIButton()); |
|
|
|
|
|
|
|
} |
|
|
|
if (createdJMenu != null && createdJMenu.getPopupMenu() != null) { |
|
|
|
|
|
|
|
setEnabled(createdJMenu.getPopupMenu().getComponentCount() > 0 && enabled); |
|
|
|
private MenuListener menuDefListener = new MenuListener() { |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
@Override |
|
|
|
|
|
|
|
public void menuCanceled(MenuEvent evt) { |
|
|
|
/** |
|
|
|
} |
|
|
|
* 删除所有组件 除了滚动条 |
|
|
|
|
|
|
|
* |
|
|
|
@Override |
|
|
|
* @param popupMenu 菜单 |
|
|
|
public void menuDeselected(MenuEvent evt) { |
|
|
|
*/ |
|
|
|
} |
|
|
|
public void removeComponent(JPopupMenu popupMenu) { |
|
|
|
|
|
|
|
UIScrollBar uiScrollBar = new UIScrollBar(); |
|
|
|
@Override |
|
|
|
if (hasScrollSubMenu) { |
|
|
|
public void menuSelected(MenuEvent evt) { |
|
|
|
for (Component comp : popupMenu.getComponents()) { |
|
|
|
Object source = evt.getSource(); |
|
|
|
if (comp instanceof UIScrollBar) { |
|
|
|
if (!(source instanceof JMenu)) { |
|
|
|
uiScrollBar = (UIScrollBar) comp; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
MenuDef.this.updateMenu(); |
|
|
|
popupMenu.removeAll(); |
|
|
|
} |
|
|
|
if (hasScrollSubMenu) { |
|
|
|
}; |
|
|
|
popupMenu.add(uiScrollBar); |
|
|
|
private MouseListener mouseListener = new MouseAdapter() { |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
@Override |
|
|
|
|
|
|
|
public void mouseReleased(MouseEvent evt) { |
|
|
|
/** |
|
|
|
Object source = evt.getSource(); |
|
|
|
* 添加菜单项 |
|
|
|
UIButton button = (UIButton) source; |
|
|
|
* |
|
|
|
if (!button.isEnabled()) { |
|
|
|
* @param menu 菜单 |
|
|
|
return; |
|
|
|
*/ |
|
|
|
} |
|
|
|
@Override |
|
|
|
|
|
|
|
public void intoJPopupMenu(JPopupMenu menu) { |
|
|
|
UIPopupMenu popupMenu = new UIPopupMenu(); |
|
|
|
updateMenu(); |
|
|
|
popupMenu.setInvoker(button); |
|
|
|
|
|
|
|
MenuDef.this.updatePopupMenu(popupMenu); |
|
|
|
menu.add(this.createJMenu()); |
|
|
|
|
|
|
|
} |
|
|
|
GUICoreUtils.showPopupMenu(popupMenu, button, 0, button.getSize().height); |
|
|
|
|
|
|
|
} |
|
|
|
/** |
|
|
|
}; |
|
|
|
* 添加 |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* @param toolBar 菜单条 |
|
|
|
//ben: for ui test
|
|
|
|
*/ |
|
|
|
public JPopupMenu getPopupMenu() { |
|
|
|
@Override |
|
|
|
return popupMenu; |
|
|
|
public void intoJToolBar(JToolBar toolBar) { |
|
|
|
} |
|
|
|
toolBar.add(this.createUIButton()); |
|
|
|
|
|
|
|
} |
|
|
|
public void setPopupMenu(JPopupMenu popupMenu) { |
|
|
|
|
|
|
|
this.popupMenu = popupMenu; |
|
|
|
private MenuListener menuDefListener = new MenuListener() { |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
public void menuCanceled(MenuEvent evt) { |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
public void menuDeselected(MenuEvent evt) { |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
public void menuSelected(MenuEvent evt) { |
|
|
|
|
|
|
|
Object source = evt.getSource(); |
|
|
|
|
|
|
|
if (!(source instanceof JMenu)) { |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
MenuDef.this.updateMenu(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
private MouseListener mouseListener = new MouseAdapter() { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
public void mouseReleased(MouseEvent evt) { |
|
|
|
|
|
|
|
Object source = evt.getSource(); |
|
|
|
|
|
|
|
UIButton button = (UIButton) source; |
|
|
|
|
|
|
|
if (!button.isEnabled()) { |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (isEastAttr) { |
|
|
|
|
|
|
|
popupMenu = new UIPopupEastAttrMenu(); |
|
|
|
|
|
|
|
popupMenu.setInvoker(button); |
|
|
|
|
|
|
|
MenuDef.this.updateEastPopupMenu(popupMenu); |
|
|
|
|
|
|
|
popupMenu.setPopupSize(new Dimension(MENU_DEFAULTWDITH, popupMenu.getPreferredSize().height)); |
|
|
|
|
|
|
|
GUICoreUtils.showPopupMenu(popupMenu, button, 0, button.getSize().height); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
popupMenu = new UIPopupMenu(); |
|
|
|
|
|
|
|
popupMenu.setInvoker(button); |
|
|
|
|
|
|
|
MenuDef.this.updatePopupMenu(popupMenu); |
|
|
|
|
|
|
|
GUICoreUtils.showPopupMenu(popupMenu, button, 0, button.getSize().height); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//ben: for ui test
|
|
|
|
|
|
|
|
public JPopupMenu getPopupMenu() { |
|
|
|
|
|
|
|
return popupMenu; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void setPopupMenu(JPopupMenu popupMenu) { |
|
|
|
|
|
|
|
this.popupMenu = popupMenu; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |