use of org.eclipse.sirius.business.api.query.EObjectQuery in project Palladio-Editors-Sirius by PalladioSimulator.
the class SetFailureType method execute.
@Override
public void execute(Collection<? extends EObject> selections, Map<String, Object> parameters) {
InternalFailureOccurrenceDescription element = (InternalFailureOccurrenceDescription) parameters.get("instance");
EObjectQuery query = new EObjectQuery(element);
Collection<Resource> resources = query.getSession().getSemanticResources();
boolean found = false;
Resource resource = null;
for (Resource r : resources) {
if (r.getURI().equals(URI.createURI("pathmap://PCM_MODELS/FailureTypes.repository"))) {
found = true;
resource = r;
break;
}
}
if (found) {
Repository rep = (Repository) resource.getContents().iterator().next();
for (EObject o : rep.eContents()) {
FailureType failureType = (FailureType) o;
if (failureType.getEntityName().equals("SoftwareInducedFailure")) {
element.setSoftwareInducedFailureType__InternalFailureOccurrenceDescription(((SoftwareInducedFailureType) failureType));
break;
}
}
}
}
use of org.eclipse.sirius.business.api.query.EObjectQuery in project InformationSystem by ObeoNetwork.
the class TypesServices method getAllReferencingStructuredTypes.
private Collection<StructuredType> getAllReferencingStructuredTypes(StructuredType referencedType) {
Collection<StructuredType> referencingTypes = new HashSet<StructuredType>();
Session session = new EObjectQuery(referencedType).getSession();
Collection<Setting> inverseReferences = null;
ECrossReferenceAdapter xReferencer = null;
if (session != null) {
xReferencer = session.getSemanticCrossReferencer();
}
if (xReferencer != null) {
inverseReferences = xReferencer.getInverseReferences(referencedType);
} else {
if (referencedType.eResource() != null && referencedType.eResource().getResourceSet() != null) {
inverseReferences = UsageCrossReferencer.find(referencedType, referencedType.eResource().getResourceSet());
}
}
if (inverseReferences != null) {
for (Setting setting : inverseReferences) {
if (setting.getEObject() instanceof StructuredType && setting.getEStructuralFeature() == EnvironmentPackage.Literals.STRUCTURED_TYPE__SUPERTYPE) {
referencingTypes.add((StructuredType) setting.getEObject());
} else if (setting.getEObject() instanceof Reference && setting.getEStructuralFeature() == EnvironmentPackage.Literals.REFERENCE__REFERENCED_TYPE) {
referencingTypes.add(((Reference) setting.getEObject()).getContainingType());
}
}
}
return referencingTypes;
}
use of org.eclipse.sirius.business.api.query.EObjectQuery in project InformationSystem by ObeoNetwork.
the class AbstractUserStoryDecorator method getAnalysis.
/**
* Retrieves the DAnalysis instance from a diagram edit part
* @param diagramEditPart Diagram edit part corresponding to an element on a viewpoint diagram
* @return the DAnalysis instance
*/
private static DAnalysis getAnalysis(IDiagramElementEditPart diagramEditPart) {
EObject viewpointNode = diagramEditPart.resolveSemanticElement();
// if there is no GMF semantic element, we won't be able to retrieve a DAnalysis
if (viewpointNode != null) {
Session session = null;
// First, try to retrieve the session using the sirius semantic element
if (viewpointNode instanceof DSemanticDecorator) {
EObject semanticElement = ((DSemanticDecorator) viewpointNode).getTarget();
if (semanticElement != null) {
session = new EObjectQuery(semanticElement).getSession();
}
}
// If it didn't work, let's try using the sirius graphical element
if (session == null) {
session = new EObjectQuery(viewpointNode).getSession();
}
// If we were able to retrieve a session, let's get the root DAnalysis
if (session != null) {
EObject analysisEObject = session.getSessionResource().getContents().get(0);
if (analysisEObject instanceof DAnalysis) {
return (DAnalysis) analysisEObject;
}
}
// Nothing worked, let's check if the EMF root element is a DAnalysis
EObject container = EcoreUtil.getRootContainer(viewpointNode);
if (container != null && container instanceof DAnalysis) {
return (DAnalysis) container;
}
}
return null;
}
use of org.eclipse.sirius.business.api.query.EObjectQuery in project InformationSystem by ObeoNetwork.
the class UnlinkRequirementAction method run.
/**
* {@inheritDoc}
*
* @see org.eclipse.jface.action.Action#run()
*/
@Override
public void run() {
MessageDialog dialog = new MessageDialog(linksView.getSite().getShell(), // $NON-NLS-1$
RequirementLinkerPlugin.getInstance().getString("DeleteRequirementLinkAction_ConfirmDialog_title"), null, // $NON-NLS-1$
RequirementLinkerPlugin.getInstance().getString("DeleteRequirementLinkAction_ConfirmDialog_msg"), MessageDialog.CONFIRM, new String[] { IDialogConstants.OK_LABEL, IDialogConstants.CANCEL_LABEL }, 1);
boolean openConfirm = dialog.open() == Window.OK;
if (openConfirm) {
Session session = new EObjectQuery(linksView.getInput()).getSession();
if (session != null) {
TransactionalEditingDomain editingDomain = session.getTransactionalEditingDomain();
RecordingCommand cmd = new // $NON-NLS-1$
RecordingCommand(// $NON-NLS-1$
editingDomain, // $NON-NLS-1$
"UnLink Requirements") {
protected void doExecute() {
for (EObjectLink link : linksView.getSelectedEntries()) {
if (link instanceof RequirementLink) {
RequirementLink reqLink = (RequirementLink) link;
reqLink.getRequirement().getReferencedObject().remove(linksView.getInput());
}
}
}
};
editingDomain.getCommandStack().execute(cmd);
}
linksView.refresh();
}
}
use of org.eclipse.sirius.business.api.query.EObjectQuery in project InformationSystem by ObeoNetwork.
the class BindingService method getRelatedBindingInfos.
private Collection<BindingInfo> getRelatedBindingInfos(StructuredType structuredType) {
EObjectQuery query = new EObjectQuery(structuredType);
Collection<EObject> targets = new HashSet<EObject>();
targets.addAll(query.getInverseReferences(EnvironmentPackage.Literals.BINDING_INFO__LEFT));
targets.addAll(query.getInverseReferences(EnvironmentPackage.Literals.BINDING_INFO__RIGHT));
Collection<BindingInfo> bindingInfos = new ArrayList<BindingInfo>();
for (EObject target : targets) {
if (target instanceof BindingInfo) {
bindingInfos.add((BindingInfo) target);
}
}
return bindingInfos;
}
Aggregations