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.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,12 +323,10 @@ public abstract class UpdateAction extends ShortCut implements Action {
@Override
public void intoJPopupMenu(JPopupMenu menu) {
update();
if (menu instanceof UIPopupMenu){
if (((UIPopupMenu) menu).getRePaint()){
if (menu instanceof UIPopupEastAttrMenu){
menu.add(this.createMenuItemEastAttr());
return;
}
}
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);
}
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());
}
}
}

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{
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;

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.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));

Loading…
Cancel
Save