SectionHelperpublic final class SectionHelper extends Object Helper for the AndroidManifest form editor.
Helps create a new SectionPart with sensible default parameters,
create default layout or add typical widgets.
IMPORTANT: This is NOT a generic class. It makes a lot of assumptions on the
UI as used by the form editor for the AndroidManifest.
TODO: Consider moving to a common package. |
Methods Summary |
---|
public static void | addControlTooltip(org.eclipse.swt.widgets.Control control, java.lang.String tooltip)Associates a tooltip with a control.
This mirrors the behavior from org.eclipse.pde.internal.ui.editor.text.PDETextHover
if (control == null || tooltip == null || tooltip.length() == 0) {
return;
}
// Some kinds of controls already properly implement tooltip display.
if (control instanceof Button) {
control.setToolTipText(tooltip);
return;
}
control.setToolTipText(null);
final DefaultInformationControl ic = new DefaultInformationControl(control.getShell());
ic.setInformation(tooltip);
Point sz = ic.computeSizeHint();
ic.setSize(sz.x, sz.y);
ic.setVisible(false); // initially hidden
control.addMouseTrackListener(new MouseTrackListener() {
public void mouseEnter(MouseEvent e) {
}
public void mouseExit(MouseEvent e) {
ic.setVisible(false);
}
public void mouseHover(MouseEvent e) {
ic.setLocation(control.toDisplay(10, 25)); // same offset as in PDETextHover
ic.setVisible(true);
}
});
| public static org.eclipse.ui.forms.widgets.FormText | createFormText(org.eclipse.swt.widgets.Composite parent, org.eclipse.ui.forms.widgets.FormToolkit toolkit, boolean isHtml, java.lang.String label, boolean setupLayoutData)Creates a FormText widget.
This expects the parent composite to have a TableWrapLayout with 2 columns.
FormText text = toolkit.createFormText(parent, true /* track focus */);
if (setupLayoutData) {
TableWrapData twd = new TableWrapData(TableWrapData.FILL_GRAB);
twd.maxWidth = AndroidEditor.TEXT_WIDTH_HINT;
if (parent.getLayout() instanceof TableWrapLayout) {
twd.colspan = ((TableWrapLayout) parent.getLayout()).numColumns;
}
text.setLayoutData(twd);
}
text.setWhitespaceNormalized(true);
text.setText(label, isHtml /* parseTags */, isHtml /* expandURLs */);
return text;
| public static org.eclipse.swt.widgets.Composite | createGridLayout(org.eclipse.swt.widgets.Composite composite, org.eclipse.ui.forms.widgets.FormToolkit toolkit, int numColumns)Creates a new composite with a GridLayout set with a given number of columns.
If the parent composite is a Section, the new composite is set as a client.
Composite grid = toolkit.createComposite(composite);
GridLayout layout = new GridLayout();
layout.numColumns = numColumns;
grid.setLayout(layout);
toolkit.paintBordersFor(grid);
if (composite instanceof Section) {
((Section) composite).setClient(grid);
}
return grid;
| public static org.eclipse.swt.widgets.Label | createLabel(org.eclipse.swt.widgets.Composite parent, org.eclipse.ui.forms.widgets.FormToolkit toolkit, java.lang.String label_text, java.lang.String tooltip)Creates a label widget.
If the parent layout if a TableWrapLayout, maximize it to span over all columns.
Label label = toolkit.createLabel(parent, label_text);
TableWrapData twd = new TableWrapData(TableWrapData.FILL_GRAB);
if (parent.getLayout() instanceof TableWrapLayout) {
twd.colspan = ((TableWrapLayout) parent.getLayout()).numColumns;
}
label.setLayoutData(twd);
addControlTooltip(label, tooltip);
return label;
| public static org.eclipse.swt.widgets.Text | createLabelAndText(org.eclipse.swt.widgets.Composite parent, org.eclipse.ui.forms.widgets.FormToolkit toolkit, java.lang.String label_text, java.lang.String value, java.lang.String tooltip)Creates two widgets: a label and a text field.
This expects the parent composite to have a TableWrapLayout with 2 columns.
Label label = toolkit.createLabel(parent, label_text);
label.setLayoutData(new TableWrapData(TableWrapData.LEFT, TableWrapData.MIDDLE));
Text text = toolkit.createText(parent, value);
text.setLayoutData(new TableWrapData(TableWrapData.FILL_GRAB, TableWrapData.MIDDLE));
addControlTooltip(label, tooltip);
return text;
| public static org.eclipse.swt.widgets.Composite | createTableLayout(org.eclipse.swt.widgets.Composite composite, org.eclipse.ui.forms.widgets.FormToolkit toolkit, int numColumns)Creates a new composite with a TableWrapLayout set with a given number of columns.
If the parent composite is a Section, the new composite is set as a client.
Composite table = toolkit.createComposite(composite);
TableWrapLayout layout = new TableWrapLayout();
layout.numColumns = numColumns;
table.setLayout(layout);
toolkit.paintBordersFor(table);
if (composite instanceof Section) {
((Section) composite).setClient(table);
}
return table;
|
|