Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » [EMF] EMF Databinding to Tableviewer
[EMF] EMF Databinding to Tableviewer [message #522445] Mon, 22 March 2010 16:30 Go to next message
Rencana Tarigan is currently offline Rencana TariganFriend
Messages: 56
Registered: July 2009
Location: Bandung, Indonesia
Member

Hi all i have code like this
IEMFListProperty contacts = EMFProperties
				.list(PIMContactPackage.Literals.ADDRESS_BOOK__CONTACTS);

		contactsTable.setInput(contacts.observe(PIMContactUtils.getInstance()
				.getPimContact().getCurrentAddressBook()));


my question are :
1. is it right way to binding emf model to tableviewer ?
2. if it right, when i edit a model from that table but when i commit the changes the value at that table not edited, and when i restart my application it's change, how i can solve this problem

Thanks,
CanA


Re: [EMF] EMF Databinding to Tableviewer [message #522511 is a reply to message #522445] Mon, 22 March 2010 20:42 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33139
Registered: July 2009
Senior Member
This is a multi-part message in MIME format.
--------------060903080807080705040700
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit

Rencana,

No, that doesn't look right. Have a look at Tom's blog:

http://tomsondev.bestsolution.at/category/databinding/emf/tu torials/

You'll want to use EMFEditProperties if you expect undoable commands to
be used.


Rencana Tarigan wrote:
> Hi all i have code like this
> IEMFListProperty contacts = EMFProperties
> .list(PIMContactPackage.Literals.ADDRESS_BOOK__CONTACTS);
>
>
> contactsTable.setInput(contacts.observe(PIMContactUtils.getI nstance()
> .getPimContact().getCurrentAddressBook()));
>
> my question are :
> 1. is it right way to binding emf model to tableviewer ?
> 2. if it right, when i edit a model from that table but when i commit
> the changes the value at that table not edited, and when i restart my
> application it's change, how i can solve this problem
>
> Thanks,
> CanA

--------------060903080807080705040700
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: 8bit

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=UTF-8" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
Rencana,<br>
<br>
No, that doesn't look right.  Have a look at Tom's blog:<br>
<blockquote><a
href=" http://tomsondev.bestsolution.at/category/databinding/emf/tu torials/"> http://tomsondev.bestsolution.at/category/databinding/emf/tu torials/</a><br>
</blockquote>
You'll want to use EMFEditProperties
if you expect undoable commands to be used.<br>
<br>
<br>
Rencana Tarigan wrote:
<blockquote cite="mid:ho85vv$afr$1@build.eclipse.org" type="cite">Hi
all i have code like this
<br>
IEMFListProperty contacts = EMFProperties
<br>
               
..list(PIMContactPackage.Literals.ADDRESS_BOOK__CONTACTS);
<br>
<br>
       
contactsTable.setInput(contacts.observe(PIMContactUtils.getI nstance()
<br>
                .getPimContact().getCurrentAddressBook()));
<br>
<br>
my question are :
<br>
1. is it right way to binding emf model to tableviewer ?
<br>
2. if it right, when i edit a model from that table but when i commit
the changes the value at that table not edited, and when i restart my
application it's change, how i can solve this problem
<br>
<br>
Thanks,
<br>
CanA
<br>
</blockquote>
</body>
</html>

--------------060903080807080705040700--


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: [EMF] EMF Databinding to Tableviewer [message #522550 is a reply to message #522511] Tue, 23 March 2010 03:04 Go to previous messageGo to next message
Rencana Tarigan is currently offline Rencana TariganFriend
Messages: 56
Registered: July 2009
Location: Bandung, Indonesia
Member

Thanks Ed, i will try to reconfigure my code Smile

Re: [EMF] EMF Databinding to Tableviewer [message #523011 is a reply to message #522550] Wed, 24 March 2010 18:43 Go to previous messageGo to next message
Rencana Tarigan is currently offline Rencana TariganFriend
Messages: 56
Registered: July 2009
Location: Bandung, Indonesia
Member

Hi, Ed, i already test to add new model and it's automatically add to table, but it's not work with edit model, can you explain to me why this happen with the same code ?

Re: [EMF] EMF Databinding to Tableviewer [message #523328 is a reply to message #523011] Thu, 25 March 2010 22:16 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6651
Registered: July 2009
Senior Member
Can you show us your LabelProviders and check out my example code Ed was
pointing you to!

Tom

Am 24.03.10 19:43, schrieb Rencana Tarigan:
> Hi, Ed, i already test to add new model and it's automatically add to
> table, but it's not work with edit model, can you explain to me why this
> happen with the same code ?
Re: [EMF] EMF Databinding to Tableviewer [message #523439 is a reply to message #523328] Fri, 26 March 2010 13:48 Go to previous messageGo to next message
Rencana Tarigan is currently offline Rencana TariganFriend
Messages: 56
Registered: July 2009
Location: Bandung, Indonesia
Member

I'm not use LabelProvider, i'm still not understand about databinding, so now i'm only use adapter and then refresh tableviewer.

Tom, can you give some article for explain about EditingDomain, or can you tell me what should i learn first to understand about EMF and CDO ?

Thanks,


Re: [EMF] EMF Databinding to Tableviewer [message #523592 is a reply to message #523439] Sat, 27 March 2010 03:45 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6651
Registered: July 2009
Senior Member
Am 26.03.10 14:48, schrieb Rencana Tarigan:
> I'm not use LabelProvider, i'm still not understand about databinding,
> so now i'm only use adapter and then refresh tableviewer.

and that's your problem you'll have to use a LabelProvider like
IObservableMapLabelProvider, ObserveableCellLabelProvider which connects
itself to the domain-attributes.

>
> Tom, can you give some article for explain about EditingDomain, or can
> you tell me what should i learn first to understand about EMF and CDO ?
>
> Thanks,
>

The best thing is to fetch my example code from CVS as outlined in my
tutorial. ALL code is in Eclipse-CVS and you simply have to walk through
it with the help of my blog. To master EMF I'd say you should by the
EMF-Book

Tom
Re: [EMF] EMF Databinding to Tableviewer [message #523593 is a reply to message #523592] Sat, 27 March 2010 03:52 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6651
Registered: July 2009
Senior Member
Part 5 [1] of the tutorial shows how to setup a TableViewer with the
appropriate LabelProviders.

Tom

[1] http://tomsondev.bestsolution.at/2009/06/27/galileo-emf-data binding-part-5/

Am 27.03.10 04:45, schrieb Tom Schindl:
> Am 26.03.10 14:48, schrieb Rencana Tarigan:
>> I'm not use LabelProvider, i'm still not understand about databinding,
>> so now i'm only use adapter and then refresh tableviewer.
>
> and that's your problem you'll have to use a LabelProvider like
> IObservableMapLabelProvider, ObserveableCellLabelProvider which connects
> itself to the domain-attributes.
>
>>
>> Tom, can you give some article for explain about EditingDomain, or can
>> you tell me what should i learn first to understand about EMF and CDO ?
>>
>> Thanks,
>>
>
> The best thing is to fetch my example code from CVS as outlined in my
> tutorial. ALL code is in Eclipse-CVS and you simply have to walk through
> it with the help of my blog. To master EMF I'd say you should by the
> EMF-Book
>
> Tom
Re: [EMF] EMF Databinding to Tableviewer [message #523684 is a reply to message #523592] Sun, 28 March 2010 16:52 Go to previous messageGo to next message
Rencana Tarigan is currently offline Rencana TariganFriend
Messages: 56
Registered: July 2009
Location: Bandung, Indonesia
Member

Tom Schindl wrote on Sat, 27 March 2010 10:45
Am 26.03.10 14:48, schrieb Rencana Tarigan:
> I'm not use LabelProvider, i'm still not understand about databinding,
> so now i'm only use adapter and then refresh tableviewer.

and that's your problem you'll have to use a LabelProvider like
IObservableMapLabelProvider, ObserveableCellLabelProvider which connects
itself to the domain-attributes.

>
> Tom, can you give some article for explain about EditingDomain, or can
> you tell me what should i learn first to understand about EMF and CDO ?
>
> Thanks,
>

The best thing is to fetch my example code from CVS as outlined in my
tutorial. ALL code is in Eclipse-CVS and you simply have to walk through
it with the help of my blog. To master EMF I'd say you should by the
EMF-Book

Tom

Thanks Tom, I already buy EMF book second Edition Smile
i will learn it more Smile and always read your blog for guide me Smile


Re: [EMF] EMF Databinding to Tableviewer [message #523685 is a reply to message #523593] Sun, 28 March 2010 16:59 Go to previous message
Rencana Tarigan is currently offline Rencana TariganFriend
Messages: 56
Registered: July 2009
Location: Bandung, Indonesia
Member

Tom Schindl wrote on Sat, 27 March 2010 10:52
Part 5 [1] of the tutorial shows how to setup a TableViewer with the
appropriate LabelProviders.

Tom

[1] http://tomsondev.bestsolution.at/2009/06/27/galileo-emf-data binding-part-5/

Am 27.03.10 04:45, schrieb Tom Schindl:
> Am 26.03.10 14:48, schrieb Rencana Tarigan:
>> I'm not use LabelProvider, i'm still not understand about databinding,
>> so now i'm only use adapter and then refresh tableviewer.
>
> and that's your problem you'll have to use a LabelProvider like
> IObservableMapLabelProvider, ObserveableCellLabelProvider which connects
> itself to the domain-attributes.
>
>>
>> Tom, can you give some article for explain about EditingDomain, or can
>> you tell me what should i learn first to understand about EMF and CDO ?
>>
>> Thanks,
>>
>
> The best thing is to fetch my example code from CVS as outlined in my
> tutorial. ALL code is in Eclipse-CVS and you simply have to walk through
> it with the help of my blog. To master EMF I'd say you should by the
> EMF-Book
>
> Tom


here is my labelprovider :
public class GenericMapCellLabelProvider extends ObservableMapCellLabelProvider {
	private IObservableMap[] attributeMaps;
	private String messagePattern;

	public GenericMapCellLabelProvider(String messagePattern,
			IObservableMap... attributeMaps) {
		super(attributeMaps);
		this.messagePattern = messagePattern;
		this.attributeMaps = attributeMaps;
	}

	@Override
	public void update(ViewerCell cell) {
		Object element = cell.getElement();
		Object[] values = new Object[attributeMaps.length];
		int i = 0;
		for (IObservableMap m : attributeMaps) {
			if (m.get(element) instanceof ContactFullName) {
				ContactFullName contactFullName = (ContactFullName) m
						.get(element);
				values[i++] = contactFullName.getFamilyName() + " , "
						+ contactFullName.getGivenName();
			} else if (m.get(element) instanceof EList<?>) {
				List<?> listObject = (List<?>) m.get(element);
				if (!listObject.isEmpty()) {
					if (listObject.get(0) instanceof ContactEmailAddress) {
						ContactEmailAddress contactEmailAddress = (ContactEmailAddress) listObject
								.get(0);
						values[i++] = contactEmailAddress.getEmailAddress();
					}
				}
			} else {
				values[i++] = m.get(element);
			}
			if (values[i - 1] == null) {
				cell.setText("null");
				return;
			}
		}
		cell.setText(MessageFormat.format(messagePattern, values));
	}



and here is my code for add adapter at Contact
contact.eAdapters().add(new AdapterImpl() {
						public void notifyChanged(Notification msg) {
							contactsTable.refresh();
						};
					});



when i remove the adapter code, the table will not refresh or update the cell when there is a change at Contact - model..
is there a wrong code from above ?


Previous Topic:[CDO] Connect to hibernate store: FactoryNotFoundException
Next Topic:Persistence advice for Newbie
Goto Forum:
  


Current Time: Tue Apr 23 07:02:03 GMT 2024

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

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

Back to the top