org.eclipse.swt.widgets.Shell#setLayout ( )源码实例Demo

下面列出了org.eclipse.swt.widgets.Shell#setLayout ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: nebula   文件: RichTextEditorExample.java
public static void main(String[] args) {
	Display display = new Display();

	final Shell shell = new Shell(display);
	shell.setText("SWT Rich Text Editor example");
	shell.setSize(800, 600);

	shell.setLayout(new GridLayout(1, true));

	RichTextEditorExample example = new RichTextEditorExample();
	example.createControls(shell);

	shell.open();
	while (!shell.isDisposed()) {
		if (!display.readAndDispatch())
			display.sleep();
	}
	display.dispose();
}
 
源代码2 项目: eclipse-cs   文件: SWTUtil.java
/**
 * @see org.eclipse.swt.events.MouseListener#mouseDown(org.eclipse.swt.events.MouseEvent)
 */
@Override
public void mouseDown(MouseEvent e) {
  Control theControl = (Control) e.widget;

  Display display = theControl.getDisplay();
  Shell tip = new Shell(theControl.getShell(), SWT.ON_TOP | SWT.TOOL);
  tip.setBackground(display.getSystemColor(SWT.COLOR_INFO_BACKGROUND));
  FillLayout layout = new FillLayout();
  layout.marginHeight = 1;
  layout.marginWidth = 2;
  tip.setLayout(layout);
  Label label = new Label(tip, SWT.NONE);
  label.setForeground(display.getSystemColor(SWT.COLOR_INFO_FOREGROUND));
  label.setBackground(display.getSystemColor(SWT.COLOR_INFO_BACKGROUND));

  label.setText(theControl.getToolTipText());
  label.addMouseTrackListener(this);
  Point size = tip.computeSize(SWT.DEFAULT, SWT.DEFAULT);
  Rectangle rect = theControl.getBounds();
  Point pt = theControl.getParent().toDisplay(rect.x, rect.y);
  tip.setBounds(pt.x, pt.y, size.x, size.y);
  tip.setVisible(true);
}
 
源代码3 项目: buffer_bci   文件: SWTTimeSeriesDemo.java
/**
 * Starting point for the demonstration application.
 *
 * @param args  ignored.
 */
public static void main(String[] args) {
    final JFreeChart chart = createChart(createDataset());
    final Display display = new Display();
    Shell shell = new Shell(display);
    shell.setSize(600, 300);
    shell.setLayout(new FillLayout());
    shell.setText("Time series demo for jfreechart running with SWT");
    ChartComposite frame = new ChartComposite(shell, SWT.NONE, chart, true);
    frame.setDisplayToolTips(true);
    frame.setHorizontalAxisTrace(false);
    frame.setVerticalAxisTrace(false);
    shell.open();
    while (!shell.isDisposed()) {
        if (!display.readAndDispatch())
            display.sleep();
    }
}
 
源代码4 项目: nebula   文件: CDTSnippet08.java
/**
 * @param args
 */
public static void main(String[] args) {
	final Display display = new Display();
	final Shell shell = new Shell(display);
	shell.setText("CDateTime");
	shell.setLayout(new GridLayout(3, true));

	final CDateTime date = new CDateTime(shell, CDT.BORDER | CDT.DROP_DOWN);
	date.setNullText("<day>");
	date.setPattern("dd");
	date.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false));

	final CDateTime month = new CDateTime(shell, CDT.BORDER | CDT.DROP_DOWN);
	month.setNullText("<month>");
	month.setPattern("MMMM");
	month.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false));

	final CDateTime year = new CDateTime(shell, CDT.BORDER | CDT.DROP_DOWN);
	year.setNullText("<year>");
	year.setPattern("yyyy");
	year.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false));

	shell.pack();
	Point size = shell.getSize();
	Rectangle screen = display.getMonitors()[0].getBounds();
	shell.setBounds(
			(screen.width-size.x)/2,
			(screen.height-size.y)/2,
			size.x,
			size.y
	);
	shell.open();
	while (!shell.isDisposed()) {
		if (!display.readAndDispatch())
			display.sleep();
	}
	display.dispose();
}
 
