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