use of com.google.cloud.vision.v1p3beta1.Feature in project osate2 by osate.
the class ChangeFeatureTypePropertySection method refresh.
@Override
public void refresh() {
final Set<NamedElement> selectedFeatures = selectedBos.boStream(NamedElement.class).collect(Collectors.toSet());
final Set<EClass> featureTypeOptions = new HashSet<>();
// Add to options
final Consumer<EClass> addFeatureTypeOption = (type) -> featureTypeOptions.add(type);
// Get comboviewer selected value and populate available type options for comboviewer
selectedFeatureType = AadlPropertySectionUtil.getTypeOptionsInformation(selectedFeatures, AadlFeatureUtil.getFeatureTypes(), (feature, type) -> isValidFeatureType(feature, type), addFeatureTypeOption);
comboViewer.setInput(featureTypeOptions);
// Set comboviewer selection
if (selectedFeatureType != null) {
comboViewer.setSelection(new StructuredSelection(selectedFeatureType));
}
comboViewer.getCombo().setEnabled(selectedFeatures.size() == 1);
}
use of com.google.cloud.vision.v1p3beta1.Feature in project osate2 by osate.
the class CreateAadlConnectionPaletteCommand method canCreate.
private boolean canCreate(final BusinessObjectContext ownerBoc, final BusinessObjectContext srcBoc, final BusinessObjectContext dstBoc) {
// Get the connection elements for the source and destination
final ConnectedElement srcConnectedElement = getConnectedElementForBusinessObjectContext(srcBoc, connectionType, false, ownerBoc);
if (srcConnectedElement == null) {
return false;
}
final ConnectedElement dstConnectedElement = getConnectedElementForBusinessObjectContext(dstBoc, connectionType, !(srcConnectedElement.getContext() instanceof Subcomponent), ownerBoc);
// Ensure they are valid and are not the same
if (dstConnectedElement == null || EcoreUtil.equals(srcConnectedElement, dstConnectedElement)) {
return false;
}
// Don't allow connecting two features owned by the same classifier
if (!(srcConnectedElement.getContext() instanceof Subcomponent || srcConnectedElement.getContext() instanceof SubprogramCall) && srcConnectedElement.getConnectionEnd() instanceof Feature && !(dstConnectedElement.getContext() instanceof Subcomponent || dstConnectedElement.getContext() instanceof SubprogramCall) && dstConnectedElement.getConnectionEnd() instanceof Feature) {
return false;
}
final Class<?> connectionEndType = getConnectionEndType(connectionType);
if (connectionEndType == null || !connectionEndType.isInstance(dstConnectedElement.getConnectionEnd())) {
return false;
}
return ownerBoc == null ? false : getClassifierOpBuilder().canBuildOperation(ownerBoc.getBusinessObject());
}
use of com.google.cloud.vision.v1p3beta1.Feature in project osate2 by osate.
the class CreateFlowSourceSinkSpecificationPaletteCommand method getOperation.
@Override
public Optional<Operation> getOperation(final GetTargetedOperationContext ctx) {
return ctx.getTarget().getBusinessObject(Feature.class).map(feature -> {
final DirectionType requiredDirection;
if (flowKind == FlowKind.SOURCE) {
requiredDirection = DirectionType.OUT;
} else if (flowKind == FlowKind.SINK) {
requiredDirection = DirectionType.IN;
} else {
return null;
}
final List<ComponentType> potentialOwners = FlowSpecificationCreationUtil.getPotentialOwnersByFeature(ctx.getTarget(), ctx.getQueryService());
if (potentialOwners.isEmpty() || !FlowSpecificationCreationUtil.isValidFlowEnd(feature, ctx.getTarget(), requiredDirection, ctx.getQueryService())) {
return null;
}
final BusinessObjectContext container = FlowSpecificationCreationUtil.getFlowSpecificationOwnerBoc(ctx.getTarget(), ctx.getQueryService());
if (container == null) {
return null;
}
return Operation.createWithBuilder(createOp -> {
AadlUiUtil.selectClassifier(createOp, potentialOwners).modifyPreviousResult(ct -> {
final FlowSpecification fs = ct.createOwnedFlowSpecification();
fs.setKind(flowKind);
fs.setName(FlowSpecificationCreationUtil.getNewFlowSpecificationName(ct));
// Create the appropriate flow end depending on the type being created
final FlowEnd flowEnd;
if (flowKind == FlowKind.SOURCE) {
flowEnd = fs.createOutEnd();
} else if (flowKind == FlowKind.SINK) {
flowEnd = fs.createInEnd();
} else {
throw new RuntimeException("Unexpected flow kind: " + flowKind);
}
flowEnd.setFeature(feature);
flowEnd.setContext(FlowSpecificationCreationUtil.getContext(ctx.getTarget(), ctx.getQueryService()));
// Clear the no flows flag
ct.setNoFlows(false);
return StepResultBuilder.create().showNewBusinessObject(container, fs).build();
});
});
});
}
use of com.google.cloud.vision.v1p3beta1.Feature in project osate2 by osate.
the class DefaultSelectSubprogramDialogModel method getSubprograms.
@Override
public List<Object> getSubprograms(final Object context) {
// Build a list of subprograms
final List<Object> subprograms = new ArrayList<Object>();
// Data/Subprogram Group/Abstract Type
if (context instanceof IEObjectDescription) {
final IEObjectDescription desc = (IEObjectDescription) context;
final Classifier contextClassifier = (Classifier) (desc.getEObjectOrProxy().eIsProxy() ? (Classifier) EcoreUtil.resolve(desc.getEObjectOrProxy(), bi.eResource()) : desc.getEObjectOrProxy());
if (!contextClassifier.eIsProxy()) {
for (final Feature tmpFeature : contextClassifier.getAllFeatures()) {
if (tmpFeature instanceof SubprogramAccess) {
// Provides Subprogram Access
if (((SubprogramAccess) tmpFeature).getKind() == AccessType.PROVIDES) {
subprograms.add(tmpFeature);
}
}
}
}
} else if (context instanceof SubprogramGroupAccess) {
// Requires Subprogram Group Access
// Only subprogram group accesses with kind = Requires and which has a subprogram group classifier should be in the context list
// Provides Subprogram Access
final SubprogramGroupClassifier spgClassifier = (SubprogramGroupClassifier) ((SubprogramGroupAccess) context).getAllClassifier();
addProvidesSubprogramAccessesForComponentClassifier(spgClassifier, subprograms);
} else if (context instanceof FeatureGroup) {
// Feature Group
final FeatureGroup fg = (FeatureGroup) context;
// Requires subprogram Access if not inverse and Provides subprogram access if is inverse
final boolean inverted = fg.isInverse();
for (final Feature tmpFeature : AadlFeatureUtil.getAllFeatures(fg.getAllFeatureGroupType())) {
if (tmpFeature instanceof SubprogramAccess) {
final AccessType accessKind = ((SubprogramAccess) tmpFeature).getKind();
if ((!inverted && accessKind == AccessType.REQUIRES) || (inverted && accessKind == AccessType.PROVIDES)) {
subprograms.add(tmpFeature);
}
}
}
} else if (context instanceof SubprogramGroupSubcomponent) {
// Subprogram Group Subcomponent
// Provides Subprogram
addProvidesSubprogramAccessesForComponentClassifier(((SubprogramGroupSubcomponent) context).getAllClassifier(), subprograms);
} else if (context == processorContext) {
// Subprogram Proxy
for (final ProcessorFeature processorFeature : AgeAadlUtil.getAllProcessorFeatures(bi)) {
if (processorFeature instanceof SubprogramProxy) {
subprograms.add(processorFeature);
}
}
} else if (context == nullContext) {
// Null Context
// Subprogram classifier reference
final Aadl2Package aadl2Package = Aadl2Package.eINSTANCE;
for (final IEObjectDescription desc : AadlModelAccessUtil.getAllEObjectsByType(bi.eResource(), aadl2Package.getComponentClassifier())) {
// Add objects that have care either types or implementations of the same category as the classifier type
final EClass classifierEClass = desc.getEClass();
if (aadl2Package.getSubprogramClassifier().isSuperTypeOf(classifierEClass)) {
subprograms.add(desc);
}
}
// Requires Subprogram Access
for (final Feature tmpFeature : bi.getAllFeatures()) {
if (tmpFeature instanceof SubprogramAccess && ((SubprogramAccess) tmpFeature).getKind() == AccessType.REQUIRES) {
subprograms.add(tmpFeature);
}
}
// Subprogram Subcomponent
for (final Subcomponent tmpSc : bi.getAllSubcomponents()) {
if (tmpSc instanceof SubprogramSubcomponent) {
subprograms.add(tmpSc);
}
}
// Subprogram Prototype
for (final Prototype prototype : bi.getAllPrototypes()) {
if (prototype instanceof SubprogramPrototype) {
subprograms.add(prototype);
}
}
}
return Collections.unmodifiableList(subprograms);
}
use of com.google.cloud.vision.v1p3beta1.Feature in project osate2 by osate.
the class AgeRenameParticipant method getDependentObjects.
private static Set<EObject> getDependentObjects(final EObject obj, final ResourceSet rs, final Map<URI, Set<URI>> externalReferencesMap) {
final Set<EObject> results = new HashSet<>();
final EObject objectOfInterest;
// is the only known way of getting types related to the renames.
if (obj instanceof ComponentTypeRename) {
final ComponentType renamedComponentType = ((ComponentTypeRename) obj).getRenamedComponentType();
objectOfInterest = renamedComponentType == null ? null : renamedComponentType;
} else {
objectOfInterest = obj;
}
if (objectOfInterest != null) {
getRelatedObjects(Collections.singleton(objectOfInterest), rs, results, externalReferencesMap, obj instanceof Feature);
}
return results;
}
Aggregations