Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » GEF » Editor for composed shapes with double-click
Editor for composed shapes with double-click [message #247081] Sun, 01 February 2009 11:11 Go to next message
Eclipse User
Originally posted by: timo.rohrberg.gmx.net

Hello everybody!

I am sure that my problem - or at least a similar one - has already been
discussed here in the past. Unfortunately, I wasn't able to find a
working solution for it by reading the newsgroup archive and therefore
decided to ask (again):

I need to create a graphical editor with GEF which enables the user to
draw composed shapes (like the logic container in the logic diagram
example). But the containers should only be displayed without other
shapes inside. When the user double clicks on one of them, a new editor
page should open where the content of the container can be edited. This
recursion should be able to continue indefinitely which means a
container can contain containers and so on ...

I tried to implement this with the performRequest() method of the
editparts but haven't been successful in opening a new editor page. In
addtion, I don't want to create a new file for each editor page but
display only a part of my model contained in one single file.

Unfortunately, I am very new to GEF but need to implement this as
quickly and as easy as possible for a study project.

Is there anyone who can maybe help me out a little bit?

I appreciate any response!

Thank you

Timo Rohrberg

--
Timo Rohrberg <timo.rohrberg@gmx.net>

"Brick walls let us show our dedication. They are there to separate
us from the people who don't really want to achieve their childhood
dreams." (Randy Pausch, computer science professor at CMU)
Re: Editor for composed shapes with double-click [message #247086 is a reply to message #247081] Mon, 02 February 2009 06:42 Go to previous messageGo to next message
Eclipse User
Originally posted by: lifesting.gmail.com

Timo Rohrberg wrote:
> Hello everybody!
>
> I am sure that my problem - or at least a similar one - has already been
> discussed here in the past. Unfortunately, I wasn't able to find a
> working solution for it by reading the newsgroup archive and therefore
> decided to ask (again):
>
> I need to create a graphical editor with GEF which enables the user to
> draw composed shapes (like the logic container in the logic diagram
> example). But the containers should only be displayed without other
> shapes inside. When the user double clicks on one of them, a new editor
> page should open where the content of the container can be edited. This
> recursion should be able to continue indefinitely which means a
> container can contain containers and so on ...
>
> I tried to implement this with the performRequest() method of the
> editparts but haven't been successful in opening a new editor page. In
> addtion, I don't want to create a new file for each editor page but
> display only a part of my model contained in one single file.
>
> Unfortunately, I am very new to GEF but need to implement this as
> quickly and as easy as possible for a study project.
>
> Is there anyone who can maybe help me out a little bit?
>
> I appreciate any response!
>
> Thank you
>
> Timo Rohrberg
>
Hi, Timo, I guested GMF Partitioning (First Type) meets your need. GMF
make it very easy exceed your imagination.

Resource:

http://wiki.eclipse.org/Diagram_Partitioning

www.jevon.org/wiki/GMF_Diagram_Partitioning

You can also search GMF newsgroup using "partitioning" as keyword, there
are a lot of discussion about this function.
Re: Editor for composed shapes with double-click [message #247101 is a reply to message #247086] Tue, 03 February 2009 09:14 Go to previous messageGo to next message
Eclipse User
Originally posted by: timo.rohrberg.gmx.net

Hello David,

thank you very much for your answer. I checked the links you sent me,
but unfortunately, I still don't understand how to do it.

I don't use GMF, but GEF only. I would just like to open a new instance
of my editor on the REQ_OPEN event fired on the composed shapes. I
already tried to implement that with the openEditor() method of the
ActivePage() but so far, it didn't work.

I found a discussion on how to do it in this newsgroup but even with the
explanations there, it doesn't work for me.

Can you - or anyone else - maybe help me out a little more? Some tips
how to do it, which documentations to read about that issue?

Thank you very much in advance!

Timo Rohrberg
--
Timo Rohrberg <timo.rohrberg@gmx.net>

"Brick walls let us show our dedication. They are there to separate
us from the people who don't really want to achieve their childhood
dreams." (Randy Pausch, computer science professor at CMU)
Re: Editor for composed shapes with double-click [message #247115 is a reply to message #247101] Wed, 04 February 2009 02:28 Go to previous messageGo to next message
Eclipse User
Originally posted by: lifesting.gmail.com

Timo Rohrberg wrote:
> Hello David,
>
> thank you very much for your answer. I checked the links you sent me,
> but unfortunately, I still don't understand how to do it.
>
> I don't use GMF, but GEF only. I would just like to open a new instance
> of my editor on the REQ_OPEN event fired on the composed shapes. I
> already tried to implement that with the openEditor() method of the
> ActivePage() but so far, it didn't work.
>
> I found a discussion on how to do it in this newsgroup but even with the
> explanations there, it doesn't work for me.
>
> Can you - or anyone else - maybe help me out a little more? Some tips
> how to do it, which documentations to read about that issue?
>
> Thank you very much in advance!
>
> Timo Rohrberg
It's simple if you write pure GEF code, the key is to implement an
IEditorInput that support MODEL PARTITION. for example, if you define a
recursive model: Container : (Container | Component)+ and a model
instance was serialized in XML as below:

<container id="-1"> //ROOT used to be Diagram
<component>
</cmponent>
<container id="1"> //Partition
<component>
......
</component>
</container>
</container>

In this scenario, you can implement an IEditorInput which at least
requires two paramenter, one is XML file Path(e.g: c:/a/b/foobar), the
other is ID uniquely presented in XML.

You'd best implement two type Container EditParts in your GEF
application, one is DiagramEditPart used to be Diagram Editing, the
other is NodeEditPart to be Node in Diagram.

Assumed that you named the second container part ContainerNodeEditPart,
an editpolicy need be installed on it to Open Partition.

for example:

ContainerNodeEditPart part = getSelectedEditPart();

int id = part.getUniqueId();

URI resource = getEditingResourcePath();

IEditorInput ei = new PartitionEditorInput(resource, id);

String editor_id = "your gef editor id";

PlatformUI.getWorkbench() .getActiveWorkbenchWindow().
getActivePage().openEditor(ei, editor_id);

Hope this help you!
Re: Editor for composed shapes with double-click [message #247319 is a reply to message #247115] Mon, 16 February 2009 14:37 Go to previous messageGo to next message
Eclipse User
Originally posted by: timo.rohrberg.gmx.net

Hello David,

first of all thank you for your detailed answer to my question and sorry
that I answer that late. I've been busy with different issues the past
weeks.

Now, I tried to get the thing with an IEditorInput supporting model
partition working, but unfortunately, I don't understand how to
integrate that into my Eclipse editor plug-in.

To be honest, I am new to GEF and started by copy-&-pasting from the
Shape Diagram Example included in the GEF documentation. In the
meantime, I understood how the model, editparts, etc. work. But the
high-level editor things are still mystery for me...

My main editor class is a subclass of GraphicalEditorWithFlyoutPalette
as in the Shape Diagram Example. And there is some logic for persisting
the model, but I don't understand how to implement an own IEditorInput
there...

Do you know of any documentation or - even better an example - how to do
that?

At the moment, I don't know how to start with...

Thank you for any hints!

Timo Rohrberg

--
Timo Rohrberg <timo.rohrberg@gmx.net>

"Brick walls let us show our dedication. They are there to separate
us from the people who don't really want to achieve their childhood
dreams." (Randy Pausch, computer science professor at CMU)
Re: Editor for composed shapes with double-click [message #247335 is a reply to message #247319] Tue, 17 February 2009 20:03 Go to previous message
Eclipse User
Originally posted by: thomas.cranksoftware.com

Timo Rohrberg wrote:
> Hello David,
>
> first of all thank you for your detailed answer to my question and sorry
> that I answer that late. I've been busy with different issues the past
> weeks.
>
> Now, I tried to get the thing with an IEditorInput supporting model
> partition working, but unfortunately, I don't understand how to
> integrate that into my Eclipse editor plug-in.

In your editor, in the init routine, you can check the input against
its type. For example, I have a custom editor input I create which
is a ScreenEditorInput (see below) and I also take a standard file
input:

public void init(IEditorSite site, IEditorInput input)
throws PartInitException {
if(input instanceof ScreenEditorInput) {
/* My custom input class operations ... */
} else {
IFile file = (IFile)input.getAdapter(IFile.class);
/* Derive content from file if it exists */
}

> To be honest, I am new to GEF and started by copy-&-pasting from the
> Shape Diagram Example included in the GEF documentation. In the
> meantime, I understood how the model, editparts, etc. work. But the
> high-level editor things are still mystery for me...

These are more Eclipse pieces than GEF pieces.

> My main editor class is a subclass of GraphicalEditorWithFlyoutPalette
> as in the Shape Diagram Example. And there is some logic for persisting
> the model, but I don't understand how to implement an own IEditorInput
> there...

In the code where I want to invoke the 'sub editor' I would invoke it as:
IWorkbenchWindow window;
window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();

ScreenEditorInput input;
input = new ScreenEditorInput(fFilePath, fModel, fScreenEditPart.getModel());

String id = "<your_editor_id_here>";
try {
window.getActivePage().openEditor(input, id);
} catch(Exception ex) {
/* Ignore */
}

The "ScreenEditorInput" is just an object that contains a reference to my
existing model and implements an IEditorInput class:

public class ScreenEditorInput implements IEditorInput {
... your implementation here ...
}

Hope this helps,
Thomas
---
Embedded Graphical Development
http://www.cranksoftware.com
Previous Topic:how to draw a menubar
Next Topic:[Announce] GEF 3.4.2 is available
Goto Forum:
  


Current Time: Thu Oct 23 15:24:22 GMT 2014

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

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