1 /*******************************************************************************
2  * Copyright (c) 2018 Red Hat and others.
3  *
4  * This program and the accompanying materials
5  * are made available under the terms of the Eclipse Public License 2.0
6  * which accompanies this distribution, and is available at
7  * https://www.eclipse.org/legal/epl-2.0/
8  *
9  * SPDX-License-Identifier: EPL-2.0
10  *
11  * Contributors:
12  *     Red Hat - initial API and implementation
13  *******************************************************************************/
14 package org.eclipse.swt.tests.gtk.snippets;
15 
16 
17 import org.eclipse.swt.SWT;
18 import org.eclipse.swt.custom.CTabFolder;
19 import org.eclipse.swt.custom.CTabItem;
20 import org.eclipse.swt.layout.GridData;
21 import org.eclipse.swt.layout.GridLayout;
22 import org.eclipse.swt.widgets.Composite;
23 import org.eclipse.swt.widgets.Display;
24 import org.eclipse.swt.widgets.Label;
25 import org.eclipse.swt.widgets.Shell;
26 import org.eclipse.swt.widgets.ToolBar;
27 import org.eclipse.swt.widgets.ToolItem;
28 
29 public class Bug443185_ToolbarTestGridLayout {
30 
main(String[] args)31 	public static void main(String[] args) {
32 		Display display = new Display();
33 		Shell shell = new Shell(display);
34 		shell.setSize(200, 400);
35 		shell.setLayout(new GridLayout());
36 
37 		// Create the tabs
38 		CTabFolder tabFolder = new CTabFolder(shell, SWT.TOP|SWT.BORDER);
39 		tabFolder.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true) );
40 		tabFolder.setMaximizeVisible(true);
41 		tabFolder.setMinimizeVisible(true);
42 
43 		CTabItem item=new CTabItem(tabFolder, SWT.BORDER);
44 		item.setText("Tab (1)");
45 		item.setShowClose(true);
46 		Label content=new Label(tabFolder,SWT.NONE);
47 		content.setText("bla");
48 		item.setControl(content);
49 
50 		Composite composite = new Composite(tabFolder, SWT.NONE);
51 		composite.setLayout(new GridLayout());
52 
53 
54 		ToolBar toolBar=new ToolBar(composite, SWT.FLAT|SWT.RIGHT|SWT.WRAP);
55 		toolBar.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
56 		for(int i=0;i<15;i++){
57 			ToolItem toolItem=new ToolItem(toolBar, SWT.PUSH);
58 			toolItem.setText("test_"+i);
59 			if(i%5==0){
60 				new ToolItem(toolBar, SWT.SEPARATOR);
61 			}
62 		}
63 		tabFolder.setTopRight(composite,SWT.RIGHT | SWT.WRAP);
64 
65 
66 		//SWT Loop
67 		shell.open();
68 		while (!shell.isDisposed()) {
69 			if (!display.readAndDispatch())
70 			{
71 				display.sleep();
72 			}
73 		}
74 		display.dispose();
75 	}
76 
77 }