Search in sources :

Example 1 with BusinessDiagramEditor

use of org.talend.designer.business.model.business.diagram.part.BusinessDiagramEditor in project tdi-studio-se by Talend.

the class OpenDiagramAction method doRun.

/*
     * (non-Javadoc)
     * 
     * @see org.eclipse.jface.action.Action#run()
     */
@Override
protected void doRun() {
    ISelection selection = getSelectedObject();
    if (selection == null) {
        return;
    }
    Object obj = ((IStructuredSelection) selection).getFirstElement();
    if (obj instanceof RepositoryNode) {
        RepositoryNode repositoryNode = (RepositoryNode) obj;
        IRepositoryViewObject repositoryObject = repositoryNode.getObject();
        Property updatedProperty = null;
        if (repositoryObject instanceof RepositoryObject) {
            RepositoryViewObject abstractRepositoryObject = new RepositoryViewObject(repositoryObject.getProperty());
            updatedProperty = abstractRepositoryObject.getProperty();
        } else if (repositoryObject instanceof RepositoryViewObject) {
            updatedProperty = repositoryObject.getProperty();
        }
        if (updatedProperty != null) {
            BusinessProcessItem businessProcessItem = (BusinessProcessItem) updatedProperty.getItem();
            DiagramResourceManager diagramResourceManager = new DiagramResourceManager(getActivePage(), new NullProgressMonitor());
            IFile file = diagramResourceManager.createDiagramFile();
            diagramResourceManager.updateResource(businessProcessItem, file);
            IEditorPart part = diagramResourceManager.openEditor(businessProcessItem, file, false);
            if (part instanceof BusinessDiagramEditor) {
                ((BusinessDiagramEditor) part).setLastVersion(true);
            }
        // TDI-21143 : Studio repository view : remove all refresh call to repo view
        // IRepositoryView view = getViewPart();
        // if (view != null) {
        // view.refresh(repositoryNode);
        // }
        }
    }
}
Also used : NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) IFile(org.eclipse.core.resources.IFile) RepositoryObject(org.talend.core.model.repository.RepositoryObject) BusinessDiagramEditor(org.talend.designer.business.model.business.diagram.part.BusinessDiagramEditor) BusinessProcessItem(org.talend.core.model.properties.BusinessProcessItem) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) IEditorPart(org.eclipse.ui.IEditorPart) RepositoryNode(org.talend.repository.model.RepositoryNode) ISelection(org.eclipse.jface.viewers.ISelection) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) RepositoryObject(org.talend.core.model.repository.RepositoryObject) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) RepositoryViewObject(org.talend.core.model.repository.RepositoryViewObject) Property(org.talend.core.model.properties.Property) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) RepositoryViewObject(org.talend.core.model.repository.RepositoryViewObject)

Example 2 with BusinessDiagramEditor

use of org.talend.designer.business.model.business.diagram.part.BusinessDiagramEditor in project tdi-studio-se by Talend.

the class ReadDiagramAction method doRun.

/*
     * (non-Javadoc)
     * 
     * @see org.eclipse.jface.action.Action#run()
     */
protected void doRun() {
    if (repositoryNode == null && getSelection() != null) {
        Object firstElement = ((IStructuredSelection) getSelection()).getFirstElement();
        if (firstElement instanceof RepositoryNode) {
            repositoryNode = (RepositoryNode) firstElement;
        }
    }
    RepositoryNode node = repositoryNode;
    if (node != null) {
        IRepositoryViewObject repositoryObject = node.getObject();
        Property updatedProperty = repositoryObject.getProperty();
        if (updatedProperty != null) {
            BusinessProcessItem businessProcessItem = (BusinessProcessItem) updatedProperty.getItem();
            DiagramResourceManager diagramResourceManager = new DiagramResourceManager(getActivePage(), new NullProgressMonitor());
            IFile file = diagramResourceManager.createDiagramFile();
            diagramResourceManager.updateResource(businessProcessItem, file);
            IEditorPart part = diagramResourceManager.openEditor(businessProcessItem, file, true);
            if (part instanceof BusinessDiagramEditor) {
                ((BusinessDiagramEditor) part).setLastVersion(true);
            }
        }
    }
}
Also used : NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) IFile(org.eclipse.core.resources.IFile) BusinessDiagramEditor(org.talend.designer.business.model.business.diagram.part.BusinessDiagramEditor) BusinessProcessItem(org.talend.core.model.properties.BusinessProcessItem) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) IEditorPart(org.eclipse.ui.IEditorPart) RepositoryNode(org.talend.repository.model.RepositoryNode) Property(org.talend.core.model.properties.Property)

