Search in sources :

Example 1 with EObjectLink

use of org.obeonetwork.tools.linker.EObjectLink 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 2 with EObjectLink

use of org.obeonetwork.tools.linker.EObjectLink in project InformationSystem by ObeoNetwork.

the class UnlinkRequirementAction method run.

/**
 * {@inheritDoc}
 *
 * @see org.eclipse.jface.action.Action#run()
 */
@Override
public void run() {
    MessageDialog dialog = new MessageDialog(linksView.getSite().getShell(), // $NON-NLS-1$
    RequirementLinkerPlugin.getInstance().getString("DeleteRequirementLinkAction_ConfirmDialog_title"), null, // $NON-NLS-1$
    RequirementLinkerPlugin.getInstance().getString("DeleteRequirementLinkAction_ConfirmDialog_msg"), MessageDialog.CONFIRM, new String[] { IDialogConstants.OK_LABEL, IDialogConstants.CANCEL_LABEL }, 1);
    boolean openConfirm = dialog.open() == Window.OK;
    if (openConfirm) {
        Session session = new EObjectQuery(linksView.getInput()).getSession();
        if (session != null) {
            TransactionalEditingDomain editingDomain = session.getTransactionalEditingDomain();
            RecordingCommand cmd = new // $NON-NLS-1$
            RecordingCommand(// $NON-NLS-1$
            editingDomain, // $NON-NLS-1$
            "UnLink Requirements") {

                protected void doExecute() {
                    for (EObjectLink link : linksView.getSelectedEntries()) {
                        if (link instanceof RequirementLink) {
                            RequirementLink reqLink = (RequirementLink) link;
                            reqLink.getRequirement().getReferencedObject().remove(linksView.getInput());
                        }
                    }
                }
            };
            editingDomain.getCommandStack().execute(cmd);
        }
        linksView.refresh();
    }
}
Also used : EObjectQuery(org.eclipse.sirius.business.api.query.EObjectQuery) TransactionalEditingDomain(org.eclipse.emf.transaction.TransactionalEditingDomain) RecordingCommand(org.eclipse.emf.transaction.RecordingCommand) EObjectLink(org.obeonetwork.tools.linker.EObjectLink) MessageDialog(org.eclipse.jface.dialogs.MessageDialog) RequirementLink(org.obeonetwork.tools.requirement.core.RequirementLink) Session(org.eclipse.sirius.business.api.session.Session)

Example 3 with EObjectLink

use of org.obeonetwork.tools.linker.EObjectLink in project InformationSystem by ObeoNetwork.

the class DeleteDocumentationLink method run.

/**
 * {@inheritDoc}
 * @see org.eclipse.jface.action.Action#run()
 */
@Override
public void run() {
    MessageDialog dialog = new MessageDialog(linksView.getSite().getShell(), // $NON-NLS-1$
    DocBridgeUI.getInstance().getString("DeleteDocumentationLinkAction_ConfirmDialog_title"), // $NON-NLS-1$
    null, DocBridgeUI.getInstance().getString("DeleteDocumentationLinkAction_ConfirmDialog_msg"), MessageDialog.CONFIRM, new String[] { // $NON-NLS-1$
    IDialogConstants.OK_LABEL, IDialogConstants.CANCEL_LABEL }, 1);
    boolean openConfirm = dialog.open() == Window.OK;
    if (openConfirm) {
        List<DocumentationLink> selection = new ArrayList<DocumentationLink>();
        for (EObjectLink link : linksView.getSelectedEntries()) {
            if (link instanceof DocumentationLink) {
                selection.add((DocumentationLink) link);
            }
        }
        EObject input = linksView.getInput();
        TransactionalEditingDomain editingDomain = TransactionUtil.getEditingDomain(input);
        if (!selection.isEmpty() && editingDomain != null) {
            for (DocumentationLink entry : selection) {
                editingDomain.getCommandStack().execute(new RemoveDocumentationLinkCommand(input, entry));
            }
            linksView.refresh();
        }
    }
}
Also used : TransactionalEditingDomain(org.eclipse.emf.transaction.TransactionalEditingDomain) RemoveDocumentationLinkCommand(org.obeonetwork.tools.doc.core.command.RemoveDocumentationLinkCommand) DocumentationLink(org.obeonetwork.tools.doc.core.DocumentationLink) EObjectLink(org.obeonetwork.tools.linker.EObjectLink) EObject(org.eclipse.emf.ecore.EObject) ArrayList(java.util.ArrayList) MessageDialog(org.eclipse.jface.dialogs.MessageDialog)