源代码5 项目: gef   文件: JFaceFontsExample.java
public static void main(String[] args) {
	Display d = new Display();
	Shell shell = new Shell(d);
	shell.setLayout(new FillLayout(SWT.VERTICAL));
	shell.setSize(400, 400);
	Button button = new Button(shell, SWT.PUSH);
	button.setText("Reload");
	button.addSelectionListener(new SelectionAdapter() {
		public void widgetSelected(SelectionEvent e) {
			viewer.setInput(null);
			viewer.setInput(new Object());
		}
	});

	viewer = new ZestContentViewer(new ZestFxJFaceModule());
	viewer.createControl(shell, SWT.NONE);
	viewer.setContentProvider(new MyContentProvider());
	viewer.setLabelProvider(new MyLabelProvider());
	viewer.setLayoutAlgorithm(new SpringLayoutAlgorithm());
	viewer.addSelectionChangedListener(new ISelectionChangedListener() {
		public void selectionChanged(SelectionChangedEvent event) {
			System.out.println(
					"Selection changed: " + (event.getSelection()));
		}
	});
	viewer.setInput(new Object());

	shell.open();
	while (!shell.isDisposed()) {
		while (!d.readAndDispatch()) {
			d.sleep();
		}
	}
}
 
源代码6 项目: e4macs   文件: BufferDialog.java
void showTip(String txt, ItemPkg tp, Table table)  {
	tip = new Shell((Shell) null, SWT.ON_TOP | SWT.TOOL);
	tip.setLayout(new FillLayout());
	tip.setBackground(table.getBackground());
	createBufferTip(tip, (IEditorReference)getSelectables().get(txt));
	Point size = tip.computeSize(SWT.DEFAULT, SWT.DEFAULT);
	Rectangle rect = tp.getBounds();
	Point pt = table.toDisplay(rect.x + getSizeAdjustment(), rect.y
			- size.y);
	tip.setBounds(pt.x, pt.y, size.x, size.y);
	tip.setVisible(true);
}
 
源代码7 项目: nebula   文件: ReparentComboTest.java
@Before
@Override
protected void setUp() throws Exception {
	combo = new MorePublicBaseCombo(getShell(), SWT.BORDER | SWT.DROP_DOWN);
	Label lbl = new Label(combo, 0);
	lbl.setText("hello world");
	combo.setContent(lbl);
	combo.getButton().setPaintInactive(true);

	shell2 = new Shell();
	shell2.setText("Shell2");
	shell2.setLayout(new FillLayout());
}
 
源代码8 项目: birt   文件: Chart3DViewer.java
/**
 * execute application
 * 
 * @param args
 */
public static void main( String[] args )
{
	Display display = Display.getDefault( );
	Shell shell = new Shell( display );
	shell.setSize( 600, 400 );
	shell.setLayout( new GridLayout( ) );

	Chart3DViewer c3dViewer = new Chart3DViewer( shell, SWT.NO_BACKGROUND );
	c3dViewer.setLayoutData( new GridData( GridData.FILL_BOTH ) );
	c3dViewer.addPaintListener( c3dViewer );

	Composite cBottom = new Composite( shell, SWT.NONE );
	cBottom.setLayoutData( new GridData( GridData.FILL_HORIZONTAL ) );
	cBottom.setLayout( new RowLayout( ) );

	Label la = new Label( cBottom, SWT.NONE );

	la.setText( "&Choose: " );//$NON-NLS-1$
	cbType = new Combo( cBottom, SWT.DROP_DOWN | SWT.READ_ONLY );
	cbType.add( "3D Bar Chart" ); //$NON-NLS-1$
	cbType.add( "3D Line Chart" );//$NON-NLS-1$
	cbType.add( "3D Area Chart" );//$NON-NLS-1$
	cbType.select( 0 );

	btn = new Button( cBottom, SWT.NONE );
	btn.setText( "&Update" );//$NON-NLS-1$
	btn.addSelectionListener( c3dViewer );
	btn.setToolTipText( "Update" );//$NON-NLS-1$
	
	shell.open( );
	while ( !shell.isDisposed( ) )
	{
		if ( !display.readAndDispatch( ) )
			display.sleep( );
	}
	display.dispose( );
}
 
