Java Code Examples for org.eclipse.gmf.runtime.notation.Diagram#eResource()

The following examples show how to use org.eclipse.gmf.runtime.notation.Diagram#eResource() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CrossflowDiagramEditor.java    From scava with Eclipse Public License 2.0 6 votes vote down vote up
/**
* @generated
*/
private ISelection getNavigatorSelection() {
	IDiagramDocument document = getDiagramDocument();
	if (document == null) {
		return StructuredSelection.EMPTY;
	}
	Diagram diagram = document.getDiagram();
	if (diagram == null || diagram.eResource() == null) {
		return StructuredSelection.EMPTY;
	}
	IFile file = WorkspaceSynchronizer.getFile(diagram.eResource());
	if (file != null) {
		CrossflowNavigatorItem item = new CrossflowNavigatorItem(diagram, file, false);
		return new StructuredSelection(item);
	}
	return StructuredSelection.EMPTY;
}
 
Example 2
Source File: CrossflowNavigatorLinkHelper.java    From scava with Eclipse Public License 2.0 6 votes vote down vote up
/**
* @generated
*/
private static IEditorInput getEditorInput(Diagram diagram) {
	Resource diagramResource = diagram.eResource();
	for (EObject nextEObject : diagramResource.getContents()) {
		if (nextEObject == diagram) {
			return new FileEditorInput(WorkspaceSynchronizer.getFile(diagramResource));
		}
		if (nextEObject instanceof Diagram) {
			break;
		}
	}
	URI uri = EcoreUtil.getURI(diagram);
	String editorName = uri.lastSegment() + '#' + diagram.eResource().getContents().indexOf(diagram);
	IEditorInput editorInput = new URIEditorInput(uri, editorName);
	return editorInput;
}
 
Example 3
Source File: CrossflowNavigatorLinkHelper.java    From scava with Eclipse Public License 2.0 6 votes vote down vote up
/**
* @generated
*/
public IStructuredSelection findSelection(IEditorInput anInput) {
	IDiagramDocument document = CrossflowDiagramEditorPlugin.getInstance().getDocumentProvider()
			.getDiagramDocument(anInput);
	if (document == null) {
		return StructuredSelection.EMPTY;
	}
	Diagram diagram = document.getDiagram();
	if (diagram == null || diagram.eResource() == null) {
		return StructuredSelection.EMPTY;
	}
	IFile file = WorkspaceSynchronizer.getFile(diagram.eResource());
	if (file != null) {
		CrossflowNavigatorItem item = new CrossflowNavigatorItem(diagram, file, false);
		return new StructuredSelection(item);
	}
	return StructuredSelection.EMPTY;
}
 
Example 4
Source File: CrossflowNavigatorActionProvider.java    From scava with Eclipse Public License 2.0 6 votes vote down vote up
/**
* @generated
*/
private static IEditorInput getEditorInput(Diagram diagram) {
	Resource diagramResource = diagram.eResource();
	for (EObject nextEObject : diagramResource.getContents()) {
		if (nextEObject == diagram) {
			return new FileEditorInput(WorkspaceSynchronizer.getFile(diagramResource));
		}
		if (nextEObject instanceof Diagram) {
			break;
		}
	}
	URI uri = EcoreUtil.getURI(diagram);
	String editorName = uri.lastSegment() + '#' + diagram.eResource().getContents().indexOf(diagram);
	IEditorInput editorInput = new URIEditorInput(uri, editorName);
	return editorInput;
}
 
Example 5
Source File: NavigatorLinkHelper.java    From statecharts with Eclipse Public License 1.0 6 votes vote down vote up
private static IEditorInput getEditorInput(Diagram diagram) {
	Resource diagramResource = diagram.eResource();
	for (Iterator<EObject> it = diagramResource.getContents().iterator(); it
			.hasNext();) {
		EObject nextEObject = (EObject) it.next();
		if (nextEObject == diagram) {
			return new FileEditorInput(
					WorkspaceSynchronizer.getFile(diagramResource));
		}
		if (nextEObject instanceof Diagram) {
			break;
		}
	}
	URI uri = EcoreUtil.getURI(diagram);
	String editorName = uri.lastSegment() + "#"
			+ diagram.eResource().getContents().indexOf(diagram);
	IEditorInput editorInput = new URIEditorInput(uri, editorName);
	return editorInput;
}
 
Example 6
Source File: ValidationMarkerProvider.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
public void clearMarkers(final Map<Diagram, DiagramEditPart> diagramsToDiagramEditPart) {
    final Iterator<Entry<Diagram, DiagramEditPart>> iterator = diagramsToDiagramEditPart.entrySet().iterator();
    while (iterator.hasNext()) {
        final Entry<Diagram, DiagramEditPart> entry = iterator.next();
        final Diagram d = entry.getKey();
        final DiagramEditPart de = entry.getValue();
        if (de != null) {
            final EObject resolvedSemanticElement = de.resolveSemanticElement();
            if (resolvedSemanticElement instanceof MainProcess) {
                final IFile target = d.eResource() != null ? WorkspaceSynchronizer.getFile(d.eResource()) : null;
                if (target != null) {
                    org.bonitasoft.studio.model.process.diagram.providers.ProcessMarkerNavigationProvider.deleteMarkers(target);
                    break;
                }
            }
        }
    }
}
 
