diff --git a/designer_base/src/com/fr/design/actions/UpdateAction.java b/designer_base/src/com/fr/design/actions/UpdateAction.java index 15b679de8f..eb0ede5fa4 100644 --- a/designer_base/src/com/fr/design/actions/UpdateAction.java +++ b/designer_base/src/com/fr/design/actions/UpdateAction.java @@ -9,10 +9,7 @@ import com.fr.base.Style; import com.fr.design.actions.core.ActionFactory; import com.fr.design.constants.UIConstants; import com.fr.design.gui.ibutton.UIButton; -import com.fr.design.gui.imenu.UICheckBoxMenuItem; -import com.fr.design.gui.imenu.UIMenuItem; -import com.fr.design.gui.imenu.UIMenuItemEastAttr; -import com.fr.design.gui.imenu.UIPopupMenu; +import com.fr.design.gui.imenu.*; import com.fr.design.menu.ShortCut; import com.fr.design.selection.SelectionListener; import com.fr.general.ComparatorUtils; @@ -254,13 +251,12 @@ public abstract class UpdateAction extends ShortCut implements Action { return (UIMenuItem) object; } - public UIMenuItemEastAttr createMenuItemEastAttr() { - UIMenuItem menuItem = new UIMenuItemEastAttr(this); + public UIMenuEastAttrItem createMenuItemEastAttr() { + UIMenuEastAttrItem menuItem = new UIMenuEastAttrItem(this); // 设置名字用作单元测 menuItem.setName(getName()); - Object object = menuItem; - this.putValue(UIMenuItem.class.getName(), object); - return (UIMenuItemEastAttr) object; + this.putValue(UIMenuItem.class.getName(), menuItem); + return menuItem; } /** @@ -327,11 +323,9 @@ public abstract class UpdateAction extends ShortCut implements Action { @Override public void intoJPopupMenu(JPopupMenu menu) { update(); - if (menu instanceof UIPopupMenu){ - if (((UIPopupMenu) menu).getRePaint()){ - menu.add(this.createMenuItemEastAttr()); - return; - } + if (menu instanceof UIPopupEastAttrMenu){ + menu.add(this.createMenuItemEastAttr()); + return; } menu.add(this.createMenuItem()); } diff --git a/designer_base/src/com/fr/design/gui/imenu/UIMenuItemEastAttr.java b/designer_base/src/com/fr/design/gui/imenu/UIMenuEastAttrItem.java similarity index 90% rename from designer_base/src/com/fr/design/gui/imenu/UIMenuItemEastAttr.java rename to designer_base/src/com/fr/design/gui/imenu/UIMenuEastAttrItem.java index 53c859a624..442464c61e 100644 --- a/designer_base/src/com/fr/design/gui/imenu/UIMenuItemEastAttr.java +++ b/designer_base/src/com/fr/design/gui/imenu/UIMenuEastAttrItem.java @@ -13,30 +13,30 @@ import java.awt.*; /** * 右侧属性面板悬浮元素、超级链接弹窗重绘 */ -public class UIMenuItemEastAttr extends UIMenuItem { +public class UIMenuEastAttrItem extends JMenuItem { - public UIMenuItemEastAttr() { + public UIMenuEastAttrItem() { this(StringUtils.BLANK); } - public UIMenuItemEastAttr(String string) { + public UIMenuEastAttrItem(String string) { this(string, null); } - public UIMenuItemEastAttr(String string, Icon pageSmallIcon) { + public UIMenuEastAttrItem(String string, Icon pageSmallIcon) { super(string, pageSmallIcon); setBackground(UIConstants.NORMAL_BACKGROUND); setUI(new UIMenuItemEastAttrUI()); } - public UIMenuItemEastAttr(String string, int key) { + public UIMenuEastAttrItem(String string, int key) { super(string, key); setBackground(UIConstants.NORMAL_BACKGROUND); setUI(new UIMenuItemEastAttrUI()); } - public UIMenuItemEastAttr(Action action) { + public UIMenuEastAttrItem(Action action) { this(); setAction(action); } @@ -96,7 +96,7 @@ public class UIMenuItemEastAttr extends UIMenuItem { } } else { SwingUtilities2.drawStringUnderlineCharAt(menuItem, g, text, - -1, -4, textRect.y + fm.getAscent()); + -1, 0, textRect.y + fm.getAscent()); } } } diff --git a/designer_base/src/com/fr/design/gui/imenu/UIPopupEastAttrMenu.java b/designer_base/src/com/fr/design/gui/imenu/UIPopupEastAttrMenu.java new file mode 100644 index 0000000000..42b04e03af --- /dev/null +++ b/designer_base/src/com/fr/design/gui/imenu/UIPopupEastAttrMenu.java @@ -0,0 +1,28 @@ +package com.fr.design.gui.imenu; + +import java.awt.Graphics; +import java.awt.Insets; + +import javax.swing.JPopupMenu; + +import com.fr.design.constants.UIConstants; + +public class UIPopupEastAttrMenu extends JPopupMenu { + + public UIPopupEastAttrMenu() { + super(); + setBackground(UIConstants.NORMAL_BACKGROUND); + } + + @Override + protected void paintBorder(Graphics g) { + g.setColor(UIConstants.POP_DIALOG_BORDER); + g.drawRect(0, 0, getWidth() - 1, getHeight() - 1); + } + + @Override + public Insets getInsets() { + return new Insets(0, 1, 1, 1); + } + +} \ No newline at end of file diff --git a/designer_base/src/com/fr/design/gui/imenu/UIPopupMenu.java b/designer_base/src/com/fr/design/gui/imenu/UIPopupMenu.java index 35f4641ced..44b36ae115 100644 --- a/designer_base/src/com/fr/design/gui/imenu/UIPopupMenu.java +++ b/designer_base/src/com/fr/design/gui/imenu/UIPopupMenu.java @@ -7,49 +7,28 @@ import javax.swing.JPopupMenu; import com.fr.design.constants.UIConstants; -public class UIPopupMenu extends JPopupMenu { - private boolean onlyText = false; - private boolean isEastAttr = false; - - public UIPopupMenu() { - super(); - setBackground(UIConstants.NORMAL_BACKGROUND); - } - - public UIPopupMenu(boolean isEastAttr) { - super(); - this.isEastAttr = isEastAttr; - setBackground(UIConstants.TOOLBARUI_BACKGROUND); - } - - public boolean getRePaint() { - return this.isEastAttr; - } - - @Override - protected void paintBorder(Graphics g) { - if (isEastAttr) { - g.setColor(UIConstants.POP_DIALOG_BORDER); - g.drawRect(0, 0, getWidth() - 1, getHeight() - 1); - } else { - g.setColor(UIConstants.LINE_COLOR); - g.drawRect(0, 0, getWidth() - 1, getHeight() - 1); - } - } - - @Override - public Insets getInsets() { - if (onlyText) { - return super.getInsets(); - } - if (isEastAttr) { - return new Insets(0, 1, 1, 1); - } else { - return new Insets(10, 2, 10, 10); - } - } - - public void setOnlyText(boolean onlyText) { - this.onlyText = onlyText; - } +public class UIPopupMenu extends JPopupMenu{ + private boolean onlyText = false; + public UIPopupMenu() { + super(); + setBackground(UIConstants.NORMAL_BACKGROUND); + } + + @Override + protected void paintBorder(Graphics g) { + g.setColor(UIConstants.LINE_COLOR); + g.drawRect(0, 0, getWidth() - 1, getHeight() - 1); + } + + @Override + public Insets getInsets() { + if(onlyText) { + return super.getInsets(); + } + return new Insets(10, 2, 10, 10); + } + + public void setOnlyText(boolean onlyText) { + this.onlyText = onlyText; + } } \ No newline at end of file diff --git a/designer_base/src/com/fr/design/menu/MenuDef.java b/designer_base/src/com/fr/design/menu/MenuDef.java index ae61d0eeab..00dd2ff3ae 100644 --- a/designer_base/src/com/fr/design/menu/MenuDef.java +++ b/designer_base/src/com/fr/design/menu/MenuDef.java @@ -3,6 +3,7 @@ package com.fr.design.menu; import com.fr.base.BaseUtils; import com.fr.design.gui.ibutton.UIButton; 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.UIScrollMenu; import com.fr.design.gui.iscrollbar.UIScrollBar; @@ -402,7 +403,7 @@ public class MenuDef extends ShortCut { return; } if (isEastAttr) { - popupMenu = new UIPopupMenu(isEastAttr); + popupMenu = new UIPopupEastAttrMenu(); popupMenu.setInvoker(button); MenuDef.this.updateEastPopupMenu(popupMenu); popupMenu.setPopupSize(new Dimension(MENU_DEFAULTWDITH, popupMenu.getPreferredSize().height));