Search in sources :

Example 11 with Classifier

use of org.geotoolkit.sml.xml.v101.Classifier in project AGREE by loonwerks.

the class AgreeScopeProvider method getNamedElements.

private Map<String, NamedElement> getNamedElements(EObject ctx) {
    Map<String, NamedElement> components = new HashMap<>();
    if (ctx instanceof AadlPackage) {
        components.put(((AadlPackage) ctx).getName(), (AadlPackage) ctx);
        PublicPackageSection pubSec = ((AadlPackage) ctx).getPublicSection();
        for (Element el : pubSec.getOwnedElements()) {
            if (el instanceof DataImplementation || el instanceof DataType) {
                components.put(((NamedElement) el).getName(), (NamedElement) el);
            }
        }
        for (AnnexLibrary annex : AnnexUtil.getAllActualAnnexLibraries(((AadlPackage) ctx), AgreePackage.eINSTANCE.getAgreeContractLibrary())) {
            AgreeContract contract = (AgreeContract) ((AgreeContractLibrary) annex).getContract();
            components.putAll(getNamedElementsFromSpecs(contract.getSpecs()));
        }
    } else {
        components.putAll(getNamedElementsFromClassifier((Classifier) ctx, false));
    }
    return components;
}
Also used : AgreeContract(com.rockwellcollins.atc.agree.agree.AgreeContract) AadlPackage(org.osate.aadl2.AadlPackage) PublicPackageSection(org.osate.aadl2.PublicPackageSection) HashMap(java.util.HashMap) Element(org.osate.aadl2.Element) NamedElement(org.osate.aadl2.NamedElement) DataImplementation(org.osate.aadl2.DataImplementation) DataType(org.osate.aadl2.DataType) Classifier(org.osate.aadl2.Classifier) ComponentClassifier(org.osate.aadl2.ComponentClassifier) AnnexLibrary(org.osate.aadl2.AnnexLibrary) NamedElement(org.osate.aadl2.NamedElement)

Example 12 with Classifier

use of org.geotoolkit.sml.xml.v101.Classifier in project AGREE by loonwerks.

the class AgreeScopeProvider method getNamedElementsFromClassifier.

private Map<String, NamedElement> getNamedElementsFromClassifier(Classifier ctx, boolean fromCompImpl) {
    Map<String, NamedElement> components = new HashMap<>();
    components.putAll(getNamedElements(getAadlContainer(ctx)));
    for (AnnexSubclause annex : AnnexUtil.getAllAnnexSubclauses(ctx, AgreePackage.eINSTANCE.getAgreeContractSubclause())) {
        AgreeContract contract = (AgreeContract) ((AgreeContractSubclause) annex).getContract();
        components.putAll(getNamedElementsFromSpecs(contract.getSpecs()));
    }
    Classifier extended = ctx.getExtended();
    if (extended != null) {
        components.putAll(getNamedElementsFromClassifier(extended, false));
    }
    if (ctx instanceof ComponentImplementation) {
        components.putAll(getNamedElementsFromClassifier(((ComponentImplementation) ctx).getType(), true));
        ArrayList<NamedElement> nes = new ArrayList<>();
        nes.addAll(((ComponentImplementation) ctx).getAllSubcomponents());
        nes.addAll(((ComponentImplementation) ctx).getAllConnections());
        components.putAll(toNamedElementMap(nes));
    } else if (ctx instanceof ComponentType) {
        if (fromCompImpl) {
            ArrayList<NamedElement> nes = new ArrayList<>();
            nes.addAll(((ComponentType) ctx).getAllFeatures());
            components.putAll(toNamedElementMap(nes));
        } else {
            ArrayList<NamedElement> nes = new ArrayList<>();
            nes.addAll(((ComponentType) ctx).getOwnedFeatures());
            components.putAll(toNamedElementMap(nes));
        }
    }
    return components;
}
Also used : AgreeContract(com.rockwellcollins.atc.agree.agree.AgreeContract) ComponentImplementation(org.osate.aadl2.ComponentImplementation) ComponentType(org.osate.aadl2.ComponentType) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) Classifier(org.osate.aadl2.Classifier) ComponentClassifier(org.osate.aadl2.ComponentClassifier) NamedElement(org.osate.aadl2.NamedElement) AnnexSubclause(org.osate.aadl2.AnnexSubclause)

Example 13 with Classifier

use of org.geotoolkit.sml.xml.v101.Classifier in project osate2 by osate.

the class Aadl2LocationInFile method getSecondaryTextRegion.

public ITextRegion getSecondaryTextRegion(EObject obj, boolean typeName) {
    if (obj instanceof ModelUnit || obj instanceof Classifier) {
        ICompositeNode node = NodeModelUtils.getNode(obj);
        INode endID = node.getLastChild().getPreviousSibling();
        List<INode> nodes = null;
        while (endID instanceof HiddenLeafNode) {
            endID = endID.getPreviousSibling();
        }
        nodes = Collections.<INode>singletonList(endID);
        if (endID instanceof ICompositeNode) {
            ICompositeNode fullName = (ICompositeNode) endID;
            if (obj instanceof AadlPackage) {
                nodes = new ArrayList<INode>();
                endID = fullName.getLastChild();
                while (endID instanceof HiddenLeafNode) {
                    endID = endID.getPreviousSibling();
                }
                INode id = fullName.getFirstChild();
                while (id instanceof HiddenLeafNode) {
                    id = id.getNextSibling();
                }
                if (id != null) {
                    nodes.add(id);
                    while (id != endID) {
                        id = id.getNextSibling();
                        nodes.add(id);
                    }
                }
            } else if (typeName) {
                endID = fullName.getFirstChild();
                while (endID instanceof HiddenLeafNode) {
                    endID = endID.getNextSibling();
                }
                nodes = Collections.<INode>singletonList(endID);
            } else {
                endID = fullName.getLastChild();
                while (endID instanceof HiddenLeafNode) {
                    endID = endID.getPreviousSibling();
                }
                nodes = Collections.<INode>singletonList(endID);
            }
        }
        return createRegion(nodes);
    } else {
        return null;
    }
}
Also used : INode(org.eclipse.xtext.nodemodel.INode) AadlPackage(org.osate.aadl2.AadlPackage) ModelUnit(org.osate.aadl2.ModelUnit) ICompositeNode(org.eclipse.xtext.nodemodel.ICompositeNode) Classifier(org.osate.aadl2.Classifier) HiddenLeafNode(org.eclipse.xtext.nodemodel.impl.HiddenLeafNode)

