Vaadin-context-menu

I tried to include vaadin-context-menu component in my project as described on Using a Third-party Vaadin Component - CUBA Platform. Developer’s Manual, but got such errors:

Could not resolve org.vaadin.addons:vaadin-context-menu:3.0.0.
> Could not get resource ‘https://repo.cuba-platform.com/content/groups/premium/org/vaadin/addons/vaadin-context-menu/3.0.0/vaadin-context-menu-3.0.0.pom’.
> Could not GET ‘https://repo.cuba-platform.com/content/groups/premium/org/vaadin/addons/vaadin-context-menu/3.0.0/vaadin-context-menu-3.0.0.pom’. Received status code 403 from server: Forbidden

I filled an UI COMPONENT GENERATION wizard as shown on this screenshot:
contextmenu

How can I do it right?

Hi,

I suppose you’re talking about this add-on - Vaadin ContextMenu - Vaadin Add-on Directory.

First of all, I don’t see 3.0.0 version. There is 2.0.0 version, but it’s for Vaadin 8, so you have to use 0.7.5 version.

Also, do not forget to inherit the correct WidgetSet: <inherits name="com.vaadin.addon.contextmenu.WidgetSet" />

Thanks Gleb, I added ContextMenu component to my project, but got compile errors:

D:\Documents\cuba-projects\portaltest\modules\web\src\com\company\portaltest\web\gui\components\WebContextMenu.java:6: error: type argument ContextMenu is not within bounds of type-variable T
public class WebContextMenu extends WebAbstractComponent<com.vaadin.addon.contextmenu.ContextMenu> implements ContextMenu {
                                                                                     ^
  where T is a type-variable:
    T extends AbstractComponent declared in class WebAbstractComponent
D:\Documents\cuba-projects\portaltest\modules\web\src\com\company\portaltest\web\gui\components\WebContextMenu.java:8: error: constructor ContextMenu in class ContextMenu cannot be applied to given types;
        this.component = new com.vaadin.addon.contextmenu.ContextMenu();
                         ^
  required: AbstractComponent,boolean
  found: no arguments
  reason: actual and formal argument lists differ in length

Maybe I should set another component interface name or something else?

ContextMenu isn’t a component, it’s an extension, so this means that you can’t create a UI component for this add-on, but you can use it to extend the functionality of existing component. For example:

// Create a context menu for 'someComponent'
ContextMenu contextMenu = new ContextMenu(somComponent, true);

// Checkable item
final MenuItem item = contextMenu.addItem("Checkable", e -> {
            Notification.show("checked: " + e.isChecked());
        });
item.setCheckable(true);
item.setChecked(true);

// Disabled item
MenuItem item2 = contextMenu.addItem("Disabled", e -> {
            Notification.show("disabled");
});
item2.setEnabled(false);
1 Like