Home » Modeling » EMF » [EMF] EMF Databinding to Tableviewer
[EMF] EMF Databinding to Tableviewer [message #522445] |
Mon, 22 March 2010 16:30 |
|
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
http://cana.web.id
|
|
|
Re: [EMF] EMF Databinding to Tableviewer [message #522511 is a reply to message #522445] |
Mon, 22 March 2010 20:42 |
Ed Merks 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 #523684 is a reply to message #523592] |
Sun, 28 March 2010 16:52 |
|
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
i will learn it more and always read your blog for guide me
http://cana.web.id
|
|
|
Re: [EMF] EMF Databinding to Tableviewer [message #523685 is a reply to message #523593] |
Sun, 28 March 2010 16:59 |
|
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 ?
http://cana.web.id
|
|
|
Goto Forum:
Current Time: Tue Apr 23 07:02:03 GMT 2024
Powered by FUDForum. Page generated in 0.04604 seconds
|