Browse Source

Merge pull request #1074 in BA/design from ~MOMEAK/design9.0:9.0release to release/9.0

* commit 'd6213e3b697e1280f3ddc32f4c58174f971b2ce1':
  代码质量
  新加一个类
  REPORT-2897 9.0设计器修改 更新超级那边样式
  REPORT-2897 右侧属性面板上的弹窗修改(参数面板和超级链接),加入rePaint参数区分菜单栏弹窗和属性面板的弹窗
master
superman 7 years ago
parent
commit
f8873df34b
  1. 2
      designer/src/com/fr/design/actions/insert/flot/ChartFloatAction.java
  2. 2
      designer/src/com/fr/design/actions/insert/flot/FormulaFloatAction.java
  3. 2
      designer/src/com/fr/design/actions/insert/flot/ImageFloatAction.java
  4. 2
      designer/src/com/fr/design/actions/insert/flot/TextBoxFloatAction.java
  5. 2
      designer/src/com/fr/design/mainframe/ReportFloatPane.java
  6. 17
      designer_base/src/com/fr/design/actions/UpdateAction.java
  7. 1
      designer_base/src/com/fr/design/gui/controlpane/UIListControlPane.java
  8. 103
      designer_base/src/com/fr/design/gui/imenu/UIMenuEastAttrItem.java
  9. 28
      designer_base/src/com/fr/design/gui/imenu/UIPopupEastAttrMenu.java
  10. 96
      designer_base/src/com/fr/design/menu/MenuDef.java

2
designer/src/com/fr/design/actions/insert/flot/ChartFloatAction.java

@ -36,7 +36,7 @@ public class ChartFloatAction extends ElementCaseAction {
public ChartFloatAction(ElementCasePane t) { public ChartFloatAction(ElementCasePane t) {
super(t); super(t);
this.setMenuKeySet(FLOAT_INSERT_CHART); this.setMenuKeySet(FLOAT_INSERT_CHART);
this.setName(getMenuKeySet().getMenuKeySetName() + "..."); this.setName(getMenuKeySet().getMenuKeySetName());
this.setMnemonic(getMenuKeySet().getMnemonic()); this.setMnemonic(getMenuKeySet().getMnemonic());
this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/m_insert/chart.png")); this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/m_insert/chart.png"));
} }

2
designer/src/com/fr/design/actions/insert/flot/FormulaFloatAction.java

@ -27,7 +27,7 @@ public class FormulaFloatAction extends AbstractShapeAction {
public FormulaFloatAction(ElementCasePane t) { public FormulaFloatAction(ElementCasePane t) {
super(t); super(t);
this.setMenuKeySet(FLOAT_INSERT_FORMULA); this.setMenuKeySet(FLOAT_INSERT_FORMULA);
this.setName(getMenuKeySet().getMenuKeySetName() + "..."); this.setName(getMenuKeySet().getMenuKeySetName());
this.setMnemonic(getMenuKeySet().getMnemonic()); this.setMnemonic(getMenuKeySet().getMnemonic());
this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/m_insert/formula.png")); this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/m_insert/formula.png"));
} }

2
designer/src/com/fr/design/actions/insert/flot/ImageFloatAction.java

@ -34,7 +34,7 @@ public class ImageFloatAction extends ElementCaseAction {
public ImageFloatAction(ElementCasePane t) { public ImageFloatAction(ElementCasePane t) {
super(t); super(t);
this.setMenuKeySet(FLOAT_INSERT_IMAGE); this.setMenuKeySet(FLOAT_INSERT_IMAGE);
this.setName(getMenuKeySet().getMenuKeySetName() + "..."); this.setName(getMenuKeySet().getMenuKeySetName());
this.setMnemonic(getMenuKeySet().getMnemonic()); this.setMnemonic(getMenuKeySet().getMnemonic());
this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/m_insert/image.png")); this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/m_insert/image.png"));
} }

2
designer/src/com/fr/design/actions/insert/flot/TextBoxFloatAction.java

@ -26,7 +26,7 @@ public class TextBoxFloatAction extends AbstractShapeAction {
public TextBoxFloatAction(ElementCasePane t) { public TextBoxFloatAction(ElementCasePane t) {
super(t); super(t);
this.setMenuKeySet(FLOAT_INSERT_TEXT); this.setMenuKeySet(FLOAT_INSERT_TEXT);
this.setName(getMenuKeySet().getMenuKeySetName() + "..."); this.setName(getMenuKeySet().getMenuKeySetName());
this.setMnemonic(getMenuKeySet().getMnemonic()); this.setMnemonic(getMenuKeySet().getMnemonic());
this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/m_insert/text.png")); this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/m_insert/text.png"));
} }

2
designer/src/com/fr/design/mainframe/ReportFloatPane.java

