use of org.eclipse.smarthome.core.items.ItemFactory in project smarthome by eclipse.
the class CommunicationManager method calculateAcceptedTypes.
private synchronized void calculateAcceptedTypes() {
acceptedCommandTypeMap.clear();
acceptedStateTypeMap.clear();
for (ItemFactory itemFactory : itemFactories) {
for (String itemTypeName : itemFactory.getSupportedItemTypes()) {
Item item = itemFactory.createItem(itemTypeName, "tmp");
if (item != null) {
acceptedCommandTypeMap.put(itemTypeName, item.getAcceptedCommandTypes());
acceptedStateTypeMap.put(itemTypeName, item.getAcceptedDataTypes());
} else {
logger.error("Item factory {} suggested it can create items of type {} but returned null", itemFactory, itemTypeName);
}
}
}
}
use of org.eclipse.smarthome.core.items.ItemFactory in project smarthome by eclipse.
the class ChannelItemProvider method createItemForLink.
private void createItemForLink(ItemChannelLink link) {
if (!enabled) {
return;
}
if (itemRegistry.get(link.getItemName()) != null) {
// there is already an item, we do not need to create one
return;
}
Channel channel = thingRegistry.getChannel(link.getLinkedUID());
if (channel != null) {
Item item = null;
// Only create an item for state channels
if (channel.getKind() == ChannelKind.STATE) {
for (ItemFactory itemFactory : itemFactories) {
item = itemFactory.createItem(channel.getAcceptedItemType(), link.getItemName());
if (item != null) {
break;
}
}
}
if (item instanceof GenericItem) {
GenericItem gItem = (GenericItem) item;
gItem.setLabel(getLabel(channel));
gItem.setCategory(getCategory(channel));
gItem.addTags(channel.getDefaultTags());
}
if (item != null) {
items.put(item.getName(), item);
for (ProviderChangeListener<Item> listener : listeners) {
listener.added(this, item);
}
}
}
}
Aggregations