Bug 114293 - Update "Understanding Layouts in SWT", layout examples and snippets
Summary: Update "Understanding Layouts in SWT", layout examples and snippets
Status: NEW
Alias: None
Product: Platform
Classification: Eclipse Project
Component: SWT (show other bugs)
Version: 3.2   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Platform-SWT-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-10-29 09:53 EDT by Sebastian Davids CLA
Modified: 2021-11-12 11:35 EST (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Sebastian Davids CLA 2005-10-29 09:53:46 EDT
http://eclipse.org/articles/Understanding%20Layouts/Understanding%20Layouts.htm

Features introduced in 3.0 and 3.1 should be explained, 
SWT examples and snippets should be moved to new preferred API.

TrimLayout should be explained ... it is the aquivalent to Swing's BorderLayout.

The convenience API – style bits defined by GridData -- are not recommended
anymore so the article should not advocate them :)
Comment 1 Sebastian Davids CLA 2005-10-29 09:58:42 EDT
TrimLayout isn't public API.
Comment 2 Veronika Irvine CLA 2005-10-30 20:50:42 EST
Also TrimLayout is very specialized to the Workbench layout and can not be used 
in the general way that BorderLayout can.
Comment 3 Sebastian Davids CLA 2007-04-18 07:27:23 EDT
Maybe you might consider adding a JFace section explaining the org.eclipse.jface.layout classes, i.e. GridDataFactory etc.

Yes, I know it's called "in SWT" -- but in JFace apps, plug-ins, and RCP apps using the new convinience API should be the preferred way of creating layouts.

At least developers should be made aware of these.

One of the most common errors I see in dialogs/layouts is forgetting to set standard margins; using:

GridLayoutFactory.swtDefaults().numColumns(nColums).generateLayout(group);

is way easier and produces less duplicate code then:

GridLayout layout = new GridLayout(numberOfColumns, false);
layout.marginHeight = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN);
layout.marginWidth = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN);
layout.verticalSpacing = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING);
layout.horizontalSpacing = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING);

and the (beforehand) call to:

initializeDialogUnits(composite);

which most people forget.
Comment 4 Stefan Xenos CLA 2007-12-07 10:36:29 EST
> GridLayoutFactory.swtDefaults().numColumns(nColums).generateLayout(group);

That would not generate standard margins. It would generate 5-pixel margins (the SWT defaults), which are wrong. To get standard margins, do this:

GridLayoutFactory.fillDefaults().margins(LayoutConstants.getMargins()).numColumns(nColumns).generateLayout(group);

There's no good reason to ever call swtDefaults(), and our examples should not endorse it.
Comment 5 Eclipse Webmaster CLA 2019-09-06 16:03:54 EDT
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet.

If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.