public void run() { IEditorPart part = getPage().findEditor(SaveableCompareEditorInput.this); getPage().closeEditor(part, false); } };
public void run() { getEditorSite().getPage().closeEditor(ServerEditor.this, false); } });
@Override public void run() { if (fSourceViewer != null) getSite().getPage().closeEditor(AbstractTextEditor.this, save); } });
@Override public void run() { if (toolkit != null) { getSite().getPage().closeEditor(FormEditor.this, save); } } });
private void closeEditor() { getSite().getPage().closeEditor(CompareEditor.this, false); }
private void closeEditor() { getSite().getPage().closeEditor(CompareEditor.this, false); }
public void close() { Display display = getSite().getShell().getDisplay(); display.asyncExec(() -> { if (toolkit != null) { getSite().getPage().closeEditor(SampleEditor.this, false); } }); } }
/** * Closes the editor programmatically. * * @param save * if <code>true</code>, the content should be saved before * closing. */ public void close(final boolean save) { Display display = getSite().getShell().getDisplay(); display.asyncExec(() -> { if (toolkit != null) { getSite().getPage().closeEditor(FormEditor.this, save); } }); }
@Override public void close(final boolean save) { enableSanityChecking(false); Display display= getSite().getShell().getDisplay(); display.asyncExec(() -> { if (fSourceViewer != null) getSite().getPage().closeEditor(AbstractTextEditor.this, save); }); }
@Override public Object execute(ExecutionEvent event) throws ExecutionException { IWorkbenchWindow window = HandlerUtil .getActiveWorkbenchWindowChecked(event); IEditorPart part = HandlerUtil.getActiveEditorChecked(event); window.getActivePage().closeEditor(part, true); return null; }
private static void closeEditorForFile(IFile file) { IWorkbenchPage page = JavaPlugin.getActivePage(); if (page != null) { IEditorPart part = page.findEditor(new FileEditorInput(file)); if (part != null) if (!page.closeEditor(part, true)) //in case user cancels closeEditor, we should not // remove unit from model //TODO: maybe throw exception (?) return; } } }
public static IEditorPart openEditor(IWorkbenchPage page, FileRevisionEditorInput editorInput) throws PartInitException { String id = getEditorId(editorInput); try { IEditorPart part = page.openEditor(editorInput, id); if (part instanceof ErrorEditorPart) { page.closeEditor(part, false); part = null; } if (part == null) { throw new PartInitException(NLS.bind(TeamUIMessages.Utils_17, id)); } return part; } catch (PartInitException e) { if (id.equals("org.eclipse.ui.DefaultTextEditor")) { //$NON-NLS-1$ throw e; } else { return page.openEditor(editorInput,"org.eclipse.ui.DefaultTextEditor"); //$NON-NLS-1$ } } }
/** * Closes this editor. */ protected void closeEditor() { final IEditorPart editor = this; DebugUIPlugin.getStandardDisplay().syncExec(() -> { IWorkbenchWindow activeWorkbenchWindow = DebugUIPlugin.getActiveWorkbenchWindow(); if (activeWorkbenchWindow != null) { IWorkbenchPage activePage = activeWorkbenchWindow.getActivePage(); if (activePage != null) { activePage.closeEditor(editor, false); } } }); }
@Override public Object execute(ExecutionEvent event) throws ExecutionException { IWorkbenchPart part = HandlerUtil.getActivePartChecked(event); IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindowChecked(event); if (part instanceof IEditorPart) { window.getActivePage().closeEditor((IEditorPart) part, true); } else if (part instanceof IViewPart) { window.getActivePage().hideView((IViewPart) part); } return null; } }
void close() { // 3.x implementation closes the editor when the ISL is disposed PartSite partSite = (PartSite) getSite(); MPart model = partSite.getModel(); Widget widget = (Widget) model.getWidget(); if (widget != null && !widget.isDisposed()) { getSite().getPage().closeEditor(MultiPageEditorPart.this, true); } }
public void run() { IWorkbenchPage[] pages = getSite().getWorkbenchWindow() .getPages(); for (int i = 0; i < pages.length; i++) { if (((FileEditorInput) editor.getEditorInput()) .getFile().getProject().equals( event.getResource())) { IEditorPart editorPart = pages[i].findEditor(editor .getEditorInput()); pages[i].closeEditor(editorPart, true); } } } });
private ITextEditor openNewTextEditor(IFile file, IWorkbenchPage activePage) throws PartInitException { IEditorDescriptor desc= IDE.getDefaultEditor(file); if (desc != null) { String editorID= desc.getId(); IEditorPart editor; if (desc.isInternal()) { editor= activePage.openEditor(new FileEditorInput(file), editorID); if (editor instanceof ITextEditor) { if (editor instanceof IReusableEditor) fEditor= (IReusableEditor) editor; return (ITextEditor)editor; } activePage.closeEditor(editor, false); } } IEditorPart editor= activePage.openEditor(new FileEditorInput(file), "org.eclipse.ui.DefaultTextEditor"); //$NON-NLS-1$ return (ITextEditor)editor; }
private static ITextEditor getEditor(String id, Object fileRevision, IStorage storage) throws PartInitException { final IWorkbench workbench= PlatformUI.getWorkbench(); final IWorkbenchWindow window= workbench.getActiveWorkbenchWindow(); IWorkbenchPage page= window.getActivePage(); IEditorPart part = page.openEditor(new FileRevisionEditorInput(fileRevision, storage), id); if (part instanceof ITextEditor) { return (ITextEditor)part; } else { // We asked for a text editor but didn't get one // so open a vanilla text editor page.closeEditor(part, false); part = page.openEditor(new FileRevisionEditorInput(fileRevision, storage), EditorsUI.DEFAULT_TEXT_EDITOR_ID); if (part instanceof ITextEditor) { return (ITextEditor)part; } else { // There is something really wrong so just bail throw new PartInitException(TeamUIMessages.RevisionAnnotationController_0); } } }
private static ITextEditor getEditor(String id, Object fileRevision, IStorage storage) throws PartInitException { final IWorkbench workbench= PlatformUI.getWorkbench(); final IWorkbenchWindow window= workbench.getActiveWorkbenchWindow(); IWorkbenchPage page= window.getActivePage(); IEditorPart part = page.openEditor(new FileRevisionEditorInput(fileRevision, storage), id); if (part instanceof ITextEditor) { return (ITextEditor)part; } else { // We asked for a text editor but didn't get one // so open a vanilla text editor page.closeEditor(part, false); part = page.openEditor(new FileRevisionEditorInput(fileRevision, storage), EditorsUI.DEFAULT_TEXT_EDITOR_ID); if (part instanceof ITextEditor) { return (ITextEditor)part; } else { // There is something really wrong so just bail throw new PartInitException(TeamUIMessages.RevisionAnnotationController_0); } } }
public void run() { IWorkbenchPage[] pages = getSite().getWorkbenchWindow() .getPages(); for (int i = 0; i < pages.length; i++) { if (((FileEditorInput) editor.getEditorInput()) .getFile().getProject().equals( event.getResource())) { IEditorPart editorPart = pages[i].findEditor(editor .getEditorInput()); pages[i].closeEditor(editorPart, true); } } } });