Search in sources :

Example 11 with Requirement

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

the class RequirementRequirementPropertiesEditionComponent 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 RequirementPropertiesEditionPart requirementPart = (RequirementPropertiesEditionPart) editingPart;
        // init values
        if (isAccessible(RequirementViewsRepository.Requirement_.id))
            requirementPart.setId(EEFConverterUtil.convertToString(EcorePackage.Literals.ESTRING, requirement.getId()));
        if (isAccessible(RequirementViewsRepository.Requirement_.version)) {
            requirementPart.setVersion(requirement.getVersion());
        }
        if (isAccessible(RequirementViewsRepository.Requirement_.name))
            requirementPart.setName(EEFConverterUtil.convertToString(EcorePackage.Literals.ESTRING, requirement.getName()));
        if (isAccessible(RequirementViewsRepository.Requirement_.statement))
            requirementPart.setStatement(EcoreUtil.convertToString(EcorePackage.Literals.ESTRING, requirement.getStatement()));
        if (isAccessible(RequirementViewsRepository.Requirement_.type)) {
            requirementPart.initType(EEFUtils.choiceOfValues(requirement, RequirementPackage.eINSTANCE.getRequirement_Type()), requirement.getType());
        }
        if (isAccessible(RequirementViewsRepository.Requirement_.status))
            requirementPart.setStatus(EEFConverterUtil.convertToString(EcorePackage.Literals.ESTRING, requirement.getStatus()));
        if (isAccessible(RequirementViewsRepository.Requirement_.subtype))
            requirementPart.setSubtype(EEFConverterUtil.convertToString(EcorePackage.Literals.ESTRING, requirement.getSubtype()));
        if (isAccessible(RequirementViewsRepository.Requirement_.modifiedOn))
            requirementPart.setModifiedOn(EEFConverterUtil.convertToString(EcorePackage.Literals.EDATE, requirement.getModifiedOn()));
        if (isAccessible(RequirementViewsRepository.Requirement_.createdOn))
            requirementPart.setCreatedOn(EEFConverterUtil.convertToString(EcorePackage.Literals.EDATE, requirement.getCreatedOn()));
        // init filters
        // Start of user code  for version filter update
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        if (requirement.getModifiedOn() != null && isAccessible(RequirementViewsRepository.Requirement_.modifiedOn))
            requirementPart.setModifiedOn(simpleDateFormat.format(requirement.getModifiedOn()));
        if (requirement.getCreatedOn() != null && isAccessible(RequirementViewsRepository.Requirement_.createdOn))
            requirementPart.setCreatedOn(simpleDateFormat.format(requirement.getCreatedOn()));
    // End of user code
    // init values for referenced views
    // init filters for referenced views
    }
    setInitializing(false);
}
Also used : Requirement(org.obeonetwork.dsl.requirement.Requirement) RequirementPropertiesEditionPart(org.obeonetwork.dsl.requirement.parts.RequirementPropertiesEditionPart) SimpleDateFormat(java.text.SimpleDateFormat)

Example 12 with Requirement

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

the class RequirementLinkType method loadLinks.

/**
 * {@inheritDoc}
 *
 * @see org.obeonetwork.tools.linker.LinkType#loadLinks(org.eclipse.emf.ecore.EObject)
 */
public List<EObjectLink> loadLinks(EObject source) {
    List<EObjectLink> links = new ArrayList<EObjectLink>();
    Requirement[] linkedRequirements = RequirementService.getLinkedRequirements(source);
    if (linkedRequirements.length > 0) {
        for (Requirement requirement : linkedRequirements) {
            links.add(new RequirementLinkImpl(requirement, source));
        }
    }
    return links;
}
Also used : Requirement(org.obeonetwork.dsl.requirement.Requirement) EObjectLink(org.obeonetwork.tools.linker.EObjectLink) ArrayList(java.util.ArrayList)

Example 13 with Requirement

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

the class RequirementService method getLinkedRequirements.

