protected WebAbstractDataGrid.ActionMenuItemWrapper createContextMenuItem(Action action) { MenuItem menuItem = contextMenu.addItem(action.getCaption(), null); menuItem.setStyleName("c-cm-item"); return new WebAbstractDataGrid.ActionMenuItemWrapper(menuItem, showIconsForPopupMenuActions) { @Override public void performAction(Action action) { action.actionPerform(WebTree.this); } }; }
protected ActionMenuItemWrapper createContextMenuItem(Action action) { MenuItem menuItem = contextMenu.addItem(action.getCaption(), null); menuItem.setStyleName("c-cm-item"); return new ActionMenuItemWrapper(menuItem, showIconsForPopupMenuActions) { @Override public void performAction(Action action) { action.actionPerform(WebAbstractDataGrid.this); } }; }
protected void actionPropertyChanged(PropertyChangeEvent evt) { Action action = (Action) evt.getSource(); CubaButton button = actionButtons.get(action); if (Action.PROP_ICON.equals(evt.getPropertyName())) { setContextMenuButtonIcon(button, showIconsForPopupMenuActions ? action.getIcon() : null); } else if (Action.PROP_CAPTION.equals(evt.getPropertyName())) { setContextMenuButtonCaption(button, action.getCaption(), action.getShortcutCombination()); } else if (Action.PROP_DESCRIPTION.equals(evt.getPropertyName())) { button.setDescription(action.getDescription()); } else if (Action.PROP_ENABLED.equals(evt.getPropertyName())) { button.setEnabled(action.isEnabled()); } else if (Action.PROP_VISIBLE.equals(evt.getPropertyName())) { button.setVisible(action.isVisible()); } }
protected void actionPropertyChanged(PropertyChangeEvent evt) { Action action = (Action) evt.getSource(); CubaButton button = actionButtons.get(action); if (Action.PROP_ICON.equals(evt.getPropertyName())) { setPickerButtonIcon(button, action.getIcon()); } else if (Action.PROP_CAPTION.equals(evt.getPropertyName())) { button.setCaption(action.getCaption()); } else if (Action.PROP_DESCRIPTION.equals(evt.getPropertyName())) { button.setDescription(action.getDescription()); } else if (Action.PROP_ENABLED.equals(evt.getPropertyName())) { button.setEnabled(action.isEnabled()); } else if (Action.PROP_VISIBLE.equals(evt.getPropertyName())) { button.setVisible(action.isVisible()); } else if (action instanceof PickerFieldAction && PickerFieldAction.PROP_EDITABLE.equals(evt.getPropertyName())) { button.setVisible(((PickerFieldAction) action).isEditable()); } }
protected void actionPropertyChanged(PropertyChangeEvent evt) { Action action = (Action) evt.getSource(); Button button = actionButtons.get(action); if (Action.PROP_ICON.equals(evt.getPropertyName())) { if (showActionIcons) { setPopupButtonIcon(button, action.getIcon()); } else { setPopupButtonIcon(button, null); } } else if (Action.PROP_CAPTION.equals(evt.getPropertyName())) { button.setCaption(action.getCaption()); } else if (Action.PROP_DESCRIPTION.equals(evt.getPropertyName())) { button.setDescription(action.getDescription()); } else if (Action.PROP_ENABLED.equals(evt.getPropertyName())) { button.setEnabled(action.isEnabled()); } else if (Action.PROP_VISIBLE.equals(evt.getPropertyName())) { button.setVisible(action.isVisible()); } }
@Override public void addAction(Action action, int index) { checkNotNullArgument(action, "action must be non null"); int oldIndex = findActionById(actionList, action.getId()); if (oldIndex >= 0) { removeAction(actionList.get(oldIndex)); if (index > oldIndex) { index--; } } if (StringUtils.isNotEmpty(action.getCaption())) { CubaButton contextMenuButton = createContextMenuButton(); initContextMenuButton(contextMenuButton, action); int visibleActionsIndex = 0; int i = 0; while (i < index && i < actionList.size()) { if (StringUtils.isNotEmpty(actionList.get(i).getCaption())) { visibleActionsIndex++; } i++; } contextMenuPopup.addComponent(contextMenuButton, visibleActionsIndex); actionButtons.put(action, contextMenuButton); } actionList.add(index, action); shortcutsDelegate.addAction(null, action); attachAction(action); actionsPermissions.apply(action); }
@Override public void addAction(Action action, int index) { checkNotNullArgument(action, "Action must be non null"); int oldIndex = findActionById(actionList, action.getId()); if (oldIndex >= 0) { removeAction(actionList.get(oldIndex)); if (index > oldIndex) { index--; } } if (StringUtils.isNotEmpty(action.getCaption())) { ActionMenuItemWrapper menuItemWrapper = createContextMenuItem(action); menuItemWrapper.setAction(action); contextMenuItems.add(menuItemWrapper); } actionList.add(index, action); shortcutsDelegate.addAction(null, action); attachAction(action); actionsPermissions.apply(action); }
@Override public void addAction(Action action, int index) { checkNotNullArgument(action, "Action must be non null"); int oldIndex = findActionById(actionList, action.getId()); if (oldIndex >= 0) { removeAction(actionList.get(oldIndex)); if (index > oldIndex) { index--; } } if (StringUtils.isNotEmpty(action.getCaption())) { WebAbstractDataGrid.ActionMenuItemWrapper menuItemWrapper = createContextMenuItem(action); menuItemWrapper.setAction(action); contextMenuItems.add(menuItemWrapper); } actionList.add(index, action); shortcutsDelegate.addAction(null, action); attachAction(action); actionsPermissions.apply(action); }
String caption = action.getCaption(); if (!StringUtils.isEmpty(caption)) { setCaption(caption); setIcon(this.action.getIcon()); } else if (Action.PROP_CAPTION.equals(evt.getPropertyName())) { setCaption(this.action.getCaption()); } else if (Action.PROP_ENABLED.equals(evt.getPropertyName())) { setEnabled(this.action.isEnabled());
protected com.vaadin.event.ShortcutAction createShortcutAction(com.haulmont.cuba.gui.components.Action action) { KeyCombination keyCombination = action.getShortcutCombination(); if (keyCombination != null) { return new com.vaadin.event.ShortcutAction( action.getCaption(), keyCombination.getKey().getCode(), KeyCombination.Modifier.codes(keyCombination.getModifiers()) ); } else { return null; } }
public CubaButton createButton(Action action) { CubaButton button = new CubaButton(); if (action instanceof DialogAction) { DialogAction.Type type = ((DialogAction) action).getType(); button.setCaption(messages.getMainMessage(type.getMsgKey())); String iconPath = icons.get(type.getIconKey()); button.setIcon(iconResolver.getIconResource(iconPath)); } button.setEnabled(action.isEnabled()); if (StringUtils.isNotEmpty(action.getCaption())) { button.setCaption(action.getCaption()); } if (StringUtils.isNotEmpty(action.getDescription())) { button.setDescription(action.getDescription()); } if (StringUtils.isNotEmpty(action.getIcon())) { button.setIcon(iconResolver.getIconResource(action.getIcon())); } return button; }
this.action.removeOwner(this); this.action.removePropertyChangeListener(actionPropertyChangeListener); if (Objects.equals(this.action.getCaption(), getCaption())) { setCaption(null); String caption = action.getCaption(); if (caption != null && component.getCaption() == null) { component.setCaption(caption); setIcon(this.action.getIcon()); } else if (Action.PROP_CAPTION.equals(evt.getPropertyName())) { setCaption(this.action.getCaption()); } else if (Action.PROP_DESCRIPTION.equals(evt.getPropertyName())) { setDescription(this.action.getDescription());
protected void setContextMenuButtonAction(CubaButton button, Action action) { setContextMenuButtonIcon(button, showIconsForPopupMenuActions ? action.getIcon() : null); setContextMenuButtonCaption(button, action.getCaption(), action.getShortcutCombination()); button.setDescription(action.getDescription()); button.setEnabled(action.isEnabled()); button.setVisible(action.isVisible()); action.addPropertyChangeListener(actionPropertyChangeListener); button.setClickHandler(event -> { beforeContextMenuButtonHandlerPerformed(); action.actionPerform(WebAbstractActionsHolderComponent.this); }); }
protected void setPopupButtonAction(CubaButton button, Action action) { button.setCaption(action.getCaption()); String description = action.getDescription(); if (description == null && action.getShortcutCombination() != null) { description = action.getShortcutCombination().format(); } if (description != null) { button.setDescription(description); } button.setEnabled(action.isEnabled()); button.setVisible(action.isVisible()); if (showActionIcons) { setPopupButtonIcon(button, action.getIcon()); } else { setPopupButtonIcon(button, null); } action.addPropertyChangeListener(actionPropertyChangeListener); button.setClickHandler(mouseEventDetails -> { this.focus(); if (isAutoClose()) { this.component.setPopupVisible(false); } action.actionPerform(this); }); }