Permalink
Browse files

Made Modeler ready for multi group buttons

  • Loading branch information...
1 parent d25a6a4 commit c5894e46889574b8d571ba486c2318daa5cab758 @vi-n vi-n committed May 8, 2012
@@ -16,10 +16,15 @@
*/
package org.openremote.modeler.domain.component;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.Set;
+
import javax.persistence.Transient;
import org.openremote.modeler.client.utils.IDUtil;
import org.openremote.modeler.domain.BusinessEntity;
+import org.openremote.modeler.domain.ClientGroup;
import flexjson.JSON;
@@ -33,6 +38,7 @@
public abstract class UIComponent extends BusinessEntity {
private transient boolean removed = false;
+ private Set<ClientGroup> groups = new HashSet<ClientGroup>();
public UIComponent() {
}
@@ -134,7 +140,48 @@ public boolean equals(Object obj) {
UIComponent other = (UIComponent) obj;
return other.getPanelXml().equals(getPanelXml());
}
+
+ /**
+ * @deprecated
+ * Use getGroups()
+ * @return the first group
+ */
+ public ClientGroup getGroup() {
+ ClientGroup group = null;
+ if(!groups.isEmpty()) {
+ group = (ClientGroup) groups.toArray()[0];
+ }
+ return group;
+ }
+
+ /**
+ * @return All the groups of the component
+ */
+ public Collection<ClientGroup> getGroups() {
+ return groups;
+ }
+
+ /**
+ * Add a group to the component
+ * @param group The group you want to add.
+ */
+ public void addGroup(ClientGroup group) {
+ groups.add(group);
+ }
+ /**
+ * @deprecated
+ * Set the current group of the Component
+ * @param group The group you want to set
+ */
+ public void setGroup(ClientGroup group) {
+ //Temporary, because we are only supporting one group at the moment.
+ if(groups.size() > 1) {
+ groups.clear();
+ }
+ groups.add(group);
+ }
+
@Override
public int hashCode() {
return (int) getOid();
@@ -33,9 +33,7 @@
*
*/
private static final long serialVersionUID = 2629776331131648211L;
-
- private ClientGroup group;
-
+
public UIControl() {
super();
}
@@ -47,16 +45,7 @@ public UIControl(long id) {
public String getName() {
return "UIControl";
}
-
- public ClientGroup getGroup() {
- return group;
- }
- public void setGroup(ClientGroup group) {
- this.group = group;
- }
-
- public abstract List<UICommand> getCommands();
-
+ public abstract List<UICommand> getCommands();
}

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.

0 comments on commit c5894e4

Please sign in to comment.