Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Requirements Modeling Framework  » How to open the SpecificationEditor programmatically
icon5.gif  How to open the SpecificationEditor programmatically [message #1734598] Thu, 09 June 2016 18:05 Go to next message
Mark Drei is currently offline Mark DreiFriend
Messages: 13
Registered: April 2016
Junior Member
Hi all,

I'd like to open the SpecificationEditor programmatically and jump to a SpecObject (= select and show it).

What I have so far:
1) I can already open the Reqif10Editor with the correct .reqif file. (I guess I have to open this one, right? Actually just the SpecificationEditor would be enough if this works)

2) I can then call Reqif10Editor.openSpecEditor(...), but I need a Specification object as parameter.
I tried saving the Specification object from another place where I traverse the Ecore model, but this leads to the odd behavior that I get 2 SpecificationEditors for the same specification. I guess what happens is this: I store an old instance of the model and a new one is created, so I actually have 2 instances instead of one and of course they are not in sync. This is not what I want.

How can I get the correct Specification object when I only have the Reqif10Editor handle?
Any pointers are welcome!
Re: How to open the SpecificationEditor programmatically [message #1734602 is a reply to message #1734598] Thu, 09 June 2016 18:49 Go to previous messageGo to next message
Michael Jastram is currently offline Michael JastramFriend
Messages: 229
Registered: April 2010
Location: Düsseldorf, Germany
Senior Member
Hi Mark,

> I guess I have to open this one, right?

Yes, this acts as the main conduit to the .reqif file. We were contemplating to do this vis Sphinx, which could do without it (but so far, we have no strong incentive to do so).

> 2) I can then call Reqif10Editor.openSpecEditor(...), but I need a Specification object as parameter.

The problem is, a SpecObject is only referenced from a Specification. This means that the SpecObject can be in more than one Specification - or none at all!

So the answer is: Iterate over all Specs (including their SpecHierarchies) and see whether the SpecObject in question is attached to it. But then you have to decide what to do if there is 0 or more than 1.

The alternative is to simply select the SpecObject. If you do so, then the SpecObject should show in the PropertyView. Maybe that's already enough? Or do you really need the SpecObject in the context of the Specification? If so, then you have to bite the bullet and hunt for it in the Specifications.

Best,

- Michael


Re: How to open the SpecificationEditor programmatically [message #1734832 is a reply to message #1734602] Mon, 13 June 2016 11:38 Go to previous messageGo to next message
Mark Drei is currently offline Mark DreiFriend
Messages: 13
Registered: April 2016
Junior Member
Thanks for the fast response Michael,

Michael Jastram wrote on Thu, 09 June 2016 18:49

The problem is, a SpecObject is only referenced from a Specification. This means that the SpecObject can be in more than one Specification - or none at all!


I was not aware of that, thanks for the hint. I guess I can deal with that.

I am now able to open the Specification Editor and to select the element in question, I however discovered an issue: When the ReqIf and the SpecificationEditor are both closed, then opening them somehow ignores my selection.
I think the comes from the code in SpecificationEditor.createSpecificationPart() which selects a default. I haven't figured out why my selection event seems to get lost when I sent it after this default was set (i.e. after opening the SpecificationEditor).
What managed to solve my problem was changing createSpecificationPart() a little:

.. // unchanged
if (false == specification.getChildren().isEmpty()) {
	boolean reuseSelection = false;
	ISelection reqifSelection = reqifEditor.getSelection();
	if (reqifSelection != null && reqifSelection instanceof IStructuredSelection) {
		Object firstSelectedElement = ((IStructuredSelection) reqifSelection).getFirstElement();
		if (firstSelectedElement != null && firstSelectedElement instanceof SpecHierarchy) {
			prorAgileGridViewer.setSelection(reqifSelection);
			reuseSelection = true;
		}
	}
	if (!reuseSelection) {
		// old code which sets the default
		prorAgileGridViewer.setSelection(new StructuredSelection(
				specification.getChildren().get(0)));
	}
... // unchanged
}


Best regards,
Mark
Re: How to open the SpecificationEditor programmatically [message #1735001 is a reply to message #1734832] Tue, 14 June 2016 14:43 Go to previous messageGo to next message
Michael Jastram is currently offline Michael JastramFriend
Messages: 229
Registered: April 2010
Location: Düsseldorf, Germany
Senior Member
Hi Mark,

Just a quick guess: You may have to set the selection on the GUI thread. Try Display.asyncExec().

Best,

- Michael


Re: How to open the SpecificationEditor programmatically [message #1735570 is a reply to message #1734598] Tue, 21 June 2016 09:21 Go to previous message
Mark Drei is currently offline Mark DreiFriend
Messages: 13
Registered: April 2016
Junior Member
Hi Michael,

Yes I tried that. Didn't change the behavior.

Best regards,
Mark
Previous Topic:Unified Column is not as per documentation
Next Topic:API ti add content to Spec Object
Goto Forum:
  


Current Time: Wed Sep 19 09:26:25 GMT 2018

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

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

Back to the top