Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » scout » Switch Tabs programatically(How to swicth tabs based on button click)
Switch Tabs programatically [message #1191370] Sun, 17 November 2013 02:47 Go to next message
Walter Mising name is currently offline Walter Mising name
Messages: 126
Registered: July 2009
Senior Member
How do I programatically switch tabs ?
Re: Switch Tabs programatically [message #1193838 is a reply to message #1191370] Mon, 18 November 2013 07:41 Go to previous messageGo to next message
Matthias Nick is currently offline Matthias Nick
Messages: 183
Registered: August 2013
Senior Member
Hi Walter, thanks for your question.

I think the method
AbstractTabBox.setSelectedTab(IGroupBox)

is what you are looking for.

I created a TabBox with 3 Tabs:
TabBox
 - Tab1Box
 - Tab2Box
 - Tab3Box


Then I created a Button with an execClickAction and the following implementation

    public class SwitchButton extends AbstractButton {
      int i = 0;

      @Override
      protected void execClickAction() throws ProcessingException {
        TabBox tabBox = getTabBox();
        IGroupBox selectedTab = tabBox.getSelectedTab(); //this one is selected
        if (i % 3 == 0) {
          tabBox.setSelectedTab(getTab1Box());
        }
        else if (i % 3 == 1) {
          tabBox.setSelectedTab(getTab2Box());
        }
        else if (i % 3 == 2 {
          tabBox.setSelectedTab(getTab3Box());
        }
        i++;
      }
    }

What this method does is, it switches to the next Tab if one clicks on the button. I have a counter (i) which will be increased by one if you click the button. The modulo operation (%) makes sure to get values between 0 and 2. If i == 0, show first tab, if i == 1 show second tab and if i == 2 show last tab.

Hope this helps.
Greetings,
Matthias
Re: Switch Tabs programatically [message #1194392 is a reply to message #1193838] Mon, 18 November 2013 13:42 Go to previous message
Walter Mising name is currently offline Walter Mising name
Messages: 126
Registered: July 2009
Senior Member
Thanks. Works as expected.
Previous Topic:What is a Scout project?
Next Topic:Exception with anchors in HtmlField
Goto Forum:
  


Current Time: Thu Oct 30 16:04:36 GMT 2014

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

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