use of org.eclipse.emf.common.util.BasicEList in project smarthome by eclipse.
the class ItemUIRegistryImpl method getChildren.
@Override
public EList<Widget> getChildren(LinkableWidget w) {
EList<Widget> widgets = null;
if (w instanceof Group && w.getChildren().isEmpty()) {
widgets = getDynamicGroupChildren((Group) w);
} else {
widgets = w.getChildren();
}
EList<Widget> result = new BasicEList<Widget>();
for (Widget widget : widgets) {
Widget resolvedWidget = resolveDefault(widget);
if (resolvedWidget != null) {
result.add(resolvedWidget);
}
}
return result;
}
use of org.eclipse.emf.common.util.BasicEList in project smarthome by eclipse.
the class ItemUIRegistryImpl method getDynamicGroupChildren.
/**
* This method creates a list of children for a group dynamically.
* If there are no explicit children defined in a sitemap, the children
* can thus be created on the fly by iterating over the members of the group item.
*
* @param group The group widget to get children for
* @return a list of default widgets provided for the member items
*/
private EList<Widget> getDynamicGroupChildren(Group group) {
EList<Widget> children = new BasicEList<Widget>();
String itemName = group.getItem();
try {
if (itemName != null) {
Item item = getItem(itemName);
if (item instanceof GroupItem) {
GroupItem groupItem = (GroupItem) item;
for (Item member : groupItem.getMembers()) {
Widget widget = getDefaultWidget(member.getClass(), member.getName());
if (widget != null) {
widget.setItem(member.getName());
children.add(widget);
}
}
} else {
logger.warn("Item '{}' is not a group.", item.getName());
}
} else {
logger.warn("Group does not specify an associated item - ignoring it.");
}
} catch (ItemNotFoundException e) {
logger.warn("Dynamic group with label '{}' will be ignored, because its item '{}' does not exist.", group.getLabel(), itemName);
}
return children;
}
use of org.eclipse.emf.common.util.BasicEList in project smarthome by eclipse.
the class ItemUIRegistryImpl method getChildren.
@Override
public EList<Widget> getChildren(Sitemap sitemap) {
EList<Widget> widgets = sitemap.getChildren();
EList<Widget> result = new BasicEList<Widget>();
for (Widget widget : widgets) {
Widget resolvedWidget = resolveDefault(widget);
if (resolvedWidget != null) {
result.add(resolvedWidget);
}
}
return result;
}
use of org.eclipse.emf.common.util.BasicEList in project smarthome by eclipse.
the class ItemUIRegistryImplTest method testStateConversionForSwitchWidgetWithMappingThroughGetState.
@Test
public void testStateConversionForSwitchWidgetWithMappingThroughGetState() throws ItemNotFoundException {
State colorState = new HSBType("23,42,50");
ColorItem colorItem = new ColorItem("myItem");
colorItem.setLabel("myItem");
colorItem.setState(colorState);
when(registry.getItem("myItem")).thenReturn(colorItem);
Switch switchWidget = mock(Switch.class);
when(switchWidget.getItem()).thenReturn("myItem");
Mapping mapping = mock(Mapping.class);
BasicEList<Mapping> mappings = new BasicEList<Mapping>();
mappings.add(mapping);
when(switchWidget.getMappings()).thenReturn(mappings);
State stateForSwitch = uiRegistry.getState(switchWidget);
assertEquals(colorState, stateForSwitch);
}
use of org.eclipse.emf.common.util.BasicEList in project alisa-examples by osate.
the class ModelVerifications method sameVoltage.
public static boolean sameVoltage(ComponentInstance ci) {
EList<FeatureInstance> inlets = new BasicEList<FeatureInstance>();
for (FeatureInstance fi : ci.getAllFeatureInstances(FeatureCategory.ABSTRACT_FEATURE)) {
Classifier cl = fi.getFeature().getAllClassifier();
if (cl.getName().equalsIgnoreCase("power")) {
inlets.add(fi);
}
}
if (inlets.size() == 2) {
double v1 = getVoltage(inlets.get(0));
double v2 = getVoltage(inlets.get(1));
return v1 == v2;
}
return false;
}
Aggregations