Search in sources :

Example 6 with ObjectDetailDescriptor

use of org.qi4j.tools.model.descriptor.ObjectDetailDescriptor in project qi4j-sdk by Qi4j.

the class ServiceUsageFinder method collectInInjectedField.

private void collectInInjectedField(Iterable<InjectedFieldDetailDescriptor> iter, Object ownerDescriptor) {
    for (InjectedFieldDetailDescriptor descriptorField : iter) {
        DependencyDescriptor dependencyDescriptor = descriptorField.descriptor().dependency();
        Annotation annotation = dependencyDescriptor.injectionAnnotation();
        Class<? extends Annotation> clazz = annotation.annotationType();
        if (Uses.class.equals(clazz) || Service.class.equals(clazz)) {
            boolean used = false;
            if (dependencyDescriptor.injectionType().equals(first(this.descriptor.descriptor().types()))) {
                ServiceUsage usage;
                if (ownerDescriptor instanceof MixinDetailDescriptor) {
                    MixinDetailDescriptor mixinDescriptor = (MixinDetailDescriptor) ownerDescriptor;
                    usage = new ServiceUsage(mixinDescriptor.composite(), descriptorField, mixinDescriptor.composite().module(), mixinDescriptor.composite().module().layer());
                } else {
                    // assume ObjectDetailDescriptor
                    ObjectDetailDescriptor objectDescriptor = (ObjectDetailDescriptor) ownerDescriptor;
                    usage = new ServiceUsage(objectDescriptor, descriptorField, objectDescriptor.module(), objectDescriptor.module().layer());
                }
                usages.add(usage);
            }
        }
    }
}
Also used : Uses(org.qi4j.api.injection.scope.Uses) InjectedFieldDetailDescriptor(org.qi4j.tools.model.descriptor.InjectedFieldDetailDescriptor) DependencyDescriptor(org.qi4j.api.composite.DependencyDescriptor) MixinDetailDescriptor(org.qi4j.tools.model.descriptor.MixinDetailDescriptor) ServiceUsage(org.qi4j.tools.model.descriptor.ServiceUsage) Service(org.qi4j.api.injection.scope.Service) ObjectDetailDescriptor(org.qi4j.tools.model.descriptor.ObjectDetailDescriptor) Annotation(java.lang.annotation.Annotation)

Example 7 with ObjectDetailDescriptor

use of org.qi4j.tools.model.descriptor.ObjectDetailDescriptor in project qi4j-sdk by Qi4j.

the class ServiceConfigurationPane method setDescriptor.

@Override
protected void setDescriptor(Object objectDesciptor) {
    clear();
    if (!(objectDesciptor instanceof ServiceDetailDescriptor)) {
        return;
    }
    configDescriptor = DescriptorUtilities.findServiceConfiguration((ServiceDetailDescriptor) objectDesciptor);
    if (configDescriptor == null) {
        return;
    }
    ModelDescriptor spiDescriptor = null;
    String typeString = null;
    if (configDescriptor instanceof ServiceDetailDescriptor) {
        spiDescriptor = ((ServiceDetailDescriptor) configDescriptor).descriptor();
        typeString = "Service";
    } else if (configDescriptor instanceof EntityDetailDescriptor) {
        spiDescriptor = ((EntityDetailDescriptor) configDescriptor).descriptor();
        typeString = "Entity";
    } else if (configDescriptor instanceof ValueDetailDescriptor) {
        spiDescriptor = ((ValueDetailDescriptor) configDescriptor).descriptor();
        typeString = "Value";
    } else if (configDescriptor instanceof ObjectDetailDescriptor) {
        spiDescriptor = ((ObjectDetailDescriptor) configDescriptor).descriptor();
        typeString = "Object";
    } else if (configDescriptor instanceof CompositeDetailDescriptor) {
        spiDescriptor = ((ObjectDetailDescriptor) configDescriptor).descriptor();
        typeString = "Transient";
    }
    Class<?> type = first(spiDescriptor.types());
    String simpleName = type.getSimpleName();
    nameLabel.setText("<html><a href='" + simpleName + "'>" + simpleName + "</a></html>");
    classLabel.setText(type.getName());
    typeLabel.setText(typeString);
    linkButton.setEnabled(true);
}
Also used : ServiceDetailDescriptor(org.qi4j.tools.model.descriptor.ServiceDetailDescriptor) EntityDetailDescriptor(org.qi4j.tools.model.descriptor.EntityDetailDescriptor) ModelDescriptor(org.qi4j.api.composite.ModelDescriptor) ValueDetailDescriptor(org.qi4j.tools.model.descriptor.ValueDetailDescriptor) ObjectDetailDescriptor(org.qi4j.tools.model.descriptor.ObjectDetailDescriptor) CompositeDetailDescriptor(org.qi4j.tools.model.descriptor.CompositeDetailDescriptor)