Example 3 with BusinessDiagramEditor

use of org.talend.designer.business.model.business.diagram.part.BusinessDiagramEditor in project tdi-studio-se by Talend.

the class SaveAsBusinessModelAction method run.

@Override
public void run() {
    SaveAsBusinessModelWizard businessModelWizard = new SaveAsBusinessModelWizard(editorPart);
    WizardDialog dlg = new WizardDialog(Display.getCurrent().getActiveShell(), businessModelWizard);
    if (dlg.open() == Window.OK) {
        try {
            BusinessProcessItem businessProcessItem = businessModelWizard.getBusinessProcessItem();
            IRepositoryNode repositoryNode = RepositoryNodeUtilities.getRepositoryNode(businessProcessItem.getProperty().getId(), false);
            // because step1, the fresh will unload the resource(EMF), so, assign a new one...
            businessProcessItem = (BusinessProcessItem) repositoryNode.getObject().getProperty().getItem();
            IWorkbenchPage page = getActivePage();
            DiagramResourceManager diagramResourceManager = new DiagramResourceManager(page, new NullProgressMonitor());
            IFile file = businessModelWizard.getTempFile();
            // Set readonly to false since created job will always be editable.
            RepositoryEditorInput newBusinessModelEditorInput = new RepositoryEditorInput(file, businessProcessItem);
            newBusinessModelEditorInput.setRepositoryNode(repositoryNode);
            // here really do the normal save as function
            IDocumentProvider provider = ((BusinessDiagramEditor) this.editorPart).getDocumentProvider();
            provider.aboutToChange(newBusinessModelEditorInput);
            provider.saveDocument(null, newBusinessModelEditorInput, provider.getDocument(this.editorPart.getEditorInput()), true);
            provider.changed(newBusinessModelEditorInput);
            // copy back from the *.business_diagram file to *.item file.
            // @see:BusinessDiagramEditor.doSave(IProgressMonitor progressMonitor)
            diagramResourceManager.updateFromResource(businessProcessItem, newBusinessModelEditorInput.getFile());
            // notice: here, must save it, save the item to disk, otherwise close the editor
            // without any modification, there won't save the
            // model again, so, will lost the graphic when reopen it.
            ProxyRepositoryFactory.getInstance().save(businessProcessItem);
            // close the old editor
            page.closeEditor(this.editorPart, false);
            // open the new editor, because at the same time, there will update the jobSetting/componentSetting view
            IEditorPart openEditor = page.openEditor(newBusinessModelEditorInput, BusinessDiagramEditor.ID, true);
        } catch (Exception e) {
            MessageDialog.openError(Display.getCurrent().getActiveShell(), "Error", "Business model could not be saved" + " : " + e.getMessage());
            ExceptionHandler.process(e);
        }
    }
}
Also used : NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) IFile(org.eclipse.core.resources.IFile) RepositoryEditorInput(org.talend.core.repository.ui.editor.RepositoryEditorInput) IRepositoryNode(org.talend.repository.model.IRepositoryNode) BusinessDiagramEditor(org.talend.designer.business.model.business.diagram.part.BusinessDiagramEditor) BusinessProcessItem(org.talend.core.model.properties.BusinessProcessItem) IEditorPart(org.eclipse.ui.IEditorPart) IDocumentProvider(org.eclipse.gmf.runtime.diagram.ui.resources.editor.document.IDocumentProvider) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) WizardDialog(org.eclipse.jface.wizard.WizardDialog)

