Announcement Announcement Module
No announcement yet.
Views As Tabs Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Views As Tabs

    Instead of my list of views being hidden away under the Menu > Window > Views, I would like to have them displayed as tabs. has anyone done something similar or have any pointers on how to start?

  • #2
    You will need to work with DefaultApplicationWindow.

    Particularly, this method:

    protected void updatePageControl(ApplicationPage oldPage) {
    control.getContentPane().remove(oldPage.getControl ());
    control.getContentPane().add(this.currentPage.getC ontrol());

    just over-write and add pages the way you want (in JTabbedPane) then specify your new window as applicationWindowPrototype in application context


    • #3
      A ApplicationPage implemented with TabbedPane

      public class TabbedPaneApplicationPage extends AbstractApplicationPage implements PageLayoutBuilder, PageComponentListener {

      private JTabbedPane tabbedPane;
      private Map controlToPageComponentMap = new HashMap();
      TabChangeListener tabChangeListener = new TabChangeListener();

      public TabbedPaneApplicationPage(ApplicationWindow window, PageDescriptor pageDescriptor) {
      super(window, pageDescriptor);

      public JComponent getControl() {
      if (tabbedPane == null) {
      this.tabbedPane = new JTabbedPane();
      return tabbedPane;

      class TabChangeListener implements ChangeListener {
      public void stateChanged(ChangeEvent evt){
      //tabbedPane.removeChangeListener(tabChangeListener) ;
      int index = tabbedPane.getSelectedIndex();
      if (index != -1) {
      PageComponent pageComponent = (PageComponent)controlToPageComponentMap.get(tabbe dPane.getComponentAt(index));
      if (pageComponent != null)

      protected boolean giveFocusTo(PageComponent pageComponent) {
      PageComponentPane pane = pageComponent.getContext().getPane();
      tabbedPane.setSelectedComponent(pane.getControl()) ;
      return true;

      // Initial Application Page Layout Builder methods
      public void addView(String viewDescriptorId) {

      // the pagecomponent to show must have viewdescriptor set in
      public void showView(PageComponent theComponent) {
      if (!getPageComponents().contains(theComponent)) {
      theComponent.setContext(new DefaultViewContext(this, new CustomPageComponentPane(theComponent)));

      * Implementing PageComponentListener
      public void componentOpened(PageComponent component) {
      PageComponentPane pane = component.getContext().getPane();
      tabbedPane.addTab(pane.getPageComponent().getId(), pane.getControl());
      controlToPageComponentMap.put(pane.getControl(), pane.getPageComponent());

      public void componentClosed(PageComponent component) {
      if (component instanceof Saveable) {
      Saveable saveable = (Saveable)component;
      if (saveable.isDirty());
      PageComponentPane pane = component.getContext().getPane();
      controlToPageComponentMap.remove(pane.getControl() );

      public void componentFocusGained(PageComponent component) {

      public void componentFocusLost(PageComponent component) {



      • #4
        i'm bubbling this back to the top to see if anyone else has an idea on how to implement this? The TabbedPaneApplicationPage suggestion does not compile, and the DefaultApplicationWindow suggestion is extremely vague on how to get it to work...


        • #5
          I've never actually done this, but here are some things to consider:

          1. The current DefaultApplicationWindow (DAW) provides a JFrame as the component to hold the view. The specific view implementation determines what it's component is (usually a JPanel).

          2. When the DAW is told to show a specific page (view) it retrieves the view configuration and then replaces the current view component with the new one. This is taking place in the updatePageControl method (as posted by bpolka). Note however that the very first view control is added to the JFrame in the applyCustomLayout method.

          3. DAW normally doesn't have access to the complete list of view ids, it just responds to requests to display a given view by id. So, you'll need to provide some mechanism to inject (or determined at runtime) the list of view ids so you can consruct a tabbed pane with the appropriate tabs.

          4. YOu'll need to modify the initial JFrame layout in order to insert your new tabbed pane instead of the initial page control directly.

          5. You'll need to decide if you want to pre-instantiate all your views or if you want to do a lazy instantiation when the page is requested. I would recommend a lazy instantiation of the view controls just to minimize startup time and also decrease the volume of code changes.

          6. Finally, in the updatePageControl method, you'll need to select the tab appropriate for the page to be displayed and lazily instantiate it if needed.

          Note that all the above is untested, just a summary of how it ought to work. You'll no doubt have to make some changes to what I've suggested.

          I hope that helps,