Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 312271 | Differences between
and this patch

Collapse All | Expand All

(-)src/org/eclipse/rap/internal/design/example/stacks/ViewStackPresentation.java (-27 / +35 lines)
Lines 436-442 Link Here
436
436
437
      }
437
      }
438
    } );
438
    } );
439
440
    Composite corner = new Composite( buttonArea, SWT.NONE );
439
    Composite corner = new Composite( buttonArea, SWT.NONE );
441
    corner.setData( WidgetUtil.CUSTOM_VARIANT, "compTrans" );
440
    corner.setData( WidgetUtil.CUSTOM_VARIANT, "compTrans" );
442
    corner.setLayout( new FormLayout() );
441
    corner.setLayout( new FormLayout() );
Lines 493-499 Link Here
493
      buttonArea.setBackground( bg );
492
      buttonArea.setBackground( bg );
494
      Control[] children = buttonArea.getChildren();
493
      Control[] children = buttonArea.getChildren();
495
      buttonArea.setLayout( new FormLayout() );
494
      buttonArea.setLayout( new FormLayout() );
496
497
      for( int i = 0; i < children.length; i++ ) {
495
      for( int i = 0; i < children.length; i++ ) {
498
        Control child = children[ i ];
496
        Control child = children[ i ];
499
        if( child instanceof Button ) {
497
        if( child instanceof Button ) {
Lines 541-550 Link Here
541
        }
539
        }
542
      }
540
      }
543
      buttonArea.getParent().layout();
541
      buttonArea.getParent().layout();
542
      preventButtonOfOverflow();
544
    }
543
    }
545
544
546
  }
545
  }
547
546
547
  private void preventButtonOfOverflow() {
548
    if( isOverflowNecessary() ) {
549
      showPartButton( currentPart );
550
    }
551
  } 
552
548
  private void checkHideSeparator( final Composite buttonArea ) {
553
  private void checkHideSeparator( final Composite buttonArea ) {
549
    int indexOf = buttonList.indexOf( buttonArea );
554
    int indexOf = buttonList.indexOf( buttonArea );
550
    for( int i = 0; i < buttonList.size(); i++ ) {
555
    for( int i = 0; i < buttonList.size(); i++ ) {
Lines 618-624 Link Here
618
      fdTabBg.top = new FormAttachment( 0 );
623
      fdTabBg.top = new FormAttachment( 0 );
619
      fdTabBg.bottom = new FormAttachment( 100 );
624
      fdTabBg.bottom = new FormAttachment( 100 );
620
      createConfArea( fdTabBg );
625
      createConfArea( fdTabBg );
621
622
      FormData fdLayout
626
      FormData fdLayout
623
        = stackBuilder.getPosition( ILayoutSetConstants.STACK_TABBG_POS );
627
        = stackBuilder.getPosition( ILayoutSetConstants.STACK_TABBG_POS );
624
      RowLayout layout = new RowLayout( SWT.HORIZONTAL );
628
      RowLayout layout = new RowLayout( SWT.HORIZONTAL );
Lines 646-655 Link Here
646
  }
650
  }
647
651
648
  private void manageOverflow() {
652
  private void manageOverflow() {
649
    int tabChildrenSize = getTabChildrenSize();
653
    if( isOverflowNecessary() ) {
650
    if( tabChildrenSize > tabBg.getBounds().width
651
        && moreThanOneChildVisible() )
652
    {
653
      hideLastVisibleButton();
654
      hideLastVisibleButton();
654
      manageOverflow();
655
      manageOverflow();
655
    } else {
656
    } else {
Lines 657-662 Link Here
657
    }
658
    }
658
    handleOverflowButton();
659
    handleOverflowButton();
659
  }
660
  }
661
  
662
  private boolean isOverflowNecessary() {
663
    int tabChildrenSize = getTabChildrenSize();
664
    boolean childrenBiggerThanParent 
665
      = tabChildrenSize > tabBg.getBounds().width;
666
    return childrenBiggerThanParent && moreThanOneChildVisible(); 
667
  }
660
668
661
  private boolean moreThanOneChildVisible() {
669
  private boolean moreThanOneChildVisible() {
662
    boolean result = false;
670
    boolean result = false;
Lines 712-724 Link Here
712
      Object obj = buttonPartMap.get( overflowButtons.get( i ) );
720
      Object obj = buttonPartMap.get( overflowButtons.get( i ) );
713
      final IPresentablePart part = ( IPresentablePart ) obj;
721
      final IPresentablePart part = ( IPresentablePart ) obj;
714
      MenuItem item = new MenuItem( overflowMenu, SWT.PUSH );
722
      MenuItem item = new MenuItem( overflowMenu, SWT.PUSH );
715
      item.setText( part.getName() );
723
      if( part != null ) {
716
      item.addSelectionListener( new SelectionAdapter() {
724
        item.setText( part.getName() );      
717
        public void widgetSelected( final SelectionEvent e ) {
725
        item.addSelectionListener( new SelectionAdapter() {
718
          activatePart( part );
726
          public void widgetSelected( final SelectionEvent e ) {
719
          showPartButton( part );
727
            activatePart( part );
720
        };
728
            showPartButton( part );
721
      } );
729
          };
730
        } );
731
      }
722
    }
732
    }
723
    // show popup
733
    // show popup
724
    overflowButton.setMenu( overflowMenu );
734
    overflowButton.setMenu( overflowMenu );
Lines 808-814 Link Here
808
            if( i > 0 ) {
818
            if( i > 0 ) {
809
              children[ i - 1 ].setVisible( false );
819
              children[ i - 1 ].setVisible( false );
810
              result = children[ i - 1 ];
820
              result = children[ i - 1 ];
811
              overflowButtons.add( children[ i - 1 ] );
821
              if( !overflowButtons.contains( children[ i - 1 ] ) ) {
822
                overflowButtons.add( children[ i - 1 ] );
823
              }
812
              children[ i ].moveAbove( children[ i - 1 ] );
824
              children[ i ].moveAbove( children[ i - 1 ] );
813
            }
825
            }
814
          } else {
826
          } else {
Lines 817-825 Link Here
817
            overflowButtons.add( children[ i ] );
829
            overflowButtons.add( children[ i ] );
818
          }
830
          }
