Search in sources :

Example 1 with EntityDetailDescriptor

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

the class EntityViewer method initEntityCombo.

private void initEntityCombo(DefaultComboBoxModel entityComboModel) {
    // create the visitor to traverse the QI4J to find the module
    ApplicationDetailDescriptor visitor = ApplicationDetailDescriptorBuilder.createApplicationDetailDescriptor(model);
    // find all entities
    Iterable<LayerDetailDescriptor> layerDescIter = visitor.layers();
    for (LayerDetailDescriptor layerDesc : layerDescIter) {
        Iterable<ModuleDetailDescriptor> moduleDescIter = layerDesc.modules();
        for (ModuleDetailDescriptor moduleDesc : moduleDescIter) {
            Iterable<EntityDetailDescriptor> entityDescIter = moduleDesc.entities();
            for (EntityDetailDescriptor entity : entityDescIter) {
                entityComboModel.addElement(entity);
            }
        }
    }
}
Also used : ApplicationDetailDescriptor(org.qi4j.tools.model.descriptor.ApplicationDetailDescriptor) EntityDetailDescriptor(org.qi4j.tools.model.descriptor.EntityDetailDescriptor) LayerDetailDescriptor(org.qi4j.tools.model.descriptor.LayerDetailDescriptor) ModuleDetailDescriptor(org.qi4j.tools.model.descriptor.ModuleDetailDescriptor)

Example 2 with EntityDetailDescriptor

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

the class EntityViewer method treePanelValueChanged.

/**
     * Event Handler for TreePanel
     *
     * @param evt the Event
     */
public void treePanelValueChanged(TreeSelectionEvent evt) {
    TreePath path = evt.getPath();
    Object source = path.getLastPathComponent();
    if (source == null) {
        return;
    }
    DefaultMutableTreeNode node = (DefaultMutableTreeNode) source;
    Object obj = node.getUserObject();
    if (obj == null) {
        return;
    }
    Class<?> clazz = obj.getClass();
    if (EntityDetailDescriptor.class.isAssignableFrom(clazz)) {
        EntityDetailDescriptor entityDesc = (EntityDetailDescriptor) obj;
        Class entityType = first(entityDesc.descriptor().types());
        // Update the selected item on the combo box, which in turn update the properties table
        ComboBoxModel comboModel = entitiesCombo.getModel();
        int index = -1;
        for (int i = 0; i < comboModel.getSize(); i++) {
            EntityDetailDescriptor entityDesc1 = (EntityDetailDescriptor) comboModel.getElementAt(i);
            Class entityType1 = first(entityDesc1.descriptor().types());
            if (entityType1.equals(entityType)) {
                index = i;
                break;
            }
        }
        if (index >= 0) {
            entitiesCombo.setSelectedIndex(index);
        }
    }
}
Also used : TreePath(javax.swing.tree.TreePath) DefaultMutableTreeNode(javax.swing.tree.DefaultMutableTreeNode) EntityDetailDescriptor(org.qi4j.tools.model.descriptor.EntityDetailDescriptor) DefaultComboBoxModel(javax.swing.DefaultComboBoxModel) ComboBoxModel(javax.swing.ComboBoxModel)

Example 3 with EntityDetailDescriptor

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

the class EntityViewer method entitiesComboItemStateChanged.

/**
     * Event Handler for EntitiesComboBox
     *
     * @param evt the Event
     */
private void entitiesComboItemStateChanged(ItemEvent evt) {
    if (evt.getStateChange() == ItemEvent.DESELECTED) {
        return;
    }
    EntityDetailDescriptor entityDescriptor = (EntityDetailDescriptor) entitiesCombo.getSelectedItem();
    Class clazz = first(entityDescriptor.descriptor().types());
    Module module = findModule(entityDescriptor);
    Query query = createQuery(module, clazz);
    propertiesPanel.reload(query);
}
Also used : Query(org.qi4j.api.query.Query) EntityDetailDescriptor(org.qi4j.tools.model.descriptor.EntityDetailDescriptor) Module(org.qi4j.api.structure.Module)

