Community
Participate
Working Groups
I've tried org.eclipse.nebula.widgets.nattable.examples._400_Configuration._440_Editing._448_CDateTimeEditorExample in a MacOS environment. By clicking on the Date button I expected that the dropdown appears. But there's only the following exception: Exception in thread "main" java.lang.NullPointerException: Cannot invoke "org.eclipse.swt.internal.cocoa.NSView.isHiddenOrHasHiddenAncestor()" because "view" is null at org.eclipse.swt.widgets.Control.calculateVisibleRegion(Control.java:772) at org.eclipse.swt.widgets.Control.getVisibleRegion(Control.java:2060) at org.eclipse.swt.widgets.Control.internal_new_GC(Control.java:2190) at org.eclipse.swt.graphics.GC.<init>(GC.java:262) at org.eclipse.swt.graphics.GC.<init>(GC.java:223) at org.eclipse.nebula.cwt.v.VControl.computeSize(VControl.java:332) at org.eclipse.nebula.cwt.v.VControl.computeSize(VControl.java:274) at org.eclipse.nebula.cwt.v.VGridLayout.loadChildSizes(VGridLayout.java:416) at org.eclipse.nebula.cwt.v.VGridLayout.layout(VGridLayout.java:401) at org.eclipse.nebula.cwt.v.VPanel.layout(VPanel.java:189) at org.eclipse.nebula.cwt.v.VPanel.layout(VPanel.java:185) at org.eclipse.nebula.widgets.cdatetime.DatePicker.updateHeader(DatePicker.java:1380) at org.eclipse.nebula.widgets.cdatetime.DatePicker.updateLabels(DatePicker.java:1390) at org.eclipse.nebula.widgets.cdatetime.DatePicker.setFields(DatePicker.java:1021) at org.eclipse.nebula.widgets.cdatetime.CDateTime.createPicker(CDateTime.java:522) at org.eclipse.nebula.widgets.cdatetime.CDateTime.setOpen(CDateTime.java:1726) at org.eclipse.nebula.widgets.cdatetime.CDateTime.setOpen(CDateTime.java:1719) at org.eclipse.nebula.cwt.base.BaseCombo$3.handleEvent(BaseCombo.java:486) at org.eclipse.nebula.cwt.v.VControl.notifyListeners(VControl.java:633) at org.eclipse.nebula.cwt.v.VButton.filterEvent(VButton.java:121) at org.eclipse.nebula.cwt.v.VControl.handleEvent(VControl.java:213) at org.eclipse.nebula.cwt.v.VControl$1.handleEvent(VControl.java:160) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:89) at org.eclipse.swt.widgets.Display.sendEvent(Display.java:4441) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1512) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1535) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1520) at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java:1324) at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:4227) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3837) at org.eclipse.nebula.widgets.nattable.examples.runner.TabbedNatExampleRunner.run(TabbedNatExampleRunner.java:114) at org.eclipse.nebula.widgets.nattable.examples.runner.TabbedNatExampleRunner.run(TabbedNatExampleRunner.java:62) at org.eclipse.nebula.widgets.nattable.examples.NatTableExamples.main(NatTableExamples.java:53) After that, the aplication freezes and can only be killed. If I try the same example in a Windows environment it works nice (also in a Linux environment). So i did some effort to find the source of this error and it seems that MacOS fires a FocusOut event right after the click on the Button. There's a "suspicious" comment in org.eclipse.swt.widgets.Display.checkFocus(): /* * Bug in Cocoa. On Mac 10.8, a control loses and gains focus * when its bounds changes. The fix is to ignore these events. * See Bug 388574 & 433275. */ But I'm not sure if this is really the reason of the bug. Would be nice if the bug could be fixed. At least I'll investigate it and try to find a solution (or workaround).
You should assign this ticket to the Nebula project as it seems to be an issue in CDateTime and not NatTable. Maybe it is already fixed in a current version. Have you tried to use a newer Nebula version locally?
I've tried the current Nebula master branch, same effect. If I use the CDateTime widget outside NatTable it works fine. So I assume that it has to do with the org.eclipse.nebula.widgets.nattable.extension.nebula.cdatetime.CDateTimeCellEditor. I've just created an ugly hack to verify my assumption: private long currentTime = System.currentTimeMillis(); @Override public boolean commit(MoveDirectionEnum direction, boolean closeAfterCommit) { if (SWT.getPlatform() == "cocoa") { long myTime = System.currentTimeMillis(); long timeDiff = myTime - this.currentTime; System.err.println(timeDiff); if (timeDiff < 5000) { System.err.println("No Commit!"); return false; } System.err.println("Commit!"); this.currentTime = myTime; } return super.commit(direction, closeAfterCommit); } If I place this code in the CDateTimeCellEditor the NPE only come up once. Hitting the button for the DateTime a second time launches the Calendar widget. So it seems to be any kind of focus error (I assume that the CDateTimeCellEditor lost focus and therefore the close-cascade is triggered).
The NatTable framework adds a focus listener to close the editor if it looses the focus. Maybe that listener needs to be adjusted to ignore the event if the button is clicked.
Created attachment 286441 [details] fix for FocusOut bug in MacOS
The attached patch seems to fix the problem.
Thanks for the patch. Unfortunately I can't accept patches attached to the ticket. Please follow the contribution guideline and provide a patch via Gerrit so I can review it, a verification build is triggered and the contribution is automatically added to the contribution documents needed for the license stuff.
New Gerrit change created: https://git.eclipse.org/r/c/nattable/org.eclipse.nebula.widgets.nattable/+/181201
Hi Dirk, thanks for applying the patch. I didn't find the time to do it for myself, sorry. Want to give a +1
Gerrit change https://git.eclipse.org/r/c/nattable/org.eclipse.nebula.widgets.nattable/+/181201 was merged to [master]. Commit: http://git.eclipse.org/c/nattable/org.eclipse.nebula.widgets.nattable.git/commit/?id=547d30f2e4ac878c270c0a5d0bdab607566173ab
I have taken your patch and added it manually as you did not respond here. I set you as the author to satisfy the process. Hope that is also fine. Although I am not happy with that setup, as it is much more work for the review.
Released with 2.0.1