Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » GEF » Custom view and ... ??
Custom view and ... ?? [message #198503] Wed, 12 October 2005 12:02 Go to next message
Eclipse UserFriend
Originally posted by: greg.gigon.tugulu.com

This is more Eclipse not GEF problem, but maybe some of you guys have
faced this kind of issue.

I've created a custom view for my Graphical Plugin Editor in Eclipse.
Then I've added a my Custom Viwer to it. It creates a form using SWT for
element properties. Using SelectionListener nicely it hookes in
GraphicalEditor and getProperties from element and display this in a
View. My problem is ... how to make it work other way around??????
When I type new things in my Form Text Boxes HOW TO REFLECT CHANGES IN A
MODEL.

Is there some kind of a mechanizm for that?

Cheers, Greg
Re: Custom view and ... ?? [message #198770 is a reply to message #198503] Wed, 12 October 2005 17:16 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: mvsteenbergen.eljakim.scratch-this.nl

Greg wrote:
> I've created a custom view for my Graphical Plugin Editor in Eclipse.
> Then I've added a my Custom Viwer to it. It creates a form using SWT for
> element properties. Using SelectionListener nicely it hookes in
> GraphicalEditor and getProperties from element and display this in a
> View. My problem is ... how to make it work other way around??????
> When I type new things in my Form Text Boxes HOW TO REFLECT CHANGES IN A
> MODEL.

Well, you just change your model (model.setXxx(), or whatever kind of
model you're using). If you're doing it the preferred way, your model
has a notification mechanism so the GraphicalEditor will notice the
model's changes and update its appearance. It's really very specific to
your model. Take a look at the Model-View-Controller design pattern if
this doesn't make much sense to you.

Good luck,

Martijn.
Re: Custom view and ... ?? [message #198869 is a reply to message #198770] Thu, 13 October 2005 08:13 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: greg.gigon.tugulu.com

That's the whole problem. You can't have direct reference to a model in
View. When element in Editor was selected SelectionListener call
selectionChange() in View object. Then using a IAdaptable (EditPart
implements IAdaptable) i retrive data from EditPart as an Object of
IMyProperties. Then I'm passing this object to the Viewer and I have
this data displeyed in a View.
How to do this other way around, how to set data??

Cheers, Greg




Martijn van Steenbergen wrote:
> Greg wrote:
>
>> I've created a custom view for my Graphical Plugin Editor in Eclipse.
>> Then I've added a my Custom Viwer to it. It creates a form using SWT
>> for element properties. Using SelectionListener nicely it hookes in
>> GraphicalEditor and getProperties from element and display this in a
>> View. My problem is ... how to make it work other way around??????
>> When I type new things in my Form Text Boxes HOW TO REFLECT CHANGES IN
>> A MODEL.
>
>
> Well, you just change your model (model.setXxx(), or whatever kind of
> model you're using). If you're doing it the preferred way, your model
> has a notification mechanism so the GraphicalEditor will notice the
> model's changes and update its appearance. It's really very specific to
> your model. Take a look at the Model-View-Controller design pattern if
> this doesn't make much sense to you.
>
> Good luck,
>
> Martijn.
Re: Custom view and ... ?? [message #198900 is a reply to message #198869] Thu, 13 October 2005 11:56 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: mvsteenbergen.eljakim.scratch-this.nl

I'm afraid I don't know what you mean. Perhaps someone else has a clue?

M.

Greg wrote:
> That's the whole problem. You can't have direct reference to a model in
> View. When element in Editor was selected SelectionListener call
> selectionChange() in View object. Then using a IAdaptable (EditPart
> implements IAdaptable) i retrive data from EditPart as an Object of
> IMyProperties. Then I'm passing this object to the Viewer and I have
> this data displeyed in a View.
> How to do this other way around, how to set data??
Re: Custom view and ... ?? [message #198971 is a reply to message #198900] Thu, 13 October 2005 16:10 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: greg.gigon.tugulu.com

Thank's Martijn for afford.
I just figured it out :)

Greg

Martijn van Steenbergen wrote:
> I'm afraid I don't know what you mean. Perhaps someone else has a clue?
>
> M.
>
> Greg wrote:
>
>> That's the whole problem. You can't have direct reference to a model
>> in View. When element in Editor was selected SelectionListener call
>> selectionChange() in View object. Then using a IAdaptable (EditPart
>> implements IAdaptable) i retrive data from EditPart as an Object of
>> IMyProperties. Then I'm passing this object to the Viewer and I have
>> this data displeyed in a View.
>> How to do this other way around, how to set data??
Re: Custom view and ... ?? [message #198986 is a reply to message #198971] Thu, 13 October 2005 16:32 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: mvsteenbergen.eljakim.scratch-this.nl

Care to share? :)

Greg wrote:
> Thank's Martijn for afford.
> I just figured it out :)
Re: Custom view and ... ?? [message #199008 is a reply to message #198986] Thu, 13 October 2005 16:48 Go to previous message
Eclipse UserFriend
Originally posted by: greg.gigon.tugulu.com

Well, no probs, maybe U can answer my D&D question then :)


When I select element on my Editor selectionChanged() is called in View.
This method is called because I've registered selection listener for my
Custom View. Now I need data from selected object. Because I can't get
data directly I'm using IAdaptable to do that. My EditPart implements
IAdapatble and method getAdapter().



public Object getAdapter(Class adapter)
{
if (adapter.equals(IGeneralProperties.class))
{
element = ((CallflowElement) getModel());

return new GeneralProperties();
}
else
return null;
}


MyEditPart{ ...
private CallflowElement element = (CallflowElement) getModel();
private class GeneralProperties implements IGeneralProperties
{
//private CallflowElement element;


public void setName(String name)
{
element.setName(name);
}

...

public String getName()
{
return element.getName();
}

....
}

....
}

I'm pasing object of GeneralProperties to a View, and it has
implementation of getProp and setProp methods.

protected void pageSelectionChanged(IWorkbenchPart part,
ISelection selection)
{
StructuredSelection sel = (StructuredSelection) selection;

if (sel.getFirstElement() instanceof IAdaptable)
{
if (sel.getFirstElement() instanceof CallflowEditPart)
{
IGeneralProperties prop = (IGeneralProperties)
((IAdaptable) sel

..getFirstElement()).getAdapter(IGeneralProperties.class);
_viewer.setGeneralProperties(prop);
}
}
}

So in Viewer when somethings changed I can update Model properties.
That's it:)


Greg

Martijn van Steenbergen wrote:
> Care to share? :)
>
> Greg wrote:
>
>> Thank's Martijn for afford.
>> I just figured it out :)
Previous Topic:combine two gef plugins via drag&drop
Next Topic:Drag & Drop in GEF
Goto Forum:
  


Current Time: Fri Apr 19 20:15:38 GMT 2024

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

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

Back to the top