Example 4 with EntityDetailDescriptor

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

the class GraphBuilder method buildEntitiesNode.

private void buildEntitiesNode(Node parent, Iterable<EntityDetailDescriptor> iter) {
    sortTypeChildren(iter);
    boolean first = true;
    for (Object obj : childList) {
        EntityDetailDescriptor descriptor = (EntityDetailDescriptor) obj;
        if (first) {
            String name = "Entities";
            parent = addChild(parent, name, name);
            first = false;
        }
        addChild(parent, descriptor.descriptor().toString(), descriptor);
    }
}
Also used : EntityDetailDescriptor(org.qi4j.tools.model.descriptor.EntityDetailDescriptor)

Example 5 with EntityDetailDescriptor

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

the class DetailModelPane method setDescriptorImpl.

private void setDescriptorImpl(Object objectDescriptor) {
    Component curSelectedComp = tabPane.getSelectedComponent();
    tabPane.removeAll();
    generalPane.setDescriptor(objectDescriptor);
    dependencyPane.setDescriptor(objectDescriptor);
    methodPane.setDescriptor(objectDescriptor);
    statePane.setDescriptor(objectDescriptor);
    serviceConfigurationPane.setDescriptor(objectDescriptor);
    serviceUsagePane.setDescriptor(objectDescriptor);
    importedByPane.setDescriptor(objectDescriptor);
    apiPane.setDescriptor(objectDescriptor);
    spiPane.setDescriptor(objectDescriptor);
    if (objectDescriptor instanceof LayerDetailDescriptor || objectDescriptor instanceof ModuleDetailDescriptor) {
        tabPane.add(bundle.getString("CTL_APITab.Text"), apiPane);
        tabPane.add(bundle.getString("CTL_SPITab.Text"), spiPane);
    } else if (objectDescriptor instanceof ServiceDetailDescriptor) {
        tabPane.add(bundle.getString("CTL_GeneralTab.Text"), generalPane);
        tabPane.add(bundle.getString("CTL_DependencyTab.Text"), dependencyPane);
        tabPane.add(bundle.getString("CTL_MethodTab.Text"), methodPane);
        tabPane.add(bundle.getString("CTL_StateTab.Text"), statePane);
        tabPane.add(bundle.getString("CTL_ServiceConfiguration.Text"), serviceConfigurationPane);
        tabPane.add(bundle.getString("CTL_ServiceUsage.Text"), serviceUsagePane);
    } else if (objectDescriptor instanceof ImportedServiceDetailDescriptor) {
        tabPane.add(bundle.getString("CTL_GeneralTab.Text"), generalPane);
        tabPane.add(bundle.getString("CTL_MethodTab.Text"), methodPane);
        tabPane.add(bundle.getString("CTL_ServiceUsage.Text"), serviceUsagePane);
        tabPane.add(bundle.getString("CTL_ImportedBy.Text"), importedByPane);
    } else if (objectDescriptor instanceof EntityDetailDescriptor) {
        tabPane.add(bundle.getString("CTL_GeneralTab.Text"), generalPane);
        tabPane.add(bundle.getString("CTL_DependencyTab.Text"), dependencyPane);
        tabPane.add(bundle.getString("CTL_MethodTab.Text"), methodPane);
        tabPane.add(bundle.getString("CTL_StateTab.Text"), statePane);
    } else if (objectDescriptor instanceof ValueDetailDescriptor) {
        tabPane.add(bundle.getString("CTL_GeneralTab.Text"), generalPane);
        tabPane.add(bundle.getString("CTL_DependencyTab.Text"), dependencyPane);
        tabPane.add(bundle.getString("CTL_MethodTab.Text"), methodPane);
        tabPane.add(bundle.getString("CTL_StateTab.Text"), statePane);
    } else if (objectDescriptor instanceof ObjectDetailDescriptor) {
        tabPane.add(bundle.getString("CTL_GeneralTab.Text"), generalPane);
        tabPane.add(bundle.getString("CTL_DependencyTab.Text"), dependencyPane);
        tabPane.add(bundle.getString("CTL_MethodTab.Text"), methodPane);
    } else if (objectDescriptor instanceof TransientDetailDescriptor) {
        tabPane.add(bundle.getString("CTL_GeneralTab.Text"), generalPane);
        tabPane.add(bundle.getString("CTL_DependencyTab.Text"), dependencyPane);
        tabPane.add(bundle.getString("CTL_MethodTab.Text"), methodPane);
        tabPane.add(bundle.getString("CTL_StateTab.Text"), statePane);
    }
    if (linkActivatedInProgress) {
        // for linking always display the first tab (General)
        linkActivatedInProgress = false;
        tabPane.setSelectedIndex(0);
    } else {
        // if not linking, then maintain the current selected tab
        if (curSelectedComp != null) {
            int index = tabPane.indexOfComponent(curSelectedComp);
            if (index != -1) {
                tabPane.setSelectedIndex(index);
            }
        }
    }
}
Also used : ImportedServiceDetailDescriptor(org.qi4j.tools.model.descriptor.ImportedServiceDetailDescriptor) ServiceDetailDescriptor(org.qi4j.tools.model.descriptor.ServiceDetailDescriptor) EntityDetailDescriptor(org.qi4j.tools.model.descriptor.EntityDetailDescriptor) LayerDetailDescriptor(org.qi4j.tools.model.descriptor.LayerDetailDescriptor) ModuleDetailDescriptor(org.qi4j.tools.model.descriptor.ModuleDetailDescriptor) ImportedServiceDetailDescriptor(org.qi4j.tools.model.descriptor.ImportedServiceDetailDescriptor) ValueDetailDescriptor(org.qi4j.tools.model.descriptor.ValueDetailDescriptor) ObjectDetailDescriptor(org.qi4j.tools.model.descriptor.ObjectDetailDescriptor) Component(java.awt.Component) TransientDetailDescriptor(org.qi4j.tools.model.descriptor.TransientDetailDescriptor)

