Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 346773

Summary: setTopCenterSeparate in ViewForm has changed in behavior
Product: [Eclipse Project] Platform Reporter: aokleung
Component: SWTAssignee: Platform-SWT-Inbox <platform-swt-inbox>
Status: CLOSED WONTFIX QA Contact:
Severity: normal    
Priority: P3 CC: eclipse.felipe, gheorghe, pwebster, remy.suen, shanec
Version: 3.6.2   
Target Milestone: ---   
Hardware: PC   
OS: Windows XP   
Whiteboard: stalebug

Description aokleung CLA 2011-05-20 18:45:52 EDT
Build Identifier: 3.6.2.r362

When I use eclipse 3.4.2, setTopCenterSeparate(true), the center control is centered left if there is enough room, and it will centered left on the next line if there is not enough room.

But in eclipse 3.6.2, setTopCenterSeparate(true), the center control is always leaning to the right. This becomes very ugly when the viewform has only one control, that is, no left control and right control.

Reproducible: Always

Steps to Reproduce:
1. Below is test program to demonstrate the problem

import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.*;
import org.eclipse.swt.graphics.*;
import org.eclipse.swt.layout.*;
import org.eclipse.swt.widgets.*;

public class TestViewForm {
  private Image menuImage;

  public void run() {
    Display display = new Display();
    Shell shell = new Shell(display);
    shell.setText("Look");

    menuImage = new Image(display, this.getClass().getResourceAsStream(
        "test.gif"));

    createContents(shell);
    shell.open();
    while (!shell.isDisposed()) {
      if (!display.readAndDispatch()) {
        display.sleep();
      }
    }

    if (menuImage != null) menuImage.dispose();
    display.dispose();
  }

  public void createContents(Composite parent) {
    parent.setLayout(new GridLayout(1, false));
    final Composite composite = new Composite(parent, SWT.NONE);
    composite.setLayoutData(new GridData(GridData.FILL_BOTH));
    composite.setLayout(new FillLayout());
    createViewFormHelper(composite, "Document");
    composite.layout();
  }

  private void createViewFormHelper(final Composite parent, String text) {
    final ViewForm vf = new ViewForm(parent, SWT.BORDER);

//     CLabel label = new CLabel(vf, SWT.NONE);
//    label.setText(text);
//    label.setAlignment(SWT.LEFT);
//    vf.setTopLeft(label);

    final ToolBar tbMenu = new ToolBar(vf, SWT.FLAT | SWT.WRAP);
    final ToolItem itemMenu = new ToolItem(tbMenu, SWT.PUSH);
    itemMenu.setImage(menuImage);
    
    final ToolItem itemMenu2 = new ToolItem(tbMenu, SWT.PUSH);
    itemMenu2.setImage(menuImage);
    
    final ToolItem itemMenu3 = new ToolItem(tbMenu, SWT.PUSH);
    itemMenu3.setImage(menuImage);
    
    final ToolItem itemMenu4 = new ToolItem(tbMenu, SWT.PUSH);
    itemMenu4.setImage(menuImage);
    
    final ToolItem itemMenu5 = new ToolItem(tbMenu, SWT.PUSH);
    itemMenu5.setImage(menuImage);
    
    final ToolItem itemMenu6 = new ToolItem(tbMenu, SWT.PUSH);
    itemMenu6.setImage(menuImage);
    
    final ToolItem itemMenu7 = new ToolItem(tbMenu, SWT.PUSH);
    itemMenu7.setImage(menuImage);
    
    final ToolItem itemMenu8 = new ToolItem(tbMenu, SWT.PUSH);
    itemMenu8.setImage(menuImage);
    
    vf.setTopCenter(tbMenu);
    vf.setTopCenterSeparate(true);

//    ToolBar tbClose = new ToolBar(vf, SWT.FLAT);
//    ToolItem itemClose = new ToolItem(tbClose, SWT.PUSH);
//    itemClose.setText("X");
//    itemClose.addSelectionListener(new SelectionAdapter() {
//      public void widgetSelected(SelectionEvent event) {
//        vf.dispose();
//        parent.layout();
//      }
//    });
//    vf.setTopRight(tbClose);
    final Text textArea = new Text(vf, SWT.MULTI | SWT.WRAP | SWT.V_SCROLL);
    vf.setContent(textArea);
  }

  public static void main(String[] args) {
    new TestViewForm().run();
  }
}
Comment 1 Eclipse Genie CLA 2019-08-31 08:36:04 EDT
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet.

If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.

--
The automated Eclipse Genie.