Home » Eclipse Projects » Eclipse 4 » Contacts based app, use of IObservable(Assertion failed exception on getting from IObservable)
Contacts based app, use of IObservable [message #525643] |
Wed, 07 April 2010 06:32  |
Eclipse User |
|
|
|
Hi,
On my continued journey learning e4. The Contacts example saves the Contact entity using saveAsVCard direct to a file. Is there a reason I cannot save the List contents directly?
When I try to do that I get an exception that I cannot find a decent description of using Google. It is clear what the exception is saying, but I could not find an example of using a WritableList is the correct way. Here is the exception
Caused by: org.eclipse.core.runtime.AssertionFailedException: assertion failed: Getter called outside realm of observable org.eclipse.core.databinding.observable.list.WritableList@437dcb
at org.eclipse.core.runtime.Assert.isTrue(Assert.java:110)
at org.eclipse.core.databinding.observable.ObservableTracker.getterCalled(ObservableTracker.java:256)
at org.eclipse.core.databinding.observable.list.ObservableList.getterCalled(ObservableList.java:241)
at org.eclipse.core.databinding.observable.list.ObservableList.size(ObservableList.java:121)
at com.hsbcib.grds.testui.model.TestCaseRepository.saveTestCases(TestCaseRepository.java:98)
Here is the code at fault
public TestCaseRepository () {
List<TestCase> tempcases = new ArrayList<TestCase>();
// Get the testcases from file store
getTestCases(tempcases);
this.testcases = new WritableList(tempcases, null);
}
...
public void saveTestCases() {
// Uses this format 'testcase name'|'Inbound meta filename'|
// 'Outbound meta filename'|'Mapping meta filename'|
// 'Inbound data filename'|'Outbound data filename'
// maps to Testcase object
FileWriter outputStream = null;
try {
outputStream = new FileWriter("./grdstestcase.dat");
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
BufferedWriter writer = new BufferedWriter(outputStream);
try {
for(int i=0; i<testcases.size(); i++){
TestCase aCase = (TestCase) testcases.get(i);
String record = "";
record = aCase.getName()+"|";
record += aCase.getInboundMetaFile()+"|";
record += aCase.getOutboundMetaFile()+"|";
record += aCase.getMappingMetaFile()+"|";
record += aCase.getInboundDataFile()+"|";
record += aCase.getOutboundDataFile()+"\n";
writer.write(record);
}
writer.close();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
testcases is the IObservableList object. The access to testcases.size() is line 98 in TestCaseRepository.
Thanks,
David
|
|
| | | | | | | |
Re: Contacts based app, use of IObservable [message #530026 is a reply to message #529974] |
Wed, 28 April 2010 04:32   |
Eclipse User |
|
|
|
I know what the error is, I just cannot see why my call to TestCaseView.doSave is different in the thread it is run in compared to the Contacts demo equivalennt. Here is the comparison between the stack traces at the point of saving.
Contacts example
Thread [ModalContext] (Suspended (breakpoint at line 74 in DetailsView))
DetailsView.doSave(IProgressMonitor) line: 74
NativeMethodAccessorImpl.invoke0(Method, Object, Object[]) line: not available [native method]
NativeMethodAccessorImpl.invoke(Object, Object[]) line: 39
DelegatingMethodAccessorImpl.invoke(Object, Object[]) line: 25
Method.invoke(Object, Object...) line: 597
InjectionMethod.callMethod(Object[]) line: 102
InjectionMethod.invoke(boolean, boolean) line: 63
InjectorImpl.invokeUsingClass(Object, Class, String, Object, IObjectProvider) line: 270
InjectorImpl.invoke(Object, String, Object, IObjectProvider) line: 255
ContextInjectionFactory.invoke(Object, String, IEclipseContext, Object) line: 140
SaveHandler$1.run(IProgressMonitor) line: 57
ModalContext$ModalContextThread.run() line: 121
Here is my application
Thread [ModalContext] (Suspended (breakpoint at line 60 in TestCaseView))
TestCaseView.doSave(IProgressMonitor) line: 60
NativeMethodAccessorImpl.invoke0(Method, Object, Object[]) line: not available [native method]
NativeMethodAccessorImpl.invoke(Object, Object[]) line: 39
DelegatingMethodAccessorImpl.invoke(Object, Object[]) line: 25
Method.invoke(Object, Object...) line: 597
InjectionMethod.callMethod(Object[]) line: 102
InjectionMethod.invoke(boolean, boolean) line: 63
InjectorImpl.invokeUsingClass(Object, Class, String, Object, IObjectProvider) line: 270
InjectorImpl.invoke(Object, String, Object, IObjectProvider) line: 255
ContextInjectionFactory.invoke(Object, String, IEclipseContext, Object) line: 140
SaveHandler$1.run(IProgressMonitor) line: 42
ModalContext$ModalContextThread.run() line: 121
I cannot see the difference here, the former works the latter fails.
What am I missing here?
Thx.
David
|
|
| | | | | | | |
Re: Contacts based app, use of IObservable [message #575270 is a reply to message #529974] |
Wed, 28 April 2010 04:32   |
Eclipse User |
|
|
|
I know what the error is, I just cannot see why my call to TestCaseView.doSave is different in the thread it is run in compared to the Contacts demo equivalennt. Here is the comparison between the stack traces at the point of saving.
Contacts example
Thread [ModalContext] (Suspended (breakpoint at line 74 in DetailsView))
DetailsView.doSave(IProgressMonitor) line: 74
NativeMethodAccessorImpl.invoke0(Method, Object, Object[]) line: not available [native method]
NativeMethodAccessorImpl.invoke(Object, Object[]) line: 39
DelegatingMethodAccessorImpl.invoke(Object, Object[]) line: 25
Method.invoke(Object, Object...) line: 597
InjectionMethod.callMethod(Object[]) line: 102
InjectionMethod.invoke(boolean, boolean) line: 63
InjectorImpl.invokeUsingClass(Object, Class, String, Object, IObjectProvider) line: 270
InjectorImpl.invoke(Object, String, Object, IObjectProvider) line: 255
ContextInjectionFactory.invoke(Object, String, IEclipseContext, Object) line: 140
SaveHandler$1.run(IProgressMonitor) line: 57
ModalContext$ModalContextThread.run() line: 121
Here is my application
Thread [ModalContext] (Suspended (breakpoint at line 60 in TestCaseView))
TestCaseView.doSave(IProgressMonitor) line: 60
NativeMethodAccessorImpl.invoke0(Method, Object, Object[]) line: not available [native method]
NativeMethodAccessorImpl.invoke(Object, Object[]) line: 39
DelegatingMethodAccessorImpl.invoke(Object, Object[]) line: 25
Method.invoke(Object, Object...) line: 597
InjectionMethod.callMethod(Object[]) line: 102
InjectionMethod.invoke(boolean, boolean) line: 63
InjectorImpl.invokeUsingClass(Object, Class, String, Object, IObjectProvider) line: 270
InjectorImpl.invoke(Object, String, Object, IObjectProvider) line: 255
ContextInjectionFactory.invoke(Object, String, IEclipseContext, Object) line: 140
SaveHandler$1.run(IProgressMonitor) line: 42
ModalContext$ModalContextThread.run() line: 121
I cannot see the difference here, the former works the latter fails.
What am I missing here?
Thx.
David
|
|
|
Re: Contacts based app, use of IObservable [message #575301 is a reply to message #530026] |
Wed, 28 April 2010 09:42  |
Eclipse User |
|
|
|
I read up on asyncExec and that did solve the problem. I will use it in the future too just to be sure. Here is my doSave method now for those who have followed this.
public void doSave(@Optional IProgressMonitor monitor) throws IOException, InterruptedException {
if (monitor == null) {
monitor = new NullProgressMonitor();
}
// Uses this format 'testcase name'|'Inbound meta filename'|
// 'Outbound meta filename'|'Mapping meta filename'|
// 'Inbound data filename'|'Outbound data filename'
// maps to Testcase object
Display display = parent.getDisplay();
if (!(display==null || display.isDisposed())) {
display.asyncExec(new Runnable () {
public void run() {
FileWriter outputStream = null;
try {
outputStream = new FileWriter("./grdstestcase.dat");
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
List<TestCase> testcases = TestCaseRepositoryFactory.getTestCaseRepository().getAllTest Cases();
BufferedWriter writer = new BufferedWriter(outputStream);
try {
for(int i=0; i<testcases.size(); i++){
TestCase aCase = testcases.get(i);
String record = "";
record = aCase.getName()+"|";
record += aCase.getInboundMetaFile()+"|";
record += aCase.getOutboundMetaFile()+"|";
record += aCase.getMappingMetaFile()+"|";
record += aCase.getInboundDataFile()+"|";
record += aCase.getOutboundDataFile()+"\n";
writer.write(record);
}
writer.close();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
dirtyable.setDirty(false);
}
});
}
}
Thanks for your help.
regards,
David
|
|
|
Goto Forum:
Current Time: Wed Jul 16 08:36:53 EDT 2025
Powered by FUDForum. Page generated in 0.08612 seconds
|