Search in sources :

Example 1 with DependencyDescriptor

use of org.qi4j.api.composite.DependencyDescriptor in project qi4j-sdk by Qi4j.

the class DependencyPane method reloadDetail.

private void reloadDetail(InjectedFieldDetailDescriptor descriptor) {
    clearDetail();
    if (descriptor == null) {
        return;
    }
    DependencyDescriptor dependencyDescriptor = descriptor.descriptor().dependency();
    classNameLabel.setText(dependencyDescriptor.injectedClass().getSimpleName());
    classNameLabel.setToolTipText(dependencyDescriptor.injectedClass().getName());
    annotationLabel.setText("@" + dependencyDescriptor.injectionAnnotation().annotationType().getSimpleName());
    optionalLabel.setText(Boolean.toString(dependencyDescriptor.optional()));
    injectionTypeLabel.setText(Classes.simpleGenericNameOf(dependencyDescriptor.injectionType()));
    injectionTypeLabel.setToolTipText(dependencyDescriptor.injectionType().toString());
}
Also used : DependencyDescriptor(org.qi4j.api.composite.DependencyDescriptor)

Example 2 with DependencyDescriptor

use of org.qi4j.api.composite.DependencyDescriptor in project qi4j-sdk by Qi4j.

the class Model2XML method map.

@Override
public Document map(ApplicationDescriptor Application) {
    try {
        DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
        final Document document = builder.newDocument();
        final Stack<Node> current = new Stack<Node>();
        current.push(document);
        Application.accept(new HierarchicalVisitor<Object, Object, DOMException>() {

            @Override
            public boolean visitEnter(Object visited) throws DOMException {
                String mapping = simpleMappings.get(visited.getClass().getSimpleName());
                if (mapping != null) {
                    Node node = document.createElement("mapping");
                    current.push(node);
                } else if (visited instanceof ApplicationDescriptor) {
                    ApplicationDescriptor applicationDescriptor = (ApplicationDescriptor) visited;
                    Node application = document.createElement("application");
                    addAttribute("name", applicationDescriptor.name(), application);
                    current.push(application);
                } else if (visited instanceof LayerDescriptor) {
                    LayerDescriptor layerDescriptor = (LayerDescriptor) visited;
                    Node layer = document.createElement("layer");
                    addAttribute("name", layerDescriptor.name(), layer);
                    current.push(layer);
                } else if (visited instanceof ModuleDescriptor) {
                    ModuleDescriptor moduleDescriptor = (ModuleDescriptor) visited;
                    Node module = document.createElement("module");
                    addAttribute("name", moduleDescriptor.name(), module);
                    current.push(module);
                } else if (visited instanceof TransientDescriptor) {
                    TransientDescriptor descriptor = (TransientDescriptor) visited;
                    Node node = document.createElement("transient");
                    addAttribute("type", first(descriptor.types()).getName(), node);
                    addAttribute("visibility", descriptor.visibility().name(), node);
                    current.push(node);
                } else if (visited instanceof MethodDescriptor) {
                    MethodDescriptor descriptor = (MethodDescriptor) visited;
                    Node node = document.createElement("method");
                    addAttribute("name", descriptor.method().getName(), node);
                    current.push(node);
                } else if (visited instanceof MixinDescriptor) {
                    MixinDescriptor descriptor = (MixinDescriptor) visited;
                    Node node = document.createElement("mixin");
                    addAttribute("class", descriptor.mixinClass().getName(), node);
                    current.push(node);
                } else if (visited instanceof DependencyDescriptor) {
                    DependencyDescriptor descriptor = (DependencyDescriptor) visited;
                    Node node = document.createElement("dependency");
                    addAttribute("annotation", descriptor.injectionAnnotation().toString(), node);
                    addAttribute("injection", descriptor.injectionType().toString(), node);
                    addAttribute("optional", Boolean.toString(descriptor.optional()), node);
                    current.push(node);
                } else {
                    Element element = document.createElement(visited.getClass().getSimpleName());
                    current.push(element);
                }
                return true;
            }

            @Override
            public boolean visitLeave(Object visited) throws DOMException {
                Node node = current.pop();
                if (node.getChildNodes().getLength() == 0 && node.getAttributes().getLength() == 0) {
                    return true;
                }
                current.peek().appendChild(node);
                return true;
            }

            @Override
            public boolean visit(Object visited) throws DOMException {
                Element element;
                if (visited instanceof DependencyDescriptor) {
                    DependencyDescriptor descriptor = (DependencyDescriptor) visited;
                    element = document.createElement("dependency");
                    addAttribute("annotation", descriptor.injectionAnnotation().toString(), element);
                    addAttribute("injection", descriptor.injectionType().toString(), element);
                    addAttribute("optional", Boolean.toString(descriptor.optional()), element);
                } else {
                    element = document.createElement(visited.getClass().getSimpleName());
                }
                current.peek().appendChild(element);
                return true;
            }

            private void addAttribute(String name, String value, Node node) {
                Attr attr = document.createAttribute(name);
                attr.setValue(value);
                ((Element) node).setAttributeNode(attr);
            }
        });
        return document;
    } catch (Exception exception) {
        throw new IllegalArgumentException(exception);
    }
}
Also used : DependencyDescriptor(org.qi4j.api.composite.DependencyDescriptor) Node(org.w3c.dom.Node) Element(org.w3c.dom.Element) MixinDescriptor(org.qi4j.api.mixin.MixinDescriptor) Document(org.w3c.dom.Document) MethodDescriptor(org.qi4j.api.composite.MethodDescriptor) ApplicationDescriptor(org.qi4j.api.structure.ApplicationDescriptor) Attr(org.w3c.dom.Attr) DOMException(org.w3c.dom.DOMException) Stack(java.util.Stack) DOMException(org.w3c.dom.DOMException) ModuleDescriptor(org.qi4j.api.structure.ModuleDescriptor) DocumentBuilder(javax.xml.parsers.DocumentBuilder) TransientDescriptor(org.qi4j.api.composite.TransientDescriptor) LayerDescriptor(org.qi4j.api.structure.LayerDescriptor)

