Bug 150393 - Support JTabbedPane version of NetBeans tabbed containers
Support JTabbedPane version of NetBeans tabbed containers
Status: RESOLVED FIXED
Product: platform
Classification: Unclassified
Component: Window System
6.x
All All
: P2 with 7 votes (vote)
: 7.2
Assigned To: maxnitribitt
issues@platform
:
Depends on: 169099
Blocks: 67455 66335 96528 120075
  Show dependency treegraph
 
Reported: 2008-10-16 14:48 UTC by David Simonek
Modified: 2012-01-26 16:09 UTC (History)
5 users (show)

See Also:
Issue Type: ENHANCEMENT
:


Attachments
proof of concept (1.01 MB, text/plain)
2009-07-28 10:44 UTC, maxnitribitt
Details

Note You need to log in before you can comment on or make changes to this bug.
Description David Simonek 2008-10-16 14:48:24 UTC
The idea is to implement tabbed containers in NetBeans window system backed by regular Swing's JTabbedPane for JDK 1.6.x
and later and offer such implementation as alternative to our TabbedContainer, mainly for platform. Such approach will
have several pros and cons:

Pros:
- Easier and better support of 3rd party L&Fs in apps written on Platform RPC. As JTabbedPane is regular Swing
component, it should work from scratch without additional work (see enh 66335)
- Enhanced configuration, tab placement (enh 96528 implementation at almost no cost)
- Possibility of more lines with tabs

Cons:
Some features will be lost - probably:
- control buttons on editor right top corner will go away
- only two state tabs, selected / not selected x current three state active / selected / not selected  
- "stretching" layout of tabs for non-editor component lost

For IDE we will probably choose to stay with specialized implementation, but apps on top of the netbeans RC platform may
find JTabbedPane impl better for them.
Comment 1 maxnitribitt 2009-07-11 08:20:54 UTC
How about retrieving the Tabbed implementation as a service via Lookup in DefaultSeparateContainer and
DefaultSplitContainer? This would be enough as a first step. Then anyone interested can write a module to swap the
default TabbedAdapter implementation against one based on JTabbedPane.
Comment 2 maxnitribitt 2009-07-11 09:41:40 UTC
What I mean is:

We could create an interface:

public interface TabbedComponentFactory {
    public Tabbed getTabbedComponent(int type);
}

and Implementation:
@ServiceProvider(service=TabbedComponentFactory.class)
public class DefaultTabbedComponentFactory implements TabbedComponentFactory{
    public Tabbed getTabbedComponent(int type) {
        return new TabbedAdapter(type);
    }
}

And use it in DefaultSplitContainer and DefaultSeparateContainer:

    protected Tabbed createTabbed() {
        Tabbed tabbed;
        TabbedComponentFactory componentFactory = Lookup.getDefault().lookup(TabbedComponentFactory.class);
        if(getKind() == Constants.MODE_KIND_EDITOR) {
            
            tabbed = componentFactory.getTabbedComponent(Constants.MODE_KIND_EDITOR);
        } else {
            tabbed = componentFactory.getTabbedComponent(Constants.MODE_KIND_VIEW);
        }
        return tabbed;    
    }

Then to add Tabbed and Constants to the public API, and anyone can do an implementation. It would be only a minimal
change, but in times of scarce resources ( and core being in maintenance mode for 6.8) it would enable external
contributors to fix this by adding an implementation in a separate module without having to touch core.windows (e.g. as
part of http://wiki.netbeans.org/NetFIX or a similar program).  





Comment 3 maxnitribitt 2009-07-11 17:16:49 UTC
dsimonek wrote:
>Cons:
>Some features will be lost - probably:
>- control buttons on editor right top corner will go away

It should be possible to keep the control buttons as well. We can use CloseButtonTabbedPane for IOWindows in UI
Utilities as a starting point for this.
 
> - "stretching" layout of tabs for non-editor component lost

Could you explain what you mean by "stretching"?

--Toni

Comment 4 David Simonek 2009-07-13 06:53:49 UTC
I'm not working on this part anymore, sorry.

By "stretching" I meant behavior of tabs for example in explorer - each tab always keeps the same portion of available
space.
Comment 5 _ tboudreau 2009-07-14 19:56:08 UTC
Look around for something (maybe lost in CVS history at this point) - an interface called Tabbed and a class called TabbedAdapter.  It was basically the API 
of JTabbedPane wrapping TabbedContainer.

If you stick to JDK 6, you can probably do close buttons properly - I think there's an API that lets you supply a component to be the tab label that can be 
whatever you want in a JTabbedPane.

The look and feel implementations for TabbedContainer are kind of a mess - apologies for that - I wanted to unify it all to one codebase and just allow 
some sort of simple skinning, but good intentions and time don't always work out.

The reason for TabbedContainer existing was really looking at the (JDK 1.4) code for JTabbedPane - after living with some horrible, unfixable bugs in the 
pre-3.6 JTabbedPane based UI - and simply deciding it was not scalable or well enough written, and we'd rather have something that was model driven, 
could scale and most importantly that we wouldn't have to wait for a JDK update if something needed fixing.  If we were doing it today, I might go for using 
JTabbedPane and some custom UI delegates.  In 2003, though, it just wasn't an option.

There *was* at some point, a boolean switch you could throw to get JTabbedPanes instead of TabbedContainers in the NetBeans UI, but I suspect that's 
long gone.
Comment 6 maxnitribitt 2009-07-14 20:42:34 UTC
That's exactly what I did. I've implemented Tabbed using JTabbedPane and created a Serviceprovider interface  (
TabbedComponentFactory as described before) that allows me to plugin my implementation. Thanks for your feedback, Tim.
No I know at least that I'm not on a dead track, and will continue fleshing this out...



Comment 7 maxnitribitt 2009-07-23 10:18:30 UTC
Started as a netdev FOW:
http://wiki.netbeans.org/OtherTabFOW

--Toni
Comment 8 maxnitribitt 2009-07-24 10:45:36 UTC
Created http://www.netbeans.org/issues/show_bug.cgi?id=169099 for the required API changes.
Comment 9 David Simonek 2009-07-27 16:04:34 UTC
Hi Toni,
Times they are changing and I was assigned as reviewer, so I'm going to study your materials and let you know...but from
the first sigh it looks OK, I remember thinking about similar approach myself.
Comment 10 maxnitribitt 2009-07-27 16:18:35 UTC
Hi Dafe,

Since it looks like this enhancement was originally submitted by you, you're probably the perfect reviewer :-). I'll fix
a few bugs with my current implementation and upload a first alpha version with partial implementation later this week.
 
--Toni
Comment 11 maxnitribitt 2009-07-28 10:44:34 UTC
Created attachment 85309 [details]
proof of concept
Comment 12 maxnitribitt 2009-07-29 07:50:16 UTC
The source code of the proof of concept is now available on Kenai: http://kenai.com/projects/nb-tabbedpane
Comment 13 Stanislav Aubrecht 2012-01-25 14:31:45 UTC
i've added a branding switch to replace TabbedContainer with JTabbedPane, see core-main 757389cbbb60
Comment 14 Quality Engineering 2012-01-26 16:09:59 UTC
Integrated into 'main-golden', will be available in build *201201260600* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main/rev/757389cbbb60
User: S. Aubrecht <saubrecht@netbeans.org>
Log: #150393 - Support JTabbedPane version of NetBeans tabbed containers


By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2012, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo