Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse 4 » Contacts based app, use of IObservable
Contacts based app, use of IObservable [message #573162] Wed, 07 April 2010 10:32 Go to next message
David Wynter is currently offline David WynterFriend
Messages: 4624
Registered: July 2009
Senior Member
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.ge tterCalled(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.saveTestCase s(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 #573237 is a reply to message #573162] Wed, 07 April 2010 16:59 Go to previous message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6651
Registered: July 2009
Senior Member
Eclipse-Databinding stuff needs to have Realm for the thread you are
using it. The workbench creates a default one for the Display-Thread
hence you often see people not using it.

If you are the one responsible for this you need to create your own
realm or if you invoke stuff not in an UI-Thread you need to provide the
Realm invoking code with Realm.runWithDefault().

Tom

Am 07.04.10 12:32, schrieb David Wynter:
> 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.ge tterCalled(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.saveTestCase s(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
>
>
Previous Topic:Bug while event setting selected Element?
Next Topic:Bye bye Eclipse?
Goto Forum:
  


Current Time: Fri Apr 26 17:05:08 GMT 2024

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

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

Back to the top