Skip to main content



      Home
Home » Modeling » Papyrus » How to open the editor on given element in given diagram ?
How to open the editor on given element in given diagram ? [message #1632852] Tue, 24 February 2015 09:24 Go to next message
Eclipse UserFriend
Hi,
Starting from an instance of papyrusmultidiagrameditor, I would like to select a given diagram, to select a list of elements in this diagram and to reveal them.

Is there an API for this ? If not, how can I achieve it ?
I want to select SysML elements existing in the model and make them appear programmatically in a diagram .


Sami.
Re: How to open the editor on given element in given diagram ? [message #1724306 is a reply to message #1632852] Mon, 22 February 2016 18:47 Go to previous messageGo to next message
Eclipse UserFriend
Hi!

I can list the existing diagrams with the following function

public List<Diagram> getDiagrams(){
		try{
			Resource notationResource;
			notationResource = NotationUtils.getNotationModel(this.editor.getServicesRegistry().getService(ModelSet.class)).getResource();
			@SuppressWarnings("unchecked")
			List<Diagram> list = (List<Diagram>)(List<?>) notationResource.getContents();
			return list;
		}catch(ServiceException e){
			throw new RuntimeException(e);
		}
	}


Here the editor is your IMultiDiagramEditor instance.

András
Re: How to open the editor on given element in given diagram ? [message #1724371 is a reply to message #1724306] Tue, 23 February 2016 06:50 Go to previous messageGo to next message
Eclipse UserFriend
Hi, András,

A bit of care is needed, here. The notation resource can also have as roots:

* tables, instances of the NattablePackage.Literals.TABLE class
* embedded stylesheets, instances of the
StylesheetsPackage.Literals.STYLESHEET class

and possibly other things (I think I've seen other objects, but I
forget what). In any case, some judicious filtering of the resource's
contents is recommended.

Coming in the M6 milestone of the Neon release will be a new API of the
IEMFModel interface (which the NotationModel implements): the
getRootElements() operation provides an iteration of all the logical
roots of the model, which in this case is notations. That includes
both diagrams and tables, but not other things like stylesheets. So,
some filtering still needed, but perhaps your use case does actually
need to account for tables, too (I don't know).

Cheers,

Christian


On 2016-02-22 23:47:57 +0000, András Dobreff said:

> Hi!
>
> I can list the existing diagrams with the following function
>
>
> public List<Diagram> getDiagrams(){
> try{
> Resource notationResource;
> notationResource =
> NotationUtils.getNotationModel(this.editor.getServicesRegistry().getService(ModelSet.class)).getResource();
>
> @SuppressWarnings("unchecked")
> List<Diagram> list = (List<Diagram>)(List<?>)
> notationResource.getContents();
> return list;
> }catch(ServiceException e){
> throw new RuntimeException(e);
> }
> }
>
>
> Here the editor is your IMultiDiagramEditor instance.
>
> András
Re: How to open the editor on given element in given diagram ? [message #1724378 is a reply to message #1724371] Tue, 23 February 2016 08:17 Go to previous messageGo to next message
Eclipse UserFriend
Hi,

The OpenElementService (Used to open e.g. Search Results in Papyrus) can help here. If you give it either a Semantic element (UML) or graphical element (Notation), it will:

- Find representations of this element (This step can be skipped if you use a graphical element directly)
- Open or focus the proper editor for this representation (Usually a Diagram editor)
- Select and Focus the representation (Ensuring it is visible on screen, moving the scrollbars as necessary)

The code looks like:

IMultiDiagramEditor editor;
OpenElementService openService = editor.getServicesRegistry().getService(OpenElementService.class);
openService.openElement(viewElement); //If you already have the representation (notation::View)
openService.openSemanticElement(semanticElement); //If you only know the semantic (UML) element


HTH,
Camille
Re: How to open the editor on given element in given diagram ? [message #1724426 is a reply to message #1724378] Tue, 23 February 2016 15:36 Go to previous message
Eclipse UserFriend
Thanks the warning Christian, I'll include the filtering.
Previous Topic:Programmatically generate Papyrus model from existing UML diagrams
Next Topic:[CSS] Filter on fields of type
Goto Forum:
  


Current Time: Sat Jul 12 11:07:16 EDT 2025

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

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

Back to the top