Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » JFace » ComboViewer Horizontal Layout
ComboViewer Horizontal Layout [message #1417368] Fri, 05 September 2014 09:16 Go to next message
Dennis Melzer is currently offline Dennis MelzerFriend
Messages: 244
Registered: July 2009
Senior Member
Hello,

i have a problem with a ComboViewer and the layout. The ComboViewer should be large as needed to show the hole content ? I don't want to set the width with the minSize, because the content length can change.

Example:
 import org.eclipse.jface.layout.GridDataFactory;
import org.eclipse.jface.viewers.ComboViewer;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Shell;

public class ComboViewerSnippet {

    public static void main(String[] args) {

        // get display.
        Display display = new Display();
        Shell shell = new Shell(display);
        shell.setText("ComboViewerSnippet");
        shell.setSize(200, 200);
        shell.setLayout(new FillLayout(SWT.HORIZONTAL));

        Composite composite = new Composite(shell, SWT.NONE);
        composite.setLayout(new GridLayout(2, false));
        new Label(composite, SWT.NONE).setText("Test");

        ComboViewer viewer = new ComboViewer(composite);
        GridDataFactory.fillDefaults().grab(true, false).applyTo(viewer.getControl());
        viewer.add("Loooooooooooooooong Text");
        viewer.add("890ß Text");
        viewer.add("980ß Text");
        viewer.getCombo().select(0);

        new Label(shell, SWT.NONE).setText("New");
        shell.open();

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

}



Has anyone an idea?

Thanks
Re: ComboViewer Horizontal Layout [message #1417385 is a reply to message #1417368] Fri, 05 September 2014 09:48 Go to previous messageGo to next message
Hussein MHANNA is currently offline Hussein MHANNAFriend
Messages: 45
Registered: February 2014
Location: LAVAL
Member
Hi,

To fix your problem, you must :

1. Replace GridDataFactory.fillDefaults().grab(true, false).applyTo(viewer.getControl()); by viewer.getCombo().setLayoutData(new GridData(GridData.FILL, GridData.BEGINNING, true, false));
2. Optionnaly : Replace shell.setLayout(new FillLayout(SWT.HORIZONTAL)); by shell.setLayout(new FillLayout(SWT.VERTICAL));

Regards,

Hussein


ALL4TEC
Re: ComboViewer Horizontal Layout [message #1417422 is a reply to message #1417385] Fri, 05 September 2014 11:49 Go to previous messageGo to next message
Dennis Melzer is currently offline Dennis MelzerFriend
Messages: 244
Registered: July 2009
Senior Member
Hello,

thanks for your reply:

The first option didn't work Sad
The second option is not possible, because is use the ComboViewer normally in a Toolbar and vertical is not possible Wink
Re: ComboViewer Horizontal Layout [message #1429430 is a reply to message #1417422] Tue, 23 September 2014 08:11 Go to previous message
Dennis Melzer is currently offline Dennis MelzerFriend
Messages: 244
Registered: July 2009
Senior Member
No other ideas?
Previous Topic:Content not displaced in TreeViewer
Next Topic:Need help with Jface in eclipse
Goto Forum:
  


Current Time: Mon Nov 19 18:27:17 GMT 2018

Powered by FUDForum. Page generated in 0.02248 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top