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