Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 14507 Details for
Bug 71684
GridLayout similar to SWTs GridLayout
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
An Example for Draw2D GridLayout
GridLayoutExample.java (text/x-java), 9.01 KB, created by
Asim Ullah
on 2004-09-11 13:18:09 EDT
(
hide
)
Description:
An Example for Draw2D GridLayout
Filename:
MIME Type:
Creator:
Asim Ullah
Created:
2004-09-11 13:18:09 EDT
Size:
9.01 KB
patch
obsolete
>package org.eclipse.draw2d.examples.layouts; > >import org.eclipse.draw2d.*; >import org.eclipse.draw2d.examples.*; >import org.eclipse.swt.SWT; >import org.eclipse.swt.events.SelectionAdapter; >import org.eclipse.swt.events.SelectionEvent; >import org.eclipse.swt.layout.FillLayout; >import org.eclipse.swt.widgets.Button; >import org.eclipse.swt.widgets.Combo; >import org.eclipse.swt.widgets.Composite; >import org.eclipse.swt.widgets.Event; >import org.eclipse.swt.widgets.Group; >import org.eclipse.swt.widgets.Label; >import org.eclipse.swt.widgets.Listener; >import org.eclipse.swt.widgets.Text; > >/** > * @author Asim Ullah > * Sep 10, 2004 > */ >public class GridLayoutExample extends AbstractExample { > > GridLayout layout; > > public static void main(String[] args) { > new GridLayoutExample().run(); > } > > /** > * @see org.eclipse.draw2d.examples.AbstractExample#getContents() > */ > protected IFigure getContents() { > Figure container = new Figure(); > container.setBorder(new LineBorder()); > > layout = new GridLayout(); > layout.numColumns = 2; > layout.makeColumnsEqualWidth = false; > > container.setLayoutManager(layout); > > Shape shape; > > shape = new Ellipse(); > shape.setBackgroundColor(ColorConstants.blue); > shape.setSize(60, 40); > container.add(shape); > > shape = new RectangleFigure(); > shape.setBackgroundColor(ColorConstants.red); > shape.setSize(30, 70); > container.add(shape); > > shape = new RoundedRectangle(); > shape.setBackgroundColor(ColorConstants.yellow); > shape.setSize(90, 30); > container.add(shape); > > shape = new RectangleFigure(); > shape.setBackgroundColor(ColorConstants.gray); > shape.setSize(50, 80); > container.add(shape); > > shape = new Ellipse(); > shape.setBackgroundColor(ColorConstants.green); > shape.setSize(50, 50); > container.add(shape); > > shape = new Triangle(); > shape.setBackgroundColor(ColorConstants.black); > shape.setSize(50, 50); > container.add(shape); > > shape = new RoundedRectangle(); > shape.setBackgroundColor(ColorConstants.cyan); > shape.setSize(50, 50); > container.add(shape); > > shape = new RectangleFigure(); > shape.setBackgroundColor(ColorConstants.darkGreen); > shape.setSize(50, 50); > container.add(shape); > > shape = new Triangle(); > shape.setBackgroundColor(ColorConstants.orange); > shape.setSize(50, 50); > container.add(shape); > > shape = new Ellipse(); > shape.setBackgroundColor(ColorConstants.red); > shape.setSize(50, 50); > container.add(shape); > > shape = new RoundedRectangle(); > shape.setBackgroundColor(ColorConstants.yellow); > shape.setSize(50, 50); > container.add(shape); > > return container; > } > > protected Integer getEventValue(Event e, String id) > { > int val = 1; > try { > if (e.widget instanceof Text){ > val = Integer.parseInt(((Text) e.widget).getText()); > } > } catch (NumberFormatException ex) { > System.out.println("Error: Invalid Number entered for "+id); > } > return new Integer(val); > } > protected Integer getEventValue(SelectionEvent e, String id) > { > int val = 5; > try { > if (e.widget instanceof Combo){ > val=Integer.parseInt(((Combo) e.widget).getText()); > } > } catch (NumberFormatException ex) { > System.out.println("Error: Invalid Number entered for "+id); > } > return new Integer(val); > } > > /** > * @see org.eclipse.draw2d.examples.AbstractExample#hookShell() > */ > protected void hookShell() { > Composite composite = new Composite(shell, 0); > composite.setLayoutData(new org.eclipse.swt.layout.GridData( > org.eclipse.swt.layout.GridData.FILL_VERTICAL)); > composite.setLayout(new org.eclipse.swt.layout.GridLayout()); > > org.eclipse.swt.layout.GridLayout _layout; > org.eclipse.swt.layout.GridData _data; > > // Columns section > Group columnsGroup = new Group(composite, 0); > columnsGroup.setText("Columns"); > > _layout = new org.eclipse.swt.layout.GridLayout(); > _layout.numColumns = 2; > columnsGroup.setLayout(_layout); > > _data = new org.eclipse.swt.layout.GridData( > org.eclipse.swt.layout.GridData.VERTICAL_ALIGN_FILL); > columnsGroup.setLayoutData(_data); > Text numColumns = new Text(columnsGroup, SWT.BORDER); > numColumns.setText("2"); > numColumns.addListener(SWT.DefaultSelection, new Listener() { > public void handleEvent(Event e) { > layout.numColumns = getEventValue( e, "numColumns").intValue(); > contents.revalidate(); > shell.pack(); > } > }); > _data = new org.eclipse.swt.layout.GridData(); > _data.widthHint = 15; > numColumns.setLayoutData(_data); > new Label(columnsGroup, SWT.NONE).setText("numColumns"); > > Button makeColumnsEqualWidth = new Button(columnsGroup, SWT.CHECK); > makeColumnsEqualWidth.setText("makeColumnsEqualWidth"); > makeColumnsEqualWidth.setSelection(false); > makeColumnsEqualWidth.addSelectionListener(new SelectionAdapter() { > public void widgetSelected(SelectionEvent e) { > layout.makeColumnsEqualWidth = !layout.makeColumnsEqualWidth; > contents.revalidate(); > shell.pack(); > } > }); > _data = new org.eclipse.swt.layout.GridData(); > _data.horizontalSpan = 2; > _data.horizontalIndent = 14; > makeColumnsEqualWidth.setLayoutData(_data); > > //Margins and Spacing section > > Group marginGroup = new Group(composite, 0); > marginGroup.setLayout(new FillLayout(SWT.VERTICAL)); > marginGroup.setText("Margins and Spacing"); > > String[] marginValues = new String[]{"0", "3", "5", "10"}; > > _data = new org.eclipse.swt.layout.GridData(); > _data.verticalSpan = 2; > marginGroup.setLayoutData(_data); > _layout = new org.eclipse.swt.layout.GridLayout(); > _layout.numColumns = 2; > marginGroup.setLayout(_layout); > new Label(marginGroup, SWT.NONE).setText("marginHeight"); > Combo marginHeight = new Combo(marginGroup, SWT.NONE); > marginHeight.setItems(marginValues); > marginHeight.select(2); > _data = new org.eclipse.swt.layout.GridData(); > _data.widthHint = 60; > marginHeight.setLayoutData(_data); > > marginHeight.addListener(SWT.DefaultSelection, new Listener() { > public void handleEvent(Event e) { > layout.marginHeight = getEventValue( e, "marginHeight").intValue(); > contents.revalidate(); > shell.pack(); > }; > }); > marginHeight.addSelectionListener(new SelectionAdapter() { > public void widgetSelected(SelectionEvent e) { > layout.marginHeight = getEventValue( e, "marginHeight").intValue(); > contents.revalidate(); > shell.pack(); > } > }); > > new Label(marginGroup, SWT.NONE).setText("marginWidth"); > Combo marginWidth = new Combo(marginGroup, SWT.NONE); > marginWidth.setItems(marginValues); > marginWidth.select(2); > _data = new org.eclipse.swt.layout.GridData(); > _data.widthHint = 60; > marginWidth.setLayoutData(_data); > > marginWidth.addListener(SWT.DefaultSelection, new Listener() { > public void handleEvent(Event e) { > layout.marginWidth = getEventValue( e, "marginWidth").intValue(); > contents.revalidate(); > shell.pack(); > }; > }); > marginWidth.addSelectionListener(new SelectionAdapter() { > public void widgetSelected(SelectionEvent e) { > layout.marginWidth = getEventValue( e, "marginWidth").intValue(); > contents.revalidate(); > shell.pack(); > } > }); > > new Label(marginGroup, SWT.NONE).setText("horizontalSpacing"); > Combo horizontalSpacing = new Combo(marginGroup, SWT.NONE); > horizontalSpacing.setItems(marginValues); > horizontalSpacing.select(2); > _data = new org.eclipse.swt.layout.GridData(); > _data.widthHint = 60; > horizontalSpacing.setLayoutData(_data); > > horizontalSpacing.addListener(SWT.DefaultSelection, new Listener() { > public void handleEvent(Event e) { > layout.horizontalSpacing = getEventValue( e, "horizontalSpacing").intValue(); > contents.revalidate(); > shell.pack(); > }; > }); > horizontalSpacing.addSelectionListener(new SelectionAdapter() { > public void widgetSelected(SelectionEvent e) { > layout.horizontalSpacing = getEventValue( e, "horizontalSpacing").intValue(); > contents.revalidate(); > shell.pack(); > } > }); > > new Label(marginGroup, SWT.NONE).setText("verticalSpacing"); > Combo verticalSpacing = new Combo(marginGroup, SWT.NONE); > verticalSpacing.setItems(marginValues); > verticalSpacing.select(2); > _data = new org.eclipse.swt.layout.GridData(); > _data.widthHint = 60; > verticalSpacing.setLayoutData(_data); > > verticalSpacing.addListener(SWT.DefaultSelection, new Listener() { > public void handleEvent(Event e) { > layout.verticalSpacing = getEventValue( e, "verticalSpacing").intValue(); > contents.revalidate(); > shell.pack(); > }; > }); > > verticalSpacing.addSelectionListener(new SelectionAdapter() { > public void widgetSelected(SelectionEvent e) { > layout.verticalSpacing = getEventValue( e, "verticalSpacing").intValue();; > contents.revalidate(); > shell.pack(); > } > }); > > }//hookShell > >}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 71684
:
14505
|
14506
|
14507
|
14522
|
14523
|
53414