intial version
[phpeclipse.git] / archive / net.sourceforge.phpeclipse.jtidy / src / net / sourceforge / phpdt / tidy / preferences / LabelFieldEditor.java
1 package net.sourceforge.phpdt.tidy.preferences;
2
3 import org.eclipse.jface.preference.FieldEditor;
4 import org.eclipse.swt.layout.GridData;
5 import org.eclipse.swt.widgets.Composite;
6 import org.eclipse.swt.widgets.Label;
7
8 /**
9  * A field editor for displaying labels not associated with other widgets.
10  */
11 class LabelFieldEditor extends FieldEditor {
12
13         private Label label;
14
15         // All labels can use the same preference name since they don't
16         // store any preference.
17         public LabelFieldEditor(String value, Composite parent) {
18                 super("label", value, parent);
19         }
20
21         // Adjusts the field editor to be displayed correctly
22         // for the given number of columns.
23         protected void adjustForNumColumns(int numColumns) {
24                 ((GridData) label.getLayoutData()).horizontalSpan = numColumns;
25         }
26
27         // Fills the field editor's controls into the given parent.
28         protected void doFillIntoGrid(Composite parent, int numColumns) {
29                 label = getLabelControl(parent);
30                 
31                 GridData gridData = new GridData();
32                 gridData.horizontalSpan = numColumns;
33                 gridData.horizontalAlignment = GridData.FILL;
34                 gridData.grabExcessHorizontalSpace = false;
35                 gridData.verticalAlignment = GridData.CENTER;
36                 gridData.grabExcessVerticalSpace = false;
37                 
38                 label.setLayoutData(gridData);
39         }
40
41         // Returns the number of controls in the field editor.
42         public int getNumberOfControls() {
43                 return 1;
44         }
45
46         // Labels do not persist any preferences, so these methods are empty.
47         protected void doLoad() {
48         }
49         protected void doLoadDefault() {
50         }
51         protected void doStore() {
52         }
53 }