ULCCloseableTabbedPane

Purpose

This extension is based on the ULC base widget (ULCTabbedPane) and allows you to use closeable tabs within a tabbed pane.

Features

  • Realized as extension. The server side class ULCCloseableTabbedPane is related to the corresponding client side class UICloseableTabbedPane.
  • When a tab is closed a TabEvent is fired, allowing you to register an ITabListener and implement a callback to be executed after the closing icon is clicked (eventually allowing you to avoid the tab to be closed).
  • When the single tab default closing behaviour is declared as CLOSE_TAB_ON_CLOSING_TAB, no TabEvent is generated and no roundtrip will be fired for this tab (added with R2_0).
  • A tab does not need to be selected in order to be closed.
  • Like in ULCTabbedPane, a SelectionChangedEvent can be associated, in order to be notified when a new tab is selected.
  • When the current selected tab is closed, a new one will be selected and an eventual SelectionChangedEvent is fired.
  • If a non selected tab is closed, the current selected one will maintain its selection, independently of the eventual new positioning in the tab list. No SelectionChangedEvent will be fired in such a case.
  • When the last tab is closed, the SelectionChangedEvent will be fired, delivering the index -1
  • Within ULCCloseableTabbedPane all tabs are closeable per default. You need to specify if a tab is not closeable.
  • Lazy loading is allowed for each tab in the tabbed pane, like in ULCTabbedPane
  • Warning: Due to the new closeable icon and behaviour, and due to the fact that the current supported Java versions do not allow to specify a generic component as tab (this will change with Java 6) the tabbed had to be redrawn. This can eventually cause some side effect when using particular L&Fs. In such cases, you may need to readapt some values in the UICloseableTabbedPane.UIManager class.
Closeable Tabbed Pane

How to use it

A sample usage of the ULCCloseableTabbedPane extension is provided in com.canoo.ulc.community.closeabletabbedpane.server.CloseableTabbedPaneSampleApplication.

...

ULCCloseableTabbedPane tabbedPane = new ULCCloseableTabbedPane(); tabbedPane.insertTab("Tab 1", new ULCIcon(CloseableTabbedPaneSampleApplication.class.getResource("/message16.png")), new ULCLabel("content of Tab 1"),null, 0); tabbedPane.insertTab("Tab 2", null, new ULCLabel("content of Tab 2"), null, 1); tabbedPane.setPreloadAt(1, false); tabbedPane.addTabListener(new ITabListener(){ public void tabClosing(TabEvent event) { System.err.println("Closing tab: " + event.getTabClosingIndex()); event.getClosableTabbedPane().closeCloseableTab(event.getTabClosingIndex()); } }); ...

How it is implemented

ULCCloseableTabbedPane is implemented as extension, based on the class ULCTabbedPane. Listeners of type ITabListener can be added to ULCCloseableTabbedPane, in order to execute a callback when the closing icon is clicked. From the received TabEvent element, you get access to the selected tab index.

Resources