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(Assertion failed exception on getting from IObservable)
Contacts based app, use of IObservable [message #525643] 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.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 #525754 is a reply to message #525643] Wed, 07 April 2010 16:59 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6566
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
>
>
Re: Contacts based app, use of IObservable [message #526318 is a reply to message #525754] Fri, 09 April 2010 16:04 Go to previous messageGo to next message
David Wynter is currently offline David WynterFriend
Messages: 4624
Registered: July 2009
Senior Member
Hi,

OK, if I understand you correctly I can use the 'hidden' Realm in the Display thread. Which suggests that I need to have all my handlers in the MParts I have in the application. Which I tried but still get the same error. Is there anywhere that explains the call sequences used for updating/persisting UI present data.

Also I need to be able to access the currently selected object on display, programatically. How do you do this?

Thx.

David
Re: Contacts based app, use of IObservable [message #527014 is a reply to message #525754] Tue, 13 April 2010 17:13 Go to previous messageGo to next message
David Wynter is currently offline David WynterFriend
Messages: 4624
Registered: July 2009
Senior Member
I'll give more information on this error.

I can see that the Contacts application has a IObservableList for the contacts in VCardContactsRepository. but the saving of an individual VCard is in the DetailsView where it is using the Realm in the UI Display thread as you indicated. It can do this because each contact is persisted in a standalone file.

My application differs in that all my testcases are held in a single file and I persist all testcases whenever any one changes, is added or is deleted. So ideally I need access to my IObservableList in my equivalent of VCardContactsRepository when persisting.

Here is the code that gets the exception as follows
Caused by: org.eclipse.core.runtime.AssertionFailedException: assertion
failed: Getter called outside realm of observable


		List<TestCase> testcases = TestCaseRepositoryFactory.getTestCaseRepository().getAllTestCases();

		BufferedWriter writer = new BufferedWriter(outputStream);
		try {
			for(int i=0; i<testcases.size(); i++){


What do I have to do to allow local access to that IObservableList (as returned by getAllTestCases()Wink above?

Thx.

David
Re: Contacts based app, use of IObservable [message #528164 is a reply to message #527014] Mon, 19 April 2010 14:37 Go to previous messageGo to next message
Boris Bokowski is currently offline Boris BokowskiFriend
Messages: 272
Registered: July 2009
Senior Member
Hi David,

Does the following wiki page help?
http://wiki.eclipse.org/JFace_Data_Binding/Realm

Boris

"David Wynter" <david_wynter@yahoo.com> wrote in message
news:hq28nc$tec$1@build.eclipse.org...
> I'll give more information on this error.
> I can see that the Contacts application has a IObservableList for the
> contacts in VCardContactsRepository. but the saving of an individual VCard
> is in the DetailsView where it is using the Realm in the UI Display thread
> as you indicated. It can do this because each contact is persisted in a
> standalone file.
>
> My application differs in that all my testcases are held in a single file
> and I persist all testcases whenever any one changes, is added or is
> deleted. So ideally I need access to my IObservableList in my equivalent
> of VCardContactsRepository when persisting.
> Here is the code that gets the exception as follows
>
> Caused by: org.eclipse.core.runtime.AssertionFailedException: assertion
> failed: Getter called outside realm of observable
>
>
>
> List<TestCase> testcases =
> TestCaseRepositoryFactory.getTestCaseRepository().getAllTest Cases();
>
> BufferedWriter writer = new BufferedWriter(outputStream);
> try {
> for(int i=0; i<testcases.size(); i++){
>
>
> What do I have to do to allow local access to that IObservableList (as
> returned by getAllTestCases();) above?
>
> Thx.
>
> David
Re: Contacts based app, use of IObservable [message #529908 is a reply to message #528164] Tue, 27 April 2010 16:03 Go to previous messageGo to next message
David Wynter is currently offline David WynterFriend
Messages: 4624
Registered: July 2009
Senior Member
Hi,

I have read that but remain confused. I read this quote from the DataBinding wiki "If your UI is the only source of changes to your model, then everything will happen on the UI thread anyway and you don't have to worry about realms." And as far as I can tell all my changes to the observable are in the UI. What I suppose is not clear is my IObservableList is instantiated in a Repository accessible via Factory, the same as for the Contacts example. It reads in the model from a file in that class, again the sampel as the Contact example. It tries to persist the model to a file in my equivalent to the DetailsView in the Contacts model. It works there for Contact but not for me in my parallel classes. I am so close in design to the Contact example I cannot see why mine fails.

I don't want to create a Realm and replace the UI thread Realm for my Observable, things are supposed to be simpler not more complex. But this is what I will try next as I can see nothing wrong with my current approach but it clearly does not work.

Thx.

David
Re: Contacts based app, use of IObservable [message #529974 is a reply to message #529908] Tue, 27 April 2010 21:02 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6566
Registered: July 2009
Senior Member
I think Save-Operations (was that the original problem) are called out
the UI-Thread.

Tom

Am 27.04.10 18:03, schrieb David Wynter:
> Hi,
>
> I have read that but remain confused. I read this quote from the
> DataBinding wiki "If your UI is the only source of changes to your
> model, then everything will happen on the UI thread anyway and you don't
> have to worry about realms." And as far as I can tell all my changes to
> the observable are in the UI. What I suppose is not clear is my
> IObservableList is instantiated in a Repository accessible via Factory,
> the same as for the Contacts example. It reads in the model from a file
> in that class, again the sampel as the Contact example. It tries to
> persist the model to a file in my equivalent to the DetailsView in the
> Contacts model. It works there for Contact but not for me in my parallel
> classes. I am so close in design to the Contact example I cannot see why
> mine fails.
>
> I don't want to create a Realm and replace the UI thread Realm for my
> Observable, things are supposed to be simpler not more complex. But this
> is what I will try next as I can see nothing wrong with my current
> approach but it clearly does not work.
>
> Thx.
>
> David
Re: Contacts based app, use of IObservable [message #530022 is a reply to message #529974] Wed, 28 April 2010 08:15 Go to previous messageGo to next message
David Wynter is currently offline David WynterFriend
Messages: 4624
Registered: July 2009
Senior Member
Hi Tom,

Sorry for my ignorance, since the e4 framework is the thing starting these threads it is not obvious to me what is in the UIThread and what is not. How do you tell?

Thx.

David
Re: Contacts based app, use of IObservable [message #530026 is a reply to message #529974] Wed, 28 April 2010 08:32 Go to previous messageGo to next message
David Wynter is currently offline David WynterFriend
Messages: 4624
Registered: July 2009
Senior Member
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 #530106 is a reply to message #530026] Wed, 28 April 2010 13:42 Go to previous messageGo to next message
David Wynter is currently offline David WynterFriend
Messages: 4624
Registered: July 2009
Senior Member
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().getAllTestCases();
					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
Re: Contacts based app, use of IObservable [message #573768 is a reply to message #525754] Fri, 09 April 2010 16:04 Go to previous messageGo to next message
David Wynter is currently offline David WynterFriend
Messages: 4624
Registered: July 2009
Senior Member
Hi,

OK, if I understand you correctly I can use the 'hidden' Realm in the Display thread. Which suggests that I need to have all my handlers in the MParts I have in the application. Which I tried but still get the same error. Is there anywhere that explains the call sequences used for updating/persisting UI present data.

Also I need to be able to access the currently selected object on display, programatically. How do you do this?

Thx.

David
Re: Contacts based app, use of IObservable [message #574130 is a reply to message #525754] Tue, 13 April 2010 17:13 Go to previous messageGo to next message
David Wynter is currently offline David WynterFriend
Messages: 4624
Registered: July 2009
Senior Member
I'll give more information on this error.

I can see that the Contacts application has a IObservableList for the contacts in VCardContactsRepository. but the saving of an individual VCard is in the DetailsView where it is using the Realm in the UI Display thread as you indicated. It can do this because each contact is persisted in a standalone file.

My application differs in that all my testcases are held in a single file and I persist all testcases whenever any one changes, is added or is deleted. So ideally I need access to my IObservableList in my equivalent of VCardContactsRepository when persisting.

Here is the code that gets the exception as follows

Caused by: org.eclipse.core.runtime.AssertionFailedException: assertion
failed: Getter called outside realm of observable



List<TestCase> testcases = TestCaseRepositoryFactory.getTestCaseRepository().getAllTest Cases();

BufferedWriter writer = new BufferedWriter(outputStream);
try {
for(int i=0; i<testcases.size(); i++){


What do I have to do to allow local access to that IObservableList (as returned by getAllTestCases();) above?

Thx.

David
Re: Contacts based app, use of IObservable [message #574829 is a reply to message #527014] Mon, 19 April 2010 14:37 Go to previous messageGo to next message
Boris Bokowski is currently offline Boris BokowskiFriend
Messages: 272
Registered: July 2009
Senior Member
Hi David,

Does the following wiki page help?
http://wiki.eclipse.org/JFace_Data_Binding/Realm

Boris

"David Wynter" <david_wynter@yahoo.com> wrote in message
news:hq28nc$tec$1@build.eclipse.org...
> I'll give more information on this error.
> I can see that the Contacts application has a IObservableList for the
> contacts in VCardContactsRepository. but the saving of an individual VCard
> is in the DetailsView where it is using the Realm in the UI Display thread
> as you indicated. It can do this because each contact is persisted in a
> standalone file.
>
> My application differs in that all my testcases are held in a single file
> and I persist all testcases whenever any one changes, is added or is
> deleted. So ideally I need access to my IObservableList in my equivalent
> of VCardContactsRepository when persisting.
> Here is the code that gets the exception as follows
>
> Caused by: org.eclipse.core.runtime.AssertionFailedException: assertion
> failed: Getter called outside realm of observable
>
>
>
> List<TestCase> testcases =
> TestCaseRepositoryFactory.getTestCaseRepository().getAllTest Cases();
>
> BufferedWriter writer = new BufferedWriter(outputStream);
> try {
> for(int i=0; i<testcases.size(); i++){
>
>
> What do I have to do to allow local access to that IObservableList (as
> returned by getAllTestCases();) above?
>
> Thx.
>
> David
Re: Contacts based app, use of IObservable [message #575210 is a reply to message #528164] Tue, 27 April 2010 16:03 Go to previous messageGo to next message
David Wynter is currently offline David WynterFriend
Messages: 4624
Registered: July 2009
Senior Member
Hi,

I have read that but remain confused. I read this quote from the DataBinding wiki "If your UI is the only source of changes to your model, then everything will happen on the UI thread anyway and you don't have to worry about realms." And as far as I can tell all my changes to the observable are in the UI. What I suppose is not clear is my IObservableList is instantiated in a Repository accessible via Factory, the same as for the Contacts example. It reads in the model from a file in that class, again the sampel as the Contact example. It tries to persist the model to a file in my equivalent to the DetailsView in the Contacts model. It works there for Contact but not for me in my parallel classes. I am so close in design to the Contact example I cannot see why mine fails.

I don't want to create a Realm and replace the UI thread Realm for my Observable, things are supposed to be simpler not more complex. But this is what I will try next as I can see nothing wrong with my current approach but it clearly does not work.

Thx.

David
Re: Contacts based app, use of IObservable [message #575239 is a reply to message #575210] Tue, 27 April 2010 21:02 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6566
Registered: July 2009
Senior Member
I think Save-Operations (was that the original problem) are called out
the UI-Thread.

Tom

Am 27.04.10 18:03, schrieb David Wynter:
> Hi,
>
> I have read that but remain confused. I read this quote from the
> DataBinding wiki "If your UI is the only source of changes to your
> model, then everything will happen on the UI thread anyway and you don't
> have to worry about realms." And as far as I can tell all my changes to
> the observable are in the UI. What I suppose is not clear is my
> IObservableList is instantiated in a Repository accessible via Factory,
> the same as for the Contacts example. It reads in the model from a file
> in that class, again the sampel as the Contact example. It tries to
> persist the model to a file in my equivalent to the DetailsView in the
> Contacts model. It works there for Contact but not for me in my parallel
> classes. I am so close in design to the Contact example I cannot see why
> mine fails.
>
> I don't want to create a Realm and replace the UI thread Realm for my
> Observable, things are supposed to be simpler not more complex. But this
> is what I will try next as I can see nothing wrong with my current
> approach but it clearly does not work.
>
> Thx.
>
> David
Re: Contacts based app, use of IObservable [message #575258 is a reply to message #529974] Wed, 28 April 2010 08:15 Go to previous messageGo to next message
David Wynter is currently offline David WynterFriend
Messages: 4624
Registered: July 2009
Senior Member
Hi Tom,

Sorry for my ignorance, since the e4 framework is the thing starting these threads it is not obvious to me what is in the UIThread and what is not. How do you tell?

Thx.

David
Re: Contacts based app, use of IObservable [message #575270 is a reply to message #529974] Wed, 28 April 2010 08:32 Go to previous messageGo to next message
David Wynter is currently offline David WynterFriend
Messages: 4624
Registered: July 2009
Senior Member
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 13:42 Go to previous message
David Wynter is currently offline David WynterFriend
Messages: 4624
Registered: July 2009
Senior Member
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
Previous Topic:Watching e4 model from BundleActivator?
Next Topic:Is inheritance supported by XWT?
Goto Forum:
  


Current Time: Wed Sep 23 11:02:46 GMT 2020

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

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

Back to the top