KickJava   Java API By Example, From Geeks To Geeks.

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


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 org.eclipse.swt.layout.*;
23 import org.eclipse.swt.widgets.*;
24 import org.eclipse.swt.*;
25
26 public class ListOptionWidget {
27
28     private Label label;
29     private Text text;
30     private String JavaDoc alias;
31     
32     
33     /**
34      * Constructor for PathOptionClass.
35      * @param parent
36      * @param style
37      */

38     public ListOptionWidget(Composite parent, int style,
39       OptionData data) {
40         
41         setAlias(data.getRealAlias());
42         
43         Group path = new Group(parent, SWT.RIGHT);
44         GridLayout gl = new GridLayout();
45         gl.numColumns = 3;
46         
47         path.setLayout(gl);
48
49         // this makes widget fill horizontal space
50
GridData gridData2 = new GridData(GridData.FILL_HORIZONTAL);
51         gridData2.horizontalSpan = 3;
52
53         path.setLayoutData(gridData2);
54                     
55         setLabel(new Label(path, SWT.NONE));
56         setLabelText(data.getText());
57         setText(new Text(path, SWT.MULTI | SWT.BORDER | SWT.V_SCROLL));
58         
59
60         if ((data.getInitText() == null) || (data.getInitText().length() == 0)){
61             getText().setText("");
62         }
63         else {
64             getText().setText(data.getInitText());
65         }
66         String JavaDoc listMessage = " Separate values on different lines.";
67         getText().setToolTipText(data.getTooltip().trim()+listMessage);
68     
69         // this makes textbox fill available space
70
GridData gridData = new GridData(GridData.FILL_HORIZONTAL);
71         gridData.horizontalSpan = 2;
72         gridData.heightHint = 35;
73         getText().setLayoutData(gridData);
74         
75         
76     }
77
78
79     public void setLabelText(String JavaDoc text) {
80         getLabel().setText(text);
81     }
82
83     /**
84      * Returns the label.
85      * @return Label
86      */

87     public Label getLabel() {
88         return label;
89     }
90
91     /**
92      * Returns the text.
93      * @return Text
94      */

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

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

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

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

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