Browse Source

代码质量

master
MoMeak 7 years ago
parent
commit
d6213e3b69
  1. 18
      designer_base/src/com/fr/design/actions/UpdateAction.java
  2. 14
      designer_base/src/com/fr/design/gui/imenu/UIMenuEastAttrItem.java
  3. 28
      designer_base/src/com/fr/design/gui/imenu/UIPopupEastAttrMenu.java
  4. 21
      designer_base/src/com/fr/design/gui/imenu/UIPopupMenu.java
  5. 3
      designer_base/src/com/fr/design/menu/MenuDef.java

18
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.actions.core.ActionFactory;
import com.fr.design.constants.UIConstants; import com.fr.design.constants.UIConstants;
import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.gui.imenu.UICheckBoxMenuItem; import com.fr.design.gui.imenu.*;
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.menu.ShortCut; import com.fr.design.menu.ShortCut;
import com.fr.design.selection.SelectionListener; import com.fr.design.selection.SelectionListener;
import com.fr.general.ComparatorUtils; import com.fr.general.ComparatorUtils;
@ -254,13 +251,12 @@ public abstract class UpdateAction extends ShortCut implements Action {
return (UIMenuItem) object; return (UIMenuItem) object;
} }
public UIMenuItemEastAttr createMenuItemEastAttr() { public UIMenuEastAttrItem createMenuItemEastAttr() {
UIMenuItem menuItem = new UIMenuItemEastAttr(this); UIMenuEastAttrItem menuItem = new UIMenuEastAttrItem(this);
// 设置名字用作单元测 // 设置名字用作单元测
menuItem.setName(getName()); menuItem.setName(getName());
Object object = menuItem; this.putValue(UIMenuItem.class.getName(), menuItem);
this.putValue(UIMenuItem.class.getName(), object); return menuItem;
return (UIMenuItemEastAttr) object;
} }
/** /**
@ -327,12 +323,10 @@ public abstract class UpdateAction extends ShortCut implements Action {
@Override @Override
public void intoJPopupMenu(JPopupMenu menu) { public void intoJPopupMenu(JPopupMenu menu) {
update(); update();
if (menu instanceof UIPopupMenu){ if (menu instanceof UIPopupEastAttrMenu){
if (((UIPopupMenu) menu).getRePaint()){
menu.add(this.createMenuItemEastAttr()); menu.add(this.createMenuItemEastAttr());
return; return;
} }
}
menu.add(this.createMenuItem()); menu.add(this.createMenuItem());
} }

14
designer_base/src/com/fr/design/gui/imenu/UIMenuItemEastAttr.java → 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); this(StringUtils.BLANK);
} }
public UIMenuItemEastAttr(String string) { public UIMenuEastAttrItem(String string) {
this(string, null); this(string, null);
} }
public UIMenuItemEastAttr(String string, Icon pageSmallIcon) { public UIMenuEastAttrItem(String string, Icon pageSmallIcon) {
super(string, pageSmallIcon); super(string, pageSmallIcon);
setBackground(UIConstants.NORMAL_BACKGROUND); setBackground(UIConstants.NORMAL_BACKGROUND);
setUI(new UIMenuItemEastAttrUI()); setUI(new UIMenuItemEastAttrUI());
} }
public UIMenuItemEastAttr(String string, int key) { public UIMenuEastAttrItem(String string, int key) {
super(string, key); super(string, key);
setBackground(UIConstants.NORMAL_BACKGROUND); setBackground(UIConstants.NORMAL_BACKGROUND);
setUI(new UIMenuItemEastAttrUI()); setUI(new UIMenuItemEastAttrUI());
} }
public UIMenuItemEastAttr(Action action) { public UIMenuEastAttrItem(Action action) {
this(); this();
setAction(action); setAction(action);
} }
@ -96,7 +96,7 @@ public class UIMenuItemEastAttr extends UIMenuItem {
} }
} else { } else {
SwingUtilities2.drawStringUnderlineCharAt(menuItem, g, text, SwingUtilities2.drawStringUnderlineCharAt(menuItem, g, text,
-1, -4, textRect.y + fm.getAscent()); -1, 0, textRect.y + fm.getAscent());
} }
} }
} }

28
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);
}
}

21
designer_base/src/com/fr/design/gui/imenu/UIPopupMenu.java

@ -9,45 +9,24 @@ import com.fr.design.constants.UIConstants;
public class UIPopupMenu extends JPopupMenu{ public class UIPopupMenu extends JPopupMenu{
private boolean onlyText = false; private boolean onlyText = false;
private boolean isEastAttr = false;
public UIPopupMenu() { public UIPopupMenu() {
super(); super();
setBackground(UIConstants.NORMAL_BACKGROUND); setBackground(UIConstants.NORMAL_BACKGROUND);
} }
public UIPopupMenu(boolean isEastAttr) {
super();
this.isEastAttr = isEastAttr;
setBackground(UIConstants.TOOLBARUI_BACKGROUND);
}
public boolean getRePaint() {
return this.isEastAttr;
}
@Override @Override
protected void paintBorder(Graphics g) { 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.setColor(UIConstants.LINE_COLOR);
g.drawRect(0, 0, getWidth() - 1, getHeight() - 1); g.drawRect(0, 0, getWidth() - 1, getHeight() - 1);
} }
}
@Override @Override
public Insets getInsets() { public Insets getInsets() {
if(onlyText) { if(onlyText) {
return super.getInsets(); return super.getInsets();
} }
if (isEastAttr) {
return new Insets(0, 1, 1, 1);
} else {
return new Insets(10, 2, 10, 10); return new Insets(10, 2, 10, 10);
} }
}
public void setOnlyText(boolean onlyText) { public void setOnlyText(boolean onlyText) {
this.onlyText = onlyText; this.onlyText = onlyText;

3
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.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;
@ -402,7 +403,7 @@ public class MenuDef extends ShortCut {
return; return;
} }
if (isEastAttr) { if (isEastAttr) {
popupMenu = new UIPopupMenu(isEastAttr); popupMenu = new UIPopupEastAttrMenu();
popupMenu.setInvoker(button); popupMenu.setInvoker(button);
MenuDef.this.updateEastPopupMenu(popupMenu); MenuDef.this.updateEastPopupMenu(popupMenu);
popupMenu.setPopupSize(new Dimension(MENU_DEFAULTWDITH, popupMenu.getPreferredSize().height)); popupMenu.setPopupSize(new Dimension(MENU_DEFAULTWDITH, popupMenu.getPreferredSize().height));

Loading…
Cancel
Save