Search in sources :

Example 1 with EdgeImpl

use of org.eclipse.gmf.runtime.notation.impl.EdgeImpl in project tdi-studio-se by Talend.

the class DeleteAssignmentAction method doRun.

@Override
protected void doRun() {
    IEditorPart activeEditor = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor();
    if (activeEditor instanceof BusinessDiagramEditor) {
        BusinessDiagramEditor editor = (BusinessDiagramEditor) activeEditor;
        ISelection selection2 = editor.getSelection();
        EObject element = null;
        Object firstElement = ((IStructuredSelection) selection2).getFirstElement();
        if (firstElement instanceof BusinessItemShapeEditPart) {
            BusinessItemShapeEditPart editpart = (BusinessItemShapeEditPart) firstElement;
            element = ((Node) editpart.getModel()).getElement();
        } else if (firstElement instanceof BaseBusinessItemRelationShipEditPart) {
            BaseBusinessItemRelationShipEditPart editpart = (BaseBusinessItemRelationShipEditPart) firstElement;
            element = ((EdgeImpl) editpart.getModel()).getElement();
        }
        if (element instanceof BusinessItem) {
            BusinessItem businessItem = (BusinessItem) element;
            DeleteAssignmentCommand command = new DeleteAssignmentCommand(businessItem, selection);
            try {
                command.execute(null, null);
            } catch (ExecutionException e) {
                ExceptionHandler.process(e);
            }
            IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
            for (IEditorReference editors : page.getEditorReferences()) {
                CorePlugin.getDefault().getDiagramModelService().refreshBusinessModel(editors);
            }
        }
    }
}
Also used : BusinessDiagramEditor(org.talend.designer.business.model.business.diagram.part.BusinessDiagramEditor) EdgeImpl(org.eclipse.gmf.runtime.notation.impl.EdgeImpl) IEditorPart(org.eclipse.ui.IEditorPart) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) DeleteAssignmentCommand(org.talend.designer.business.diagram.custom.commands.DeleteAssignmentCommand) BaseBusinessItemRelationShipEditPart(org.talend.designer.business.diagram.custom.edit.parts.BaseBusinessItemRelationShipEditPart) IEditorReference(org.eclipse.ui.IEditorReference) BusinessItemShapeEditPart(org.talend.designer.business.diagram.custom.edit.parts.BusinessItemShapeEditPart) EObject(org.eclipse.emf.ecore.EObject) ISelection(org.eclipse.jface.viewers.ISelection) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) EObject(org.eclipse.emf.ecore.EObject) ExecutionException(org.eclipse.core.commands.ExecutionException) BusinessItem(org.talend.designer.business.model.business.BusinessItem)

Aggregations

ExecutionException (org.eclipse.core.commands.ExecutionException)1 EObject (org.eclipse.emf.ecore.EObject)1 EdgeImpl (org.eclipse.gmf.runtime.notation.impl.EdgeImpl)1 ISelection (org.eclipse.jface.viewers.ISelection)1 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)1 IEditorPart (org.eclipse.ui.IEditorPart)1 IEditorReference (org.eclipse.ui.IEditorReference)1 IWorkbenchPage (org.eclipse.ui.IWorkbenchPage)1 DeleteAssignmentCommand (org.talend.designer.business.diagram.custom.commands.DeleteAssignmentCommand)1 BaseBusinessItemRelationShipEditPart (org.talend.designer.business.diagram.custom.edit.parts.BaseBusinessItemRelationShipEditPart)1 BusinessItemShapeEditPart (org.talend.designer.business.diagram.custom.edit.parts.BusinessItemShapeEditPart)1 BusinessItem (org.talend.designer.business.model.business.BusinessItem)1 BusinessDiagramEditor (org.talend.designer.business.model.business.diagram.part.BusinessDiagramEditor)1