2 * Copyright 2000-2009 JetBrains s.r.o.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
16 package com
.intellij
.uiDesigner
.radComponents
;
18 import com
.intellij
.uiDesigner
.XmlWriter
;
19 import com
.intellij
.uiDesigner
.UIFormXmlConstants
;
20 import com
.intellij
.uiDesigner
.lw
.IButtonGroup
;
22 import java
.util
.ArrayList
;
23 import java
.util
.List
;
24 import java
.util
.Collections
;
29 public class RadButtonGroup
implements IButtonGroup
{
30 public static final RadButtonGroup NEW_GROUP
= new RadButtonGroup(null);
32 private String myName
;
33 private final List
<String
> myComponentIds
= new ArrayList
<String
>();
34 private boolean myBound
;
36 public RadButtonGroup(final String name
) {
40 public void write(final XmlWriter writer
) {
41 writer
.startElement(UIFormXmlConstants
.ELEMENT_GROUP
);
42 writer
.addAttribute(UIFormXmlConstants
.ATTRIBUTE_NAME
, myName
);
44 writer
.addAttribute(UIFormXmlConstants
.ATTRIBUTE_BOUND
, true);
46 for(String id
: myComponentIds
) {
47 writer
.startElement(UIFormXmlConstants
.ELEMENT_MEMBER
);
48 writer
.addAttribute(UIFormXmlConstants
.ATTRIBUTE_ID
, id
);
54 public boolean contains(final RadComponent component
) {
55 return myComponentIds
.contains(component
.getId());
58 public String
getName() {
62 public void setName(final String name
) {
66 public boolean isBound() {
70 public void setBound(final boolean bound
) {
74 public void add(final RadComponent component
) {
75 myComponentIds
.add(component
.getId());
78 public void remove(final RadComponent component
) {
79 myComponentIds
.remove(component
.getId());
82 public void addComponentIds(final String
[] componentIds
) {
83 Collections
.addAll(myComponentIds
, componentIds
);
86 public String
[] getComponentIds() {
87 return myComponentIds
.toArray(new String
[myComponentIds
.size()]);
90 public boolean isEmpty() {
91 return myComponentIds
.size() == 0;