Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Hide elements in [List]Viewer
Hide elements in [List]Viewer [message #431182] Wed, 01 July 2009 18:12 Go to next message
Waldi  is currently offline Waldi
Messages: 60
Registered: July 2009
Member
Hi,

My model:
Gruppe - Leiter - Person
1 - N 1 - 1

I have two ListViewers. There are view things from different resources.
On the left there is a complete list of Persons and on the right one is
the detail from a masterDetail scenario.

Now when I load the application new, all persons are viewed on the left
one. When I add a person to the detail view, the Person is removed from
the left viewer and added to the right. Thats all fine, but i would when
I start the application in the left one all persons are viewed in the
left one without there in the right on.

In my meaning i should implement a Filter, but i have problems with it,
can you help me there?

This are my inputs:
For my Detail ListViewer:
leiterAuswahl.setInput(EMFEditObservables.observeDetailList( Realm
.getDefault(), p.getEditingDomain(), viewerSelection,
ZlvpPackage.Literals.GRUPPEN__LEITER));

For my all Persons Viewer:
getPersons is a IObservableList.
leiter.setInput(p.getPersons());

it should be p.getPersons()-ZlvpPackage.Literals.GRUPPEN__LEITER) ;-)

Annother realy easy an short question:
I do this:
Command cmdRemove = RemoveCommand.create(p.getEditingDomain(), gruppe,
ZlvpPackage.Literals.GRUPPEN__LEITER, leiter);

if (cmdRemove.canExecute()) {
p.getEditingDomain().getCommandStack().execute(cmdRemove);
p.getResourcePerson().getContents().add(leiter.getPerson());
}else{
System.out.println("Hat ned geklappt");
}

It works fine but ithink it dirty. Is there another way to delete only a
reference? Only this: Command cmdRemove =
RemoveCommand.create(p.getEditingDomain(), gruppe,
ZlvpPackage.Literals.GRUPPEN__LEITER, leiter);

Deletes the Person and the Leiter...
Re: Hide elements in [List]Viewer [message #431185 is a reply to message #431182] Wed, 01 July 2009 19:11 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas Schindl
Messages: 5407
Registered: July 2009
Senior Member
Waldi Waldemar schrieb:
> Hi,
>
> My model:
> Gruppe - Leiter - Person
> 1 - N 1 - 1
>
> I have two ListViewers. There are view things from different resources.
> On the left there is a complete list of Persons and on the right one is
> the detail from a masterDetail scenario.
>
> Now when I load the application new, all persons are viewed on the left
> one. When I add a person to the detail view, the Person is removed from
> the left viewer and added to the right. Thats all fine, but i would when
> I start the application in the left one all persons are viewed in the
> left one without there in the right on.
>
> In my meaning i should implement a Filter, but i have problems with it,
> can you help me there?
>
> This are my inputs:
> For my Detail ListViewer:
> leiterAuswahl.setInput(EMFEditObservables.observeDetailList( Realm
> .getDefault(), p.getEditingDomain(),
> viewerSelection,
> ZlvpPackage.Literals.GRUPPEN__LEITER));
>

ViewerFilter?

> For my all Persons Viewer:
> getPersons is a IObservableList.
> leiter.setInput(p.getPersons());
>
> it should be p.getPersons()-ZlvpPackage.Literals.GRUPPEN__LEITER) ;-)
>
> Annother realy easy an short question:
> I do this:
> Command cmdRemove = RemoveCommand.create(p.getEditingDomain(), gruppe,
> ZlvpPackage.Literals.GRUPPEN__LEITER, leiter);
>
> if (cmdRemove.canExecute()) {
> p.getEditingDomain().getCommandStack().execute(cmdRemove);
> p.getResourcePerson().getContents().add(leiter.getPerson());
> }else{
> System.out.println("Hat ned geklappt");
> }
>
> It works fine but ithink it dirty. Is there another way to delete only a
> reference? Only this: Command cmdRemove =
> RemoveCommand.create(p.getEditingDomain(), gruppe,
> ZlvpPackage.Literals.GRUPPEN__LEITER, leiter);
>

