Search in sources :

Example 6 with Requirement

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();
}
Also used : Requirement(org.obeonetwork.dsl.requirement.Requirement) TransactionalEditingDomain(org.eclipse.emf.transaction.TransactionalEditingDomain) RecordingCommand(org.eclipse.emf.transaction.RecordingCommand) EObject(org.eclipse.emf.ecore.EObject)

Example 7 with Requirement

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;
}
Also used : Requirement(org.obeonetwork.dsl.requirement.Requirement) Repository(org.obeonetwork.dsl.requirement.Repository) Category(org.obeonetwork.dsl.requirement.Category) Resource(org.eclipse.emf.ecore.resource.Resource) EObject(org.eclipse.emf.ecore.EObject) HashSet(java.util.HashSet) LinkedHashSet(java.util.LinkedHashSet)

Example 8 with Requirement

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());
        }
    }
}
Also used : Requirement(org.obeonetwork.dsl.requirement.Requirement) EObjectPropertiesEditionContext(org.eclipse.emf.eef.runtime.context.impl.EObjectPropertiesEditionContext) Category(org.obeonetwork.dsl.requirement.Category) PropertiesEditingProvider(org.eclipse.emf.eef.runtime.providers.PropertiesEditingProvider) EObject(org.eclipse.emf.ecore.EObject) PropertiesEditingPolicy(org.eclipse.emf.eef.runtime.policies.PropertiesEditingPolicy) CreateEditingPolicy(org.eclipse.emf.eef.runtime.policies.impl.CreateEditingPolicy) EReferencePropertiesEditionContext(org.eclipse.emf.eef.runtime.context.impl.EReferencePropertiesEditionContext)

Example 9 with Requirement

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);
}
Also used : Requirement(org.obeonetwork.dsl.requirement.Requirement) Category(org.obeonetwork.dsl.requirement.Category) ReferencesTableSettings(org.eclipse.emf.eef.runtime.ui.widgets.referencestable.ReferencesTableSettings) ViewerFilter(org.eclipse.jface.viewers.ViewerFilter) CategoryPropertiesEditionPart(org.obeonetwork.dsl.requirement.parts.CategoryPropertiesEditionPart) Viewer(org.eclipse.jface.viewers.Viewer) EObject(org.eclipse.emf.ecore.EObject)

Example 10 with Requirement

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);
}
Also used : Requirement(org.obeonetwork.dsl.requirement.Requirement) EObjectStrictFilter(org.eclipse.emf.eef.runtime.impl.filters.EObjectStrictFilter) ReferencesTableSettings(org.eclipse.emf.eef.runtime.ui.widgets.referencestable.ReferencesTableSettings) ViewerFilter(org.eclipse.jface.viewers.ViewerFilter) EObject(org.eclipse.emf.ecore.EObject) Viewer(org.eclipse.jface.viewers.Viewer) EObject(org.eclipse.emf.ecore.EObject) AdvancedPropertiesEditionPart(org.obeonetwork.dsl.requirement.parts.AdvancedPropertiesEditionPart)

Aggregations

Requirement (org.obeonetwork.dsl.requirement.Requirement)20 EObject (org.eclipse.emf.ecore.EObject)11 ArrayList (java.util.ArrayList)7 Category (org.obeonetwork.dsl.requirement.Category)6 Resource (org.eclipse.emf.ecore.resource.Resource)5 Repository (org.obeonetwork.dsl.requirement.Repository)5 ResourceSet (org.eclipse.emf.ecore.resource.ResourceSet)3 HashSet (java.util.HashSet)2 LinkedHashSet (java.util.LinkedHashSet)2 LinkedList (java.util.LinkedList)2 List (java.util.List)2 Setting (org.eclipse.emf.ecore.EStructuralFeature.Setting)2 ReferencesTableSettings (org.eclipse.emf.eef.runtime.ui.widgets.referencestable.ReferencesTableSettings)2 RecordingCommand (org.eclipse.emf.transaction.RecordingCommand)2 TransactionalEditingDomain (org.eclipse.emf.transaction.TransactionalEditingDomain)2 Viewer (org.eclipse.jface.viewers.Viewer)2 ViewerFilter (org.eclipse.jface.viewers.ViewerFilter)2 SimpleDateFormat (java.text.SimpleDateFormat)1 HashMap (java.util.HashMap)1 IStatus (org.eclipse.core.runtime.IStatus)1