Skip to content

Commit

Permalink
Use unique key for resources (#105)
Browse files Browse the repository at this point in the history
* Use unique key for resources

- Update demo
  • Loading branch information
Anastasia Smirnova authored and ZheSun88 committed Sep 24, 2019
1 parent c836b16 commit d698bca
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,9 @@ private List<ContextMenuItemState> convertItemsToState(List<MenuItem> items,
.getDescriptionContentMode();
menuItemState.enabled = item.isEnabled();
menuItemState.separator = item.isSeparator();
String key="icon";
String key= item.getIcon()!= null ?
String.valueOf(item.getIcon().hashCode())
: "icon";
ResourceReference resourceReference = ResourceReference.create(item.getIcon(), this, key);
if (item.getIcon()!=null && (item.getIcon() instanceof ConnectorResource)) {
super.getState().resources.put(key,resourceReference);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ private void fillMenu(ContextMenu menu) {
item.setCheckable(true);
item.setChecked(true);

MenuItem item2 = menu.addItem("Disabled",
MenuItem item2 = menu.addItem("Disabled",new ClassResource("/images/tiger.jpg"),
e -> Notification.show("disabled")
);
item2.setDescription("Disabled item");
Expand Down Expand Up @@ -118,7 +118,7 @@ private void fillMenu(ContextMenu menu) {
MenuItem item6 = menu.addItem("Submenu");
item6.addItem("Subitem", VaadinIcons.OPTION, e -> Notification.show("SubItem"));
item6.addSeparator();
item6.addItem("Subitem", e -> Notification.show("SubItem"))
item6.addItem("Subitem",new ThemeResource("images/cat2.jpg"), e -> Notification.show("SubItem"))
.setDescription("Test");
MenuItem openWindowNotification = item6.addItem(
"Open Window + Notification",
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit d698bca

Please sign in to comment.