Aggregations

EntityDetailDescriptor (org.qi4j.tools.model.descriptor.EntityDetailDescriptor)6 LayerDetailDescriptor (org.qi4j.tools.model.descriptor.LayerDetailDescriptor)2 ModuleDetailDescriptor (org.qi4j.tools.model.descriptor.ModuleDetailDescriptor)2 ObjectDetailDescriptor (org.qi4j.tools.model.descriptor.ObjectDetailDescriptor)2 ServiceDetailDescriptor (org.qi4j.tools.model.descriptor.ServiceDetailDescriptor)2 ValueDetailDescriptor (org.qi4j.tools.model.descriptor.ValueDetailDescriptor)2 Component (java.awt.Component)1 ComboBoxModel (javax.swing.ComboBoxModel)1 DefaultComboBoxModel (javax.swing.DefaultComboBoxModel)1 DefaultMutableTreeNode (javax.swing.tree.DefaultMutableTreeNode)1 TreePath (javax.swing.tree.TreePath)1 ModelDescriptor (org.qi4j.api.composite.ModelDescriptor)1 Query (org.qi4j.api.query.Query)1 Module (org.qi4j.api.structure.Module)1 ApplicationDetailDescriptor (org.qi4j.tools.model.descriptor.ApplicationDetailDescriptor)1 CompositeDetailDescriptor (org.qi4j.tools.model.descriptor.CompositeDetailDescriptor)1 ImportedServiceDetailDescriptor (org.qi4j.tools.model.descriptor.ImportedServiceDetailDescriptor)1 TransientDetailDescriptor (org.qi4j.tools.model.descriptor.TransientDetailDescriptor)1