Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Refresh widget contents in Form Page when resource is changed
Refresh widget contents in Form Page when resource is changed [message #1780946] Tue, 30 January 2018 09:41 Go to next message
Gaurav Tripathi is currently offline Gaurav TripathiFriend
Messages: 43
Registered: September 2015
Member
Hello,

I have the following problem.

I have implemented an Eclipse form editor which extends AutosarFormEditor so as to handle my model. Then I added form page which extends org.eclipse.ui.forms.editor.FormPage and added this page to the editor. My model's content is changed through many SWT widget like text boxes/ checkbox/Drop-down Combo etc. that exist on the form. So far I am able to make changes and additions to the model within the editor but I want to add the following functionality.

I want to be able to reflect the changes performed outside from my editor form page, while my editor is still open.

Now how would it be possible to refresh all the SWT widget data like textbox's content in my editor form page when the resource is changed from an external or let suppose programmatically but not from form page UI?

Any suggestions?

Thank you in advance.
Re: Refresh widget contents in Form Page when resource is changed [message #1780952 is a reply to message #1780946] Tue, 30 January 2018 11:09 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33140
Registered: July 2009
Senior Member
I obviously know nothing about AutosarFormEditor. Unfortunately I don't know about org.eclipse.ui.forms.editor.FormPage either. Nor do I know how you are "binding" your model with the widgets. In general to update the model because the underlying resource is changed, you need to call Resource.unload and then Resource.load. Here's an example from the EcoreEditor:
  protected void handleChangedResources()
  {
    if (!changedResources.isEmpty() && (!isDirty() || handleDirtyConflict()))
    {
      if (isDirty())
      {
        changedResources.addAll(editingDomain.getResourceSet().getResources());
      }
      editingDomain.getCommandStack().flush();

      updateProblemIndication = false;
      List<Resource> unloadedResources = new ArrayList<Resource>();
      for (Resource resource : changedResources)
      {
        if (resource.isLoaded())
        {
          resource.unload();
          unloadedResources.add(resource);
        }
      }

      for (Resource resource : unloadedResources)
      {
        try
        {
          resource.load(Collections.EMPTY_MAP);
        }
        catch (IOException exception)
        {
          if (!resourceToDiagnosticMap.containsKey(resource))
          {
            resourceToDiagnosticMap.put(resource, analyzeResourceProblems(resource, exception));
          }
        }
      }

      if (AdapterFactoryEditingDomain.isStale(editorSelection))
      {
        setSelection(StructuredSelection.EMPTY);
      }

      updateProblemIndication = true;
      updateProblemIndication();
    }
  }
The Ecore editor, like any generated EMF Editor listens to workspace deltas, org.eclipse.emf.ecore.presentation.EcoreEditor.resourceChangeListener, and will unload and load resources that are detected to have been changed.

But this generally means that all your objects will disappear and new ones will be created, and those will need to be set as input to the form.


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Refresh widget contents in Form Page when resource is changed [message #1780953 is a reply to message #1780952] Tue, 30 January 2018 11:14 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33140
Registered: July 2009
Senior Member
I should also point at that the EMF Forms project may be something you want to look at: https://www.eclipse.org/ecp/emfforms/

Also, org.eclipse.emf.databinding.edit.EMFEditObservables is helpful for implementing two-way data binding.


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Refresh widget contents in Form Page when resource is changed [message #1781455 is a reply to message #1780953] Wed, 07 February 2018 12:39 Go to previous messageGo to next message
Lorenzo Bettini is currently offline Lorenzo BettiniFriend
Messages: 1812
Registered: July 2009
Location: Firenze, Italy
Senior Member
Also EMF Parsley provides forms based on EMF models, https://www.eclipse.org/emf-parsley/

Re: Refresh widget contents in Form Page when resource is changed [message #1781957 is a reply to message #1781455] Thu, 15 February 2018 09:06 Go to previous messageGo to next message
Gaurav Tripathi is currently offline Gaurav TripathiFriend
Messages: 43
Registered: September 2015
Member
Thanks for the answer Ed Merks and Lorenzo.

I tried calling reload method from ModelLoadManager.INSTANCE.reloadFile(iFile, false, arg0); but not able to reset input for Form.

Is there any way from where I can reset/reload/refresh editor contents and any listener which invoke only when a file is changed external to Editor?

Thanks.
Re: Refresh widget contents in Form Page when resource is changed [message #1782024 is a reply to message #1781957] Fri, 16 February 2018 06:31 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 33140
Registered: July 2009
Senior Member
I can only point you to a generated editor because all this works properly there. If you're using other technology, you'll have to ask the folks/project providing that, e.g., whomever is providing ModelLoadManager.

Ed Merks
Professional Support: https://www.macromodeling.com/
Previous Topic:Undoable command
Next Topic:synchronize form editor with emf editing domain
Goto Forum:
  


Current Time: Wed Apr 24 14:17:41 GMT 2024

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

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

Back to the top