Community
Participate
Working Groups
Example: @Override protected void onAfterDeactivated(ISubModuleNode source) { super.onAfterDeactivated(source); source.setVisible(false); } In this case the SubModuleNode becomes invisible, then the last seen/activated node becomes shortly visible and then the first node in the navigation tree is activated and becomes visible. The last jump is very confusing and interferes some actions.
The reason is that the SWT tree item is made invisible while it is still the one that has the selection in the tree. SWT triggers an event to then select the first node. A solution is a make the source available sometime later. So instead write: Thread t = new Thread() { @Override public void run() { try { Thread.sleep(20); } catch (InterruptedException e) { // TODO Auto-generated catch block e.printStackTrace(); } Display.getCurrent().syncExec(new Runnable() { @Override public void run() { source.setVisible(false); } }); } }; t.start(); Display.syncExec alone is not enough. With the code above you get the desired behaviour. Not sure we can fix that in Riena. I leave the bug open for further investigation.
setting the severity to normal, since we have a working workaround.
I experienced sometimes a NPE using Display.getCurrent() what worked for me was using Display.getDefault(). So you should replace Display.getCurrent() with Display.getDefault()
Actually both Display.getXXX variants are "evil" and should not be avoided where possible. The problem is that their return value depends on the thread that calls them. Please use PlatformUI.getWorkbench().getDisplay(). :-)
typo - the above should read: "Display.getXXX should BE avoided..."