源代码9 项目: nebula   文件: GridViewerSnippet2.java
public static void main(String[] args) {
	Display display = new Display();
	Shell shell = new Shell(display);
	shell.setLayout(new FillLayout());
	new GridViewerSnippet2(shell);
	shell.open();

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

	display.dispose();
}
 
源代码10 项目: nebula   文件: CarouselSnippet.java
/**
 * @param args
 */
public static void main(final String[] args) {
	final Display display = new Display();
	shell = new Shell(display);
	shell.setText("Carousel Snippet");
	shell.setLayout(new FillLayout());
	shell.setBackground(display.getSystemColor(SWT.COLOR_WHITE));

	final Carousel carousel = new Carousel(shell, SWT.NONE);
	carousel.addImage(loadImage("images/first.png"));
	carousel.addImage(loadImage("images/second.jpg"));
	carousel.addImage(loadImage("images/third.png"));

	final Listener listener = event -> {
		System.out.println("Click on " + carousel.getSelection());
	};
	carousel.addListener(SWT.Selection, listener);

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

	display.dispose();

}
 
源代码11 项目: nebula   文件: NoBeepSoundFormatterSnippet.java
public static void main(String[] args) {
	Display display = new Display();
   Shell shell = new Shell(display);
   shell.setLayout(new GridLayout());

   final FormattedText text = new FormattedText(shell, SWT.BORDER);
   text.setFormatter(new DateFormatter());
   GridData data = new GridData();
   data.widthHint = 70;
   text.getControl().setLayoutData(data);

   Button toggleBeep = new Button(shell, SWT.PUSH);
   toggleBeep.setText("Toggle beep sound");
   toggleBeep.addSelectionListener(new SelectionAdapter() {
		@Override
		public void widgetSelected(SelectionEvent e) {
			FormattedText.setBeepSound(! FormattedText.isBeepSound());
			text.getControl().setFocus();
		}
   });

   shell.open();
   while ( ! shell.isDisposed() ) {
   	if (!display.readAndDispatch()) display.sleep();
   }
   display.dispose();
}
 
源代码12 项目: swt-bling   文件: PopOverCompositeExample.java
public void run(Display display, Shell shell) {
  shell.setLayout(new FillLayout());
  Button button = new Button(shell, SWT.PUSH);
  button.setText("Open PopOverComposite");

  final PopOverComposite popOverComposite = PopOverComposite.createPopOverComposite(button);
  button.addSelectionListener(new SelectionAdapter() {
    public void widgetSelected(SelectionEvent e) {
      popOverComposite.toggle();
    }
  });

  Composite composite = new Composite(popOverComposite.getPopOverCompositeShell(), SWT.NONE);
  composite.setLayout(new GridLayout(2, false));

  Image iconInformation = display.getSystemImage(SWT.ICON_INFORMATION);
  Image iconError = display.getSystemImage(SWT.ICON_ERROR);
  Image iconWarning = display.getSystemImage(SWT.ICON_WARNING);

  new SquareButton.SquareButtonBuilder()
          .setImage(iconInformation)
          .setImagePosition(SquareButton.ImagePosition.LEFT_OF_TEXT)
          .setText("This button provides you with some information.")
          .setParent(composite)
          .build();

  new SquareButton.SquareButtonBuilder()
          .setImage(iconWarning)
          .setImagePosition(SquareButton.ImagePosition.LEFT_OF_TEXT)
          .setText("You should be cautious clicking this button.")
          .setParent(composite)
          .build();

  new SquareButton.SquareButtonBuilder()
          .setImage(iconError)
          .setImagePosition(SquareButton.ImagePosition.LEFT_OF_TEXT)
          .setText("This button will produce an error.")
          .setParent(composite)
          .build();

  new SquareButton.SquareButtonBuilder()
          .setImage(iconError)
          .setImagePosition(SquareButton.ImagePosition.LEFT_OF_TEXT)
          .setText("This button is bad news.")
          .setParent(composite)
          .build();

  popOverComposite.setComposite(composite);

  shell.pack();
  shell.open();
}
 
