KickJava   Java API By Example, From Geeks To Geeks.

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


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 package ca.mcgill.sable.soot.ui;
20
21 import java.util.*;
22
23 import org.eclipse.swt.widgets.*;
24 import ca.mcgill.sable.soot.ui.*;
25
26
27 public class EnableGroup {
28
29     private String JavaDoc phaseAlias;
30     private String JavaDoc subPhaseAlias;
31     private BooleanOptionWidget leader;
32     private ArrayList controls;
33     private boolean phaseOptType;
34     
35     public EnableGroup(){
36         
37     }
38     
39     public void addControl(ISootOptionWidget c){
40         if (getControls() == null){
41             setControls(new ArrayList());
42         }
43         getControls().add(c);
44     }
45     
46     public void addControls(ArrayList c){
47         if (getControls() == null){
48             setControls(new ArrayList());
49         }
50         getControls().addAll(c);
51     }
52     
53     public boolean isLeader(BooleanOptionWidget l){
54         if (l.equals(getLeader())) return true;
55         return false;
56     }
57     
58     public void changeControlState(boolean enabled){
59         if (getControls() == null) return;
60         Iterator it = getControls().iterator();
61         while (it.hasNext()){
62             ISootOptionWidget control = (ISootOptionWidget)it.next();
63             if (control.getControls() == null) continue;
64             Iterator conIt = control.getControls().iterator();
65             while (conIt.hasNext()){
66                 Object JavaDoc obj = conIt.next();
67                 ((Control)obj).setEnabled(enabled);
68             }
69             
70         }
71     }
72     
73     /**
74      * @return
75      */

76     public ArrayList getControls() {
77         return controls;
78     }
79
80     /**
81      * @return
82      */

83     public BooleanOptionWidget getLeader() {
84         return leader;
85     }
86
87     /**
88      * @param list
89      */

90     private void setControls(ArrayList list) {
91         controls = list;
92     }
93
94     /**
95      * @param button
96      */

97     public void setLeader(BooleanOptionWidget button) {
98         leader = button;
99     }
100     
101     public String JavaDoc toString(){
102         StringBuffer JavaDoc sb = new StringBuffer JavaDoc();
103         sb.append("Phase: "+getPhaseAlias()+" SubPhase: "+getSubPhaseAlias());
104         sb.append("Leader: "+getLeader().getAlias()+" sel: "+getLeader().getButton().getSelection()+" enabled: "+getLeader().getButton().isEnabled()+"\n");
105         if (getControls() != null){
106             Iterator it = getControls().iterator();
107             while (it.hasNext()){
108                 ISootOptionWidget next = (ISootOptionWidget)it.next();
109                 sb.append("control: "+next.getId()+"\n");
110                 if (next instanceof BooleanOptionWidget){
111                     sb.append("control is boolean and enable state: "+((BooleanOptionWidget)next).getButton().isEnabled()+"\n");
112                 }
113             }
114         }
115         return sb.toString();
116     }
117
118     /**
119      * @return
120      */

121     public String JavaDoc getPhaseAlias() {
122         return phaseAlias;
123     }
124
125     /**
126      * @return
127      */

128     public String JavaDoc getSubPhaseAlias() {
129         return subPhaseAlias;
130     }
131
132     /**
133      * @param string
134      */

135     public void setPhaseAlias(String JavaDoc string) {
136         phaseAlias = string;
137     }
138
139     /**
140      * @param string
141      */

142     public void setSubPhaseAlias(String JavaDoc string) {
143         subPhaseAlias = string;
144     }
145
146     /**
147      * @return
148      */

149     public boolean isPhaseOptType() {
150         return phaseOptType;
151     }
152
153     /**
154      * @param b
155      */

156     public void setPhaseOptType(boolean b) {
157         phaseOptType = b;
158     }
159
160 }
161
Popular Tags