Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Graphiti » Custom palette depending on diagram instance
Custom palette depending on diagram instance [message #1709056] Wed, 23 September 2015 15:37 Go to next message
Rafal Filipiuk is currently offline Rafal FilipiukFriend
Messages: 14
Registered: September 2015
Junior Member
Hi,

So I've been coding my implementation of my DiagramType using patterns, and I understand that the FeatureProvider is responsible for registering them (with addPattern()). What I need to be able to do is register patterns depending on the presence of some EObjects in my diagram instance's model file resource. For example, if an EObject of type Foo with name 'This is X' is present, I need to add a pattern as such: addPattern(new FooPattern('This is x')).

The main goal is so that when the user boots up the Diagram, the palette displays all instances of Foo as independent EClasses that, once the user creates them, will be serialized into instances of Bar.

To reiterate and clarify:

-Diagram resource (model file) has serialized instances of Foo.
-For every instance of Foo, a palette entry should exist
-Every palette entry creates instances of Bar, which are then serialized into our resource.

So essentially, I need to create patterns from an instance of a diagram, not from the diagram type. How would I do that? Is there anywhere I can regenerate the palette when opening a diagram file?

Thanks again for such prompt responses to questions.

Raf
Re: Custom palette depending on diagram instance [message #1709112 is a reply to message #1709056] Thu, 24 September 2015 07:21 Go to previous messageGo to next message
Michael Wenz is currently offline Michael WenzFriend
Messages: 1932
Registered: July 2009
Location: Walldorf, Germany
Senior Member
Rafal,

without really having tried this, this sounds as if your feature provider should dynamically provide only those create features that EOBjects foo exist in the diagram. When opening the diagram and adding or removing foo EOBjects the palette needs to be refreshed; to do that you can trigger GFPaletteRoot.updatePaletteEntries(). The palette root can be retrieved from the diagram editor.

HTH,
Michael
Re: Custom palette depending on diagram instance [message #1709197 is a reply to message #1709112] Thu, 24 September 2015 19:25 Go to previous messageGo to next message
Rafal Filipiuk is currently offline Rafal FilipiukFriend
Messages: 14
Registered: September 2015
Junior Member
From what method can I refer to the diagram editor to be able to add patterns from my model file's Foos? The palette needs to be updated right away when the user opens the diagram file.

From what I understand, when I open a diagram file, the diagramEditor is initialized (along with my featureProvider and its patterns), and then the diagram file is drawn. Is there a way to change the 'opening diagram file' behavior so I can deserialize its model file and add the missing patterns? I just don't know at what point I can refer to the diagram editor's diagram file..

[Updated on: Thu, 24 September 2015 21:10]

Report message to a moderator

Re: Custom palette depending on diagram instance [message #1709256 is a reply to message #1709197] Fri, 25 September 2015 11:35 Go to previous messageGo to next message
Michael Wenz is currently offline Michael WenzFriend
Messages: 1932
Registered: July 2009
Location: Walldorf, Germany
Senior Member
Rafal,

the editor is initialized and the diagram file is read within the DiagramEditor.init(...) method. When that method has finished you should be able to access the EMF model, extract the required entries and update the palette.

Michael
Re: Custom palette depending on diagram instance [message #1709270 is a reply to message #1709256] Fri, 25 September 2015 13:56 Go to previous message
Rafal Filipiuk is currently offline Rafal FilipiukFriend
Messages: 14
Registered: September 2015
Junior Member
Got it, thanks!

[Updated on: Fri, 25 September 2015 14:17]

Report message to a moderator

Previous Topic:Using Marquee Tool to select Connectors.
Next Topic:Saving only the domain model
Goto Forum:
  


Current Time: Sat Nov 09 02:08:06 GMT 2024

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

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

Back to the top