源代码13 项目: Flashtool   文件: USBLogviewer.java
/**
 * Create contents of the dialog.
 */
private void createContents() {
	shlUSBLogviewer = new Shell(getParent(), getStyle());
	shlUSBLogviewer.setSize(710, 475);
	shlUSBLogviewer.setText("USB Log Viewer");
	shlUSBLogviewer.setLayout(new FormLayout());
	
	btnClose = new Button(shlUSBLogviewer, SWT.NONE);
	FormData fd_btnClose = new FormData();
	fd_btnClose.bottom = new FormAttachment(100, -10);
	fd_btnClose.right = new FormAttachment(100, -10);
	btnClose.setLayoutData(fd_btnClose);
	btnClose.setText("Close");
	
	compositeTable = new Composite(shlUSBLogviewer, SWT.NONE);
	compositeTable.setLayout(new FillLayout(SWT.HORIZONTAL));
	FormData fd_compositeTable = new FormData();
	
	fd_compositeTable.right = new FormAttachment(100, -10);
	fd_compositeTable.left = new FormAttachment(0, 10);
	fd_compositeTable.bottom = new FormAttachment(btnClose, -6);
	compositeTable.setLayoutData(fd_compositeTable);
	
	tableViewer = new TableViewer(compositeTable,SWT.FULL_SELECTION | SWT.V_SCROLL | SWT.H_SCROLL | SWT.BORDER | SWT.SINGLE);
	tableViewer.setContentProvider(new VectorContentProvider());
	tableViewer.setLabelProvider(new VectorLabelProvider());

	table = tableViewer.getTable();
	TableColumn[] columns = new TableColumn[2];
	columns[0] = new TableColumn(table, SWT.NONE);
	columns[0].setText("Action");
	columns[1] = new TableColumn(table, SWT.NONE);
	columns[1].setText("Parameter");
	table.setHeaderVisible(true);
	table.setLinesVisible(true);
	TableSorter sort = new TableSorter(tableViewer);
	Composite compositeSource = new Composite(shlUSBLogviewer, SWT.NONE);
	compositeSource.setLayout(new GridLayout(3, false));
	FormData fd_compositeSource = new FormData();
	fd_compositeSource.top = new FormAttachment(0, 10);
	fd_compositeSource.left = new FormAttachment(0, 10);
	fd_compositeSource.right = new FormAttachment(100, -10);
	compositeSource.setLayoutData(fd_compositeSource);
	
	fd_compositeTable.top = new FormAttachment(compositeSource, 6);
	
	lblLogfile = new Label(compositeSource, SWT.BORDER);
	lblLogfile.setText("USB Log file :");
	
	textLogFile = new Text(compositeSource, SWT.BORDER);
	textLogFile.setEditable(false);
	GridData gd_textLogFile = new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1);
	gd_textLogFile.widthHint = 471;
	textLogFile.setLayoutData(gd_textLogFile);
	
	btnLogFile = new Button(compositeSource, SWT.NONE);
	btnLogFile.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
	btnLogFile.setText("...");
	
	Label lblSinfolder = new Label(compositeSource, SWT.NONE);
	GridData gd_lblSinfolder = new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1);
	gd_lblSinfolder.widthHint = 110;
	lblSinfolder.setLayoutData(gd_lblSinfolder);
	lblSinfolder.setText("Source folder :");
	
	textSinFolder = new Text(compositeSource, SWT.BORDER);
	textSinFolder.setEditable(false);
	GridData gd_textSinFolder = new GridData(SWT.CENTER, SWT.CENTER, false, false, 1, 1);
	gd_textSinFolder.widthHint = 509;
	textSinFolder.setLayoutData(gd_textSinFolder);
	
	btnSourceFolder = new Button(compositeSource, SWT.NONE);
	GridData gd_btnSourceFolder = new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1);
	gd_btnSourceFolder.widthHint = 46;
	btnSourceFolder.setLayoutData(gd_btnSourceFolder);
	btnSourceFolder.setText("...");
	btnParse = new Button(shlUSBLogviewer, SWT.NONE);
	FormData fd_btnParse = new FormData();
	fd_btnParse.bottom = new FormAttachment(100,-10);
	fd_btnParse.right = new FormAttachment(btnClose, -6);
	btnParse.setLayoutData(fd_btnParse);
	btnParse.setText("Parse");

}
 