@ -67,7 +67,7 @@ public class ReportFloatPane extends JPanel {
} }
private MenuDef createInsertToolBar() { private MenuDef createInsertToolBar() {
MenuDef insertFloatMenu = new MenuDef(); MenuDef insertFloatMenu = new MenuDef(true);
insertFloatMenu.setName(KeySetUtils.INSERT_FLOAT.getMenuKeySetName()); insertFloatMenu.setName(KeySetUtils.INSERT_FLOAT.getMenuKeySetName());
insertFloatMenu.setTooltip(Inter.getLocText("FR-Designer_T_Insert_Float")); insertFloatMenu.setTooltip(Inter.getLocText("FR-Designer_T_Insert_Float"));
insertFloatMenu.setIconPath("com/fr/design/images/control/addPopup.png"); insertFloatMenu.setIconPath("com/fr/design/images/control/addPopup.png");

17
designer_base/src/com/fr/design/actions/UpdateAction.java

@ -9,8 +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.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;
@ -249,10 +248,17 @@ public abstract class UpdateAction extends ShortCut implements Action {
this.putValue(UIMenuItem.class.getName(), object); this.putValue(UIMenuItem.class.getName(), object);
} }
return (UIMenuItem) object; return (UIMenuItem) object;
} }
public UIMenuEastAttrItem createMenuItemEastAttr() {
UIMenuEastAttrItem menuItem = new UIMenuEastAttrItem(this);
// 设置名字用作单元测
menuItem.setName(getName());
this.putValue(UIMenuItem.class.getName(), menuItem);
return menuItem;
}
/** /**
* Gets component on toolbar. * Gets component on toolbar.
* *
@ -317,7 +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 UIPopupEastAttrMenu){
menu.add(this.createMenuItemEastAttr());
return;
}
menu.add(this.createMenuItem()); menu.add(this.createMenuItem());
} }

1
designer_base/src/com/fr/design/gui/controlpane/UIListControlPane.java

@ -488,6 +488,7 @@ public abstract class UIListControlPane extends UIControlPane {
*/ */
protected class AddItemMenuDef extends MenuDef { protected class AddItemMenuDef extends MenuDef {
public AddItemMenuDef(NameableCreator[] creators) { public AddItemMenuDef(NameableCreator[] creators) {
super(true);
this.setName(Inter.getLocText("FR-Action_Add")); this.setName(Inter.getLocText("FR-Action_Add"));
this.setMnemonic('A'); this.setMnemonic('A');
this.setIconPath("/com/fr/design/images/control/addPopup.png"); this.setIconPath("/com/fr/design/images/control/addPopup.png");

103
designer_base/src/com/fr/design/gui/imenu/UIMenuEastAttrItem.java

@ -0,0 +1,103 @@
package com.fr.design.gui.imenu;
import com.fr.design.constants.UIConstants;
import com.fr.design.utils.gui.GUIPaintUtils;
import com.fr.stable.Constants;
import com.fr.stable.StringUtils;
import sun.swing.SwingUtilities2;
import javax.swing.*;
import javax.swing.plaf.basic.BasicMenuItemUI;
import java.awt.*;
/**
* 右侧属性面板悬浮元素超级链接弹窗重绘
*/
public class UIMenuEastAttrItem extends JMenuItem {
public UIMenuEastAttrItem() {
this(StringUtils.BLANK);
}
public UIMenuEastAttrItem(String string) {
this(string, null);
}
public UIMenuEastAttrItem(String string, Icon pageSmallIcon) {
super(string, pageSmallIcon);
setBackground(UIConstants.NORMAL_BACKGROUND);
setUI(new UIMenuItemEastAttrUI());
}
public UIMenuEastAttrItem(String string, int key) {
super(string, key);
setBackground(UIConstants.NORMAL_BACKGROUND);
setUI(new UIMenuItemEastAttrUI());
}
public UIMenuEastAttrItem(Action action) {
this();
setAction(action);
}
@Override
public String getText() {
return StringUtils.BLANK + super.getText();
}
private class UIMenuItemEastAttrUI extends BasicMenuItemUI {
@Override
protected void paintBackground(Graphics g, JMenuItem menuItem,Color bgColor) {
if(menuItem.getIcon() != null) {
menuItem.setIcon(null);
}
ButtonModel model = menuItem.getModel();
Color oldColor = g.getColor();
int menuWidth = menuItem.getWidth();
int menuHeight = menuItem.getHeight();
g.setColor(UIConstants.NORMAL_BACKGROUND);
g.fillRect(0, 0, menuWidth, menuHeight);
if (menuItem.isOpaque()) {
if (model.isArmed() || (menuItem instanceof JMenu && model.isSelected())) {
GUIPaintUtils.fillPaint((Graphics2D) g, 0, 0, menuWidth, menuHeight, true, Constants.NULL, UIConstants.FLESH_BLUE, 0);
} else {
GUIPaintUtils.fillPaint((Graphics2D) g, 0, 0, menuWidth, menuHeight, true, Constants.NULL, UIConstants.TOOLBARUI_BACKGROUND, 0);
}
g.setColor(oldColor);
}
else if (model.isArmed() || (menuItem instanceof JMenu &&
model.isSelected())) {
GUIPaintUtils.fillPaint((Graphics2D)g, 0, 0, menuWidth, menuHeight, true, Constants.NULL, UIConstants.FLESH_BLUE, 7);
g.setColor(oldColor);
}
}
protected void paintText(Graphics g, JMenuItem menuItem, Rectangle textRect, String text) {
ButtonModel model = menuItem.getModel();
FontMetrics fm = SwingUtilities2.getFontMetrics(menuItem, g);
if(!model.isEnabled()) {
// *** paint the text disabled
if ( UIManager.get("MenuItem.disabledForeground") instanceof Color ) {
g.setColor( UIManager.getColor("MenuItem.disabledForeground") );
SwingUtilities2.drawStringUnderlineCharAt(menuItem, g,text,
-1, textRect.x, textRect.y + fm.getAscent());
} else {
g.setColor(menuItem.getBackground().brighter());
SwingUtilities2.drawStringUnderlineCharAt(menuItem, g, text,
-1, textRect.x, textRect.y + fm.getAscent());
g.setColor(menuItem.getBackground().darker());
SwingUtilities2.drawStringUnderlineCharAt(menuItem, g,text,
-1, textRect.x - 1, textRect.y +
fm.getAscent() - 1);
}
} else {
SwingUtilities2.drawStringUnderlineCharAt(menuItem, g, text,
-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);
}
}

96
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;
@ -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,7 +26,10 @@ import java.util.List;
*/ */
public class MenuDef extends ShortCut { public class MenuDef extends ShortCut {
private static final int MENU_DEFAULTWDITH = 156;
protected String name; protected String name;
//右侧属性表弹出框重绘
protected Boolean isEastAttr = false;
protected char mnemonic; protected char mnemonic;
protected String iconPath; protected String iconPath;
protected String tooltip; protected String tooltip;
@ -44,6 +51,10 @@ public class MenuDef extends ShortCut {
this.setName(name); this.setName(name);
} }
public MenuDef(Boolean rePaint) {
this.setRePaint(rePaint);
}
public MenuDef(String name, char mnemonic) { public MenuDef(String name, char mnemonic) {
this.setName(name); this.setName(name);
this.setMnemonic(mnemonic); this.setMnemonic(mnemonic);
@ -57,6 +68,14 @@ public class MenuDef extends ShortCut {
this.name = name; this.name = name;
} }
public boolean getRePaint() {
return isEastAttr;
}
public void setRePaint(boolean rePaint) {
this.isEastAttr = rePaint;
}
public char getMnemonic() { public char getMnemonic() {
return mnemonic; return mnemonic;
} }
@ -99,6 +118,7 @@ public class MenuDef extends ShortCut {
/** /**
* 插入菜单项 * 插入菜单项
*
* @param index 插入的位置 * @param index 插入的位置
* @param shortCut 菜单信息 * @param shortCut 菜单信息
*/ */
@ -110,6 +130,7 @@ public class MenuDef extends ShortCut {
/** /**
* 用可变参数方便添加数组 * 用可变参数方便添加数组
*
* @param shortcut 参数 存储菜单项信息 * @param shortcut 参数 存储菜单项信息
*/ */
public void addShortCut(ShortCut... shortcut) { public void addShortCut(ShortCut... shortcut) {
@ -132,6 +153,7 @@ public class MenuDef extends ShortCut {
/** /**
* 生成UIButton * 生成UIButton
*
* @return 菜单按钮 * @return 菜单按钮
*/ */
public UIButton createUIButton() { public UIButton createUIButton() {
@ -157,6 +179,7 @@ public class MenuDef extends ShortCut {
/** /**
* 生成JMenu * 生成JMenu
*
* @return 菜单 * @return 菜单
*/ */
public UIMenu createJMenu() { public UIMenu createJMenu() {
@ -172,7 +195,7 @@ public class MenuDef extends ShortCut {
} }
createdJMenu.addMenuListener(menuDefListener); createdJMenu.addMenuListener(menuDefListener);
ContainerListener listener = getContainerListener(); ContainerListener listener = getContainerListener();
if(listener != null){ if (listener != null) {
createdJMenu.getPopupMenu().addContainerListener(listener); createdJMenu.getPopupMenu().addContainerListener(listener);
} }
} }
@ -183,8 +206,10 @@ public class MenuDef extends ShortCut {
protected ContainerListener getContainerListener() { protected ContainerListener getContainerListener() {
return null; return null;
} }
/** /**
* 生成 JPopupMenu * 生成 JPopupMenu
*
* @return 弹出菜单 * @return 弹出菜单
*/ */
public JPopupMenu createJPopupMenu() { public JPopupMenu createJPopupMenu() {
@ -195,6 +220,7 @@ public class MenuDef extends ShortCut {
/** /**
* 设置是否可用 * 设置是否可用
*
* @param b 布尔型 * @param b 布尔型
*/ */
@Override @Override
@ -212,6 +238,7 @@ public class MenuDef extends ShortCut {
/** /**
* 按钮状态 * 按钮状态
*
* @return 状态 * @return 状态
*/ */
@Override @Override
@ -235,6 +262,7 @@ public class MenuDef extends ShortCut {
/** /**
* 更新菜单 * 更新菜单
*
* @param popupMenu 菜单 * @param popupMenu 菜单
*/ */
protected void updatePopupMenu(JPopupMenu popupMenu) { protected void updatePopupMenu(JPopupMenu popupMenu) {
@ -263,32 +291,69 @@ public class MenuDef extends ShortCut {
isFirstItem = false; isFirstItem = false;
} }
if (createdJMenu != null && createdJMenu.getPopupMenu() != null){ if (createdJMenu != null && createdJMenu.getPopupMenu() != null) {
setEnabled(createdJMenu.getPopupMenu().getComponentCount() > 0 && enabled);
}
}
/**
* 更新右侧属性面板菜单
*
* @param popupMenu 菜单
*/
protected void updateEastPopupMenu(JPopupMenu popupMenu) {
removeComponent(popupMenu);
this.popupMenu = popupMenu;
// 一开始是不能插入分隔符的
boolean nec_seperator = false;
boolean isFirstItem = true;
int actionCount = this.getShortCutCount();
for (int i = 0; i < actionCount; i++) {
ShortCut shortcut = this.getShortCut(i);
// 如果shortcut是SeparatorDef,先不加,先标记一下nec_seperator为true,等下一个shortcut需要加到PopupMenu时再加
if (shortcut instanceof SeparatorDef) {
nec_seperator = true;
continue;
}
if (nec_seperator) {
if (!isFirstItem) {
SeparatorDef.DEFAULT.intoJPopupMenu(popupMenu);
}
nec_seperator = false;
}
shortcut.intoJPopupMenu(popupMenu);
isFirstItem = false;
}
if (createdJMenu != null && createdJMenu.getPopupMenu() != null) {
setEnabled(createdJMenu.getPopupMenu().getComponentCount() > 0 && enabled); setEnabled(createdJMenu.getPopupMenu().getComponentCount() > 0 && enabled);
} }
} }
/** /**
* 删除所有组件 除了滚动条 * 删除所有组件 除了滚动条
*
* @param popupMenu 菜单 * @param popupMenu 菜单
*/ */
public void removeComponent(JPopupMenu popupMenu){ public void removeComponent(JPopupMenu popupMenu) {
UIScrollBar uiScrollBar = new UIScrollBar(); UIScrollBar uiScrollBar = new UIScrollBar();
if(hasScrollSubMenu){ if (hasScrollSubMenu) {
for(Component comp : popupMenu.getComponents()){ for (Component comp : popupMenu.getComponents()) {
if(comp instanceof UIScrollBar){ if (comp instanceof UIScrollBar) {
uiScrollBar =(UIScrollBar) comp; uiScrollBar = (UIScrollBar) comp;
} }
} }
} }
popupMenu.removeAll(); popupMenu.removeAll();
if(hasScrollSubMenu){ if (hasScrollSubMenu) {
popupMenu.add(uiScrollBar); popupMenu.add(uiScrollBar);
} }
} }
/** /**
* 添加菜单项 * 添加菜单项
*
* @param menu 菜单 * @param menu 菜单
*/ */
@Override @Override
@ -300,6 +365,7 @@ public class MenuDef extends ShortCut {
/** /**
* 添加 * 添加
*
* @param toolBar 菜单条 * @param toolBar 菜单条
*/ */
@Override @Override
@ -336,13 +402,19 @@ public class MenuDef extends ShortCut {
if (!button.isEnabled()) { if (!button.isEnabled()) {
return; return;
} }
if (isEastAttr) {
UIPopupMenu popupMenu = new UIPopupMenu(); 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); popupMenu.setInvoker(button);
MenuDef.this.updatePopupMenu(popupMenu); MenuDef.this.updatePopupMenu(popupMenu);
GUICoreUtils.showPopupMenu(popupMenu, button, 0, button.getSize().height); GUICoreUtils.showPopupMenu(popupMenu, button, 0, button.getSize().height);
} }
}
}; };

Loading…
Cancel
Save