mirror of
https://gitee.com/jmix/cuba.git
synced 2024-12-03 03:38:33 +08:00
PL-7402 Ability to set description to menu item
This commit is contained in:
parent
64db93f500
commit
d945986610
@ -172,6 +172,7 @@ public class MenuConfig {
|
||||
|
||||
loadShortcut(menuItem, element);
|
||||
loadStylename(element, menuItem);
|
||||
loadDescription(element, menuItem);
|
||||
loadMenuItems(element, menuItem);
|
||||
|
||||
// if (menuItem.getChildren().isEmpty()) {
|
||||
@ -185,6 +186,7 @@ public class MenuConfig {
|
||||
menuItem.setDescriptor(element);
|
||||
loadShortcut(menuItem, element);
|
||||
loadStylename(element, menuItem);
|
||||
loadDescription(element, menuItem);
|
||||
}
|
||||
} else if ("separator".equals(element.getName())) {
|
||||
String id = element.attributeValue("id");
|
||||
@ -207,6 +209,13 @@ public class MenuConfig {
|
||||
}
|
||||
}
|
||||
|
||||
protected void loadDescription(Element element, MenuItem menuItem) {
|
||||
String description = element.attributeValue("description");
|
||||
if (StringUtils.isNotBlank(description)) {
|
||||
menuItem.setDescription(description);
|
||||
}
|
||||
}
|
||||
|
||||
protected void loadStylename(Element element, MenuItem menuItem) {
|
||||
String stylename = element.attributeValue("stylename");
|
||||
if (StringUtils.isNotBlank(stylename)) {
|
||||
|
@ -37,6 +37,7 @@ public class MenuItem {
|
||||
|
||||
private String id;
|
||||
private String stylename;
|
||||
private String description;
|
||||
private Element descriptor;
|
||||
private boolean separator = false;
|
||||
|
||||
@ -77,6 +78,14 @@ public class MenuItem {
|
||||
return descriptor;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public String getStylename() {
|
||||
return stylename;
|
||||
}
|
||||
|
@ -44,6 +44,7 @@
|
||||
<xs:attribute type="xs:string" name="id" use="optional"/>
|
||||
<xs:attribute type="xs:string" name="insertBefore" use="optional"/>
|
||||
<xs:attribute type="xs:string" name="insertAfter" use="optional"/>
|
||||
<xs:attribute type="xs:string" name="description" use="optional"/>
|
||||
<xs:attribute type="xs:string" name="stylename" use="optional"/>
|
||||
</xs:complexType>
|
||||
|
||||
@ -56,6 +57,7 @@
|
||||
<xs:attribute type="openTypeType" name="openType" use="optional"/>
|
||||
<xs:attribute type="xs:boolean" name="resizable" use="optional"/>
|
||||
<xs:attribute type="xs:string" name="shortcut" use="optional"/>
|
||||
<xs:attribute type="xs:string" name="description" use="optional"/>
|
||||
<xs:attribute type="xs:string" name="stylename" use="optional"/>
|
||||
<xs:attribute type="xs:string" name="insertBefore" use="optional"/>
|
||||
<xs:attribute type="xs:string" name="insertAfter" use="optional"/>
|
||||
|
@ -108,6 +108,7 @@ public class MenuBuilder {
|
||||
createSubMenu(menuItem, item, session);
|
||||
assignTestId(menuItem, item);
|
||||
assignStyleName(menuItem, item);
|
||||
assignDescription(menuItem, item);
|
||||
if (isMenuItemEmpty(menuItem)) {
|
||||
menuBar.removeItem(menuItem);
|
||||
}
|
||||
@ -122,6 +123,8 @@ public class MenuBuilder {
|
||||
MenuBar.MenuItem menuItem = (child.isSeparator()) ? vItem.addSeparator() : vItem.addItem(MenuConfig.getMenuItemCaption(child.getId()), createMenuBarCommand(child));
|
||||
assignShortcut(menuItem, child);
|
||||
assignTestId(menuItem, child);
|
||||
assignDescription(menuItem, child);
|
||||
assignStyleName(menuItem, child);
|
||||
}
|
||||
} else {
|
||||
if (child.isPermitted(session)) {
|
||||
@ -129,6 +132,8 @@ public class MenuBuilder {
|
||||
assignShortcut(menuItem, child);
|
||||
createSubMenu(menuItem, child, session);
|
||||
assignTestId(menuItem, child);
|
||||
assignDescription(menuItem, child);
|
||||
assignStyleName(menuItem, child);
|
||||
if (isMenuItemEmpty(menuItem)) {
|
||||
vItem.removeChild(menuItem);
|
||||
}
|
||||
@ -204,4 +209,10 @@ public class MenuBuilder {
|
||||
menuItem.setStyleName("ms " + conf.getStylename());
|
||||
}
|
||||
}
|
||||
|
||||
protected void assignDescription(MenuBar.MenuItem menuItem, MenuItem conf) {
|
||||
if (conf.getDescription() != null) {
|
||||
menuItem.setDescription(conf.getDescription());
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user