use of org.eclipse.emf.common.ui.URIEditorInput in project statecharts by Yakindu.
the class NavigatorLinkHelper method getEditorInput.
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;
}
use of org.eclipse.emf.common.ui.URIEditorInput in project statecharts by Yakindu.
the class ActiveEditorTracker method getLastActiveEditorProject.
/**
* @return The project which contains the file that is open in the last
* active editor in the current workbench page.
*/
public static IProject getLastActiveEditorProject() {
final IEditorPart editor = getLastActiveEditor();
if (editor == null)
return null;
final IEditorInput editorInput = editor.getEditorInput();
if (editorInput instanceof IFileEditorInput) {
final IFileEditorInput input = (IFileEditorInput) editorInput;
return input.getFile().getProject();
} else if (editorInput instanceof URIEditorInput) {
final URI uri = ((URIEditorInput) editorInput).getURI();
if (uri.isPlatformResource()) {
final String platformString = uri.toPlatformString(true);
return ResourcesPlugin.getWorkspace().getRoot().findMember(platformString).getProject();
}
}
return null;
}
use of org.eclipse.emf.common.ui.URIEditorInput in project statecharts by Yakindu.
the class ResourceUnloadingTool method getDiagramResource.
private static Resource getDiagramResource(ResourceSet resourceSet, IEditorInput editorInput) {
Resource diagramResource = null;
if (editorInput instanceof URIEditorInput) {
final URI resourceURI = ((URIEditorInput) editorInput).getURI().trimFragment();
diagramResource = resourceSet.getResource(resourceURI, false);
} else if (editorInput instanceof IDiagramEditorInput) {
final Diagram diagram = ((IDiagramEditorInput) editorInput).getDiagram();
diagramResource = diagram.eResource();
} else if (editorInput instanceof IFileEditorInput) {
final URI resourceURI = URI.createPlatformResourceURI(((IFileEditorInput) editorInput).getFile().getFullPath().toString(), true);
diagramResource = resourceSet.getResource(resourceURI, false);
}
return diagramResource;
}
Aggregations