Community
Participate
Working Groups
Since Eclipse 4.9 (SimRel 2018-09, org.eclipse.jface 3.14.100), the "Model Explorer" view from Sirius fails to initialize with: java.lang.ClassCastException: org.eclipse.swt.layout.GridData cannot be cast to org.eclipse.swt.layout.FillData at org.eclipse.swt.layout.FillLayout.flushCache(FillLayout.java:176) at org.eclipse.swt.widgets.Composite.layout(Composite.java:834) at org.eclipse.swt.widgets.Control.requestLayout(Control.java:2414) at org.eclipse.jface.action.ToolBarManager.relayout(ToolBarManager.java:224) at org.eclipse.jface.action.ToolBarManager.update(ToolBarManager.java:384) at org.eclipse.sirius.ui.tools.internal.views.common.navigator.filter.FilteredCommonTree.createFilterControls(FilteredCommonTree.java:356) at org.eclipse.sirius.ui.tools.internal.views.common.navigator.filter.FilteredCommonTree.createControl(FilteredCommonTree.java:320) at org.eclipse.sirius.ui.tools.internal.views.common.navigator.filter.FilteredCommonTree.init(FilteredCommonTree.java:285) at org.eclipse.sirius.ui.tools.internal.views.common.navigator.filter.FilteredCommonTree.<init>(FilteredCommonTree.java:232) at org.eclipse.sirius.ui.tools.internal.views.modelexplorer.ModelExplorerView.createCommonViewerObject(ModelExplorerView.java:321) This is only visible under Windows, and corresponds to a very old (but latent until now) bug in Sirius's FilteredCommonTree.
In `ModelExplorerView` we do: @Override public void createPartControl(Composite aParent) { aParent.setLayout(new FillLayout(SWT.HORIZONTAL)); i.e. we confgure the "aParent" composite to use a FillLayout to layout its children. After a few more calls... oes.ui.tools.internal.views.common.navigator.filter.FilteredCommonTree.<init>(java.lang.String, org.eclipse.swt.widgets.Composite, int, boolean) line: 228 oes.ui.tools.internal.views.modelexplorer.ModelExplorerView.createCommonViewerObject(org.eclipse.swt.widgets.Composite) line: 321 oes.ui.tools.internal.views.modelexplorer.ModelExplorerView(org.eclipse.ui.navigator.CommonNavigator).createCommonViewer(org.eclipse.swt.widgets.Composite) line: 495 oes.ui.tools.internal.views.modelexplorer.ModelExplorerView(org.eclipse.ui.navigator.CommonNavigator).createPartControl(org.eclipse.swt.widgets.Composite) line: 187 oes.ui.tools.internal.views.modelexplorer.ModelExplorerView.createPartControl(org.eclipse.swt.widgets.Composite) line: 102 we end up creating a FilteredCommonTree with this composite as parent, still configured to use a FillLayout. Then in FilteredCommonTree.createControl(Composite, int) we do: protected void createControl(Composite aParent, int treeStyle) { GridLayout layout = new GridLayout(); layout.marginHeight = 0; layout.marginWidth = 0; setLayout(layout); setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); I'm not sure what was the original intent, but we associate an a GridData to the FilteredCommonTree although its parent (the composite) is configured with a FillLayout. This fails a little later with java.lang.ClassCastException: org.eclipse.swt.layout.GridData cannot be cast to org.eclipse.swt.layout.FillData at org.eclipse.swt.layout.FillLayout.flushCache(FillLayout.java:176) at org.eclipse.swt.widgets.Composite.layout(Composite.java:834) at org.eclipse.swt.widgets.Control.requestLayout(Control.java:2414) at org.eclipse.jface.action.ToolBarManager.relayout(ToolBarManager.java:224) at org.eclipse.jface.action.ToolBarManager.update(ToolBarManager.java:384) when the FillLayout is called and assumes all the children to layout are correctly setup with a FillData.
The bug only happens under Windows as it is triggered by filterToolBar.update(false) in FilteredCommonTree.createFilterControls(Composite), but this call is never made under Linux because here filterToolBar is never initialized. In FilteredCommonTree.createClearTextOld(Composite), filterToolBar is created only if the text field doesn't have the SWT.ICON_CANCEL flag, and this is only set depending on the result of FilteredCommonTree.useNativeSearchField(aParent), which is OS-dependant. Up to (and including) Photon, the inconsistancy was present but for some reason never triggered a failure. The change made in ToolBarManager.relayout(ToolBar, int, int) by commit https://git.eclipse.org/r/c/125161 changed that, and starting with JFace 3.14.100 (first available in SimRel 2018-09), we now get a ClassCastException and a complete failure to initialize thee Model Explorer view.
Created attachment 275933 [details] The Model Explorer view failing to initialize
Sirius's FilteredCommonTree class was initially (a looong time ago) a copy of JFace's org.eclipse.ui.dialogs.FilteredTree. The bug was there at the time in the original. It was fixed in FilteredTree by commit: c9e5e2d2d0c28bcc0fef48dcca2be87cc429db51 "Fixed bug 226155: FilteredTree assumes parent uses GridLayout" See https://git.eclipse.org/r/plugins/gitiles/platform/eclipse.platform.ui/+/c9e5e2d2d0c28bcc0fef48dcca2be87cc429db51%5E%21/#F0 Of course we did not notice that, and our own version has been exposed to the bug until now. The fix will be simply to apply to our version the same change that was made in FilteredTree. In addition I'll try to have a look at *why* we needed (or thought we needed) to create a whole copy of the JFace class, instead of subclassing it (for example).
New Gerrit change created: https://git.eclipse.org/r/129866
Gerrit change https://git.eclipse.org/r/129866 was merged to [v6.0.x]. Commit: http://git.eclipse.org/c/sirius/org.eclipse.sirius.git/commit/?id=ad152bfcec01d6154d037808e6de85409da82c2c
Fixed by ad152bfcec01d6154d037808e6de85409da82c2c. There are no automated tests: * our test suites are normally run under Linux, so wouldn't show the problem; * under Windows, almost every single (SWTbot) test which tries to interact with the Model Explorer view would already fail with this bug, as long as we are in the correct context (Windows, SimRel 2018-09 or later). Steps to validate, under Windows: 1. Install an Eclipse Commiters package (any package without Sirius pre-installed, so any except Modeling) from SimRel 2018-09 (or later). 2. Launch Eclipse and install the Sirius version begin validated from its repository, e.g. http://download.eclipse.org/sirius/updates/nightly/6.0.x/photon 3. Restart; switch the the "Modeling" perspective: the "Model Explorer" view in the top-left should be initialized without error.
Validated on Sirius 6.0.2 (6.0.2.201809241340)
New Gerrit change created: https://git.eclipse.org/r/129934
Gerrit change https://git.eclipse.org/r/129934 was merged to [v6.0.x]. Commit: http://git.eclipse.org/c/sirius/org.eclipse.sirius.git/commit/?id=15b4d163768790378157f76dc6b96cb2742ee464
Available in Sirius 6.0.2: https://wiki.eclipse.org/Sirius/6.0.2
*** Bug 540039 has been marked as a duplicate of this bug. ***