Search in sources :

Example 1 with Category

use of org.obeonetwork.dsl.requirement.Category in project InformationSystem by ObeoNetwork.

the class CategoryItemProvider method getText.

/**
 * This returns the label text for the adapted class.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated NOT
 */
@Override
public String getText(Object object) {
    Category cat = (Category) object;
    String id = cat.getId();
    String name = cat.getName();
    String label = null;
    if (!isEmptyString(id) && !isEmptyString(name)) {
        label = id + " - " + name;
    } else if (isEmptyString(id) && !isEmptyString(name)) {
        label = name;
    } else if (!isEmptyString(id) && isEmptyString(name)) {
        label = id;
    }
    return label == null || label.length() == 0 ? getString("_UI_Category_type") + " undefined" : label;
}
Also used : Category(org.obeonetwork.dsl.requirement.Category)

Example 2 with Category

use of org.obeonetwork.dsl.requirement.Category in project InformationSystem by ObeoNetwork.

the class ValidateRequirementsHandler method execute.

public Object execute(ExecutionEvent event) throws ExecutionException {
    IEditorPart editor = HandlerUtil.getActiveEditor(event);
    IEditorInput editorInput = HandlerUtil.getActiveEditorInput(event);
    if (editor instanceof RequirementEditor) {
        shell = HandlerUtil.getActiveShell(event);
        RequirementEditor ed = (RequirementEditor) editor;
        resourceSet = ed.getEditingDomain().getResourceSet();
    } else if (editorInput instanceof SessionEditorInput) {
        shell = HandlerUtil.getActiveShell(event);
        resourceSet = ((SessionEditorInput) editorInput).getSession().getTransactionalEditingDomain().getResourceSet();
    } else {
        return null;
    }
    Collection<EObject> objects = new ArrayList<EObject>();
    for (Resource resource : resourceSet.getResources()) {
        for (EObject eObject : resource.getContents()) {
            if (eObject instanceof Repository || eObject instanceof Category || eObject instanceof Requirement) {
                objects.add(eObject);
            }
        }
    }
    executeValidation(objects);
    return null;
}
Also used : SessionEditorInput(org.eclipse.sirius.ui.business.api.session.SessionEditorInput) Requirement(org.obeonetwork.dsl.requirement.Requirement) Repository(org.obeonetwork.dsl.requirement.Repository) Category(org.obeonetwork.dsl.requirement.Category) EObject(org.eclipse.emf.ecore.EObject) ArrayList(java.util.ArrayList) Resource(org.eclipse.emf.ecore.resource.Resource) RequirementEditor(org.obeonetwork.dsl.requirement.presentation.RequirementEditor) IEditorPart(org.eclipse.ui.IEditorPart) IEditorInput(org.eclipse.ui.IEditorInput)

Example 3 with Category

use of org.obeonetwork.dsl.requirement.Category in project InformationSystem by ObeoNetwork.

the class RequiremelntServicesTest method testService.

@Test
public void testService() {
    Repository repo = (Repository) EcoreUtil.create(RequirementPackage.Literals.REPOSITORY);
    Category cat = (Category) EcoreUtil.create(RequirementPackage.Literals.CATEGORY);
    repo.getMainCategories().add(cat);
    Requirement req1 = (Requirement) EcoreUtil.create(RequirementPackage.Literals.REQUIREMENT);
    Requirement req2 = (Requirement) EcoreUtil.create(RequirementPackage.Literals.REQUIREMENT);
    Requirement req3 = (Requirement) EcoreUtil.create(RequirementPackage.Literals.REQUIREMENT);
    cat.getRequirements().add(req1);
    cat.getRequirements().add(req2);
    cat.getRequirements().add(req3);
    Repository repo2 = (Repository) EcoreUtil.create(RequirementPackage.Literals.REPOSITORY);
    ResourceSet rs = new ResourceSetImpl();
    Resource resource = new XMLResourceImpl();
    rs.getResources().add(resource);
    resource.getContents().add(repo);
    resource.getContents().add(repo2);
    req1.getReferencedObject().add(repo2);
    req2.getReferencedObject().add(repo2);
    req3.getReferencedObject().add(repo2);
    List<Requirement> reqs = new RequirementServices().relatedRequirements(repo2);
    assertTrue(reqs.contains(req1));
    assertTrue(reqs.contains(req2));
    assertTrue(reqs.contains(req3));
}
Also used : XMLResourceImpl(org.eclipse.emf.ecore.xmi.impl.XMLResourceImpl) Requirement(org.obeonetwork.dsl.requirement.Requirement) Repository(org.obeonetwork.dsl.requirement.Repository) Category(org.obeonetwork.dsl.requirement.Category) ResourceSetImpl(org.eclipse.emf.ecore.resource.impl.ResourceSetImpl) Resource(org.eclipse.emf.ecore.resource.Resource) RequirementServices(org.obeonetwork.requirement.m2doc.services.RequirementServices) ResourceSet(org.eclipse.emf.ecore.resource.ResourceSet) Test(org.junit.Test)

Example 4 with Category

use of org.obeonetwork.dsl.requirement.Category 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 5 with Category

use of org.obeonetwork.dsl.requirement.Category 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)

Aggregations

Category (org.obeonetwork.dsl.requirement.Category)15 EObject (org.eclipse.emf.ecore.EObject)12 Repository (org.obeonetwork.dsl.requirement.Repository)7 Requirement (org.obeonetwork.dsl.requirement.Requirement)6 Resource (org.eclipse.emf.ecore.resource.Resource)4 ArrayList (java.util.ArrayList)3 Shell (org.eclipse.swt.widgets.Shell)3 CategorySelectionDialog (org.obeonetwork.dsl.requirement.design.selection.CategorySelectionDialog)3 List (java.util.List)2 IStatus (org.eclipse.core.runtime.IStatus)2 Status (org.eclipse.core.runtime.Status)2 EObjectPropertiesEditionContext (org.eclipse.emf.eef.runtime.context.impl.EObjectPropertiesEditionContext)2 EReferencePropertiesEditionContext (org.eclipse.emf.eef.runtime.context.impl.EReferencePropertiesEditionContext)2 PropertiesEditingPolicy (org.eclipse.emf.eef.runtime.policies.PropertiesEditingPolicy)2 CreateEditingPolicy (org.eclipse.emf.eef.runtime.policies.impl.CreateEditingPolicy)2 PropertiesEditingProvider (org.eclipse.emf.eef.runtime.providers.PropertiesEditingProvider)2 ReferencesTableSettings (org.eclipse.emf.eef.runtime.ui.widgets.referencestable.ReferencesTableSettings)2 Viewer (org.eclipse.jface.viewers.Viewer)2 ViewerFilter (org.eclipse.jface.viewers.ViewerFilter)2 ISelectionStatusValidator (org.eclipse.ui.dialogs.ISelectionStatusValidator)2