Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » GEF » Usage of GEF only in an eclipse view (no editor)
Usage of GEF only in an eclipse view (no editor) [message #212188] Mon, 20 March 2006 04:48 Go to next message
Eclipse UserFriend
Originally posted by: jojy.sv.gmail.com

Hello,



Recently I came across the GEF and its features.



I find that this is a framework for creating appealing editors.

Can any one of tell me how I can use GEF and draw2d in an eclipse View.



Because I just want to display some information in a view I don’t want to
edit information.



I might require only the Figures and may be edit parts I suppose.



Any sample code would be of great help



Thanks a lot

George
Re: Usage of GEF only in an eclipse view (no editor) [message #212205 is a reply to message #212188] Mon, 20 March 2006 06:20 Go to previous messageGo to next message
Andreas Schosser is currently offline Andreas SchosserFriend
Messages: 30
Registered: July 2009
Member
Hi Sebastian,

you have to initialize a (GEF) GraphicalViewer inside your view part.
You should add something like the following to your view part class:

private ScrollingGraphicalViewer m_viewer;

/*
* @see WorkbenchPart#createPartControl(Composite parent)
*/
public void createPartControl(Composite parent)
{
initializeGraphicalViewer();
getGraphicalViewer().createControl(parent);
getViewSite().setSelectionProvider(getGraphicalViewer());
getSite().setSelectionProvider(getGraphicalViewer());
}

public void initializeGraphicalViewer()
{
getGraphicalViewer().setRootEditPart(new ScalableFreeformRootEditPart());
// set YOUR (GEF) part factory
getGraphicalViewer().setEditPartFactory(new YourEditPartFactory());
//m_viewer.setEditDomain(new ViewPartEditDomain(this));
}

public ScrollingGraphicalViewer getGraphicalViewer()
{
if (m_viewer == null)
m_viewer = new ScrollingGraphicalViewer();
return m_viewer;
}

Kind regards,

--
A. Schosser
Mind8 GmbH

George Sebastian <jojy.sv@gmail.com> wrote:

> Hello,
>
> Recently I came across the GEF and its features.
>
> I find that this is a framework for creating appealing editors.
>
> Can any one of tell me how I can use GEF and draw2d in an eclipse View.
>
> Because I just want to display some information in a view I don’t want
> to edit information.
>
> I might require only the Figures and may be edit parts I suppose.
>
> Any sample code would be of great help Thanks a lot
>
> George
Re: Usage of GEF only in an eclipse view (no editor) [message #212212 is a reply to message #212205] Mon, 20 March 2006 06:31 Go to previous messageGo to next message
Andreas Schosser is currently offline Andreas SchosserFriend
Messages: 30
Registered: July 2009
Member
And of course, you have to set the viewer's contents (the model's root
element, usually the so called 'Diagram') either.
In my example I got a getDiagram() method (inside my view part) for this
purpose:

Diagram m_diagram;

public Diagram getDiagram()
{
if(m_diagram == null)
{
m_diagram = new Diagram();
getGraphicalViewer().setContents(m_diagram);
}
}


--
A. Schosser
Mind8 GmbH
Re: Usage of GEF only in an eclipse view (no editor) [message #212219 is a reply to message #212212] Mon, 20 March 2006 09:00 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: jojy.sv.gmail.com

Hi Schosser,

I have done the same thing but the eclipse is opening up a view
but not displaying any figure in it

Thanks for you help It has been really great

Let me try to resolve or narrow down the issues

-Regards
George S
Re: Usage of GEF only in an eclipse view (no editor) [message #212242 is a reply to message #212219] Mon, 20 March 2006 11:16 Go to previous messageGo to next message
Andreas Schosser is currently offline Andreas SchosserFriend
Messages: 30
Registered: July 2009
Member
Hi,

you have to add a few figure children to your top-level (Diagram) model
element.
I do this by calling create commands, but adding child model elements to
the top-level element should work either.

Regards,

Andreas

P.S.: sorry for mixing up first and last name

George Sebastian <jojy.sv@gmail.com> wrote:

> Hi Schosser,
>
> I have done the same thing but the eclipse is opening up a view but not
> displaying any figure in it
>
> Thanks for you help It has been really great Let me try to resolve or
> narrow down the issues
>
> -Regards
> George S
>
Re: Usage of GEF only in an eclipse view (no editor) [message #212294 is a reply to message #212242] Tue, 21 March 2006 06:59 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: jojy.sv.gmail.com

Hi Schosser

From the documentation I understand I need to override these three methods
in my Editparts

protected List getModelSourceConnections ()

protected List getModelChildren ()

and public List getSourceConnections ()

But I am not so sure what is supposed to be done in each of them.

Let me explain my requirement in detail.


I have a Data Structure which holds different other data structures with
in it.
I just used the same data structures as the model objects.

And I just need to display state of (instance values) these data
structures in an eclipse view in a hierarchial way.

So I hope I need to created do make some connection parts as well to show
the the links between the data structures.

But since I am using my existing data structure as the model I am not sure
how I can add this connection model or connectioneditpart to my diagram
at run time.

Please help me on this

Thanks a lot
Regards
George Sebastian
Re: Usage of GEF only in an eclipse view (no editor) [message #212302 is a reply to message #212294] Tue, 21 March 2006 08:00 Go to previous messageGo to next message
Andreas Schosser is currently offline Andreas SchosserFriend
Messages: 30
Registered: July 2009
Member
Alright, let's go through your questions.

> From the documentation I understand I need to override these three
> methods in my Editparts

First of all you should derive your EditPart classes from the
AbstractGraphicalEditPart (derived from AbstractEditPart), which already
holds defintions of these methods. The methods have to be overwritten for
certain purposes as I will try to describe below.

> protected List getModelChildren ()

This method has to be explicitly (re)defined for all parent model
elements, in particular the top-level model element (Diagram or Graph).
After passing the top-level model element to the viewer (done by
GraphicalViewer#setContents), the EditPartFactory will utilize the so
defined child model element List to create the EditParts for each child
model element.
This assumes that a parent model element has to contain a List of the
child model elements (that have to be known to the EditPartFactory method
createEditPart). This model list has to be returned by the parent's
EditPart#getModelChildren, e.g.:

protected List getModelChildren()
{
// get children list of top-level model element
return getDiagram().getChildren();
}

> protected List getModelSourceConnections ()
> and public List getSourceConnections ()

Theses methods are associated with (Draw2D) Nodes respectively with their
EditParts. The EditPart method getModelSourceConnections usually calls the
model element's getSourceConnection method. Remember, the EditPart is the
controller class dispatching changes at the model respectively at the
editor (view). Maybe you should have a look at the shapes example again.
They give a good impression of the architecturally desing mechanism.

> But since I am using my existing data structure as the model I am not
> sure how I can add this connection model or connectioneditpart to my
> diagram at run time.

There are two recent GEF tutorials from Santa Clara online, that could be
relevant to you:
http://eclipsezilla.eclipsecon.org/php/attachment.php?bugid= 52 - by Randy
Hudson
http://eclipsezilla.eclipsecon.org/php/attachment.php?bugid= 71 - by Koen
Aers

Regards,

Andreas

--
A. Schosser
Mind8 GmbH
Re: Usage of GEF only in an eclipse view (no editor) [message #212441 is a reply to message #212302] Wed, 22 March 2006 15:17 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: jojy.sv.gmail.com

Hi,

The tutorials were really good
I a got many of the issues resolved by you comments

But not complete I am working on them
Thanks
George S
Re: Usage of GEF only in an eclipse view (no editor) [message #213512 is a reply to message #212205] Thu, 06 April 2006 16:57 Go to previous message
Eclipse UserFriend
Originally posted by: ben.vitale.precipia.com

Hi,

I'm trying to accomplish the same task: a GEF-based editor inside an
Eclipse view. The code below is quite helpful, but I'm wondering what
my view part class should be extending/implementing. Currently it's:

public class ScenarioBuilderView extends ViewPart

But it's complaining about getGraphicalViewer() and others not being
present in the ViewPart interface. Do I need to implement another class
as well? What is the relationship between ViewPart and
org.eclipse.gef.GraphicalViewer?

Thanks
Ben

A. Schosser wrote:
> Hi Sebastian,
>
> you have to initialize a (GEF) GraphicalViewer inside your view part.
> You should add something like the following to your view part class:
>
> private ScrollingGraphicalViewer m_viewer;
>
> /*
> * @see WorkbenchPart#createPartControl(Composite parent)
> */
> public void createPartControl(Composite parent)
> {
> initializeGraphicalViewer();
> getGraphicalViewer().createControl(parent);
> getViewSite().setSelectionProvider(getGraphicalViewer());
> getSite().setSelectionProvider(getGraphicalViewer());
> }
>
> public void initializeGraphicalViewer()
> {
> getGraphicalViewer().setRootEditPart(new
> ScalableFreeformRootEditPart());
> // set YOUR (GEF) part factory
> getGraphicalViewer().setEditPartFactory(new YourEditPartFactory());
> //m_viewer.setEditDomain(new ViewPartEditDomain(this));
> }
>
> public ScrollingGraphicalViewer getGraphicalViewer()
> {
> if (m_viewer == null)
> m_viewer = new ScrollingGraphicalViewer();
> return m_viewer;
> }
>
> Kind regards,
>
> --A. Schosser
> Mind8 GmbH
>
> George Sebastian <jojy.sv@gmail.com> wrote:
>
>> Hello,
>>
>> Recently I came across the GEF and its features.
>>
>> I find that this is a framework for creating appealing editors.
>>
>> Can any one of tell me how I can use GEF and draw2d in an eclipse View.
>>
>> Because I just want to display some information in a view I don�t
>> want to edit information.
>>
>> I might require only the Figures and may be edit parts I suppose.
>>
>> Any sample code would be of great help Thanks a lot
>>
>> George
Previous Topic:Newbie alert - Getting started in GEF for an RCP application?
Next Topic:StandAlone gef: gef outside a plug-in.
Goto Forum:
  


Current Time: Sat Apr 20 02:04:07 GMT 2024

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

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

Back to the top