Example 8 with ObjectDetailDescriptor

use of org.qi4j.tools.model.descriptor.ObjectDetailDescriptor in project qi4j-sdk by Qi4j.

the class StatePane method setDescriptor.

@Override
protected void setDescriptor(Object objectDesciptor) {
    clear();
    if (objectDesciptor instanceof CompositeDetailDescriptor) {
        CompositeDetailDescriptor descriptor = ((CompositeDetailDescriptor) objectDesciptor);
        List<CompositeMethodDetailDescriptor> list = DescriptorUtilities.findState(descriptor);
        for (CompositeMethodDetailDescriptor methodDescriptor : list) {
            methodListModel.addElement(methodDescriptor);
        }
        if (!methodListModel.isEmpty()) {
            methodList.setSelectedIndex(0);
        }
    } else if (objectDesciptor instanceof ObjectDetailDescriptor) {
    // Object does not have state
    }
}
Also used : CompositeMethodDetailDescriptor(org.qi4j.tools.model.descriptor.CompositeMethodDetailDescriptor) ObjectDetailDescriptor(org.qi4j.tools.model.descriptor.ObjectDetailDescriptor) CompositeDetailDescriptor(org.qi4j.tools.model.descriptor.CompositeDetailDescriptor)

Aggregations

ObjectDetailDescriptor (org.qi4j.tools.model.descriptor.ObjectDetailDescriptor)8 CompositeDetailDescriptor (org.qi4j.tools.model.descriptor.CompositeDetailDescriptor)4 MixinDetailDescriptor (org.qi4j.tools.model.descriptor.MixinDetailDescriptor)3 CompositeMethodDetailDescriptor (org.qi4j.tools.model.descriptor.CompositeMethodDetailDescriptor)2 EntityDetailDescriptor (org.qi4j.tools.model.descriptor.EntityDetailDescriptor)2 ServiceDetailDescriptor (org.qi4j.tools.model.descriptor.ServiceDetailDescriptor)2 ServiceUsage (org.qi4j.tools.model.descriptor.ServiceUsage)2 ValueDetailDescriptor (org.qi4j.tools.model.descriptor.ValueDetailDescriptor)2 Component (java.awt.Component)1 Annotation (java.lang.annotation.Annotation)1 ArrayList (java.util.ArrayList)1 DependencyDescriptor (org.qi4j.api.composite.DependencyDescriptor)1 ModelDescriptor (org.qi4j.api.composite.ModelDescriptor)1 Service (org.qi4j.api.injection.scope.Service)1 Uses (org.qi4j.api.injection.scope.Uses)1 ImportedServiceDetailDescriptor (org.qi4j.tools.model.descriptor.ImportedServiceDetailDescriptor)1 InjectedFieldDetailDescriptor (org.qi4j.tools.model.descriptor.InjectedFieldDetailDescriptor)1 LayerDetailDescriptor (org.qi4j.tools.model.descriptor.LayerDetailDescriptor)1 ModuleDetailDescriptor (org.qi4j.tools.model.descriptor.ModuleDetailDescriptor)1 TransientDetailDescriptor (org.qi4j.tools.model.descriptor.TransientDetailDescriptor)1