Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » GEF » Creating parts
Creating parts [message #1731756] Mon, 09 May 2016 22:15 Go to next message
Colin Sharples is currently offline Colin SharplesFriend
Messages: 90
Registered: July 2009
Location: Wellington, New Zealand
Member

As I am using the Logo example to work out how to use GEF4, I get a bit stumped when I have a requirement that's not covered by the example. I have a couple of issues around creating parts that I could use some help with.

1. Using a palette to create parts - my model has around 40 different part types, so the cycling object creation menu in the example really isn't going to work for me. The parts are grouped in categories, so I guess at least my context menu could contain two toolbars, with categories in the top, and the parts available in the selected category in the bottom. However, I'd really prefer to have a separate palette in a splitpane beside the main viewer. I gather there was a request to create an example of a palette viewer - has this got anywhere? If not, where do I start? The thing I am not clear about is how you would change what the creation tool/policy would be doing when you select an item in the palette, given that tools seem to be very different in GEF4.

2. Most of my parts do not have a "default" shape, so it doesn't really make sense to have a click-to-drop-and-create style policy. For example, several shapes are based on Polyline, so what I really want is for the user to click to start creating, then click at intermediate points to build up the line, and then some gesture (e.g. double-click or ctrl+click) to indicate completion. The object would only actually get created and added to the model upon completion, so the visual would only be a feedback part during the drawing phase. This was pretty straightforward in GEF3 - just had a tool that extended TargetingTool, kept track of the state and executed the create command when it received the completion gesture. I'm really struggling to see what the equivalent in GEF4 would be.


Colin Sharples
CTG Games Ltd
Wellington, New Zealand
Re: Creating parts [message #1731795 is a reply to message #1731756] Tue, 10 May 2016 09:01 Go to previous messageGo to next message
Alexander Nyssen is currently offline Alexander NyssenFriend
Messages: 235
Registered: July 2009
Location: Lünen
Senior Member
Hi Colin,

1. We have started to work on https://bugs.eclipse.org/bugs/show_bug.cgi?id=481677 (palette integration in MVC logo example) already (I have enhanced the adapter injection mechanism so we can bind different adapters for content and palette viewer each, which BTW causes the warnings you have reported in your other post). We hope to complete this by this week (Thursday or Friday), so we have a working demonstrator for RC1 that you could use for guidance.

2. The functionality is comparable within GEF4, only that tools are rather trivial in GEF4 and your logic would have to go into respective interaction (and related transaction) policies. As interaction policies (which are called by tools) are based on interfaces, a specific policy can handle several interaction gestures simultaneously (if you e.g. need to react to mouse clicks and key type events within a single interaction). The model manipulation would have to be performed by a transaction policy (encapsulated in a transactional operation) and should only be executed when committing a transaction, not during the interaction (locally execute). All visual manipulations that are performed during the interaction need to be encapsulated into respective operations as well, which are locally executed during the interaction. Here, locally means that the operation history is not affected by the operation.

Regards
Alexander
Re: Creating parts [message #1732223 is a reply to message #1731795] Fri, 13 May 2016 14:07 Go to previous messageGo to next message
Alexander Nyssen is currently offline Alexander NyssenFriend
Messages: 235
Registered: July 2009
Location: Lünen
Senior Member
The palette integration for the MVC logo example has been finalized today and will be included in the Neon RC1 promotion.
Re: Creating parts [message #1732253 is a reply to message #1732223] Fri, 13 May 2016 23:48 Go to previous messageGo to next message
Colin Sharples is currently offline Colin SharplesFriend
Messages: 90
Registered: July 2009
Location: Wellington, New Zealand
Member

Cool, I picked up the palette example this morning. Looks pretty good. In my case, I would prefer to have an always open palette, so I would probably have the editor in a BorderPane with the palette in the left slot and the content viewer in the center. I had a quick try of that layout in the example, but it didn't quite work - it looks like the drag gesture doesn't carry over between the two FXViewers, so the part immediately gets dropped on the canvas at the place where the mouse crosses over between the two viewers.

In any case, as I said above, I probably wouldn't want to drag from the palette anyway, it's more that the items in the palette would act as buttons that switch the content viewer into create mode, I guess by activating a particular interaction policy. How do I tell the content viewer to activate policy X?


Colin Sharples
CTG Games Ltd
Wellington, New Zealand
Re: Creating parts [message #1732288 is a reply to message #1732253] Sat, 14 May 2016 20:22 Go to previous messageGo to next message
Colin Sharples is currently offline Colin SharplesFriend
Messages: 90
Registered: July 2009
Location: Wellington, New Zealand
Member

I think I mostly worked it out. In the end I didn't even use an FXViewer for the palette, just regular JavaFX components. I wanted an accordion layout to organize the buttons into categories, and it seemed easier just to manually construct that. I use my content part factory to create graphics for the button based on the model objects, and the button then just looks up the appropriate creation policy from the root part of the content viewer, and sets it into create mode. No doubt there is a way to do it in a more purist GEF4 style, but what I have works for me.

Colin Sharples
CTG Games Ltd
Wellington, New Zealand
Re: Creating parts [message #1732423 is a reply to message #1732288] Tue, 17 May 2016 07:57 Go to previous message
Matthias Wienand is currently offline Matthias WienandFriend
Messages: 163
Registered: March 2015
Senior Member
That sounds just fine. However, the drag policy being interrupted is due to the CreationPolicy executing a ChangeFocusOperation to assign focus to the newly created part, which will in turn take focus from the palette viewer, which will then abort the currently running drag policy. Therefore, for a separate viewer setup you would need to exchange the CreationPolicy. For example, the method CreationPolicy#createFocusOperation() could be overridden to return null.

Best regards,
Matthias
Previous Topic:Warnings about
Next Topic:[GEF4] Rotation using wrong angle
Goto Forum:
  


Current Time: Mon Nov 19 11:05:23 GMT 2018

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

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

Back to the top