Example 4 with BusinessDiagramEditor

use of org.talend.designer.business.model.business.diagram.part.BusinessDiagramEditor in project tdi-studio-se by Talend.

the class FindAssignmentAction method doRun.

/*
     * (non-Javadoc)
     * 
     * @see org.eclipse.jface.action.Action#run()
     */
@Override
protected void doRun() {
    RepositoryNode repositoryNode = (RepositoryNode) getFirstSelectedObject();
    IEditorPart activeEditor = getActiveEditor();
    // remove frames draw last time
    for (BusinessItemShapeFigure shapFigure : repaintedFigures) {
        shapFigure.setDrawFrame(false);
        shapFigure.revalidate();
        shapFigure.repaint();
    }
    if (activeEditor instanceof BusinessDiagramEditor) {
        BusinessDiagramEditor businessDiagramEditor = (BusinessDiagramEditor) activeEditor;
        Diagram diagram = (Diagram) businessDiagramEditor.getDiagramEditPart().getModel();
        BusinessProcess businessProcess = (BusinessProcess) diagram.getElement();
        // PTODO mhelleboid use OCL or using a visitor
        List list = new ArrayList();
        for (Iterator iter = businessProcess.getBusinessItems().iterator(); iter.hasNext(); ) {
            BusinessItem businessItem = (BusinessItem) iter.next();
            for (Iterator iterator = businessItem.getAssignments().iterator(); iterator.hasNext(); ) {
                BusinessAssignment businessAssignment = (BusinessAssignment) iterator.next();
                TalendItem talendItem = businessAssignment.getTalendItem();
                IRepositoryViewObject obj = repositoryNode.getObject();
                if (talendItem.getId().equals(repositoryNode.getId())) {
                    list.add(businessItem);
                } else if (talendItem instanceof SQLPattern || talendItem instanceof Routine || talendItem instanceof TableMetadata || talendItem instanceof Query || talendItem instanceof SapFunctionMetadata) {
                    if (talendItem.getLabel().equals(repositoryNode.getProperties(EProperties.LABEL))) {
                        list.add(businessItem);
                    }
                }
            }
        }
        IDiagramGraphicalViewer diagramGraphicalViewer = businessDiagramEditor.getDiagramGraphicalViewer();
        List editParts = new ArrayList();
        for (Iterator iter = list.iterator(); iter.hasNext(); ) {
            BusinessItem businessItem = (BusinessItem) iter.next();
            editParts.addAll(diagramGraphicalViewer.findEditPartsForElement(EMFCoreUtil.getProxyID(businessItem), BaseBusinessItemRelationShipEditPart.class));
            editParts.addAll(diagramGraphicalViewer.findEditPartsForElement(EMFCoreUtil.getProxyID(businessItem), BusinessItemShapeEditPart.class));
        }
        diagramGraphicalViewer.deselectAll();
        // add a frame when use findAassignment
        for (Iterator iter = editParts.iterator(); iter.hasNext(); ) {
            EditPart editPart = (EditPart) iter.next();
            if (editPart instanceof BusinessItemShapeEditPart) {
                BusinessItemShapeEditPart shapEditPart = (BusinessItemShapeEditPart) editPart;
                IFigure figure = shapEditPart.getFigure();
                for (Object child : figure.getChildren()) {
                    if (child instanceof BusinessItemShapeFigure) {
                        BusinessItemShapeFigure shapFigure = (BusinessItemShapeFigure) child;
                        shapFigure.setDrawFrame(true);
                        shapFigure.revalidate();
                        shapFigure.repaint();
                        repaintedFigures.add(shapFigure);
                    }
                }
            }
            diagramGraphicalViewer.getSelectionManager().appendSelection(editPart);
        }
        ZoomManager zoomManager = (ZoomManager) businessDiagramEditor.getAdapter(ZoomManager.class);
        zoomFitSelection(zoomManager, editParts, businessDiagramEditor.getDiagramEditPart(), true);
    }
}
Also used : IDiagramGraphicalViewer(org.eclipse.gmf.runtime.diagram.ui.parts.IDiagramGraphicalViewer) SapFunctionMetadata(org.talend.designer.business.model.business.SapFunctionMetadata) BusinessDiagramEditor(org.talend.designer.business.model.business.diagram.part.BusinessDiagramEditor) BusinessAssignment(org.talend.designer.business.model.business.BusinessAssignment) Query(org.talend.designer.business.model.business.Query) ArrayList(java.util.ArrayList) Iterator(java.util.Iterator) ArrayList(java.util.ArrayList) List(java.util.List) TalendItem(org.talend.designer.business.model.business.TalendItem) IFigure(org.eclipse.draw2d.IFigure) TableMetadata(org.talend.designer.business.model.business.TableMetadata) SQLPattern(org.talend.designer.business.model.business.SQLPattern) BusinessItemShapeEditPart(org.talend.designer.business.diagram.custom.edit.parts.BusinessItemShapeEditPart) DiagramEditPart(org.eclipse.gmf.runtime.diagram.ui.editparts.DiagramEditPart) GraphicalEditPart(org.eclipse.gef.GraphicalEditPart) EditPart(org.eclipse.gef.EditPart) BaseBusinessItemRelationShipEditPart(org.talend.designer.business.diagram.custom.edit.parts.BaseBusinessItemRelationShipEditPart) IEditorPart(org.eclipse.ui.IEditorPart) Routine(org.talend.designer.business.model.business.Routine) RepositoryNode(org.talend.repository.model.RepositoryNode) BaseBusinessItemRelationShipEditPart(org.talend.designer.business.diagram.custom.edit.parts.BaseBusinessItemRelationShipEditPart) Diagram(org.eclipse.gmf.runtime.notation.Diagram) BusinessItemShapeEditPart(org.talend.designer.business.diagram.custom.edit.parts.BusinessItemShapeEditPart) ZoomManager(org.eclipse.gef.editparts.ZoomManager) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) BusinessItemShapeFigure(org.talend.designer.business.diagram.custom.figures.BusinessItemShapeFigure) BusinessItem(org.talend.designer.business.model.business.BusinessItem) BusinessProcess(org.talend.designer.business.model.business.BusinessProcess)

