Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Remote Application Platform (RAP) » ClassCastException layout.GridData cannot cast to FillData in RAP 3.11(RAP 3.11 Compatability.)
ClassCastException layout.GridData cannot cast to FillData in RAP 3.11 [message #1821583] Sun, 16 February 2020 13:37 Go to next message
Chandra Kyama is currently offline Chandra KyamaFriend
Messages: 9
Registered: February 2020
Junior Member
Currently we are migrating our product RCP to RAP where as Eclipse org.eclipse.swt_3.8.1.v3836 to RAP 3.11 Version.
While opening the file selection dialog, we are getting the below exceptions.

The peice of code we are using in FileDialog.

FileDialog dlg = new FileDialog(getShell(), SWT.CLOSE | SWT.TITLE | SWT.APPLICATION_MODAL);
dlg.setText(IMessages.ATTACH_MY_DOC_BTN);
dlg.setFilterExtensions(new String[]{EXTENSIONS});
String[] filterNames = { "PDF Files", "All Files" };
dlg.setFilterExtensions(filterNames);
String fp = dlg.open();

Exception:
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:184)
at org.eclipse.swt.widgets.Composite.changed(Composite.java:664)
at org.eclipse.rap.rwt.internal.textsize.ClearLayoutBuffersVisitor.visit(ClearLayoutBuffersVisitor.java:25)
at org.eclipse.swt.internal.widgets.WidgetTreeUtil.accept(WidgetTreeUtil.java:32)
at org.eclipse.swt.internal.widgets.WidgetTreeUtil.handleChildren(WidgetTreeUtil.java:111)
at org.eclipse.swt.internal.widgets.WidgetTreeUtil.accept(WidgetTreeUtil.java:40)
at org.eclipse.swt.internal.widgets.WidgetTreeUtil.handleChildren(WidgetTreeUtil.java:111)
at org.eclipse.swt.internal.widgets.WidgetTreeUtil.accept(WidgetTreeUtil.java:40)
at org.eclipse.swt.internal.widgets.WidgetTreeUtil.handleChildren(WidgetTreeUtil.java:111)
at org.eclipse.swt.internal.widgets.WidgetTreeUtil.accept(WidgetTreeUtil.java:40)
at org.eclipse.swt.internal.widgets.WidgetTreeUtil.handleChildren(WidgetTreeUtil.java:111)
at org.eclipse.swt.internal.widgets.WidgetTreeUtil.accept(WidgetTreeUtil.java:40)
at org.eclipse.swt.internal.widgets.WidgetTreeUtil.handleChildren(WidgetTreeUtil.java:111)
at org.eclipse.swt.internal.widgets.WidgetTreeUtil.accept(WidgetTreeUtil.java:40)
at org.eclipse.rap.rwt.internal.textsize.TextSizeRecalculation.clearLayoutBuffers(TextSizeRecalculation.java:61)
at org.eclipse.rap.rwt.internal.textsize.TextSizeRecalculation.forceShellRecalculations(TextSizeRecalculation.java:44)
at org.eclipse.rap.rwt.internal.textsize.TextSizeRecalculation.execute(TextSizeRecalculation.java:36)
at org.eclipse.rap.rwt.internal.textsize.MeasurementOperator$MeasurementOperatorHandler$1.run(MeasurementOperator.java:127)
at org.eclipse.rap.rwt.internal.lifecycle.ProcessActionRunner.executeNext(ProcessActionRunner.java:50)
at org.eclipse.swt.widgets.Display.runPendingMessages(Display.java:1196)
at org.eclipse.swt.widgets.Display.safeReadAndDispatch(Display.java:1181)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:1173)
at org.eclipse.swt.widgets.Dialog.runEventLoop(Dialog.java:255)
at org.eclipse.swt.widgets.FileDialog.open(FileDialog.java:332)
at com.kewill.kc.image.ui.composite.ImagingFindComposite$10.run(ImagingFindComposite.java:537)
at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:66)
at com.kewill.kc.image.ui.composite.ImagingFindComposite.attachMyDocBtnClick(ImagingFindComposite.java:521)
at com.kewill.kc.image.ui.composite.ImagingFindComposite.access$7(ImagingFindComposite.java:520)
at com.kewill.kc.image.ui.composite.ImagingFindComposite$9.widgetSelected(ImagingFindComposite.java:323)
at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:263)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:109)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:687)
at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java:594)
at org.eclipse.swt.widgets.Display.executeNextEvent(Display.java:1217)
at org.eclipse.swt.widgets.Display.runPendingMessages(Display.java:1198)
at org.eclipse.swt.widgets.Display.safeReadAndDispatch(Display.java:1181)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:1173)
at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2733)
at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2694)
at org.eclipse.ui.internal.Workbench.access$5(Workbench.java:2530)
at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:701)
at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:338)
at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:684)
at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:157)
at com.kewill.icustoms.ui.rap.CmusWorkbench.createUI(CmusWorkbench.java:49)
at org.eclipse.rap.rwt.internal.lifecycle.RWTLifeCycle.createUI(RWTLifeCycle.java:177)
at org.eclipse.rap.rwt.internal.lifecycle.RWTLifeCycle$UIThreadController.run(RWTLifeCycle.java:290)
at java.lang.Thread.run(Thread.java:745)
at org.eclipse.rap.rwt.internal.lifecycle.UIThread.run(UIThread.java:107)

