Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Requirements Modeling Framework  » CREATING REQIF SPECHIERARCHY AND SPECIFICATIONS PROGRAMMATICALLY
CREATING REQIF SPECHIERARCHY AND SPECIFICATIONS PROGRAMMATICALLY [message #1706502] Thu, 27 August 2015 12:23 Go to next message
Anil Ozturk is currently offline Anil OzturkFriend
Messages: 6
Registered: July 2015
Junior Member
Hi everyone,
I m developing some tools with using RMF. My problem is very clear. I want to add child (specifications or spechiearchies) depend on my select on tree programmatically. I can create specs and spechierarchies using ReqIF10Factory instance but i cannot add them for my selected item's children on tree. Let me show related part of my code to you. Sorry for my English. Any help would be so grateful to me.

private ArrayList<SpecHierarchy> listOfSpecs;

EObject eObject = (EObject) CreatingReqifSpecPage.markTreeViewer.getCheckedElements()[0];
    if (eObject instanceof SpecHierarchy) {
      SpecHierarchy specHier = (SpecHierarchy) eObject;
EcoreEditor eEditor = (EcoreEditor) Activator.getEditor();
      Resource myResource =
          eEditor.getEditingDomain().getResourceSet().getResource(EcoreUtil.getURI(eObject), true);
      EList<EObject> list = myResource.getContents();
      if (list.get(0) instanceof ReqIFImpl) {
        ReqIFImpl reqIFimpl = (ReqIFImpl) list.get(0);
        EList<Specification> listOfSpecsFake = reqIFimpl.getCoreContent().getSpecifications();
        for (Specification specification : listOfSpecsFake) {
          EList<SpecHierarchy> listOfSpecHier = specification.getChildren();
          for (SpecHierarchy specHierarchy : listOfSpecHier) {
            if (specHierarchy.getIdentifier().equals(specHier.getIdentifier())) {
              specHierarchy.getChildren().addAll(listOfSpecs);
              break;
            }
          }
        }
      }
      try {
        myResource.save(null);
      } catch (IOException e) {
        e.printStackTrace();
      }

[Updated on: Fri, 28 August 2015 13:00]

Report message to a moderator

Re: CREATING REQIF SPECHIERARCHY AND SPECIFICATIONS PROGRAMMATICALLY [message #1706622 is a reply to message #1706502] Fri, 28 August 2015 08:29 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
Anil,

At first glance it looks like you're using the same SpecHierary and try to add it to a second parent. That does not work. You have to create a new SpecHierarchy. You then have to set the old SpecHierarchy's SpecObject on the newly created SpecHierarchy.

A SpecHierarchy can have only one parent.

Best,

- Michael


Re: CREATING REQIF SPECHIERARCHY AND SPECIFICATIONS PROGRAMMATICALLY [message #1706629 is a reply to message #1706622] Fri, 28 August 2015 09:13 Go to previous messageGo to next message
Anil Ozturk is currently offline Anil OzturkFriend
Messages: 6
Registered: July 2015
Junior Member
Firstly thank you for your care,

I just want to add some children to selected spec hieararchy on tree . So there is one parent which is selected item. In debug i can see when addAll command executed, selected specHierarchy's children has been updated correctly. But i dont see any changes in tree on the editor.
Re: CREATING REQIF SPECHIERARCHY AND SPECIFICATIONS PROGRAMMATICALLY [message #1706631 is a reply to message #1706629] Fri, 28 August 2015 09:25 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 Anil,

If you want to see the results in the UI while the model is open, then you have to use commands, rather than editing the model directly. Using commands will also give you undo/redo.

Best,

- Michael


Re: CREATING REQIF SPECHIERARCHY AND SPECIFICATIONS PROGRAMMATICALLY [message #1706657 is a reply to message #1706631] Fri, 28 August 2015 12:59 Go to previous message
Anil Ozturk is currently offline Anil OzturkFriend
Messages: 6
Registered: July 2015
Junior Member
Would you give me some detail about this command ? When i search what you say i found CreateChildCommand but i didnt understand actually how to use it.

When I try use
 CreateChildCommand.create 
command, it takes some parameters like these
 (EditingDomain domain, Object owner, Object newChildDescriptor, Collection <?> selection)

. I did not understand.

I 've got editing domain from editor, but the others don't make any sense for me.

Especially to put newChildDescriptor I tried use to
 CommandParameter(Object owner, Object feature, Object value, Collection<?> collection) 
. And also I did not understand it.

Please give me more info.

Regards.

Anil.
Previous Topic:Highlighting problems
Next Topic:Creating SpecHierarchy Programmatically and Save to .reqif file
Goto Forum:
  


Current Time: Wed Sep 19 07:13:56 GMT 2018

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

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

Back to the top