Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Graphiti » Variation of Drill-Down Feature
Variation of Drill-Down Feature [message #1198476] Wed, 20 November 2013 05:41 Go to next message
Roman H is currently offline Roman H
Messages: 2
Registered: November 2013
Junior Member
Hi everyone,

I am using Graphiti now for about a month and it works great.

What I would like to realize at the moment is the following:
I would like to have an object that can be inserted in the diagram - that`s fine.
This object should have a custom drill-down feature, which makes it possible to open an associated diagram when the feature is called. The diagram should be created and linked with the PictogramElement when it is inserted in the diagram.

What I have done so far:
- I have got a create feature, which instanciates a BO
- an add feature, which specifies a rectangle, text and so on. At the end of the add feature I create a new diagram and link it with my BO:
final Diagram diagram = Graphiti.getCreateService().createDiagram(DiagramTypeProvider.DIAGRAM_TYPE_ID, filename, true);

addedClass.eResource().getContents().add(diagram);

link(diagram, addedClass);

link(containerShape, addedClass);

- The drill-down works with the implementation of the AbstractDrillDownFeature. I just changed the getDiagram()-method of my drill-down implementation:
protected Collection<Diagram> getDiagrams() {
Resource resource = getDiagram().eResource();
       
// does resource contain a diagram as root object?
final EList<EObject> contents = resource.getContents();
List<Diagram> diagramCollection = new ArrayList<Diagram>();
       
for (final EObject object : contents) {
     if (object instanceof Diagram) {
           diagramCollection.add((Diagram) object);
     }
}
      
return diagramCollection;
}


My problem is the following: As long as I did not save the diagram which contains the newly created PictogramElement (the BO of this is linked to another diagram) at least once, I can not use the Drill-Down feature. Graphiti then opens a new diagram tab, but there is only the string "No Diagram found for URI 'platform:/resource/Graphiti_Bsp/src/diagrams/newDiagram.diagram#/3" displayed.

I debugged the project. The canExecute-method returns true (otherwise no tab would be opened), so the newly created diagram is "found".

No exception is thrown while the canExecute/ execute methods are executed.

So now my question: Do you have an idea, why I have to save the diagram first before I can display it? What may I have to change such that I can open the linked diagram, even if the diagram was not saved before?

If you need more information to be able to answer my question, please just tell me Smile

Thank you very much for your help!
Re: Variation of Drill-Down Feature [message #1200968 is a reply to message #1198476] Thu, 21 November 2013 09:01 Go to previous messageGo to next message
Michael Wenz is currently offline Michael Wenz
Messages: 1577
Registered: July 2009
Location: Walldorf, Germany
Senior Member
Roman,

by default, every new diagram Editor uses its own editing domain. The
editing domain is linked with its own ResourceSet which loads its Resources
from disk. That's why you have to save first.

In order to be able to open the second diagram without saving, you should
not create a new editing domain as the default implementation in
DefaultUpdateBehavior.createEditingDomain does but reuse the editing domain
from the first editor. This means however that teh command stack of the
editors will mingle.

Michael
Re: Variation of Drill-Down Feature [message #1220894 is a reply to message #1198476] Sun, 15 December 2013 13:17 Go to previous messageGo to next message
Albert Steckermeier is currently offline Albert Steckermeier
Messages: 5
Registered: November 2013
Junior Member
Hello Michael,

is there an easy way to achieve the solution you proposed? The only thing I can think of is to subclass a bunch of graphiti classes to get graphiti to use a custom UpdateBehavior class.

Best regards,

Albert
Re: Variation of Drill-Down Feature [message #1220944 is a reply to message #1220894] Mon, 16 December 2013 04:49 Go to previous messageGo to next message
Andreas Graf is currently offline Andreas Graf
Messages: 151
Registered: July 2009
Senior Member
Hi Roman,

we use the Eclipse Sphinx project for that. It is not really easy to learn about it, but it gives you the option to define what kind of resources should be all loaded into the same model and then access the same instance from the model by a simple API.

We configured it so that all our diagrams are automatically loaded into the same resource set as the domain model (EATOP and ARTOP).

That makes sure that all the Sphinx-aware views and editors work on the same model. E.g., you get full automatic updates in the explorer view in the model, without saving, since editors and explorer and ... are all working on the same model instance.

OTOH, as Michael pointed out, that will also make all the editors "dirty" at the same time.

Andreas
Re: Variation of Drill-Down Feature [message #1222052 is a reply to message #1220894] Thu, 19 December 2013 09:59 Go to previous messageGo to next message
Michael Wenz is currently offline Michael Wenz
Messages: 1577
Registered: July 2009
Location: Walldorf, Germany
Senior Member
Albert,

basically all you need would be a subclass of DiagramEditor and one for the
DefaultUpdateBehavior, the rest could be reused if if do not oversee a
detail without actually doing it. Besides you will of course need to
register your editor in plugin.xml

Michael
Re: Variation of Drill-Down Feature [message #1229015 is a reply to message #1222052] Wed, 08 January 2014 09:49 Go to previous messageGo to next message
Roman H is currently offline Roman H
Messages: 2
Registered: November 2013
Junior Member
Michael,

thanks for your response! Please do not wonder about the different authors, Albert and me work together on this problem Wink
What we have done so far:
We created a new Editor and registered it in our plugin.xml (which works fine). We override the createDiagramBehavior-method and there we return an instance of our own DiagramBehavior.
In our DiagramBehavior class we override the createUpdateBehavior method, where we return a new instance of our UpdateBehavior class.
Now, in the UpdateBehavior, we do not really know how to fulfill this:
Quote:
you should not create a new editing domain as the default implementation in
DefaultUpdateBehavior.createEditingDomain does but reuse the editing domain
from the first editor

How can we find out if there is already an EditingDomain at this point and how can we get this one?
If there is no EditingDomain (which is the case when we create a new project, for example) we have to use the existing code, right?

Thanks!

Roman
Re: Variation of Drill-Down Feature [message #1230998 is a reply to message #1229015] Mon, 13 January 2014 10:16 Go to previous messageGo to next message
Michael Wenz is currently offline Michael Wenz
Messages: 1577
Registered: July 2009
Location: Walldorf, Germany
Senior Member
Roman,

yes, that's right and sounds good so far...

Graphiti itself does not offer functionality for managing editing domains.
That meas that you would have to create some means to organize and store
editing domains, e.g. some kind of registry where you hold the editing
domain to use for a project. In case no editing domain exists you could use
the existing functionality in the editor and store the domain in your
registry.

Michael
Re: Variation of Drill-Down Feature [message #1234719 is a reply to message #1198476] Wed, 22 January 2014 11:58 Go to previous messageGo to next message
Albert Steckermeier is currently offline Albert Steckermeier
Messages: 5
Registered: November 2013
Junior Member
We managed to use one EditingDomain by using a MultiPageEditor which handles the EditingDomain. So far so good. Unfortunately we now need real time update behavior. If whe change something in one Editor we want the changes to the business model objects to be visible in the other editor. Graphiti calls the updateNeeded function of our features which returns true but doesn't autoUpdate the diagram elements. DiagramtypeProvider returns isAutoUpdateAtRuntime() == true. What can we do to auto update the PictogramElements?

Best,

Albert

Edit: Problem solved!

[Updated on: Thu, 23 January 2014 18:35]

Report message to a moderator

Re: Variation of Drill-Down Feature [message #1237003 is a reply to message #1234719] Tue, 28 January 2014 10:53 Go to previous messageGo to next message
Michael Wenz is currently offline Michael Wenz
Messages: 1577
Registered: July 2009
Location: Walldorf, Germany
Senior Member
Albert,

Graphiti stores the information that an editor needs to be updated and will
do the actual update only on activation of the editor (see
DefaultUpdateBehavior.handleActivate e.g. triggered by
DiagramEditor.setFocus).

Have you checked if your MultiPageEditor forwards this event to the
DiagramEditor?

Michael
Re: Variation of Drill-Down Feature [message #1237116 is a reply to message #1198476] Tue, 28 January 2014 17:43 Go to previous message
Albert Steckermeier is currently offline Albert Steckermeier
Messages: 5
Registered: November 2013
Junior Member
Micheal,

the problem was, that the notification came from a contained object and not the container object which is linked as the business object. Therefore the DomainModelChangeListener didn't recognize it as a changed business object.

Best,

Albert
Previous Topic:Moving the center point possible?
Next Topic:Properties page for Graphiti Pictograms is cryptic
Goto Forum:
  


Current Time: Wed Jul 30 19:30:31 EDT 2014

Powered by FUDForum. Page generated in 0.02527 seconds