Example 3 with DependencyDescriptor

use of org.qi4j.api.composite.DependencyDescriptor in project qi4j-sdk by Qi4j.

the class DependencyPane method reload.

private void reload(Iterable<InjectedFieldDetailDescriptor> iter) {
    for (InjectedFieldDetailDescriptor descriptor : iter) {
        DependencyDescriptor dependencyDescriptor = descriptor.descriptor().dependency();
        Annotation annotation = dependencyDescriptor.injectionAnnotation();
        if (isDependencyField(annotation.annotationType())) {
            fieldListModel.addElement(descriptor);
        }
    }
}
Also used : InjectedFieldDetailDescriptor(org.qi4j.tools.model.descriptor.InjectedFieldDetailDescriptor) DependencyDescriptor(org.qi4j.api.composite.DependencyDescriptor) Annotation(java.lang.annotation.Annotation)

Example 4 with DependencyDescriptor

use of org.qi4j.api.composite.DependencyDescriptor in project qi4j-sdk by Qi4j.

the class PDFWriter method writeTypeServiceUsagePage.

private void writeTypeServiceUsagePage(Object objectDesciptor) {
    setFont(header5Font, header5FontSize);
    writeString("Usage: ", headerLineSpace);
    setFont(normalFont, normalFontSize);
    List<ServiceUsage> serviceUsages = DescriptorUtilities.findServiceUsage((ServiceDetailDescriptor) objectDesciptor);
    List<TableRow> rows = TableRowUtilities.toTableRows(serviceUsages);
    for (TableRow row : rows) {
        //String owner;
        String usage;
        String module;
        String layer;
        Object obj = row.get(0);
        if (obj instanceof CompositeDetailDescriptor) {
            CompositeDetailDescriptor descriptor = (CompositeDetailDescriptor) obj;
            //owner = descriptor.toString();
            module = descriptor.module().toString();
            layer = descriptor.module().layer().toString();
        } else {
            ObjectDetailDescriptor descriptor = (ObjectDetailDescriptor) obj;
            //owner = descriptor.toString();
            module = descriptor.module().toString();
            layer = descriptor.module().layer().toString();
        }
        InjectedFieldDetailDescriptor injectedFieldescriptor = (InjectedFieldDetailDescriptor) row.get(1);
        DependencyDescriptor dependencyDescriptor = injectedFieldescriptor.descriptor().dependency();
        Annotation annotation = dependencyDescriptor.injectionAnnotation();
        usage = injectedFieldescriptor.toString() + " (@" + annotation.annotationType().getSimpleName() + ")";
        writeString("- owner: " + row.get(0).toString());
        writeString("    * usage: " + usage);
        writeString("    * module: " + module);
        writeString("    * layer: " + layer);
    }
}
Also used : DependencyDescriptor(org.qi4j.api.composite.DependencyDescriptor) TableRow(org.qi4j.envisage.util.TableRow) Annotation(java.lang.annotation.Annotation)

Example 5 with DependencyDescriptor

use of org.qi4j.api.composite.DependencyDescriptor in project qi4j-sdk by Qi4j.

the class PDFWriter method writeTypeDependenciesPage.

private void writeTypeDependenciesPage(Iterable<InjectedFieldDetailDescriptor> iter) {
    setFont(normalFont, normalFontSize);
    for (InjectedFieldDetailDescriptor descriptor : iter) {
        DependencyDescriptor dependencyDescriptor = descriptor.descriptor().dependency();
        writeString("- name: " + dependencyDescriptor.injectedClass().getSimpleName());
        writeString("    * annotation: @" + dependencyDescriptor.injectionAnnotation().annotationType().getSimpleName());
        writeString("    * optional: " + Boolean.toString(dependencyDescriptor.optional()));
        writeString("    * type: " + dependencyDescriptor.injectionType().getClass().getSimpleName());
    }
}
Also used : DependencyDescriptor(org.qi4j.api.composite.DependencyDescriptor)

Aggregations

DependencyDescriptor (org.qi4j.api.composite.DependencyDescriptor)6 Annotation (java.lang.annotation.Annotation)3 InjectedFieldDetailDescriptor (org.qi4j.tools.model.descriptor.InjectedFieldDetailDescriptor)2 Stack (java.util.Stack)1 DocumentBuilder (javax.xml.parsers.DocumentBuilder)1 MethodDescriptor (org.qi4j.api.composite.MethodDescriptor)1 TransientDescriptor (org.qi4j.api.composite.TransientDescriptor)1 Service (org.qi4j.api.injection.scope.Service)1 Uses (org.qi4j.api.injection.scope.Uses)1 MixinDescriptor (org.qi4j.api.mixin.MixinDescriptor)1 ApplicationDescriptor (org.qi4j.api.structure.ApplicationDescriptor)1 LayerDescriptor (org.qi4j.api.structure.LayerDescriptor)1 ModuleDescriptor (org.qi4j.api.structure.ModuleDescriptor)1 TableRow (org.qi4j.envisage.util.TableRow)1 MixinDetailDescriptor (org.qi4j.tools.model.descriptor.MixinDetailDescriptor)1 ObjectDetailDescriptor (org.qi4j.tools.model.descriptor.ObjectDetailDescriptor)1 ServiceUsage (org.qi4j.tools.model.descriptor.ServiceUsage)1 Attr (org.w3c.dom.Attr)1 DOMException (org.w3c.dom.DOMException)1 Document (org.w3c.dom.Document)1