KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > ca > mcgill > sable > soot > ui > StringOptionWidget


1 /* Soot - a J*va Optimization Framework
2  * Copyright (C) 2003 Jennifer Lhotak
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2.1 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, write to the
16  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17  * Boston, MA 02111-1307, USA.
18  */

19
20 package ca.mcgill.sable.soot.ui;
21
22 import java.util.ArrayList JavaDoc;
23
24 import org.eclipse.swt.widgets.*;
25 import org.eclipse.swt.layout.*;
26 import org.eclipse.swt.*;
27 import ca.mcgill.sable.soot.ui.*;
28
29 public class StringOptionWidget implements ISootOptionWidget {
30
31     private Text text;
32     private Label label;
33     private String JavaDoc alias;
34     
35     
36     
37     /**
38      * Constructor for StringOptionWidget.
39      * @param parent
40      * @param style
41      */

42     public StringOptionWidget(Composite parent, int style,
43         OptionData data) {
44         
45         setAlias(data.getRealAlias());
46         
47         Group path = new Group(parent, SWT.NONE);
48         GridLayout gl = new GridLayout();
49         gl.numColumns = 2;
50         path.setLayout(gl);
51         // this makes widget fill horizontal space
52
GridData gridData2 = new GridData(GridData.FILL_HORIZONTAL);
53         path.setLayoutData(gridData2);
54        
55   
56         
57         setLabel(new Label(path, SWT.NONE));
58         setLabelText(data.getText());
59         setText(new Text(path, SWT.SINGLE | SWT.BORDER));
60         
61         getText().setText(data.getInitText());
62         getText().setToolTipText(data.getTooltip().trim());
63         getText().setSize(300, 20);
64         
65         // this makes textbox fill available space
66
GridData gridData = new GridData(GridData.FILL_HORIZONTAL);
67         gridData.horizontalSpan = 1;
68         getText().setLayoutData(gridData);
69         
70         
71     }
72     public ArrayList JavaDoc getControls(){
73         ArrayList JavaDoc controls = new ArrayList JavaDoc();
74         controls.add(getText());
75         return controls;
76     }
77     
78     public String JavaDoc getId(){
79         return getAlias();
80     }
81     
82     public void setLabelText(String JavaDoc text) {
83         getLabel().setText(text);
84     }
85
86     /**
87      * Returns the label.
88      * @return Label
89      */

90     public Label getLabel() {
91         return label;
92     }
93
94     /**
95      * Returns the text.
96      * @return Text
97      */

98     public Text getText() {
99         return text;
100     }
101
102     /**
103      * Sets the label.
104      * @param label The label to set
105      */

106     public void setLabel(Label label) {
107         this.label = label;
108     }
109
110     /**
111      * Sets the text.
112      * @param text The text to set
113      */

114     public void setText(Text text) {
115         this.text = text;
116     }
117
118     /**
119      * Returns the alias.
120      * @return String
121      */

122     public String JavaDoc getAlias() {
123         return alias;
124     }
125
126     /**
127      * Sets the alias.
128      * @param alias The alias to set
129      */

130     public void setAlias(String JavaDoc alias) {
131         this.alias = alias;
132     }
133
134 }
135
Popular Tags