Archimate - how to open a IDiagramModel in a ViewPart instead of editor

Started by saffko, February 24, 2016, 16:01:02 PM

Previous topic - Next topic

saffko

Hello Mr Phillip Beauvoir,

I'm currently trying to extend some functionnality of Archi, and want to have your advice on which path to follow.
My problem is that I want to show a diagram (based on a ArchimateDiagramModel) in a view (ViewPart) instead of editor.
Do you think that is possible ?

Waiting forward to your answer, let me wish you a nice afternoon and an excellent end of week !

Kind regards,

Saffet.

Phil Beauvoir

Hi Saffet,

can I ask why you want to show a diagram in a view instead of an editor? Do you want to actually edit the diagram? Or do you want to display an image of the diagram in the view?

Eclipse makes a distinction between an "editor" and a "view" and it's usally the case that editing actions and undo/redo are tied to the editor part rather than a view part.

Phil
If you value and use Archi, please consider making a donation!
Ask your ArchiMate related questions to the ArchiMate Community's Discussion Board.

saffko

Hi Phillip,

Yes, I know that in eclipse you can have many separated views, but only one editor (which takes place in only one region whereas views can be moved anywhere).
I need to open a diagram in read-only mode (in a view) and use the editor to build another diagram (which is therefore in read/write mode).
Opening an image will not be sufficient, because what I want to be able to "select" components and also right-click on a component with a contextual menu which result in an action.

That's why I need to open a diagram in a view :)

Saffet.

Phil Beauvoir

Hi Saffet,

it is possible to drag and drop to move an editor part wherever you like.

I think you should clearly define what you are *really* trying to do. Maybe there is another solution. You say that you want to "build another diagram". Why? Are you trying to create a new diagram based on an existing one? Or something else? I think if you were to clearly analyse yoour goal, another solution woulf be apparant.

Phil
If you value and use Archi, please consider making a donation!
Ask your ArchiMate related questions to the ArchiMate Community's Discussion Board.

prgee

Hi Saffet,

Just another thought. I often find the need to create a new diagram based on an existing one. For this purpose I simply "duplicate" the diagram I am starting from (right-click/duplicate on the original diagram name) and then work with the new copy. Duplicating the diagram creates a new view but does not duplicate the elements and relations referenced in the view.

Regards,
Peter

saffko

Hi Phil,

first of all, thank you for your quick react.
To be clear, what I want to do in archimate is the following:

I want to be able to have simultaneously 2 diagrams :
   - one opened in read/write mode in the editor (as is in archi) : the view A
   - another one opened in a read-only mode in a view (or whatever else) : the view B

I want to use "view B" as a viewer: so the diagram showed into should not be modifiable (user will not be pertmitted to move or edit it), but action like "right-click", "hover", "tooltip", etc... should still be working.
When I right-click on the "view B", I want to open a contextual menu and fire an action.
This action will result on a creation of a copy of the clicked component and the newly created copy should take place on a new "view A" (a new tab in fact).
=> we could see this action as an action with the palette.

VoilĂ , that's the high-level flow of what I want to implement.

At this time, I've tried to emulate this behaviour on cloning the "diagram editor view", but it's quite difficult to make it read-only.
And also in term of semantics, an editor should be something "editable", but actually what I want to do is not to edit.
That's why I was thinking about a "viewer" and not an "editor".

All kinds of solutions are welcome :)

Thanks in advance,

Saffet.

Phil Beauvoir

Hi Saffet,

in order to render the diagram as read-only you will need to use either a view part or an editor part but there will need to be the whole stack of EMF model, GEF editor parts, etc, just as it is now in the code. Using a View part will not make it read-only. I think that in order to make it read only, you'd need to do something like the "locked" edit parts in a Canvas view - each edit part in a diagram has to be made non-editable. I think this involves not attaching edit policies to an edit part - see createEditPolicies() in the code. Or you can set the setLocked(true) on a model object.

Regards,

Phil
If you value and use Archi, please consider making a donation!
Ask your ArchiMate related questions to the ArchiMate Community's Discussion Board.

saffko

Hi Phil,

hope that everything is fine with you :)
Thank you for your explanations, I have a better idea of what & how to do now.

Can I just ask you "how to open a diagram in a ViewPart (org.eclipse.ui.part.ViewPart)" :)

have a nice day !

Kind regards,

Saffet.

Phil Beauvoir

Hi Saffet,

I don't know exactly how to do it, but if you look at the source code for  org.eclipse.gef.ui.parts.GraphicalEditor you should see how it's done. Basically the view should create a  ScrollingGraphicalViewer() and populate it with a model.

Phil
If you value and use Archi, please consider making a donation!
Ask your ArchiMate related questions to the ArchiMate Community's Discussion Board.