Using FormEditor with a single page

I tried to think of a snazzier title for this post, but I’m in a literal mood I guess. So have you ever faced this problem? You want to use the FormEditor class (or it’s new subclass SharedHeaderFormEditor), but you only have a single page.

Sure, you can use FormEditor with a single page, but you’ll wind up with a single tab at the bottom of the editor. It looks a bit goofy:

View of editor showing tab on single page

Well the solution is surprisingly simple. In your subclass of FormEditor, just override the createPages method like this:

protected void createPages() {
        if (getPageCount() == 1 &&
		getContainer() instanceof CTabFolder) {
            ((CTabFolder) getContainer()).setTabHeight(0);

This code hides the tabs when there is only one page, and you wind up with this:

View of editor with no tabs for single page

Note that you need to call the super method before resizing the tab height, or this won’t work.


5 Responses to Using FormEditor with a single page

  1. I don’t think making the method public is a good idea.

  2. Patrick says:

    Thanks, Remy. That was a typo and it’s now fixed.

  3. I enjoyed this installment of “stupid editor tricks” 🙂

    I think this should be the default behavior of FormEditor, so that clients don’t have to worry about overriding it.

  4. […] Editor without a Tab September 27, 2010 graphr Leave a comment Go to comments… Categories: Uncategorized Comments (0) Trackbacks (0) Leave a comment […]

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: