Search in sources :

Example 11 with FeatureGroupType

use of org.osate.aadl2.FeatureGroupType in project osate2 by osate.

the class ClassifierInfoView method updateDisplay.

// Synchronized to make manipulation of the currentRefreshJob atomic
private synchronized void updateDisplay(final Classifier inputHierarchy, final Classifier inputMember) {
    // Stop any current refresh job
    if (currentRefreshJob != null) {
        currentRefreshJob.cancel();
    }
    final Job waitForJob = currentRefreshJob;
    // Compute the tree in a separate job and then update the view on the display thread.
    final IWorkbenchSiteProgressService service = getSite().getService(IWorkbenchSiteProgressService.class);
    final Job refreshJob = new Job("Classifier Info View Refresh") {

        @Override
        protected IStatus run(final IProgressMonitor monitor) {
            // Wait for the current refresh to finish (it should have been cancelled)
            if (waitForJob != null) {
                try {
                    waitForJob.join();
                } catch (final OperationCanceledException | InterruptedException e) {
                    /*
						 * We were interrupted while waiting. Not sure this should be possible, but
						 * if it happens, we clear the display.
						 */
                    clearDisplay(false);
                    return Status.CANCEL_STATUS;
                }
            }
            boolean needsRefresh = false;
            boolean skipMember = false;
            final SubMonitor subMonitor = SubMonitor.convert(monitor, 2);
            if (inputHierarchy != null) {
                subMonitor.subTask("Buidling classifier hiearchy");
                final Set<IProject> projects = getDependantProjects(inputHierarchy);
                projectDependancies.addAll(projects);
                try {
                    final AncestorTree ancestorTreeModel = createAncestorTree(inputHierarchy, subMonitor);
                    subMonitor.worked(1);
                    final DescendantTree descendantTreeModel = createDescendantTree(inputHierarchy, projects, subMonitor.split(1));
                    // Update the view contents in the UI thread
                    getViewSite().getShell().getDisplay().asyncExec(() -> {
                        ancestorTreeViewer.setInput(ancestorTreeModel);
                        ancestorTreeViewer.expandToLevel(2);
                        ancestorTreeViewer.setSelection(new TreeSelection(new TreePath(ancestorTreeModel.getChildren())));
                        descendantTreeViewer.setInput(descendantTreeModel);
                        descendantTreeViewer.expandToLevel(2);
                        descendantTreeViewer.setSelection(new TreeSelection(new TreePath(descendantTreeModel.getChildren())));
                    });
                } catch (final OperationCanceledException | InterruptedException e) {
                    /*
						 * Hierarchy build cancelled-- clear both panes. Originally we just cleared the
						 * hierarchy pane, but then it is confusing what is being shown in the member pane.
						 * Set the 'skip' flag so we don't readd the member pane below.
						 */
                    clearDisplay(false);
                    // Update incomplete, so we still need to refresh later
                    needsRefresh = true;
                    skipMember = true;
                }
                subMonitor.done();
            } else {
                subMonitor.worked(2);
            }
            if (inputMember != null && !skipMember) {
                final MemberTree memberTree;
                if (inputMember instanceof ComponentType) {
                    memberTree = createMemberTree((ComponentType) inputMember);
                } else if (inputMember instanceof ComponentImplementation) {
                    memberTree = createMemberTree((ComponentImplementation) inputMember);
                } else if (inputMember instanceof FeatureGroupType) {
                    memberTree = createMemberTree((FeatureGroupType) inputMember);
                } else {
                    // Shouldn't get here
                    memberTree = null;
                }
                if (memberTree != null) {
                    // Update the view contents in the UI thread
                    getViewSite().getShell().getDisplay().asyncExec(() -> {
                        memberTreeViewer.setInput(memberTree);
                        memberTreeViewer.expandToLevel(2);
                    });
                } else {
                    clearMembers(false);
                }
            }
            setNeedsRefresh(needsRefresh);
            // Mark the view as changed (should show up with a bold title)
            service.warnOfContentChange();
            return Status.OK_STATUS;
        }
    };
    // doesn't write resources
    refreshJob.setRule(null);
    refreshJob.setUser(true);
    refreshJob.setSystem(false);
    // Run the job using the progress service so that the view is marked as busy (italics)
    currentRefreshJob = refreshJob;
    service.schedule(refreshJob, 0, true);
}
Also used : ComponentImplementation(org.osate.aadl2.ComponentImplementation) ComponentType(org.osate.aadl2.ComponentType) OperationCanceledException(org.eclipse.core.runtime.OperationCanceledException) SubMonitor(org.eclipse.core.runtime.SubMonitor) FeatureGroupType(org.osate.aadl2.FeatureGroupType) IProject(org.eclipse.core.resources.IProject) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) IWorkbenchSiteProgressService(org.eclipse.ui.progress.IWorkbenchSiteProgressService) TreePath(org.eclipse.jface.viewers.TreePath) TreeSelection(org.eclipse.jface.viewers.TreeSelection) Job(org.eclipse.core.runtime.jobs.Job)

Example 12 with FeatureGroupType

use of org.osate.aadl2.FeatureGroupType in project osate2 by osate.

the class PrototypesModel method setConstrainingClassifier.

@Override
public void setConstrainingClassifier(final EditablePrototype prototype, final NamedElementOrDescription value) {
    modifyPrototype("Set Constraining Classifier", prototype, p -> {
        final EObject classifier = value.getResolvedValue(prototype.prototype.eResource().getResourceSet());
        if (classifier != null) {
            // Import its package if necessary
            final AadlPackage pkg = (AadlPackage) p.getElementRoot();
            if (classifier instanceof Classifier && ((Classifier) classifier).getNamespace() != null && pkg != null) {
                final PackageSection section = pkg.getPublicSection();
                final AadlPackage selectedClassifierPkg = (AadlPackage) ((Classifier) classifier).getNamespace().getOwner();
                if (selectedClassifierPkg != null && pkg != selectedClassifierPkg) {
                    AadlImportsUtil.addImportIfNeeded(section, selectedClassifierPkg);
                }
            }
        }
        // Update the classifier
        if (p instanceof ComponentPrototype) {
            ((ComponentPrototype) p).setConstrainingClassifier((ComponentClassifier) classifier);
        } else if (p instanceof FeatureGroupPrototype) {
            ((FeatureGroupPrototype) p).setConstrainingFeatureGroupType((FeatureGroupType) classifier);
        } else if (p instanceof FeaturePrototype) {
            ((FeaturePrototype) p).setConstrainingClassifier((ComponentClassifier) classifier);
        }
    });
}
Also used : FeatureGroupPrototype(org.osate.aadl2.FeatureGroupPrototype) AadlPackage(org.osate.aadl2.AadlPackage) FeaturePrototype(org.osate.aadl2.FeaturePrototype) PackageSection(org.osate.aadl2.PackageSection) EObject(org.eclipse.emf.ecore.EObject) FeatureGroupType(org.osate.aadl2.FeatureGroupType) ComponentClassifier(org.osate.aadl2.ComponentClassifier) Classifier(org.osate.aadl2.Classifier) ComponentPrototype(org.osate.aadl2.ComponentPrototype)

Example 13 with FeatureGroupType

use of org.osate.aadl2.FeatureGroupType in project osate2 by osate.

the class FeatureInstanceTooltipContributor method addTooltipContents.

@Override
public void addTooltipContents(final TooltipContributorContext ctx) {
    ctx.getBusinessObjectContext().getBusinessObject(FeatureInstance.class).ifPresent(featureInstance -> {
        final Feature feature = featureInstance.getFeature();
        if (feature instanceof Feature || feature instanceof InternalFeature || feature instanceof ProcessorFeature) {
            // Determine the feature classifier
            final Classifier featureClassifier;
            if (feature instanceof EventDataSource) {
                final EventDataSource aadlFeature = (EventDataSource) feature;
                featureClassifier = aadlFeature.getDataClassifier();
            } else if (feature instanceof PortProxy) {
                final PortProxy aadlFeature = (PortProxy) feature;
                featureClassifier = aadlFeature.getDataClassifier();
            } else if (feature instanceof SubprogramProxy) {
                final SubprogramProxy aadlFeature = (SubprogramProxy) feature;
                featureClassifier = aadlFeature.getSubprogramClassifier();
            } else if (feature instanceof Feature) {
                final Feature aadlFeature = (Feature) feature;
                featureClassifier = aadlFeature.getAllClassifier();
            } else {
                featureClassifier = null;
            }
            // Build the text to contribute to the tooltip
            final StringBuffer tooltipContents = new StringBuffer();
            if (featureClassifier instanceof ComponentClassifier) {
                tooltipContents.append(((ComponentClassifier) featureClassifier).getCategory() + " " + featureClassifier.getQualifiedName());
            } else if (featureClassifier instanceof FeatureGroupType) {
                tooltipContents.append("feature group " + featureClassifier.getQualifiedName());
            } else if (featureClassifier == null) {
                tooltipContents.append("No Classifier");
            } else {
                tooltipContents.append(featureClassifier.getQualifiedName());
            }
            // Create the styled text describing the feature
            final Label lbl = new Label(ctx.getTooltip(), SWT.NONE);
            lbl.setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_INFO_FOREGROUND));
            lbl.setText(tooltipContents.toString());
        }
    });
}
Also used : ComponentClassifier(org.osate.aadl2.ComponentClassifier) SubprogramProxy(org.osate.aadl2.SubprogramProxy) FeatureInstance(org.osate.aadl2.instance.FeatureInstance) PortProxy(org.osate.aadl2.PortProxy) InternalFeature(org.osate.aadl2.InternalFeature) FeatureGroupType(org.osate.aadl2.FeatureGroupType) Label(org.eclipse.swt.widgets.Label) ProcessorFeature(org.osate.aadl2.ProcessorFeature) ComponentClassifier(org.osate.aadl2.ComponentClassifier) Classifier(org.osate.aadl2.Classifier) ProcessorFeature(org.osate.aadl2.ProcessorFeature) Feature(org.osate.aadl2.Feature) InternalFeature(org.osate.aadl2.InternalFeature) EventDataSource(org.osate.aadl2.EventDataSource)

Example 14 with FeatureGroupType

use of org.osate.aadl2.FeatureGroupType in project osate2 by osate.

the class EMV2Util method getErrorPropagationFeatureDirection.

/**
 * returns the feature instance in the component instance that is referenced by the Error Propagation (or Containment)
 * @param ep
 * @param ci
 * @return
 */
public static DirectionType getErrorPropagationFeatureDirection(ErrorPropagation ep) {
    FeatureorPPReference fref = ep.getFeatureorPPRef();
    boolean inverse = false;
    NamedElement f = null;
    DirectionType featuredir = DirectionType.IN_OUT;
    while (fref != null) {
        f = fref.getFeatureorPP();
        fref = fref.getNext();
        if (f instanceof FeatureGroup && fref != null) {
            FeatureGroup fg = (FeatureGroup) f;
            FeatureGroupType fgt = fg.getAllFeatureGroupType();
            if (fg.isInverse()) {
                inverse = !inverse;
            }
            if (fgt != null && fgt.getInverse() != null && !fgt.getOwnedFeatures().contains(fref.getFeatureorPP())) {
                inverse = !inverse;
            }
        }
    }
    if (f instanceof DirectedFeature) {
        featuredir = ((DirectedFeature) f).getDirection();
        if (inverse) {
            return featuredir.getInverseDirection();
        } else {
            return featuredir;
        }
    }
    return featuredir;
}
Also used : DirectionType(org.osate.aadl2.DirectionType) FeatureGroup(org.osate.aadl2.FeatureGroup) FeatureGroupType(org.osate.aadl2.FeatureGroupType) DirectedFeature(org.osate.aadl2.DirectedFeature) ContainedNamedElement(org.osate.aadl2.ContainedNamedElement) NamedElement(org.osate.aadl2.NamedElement) FeatureorPPReference(org.osate.xtext.aadl2.errormodel.errorModel.FeatureorPPReference)

Example 15 with FeatureGroupType

use of org.osate.aadl2.FeatureGroupType in project osate2 by osate.

the class FeatureInstanceImpl method findInverseFeatureGroup.

/**
 * find the matching inverse feature group instance in this feature group instance
 * the contained feature group instance must have the inverse feature group type
 * @param targetpgt feature group instance with feature group type to be found
 * @return feature instance with the specified feature, or null
 */
// XXX: [AADL 1 -> AADL 2] Added to make instantiation work.
public FeatureInstance findInverseFeatureGroup(FeatureGroupType targetpgt) {
    if (!(getFeature() instanceof FeatureGroup)) {
        return null;
    }
    EList<FeatureInstance> subcil = getFeatureInstances();
    for (Iterator<FeatureInstance> it = subcil.iterator(); it.hasNext(); ) {
        FeatureInstance fi = it.next();
        if (fi.getFeature() instanceof FeatureGroup) {
            FeatureGroupType srcpgt = ((FeatureGroup) fi.getFeature()).getFeatureGroupType();
            if (srcpgt != null && srcpgt.isInverseOf(targetpgt)) {
                return fi;
            }
            fi.findInverseFeatureGroup(targetpgt);
        }
    }
    return null;
}
Also used : FeatureGroup(org.osate.aadl2.FeatureGroup) FeatureInstance(org.osate.aadl2.instance.FeatureInstance) FeatureGroupType(org.osate.aadl2.FeatureGroupType)

Aggregations

FeatureGroupType (org.osate.aadl2.FeatureGroupType)49 Classifier (org.osate.aadl2.Classifier)23 FeatureGroup (org.osate.aadl2.FeatureGroup)22 ComponentClassifier (org.osate.aadl2.ComponentClassifier)20 Feature (org.osate.aadl2.Feature)16 Subcomponent (org.osate.aadl2.Subcomponent)13 ComponentPrototype (org.osate.aadl2.ComponentPrototype)10 ComponentType (org.osate.aadl2.ComponentType)10 FeatureGroupPrototype (org.osate.aadl2.FeatureGroupPrototype)10 NamedElement (org.osate.aadl2.NamedElement)10 FeatureInstance (org.osate.aadl2.instance.FeatureInstance)9 AadlPackage (org.osate.aadl2.AadlPackage)8 FeatureGroupPrototypeBinding (org.osate.aadl2.FeatureGroupPrototypeBinding)8 EObject (org.eclipse.emf.ecore.EObject)7 ComponentImplementation (org.osate.aadl2.ComponentImplementation)7 ComponentPrototypeBinding (org.osate.aadl2.ComponentPrototypeBinding)7 FeatureGroupPrototypeActual (org.osate.aadl2.FeatureGroupPrototypeActual)7 ArrayList (java.util.ArrayList)6 ContainmentPathElement (org.osate.aadl2.ContainmentPathElement)6 EClass (org.eclipse.emf.ecore.EClass)5