package org.rubypeople.rdt.debug.ui;
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Font;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Combo;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Group;
public class SWTFactory {
/**
* Creates a Group widget
*
* @param parent
* the parent composite to add this group to
* @param text
* the text for the heading of the group
* @param columns
* the number of columns within the group
* @param hspan
* the horizontal span the group should take up on the parent
* @param fill
* the style for how this composite should fill into its parent
* @return the new group
* @since 3.2
*
*/
public static Group createGroup(Composite parent, String text, int columns,
int hspan, int fill) {
Group g = new Group(parent, SWT.NONE);
g.setLayout(new GridLayout(columns, false));
g.setText(text);
g.setFont(parent.getFont());
GridData gd = new GridData(fill);
gd.horizontalSpan = hspan;
g.setLayoutData(gd);
return g;
}
/**
* This method is used to make a combo box
*
* @param parent
* the parent composite to add the new combo to
* @param style
* the style for the Combo
* @param hspan
* the horizontal span to take up on the parent composite
* @param fill
* how the combo will fill into the composite Can be one of
* <code>GridData.FILL_HORIZONAL</code>,
* <code>GridData.FILL_BOTH</code> or
* <code>GridData.FILL_VERTICAL</code>
* @param items
* the item to put into the combo
* @return a new Combo instance
* @since 3.3
*/
public static Combo createCombo(Composite parent, int style, int hspan,
int fill, String[] items) {
Combo c = new Combo(parent, style);
c.setFont(parent.getFont());
GridData gd = new GridData(fill);
gd.horizontalSpan = hspan;
c.setLayoutData(gd);
if (items != null) {
c.setItems(items);
}
c.select(0);
return c;
}
/**
* Creates a Composite widget
*
* @param parent
* the parent composite to add this composite to
* @param font
* the font to set on the control
* @param columns
* the number of columns within the composite
* @param hspan
* the horizontal span the composite should take up on the parent
* @param fill
* the style for how this composite should fill into its parent
* @return the new group
* @since 3.3
*/
public static Composite createComposite(Composite parent, Font font,
int columns, int hspan, int fill) {
Composite g = new Composite(parent, SWT.NONE);
g.setLayout(new GridLayout(columns, false));
g.setFont(font);
GridData gd = new GridData(fill);
gd.horizontalSpan = hspan;
g.setLayoutData(gd);
return g;
}
}