KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > omg > lifl > eclipse > plugin > project > utils > SWT > CheckGroup


1 /*====================================================================
2
3 OpenCCM: The Open CORBA Component Model Platform
4 Copyright (C) 2000-2003 USTL - LIFL - GOAL
5 Contact: openccm-team@objectweb.org
6
7 This library is free software; you can redistribute it and/or
8 modify it under the terms of the GNU Lesser General Public
9 License as published by the Free Software Foundation; either
10 version 2.1 of the License, or any later version.
11
12 This library is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 Lesser General Public License for more details.
16
17 You should have received a copy of the GNU Lesser General Public
18 License along with this library; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
20 USA
21
22 Initial developer(s): Jerome Offroy.
23 Contributor(s): ______________________________________.
24
25 ====================================================================*/

26 /*
27  * Created on 5 juin 2003 by jerome OFFROY (offroy@lifl.fr)
28  *
29  */

30
31 package org.omg.lifl.eclipse.plugin.project.utils.SWT;
32
33 import org.eclipse.swt.SWT;
34 import org.eclipse.swt.layout.RowLayout;
35 import org.eclipse.swt.widgets.Button;
36 import org.eclipse.swt.widgets.Composite;
37 import org.eclipse.swt.widgets.Event;
38 import org.eclipse.swt.widgets.Group;
39 import org.eclipse.swt.widgets.Listener;
40
41 /**
42  * @author offroy
43  *
44  */

45 public class CheckGroup {
46
47     private Group subGroup;
48     private boolean subGroupVisible;
49     private Button checkBox;
50     private String JavaDoc groupTitle;
51     private Group group;
52     
53     public CheckGroup(Composite parent,String JavaDoc title) {
54         subGroupVisible = true;
55         setGroupTitle(title);
56         group = new Group(parent, SWT.NONE);
57         checkBox = new Button(group, SWT.CHECK);
58         
59         group.setLayout(new RowLayout());
60         group.setText(getGroupTitle());
61         
62         checkBox.setSelection(subGroupVisible);
63         checkBox.addListener(SWT.Selection, new Listener() {
64
65             public void handleEvent(Event e) {
66                 subGroupVisible = checkBox.getSelection();
67                 if (subGroup != null)
68                 // TODO disable on cascade whereas make subGroup disapear
69
// subGroup.setEnabled(subGroupVisible);
70
subGroup.setVisible(subGroupVisible);
71                 else //TODO do something when there is no subGroup
72
;
73             }
74         });
75
76     }
77
78
79     /**
80      * @return
81      */

82     public Group getSubGroup() {
83         return subGroup;
84     }
85
86     /**
87      * @param group
88      */

89     public void setSubGroup(Group group) {
90         subGroup = group;
91     }
92
93     /**
94      * @return
95      */

96     public Group getGroup() {
97         return group;
98     }
99
100     /**
101      * @param group
102      */

103     public void setGroup(Group group) {
104         this.group = group;
105     }
106
107     /**
108      * @return
109      */

110     public String JavaDoc getGroupTitle() {
111         return groupTitle;
112     }
113
114     /**
115      * @param string
116      */

117     public void setGroupTitle(String JavaDoc string) {
118         groupTitle = string;
119     }
120
121     /**
122      * @return
123      */

124     public boolean isSubGroupVisible() {
125         return subGroupVisible;
126     }
127
128     /**
129      * @param b
130      */

131     public void setSubGroupVisible(boolean b) {
132         subGroupVisible = b;
133     }
134
135 }
136
Popular Tags