Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Sapphire » How to get UI part for a specific model element?
How to get UI part for a specific model element? [message #1644871] Mon, 02 March 2015 08:00 Go to next message
Ondrej Ilcik is currently offline Ondrej IlcikFriend
Messages: 21
Registered: November 2014
Junior Member
I encountered this when I was looking for a workaround for #461169. Is there some kind of binding between model elements and the actual SWT components I can use in runtime? I realize it's not that easy as sometimes the UI for a single model element/property consists of several UI components, but at least something like getRootCompositeFor(model_element) might be useful in some cases.

[Updated on: Mon, 02 March 2015 08:02]

Report message to a moderator

Re: How to get UI part for a specific model element? [message #1645755 is a reply to message #1644871] Mon, 02 March 2015 17:27 Go to previous messageGo to next message
Konstantin Komissarchik is currently offline Konstantin KomissarchikFriend
Messages: 1077
Registered: July 2009
Senior Member
It's more complex than that... For every property instance, there could be multiple UI parts (they track UI state without being aware of presentation technologies). For every UI part, there could be multiple bound presentations, each composed of multiple controls.

There is no master mapping that's maintained from an SWT control to a property instance, but you can get there with some effort... Each SWT control rendered by Sapphire is tagged with the associated part, so if you want you can iterate down the SWT control hierarchy and perform the following test...

final FormComponentPart part = (FormComponentPart) control.getData( "Sapphire.Part" );

if( part instanceof PropertyEditorPart )
{
    final Property property = ( (PropertyEditorPart) part ).property();

    ...
}


Assuming that the part is not null, check if ithe part is a PropertyEditorPart.
Re: How to get UI part for a specific model element? [message #1645770 is a reply to message #1645755] Mon, 02 March 2015 17:35 Go to previous messageGo to next message
Ondrej Ilcik is currently offline Ondrej IlcikFriend
Messages: 21
Registered: November 2014
Junior Member
Oh, I see. Thanks a lot!
Re: How to get UI part for a specific model element? [message #1645772 is a reply to message #1645755] Mon, 02 March 2015 17:37 Go to previous message
Konstantin Komissarchik is currently offline Konstantin KomissarchikFriend
Messages: 1077
Registered: July 2009
Senior Member
Keep in mind that depending on your particular UI arrangement, Sapphire will dispose and re-render SWT controls if needed due to UI structural changes, such as nearby parts changing their visibility, or simply to conserve system resources if controls are not being displayed.

A better path would be to build Sapphire locally with your candidate fix. There are instruction on the website for how to do that. Then it's a small step from there to contributing the fix to the project.

http://git.eclipse.org/c/sapphire/org.eclipse.sapphire.git
https://www.eclipse.org/sapphire/developers/BuildingLocally.php
Previous Topic:Default value recomputed but not refreshed in UI on Linux
Next Topic:Recursive Diagrams
Goto Forum:
  


Current Time: Thu Sep 20 16:09:14 GMT 2018

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

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

Back to the top