源代码14 项目: nebula   文件: TestBug387468.java
/**
 *
 * @param args
 */
public static void main(String[] args) {
    Display display = new Display();
    Shell shell = new Shell(display);
    shell.setLayout(new FillLayout());

    Grid grid = new Grid(shell, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL);

    grid.setHeaderVisible(true);
    GridColumn column = new GridColumn(grid, SWT.NONE);
    column.setText("Employee");
    column.setWidth(100);

    GridColumn column2 = new GridColumn(grid, SWT.NONE);
    column2.setText("Company");
    column2.setWidth(100);

    GridItem item1 = new GridItem(grid, SWT.NONE);
    item1.setText("Anne");
    item1.setText(1, "Company A");
    item1.setRowSpan(1, 2);

    GridItem item2 = new GridItem(grid, SWT.NONE);
    item2.setText("Jim");
    item1.setText(1, "Company A");
    item2.setRowSpan(1, 2);

    GridItem item3 = new GridItem(grid, SWT.NONE);
    item3.setText("Sara");
    item3.setText(1, "Company A");
    item3.setRowSpan(1, 2);

    GridItem item4 = new GridItem(grid, SWT.NONE);
    item4.setText("Tom");
    item4.setText(1, "Company B");
    item4.setRowSpan(1, 1);

    GridItem item5 = new GridItem(grid, SWT.NONE);
    item5.setText("Nathalie");
    item5.setText(1, "Company B");
    item5.setRowSpan(1, 1);

    GridItem item6 = new GridItem(grid, SWT.NONE);
    item6.setText("Wim");
    item6.setText(1, "Company C");
    item6.setRowSpan(1, 1);

    GridItem item7 = new GridItem(grid, SWT.NONE);
    item7.setText("Pauline");
    item7.setText(1, "Company C");
    item7.setRowSpan(1, 1);

    shell.setSize(300, 300);
    shell.open();

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

    display.dispose();
}
 
源代码15 项目: tmxeditor8   文件: InnerTag.java
/**
 * 各种标记绘制样式效果。
 * @param args
 *            ;
 */
