use of org.obeonetwork.dsl.requirement.Requirement in project InformationSystem by ObeoNetwork.
the class LinkRequirementsDialog method okPressed.
@Override
protected void okPressed() {
TransactionalEditingDomain editingDomain = TransactionUtil.getEditingDomain(this.selectedEObject);
RecordingCommand cmd = new // $NON-NLS-1$
RecordingCommand(// $NON-NLS-1$
editingDomain, // $NON-NLS-1$
"Link Requirements") {
protected void doExecute() {
// Clear all requirements links
for (Requirement requirement : RequirementService.getLinkedRequirements(LinkRequirementsDialog.this.selectedEObject)) {
requirement.getReferencedObject().remove(LinkRequirementsDialog.this.selectedEObject);
}
// Add new requirements links
for (Object checkedElement : LinkRequirementsDialog.this.checkboxTreeViewer.getCheckedElements()) {
if (checkedElement instanceof Requirement) {
Requirement requirement = (Requirement) checkedElement;
requirement.getReferencedObject().add(LinkRequirementsDialog.this.selectedEObject);
}
}
}
};
editingDomain.getCommandStack().execute(cmd);
super.okPressed();
}
use of org.obeonetwork.dsl.requirement.Requirement in project InformationSystem by ObeoNetwork.
the class LinkRequirementsDialog method determineObjectsToCheck.
/**
* Initially, we want to check:
* <ul>
* <li>the {@link Requirement Requirements} linked to the selected model
* element.</li>
* <li>the {@link Category Categories and sub-Categories} containing
* selected {@link Requirement Requirements}.</li>
* <li>the {@link Repository Repositories} containing selected
* {@link Requirement Requirements}.</li>
* <li>the {@link Resource Resources} containing selected {@link Requirement
* Requirements}.</li>
* </ul>
*
* @param linkedRequirements
* the {@link Requirement Requirements} linked to the selected
* model element.
* @return the objects in the {@link CheckboxTreeViewer} which must be
* checked initially.
*/
private static Set<Object> determineObjectsToCheck(Set<Requirement> linkedRequirements) {
Set<Object> objectsToCheck = new HashSet<Object>();
for (Requirement linkedRequirement : linkedRequirements) {
// The linked Requirement.
objectsToCheck.add(linkedRequirement);
// The Categories and all its super-Categories.
Category category = linkedRequirement.getCategory();
objectsToCheck.add(category);
while (category.getParentCategory() != null) {
category = category.getParentCategory();
objectsToCheck.add(category);
}
// The Repository
Repository repository = category.getRepository();
objectsToCheck.add(repository);
// The Resource
Resource resource = repository.eResource();
objectsToCheck.add(resource);
}
return objectsToCheck;
}
use of org.obeonetwork.dsl.requirement.Requirement in project InformationSystem by ObeoNetwork.
the class CategoryPropertiesEditionComponent method updateSemanticModel.
/**
* {@inheritDoc}
* @see org.eclipse.emf.eef.runtime.impl.components.StandardPropertiesEditionComponent#updateSemanticModel(org.eclipse.emf.eef.runtime.api.notify.IPropertiesEditionEvent)
*/
public void updateSemanticModel(final IPropertiesEditionEvent event) {
Category category = (Category) semanticObject;
if (RequirementViewsRepository.Category.Category_.id == event.getAffectedEditor()) {
category.setId((java.lang.String) EEFConverterUtil.createFromString(EcorePackage.Literals.ESTRING, (String) event.getNewValue()));
}
if (RequirementViewsRepository.Category.Category_.name == event.getAffectedEditor()) {
category.setName((java.lang.String) EEFConverterUtil.createFromString(EcorePackage.Literals.ESTRING, (String) event.getNewValue()));
}
if (RequirementViewsRepository.Category.Category_.requirements == event.getAffectedEditor()) {
if (event.getKind() == PropertiesEditionEvent.ADD) {
EReferencePropertiesEditionContext context = new EReferencePropertiesEditionContext(editingContext, this, requirementsSettings, editingContext.getAdapterFactory());
PropertiesEditingProvider provider = (PropertiesEditingProvider) editingContext.getAdapterFactory().adapt(semanticObject, PropertiesEditingProvider.class);
if (provider != null) {
PropertiesEditingPolicy policy = provider.getPolicy(context);
if (policy instanceof CreateEditingPolicy) {
policy.execute();
}
}
} else if (event.getKind() == PropertiesEditionEvent.EDIT) {
EObjectPropertiesEditionContext context = new EObjectPropertiesEditionContext(editingContext, this, (EObject) event.getNewValue(), editingContext.getAdapterFactory());
PropertiesEditingProvider provider = (PropertiesEditingProvider) editingContext.getAdapterFactory().adapt((EObject) event.getNewValue(), PropertiesEditingProvider.class);
if (provider != null) {
PropertiesEditingPolicy editionPolicy = provider.getPolicy(context);
if (editionPolicy != null) {
editionPolicy.execute();
}
}
} else if (event.getKind() == PropertiesEditionEvent.REMOVE) {
requirementsSettings.removeFromReference((EObject) event.getNewValue());
} else if (event.getKind() == PropertiesEditionEvent.MOVE) {
requirementsSettings.move(event.getNewIndex(), (Requirement) event.getNewValue());
}
}
if (RequirementViewsRepository.Category.Category_.subCategories == event.getAffectedEditor()) {
if (event.getKind() == PropertiesEditionEvent.ADD) {
EReferencePropertiesEditionContext context = new EReferencePropertiesEditionContext(editingContext, this, subCategoriesSettings, editingContext.getAdapterFactory());
PropertiesEditingProvider provider = (PropertiesEditingProvider) editingContext.getAdapterFactory().adapt(semanticObject, PropertiesEditingProvider.class);
if (provider != null) {
PropertiesEditingPolicy policy = provider.getPolicy(context);
if (policy instanceof CreateEditingPolicy) {
policy.execute();
}
}
} else if (event.getKind() == PropertiesEditionEvent.EDIT) {
EObjectPropertiesEditionContext context = new EObjectPropertiesEditionContext(editingContext, this, (EObject) event.getNewValue(), editingContext.getAdapterFactory());
PropertiesEditingProvider provider = (PropertiesEditingProvider) editingContext.getAdapterFactory().adapt((EObject) event.getNewValue(), PropertiesEditingProvider.class);
if (provider != null) {
PropertiesEditingPolicy editionPolicy = provider.getPolicy(context);
if (editionPolicy != null) {
editionPolicy.execute();
}
}
} else if (event.getKind() == PropertiesEditionEvent.REMOVE) {
subCategoriesSettings.removeFromReference((EObject) event.getNewValue());
} else if (event.getKind() == PropertiesEditionEvent.MOVE) {
subCategoriesSettings.move(event.getNewIndex(), (Category) event.getNewValue());
}
}
}
use of org.obeonetwork.dsl.requirement.Requirement in project InformationSystem by ObeoNetwork.
the class CategoryPropertiesEditionComponent method initPart.
/**
* {@inheritDoc}
*
* @see org.eclipse.emf.eef.runtime.api.component.IPropertiesEditionComponent#initPart(java.lang.Object, int, org.eclipse.emf.ecore.EObject,
* org.eclipse.emf.ecore.resource.ResourceSet)
*/
public void initPart(Object key, int kind, EObject elt, ResourceSet allResource) {
setInitializing(true);
if (editingPart != null && key == partKey) {
editingPart.setContext(elt, allResource);
final Category category = (Category) elt;
final CategoryPropertiesEditionPart categoryPart = (CategoryPropertiesEditionPart) editingPart;
// init values
if (isAccessible(RequirementViewsRepository.Category.Category_.id))
categoryPart.setId(EEFConverterUtil.convertToString(EcorePackage.Literals.ESTRING, category.getId()));
if (isAccessible(RequirementViewsRepository.Category.Category_.name))
categoryPart.setName(EEFConverterUtil.convertToString(EcorePackage.Literals.ESTRING, category.getName()));
if (isAccessible(RequirementViewsRepository.Category.Category_.requirements)) {
requirementsSettings = new ReferencesTableSettings(category, RequirementPackage.eINSTANCE.getCategory_Requirements());
categoryPart.initRequirements(requirementsSettings);
}
if (isAccessible(RequirementViewsRepository.Category.Category_.subCategories)) {
subCategoriesSettings = new ReferencesTableSettings(category, RequirementPackage.eINSTANCE.getCategory_SubCategories());
categoryPart.initSubCategories(subCategoriesSettings);
}
if (isAccessible(RequirementViewsRepository.Category.Category_.requirements)) {
categoryPart.addFilterToRequirements(new ViewerFilter() {
/**
* {@inheritDoc}
*
* @see org.eclipse.jface.viewers.ViewerFilter#select(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object)
*/
public boolean select(Viewer viewer, Object parentElement, Object element) {
// $NON-NLS-1$
return (element instanceof String && element.equals("")) || (element instanceof Requirement);
}
});
// Start of user code for additional businessfilters for requirements
// End of user code
}
if (isAccessible(RequirementViewsRepository.Category.Category_.subCategories)) {
categoryPart.addFilterToSubCategories(new ViewerFilter() {
/**
* {@inheritDoc}
*
* @see org.eclipse.jface.viewers.ViewerFilter#select(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object)
*/
public boolean select(Viewer viewer, Object parentElement, Object element) {
// $NON-NLS-1$
return (element instanceof String && element.equals("")) || (element instanceof Category);
}
});
// Start of user code for additional businessfilters for subCategories
// End of user code
}
// init values for referenced views
// init filters for referenced views
}
setInitializing(false);
}
use of org.obeonetwork.dsl.requirement.Requirement in project InformationSystem by ObeoNetwork.
the class RequirementAdvancedPropertiesEditionComponent method initPart.
/**
* {@inheritDoc}
*
* @see org.eclipse.emf.eef.runtime.api.component.IPropertiesEditionComponent#initPart(java.lang.Object, int, org.eclipse.emf.ecore.EObject,
* org.eclipse.emf.ecore.resource.ResourceSet)
*/
public void initPart(Object key, int kind, EObject elt, ResourceSet allResource) {
setInitializing(true);
if (editingPart != null && key == partKey) {
editingPart.setContext(elt, allResource);
final Requirement requirement = (Requirement) elt;
final AdvancedPropertiesEditionPart advancedPart = (AdvancedPropertiesEditionPart) editingPart;
// init values
if (isAccessible(RequirementViewsRepository.Advanced.rationale))
advancedPart.setRationale(EcoreUtil.convertToString(EcorePackage.Literals.ESTRING, requirement.getRationale()));
if (isAccessible(RequirementViewsRepository.Advanced.acceptanceCriteria))
advancedPart.setAcceptanceCriteria(EcoreUtil.convertToString(EcorePackage.Literals.ESTRING, requirement.getAcceptanceCriteria()));
if (isAccessible(RequirementViewsRepository.Advanced.referencedObject)) {
referencedObjectSettings = new ReferencesTableSettings(requirement, RequirementPackage.eINSTANCE.getRequirement_ReferencedObject());
advancedPart.initReferencedObject(referencedObjectSettings);
}
if (isAccessible(RequirementViewsRepository.Advanced.referencedObject)) {
advancedPart.addFilterToReferencedObject(new ViewerFilter() {
/**
* {@inheritDoc}
*
* @see org.eclipse.jface.viewers.ViewerFilter#select(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object)
*/
public boolean select(Viewer viewer, Object parentElement, Object element) {
if (element instanceof EObject)
return (!advancedPart.isContainedInReferencedObjectTable((EObject) element));
return element instanceof String && element.equals("");
}
});
advancedPart.addFilterToReferencedObject(new EObjectStrictFilter(EcorePackage.Literals.EOBJECT));
// Start of user code for additional businessfilters for referencedObject
// End of user code
}
// init values for referenced views
// init filters for referenced views
}
setInitializing(false);
}
Aggregations