I'm not sure I understand what you are asking.

Tom
Re: Hide elements in [List]Viewer [message #431187 is a reply to message #431185] Wed, 01 July 2009 19:25 Go to previous messageGo to next message
Waldi  is currently offline Waldi
Messages: 60
Registered: July 2009
Member
I mean a thing like this (if you had another way, i can use it):
Taken from the TeamAdmin example.

public class ViewFilterImpl extends ViewerFilter {
@Override
public boolean select(Viewer viewer, Object parentElement, Object
element)
{
if (element != null && element instanceof Person)
{
if(element is in the other ListViewer){
return false;
}
}
return true;
}
}


Explanation to your secound statement:
In the Database is save a association between the Leiter and the person.
I will delete the Leiter without the person. How can I do this better
than below.

Tom Schindl schrieb:
> Waldi Waldemar schrieb:
>> Hi,
>>
>> My model:
>> Gruppe - Leiter - Person
>> 1 - N 1 - 1
>>
>> I have two ListViewers. There are view things from different resources.
>> On the left there is a complete list of Persons and on the right one is
>> the detail from a masterDetail scenario.
>>
>> Now when I load the application new, all persons are viewed on the left
>> one. When I add a person to the detail view, the Person is removed from
>> the left viewer and added to the right. Thats all fine, but i would when
>> I start the application in the left one all persons are viewed in the
>> left one without there in the right on.
>>
>> In my meaning i should implement a Filter, but i have problems with it,
>> can you help me there?
>>
>> This are my inputs:
>> For my Detail ListViewer:
>> leiterAuswahl.setInput(EMFEditObservables.observeDetailList( Realm
>> .getDefault(), p.getEditingDomain(),
>> viewerSelection,
>> ZlvpPackage.Literals.GRUPPEN__LEITER));
>>
>
> ViewerFilter?
>
>> For my all Persons Viewer:
>> getPersons is a IObservableList.
>> leiter.setInput(p.getPersons());
>>
>> it should be p.getPersons()-ZlvpPackage.Literals.GRUPPEN__LEITER) ;-)
>>
>> Annother realy easy an short question:
>> I do this:
>> Command cmdRemove = RemoveCommand.create(p.getEditingDomain(), gruppe,
>> ZlvpPackage.Literals.GRUPPEN__LEITER, leiter);
>>
>> if (cmdRemove.canExecute()) {
>> p.getEditingDomain().getCommandStack().execute(cmdRemove);
>> p.getResourcePerson().getContents().add(leiter.getPerson());
>> }else{
>> System.out.println("Hat ned geklappt");
>> }
>>
>> It works fine but ithink it dirty. Is there another way to delete only a
>> reference? Only this: Command cmdRemove =
>> RemoveCommand.create(p.getEditingDomain(), gruppe,
>> ZlvpPackage.Literals.GRUPPEN__LEITER, leiter);
>>
>
> I'm not sure I understand what you are asking.
>
> Tom
Re: Hide elements in [List]Viewer [message #431188 is a reply to message #431185] Wed, 01 July 2009 19:26 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas Schindl
Messages: 5407
Registered: July 2009
Senior Member
[...]
>> Annother realy easy an short question:
>> I do this:
>> Command cmdRemove = RemoveCommand.create(p.getEditingDomain(), gruppe,
>> ZlvpPackage.Literals.GRUPPEN__LEITER, leiter);
>>
>> if (cmdRemove.canExecute()) {
>> p.getEditingDomain().getCommandStack().execute(cmdRemove);
>> p.getResourcePerson().getContents().add(leiter.getPerson());

Not going through the editing-domain with the add looks wrong!

Tom
Re: Hide elements in [List]Viewer [message #431190 is a reply to message #431188] Wed, 01 July 2009 19:34 Go to previous messageGo to next message
Waldi  is currently offline Waldi
Messages: 60
Registered: July 2009
Member
But it works fine, Teneo delete only the Leiter, not the Person.

I try this but it doesnt work
Command cmdAdd = AddCommand.create(p.getEditingDomain(), null,
ZlvpPackage.Literals.PERSON, leiter.getPerson());

Person has no owner...

Tom Schindl schrieb:
> [...]
>>> Annother realy easy an short question:
>>> I do this:
>>> Command cmdRemove = RemoveCommand.create(p.getEditingDomain(), gruppe,
>>> ZlvpPackage.Literals.GRUPPEN__LEITER, leiter);
>>>
>>> if (cmdRemove.canExecute()) {
>>> p.getEditingDomain().getCommandStack().execute(cmdRemove);
>>> p.getResourcePerson().getContents().add(leiter.getPerson());
>
> Not going through the editing-domain with the add looks wrong!
>
> Tom
Re: Hide elements in [List]Viewer [message #431191 is a reply to message #431190] Wed, 01 July 2009 19:47 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas Schindl
Messages: 5407
Registered: July 2009
Senior Member
Teneo doesn't care if you are going through the EditingDomain or not but
Undo/Redo does.

To execute a Command on the Resource you need to:

--------8<--------
AddCommand.create(
p.getEditingDomain(),
p.getResourcePerson().getContents(),
leiter.getPerson()
);
--------8<--------

Tom

Waldi Waldemar schrieb:
> But it works fine, Teneo delete only the Leiter, not the Person.
>
> I try this but it doesnt work
> Command cmdAdd = AddCommand.create(p.getEditingDomain(), null,
> ZlvpPackage.Literals.PERSON, leiter.getPerson());
>
> Person has no owner...
>
> Tom Schindl schrieb:
>> [...]
>>>> Annother realy easy an short question:
>>>> I do this:
>>>> Command cmdRemove = RemoveCommand.create(p.getEditingDomain(), gruppe,
>>>> ZlvpPackage.Literals.GRUPPEN__LEITER, leiter);
>>>>
>>>> if (cmdRemove.canExecute()) {
>>>> p.getEditingDomain().getCommandStack().execute(cmdRemove);
>>>>
>>>> p.getResourcePerson().getContents().add(leiter.getPerson());
>>
>> Not going through the editing-domain with the add looks wrong!
>>
>> Tom
Re: Hide elements in [List]Viewer [message #431192 is a reply to message #431191] Wed, 01 July 2009 20:02 Go to previous messageGo to next message
Waldi  is currently offline Waldi
Messages: 60
Registered: July 2009
Member
Your Snipped doesn't run. The
AddCommand.create(want,four,parameters,not) three

This Command cmdAdd =
AddCommand.create(p.getEditingDomain(),p.getResourcePerson() .getContents(),
ZlvpPackage.Literals.PERSON, leiter.getPerson());

doesn't run to

Tom Schindl schrieb:
> Teneo doesn't care if you are going through the EditingDomain or not but
> Undo/Redo does.
>
> To execute a Command on the Resource you need to:
>
> --------8<--------
> AddCommand.create(
> p.getEditingDomain(),
> p.getResourcePerson().getContents(),
> leiter.getPerson()
> );
> --------8<--------
>
> Tom
>
> Waldi Waldemar schrieb:
>> But it works fine, Teneo delete only the Leiter, not the Person.
>>
>> I try this but it doesnt work
>> Command cmdAdd = AddCommand.create(p.getEditingDomain(), null,
>> ZlvpPackage.Literals.PERSON, leiter.getPerson());
>>
>> Person has no owner...
>>
>> Tom Schindl schrieb:
>>> [...]
>>>>> Annother realy easy an short question:
>>>>> I do this:
>>>>> Command cmdRemove = RemoveCommand.create(p.getEditingDomain(), gruppe,
>>>>> ZlvpPackage.Literals.GRUPPEN__LEITER, leiter);
>>>>>
>>>>> if (cmdRemove.canExecute()) {
>>>>> p.getEditingDomain().getCommandStack().execute(cmdRemove);
>>>>>
>>>>> p.getResourcePerson().getContents().add(leiter.getPerson());
>>> Not going through the editing-domain with the add looks wrong!
>>>
>>> Tom
Re: Hide elements in [List]Viewer [message #431193 is a reply to message #431192] Wed, 01 July 2009 20:04 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas Schindl
Messages: 5407
Registered: July 2009
Senior Member
Sorry:
new AddCommand(....)

Tom

Waldi Waldemar schrieb:
> Your Snipped doesn't run. The
> AddCommand.create(want,four,parameters,not) three
>
> This Command cmdAdd =
> AddCommand.create(p.getEditingDomain(),p.getResourcePerson() .getContents(),
> ZlvpPackage.Literals.PERSON, leiter.getPerson());
>
> doesn't run to
>
> Tom Schindl schrieb:
>> Teneo doesn't care if you are going through the EditingDomain or not but
>> Undo/Redo does.
>>
>> To execute a Command on the Resource you need to:
>>
>> --------8<--------
>> AddCommand.create(
>> p.getEditingDomain(),
>> p.getResourcePerson().getContents(),
>> leiter.getPerson()
>> );
>> --------8<--------
>>
>> Tom
>>
>> Waldi Waldemar schrieb:
>>> But it works fine, Teneo delete only the Leiter, not the Person.
>>>
>>> I try this but it doesnt work
>>> Command cmdAdd = AddCommand.create(p.getEditingDomain(), null,
>>> ZlvpPackage.Literals.PERSON, leiter.getPerson());
>>>
>>> Person has no owner...
>>>
>>> Tom Schindl schrieb:
>>>> [...]
>>>>>> Annother realy easy an short question:
>>>>>> I do this:
>>>>>> Command cmdRemove = RemoveCommand.create(p.getEditingDomain(),
>>>>>> gruppe,
>>>>>> ZlvpPackage.Literals.GRUPPEN__LEITER, leiter);
>>>>>>
>>>>>> if (cmdRemove.canExecute()) {
>>>>>>
>>>>>> p.getEditingDomain().getCommandStack().execute(cmdRemove);
>>>>>>
>>>>>> p.getResourcePerson().getContents().add(leiter.getPerson());
>>>> Not going through the editing-domain with the add looks wrong!
>>>>
>>>> Tom
Re: Hide elements in [List]Viewer [message #431194 is a reply to message #431193] Wed, 01 July 2009 20:18 Go to previous messageGo to next message
Waldi  is currently offline Waldi
Messages: 60
Registered: July 2009
Member
Worked fine.

Have you a solution for my question above? I haven't a idea how to
implement the ViewerFilter. I try some things and play with it but no
success.

Tom Schindl schrieb:
> Sorry:
> new AddCommand(....)
>
> Tom
>
> Waldi Waldemar schrieb:
>> Your Snipped doesn't run. The
>> AddCommand.create(want,four,parameters,not) three
>>
>> This Command cmdAdd =
>> AddCommand.create(p.getEditingDomain(),p.getResourcePerson() .getContents(),
>> ZlvpPackage.Literals.PERSON, leiter.getPerson());
>>
>> doesn't run to
>>
>> Tom Schindl schrieb:
>>> Teneo doesn't care if you are going through the EditingDomain or not but
>>> Undo/Redo does.
>>>
>>> To execute a Command on the Resource you need to:
>>>
>>> --------8<--------
>>> AddCommand.create(
>>> p.getEditingDomain(),
>>> p.getResourcePerson().getContents(),
>>> leiter.getPerson()
>>> );
>>> --------8<--------
>>>
>>> Tom
>>>
>>> Waldi Waldemar schrieb:
>>>> But it works fine, Teneo delete only the Leiter, not the Person.
>>>>
>>>> I try this but it doesnt work
>>>> Command cmdAdd = AddCommand.create(p.getEditingDomain(), null,
>>>> ZlvpPackage.Literals.PERSON, leiter.getPerson());
>>>>
>>>> Person has no owner...
>>>>
>>>> Tom Schindl schrieb:
>>>>> [...]
>>>>>>> Annother realy easy an short question:
>>>>>>> I do this:
>>>>>>> Command cmdRemove = RemoveCommand.create(p.getEditingDomain(),
>>>>>>> gruppe,
>>>>>>> ZlvpPackage.Literals.GRUPPEN__LEITER, leiter);
>>>>>>>
>>>>>>> if (cmdRemove.canExecute()) {
>>>>>>>
>>>>>>> p.getEditingDomain().getCommandStack().execute(cmdRemove);
>>>>>>>
>>>>>>> p.getResourcePerson().getContents().add(leiter.getPerson());
>>>>> Not going through the editing-domain with the add looks wrong!
>>>>>
>>>>> Tom
Re: Hide elements in [List]Viewer [message #431195 is a reply to message #431194] Wed, 01 July 2009 20:53 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas Schindl
Messages: 5407
Registered: July 2009
Senior Member
Hi,

I don't get what the problem should be a simply check of the opposite
(right hand side) IObservableList.contains(o) should be enough to find
out if you want filter out or not.

Tom

Waldi Waldemar schrieb:
> Worked fine.
>
> Have you a solution for my question above? I haven't a idea how to
> implement the ViewerFilter. I try some things and play with it but no
> success.
>
> Tom Schindl schrieb:
>> Sorry:
>> new AddCommand(....)
>>
>> Tom
>>
>> Waldi Waldemar schrieb:
>>> Your Snipped doesn't run. The
>>> AddCommand.create(want,four,parameters,not) three
>>>
>>> This Command cmdAdd =
>>> AddCommand.create(p.getEditingDomain(),p.getResourcePerson() .getContents(),
>>>
>>> ZlvpPackage.Literals.PERSON, leiter.getPerson());
>>>
>>> doesn't run to
>>>
>>> Tom Schindl schrieb:
>>>> Teneo doesn't care if you are going through the EditingDomain or not
>>>> but
>>>> Undo/Redo does.
>>>>
>>>> To execute a Command on the Resource you need to:
>>>>
>>>> --------8<--------
>>>> AddCommand.create(
>>>> p.getEditingDomain(),
>>>> p.getResourcePerson().getContents(),
>>>> leiter.getPerson()
>>>> );
>>>> --------8<--------
>>>>
>>>> Tom
>>>>
>>>> Waldi Waldemar schrieb:
>>>>> But it works fine, Teneo delete only the Leiter, not the Person.
>>>>>
>>>>> I try this but it doesnt work
>>>>> Command cmdAdd = AddCommand.create(p.getEditingDomain(), null,
>>>>> ZlvpPackage.Literals.PERSON, leiter.getPerson());
>>>>>
>>>>> Person has no owner...
>>>>>
>>>>> Tom Schindl schrieb:
>>>>>> [...]
>>>>>>>> Annother realy easy an short question:
>>>>>>>> I do this:
>>>>>>>> Command cmdRemove = RemoveCommand.create(p.getEditingDomain(),
>>>>>>>> gruppe,
>>>>>>>> ZlvpPackage.Literals.GRUPPEN__LEITER, leiter);
>>>>>>>>
>>>>>>>> if (cmdRemove.canExecute()) {
>>>>>>>>
>>>>>>>> p.getEditingDomain().getCommandStack().execute(cmdRemove);
>>>>>>>>
>>>>>>>> p.getResourcePerson().getContents().add(leiter.getPerson());
>>>>>> Not going through the editing-domain with the add looks wrong!
>>>>>>
>>>>>> Tom
Re: Hide elements in [List]Viewer [message #431197 is a reply to message #431195] Thu, 02 July 2009 09:28 Go to previous message
Waldi  is currently offline Waldi
Messages: 60
Registered: July 2009
Member
Ok... I try it, no success:

Try:

IObservableList detailList = EMFEditObservables.observeDetailList(Realm
.getDefault(), p.getEditingDomain(), viewerSelection,
ZlvpPackage.Literals.GRUPPEN__LEITER);

Person personFromCompleteList = (Person)element;

if (detailList.contains(personFromCompleteList)) {
//never comes here ... because thats Leiter, no Persons
return false;
}
then i try this. Ok its a dirty way but see you another solution?
IObservableList detailList = EMFEditObservables.observeDetailList(Realm
.getDefault(), p.getEditingDomain(), viewerSelection,
ZlvpPackage.Literals.GRUPPEN__LEITER);

Person personFromCompleteList = (Person)element;
Iterator<?> iterator = detailList.iterator();

while(iterator.hasNext()){
Leiter tempLeiter = (Leiter) iterator.next();
Person tempPerson = tempLeiter.getPerson();

if (tempPerson.getId() == personFromCompleteList.getId()) {
return false;
}
}

Thanks for your help



"Tom Schindl" <tom.schindl@bestsolution.at> schrieb im Newsbeitrag
news:h2gibs$t1k$1@build.eclipse.org...
> Hi,
>
> I don't get what the problem should be a simply check of the opposite
> (right hand side) IObservableList.contains(o) should be enough to find
> out if you want filter out or not.
>
> Tom
>
> Waldi Waldemar schrieb:
>> Worked fine.
>>
>> Have you a solution for my question above? I haven't a idea how to
>> implement the ViewerFilter. I try some things and play with it but no
>> success.
>>
>> Tom Schindl schrieb:
>>> Sorry:
>>> new AddCommand(....)
>>>
>>> Tom
>>>
>>> Waldi Waldemar schrieb:
>>>> Your Snipped doesn't run. The
>>>> AddCommand.create(want,four,parameters,not) three
>>>>
>>>> This Command cmdAdd =
>>>> AddCommand.create(p.getEditingDomain(),p.getResourcePerson() .getContents(),
>>>>
>>>> ZlvpPackage.Literals.PERSON, leiter.getPerson());
>>>>
>>>> doesn't run to
>>>>
>>>> Tom Schindl schrieb:
>>>>> Teneo doesn't care if you are going through the EditingDomain or not
>>>>> but
>>>>> Undo/Redo does.
>>>>>
>>>>> To execute a Command on the Resource you need to:
>>>>>
>>>>> --------8<--------
>>>>> AddCommand.create(
>>>>> p.getEditingDomain(),
>>>>> p.getResourcePerson().getContents(),
>>>>> leiter.getPerson()
>>>>> );
>>>>> --------8<--------
>>>>>
>>>>> Tom
>>>>>
>>>>> Waldi Waldemar schrieb:
>>>>>> But it works fine, Teneo delete only the Leiter, not the Person.
>>>>>>
>>>>>> I try this but it doesnt work
>>>>>> Command cmdAdd = AddCommand.create(p.getEditingDomain(), null,
>>>>>> ZlvpPackage.Literals.PERSON, leiter.getPerson());
>>>>>>
>>>>>> Person has no owner...
>>>>>>
>>>>>> Tom Schindl schrieb:
>>>>>>> [...]
>>>>>>>>> Annother realy easy an short question:
>>>>>>>>> I do this:
>>>>>>>>> Command cmdRemove = RemoveCommand.create(p.getEditingDomain(),
>>>>>>>>> gruppe,
>>>>>>>>> ZlvpPackage.Literals.GRUPPEN__LEITER, leiter);
>>>>>>>>>
>>>>>>>>> if (cmdRemove.canExecute()) {
>>>>>>>>>
>>>>>>>>> p.getEditingDomain().getCommandStack().execute(cmdRemove);
>>>>>>>>>
>>>>>>>>> p.getResourcePerson().getContents().add(leiter.getPerson());
>>>>>>> Not going through the editing-domain with the add looks wrong!
>>>>>>>
>>>>>>> Tom
Previous Topic:Teneo 1.0.4/Teneo 1.1.1 Maintenance Builds, Hibernate version, xsd:any/xsd:anytype
Next Topic:Question about EFeatureMap
Goto Forum:
  


Current Time: Wed Oct 22 22:36:14 GMT 2014

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

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