819
          lastChildHidden = true;
831
          lastChildHidden = true;
820
  
832
          tabBg.layout( true, true );  
821
          tabBg.layout( true, true );
822
  
823
        }
833
        }
824
      }
834
      }
825
    }
835
    }
Lines 874-880 Link Here
874
      fdConfArea.right = new FormAttachment( 100 );
884
      fdConfArea.right = new FormAttachment( 100 );
875
      fdConfArea.width = 28;
885
      fdConfArea.width = 28;
876
      fdTabBg.right = new FormAttachment( confArea );
886
      fdTabBg.right = new FormAttachment( confArea );
877
878
      confCorner = new Label( confArea, SWT.NONE );
887
      confCorner = new Label( confArea, SWT.NONE );
879
      Image cornerImage
888
      Image cornerImage
880
        = stackBuilder.getImage( ILayoutSetConstants.STACK_INACTIVE_CORNER );
889
        = stackBuilder.getImage( ILayoutSetConstants.STACK_INACTIVE_CORNER );
Lines 884-890 Link Here
884
      fdCorner.left = new FormAttachment( 0 );
893
      fdCorner.left = new FormAttachment( 0 );
885
      fdCorner.top = new FormAttachment( 0 );
894
      fdCorner.top = new FormAttachment( 0 );
886
      fdCorner.bottom = new FormAttachment( 100 );
895
      fdCorner.bottom = new FormAttachment( 100 );
887
888
      confButton = new Button( confArea, SWT.PUSH );
896
      confButton = new Button( confArea, SWT.PUSH );
889
      Image confImage
897
      Image confImage
890
        = stackBuilder.getImage( ILayoutSetConstants.STACK_CONF_INACTIVE );
898
        = stackBuilder.getImage( ILayoutSetConstants.STACK_CONF_INACTIVE );
Lines 923-938 Link Here
923
931
924
  public Control[] getTabList( final IPresentablePart part ) {
932
  public Control[] getTabList( final IPresentablePart part ) {
925
    ArrayList list = new ArrayList();
933
    ArrayList list = new ArrayList();
926
    if (getControl() != null) {
934
    if( getControl() != null ) {
927
        list.add(getControl());
935
      list.add( getControl() );
928
    }
936
    }
929
    if (part.getToolBar() != null) {
937
    if( part.getToolBar() != null ) {
930
        list.add(part.getToolBar());
938
      list.add( part.getToolBar() );
931
    }
939
    }
932
    if (part.getControl() != null) {
940
    if( part.getControl() != null ) {
933
        list.add(part.getControl());
941
      list.add( part.getControl() );
934
    }
942
    }
935
    return (Control[]) list.toArray(new Control[list.size()]);
943
    return ( Control[] )list.toArray( new Control[ list.size() ] );
936
  }
944
  }
937
945
938
  public void removePart( final IPresentablePart oldPart ) {
946
  public void removePart( final IPresentablePart oldPart ) {

Return to bug 312271