public static void main(String[] args) {
	Display display = new Display();
	Shell shell = new Shell(display);
	shell.setSize(800, 600);
	GridLayout gl = new GridLayout();
	shell.setLayout(gl);
	//
	// Color borderColor = new Color(display, 0, 255, 255);
	// Color textBgColor = new Color(display, 0, 205, 205);
	// Color indexBgColor = new Color(display, 0, 139, 139);
	// Color textFgColor = new Color(display, 0, 104, 139);
	// Color indexFgColor = borderColor;
	//
	// Font font = new Font(Display.getDefault(), "Arial", 8, SWT.BOLD);
	//
	// InnerTag tag1 = new InnerTag(shell, SWT.NONE, "<ph id=\"1\" />&lt;this&gt;&amp; is a ph text.</ph>", "ph",
	// 4333,
	// STANDALONE, FULL);
	// tag1.initColor(textFgColor, textBgColor, indexFgColor, indexBgColor, borderColor);
	// tag1.setFont(font);
	// tag1.pack();
	//
	// InnerTag tag2 = new InnerTag(shell, SWT.NONE, "<ph id=\"2\" />this is a ph text.</ph>", "ph", 2, STANDALONE,
	// SIMPLE);
	// tag2.initColor(textFgColor, textBgColor, indexFgColor, indexBgColor, borderColor);
	// tag2.setFont(font);
	// tag2.pack();
	//
	// InnerTag tag3 = new InnerTag(shell, SWT.NONE, "<ph id=\"3\" />this is a ph text.</ph>", "ph", 3, STANDALONE,
	// INDEX);
	// tag3.initColor(textFgColor, textBgColor, indexFgColor, indexBgColor, borderColor);
	// tag3.setFont(font);
	// tag3.pack();
	//
	// InnerTag tag4 = new InnerTag(shell, SWT.NONE, "<bx id=\"1\" />", "bx", 4, START, FULL);
	// tag4.initColor(textFgColor, textBgColor, indexFgColor, indexBgColor, borderColor);
	// tag4.setFont(font);
	// tag4.pack();
	//
	// InnerTag tag5 = new InnerTag(shell, SWT.NONE, "<bx id=\"2\" />", "bx", 5, START, SIMPLE);
	// tag5.initColor(textFgColor, textBgColor, indexFgColor, indexBgColor, borderColor);
	// tag5.setFont(font);
	// tag5.pack();
	//
	// InnerTag tag6 = new InnerTag(shell, SWT.NONE, "<bx id=\"3\" />", "bx", 6, START, INDEX);
	// tag6.initColor(textFgColor, textBgColor, indexFgColor, indexBgColor, borderColor);
	// tag6.setFont(font);
	// tag6.pack();
	//
	// InnerTag tag7 = new InnerTag(shell, SWT.NONE, "<ex id=\"3\" />", "ex", 6, END, INDEX);
	// tag7.initColor(textFgColor, textBgColor, indexFgColor, indexBgColor, borderColor);
	// tag7.setFont(font);
	// tag7.pack();
	//
	// InnerTag tag8 = new InnerTag(shell, SWT.NONE, "<ex id=\"2\" />", "ex", 5, END, SIMPLE);
	// tag8.initColor(textFgColor, textBgColor, indexFgColor, indexBgColor, borderColor);
	// tag8.setFont(font);
	// tag8.pack();
	// //
	// InnerTagControl tag9 = new InnerTagControl(shell, SWT.NONE, "", "", 4, STANDALONE, TagStyle.FULL);
	// tag9.initColor(textFgColor, textBgColor, indexFgColor, indexBgColor, borderColor);
	// tag9.setFont(font);
	// tag9.pack();
	//
	shell.pack();
	shell.open();
	while (!shell.isDisposed()) {
		if (!display.readAndDispatch()) {
			display.sleep();
		}
	}
}
 
源代码16 项目: gef   文件: AbstractExample.java
public AbstractExample(String title, String... infos) {
	Display display = new Display();

	shell = new Shell(display, SWT.SHELL_TRIM | SWT.DOUBLE_BUFFERED);
	shell.setText(title);
	shell.setBounds(0, 0, 640, 480);
	shell.setLayout(new FormLayout());

	if (infos.length > 0) {
		Label infoLabel = new Label(shell, SWT.NONE);
		FormData infoLabelFormData = new FormData();
		infoLabelFormData.right = new FormAttachment(100, -10);
		infoLabelFormData.bottom = new FormAttachment(100, -10);
		infoLabel.setLayoutData(infoLabelFormData);

		String infoText = "You can...";
		for (int i = 0; i < infos.length; i++) {
			infoText += "\n..." + infos[i];
		}
		infoLabel.setText(infoText);
	}

	// open the shell before creating the controllable shapes so that their
	// default coordinates are not changed due to the resize of their canvas
	shell.setBackground(
			Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));
	shell.open();

	viewer = new ControllableShapeViewer(shell);
	for (ControllableShape cs : getControllableShapes()) {
		viewer.addShape(cs);
	}

	onInit();

	shell.addPaintListener(this);
	shell.redraw(); // triggers a PaintEvent platform independently

	while (!shell.isDisposed()) {
		if (!display.readAndDispatch()) {
			display.sleep();
		}
	}
}
 
