Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF "Technology" (Ecore Tools, EMFatic, etc)  » [ECP] Custom Control always in a ScrolledComposite(Is it possible to have a Custom Control not be in a ScrolledComposite so that it can deal with scrolling itself?)
[ECP] Custom Control always in a ScrolledComposite [message #1407118] Mon, 11 August 2014 23:11 Go to next message
Charles Eutsler is currently offline Charles EutslerFriend
Messages: 19
Registered: July 2009
Junior Member
We have created a custom control that contains a Combo control and a table that contains the items of the type selected in the Combo. We'd like the Combo box always to be displayed and have the table take up all the remaining room in the parent Composite.

The problem is that the custom control, which extends ECPAbstractCustomControlSWT, always has a ScrolledComposite as a parent. As a result, our table takes up some fixed region and the whole custom control's area scrolls when the contents are larger that some size (often, that is smaller than the area shown in the sash). The Combo box gets scrolled out of view when items in the table are scrolled into view.

Is there a way to have the parent of our custom control be a simple Composite and let us deal with the scrolling?

I must be missing something, surely.
Re: [ECP] Custom Control always in a ScrolledComposite [message #1408390 is a reply to message #1407118] Fri, 15 August 2014 00:07 Go to previous messageGo to next message
Eugen Neufeld is currently offline Eugen NeufeldFriend
Messages: 63
Registered: March 2012
Member
Hi,
the ScrolledComposite is added as a root control, so that we can also display large auto generated forms.
Did you try to first add a Composite which would fill the ScrolledComposite and then add your controls to this composite? This way there should be no scrollbars.

--
Eugen Neufeld

Get Professional Eclipse Support: http://eclipsesource.com/munich
Re: [ECP] Custom Control always in a ScrolledComposite [message #1408660 is a reply to message #1408390] Fri, 15 August 2014 18:15 Go to previous messageGo to next message
Charles Eutsler is currently offline Charles EutslerFriend
Messages: 19
Registered: July 2009
Junior Member
The troublesome part of our form is defined as:
ViewForm
    Categorization
        Leaf Category one
            ...
        Leaf Category troublesome
            Custom Control troublesome
                Custom Domain Model Reference


When the renderControl is called for the troublesome custom control, the hierarchy of composites leading to the renderControl's parent parameter is:
  ...
    SashForm
      ScrolledComposite
        Composite
          Composite

The last Composite is the renderControl method's parent parameter value.

Into the parent composite we build:
  Composite (with GridLayout(2, false)
    Label
    Combo
    TableViewer (with GridData(SWT.FILL, SWT.FILL, true, true, 2, 1))

So, the TableViewer should ultimately get all the real estate of the custom control not taken by the combo and its label (and any margins of the containing Composites).

The problem is that the ScrolledComposite is given all the real estate of its part of the SashForm and it displays scroll bars when the Composite it contains requires more area than is available in the ScrolledComposite's area.

The contained composite does not expand to fill the available space (nor do its children). The size of the topmost contained Composite is what is used to determine when scroll bars are displayed. The size of that Composite comes from the sizes of the components it contains (based on preferred dimensions and whatnot). But there is no filling of the ScrolledComposite.

What I think is needed here is to have the child of the SashForm be a simple Composite that gives its child all its real estate when it has a single, custom control as its child.

OK, I'm seeing a little bit of a problem here...I see that the View Model editor context menu lets me add a Control to a Leaf Category but it doesn't let me add a Custom Control. I seem to have defined the Custom Control somewhere then dragged it into the Leaf Category. The editor didn't help me create it there but it did let me move it there so I'm guessing it is valid and that the View Model editor is just missing the Custom Control entry in the context menu of the Leaf Category tree node.
Re: [ECP] Custom Control always in a ScrolledComposite [message #1409667 is a reply to message #1408660] Mon, 18 August 2014 17:15 Go to previous messageGo to next message
Eugen Neufeld is currently offline Eugen NeufeldFriend
Messages: 63
Registered: March 2012
Member
Hi,
I reproduced your problem.
This is "intended" behavior.
What you need is to replace the layoutprovider classe.
Please take a look at http://eclipsesource.com/blogs/emf-forms-rendering/ and the part about Layouts.

The default behavior is not to grab all space that is there. I would recommend to create an own Composite in your Custom Control on which you render your combobox and the table and create your own LayoutProvider which will let all Composites or all Composites with a specific data object set grab all space.
The default ECP implementation of the LayoutProvider is org.eclipse.emf.ecp.view.swt.internal.layout.ECPLayoutProvider

Cheers,
Eugen
Re: [ECP] Custom Control always in a ScrolledComposite [message #1409754 is a reply to message #1409667] Mon, 18 August 2014 23:24 Go to previous messageGo to next message
Charles Eutsler is currently offline Charles EutslerFriend
Messages: 19
Registered: July 2009
Junior Member
The problem is getting clearer to me. As it stands, it's beginning to look like we have to deal with the fact that our Custom Control is in a ScrolledComposite and we'll have to do something to accommodate that. Perhaps we can create our table such that it isn't in a ScrolledComposite of its own.

I don't see how the LayoutProvider suggestion can work. From what I can see, there can be only one LayoutProvider and there is one provided by the framework. It seems that a LayoutProvider is contributed by the org.eclipse.emf.ecp.ui.view.swt.layoutProvider extension point. org.eclipse.emf.ecp.view.spi.swt.layout.LayoutProviderHelper.checkProviderLength() throws an IllegalStateException when there is more than one LayoutProvider.

I don't see a way to specify a LayoutProvider control-by-control. Besides, the existing layout provider is already having controls fill the parent so I don't see what more we could have it do.

I see that my suggestion that a simple Composite be the parent of the contents of the SashForm when a single Custom Control is the only child won't work. It looks like the ScrolledComposite is the common parent control for all of the Categorization elements of the View Model.

Let me update my suggestion for making this work: If the Categorization element's control were a simple Composite (instead of a ScrolledComposite) and the Leaf Category elements were rendered by ScrolledComposites (rather than simple Composites), we probably could make things work the way we would like. In that case, I think we could provide a Renderer for the Category when it is one of ours that doesn't want to be in a ScrolledComposite.

But, of course, that could break existing code where people have made custom renderers for the Category level who expect their control to be in a ScrolledComposite.

[Updated on: Mon, 18 August 2014 23:37]

Report message to a moderator

Re: [ECP] Custom Control always in a ScrolledComposite [message #1409892 is a reply to message #1409754] Tue, 19 August 2014 08:30 Go to previous messageGo to next message
Eugen Neufeld is currently offline Eugen NeufeldFriend
Messages: 63
Registered: March 2012
Member
Hi,
you can replace the categorization renderer and the leaf category renderer. And thus provide Composites/ScrolledComposites just like you like.
You can also replace the LayoutProvider (by deactivating the ecp.view.swt.layout plugin and activating your own).
The control that is returned by your custom control gets a GridData object which is provided by the LayoutProvider. The relevant method is getLayoutData .
In the case of the ECPLayoutProvider this method delegates to getControlGridData because a VCustomControl extends VControl. The getControlGridData returns a GridData which doesn't grab and doesn't fill vertically.

I'm suggesting to replace the LayoutProvider and provide GridDatas just the way you need them.

Cheers,
Eugen
Re: [ECP] Custom Control always in a ScrolledComposite [message #1410115 is a reply to message #1409892] Tue, 19 August 2014 22:05 Go to previous messageGo to next message
Charles Eutsler is currently offline Charles EutslerFriend
Messages: 19
Registered: July 2009
Junior Member
Thanks for the suggestions, Eugen!

I'm embarrassed that I said we could provided a Renderer for the Category level but didn't think that we could also provide our own Renderer for the higher level. This is all beginning to look like we can achieve what we want.

Re: [ECP] Custom Control always in a ScrolledComposite [message #1410363 is a reply to message #1410115] Wed, 20 August 2014 14:55 Go to previous message
Jonas Helming is currently offline Jonas HelmingFriend
Messages: 699
Registered: July 2009
Senior Member
Hi Charles,

if you need professional support for this, please let us know.

Best regards

Jonas

Am 20.08.2014 00:05, schrieb Charles Eutsler:
> Thanks for the suggestions, Eugen!
>
> I'm embarrassed that I said we could provided a Renderer for the
> Category level but didn't think that we could also provide our own
> Renderer for the higher level. This is all beginning to look like we can
> achieve what we want.
>
>
Previous Topic:[EMF FORMS] VFeaturePathModelReference resolve issue
Next Topic:[EMF FORMS] Validation & Rules.
Goto Forum:
  


Current Time: Fri Apr 19 20:11:28 GMT 2024

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

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

Back to the top