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.layout.RowData; 23 import org.eclipse.swt.layout.RowLayout; 24 import org.eclipse.swt.widgets.Composite; 25 import org.eclipse.swt.widgets.Display; 26 import org.eclipse.swt.widgets.Label; 27 import org.eclipse.swt.widgets.Shell; 28 import org.eclipse.swt.widgets.ToolBar; 29 import org.eclipse.swt.widgets.ToolItem; 30 31 public class Bug443185_ToolbarTestRowLayout { 32 main(String[] args)33 public static void main(String[] args) { 34 Display display = new Display(); 35 Shell shell = new Shell(display); 36 shell.setSize(200, 400); 37 shell.setLayout(new GridLayout()); 38 39 // Create the tabs 40 CTabFolder tabFolder = new CTabFolder(shell, SWT.TOP|SWT.BORDER); 41 tabFolder.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true) ); 42 tabFolder.setMaximizeVisible(true); 43 tabFolder.setMinimizeVisible(true); 44 45 CTabItem item=new CTabItem(tabFolder, SWT.BORDER); 46 item.setText("Tab (1)"); 47 item.setShowClose(true); 48 Label content=new Label(tabFolder,SWT.NONE); 49 content.setText("bla"); 50 item.setControl(content); 51 52 Composite composite = new Composite(tabFolder, SWT.NONE); 53 composite.setLayout(new RowLayout()); 54 55 56 ToolBar toolBar=new ToolBar(composite, SWT.FLAT|SWT.RIGHT|SWT.WRAP); 57 toolBar.setLayoutData(new RowData()); 58 for(int i=0;i<15;i++){ 59 ToolItem toolItem=new ToolItem(toolBar, SWT.PUSH); 60 toolItem.setText("test_"+i); 61 if(i%5==0){ 62 new ToolItem(toolBar, SWT.SEPARATOR); 63 } 64 } 65 tabFolder.setTopRight(composite ,SWT.RIGHT | SWT.WRAP); 66 67 68 //SWT Loop 69 shell.open(); 70 while (!shell.isDisposed()) { 71 if (!display.readAndDispatch()) 72 { 73 display.sleep(); 74 } 75 } 76 display.dispose(); 77 } 78 79 }