Search in sources :

Example 1 with RemoveDocumentationLinkCommand

use of org.obeonetwork.tools.doc.core.command.RemoveDocumentationLinkCommand 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)

Aggregations

ArrayList (java.util.ArrayList)1 EObject (org.eclipse.emf.ecore.EObject)1 TransactionalEditingDomain (org.eclipse.emf.transaction.TransactionalEditingDomain)1 MessageDialog (org.eclipse.jface.dialogs.MessageDialog)1 DocumentationLink (org.obeonetwork.tools.doc.core.DocumentationLink)1 RemoveDocumentationLinkCommand (org.obeonetwork.tools.doc.core.command.RemoveDocumentationLinkCommand)1 EObjectLink (org.obeonetwork.tools.linker.EObjectLink)1