Example 14 with Classifier

use of org.geotoolkit.sml.xml.v101.Classifier in project osate2 by osate.

the class CreateFeaturePaletteCommand method getOperation.

@Override
public Optional<Operation> getOperation(final GetTargetedOperationContext ctx) {
    return ctx.getTarget().getBusinessObject(EObject.class).map(targetBo -> {
        final AadlOperationBuilder<Classifier> opBuilder = AadlOperationBuilder.classifiers().filter(c -> AadlFeatureUtil.canOwnFeatureType(c, featureType));
        if (!opBuilder.canBuildOperation(targetBo)) {
            return null;
        }
        return Operation.createWithBuilder(createOp -> {
            // Create the feature
            opBuilder.buildOperation(createOp, targetBo).modifyPreviousResult(owner -> {
                final String newFeatureName = AadlNamingUtil.buildUniqueIdentifier(owner, "new_feature");
                final NamedElement newFeature = AadlFeatureUtil.createFeature(owner, featureType);
                newFeature.setName(newFeatureName);
                // Set in or out based on target docking position
                final boolean isRight = ctx.getDockingPosition() == DockingPosition.RIGHT;
                if (newFeature instanceof DirectedFeature) {
                    if (!(newFeature instanceof FeatureGroup)) {
                        final DirectedFeature newDirectedFeature = (DirectedFeature) newFeature;
                        newDirectedFeature.setIn(!isRight);
                        newDirectedFeature.setOut(isRight);
                    }
                } else if (newFeature instanceof Access) {
                    final Access access = (Access) newFeature;
                    access.setKind(isRight ? AccessType.PROVIDES : AccessType.REQUIRES);
                }
                if (owner instanceof ComponentType) {
                    ((ComponentType) owner).setNoFeatures(false);
                }
                return StepResultBuilder.create().showNewBusinessObject(ctx.getTarget(), newFeature).build();
            });
        });
    });
}
Also used : FeatureGroup(org.osate.aadl2.FeatureGroup) ComponentType(org.osate.aadl2.ComponentType) EObject(org.eclipse.emf.ecore.EObject) Access(org.osate.aadl2.Access) DirectedFeature(org.osate.aadl2.DirectedFeature) Classifier(org.osate.aadl2.Classifier) NamedElement(org.osate.aadl2.NamedElement)

Example 15 with Classifier

use of org.geotoolkit.sml.xml.v101.Classifier in project osate2 by osate.

the class OpenAssociatedDiagramHandler method setEnabled.

@Override
public void setEnabled(final Object evaluationContext) {
    boolean enabled = false;
    final List<BusinessObjectContext> selectedBusinessObjectContexts = AgeHandlerUtil.getSelectedBusinessObjectContexts();
    if (selectedBusinessObjectContexts.size() == 1) {
        final BusinessObjectContext selectedBusinessObjectContext = selectedBusinessObjectContexts.get(0);
        final Object bo = selectedBusinessObjectContext.getBusinessObject();
        enabled = (bo instanceof AadlPackage || bo instanceof Classifier || (bo instanceof Subcomponent && AadlSubcomponentUtil.getComponentClassifier(selectedBusinessObjectContext, (Subcomponent) bo) != null)) && ProjectUtil.getProjectForBo(bo).isPresent();
    }
    setBaseEnabled(enabled);
}
Also used : AadlPackage(org.osate.aadl2.AadlPackage) Subcomponent(org.osate.aadl2.Subcomponent) ComponentClassifier(org.osate.aadl2.ComponentClassifier) Classifier(org.osate.aadl2.Classifier) BusinessObjectContext(org.osate.ge.BusinessObjectContext)

Aggregations

Classifier (org.osate.aadl2.Classifier)203 ComponentClassifier (org.osate.aadl2.ComponentClassifier)90 ComponentImplementation (org.osate.aadl2.ComponentImplementation)49 NamedElement (org.osate.aadl2.NamedElement)40 AadlPackage (org.osate.aadl2.AadlPackage)38 Subcomponent (org.osate.aadl2.Subcomponent)37 ComponentType (org.osate.aadl2.ComponentType)34 EObject (org.eclipse.emf.ecore.EObject)31 ArrayList (java.util.ArrayList)29 BasicEList (org.eclipse.emf.common.util.BasicEList)28 Feature (org.osate.aadl2.Feature)26 DataClassifier (org.osate.aadl2.DataClassifier)22 FeatureGroupType (org.osate.aadl2.FeatureGroupType)21 ProcessorClassifier (org.osate.aadl2.ProcessorClassifier)21 AnnexSubclause (org.osate.aadl2.AnnexSubclause)17 Element (org.osate.aadl2.Element)17 EList (org.eclipse.emf.common.util.EList)15 ComponentInstance (org.osate.aadl2.instance.ComponentInstance)15 FeatureGroup (org.osate.aadl2.FeatureGroup)14 PropertyExpression (org.osate.aadl2.PropertyExpression)14