|
Link Here
|
| 1 |
/******************************************************************************* |
| 2 |
* Copyright (c) 2002, 2009 Innoopract Informationssysteme GmbH. |
| 3 |
* All rights reserved. This program and the accompanying materials |
| 4 |
* are made available under the terms of the Eclipse Public License v1.0 |
| 5 |
* which accompanies this distribution, and is available at |
| 6 |
* http://www.eclipse.org/legal/epl-v10.html |
| 7 |
* |
| 8 |
* Contributors: |
| 9 |
* Innoopract Informationssysteme GmbH - initial API and implementation |
| 10 |
* EclipseSource - ongoing development |
| 11 |
******************************************************************************/ |
| 12 |
|
| 13 |
package org.eclipse.rap.demo.controls; |
| 14 |
|
| 15 |
import org.eclipse.rwt.lifecycle.WidgetUtil; |
| 16 |
import org.eclipse.swt.SWT; |
| 17 |
import org.eclipse.swt.custom.CTabFolder; |
| 18 |
import org.eclipse.swt.widgets.*; |
| 19 |
|
| 20 |
public class MenuTab extends ExampleTab { |
| 21 |
|
| 22 |
|
| 23 |
public MenuTab( final CTabFolder folder ) { |
| 24 |
super( folder, "Menu" ); |
| 25 |
} |
| 26 |
|
| 27 |
protected void createStyleControls( final Composite parent ) { |
| 28 |
} |
| 29 |
|
| 30 |
protected void createExampleControls( final Composite parent ) { |
| 31 |
// Set a context menu |
| 32 |
Menu menu = new Menu( parent ); |
| 33 |
MenuItem itemDefault = new MenuItem( menu, SWT.CASCADE ); |
| 34 |
itemDefault.setMenu( new Menu( itemDefault ) ); |
| 35 |
itemDefault.setText( "default" ); |
| 36 |
for( int i = 0; i < 5; i++ ) { |
| 37 |
MenuItem item = new MenuItem( itemDefault.getMenu(), SWT.PUSH ); |
| 38 |
item.setText( "default Item " + ( i + 1 ) ); |
| 39 |
} |
| 40 |
|
| 41 |
MenuItem itemFancy = new MenuItem( menu, SWT.CASCADE ); |
| 42 |
itemFancy.setMenu( new Menu( itemFancy ) ); |
| 43 |
itemFancy.setText( "fancy" ); |
| 44 |
itemFancy.setData( WidgetUtil.CUSTOM_VARIANT, "fancy" ); |
| 45 |
for( int i = 0; i < 5; i++ ) { |
| 46 |
MenuItem item = new MenuItem( itemFancy.getMenu(), SWT.PUSH ); |
| 47 |
item.setText( "fancy Item " + ( i + 1 ) ); |
| 48 |
item.setData( WidgetUtil.CUSTOM_VARIANT, "fancy" ); |
| 49 |
} |
| 50 |
|
| 51 |
parent.setMenu( menu ); |
| 52 |
} |
| 53 |
|
| 54 |
} |