private static Set<Requirement> getLinkedRequirements(Session session, EObject eObject) {
    ECrossReferenceAdapter crossReferenceAdapter = session.getSemanticCrossReferencer();
    HashSet<Requirement> linkedRequirements = new HashSet<Requirement>();
    for (Setting setting : crossReferenceAdapter.getInverseReferences(eObject)) {
        if (setting.getEObject() instanceof Requirement) {
            Requirement requirement = (Requirement) setting.getEObject();
            // duplicates
            if (requirement.getReferencedObject().contains(eObject)) {
                linkedRequirements.add(requirement);
            }
        }
    }
    return linkedRequirements;
}
Also used : ECrossReferenceAdapter(org.eclipse.emf.ecore.util.ECrossReferenceAdapter) Requirement(org.obeonetwork.dsl.requirement.Requirement) Setting(org.eclipse.emf.ecore.EStructuralFeature.Setting) HashSet(java.util.HashSet)

Example 14 with Requirement

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

the class LinkRequirementsDialog method expandTreeViewerUpToCheckedElements.

/**
 * Expands a {@link TreeViewer} up to all the given elements.
 *
 * @param treeViewer
 * @param checkedElements
 */
private static void expandTreeViewerUpToCheckedElements(TreeViewer treeViewer, List<Requirement> checkedElements) {
    ITreeContentProvider contentProvider = (ITreeContentProvider) treeViewer.getContentProvider();
    // We need the unicity because there may be common ancestors in the tree
    // of several checked elements. We also need the insertion order because
    // we need to expand the higher nodes first.
    LinkedHashSet<Object> treeOfElements = new LinkedHashSet<Object>();
    for (Requirement checkedElement : checkedElements) {
        Object element = checkedElement;
        while (contentProvider.getParent(element) != null) {
            treeOfElements.add(element);
            element = contentProvider.getParent(element);
        }
    }
    // Reverse the order to start with the root element (the EMF Resource).
    List<Object> elementsToExpand = new ArrayList<Object>(treeOfElements);
    Collections.reverse(elementsToExpand);
    treeViewer.setExpandedElements(elementsToExpand.toArray());
}
Also used : LinkedHashSet(java.util.LinkedHashSet) ITreeContentProvider(org.eclipse.jface.viewers.ITreeContentProvider) Requirement(org.obeonetwork.dsl.requirement.Requirement) ArrayList(java.util.ArrayList) EObject(org.eclipse.emf.ecore.EObject)

Example 15 with Requirement

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

the class RequirementCreationOperation method doExecute.

/**
 * {@inheritDoc}
 *
 * @see org.eclipse.emf.workspace.AbstractEMFOperation#doExecute(org.eclipse.core.runtime.IProgressMonitor,
 *      org.eclipse.core.runtime.IAdaptable)
 */
protected IStatus doExecute(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
    ((RequirementCreationPropertiesEditingContext) this.editingContext).preProcess();
    RequirementEditingWizard wizard = new RequirementEditingWizard(editingContext, editingContext.getAdapterFactory(), editingContext.getEObject());
    WizardDialog wDialog = new WizardDialog(EditingUtils.getShell(), wizard) {

        /**
         * {@inheritDoc}
         *
         * @see org.eclipse.jface.dialogs.TitleAreaDialog#getInitialSize()
         */
        @Override
        protected Point getInitialSize() {
            Point initialSize = super.getInitialSize();
            return new Point(Math.min(UIConstants.INITIAL_WIZARD_SIZE.x, initialSize.x), Math.min(UIConstants.INITIAL_WIZARD_SIZE.y, initialSize.y));
        }
    };
    int open = wDialog.open();
    ChangeDescription description = editingContext.getChangeRecorder().endRecording();
    if (open == Window.OK) {
        Requirement requirement = (Requirement) editingContext.getEObject();
        requirement.eResource().getContents().remove(requirement);
        wizard.getOwningCategory().getRequirements().add(requirement);
        return Status.OK_STATUS;
    } else {
        description.applyAndReverse();
        return Status.CANCEL_STATUS;
    }
}
Also used : Requirement(org.obeonetwork.dsl.requirement.Requirement) RequirementCreationPropertiesEditingContext(org.obeonetwork.tools.requirement.wizard.util.RequirementCreationPropertiesEditingContext) ChangeDescription(org.eclipse.emf.ecore.change.ChangeDescription) RequirementEditingWizard(org.obeonetwork.tools.requirement.wizard.RequirementEditingWizard) Point(org.eclipse.swt.graphics.Point) WizardDialog(org.eclipse.jface.wizard.WizardDialog) Point(org.eclipse.swt.graphics.Point)

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