Browse Source

REPORT-92160 设计器-图标-数据源部分-新建无disable状态

release/11.0
obo 2 years ago
parent
commit
083ceefcfb
  1. 2
      designer-base/src/main/java/com/fr/design/data/datapane/TableDataTreePane.java
  2. 33
      designer-base/src/main/java/com/fr/design/menu/MenuDef.java

2
designer-base/src/main/java/com/fr/design/data/datapane/TableDataTreePane.java

@ -229,7 +229,7 @@ public class TableDataTreePane extends BasicTableDataTreePane {
private TreeSearchToolbarPane initToolBarPane() {
// toolbar
addMenuDef = new MenuDef(Toolkit.i18nText("Fine-Design_Basic_Action_Add"));
addMenuDef.setIconPath("/com/fr/design/standard/addpopup/addPopup");
addMenuDef.setDisabledIcon("/com/fr/design/standard/addpopup/addPopup", true);
createAddMenuDef();
// 创建插件监听
createPluginListener();

33
designer-base/src/main/java/com/fr/design/menu/MenuDef.java

@ -3,25 +3,32 @@ package com.fr.design.menu;
import com.fr.base.svg.IconUtils;
import com.fr.design.file.HistoryTemplateListCache;
import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.gui.imenu.*;
import com.fr.design.gui.imenu.UIHeadMenu;
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;
import com.fr.design.i18n.Toolkit;
import com.fr.design.mainframe.JTemplate;
import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.stable.StringUtils;
import java.util.HashSet;
import java.util.Set;
import javax.swing.*;
import javax.swing.JMenu;
import javax.swing.JPopupMenu;
import javax.swing.JToolBar;
import javax.swing.event.MenuEvent;
import javax.swing.event.MenuListener;
import java.awt.*;
import java.awt.Component;
import java.awt.Dimension;
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.HashSet;
import java.util.List;
import java.util.Set;
/**
* Define Menu.
@ -46,6 +53,7 @@ public class MenuDef extends ShortCut {
protected Boolean isEastAttr = false;
protected char mnemonic;
protected String iconPath;
private boolean needDisabled;
protected String tooltip;
//item List.
private List<ShortCut> shortcutList = new ArrayList<ShortCut>();
@ -112,9 +120,19 @@ public class MenuDef extends ShortCut {
}
public void setIconPath(String iconPath) {
this.iconPath = iconPath;
setDisabledIcon(iconPath, false);
}
/**
* 设置不可用图标时,注意传递路径问题,若路径为"view_normal.svg",请传递"view",不带后缀
* 读取disable图标的文件名应当为"xxx_disabled.svg",也是项目中的svg命名规范
* 注意必须是svg图标路径才能使用此函数设置正常和禁用状态
*
* */
public void setDisabledIcon(String iconPath, boolean needDisabled) {
this.iconPath = iconPath;
this.needDisabled = needDisabled;
}
public int getShortCutCount() {
return this.shortcutList.size();
}
@ -183,6 +201,9 @@ public class MenuDef extends ShortCut {
if (createdButton == null) {
if (iconPath != null) {
createdButton = new UIButton(IconUtils.readIcon(iconPath));
if(needDisabled) {
createdButton.setDisabledIcon(IconUtils.readIcon(iconPath + IconUtils.ICON_TYPE_DISABLED));
}
createdButton.set4ToolbarButton();
} else {
createdButton = new UIButton(name);

Loading…
Cancel
Save