源代码17 项目: Pydev   文件: HierarchyViewerTest.java
public static Shell open(Display display) {
    final Shell shell = new Shell(display);
    shell.setLayout(new FillLayout());

    HierarchyViewer viewer = new HierarchyViewer();
    viewer.createPartControl(shell);
    HierarchyNodeModel curr = new HierarchyNodeModel("curr");

    final HierarchyNodeModel par1pac1 = new HierarchyNodeModel("par1", "package1", null);
    final HierarchyNodeModel par1 = new HierarchyNodeModel("par1", "pack2", null);
    final HierarchyNodeModel super1 = new HierarchyNodeModel("super1", "pack3", null);
    final HierarchyNodeModel super2 = new HierarchyNodeModel("super2", "pack3", null);
    final HierarchyNodeModel par2 = new HierarchyNodeModel("par2", "pack3", null);
    final HierarchyNodeModel par3 = new HierarchyNodeModel("par3", "pack3", null);

    super1.parents.add(super2);
    super2.parents.add(par1pac1);
    par1.parents.add(super1);
    par1.parents.add(super2);
    par2.parents.add(super1);
    par3.parents.add(super2);

    curr.parents.add(par1);
    curr.parents.add(par2);
    curr.parents.add(par3);

    curr.parents.add(new HierarchyNodeModel("par4"));

    final HierarchyNodeModel c1 = new HierarchyNodeModel("child1", "pack3", null);
    curr.children.add(c1);
    curr.children.add(new HierarchyNodeModel("child2", "pack3", null));
    final HierarchyNodeModel c3 = new HierarchyNodeModel("child3", "pack3", null);
    c3.parents.add(par3); //does not show (we go straight to the top or to the bottom)
    curr.children.add(c3);

    c1.children.add(new HierarchyNodeModel("sub1", "pack3", null));

    viewer.setHierarchy(curr);

    shell.open();
    return shell;
}
 
源代码18 项目: nebula   文件: SnippetSimpleGroupImageHScroll.java
public static void main(String[] args) {
	Display display = new Display();
	Image itemImage = new Image(display, Program.findProgram("jpg") //$NON-NLS-1$
			.getImageData());

	Shell shell = new Shell(display);
	shell.setLayout(new FillLayout());
	Gallery gallery = new Gallery(shell, SWT.H_SCROLL | SWT.MULTI);

	// Renderers
	DefaultGalleryGroupRenderer gr = new DefaultGalleryGroupRenderer();
	gr.setMinMargin(2);
	gr.setItemHeight(56);
	gr.setItemWidth(72);
	gr.setAutoMargin(true);

	gallery.setGroupRenderer(gr);

	DefaultGalleryItemRenderer ir = new DefaultGalleryItemRenderer();
	gallery.setItemRenderer(ir);

	for (int g = 0; g < 3; g++) {
		GalleryItem group = new GalleryItem(gallery, SWT.NONE);
		group.setText("Group " + g); //$NON-NLS-1$
		group.setExpanded(true);
		group.setImage(itemImage);

		if (g > 0)
			group.setText(1, "descr1"); //$NON-NLS-1$

		if (g > 1)
			group.setText(2, "descr2"); //$NON-NLS-1$

		for (int i = 0; i < 50; i++) {
			GalleryItem item = new GalleryItem(group, SWT.NONE);
			if (itemImage != null) {
				item.setImage(itemImage);
			}
			item.setText("Item " + i); //$NON-NLS-1$
		}
	}

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

	if (itemImage != null)
		itemImage.dispose();
	display.dispose();
}
 
