void ZLOptionView::setVisible(bool visible) {
	if (visible) {
		if (!myInitialized) {
			_createItem();
			myInitialized = true;
		}
		setActive(myOption->isActive());
		_show();
	} else {
		if (myInitialized) _hide();
	}
}
void NonPersistentItemFactory::handleDatabaseJobComplete(void* ref,DatabaseResult* result)
{
    QueryNonPersistentItemFactory* asyncContainer = reinterpret_cast<QueryNonPersistentItemFactory*>(ref);

    switch(asyncContainer->mQueryType)
    {
    case NPQuery_MainData:
    {
        Item* item = _createItem(result, asyncContainer->mId);

        // To be used when doing item factories.
        if (item->getLoadState() == LoadState_Attributes)
        {
            QueryNonPersistentItemFactory* asContainer = new(mQueryContainerPool.ordered_malloc()) QueryNonPersistentItemFactory(asyncContainer->mOfCallback,NPQuery_Attributes,asyncContainer->mId);
            asContainer->mObject = item;

            mDatabase->executeSqlAsync(this,asContainer,"SELECT attributes.name,item_family_attribute_defaults.attribute_value,attributes.internal"
                                       " FROM %s.item_family_attribute_defaults"
                                       " INNER JOIN %s.attributes ON (item_family_attribute_defaults.attribute_id = attributes.id)"
                                       " WHERE item_family_attribute_defaults.item_type_id = %u ORDER BY item_family_attribute_defaults.attribute_order",
                                       mDatabase->galaxy(),mDatabase->galaxy(),item->getItemType());
           
        }
        else if (item->getLoadState() == LoadState_Loaded && asyncContainer->mOfCallback)
        {
            asyncContainer->mOfCallback->handleObjectReady(item);
        }
    }
    break;

    case NPQuery_Attributes:
    {
        _buildAttributeMap(asyncContainer->mObject,result);
        if ((asyncContainer->mObject->getLoadState() == LoadState_Loaded) && (asyncContainer->mOfCallback))
        {
            asyncContainer->mOfCallback->handleObjectReady(asyncContainer->mObject);
        }
    }
    break;

    default:
        break;
    }
    mQueryContainerPool.free(asyncContainer);
}