use of org.eclipse.gmf.runtime.diagram.ui.parts.IDiagramEditorInput in project statecharts by Yakindu.
the class DiagramPartitioningEditor method closeSubdiagramEditors.
protected void closeSubdiagramEditors() {
if (getDiagram() != null && getDiagram().getElement() instanceof Statechart) {
List<IEditorReference> refsToClose = new ArrayList<IEditorReference>();
IWorkbenchWindow workbenchWindow = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
if (workbenchWindow == null)
return;
IWorkbenchPage activePage = workbenchWindow.getActivePage();
if (activePage == null)
return;
IEditorReference[] refs = activePage.getEditorReferences();
for (IEditorReference ref : refs) {
try {
if (ref.getEditorInput() instanceof IDiagramEditorInput) {
IDiagramEditorInput diagramInput = (IDiagramEditorInput) ref.getEditorInput();
if (diagramInput.getDiagram().eResource() == getDiagram().eResource()) {
refsToClose.add(ref);
}
}
} catch (PartInitException e) {
e.printStackTrace();
}
}
if (refsToClose.size() > 0) {
boolean close = MessageDialog.openQuestion(activePage.getActivePart().getSite().getShell(), "Close subdiagram editors?", "There are still subdiagram editors open. Do you want to close them?");
if (close) {
for (IEditorReference ref : refsToClose) {
activePage.closeEditor(ref.getEditor(false), false);
}
}
}
}
}
use of org.eclipse.gmf.runtime.diagram.ui.parts.IDiagramEditorInput in project statecharts by Yakindu.
the class DiagramPartitioningDocumentProvider method createElementInfo.
@Override
protected ElementInfo createElementInfo(Object element) throws CoreException {
ElementInfo info = super.createElementInfo(element);
if (element instanceof IDiagramEditorInput) {
Resource eResource = ((IDiagramEditorInput) element).getDiagram().eResource();
TransactionalEditingDomain sharedDomain = DiagramPartitioningUtil.getSharedDomain();
if (eResource.isLoaded() && !sharedDomain.isReadOnly(eResource) && eResource.isModified()) {
info.fCanBeSaved = true;
}
}
return info;
}
use of org.eclipse.gmf.runtime.diagram.ui.parts.IDiagramEditorInput in project statecharts by Yakindu.
the class DiagramPartitioningDocumentProvider method setDocumentContent.
@Override
protected boolean setDocumentContent(IDocument document, IEditorInput editorInput) throws CoreException {
if (editorInput instanceof IDiagramEditorInput) {
Diagram diagram = ((IDiagramEditorInput) editorInput).getDiagram();
document.setContent(diagram);
return true;
} else if (editorInput instanceof FileEditorInputProxy) {
setDocumentContentFromStorage(document, ((FileEditorInputProxy) editorInput).getFile());
return true;
}
return super.setDocumentContent(document, editorInput);
}
use of org.eclipse.gmf.runtime.diagram.ui.parts.IDiagramEditorInput in project statecharts by Yakindu.
the class DiagramPartitioningUtil method closeSubdiagramEditors.
/**
* Forces the user to close all opened editors for subdiagrams that are inlined.
*
* @return true if all editors were closed, false otherwise
*/
public static boolean closeSubdiagramEditors(State state) {
Diagram diagram = DiagramPartitioningUtil.getSubDiagram(state);
if (diagram == null)
return true;
IWorkbenchPage activePage = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
IEditorReference[] refs = activePage.getEditorReferences();
for (IEditorReference ref : refs) {
try {
if (ref.getEditorInput() instanceof IDiagramEditorInput) {
IDiagramEditorInput diagramInput = (IDiagramEditorInput) ref.getEditorInput();
if (diagramInput.getDiagram().equals(diagram)) {
boolean close = MessageDialog.openQuestion(activePage.getActivePart().getSite().getShell(), "Close subdiagram editor?", "The subdiagram is still open in another editor. Do you want to close it?");
if (close) {
activePage.closeEditor(ref.getEditor(false), false);
}
return close;
}
}
} catch (PartInitException e) {
e.printStackTrace();
}
}
return true;
}
use of org.eclipse.gmf.runtime.diagram.ui.parts.IDiagramEditorInput 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