vaadin / context-menu Goto Github PK
View Code? Open in Web Editor NEWVaadin ContextMenu
License: Apache License 2.0
Vaadin ContextMenu
License: Apache License 2.0
The sub menu does not render at all with the recent Vaadin version
I see its compiled with java 1.8 but I want to use it with 1.7. I tried to compile it by my own but has some compilation issues as below
[ERROR] Project/context-menu/vaadin-context-menu-addon/src/main/java/com/vaadin/addon/contextmenu/GridContextMenu.java:[24,71] local variable section is accessed from within inner class; needs to be declared final
[ERROR] Project/context-menu/vaadin-context-menu-addon/src/main/java/com/vaadin/addon/contextmenu/GridContextMenu.java:[25,49] local variable listener is accessed from within inner class; needs to be declared final
I don't want to maintain this by changing the code. How should I go about this?
Code to reproduce, either listener works on its own but not together:
@SuppressWarnings("unchecked")
private TreeTable createTreeTable() {
TreeTable table = new TreeTable();
table.addContainerProperty("id", Integer.class, null);
for (int i = 0; i < 10; ++i) {
Item item = table.addItem(i);
item.getItemProperty("id").setValue(i);
}
addItemClickListener(table);
addContextMenu(table);
return table;
}
private void addContextMenu(TreeTable table) {
final ContextMenu menu = new ContextMenu(table, true);
menu.addContextMenuOpenListener(event -> {
System.out.println("context menu open!");
});
}
private void addItemClickListener(TreeTable table) {
table.addItemClickListener(event -> {
if (event.isDoubleClick()) {
System.out.println("double-click!");
}
});
}
In the Generic GridContextMenu class the GridContextMenuOpenEvent returns Object instead of T. This should be changed to the generic type T.
If there are no items, or all items are invisible, a tiny 6px popup is shown. The issue is especially valid for a grid, where often context menu is present for header or body cells only.
It would be great if Context Menu allow the placement of buttons as menu elements. This is allowed in MenuBar and there are certain situations where this is needed in order to perform certain actions. For instance, opening new browser windows / tabs does need to .extend(someComponent), but MenuItems are not Components, so it's impossible to open a new browser window / tab from Context Menu.
My assumption is that it wouldn't be that difficult to add this functionality...
For own styling it would be great to add the Vaadin-Standard-Methods "addStylename" and "setPrimaryStylename".
Thx!
Contextmenu gwt.xml file has this
<!-- Widget styles in public -directory -->
<stylesheet src="context-menu/styles.css"/>
And in the log file, I get these warnings?
2015-12-01 14:50:14.630 INFO 7380 --- [ XNIO-1 task-16] com.vaadin.server.VaadinServlet : Requested resource [/VAADIN/widgetsets/com.globalbilisim.nostro.WidgetSet/context-menu/styles.css] not found from filesystem or through class loader. Add widgetset and/or theme JAR to your classpath or add files to WebContent/VAADIN folder.
2015-12-01 14:50:17.555 INFO 7380 --- [ XNIO-1 task-23] com.vaadin.server.VaadinServlet : Requested resource [/VAADIN/widgetsets/com.globalbilisim.nostro.WidgetSet/context-menu/styles.css] not found from filesystem or through class loader. Add widgetset and/or theme JAR to your classpath or add files to WebContent/VAADIN folder.
2015-12-01 14:50:19.290 INFO 7380 --- [ XNIO-1 task-33] ContextMenu : beforeClientResponse
2015-12-01 14:50:19.291 INFO 7380 --- [ XNIO-1 task-33] ContextMenu : beforeClientResponse
2015-12-01 14:51:16.574 INFO 7380 --- [ XNIO-1 task-45] ContextMenu : Context click listener
css file is under context-menu2 folder and seems working but this is logged. Also everytime I click the contect menu, it logs above.
This is important for our automation testing procedures.
For example, on a menu bar menu item you can click on a menu item in order to select it (instead of hovering), and that gets the submenu to popup.
In this tool the whole popup menu closes on clicking an entry, even if the entry is just the parent ofr submenus.
class ContextMenuConnector registers a native preview event handler (in method #init), but never releases it. This is both a problem of memory (widget never get released, including all stuff hanging on those objects) and of performance (more and more handlers have to be invoked with every native event)
I think the title self-explains it.
Hi, i find possible bug.
Problem occures when context menu was opened and i try to reopen it with right click.
In some cases when i trying to reopen menu, i saw rapidly animation of opening/closing and menu stays closed.
I tried to fix it by my own.
In class Overlay, method
hide(final boolean autoClosed, final boolean animateIn, final boolean animateOut)
i find this:
Overlay.this.setPreviewingAllNativeEvents(false);
As i can see, this line prevents opening of new menu, when closing animation still in process.
And closing animation action was hardcoded, when you call hide method.
In my case i fix this with overriding call of hide method in MyVOverlay clsss, and set animation false.
@Override public void hide(boolean autoClosed) { super.hide(autoClosed, false, false); }
HTML in menu items is ignored. This is also shown in the online demo.
If the grid-row where I right-click has a tooltip, the tooltip is opened on top of the menu.
To get rid of the tooltip I have to move the mouse out of the menu, move it around a bit and then back.
It seems the menu has z-index 20000, and the tooltip has 20001
The client-side imports/exports for the OSGI Bundle need to be removed.
Reference: https://vaadin.com/blog/-/blogs/osgifying-your-add-ons
Is there a way how to simulate right click on tablets? (iOS, Android) Any idea how to make context menu available on touch devices?
When I open the context menu and use down cursor it skips one entry, as if one would have used down cursor twice. Same with the up-key.
Example code:
<vaadin-context-menu selector="vaadin-button" open-on="click" close-on="none">
<template>
<vaadin-list-box>
<vaadin-item>Item 1</vaadin-item>
<vaadin-item>Item 2</vaadin-item>
<vaadin-item>Item 3</vaadin-item>
</vaadin-list-box>
</template>
<vaadin-button>Context Menu, TabIndex 0</vaadin-button>
</vaadin-context-menu>
#24 broke context menu for me. @mletenay already has investigated this issue.
@mletenay said:
When I mouseclick on the menu item, the standard Vaadin's (7.6.4) VMenuBar#itemClick is invoked:
hideParents(true);
menuVisible = false;
Scheduler.get().scheduleDeferred(item.getCommand());
The menu is hidden / detached and when the scheduled command is invoked it is ignored.
Am I doing something wrong or is this a bug ? What's actually meaning of that isAttached() check ?
Using versions:
Spring Boot,
Vaadin 8.1.2,
ContextMenu 2.0.0
I can't seem to get the ContextMenu to open. I can debug through the right click event until I get to 'GridContextMenu.open(int x, int y). The call in to the proxy to 'showContextMenu' doesn't seem to do anything.
public void open(int x, int y) {
getRpcProxy(ContextMenuClientRpc.class).showContextMenu(x, y);
}
I have the same issue on the demo project and can't get contextmenus to open on any component. I'm not clear if I've missed out on some resource file configuration or if the code below should be enough.
GridContextMenu<FIXMessageEntry> gridMenu = new GridContextMenu<>(grid);
gridMenu.addItem("Say Hi", e -> Notification.show("Hi"));
According to the Vaadin Directory the current version of this add-on is 0.7.2. But all pom.xml files of this project state the version as 0.7. The version number should be updated before every release. And after the release it should be changed to a SNAPSHOT release (e.g. 0.7.3-SNAPSHOT).
Grid motion cursors stop responding. It happens when using the ContextMenu in a Grid. I press right click and it shows me the menu. Then, I press left-click outside the menu and from that moment the movement cursors (up, down to the sides) stop responding in the Grid.
It also happens in online examples, for example, at https://demo.vaadin.com/sampler/#addons/contextmenu
It occurs both in the version of Vaadin 8 and 7.
There seems to be a weird bug that makes the component useless with other but Valo based themes. With reindeer now context click events are fired. The actual context menu is shown and closed just fine.
See this thread for more details:
https://vaadin.com/forum#!/thread/12825591/13043883
When I add MenuItem
to existing MenuItem
as sub menu items, I can only trigger parents items by ContextClickEvent
. When I trigger ClickEvent
(left mouse button), the submenu will show for a second and turn off all the ContextMenu
item. Please explain why you implement it that way.
After some test, I confrim that this still continue. I believe it's due to gwt.xml:
Contextmenu gwt.xml file has this
<!-- Widget styles in public -directory -->
<stylesheet src="context-menu/styles.css"/>
info message:
2015-12-09 12:08:09.016 INFO 6700 --- [ XNIO-1 task-9] com.vaadin.server.VaadinServlet : Requested resource [/VAADIN/widgetsets/vwscdn2b36d3d30e1dfdb8ec1f8cae96e8e870/context-menu/styles.css] not found from filesystem or through class loader. Add widgetset and/or theme JAR to your classpath or add files to WebContent/VAADIN folder.
All of our products should use com.vaadin
as group id to make it easier to remember dependencies.
Seems to me to be "debug" type stuff that has been left behind.
As in ContextMenu.java
:
logger.info("Context click listener");
Such should be removed or changed to another logging level.
Provide MANIFEST.MF with OSGi meta-data
Using ContextMenu with Vaadin Framework 8.1 Tree is a bit awkward. The Tree does not extend directly from Grid, but uses the new Composite concept to re-package TreeGrid in to a new component. The internal TreeGrid is not available for the user of Tree as it's a private field.
This is the first workaround for the issue I came up with:
Wnt/vaadin-fiddle@6df5870#diff-9678f070438ec4e39925356f264887b1R288
using reflection to get hold of the internal TreeGrid to be able to add the context menu to the Tree.
Second workaround uses a class that extends Tree to be able to call Composite's getCompositionRoot, casts the returned component and finally adds API for adding a context menu:
Wnt/vaadin-fiddle@4806d41#diff-2a47376b01da011f7fe17f8d4818266bR7
By using either workaround the ContextMenu works as expected, but there are some warnings in the server console:
WARNING: Ignoring RPC call to com.vaadin.shared.ContextClickRpc.contextClick in connector com.vaadin.ui.Tree(158) as no RPC implementation is registered
or in the 2nd version:
WARNING: Ignoring RPC call to com.vaadin.shared.ContextClickRpc.contextClick in connector org.vaadin.vaadinfiddle.vaadinfiddleprototype.components.TreeWithContextMenu(15) as no RPC implementation is registered
Currently, the only way to close the menu is to click outside it.
Looking at regular menus in Windows, it seems that it is standard to also close on Escape.
It would be nice if the Vaadin ContextMenu also supported this.
Please remember to allow Escape to propagate to other components if the menu is not open.
If the context menu is open and then you try to open the context menu again on another item e.g., it will shortly be opened but directly closed afterwards... probably related to animation.
After opening the context menu, the up/down cursors don't work anymore.
Steps to reproduce:
@Theme("mytheme")
public class TestUI extends UI {
@WebServlet(urlPatterns = "/*", name = "TestUIServlet", asyncSupported = true)
@VaadinServletConfiguration(ui = TestUI.class, productionMode = false)
public static class TestUIServlet extends VaadinServlet {
}
public class TestBean {
private String name = "name";
private String value = "value";
public String getName() {
return name;
}
public void setName(String inName) {
name = inName;
}
public String getValue() {
return value;
}
public void setValue(String inValue) {
value = inValue;
}
}
private Grid<TestBean> grid = new Grid<TestBean>(TestBean.class);
private GridContextMenu<TestBean> contextMenu = new GridContextMenu<>(grid);
private ArrayList<TestBean> items = new ArrayList<>();
@Override
protected void init(VaadinRequest request) {
final VerticalLayout layout = new VerticalLayout();
layout.setMargin(true);
setContent(layout);
items.add(new TestBean());
grid.setDataProvider(new ListDataProvider<>(items));
grid.setWidth("100%");
grid.setHeight("400px");
layout.addComponent(grid);
contextMenu.addContextMenuOpenListener(event -> handleOpen(event));
}
private void handleOpen(ContextMenuOpenEvent inEvent) {
contextMenu.removeItems();
contextMenu.addItem("test1", event -> System.out.println("clicked 1"));
contextMenu.addItem("test2", event -> System.out.println("clicked 2"));
}
}
Hi, thank you for this awesome extension. Just a minor thing: the ContextMenu class is not serializable: the Logger logger is not serializable and the serialization fails:
Caused by: java.io.NotSerializableException: java.util.logging.Logger
at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1184)
Perhaps the logger field should be static.
Menu is always opened with its upper left corner at the mouse pointer.
If the mouse pointer is in the lower part of the screen this means that the bottom of the menu can be outside the visible area.
The menu should be moved up (and to the left) until it is inside visible area, but not so far that the top is clipped.
Ideally, if the menu is too high for the screen, it should have some sort of scroll.
Same problem for submenus.
From @tkvtkv on April 18, 2017 11:51
I created a ContextMenu (vaadin-context-menu-0.7.4).
ContextMenu contextMenu = new ContextMenu(this, false);
contextMenu.setAsContextMenuOf(butTest);
contextMenu.addContextMenuOpenListener(new ContextMenu.ContextMenuOpenListener() {
public void onContextMenuOpen(ContextMenu.ContextMenuOpenListener.ContextMenuOpenEvent event) {
Notification.show("Context menu on "
+ event.getSourceComponent().getCaption());
}
});
MenuItem basic = contextMenu.addItem("Basic Item", new ContextMenu.Command() {
public void menuSelected(com.vaadin.addon.contextmenu.MenuItem selectedItem) {
//main.addWindow(getAboutDialog());
labAction.setValue("ContextMenu item 'Basic Item' selected " );
}
});
MenuItem second = contextMenu.addItem("Second Item", new Menu.Command() {
public void menuSelected(com.vaadin.addon.contextmenu.MenuItem menuItem) {
labAction.setValue("ContextMenu item 'Second Item' selected " );
}
});
When I right mouse click on butTest I see a notification "Context menu on ..." only. But the Context menu is invisible.
What I missed?
Please help me to understand what need to do to show a context menu.
Copied from original issue: vaadin/vaadin-core#102
2015-12-04 22:38:49.784 INFO 827 --- [ XNIO-2 task-4] ContextMenu : beforeClientResponse
2015-12-04 22:38:52.474 INFO 827 --- [ XNIO-2 task-6] ContextMenu : Context click listener
These 2 entry are always logged. Setting log level to higher can resolve it.
After adding the GridContextmenu to a Grid or Treegrid the menu ist already visible (only a short black line, because not items are added yet). I haven't added any header, body or footer listener yet. Should this be the case?
I would expect, that a menu is only visible after adding a menu to header, body or footer.
Furthermore after adding only a "addGridBodyContextMenuListener" the same menu appears in the header. I think this isn't correct yet.
Currently they return Objects but class itself has a generic type T, so getItem() can return T instead of Object and getColumn() Column<T, ?> instead of Column.
With the latest version of vaadin there is a support for extending MenuBar.MenuItem by a FileDownloader. This is possible because MenuBar.MenuItem is implementing the new interface EventTrigger.
This should be also supported by the MenuItems of a contextmenu.
This is a really weird issue. I have two Trees on the application. One is defined in the UI class and one in a custom component. When I click on the first Tree I get the context menus, but I get this warning when I try the same on the tree in the custom component:
WARNING: Ignoring RPC call to com.vaadin.shared.ui.tree.TreeServerRpc.contextClick in connector com.vaadin.ui.Tree(99) as no RPC implementation is registered
Any idea?
The sources are here. The custom component is here.
This is on version 0.7.5 since I'm using Vaadin 7.7.10.
Icons with FontAwesome do work fine, but I don't get any other icons visible (e.g. from a FileResource or ExternalResource) .
Browserrequest looks like this:
http://localhost:8080/app/~main~/APP/connector/0/233//1.png 404 (Not Found)
There should be an option to hide the menu completely if some items don't match some cases. This is very important for a GridContextMenu. I want to show only menu items on special items not for all. For the moment this is not possible, because you can't hide the menu. removing all items from the menu returns a black line (the menu without any items).
Hi,
I can't get a tooltip to show on menu items.
Reproduce:
"Icon + Description + <b>HTML</b>"
According to the source there should be a tooltip on this menu item. It does not show when i do it. Tested with firefox and chromium on linux.
For my project i use contex-menu with vaadin 7 and it does not show the tooltip too.
btw. I'm not sure if this <b>HTML</b>
is a bug as well
Thanks, raffael
Why is that a context-click (aka right-click) doesn't fire a focus event?
I'm just asking because I'm not fully aware how the same situation is in other frameworks, such a Swing.
To me there should be a least be an option for a context-click to also trigger a focus event. Not sure if such functionality belongs in the add-on or in the framework.
The consequence of not having the focus change on context-click is that the user gets very confused. "Which row did I actually click?" (surely not the one with the focus border).
On Grid I've currently semi-solved the problem by turning off completely the visual indicator for focus on cells. This I've done via CSS. For reference this works for me:
// Turn off focus visual indication for grid cells
.v-grid:focus .v-grid-cell-focused:before {
display: none;
}
However this will not solve the problem for those who still (for one reason or another) require the visual indicator for focus.
To solve this usability issue I still believe the best option is to have a context-click trigger a focus event as well.
With following version:
<!-- https://mvnrepository.com/artifact/com.vaadin.addon/vaadin-context-menu -->
<dependency>
<groupId>com.vaadin.addon</groupId>
<artifactId>vaadin-context-menu</artifactId>
<version>0.7.5</version>
</dependency>
I experience on latest Vaadin release:
INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ archive-service ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 133 source files to /home/zangetsu/proj/coreso/integration/commons/archive-service/target/classes
[WARNING] /home/zangetsu/proj/coreso/integration/commons/archive-service/src/main/java/org/archenroot/integration/commons/archive_service/backend/domain/entity/StringToEnumFactory.java: /home/zangetsu/proj/coreso/integration/commons/archive-service/src/main/java/org/archenroot/integration/commons/archive_service/backend/domain/entity/StringToEnumFactory.java uses unchecked or unsafe operations.
[WARNING] /home/zangetsu/proj/coreso/integration/commons/archive-service/src/main/java/org/archenroot/integration/commons/archive_service/backend/domain/entity/StringToEnumFactory.java: Recompile with -Xlint:unchecked for details.
[INFO]
[INFO] --- vaadin-maven-plugin:8.1.3:compile (default) @ archive-service ---
[INFO] auto discovered modules [AppWidgetset]
[INFO] Using com.vaadin:vaadin-client version 8.1.3
[INFO] Using com.vaadin:vaadin-client-compiler version 8.1.3
[INFO] Compiling module AppWidgetset
[INFO] Tracing compile failure path for type 'com.vaadin.addon.contextmenu.client.MyVOverlay'
[INFO] [ERROR] Errors in 'jar:file:/home/zangetsu/.m2/repository/com/vaadin/addon/vaadin-context-menu/0.7.5/vaadin-context-menu-0.7.5.jar!/com/vaadin/addon/contextmenu/client/MyVOverlay.java'
[INFO] [ERROR] Line 15: The constructor VOverlay(boolean, boolean, boolean) is undefined
[INFO] [ERROR] Aborting compile due to errors in some input files
Is there any support for TreeGrid planned ? Can we move to Vaadin 8.1 ? I tried with the GridContextMenu, but the context menu does not close after left-clicking a menu item and the menu action is called multiple times (I supposed once for every predecessor of the tree node that the menu was opened on).
Either the POMs in the project or the CI configuration must make sure that only the add-on module is deployed to a staging repository.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.