To reslove above error, I have tried with the below code(override).
Method 1:
GridData gd = new GridData();
gd.grabExcessHorizontalSpace = true;
gd.grabExcessVerticalSpace = true;
getShell().setLayoutData(layoutData);

Method 2:
FillLayout fillLayout = new FillLayout();
getShell().setLayoutData(fillLayout);

Method 3:
Unable to override FillLayout.flushCache() in Local class.

Even after made above changes, we are getting same problem or exception.
Would please suggest to overcome this problem and fix accordingly and provide me if any upgrade version RAP will solve this problem?
Re: ClassCastException layout.GridData cannot cast to FillData in RAP 3.11 [message #1822375 is a reply to message #1821583] Thu, 05 March 2020 08:51 Go to previous message
Chandra Kyama is currently offline Chandra KyamaFriend
Messages: 9
Registered: February 2020
Junior Member
Subject :

We Identified and fixed the problem in below possible ways.
As we all know FileDialog does not creates the layout problem and the problem is created in respective Composite's layout used fileDialog. We found familiar solutions as mentioned in below.

Solution 1:
RAP API provides to @Overrides the FileDialog open method implementation with Callback mechanism in RAP latest versions. As we are implemented same in our application with additional asynchronous multidialog mechanism it is working fine as we expected.
Sample Code Provides as below.

BusyIndicator.showWhile(this.getDisplay(), new Runnable() {
public void run() {
try {
FileDialog dlg = new FileDialog(getShell());
dlg.setText(IMessages.ATTACH_MY_DOC_BTN);
dlg.setFilterExtensions(new String[]{EXTENSIONS});
dlg.open(new DialogCallback() {
public void dialogClosed(int returnCode) {
//TODO your own specific implementation logic.
}
});
}
catch (Exception e) {
log.error("Error to attach image.", e);
}
}
});

Solution 2:
In FileDialog, We have @override org.eclipse.swt.widgets.Dialog's runEventLoop function and bypassing the CCE exception and implemented the customized FileDialog, working fine as expected.
Sample Code implementation:
Write your own fileDialog and override the runEventLoop function.

@Override
protected void runEventLoop( Shell shell ) {
shell.open();
Display display = shell.getDisplay();
while( !shell.isDisposed() ) {
try {
if( !display.readAndDispatch() ) {
display.sleep();
}
} catch (ClassCastException e) {
e.printStackTrace();
} catch (Exception e) {
throw e;
}
}
}

First of all try approach Solution-1 and if it is not work then go to Solution-2.

Thanks & Regards
Chandra Shaker K


Previous Topic:LabelProvider called even for invisible GridColumns
Next Topic:BUild Rap runtime from source
Goto Forum:
  


Current Time: Wed Dec 04 19:00:57 GMT 2024

Powered by FUDForum. Page generated in 0.04016 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top