Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » scout » Tabs at bottom instead of top
Tabs at bottom instead of top [message #1022100] Thu, 21 March 2013 09:20 Go to next message
Urs Beeli is currently offline Urs Beeli
Messages: 335
Registered: October 2012
Location: Bern, Switzerland
Senior Member
Is it possible to have the tabs of a TabBox shown at the bottom instead of at the top?

To illustrate the effect I'm looking for, see this screen shot:
index.php/fa/13960/0/

[Updated on: Thu, 21 March 2013 09:21]

Report message to a moderator

Re: Tabs at bottom instead of top [message #1022144 is a reply to message #1022100] Thu, 21 March 2013 10:52 Go to previous messageGo to next message
Andreas Hoegger is currently offline Andreas Hoegger
Messages: 174
Registered: February 2010
Senior Member
Currently it is not part of the API. Nevertheless it is possible to get there:
Create a SWT field extension e.g. SwtScoutBottomAlignedTabBox extends SwtScoutTabBox. Override the initializeSwt method like:
  @Override
  protected void initializeSwt(Composite parent) {
    super.initializeSwt(parent);
    getSwtField().setTabPosition(SWT.BOTTOM);
  }


There we are.

I would appreciate to see an API request in bugzilla.

Re: Tabs at bottom instead of top [message #1033631 is a reply to message #1022144] Thu, 04 April 2013 13:05 Go to previous messageGo to next message
Urs Beeli is currently offline Urs Beeli
Messages: 335
Registered: October 2012
Location: Bern, Switzerland
Senior Member
Andi, thanks for your help with this. For anyone else interested in how to do this, I'll summarise the solution we came up with to make this configurable.

First, we created an interface IBottomAlignedTabBox:
import org.eclipse.scout.rt.client.ui.form.fields.tabbox.ITabBox;

public interface IBottomAlignedTabBox extends ITabBox {
  static String PROP_TAB_ALIGNED_BOTTOM = "alignedBottom";

  boolean isTabBottomAligned();

  void setTabBottomAligned(boolean tabBottomAligned);

}


Next, we created an abstract class AbstractBottomAlignedTabBox:
import org.eclipse.scout.commons.annotations.ConfigProperty;
import org.eclipse.scout.commons.annotations.Order;
import org.eclipse.scout.rt.client.ui.form.fields.tabbox.AbstractTabBox;

public abstract class AbstractBottomAlignedTabBox extends AbstractTabBox implements IBottomAlignedTabBox {

  @Override
  public boolean isTabBottomAligned() {
    return propertySupport.getPropertyBool(PROP_TAB_ALIGNED_BOTTOM);
  }

  @Override
  public void setTabBottomAligned(boolean tabAtBottomAligned) {
    propertySupport.setPropertyBool(PROP_TAB_ALIGNED_BOTTOM, tabAtBottomAligned);
  }

  @ConfigProperty(ConfigProperty.BOOLEAN)
  @Order(1000)
  protected boolean getConfiguredTabBottomAligned() {
    return false;
  }

  @Override
  protected void initConfig() {
    super.initConfig();
    setTabBottomAligned((getConfiguredTabBottomAligned()));
  }

}


Next, we created the Swt class SwtScoutBottomAlignedTabBox
import org.eclipse.scout.rt.ui.swt.form.fields.tabbox.SwtScoutTabBox;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Composite;

import com.bsiag.minicrm.client.ui.form.fields.ext.IBottomAlignedTabBox;

public class SwtScoutBottomAlignedTabBox extends SwtScoutTabBox {

  @Override
  protected void attachScout() {
    super.attachScout();
    updateAlignmentFromScout();
  }

  @Override
  public IBottomAlignedTabBox getScoutObject() {
    return (IBottomAlignedTabBox) super.getScoutObject();
  }

  protected void updateAlignmentFromScout() {
    getSwtField().setTabPosition(getScoutObject().isTabBottomAligned() ? SWT.BOTTOM : SWT.TOP);
    getSwtContainer().layout(true);
  }

  @Override
  protected void initializeSwt(Composite parent) {
    super.initializeSwt(parent);
    updateAlignmentFromScout();
  }

  @Override
  protected void handleScoutPropertyChange(String name, Object newValue) {
    super.handleScoutPropertyChange(name, newValue);
    if (name.equals(IBottomAlignedTabBox.PROP_TAB_ALIGNED_BOTTOM)) {
      updateAlignmentFromScout();
    }
  }
}


Finally, in the SWT plugin.xml we added an entry to the extension point formfields
   <extension point="org.eclipse.scout.rt.ui.swt.formfields">
     <formField
           active="true"
           modelClass="org.eclipse.minicrm.client.ui.form.fields.ext.AbstractBottomAlignedTabBox"
           name="Bottom Aligned Tab Box"
           scope="default">
        <uiClass
              class="org.eclipse.minicrm.ui.swt.form.fields.ext.SwtScoutBottomAlignedTabBox">
        </uiClass>
     </formField>
   </extension>


This gives us SDK support for the new property when using a "BottomAlignedTabBox" instead of a "TabBox":
index.php/fa/14242/0/

And in our client, this looks as follows:
index.php/fa/14244/0/

If we were adventurous, we could even swap the position of the tabs at runtime by calling
setTabBottomAligned(!isTabBottomAligned());

[Updated on: Thu, 04 April 2013 13:06]

Report message to a moderator

Re: Tabs at bottom instead of top [message #1037086 is a reply to message #1022144] Tue, 09 April 2013 06:50 Go to previous messageGo to next message
Urs Beeli is currently offline Urs Beeli
Messages: 335
Registered: October 2012
Location: Bern, Switzerland
Senior Member
Andreas Hoegger wrote on Thu, 21 March 2013 11:52
I would appreciate to see an API request in bugzilla.


Here we go: https://bugs.eclipse.org/bugs/show_bug.cgi?id=405234
Re: Tabs at bottom instead of top [message #1037131 is a reply to message #1037086] Tue, 09 April 2013 07:49 Go to previous messageGo to next message
Jeremie Bresson is currently online Jeremie Bresson
Messages: 764
Registered: October 2011
Senior Member
Can you attach a patch to your bug?
=> If you need help with setup (Git checkout, Gerrit Push...) we will be happy to help.
Re: Tabs at bottom instead of top [message #1037281 is a reply to message #1037131] Tue, 09 April 2013 11:24 Go to previous messageGo to next message
Urs Beeli is currently offline Urs Beeli
Messages: 335
Registered: October 2012
Location: Bern, Switzerland
Senior Member
I'd be happy to do that. However I have no clue where I would need to start to create a patch, so I'll probably need some pretty detailed help to get me going.
Re: Tabs at bottom instead of top [message #1037375 is a reply to message #1037281] Tue, 09 April 2013 13:23 Go to previous messageGo to next message
Jeremie Bresson is currently online Jeremie Bresson
Messages: 764
Registered: October 2011
Senior Member
Nice, as you might have noticed we are moving to gerrit (a code review tool based on git). Stephan will update our contribution guide.

I suggest that you follow the steps described there when Stephan has written them.

This will provide us a great feedback: the goal should be that every scout developer (without previous knowledge of git, egit, gerrit) is able to open a change to contribute something to Eclipse Scout.

Re: Tabs at bottom instead of top [message #1037411 is a reply to message #1037375] Tue, 09 April 2013 14:21 Go to previous messageGo to next message
Urs Beeli is currently offline Urs Beeli
Messages: 335
Registered: October 2012
Location: Bern, Switzerland
Senior Member
Thanks Jeremie

I'll keep an eye on the contribution guide to see when it's adapted to gerrit.

Cheers
/urs
Re: Tabs at bottom instead of top [message #1059651 is a reply to message #1037281] Tue, 21 May 2013 06:13 Go to previous message
Urs Beeli is currently offline Urs Beeli
Messages: 335
Registered: October 2012
Location: Bern, Switzerland
Senior Member
Urs Beeli wrote on Tue, 09 April 2013 13:24
I'd be happy to do that.


While I'm still willing to put together a patch for this, I simply don't have time at the moment. It might be a while until I get around to it...
Previous Topic:Eclipse Scout on OS X Java 7
Next Topic:How to customize the Rayo Look&Feel?
Goto Forum:
  


Current Time: Fri Oct 24 12:59:36 GMT 2014

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

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