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);
}
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;
}
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;
}
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());
}
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;
}
}
Aggregations