Example 5 with BusinessDiagramEditor

use of org.talend.designer.business.model.business.diagram.part.BusinessDiagramEditor 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

IEditorPart (org.eclipse.ui.IEditorPart)7 BusinessDiagramEditor (org.talend.designer.business.model.business.diagram.part.BusinessDiagramEditor)7 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)4 IFile (org.eclipse.core.resources.IFile)3 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)3 BusinessProcessItem (org.talend.core.model.properties.BusinessProcessItem)3 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)3 RepositoryNode (org.talend.repository.model.RepositoryNode)3 ISelection (org.eclipse.jface.viewers.ISelection)2 IEditorReference (org.eclipse.ui.IEditorReference)2 IWorkbenchPage (org.eclipse.ui.IWorkbenchPage)2 Property (org.talend.core.model.properties.Property)2 BaseBusinessItemRelationShipEditPart (org.talend.designer.business.diagram.custom.edit.parts.BaseBusinessItemRelationShipEditPart)2 BusinessItemShapeEditPart (org.talend.designer.business.diagram.custom.edit.parts.BusinessItemShapeEditPart)2 BusinessItem (org.talend.designer.business.model.business.BusinessItem)2 ArrayList (java.util.ArrayList)1 Iterator (java.util.Iterator)1 List (java.util.List)1 ExecutionException (org.eclipse.core.commands.ExecutionException)1 IFigure (org.eclipse.draw2d.IFigure)1