Javascript error when displaying a contextual menu [message #73650] |
Wed, 13 February 2008 04:11  |
Eclipse User |
|
|
|
Hi,
I have actually a problem with the dynamic context menu of a TableViewer I
have created.
Depending, of the state of my data, the contextual menu has the following
actions available :
-> Display Label
OR
-> Hide Label
So, sometimes, when I am doing fast right-clicks on the rows of the
TableViewer, I got that javascript error :
//---------------------------------------------------------- -----------
Could not evaluate javascript response:
[Exception... "Node was not found" code: "8" nsresult: "0x80530008
(NS_ERROR_DOM_NOT_FOUND_ERR)" location: "http://localhost:9090/trs Line:
76"]
org.eclipse.swt.EventUtil.suspendEventHandling();
var req = org.eclipse.swt.Request.getInstance();
req.setRequestCounter( "1063" );
var wm = org.eclipse.swt.WidgetManager.getInstance();
wm.dispose( "w617" );
var w = wm.findWidgetById( "w3" );
w.setSpace( 0, 1143, 0, 20 );
org.eclipse.swt.MenuUtil.unhideMenu( wm.findWidgetById( "w12" ) );
var w = wm.newWidget( "w618", "", false, null, 'qx.ui.menu.Button' );
org.eclipse.swt.MenuUtil.setLabelMode( w );
var t = wm.findWidgetById( "w12" );
t.addAt( w, 0 );
w.setLabel( "Hide Labels" );
w.addEventListener( "execute", org.eclipse.swt.EventUtil.widgetSelected );
qx.ui.core.Widget.flushGlobalQueues();
org.eclipse.swt.EventUtil.resumeEventHandling();
//---------------------------------------------------------- -----------
Here the code which support my contextual menu :
//---------------------------------------------------------- -----------
private ContextMenuListener contextMenuListener = new
ContextMenuListener();
private MenuManager manager;
private void hookContextMenu() {
manager = new MenuManager("#LabelLayersPopup");
manager.setRemoveAllWhenShown(true);
Menu menu = manager.createContextMenu(this.filtersTableViewer
.getControl());
this.filtersTableViewer.getControl().setMenu(menu);
manager.addMenuListener(contextMenuListener);
}
private void fillContextMenu(IMenuManager manager) {
Menu menu = filtersTableViewer.getControl().getMenu();
if (menu == null) {
menu = new Menu(filtersTableViewer.getControl());
filtersTableViewer.getControl().setMenu(menu);
}
TableItem[] selection = filtersTableViewer.getTable().getSelection();
if (selection != null && selection.length > 0) {
Object data = selection[0].getData();
GxForegroundLayer layer = ((GxForegroundLayer) data);
WeakReference<CrCGxLabelLayer> reference = layer.getLabelLayer();
if (layer.isVisible() && reference != null) {
final CrCGxLabelLayer labelLayer = layer.getLabelLayer().get();
if (labelLayer != null) {
Action action = null;
if (labelLayer.isVisible()) {
action = new Action("Hide Labels") {
public void run() {
labelLayer.setVisible(!labelLayer.isVisible());
}
};
} else {
action = new Action("Display Labels") {
public void run() {
labelLayer.setVisible(!labelLayer.isVisible());
}
};
}
manager.add(action);
}
}
}
}
private class ContextMenuListener implements IMenuListener2 {
public void menuAboutToHide(IMenuManager manager) {
}
public void menuAboutToShow(IMenuManager manager) {
fillContextMenu(manager);
}
}
//---------------------------------------------------------- --------
It seems like the right-clicks are so fasts that the IHM has no time to
treat all the request. But I don't if I forgot something in the code or if
it has to be considered as a bug.
Thanks for your help.
Cédric G.
|
|
|
|
Re: Javascript error when displaying a contextual menu [message #74288 is a reply to message #74253] |
Mon, 18 February 2008 05:06  |
Eclipse User |
|
|
|
Originally posted by: rherrmann.innoopract.com
Cedric,
thanks for pointing this out. Yes, a bug report to capture these
steps and track progress would help.
Cheers
Rüdiger
Cédric G. wrote:
> Hi,
>
> I have reproduced the problem described in the previous message with the
> fourth rap demo http://ondemand.yoxos.com/geteclipse/start
>
> In the "Plug-in Explorer" tab, I got it when doing fast right clicks on
> the tree items.
>
> The problem seems located in the Javascript method "unhideMenu" of the
> "MenuUtil" class :
>
> /*
> * Hides preliminary item and reveals the menu. Called by the
> response to a
> * menu shown event.
> */
> unhideMenu : function( menu ) {
> var items = menu.getLayout().getChildren();
> for( var i = 0; i < items.length; i++ ) {
> var item = items[ i ];
> item.setDisplay( true );
> }
> var preItem = menu.getUserData( "preItem" );
> if( preItem ) {
> preItem.setDisplay( false );
> }
> }
>
> I would say that when the "setDisplay" is called, the node for the
> preitem doesn't exist anymore in the node tree.
>
> Should I notice it in bugzilla ?
>
> Regards,
>
> Cédric G.
>
|
|
|
Powered by
FUDForum. Page generated in 0.03395 seconds