Example 7
Source File: BatchValidationOperation.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
public IStatus getResult() {
    final MultiStatus result = new MultiStatus(ValidationCommonPlugin.PLUGIN_ID, IStatus.OK, "", null);
    fileProcessed.clear();
    for (final Diagram d : diagramsToDiagramEditPart.keySet()) {
        final EObject element = d.getElement();
        if (element != null) {
            final IFile target = d.eResource() != null ? WorkspaceSynchronizer.getFile(d.eResource()) : null;
            if (target != null && !fileProcessed.contains(target)) {
                try {
                    buildMultiStatus(target, result);
                } catch (final CoreException e) {
                    BonitaStudioLog.error(e);
                }
            }
        }
    }
    return result;
}
 
Example 8
Source File: ProcessDiagramEditor.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
/**
* @generated
*/
private ISelection getNavigatorSelection() {
	IDiagramDocument document = getDiagramDocument();
	if (document == null) {
		return StructuredSelection.EMPTY;
	}
	Diagram diagram = document.getDiagram();
	if (diagram == null || diagram.eResource() == null) {
		return StructuredSelection.EMPTY;
	}
	IFile file = WorkspaceSynchronizer.getFile(diagram.eResource());
	if (file != null) {
		ProcessNavigatorItem item = new ProcessNavigatorItem(diagram, file, false);
		return new StructuredSelection(item);
	}
	return StructuredSelection.EMPTY;
}
 
Example 9
Source File: ProcessNavigatorActionProvider.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
/**
* @generated
*/
private static IEditorInput getEditorInput(Diagram diagram) {
	Resource diagramResource = diagram.eResource();
	for (EObject nextEObject : diagramResource.getContents()) {
		if (nextEObject == diagram) {
			return new FileEditorInput(WorkspaceSynchronizer.getFile(diagramResource));
		}
		if (nextEObject instanceof Diagram) {
			break;
		}
	}
	URI uri = EcoreUtil.getURI(diagram);
	String editorName = uri.lastSegment() + '#' + diagram.eResource().getContents().indexOf(diagram);
	IEditorInput editorInput = new URIEditorInput(uri, editorName);
	return editorInput;
}
 
Example 10
Source File: ProcessNavigatorLinkHelper.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
/**
* @generated
*/
private static IEditorInput getEditorInput(Diagram diagram) {
	Resource diagramResource = diagram.eResource();
	for (EObject nextEObject : diagramResource.getContents()) {
		if (nextEObject == diagram) {
			return new FileEditorInput(WorkspaceSynchronizer.getFile(diagramResource));
		}
		if (nextEObject instanceof Diagram) {
			break;
		}
	}
	URI uri = EcoreUtil.getURI(diagram);
	String editorName = uri.lastSegment() + '#' + diagram.eResource().getContents().indexOf(diagram);
	IEditorInput editorInput = new URIEditorInput(uri, editorName);
	return editorInput;
}
 
Example 11
Source File: ProcessNavigatorLinkHelper.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
/**
* @generated
*/
public IStructuredSelection findSelection(IEditorInput anInput) {
	IDiagramDocument document = ProcessDiagramEditorPlugin.getInstance().getDocumentProvider()
			.getDiagramDocument(anInput);
	if (document == null) {
		return StructuredSelection.EMPTY;
	}
	Diagram diagram = document.getDiagram();
	if (diagram == null || diagram.eResource() == null) {
		return StructuredSelection.EMPTY;
	}
	IFile file = WorkspaceSynchronizer.getFile(diagram.eResource());
	if (file != null) {
		ProcessNavigatorItem item = new ProcessNavigatorItem(diagram, file, false);
		return new StructuredSelection(item);
	}
	return StructuredSelection.EMPTY;
}
 
Example 12
Source File: ExtendendResourceLinkHelper.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
@Override
public IStructuredSelection findSelection(IEditorInput anInput) {
    IDiagramDocument document = ProcessDiagramEditorPlugin.getInstance().getDocumentProvider()
            .getDiagramDocument(anInput);
    if (document == null) {
        return super.findSelection(anInput);
    }
    Diagram diagram = document.getDiagram();
    if (diagram == null || diagram.eResource() == null) {
        return StructuredSelection.EMPTY;
    }
    IFile file = WorkspaceSynchronizer.getFile(diagram.eResource());
    if (file != null) {
        return new StructuredSelection(file);
    }
    return StructuredSelection.EMPTY;
}
 
Example 13
Source File: BatchValidationOperation.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
protected DiagramEditPart createDiagramEditPart(final Diagram d) {
    if (d != null && d.eResource() != null) {
        DiagramEditPart offscreenDiagramEditPart = null;
        try {
            offscreenDiagramEditPart = offscreenEditPartFactory.createOffscreenDiagramEditPart(d);
        } catch (final Exception e) {
            //Need to call twice because sometimes for unknown reasons, the first time is not working
            offscreenDiagramEditPart = offscreenEditPartFactory.createOffscreenDiagramEditPart(d);
        }
        return offscreenDiagramEditPart;
    }
    return null;
}