Search in sources :

Example 6 with Diagram

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

the class GmfPastCommand method doExecuteWithResult.

/*
     * (non-Javadoc)
     * 
     * @see
     * org.eclipse.gmf.runtime.emf.commands.core.command.AbstractTransactionalCommand#doExecuteWithResult(org.eclipse
     * .core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
     */
@Override
protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
    List pChildren = ((Diagram) part.getModel()).getPersistedChildren();
    cloneAssignmentForModel(nodes, pChildren);
    cloneAssignmentForModel(edges, ((Diagram) part.getModel()).getPersistedEdges());
    return CommandResult.newOKCommandResult();
}
Also used : ArrayList(java.util.ArrayList) List(java.util.List) Diagram(org.eclipse.gmf.runtime.notation.Diagram)

Example 7 with Diagram

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

the class DiagramResourceManager method updateFromResource.

public void updateFromResource(BusinessProcessItem businessProcessItem, IFile file) {
    Resource resource = createResource(file);
    BusinessProcess semantic = (BusinessProcess) EcoreUtil.getObjectByType(resource.getContents(), BusinessPackage.eINSTANCE.getBusinessProcess());
    Diagram notation = (Diagram) EcoreUtil.getObjectByType(resource.getContents(), NotationPackage.eINSTANCE.getDiagram());
    businessProcessItem.setSemantic(semantic);
    businessProcessItem.setNotation(notation);
}
Also used : Resource(org.eclipse.emf.ecore.resource.Resource) BusinessProcess(org.talend.designer.business.model.business.BusinessProcess) Diagram(org.eclipse.gmf.runtime.notation.Diagram)

Example 8 with Diagram

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

the class BusinessDocumentProvider method saveDocumentToFile.

/**
     * @generated
     */
protected void saveDocumentToFile(IDocument document, IFile file, boolean overwrite, IProgressMonitor monitor) throws CoreException {
    Diagram diagram = (Diagram) document.getContent();
    Resource diagramResource = diagram.eResource();
    IDiagramDocument diagramDocument = (IDiagramDocument) document;
    TransactionalEditingDomain domain = diagramDocument.getEditingDomain();
    List resources = domain.getResourceSet().getResources();
    //$NON-NLS-1$
    monitor.beginTask("Saving diagram", resources.size() + 1);
    super.saveDocumentToFile(document, file, overwrite, new SubProgressMonitor(monitor, 1));
    for (Iterator it = resources.iterator(); it.hasNext(); ) {
        Resource nextResource = (Resource) it.next();
        //$NON-NLS-1$
        monitor.setTaskName("Saving " + nextResource.getURI());
        if (nextResource != diagramResource && nextResource.isLoaded()) {
            try {
                nextResource.save(Collections.EMPTY_MAP);
            } catch (IOException e) {
                BusinessDiagramEditorPlugin.getInstance().logError("Unable to save resource: " + nextResource.getURI(), //$NON-NLS-1$
                e);
            }
        }
        monitor.worked(1);
    }
    monitor.done();
}
Also used : TransactionalEditingDomain(org.eclipse.emf.transaction.TransactionalEditingDomain) IResource(org.eclipse.core.resources.IResource) Resource(org.eclipse.emf.ecore.resource.Resource) IDiagramDocument(org.eclipse.gmf.runtime.diagram.ui.resources.editor.document.IDiagramDocument) Iterator(java.util.Iterator) ArrayList(java.util.ArrayList) List(java.util.List) IOException(java.io.IOException) SubProgressMonitor(org.eclipse.core.runtime.SubProgressMonitor) Diagram(org.eclipse.gmf.runtime.notation.Diagram)

Aggregations

Diagram (org.eclipse.gmf.runtime.notation.Diagram)8 List (java.util.List)6 ArrayList (java.util.ArrayList)5 Resource (org.eclipse.emf.ecore.resource.Resource)4 BusinessProcess (org.talend.designer.business.model.business.BusinessProcess)4 IOException (java.io.IOException)3 Iterator (java.util.Iterator)3 ExecutionException (org.eclipse.core.commands.ExecutionException)3 Collection (java.util.Collection)2 IFile (org.eclipse.core.resources.IFile)2 CoreException (org.eclipse.core.runtime.CoreException)2 IAdaptable (org.eclipse.core.runtime.IAdaptable)2 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)2 SubProgressMonitor (org.eclipse.core.runtime.SubProgressMonitor)2 EObject (org.eclipse.emf.ecore.EObject)2 ResourceSet (org.eclipse.emf.ecore.resource.ResourceSet)2 TransactionalEditingDomain (org.eclipse.emf.transaction.TransactionalEditingDomain)2 EditPart (org.eclipse.gef.EditPart)2 DiagramEditPart (org.eclipse.gmf.runtime.diagram.ui.editparts.DiagramEditPart)2 AbstractTransactionalCommand (org.eclipse.gmf.runtime.emf.commands.core.command.AbstractTransactionalCommand)2