|
Re: Tabs at bottom instead of top [message #1022144 is a reply to message #1022100] |
Thu, 21 March 2013 10:52 |
Eclipse User |
|
|
|
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 |
Urs Beeli Messages: 573 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":
And in our client, this looks as follows:
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
|
|
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03599 seconds