源代码19 项目: nebula   文件: TestBug246608.java
public static void main(String[] args) {
	Display display = new Display();
	Shell shell = new Shell(display);
	shell.setLayout(new FillLayout());

	final Grid grid = new Grid(shell, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL);
	grid.setHeaderVisible(true);
	grid.setAutoWidth(true);

	GridColumn column1 = new GridColumn(grid, SWT.NONE);
	column1.setText("Column 1");
	column1.setWidth(150);
	column1.setWordWrap(true);
	column1.setVerticalAlignment(SWT.TOP);

	GridColumn column2 = new GridColumn(grid, SWT.NONE);
	column2.setText("Column 2");
	column2.setWidth(200);
	column2.setWordWrap(true);
	column2.setVerticalAlignment(SWT.CENTER);

	GridColumn column3 = new GridColumn(grid, SWT.NONE);
	column3.setText("Column 3");
	column3.setWidth(200);
	column3.setVerticalAlignment(SWT.BOTTOM);

	GridItem item1 = new GridItem(grid, SWT.NONE);
	item1.setText(0, "Item 1, Column 0: " + MEDIUM_TEXT);
	item1.setText(1, "Item 1, Column 1: " + MEDIUM_TEXT);
	item1.setText(2, "Item 1, Column 2: " + MEDIUM_TEXT);
	item1.setHeight(150);

	GridItem item2 = new GridItem(grid, SWT.NONE);
	item2.setText("Item 2, Columns 0-1: " + MEDIUM_TEXT);
	item2.setColumnSpan(0, 1);
	item2.setText(2, "Item 2, Column 2: Dummy");
	item2.setHeight(100);

	GridItem item3 = new GridItem(grid, SWT.NONE);
	item3.setText(0, "Item 3, Column 0: " + MEDIUM_TEXT);
	item3.setText(1, "Item 3, Column 1: " + MEDIUM_TEXT);
	item3.setText(2, "Item 3, Column 2: Column");
	item3.setHeight(120);

	shell.setSize(600, 500);
	shell.open();
	while (!shell.isDisposed()) {
		if (!display.readAndDispatch())
			display.sleep();
	}
	display.dispose();
}
 
源代码20 项目: nebula   文件: SnippetSimpleListOverlay.java
public static void main(String[] args) {
	Display display = new Display();
	Image[] itemImages = {
			new Image(display, Program.findProgram("jpg").getImageData()), //$NON-NLS-1$
			new Image(display, Program.findProgram("mov").getImageData()), //$NON-NLS-1$
			new Image(display, Program.findProgram("mp3").getImageData()), //$NON-NLS-1$
			new Image(display, Program.findProgram("txt").getImageData()) }; //$NON-NLS-1$

	Shell shell = new Shell(display);
	shell.setLayout(new FillLayout());
	Gallery gallery = new Gallery(shell, SWT.V_SCROLL | SWT.MULTI);

	// Renderers
	DefaultGalleryGroupRenderer gr = new DefaultGalleryGroupRenderer();
	gr.setMinMargin(2);
	gr.setItemHeight(82);
	gr.setItemWidth(200);
	gr.setAutoMargin(true);
	gallery.setGroupRenderer(gr);

	ListItemRenderer ir = new ListItemRenderer();
	gallery.setItemRenderer(ir);

	for (int g = 0; g < 2; g++) {
		GalleryItem group = new GalleryItem(gallery, SWT.NONE);
		group.setText("Group " + g); //$NON-NLS-1$
		group.setExpanded(true);

		for (int i = 0; i < 50; i++) {
			GalleryItem item = new GalleryItem(group, SWT.NONE);
			if (itemImages[0] != null) {
				item.setImage(itemImages[0]);
			}
			item.setText("Item " + i); //$NON-NLS-1$
			Image[] over = { itemImages[0] };
			Image[] over2 = { itemImages[1], itemImages[2] };
			Image[] over3 = { itemImages[3] };
			item.setData(AbstractGalleryItemRenderer.OVERLAY_BOTTOM_RIGHT,
					over3);
			item.setData(AbstractGalleryItemRenderer.OVERLAY_BOTTOM_LEFT,
					over);
			item.setData(AbstractGalleryItemRenderer.OVERLAY_TOP_RIGHT,
					over);
			item.setData(AbstractGalleryItemRenderer.OVERLAY_TOP_LEFT,
					over2);

		}
	}

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

	for (int i = 0; i < itemImages.length; i++) {
		itemImages[i].dispose();
	}
	
	display.dispose();
}