Example 4 with EObjectLink

use of org.obeonetwork.tools.linker.EObjectLink in project InformationSystem by ObeoNetwork.

the class EObjectLinkContentProvider method getChildrenEntries.

/**
 * @param inputElement
 * @return
 */
private List<EObjectLink> getChildrenEntries(EObject inputElement) {
    List<EObjectLink> result = new ArrayList<EObjectLink>();
    for (Iterator<EObject> iter = inputElement.eAllContents(); iter.hasNext(); ) {
        EObject next = iter.next();
        result.addAll(linker.getLinks(next));
    }
    return result;
}
Also used : EObjectLink(org.obeonetwork.tools.linker.EObjectLink) EObject(org.eclipse.emf.ecore.EObject) ArrayList(java.util.ArrayList)

Example 5 with EObjectLink

use of org.obeonetwork.tools.linker.EObjectLink in project InformationSystem by ObeoNetwork.

the class DocumentationLinkType method loadLinks.

/**
 * {@inheritDoc}
 * @see org.obeonetwork.tools.linker.LinkType#loadLinks(org.eclipse.emf.ecore.EObject)
 */
public List<EObjectLink> loadLinks(EObject source) {
    if (source instanceof ObeoDSMObject) {
        ObeoDSMObject element = (ObeoDSMObject) source;
        MetaDataContainer metadatas = element.getMetadatas();
        if (metadatas != null) {
            List<EObjectLink> result = new ArrayList<EObjectLink>();
            for (MetaData metadata : metadatas.getMetadatas()) {
                if (metadata instanceof Annotation) {
                    Annotation annotation = (Annotation) metadata;
                    if (annotation.getTitle() != null && annotation.getTitle().startsWith(DocumentationLink.DOCUMENTATION_ANNOTATION_TITLE)) {
                        DocumentationLink link = new DocumentationLinkImpl(annotation);
                        result.add(link);
                    }
                }
            }
            return result;
        }
    }
    return Collections.emptyList();
}
Also used : MetaData(org.obeonetwork.dsl.environment.MetaData) DocumentationLink(org.obeonetwork.tools.doc.core.DocumentationLink) ObeoDSMObject(org.obeonetwork.dsl.environment.ObeoDSMObject) EObjectLink(org.obeonetwork.tools.linker.EObjectLink) ArrayList(java.util.ArrayList) MetaDataContainer(org.obeonetwork.dsl.environment.MetaDataContainer) Annotation(org.obeonetwork.dsl.environment.Annotation)

Aggregations

EObjectLink (org.obeonetwork.tools.linker.EObjectLink)5 ArrayList (java.util.ArrayList)4 EObject (org.eclipse.emf.ecore.EObject)2 TransactionalEditingDomain (org.eclipse.emf.transaction.TransactionalEditingDomain)2 MessageDialog (org.eclipse.jface.dialogs.MessageDialog)2 DocumentationLink (org.obeonetwork.tools.doc.core.DocumentationLink)2 RecordingCommand (org.eclipse.emf.transaction.RecordingCommand)1 EObjectQuery (org.eclipse.sirius.business.api.query.EObjectQuery)1 Session (org.eclipse.sirius.business.api.session.Session)1 Annotation (org.obeonetwork.dsl.environment.Annotation)1 MetaData (org.obeonetwork.dsl.environment.MetaData)1 MetaDataContainer (org.obeonetwork.dsl.environment.MetaDataContainer)1 ObeoDSMObject (org.obeonetwork.dsl.environment.ObeoDSMObject)1 Requirement (org.obeonetwork.dsl.requirement.Requirement)1 RemoveDocumentationLinkCommand (org.obeonetwork.tools.doc.core.command.RemoveDocumentationLinkCommand)1 RequirementLink (org.obeonetwork.tools.requirement.core.RequirementLink)1