/** * Save all dirty editors in the workbench that are open on files that may * be affected by this operation. Opens a dialog to prompt the user if * <code>confirm</code> is true. Return true if successful. Return false * if the user has canceled the command. Must be called from the UI thread. * @param resources the root resources being operated on * @param confirm prompt the user if true * @return boolean false if the operation was canceled. */ public final boolean saveAllEditors(IResource[] resources, boolean confirm) { return IDE.saveAllEditors(resources, confirm); }
@Override public boolean selectReveal(Object object) { if (object instanceof IMarker) { IDE.gotoMarker(this, (IMarker) object); return true; } return false; }
@Override public String getLabel(Object o) { return ((FileStoreEditorInput) o).getName(); }
private IEditorPart showWithoutReuse(IFile file, IWorkbenchPage wbPage, String editorID, boolean activate) throws PartInitException { return IDE.openEditor(wbPage, file, editorID, activate); }
/** * Return whether the given dirty editor part is editing resources that are * descendants of the given roots. * * @param part the dirty editor part * @return whether the given dirty editor part is editing resources that are * descendants of the given roots */ private boolean isEditingDescendantOf(IEditorPart part) { IFile file = ResourceUtil.getFile(part.getEditorInput()); if (file != null) { return isDescendantOfRoots(file); } return false; }
@Override public IStructuredSelection findSelection(IEditorInput anInput) { IFile file = ResourceUtil.getFile(anInput); if (file != null) { return new StructuredSelection(file); } return StructuredSelection.EMPTY; }
/** * Returns the resolutions for the given marker. * * @param marker the marker for which to obtain resolutions * @return the resolutions for the selected marker */ private IMarkerResolution[] getResolutions(IMarker marker) { return IDE.getMarkerHelpRegistry().getResolutions(marker); }
/** * Applies the <code>org.eclipse.ui.ide.editorAssociationOverride</code> extensions to the given * input. * * @param fileName the name of the file for which to choose the editor * @param contentType the content type of the input or <code>null</code> if not available * @param editorDescriptors the current association for the given input * @return the editor descriptors to be used for the given input - can be * <code>editorDescriptors</code>. The order is not relevant. * @see IEditorAssociationOverride#overrideEditors(IEditorInput, IContentType, * IEditorDescriptor[]) * @since 3.8 */ public static IEditorDescriptor[] overrideEditorAssociations(String fileName, IContentType contentType, IEditorDescriptor[] editorDescriptors) { IEditorAssociationOverride[] overrides = getEditorAssociationOverrides(); for (int i = 0; i < overrides.length; i++) { editorDescriptors = overrides[i].overrideEditors(fileName, contentType, editorDescriptors); } return removeNullEntries(editorDescriptors); }
@Override public boolean select(Saveable saveable, IWorkbenchPart[] containingParts) { if (isDescendantOfRoots(saveable)) { return true; } // For backwards compatibility, we need to check the parts for (int i = 0; i < containingParts.length; i++) { IWorkbenchPart workbenchPart = containingParts[i]; if (workbenchPart instanceof IEditorPart) { IEditorPart editorPart = (IEditorPart) workbenchPart; if (isEditingDescendantOf(editorPart)) { return true; } } } return false; }
/** * Applies the <code>org.eclipse.ui.ide.editorAssociationOverride</code> extensions to the given * input. * * @param fileName the name of the file for which to choose the editor * @param contentType the content type of the input or <code>null</code> if not available * @param editorDescriptor the current association for the given input or <code>null</code> if * none * @return the editor descriptor to be used for the given input or <code>null</code> if none. * Can be <code>editorDescriptor</code>. * @see IEditorAssociationOverride#overrideDefaultEditor(String, IContentType, * IEditorDescriptor) * @since 3.8 */ private static IEditorDescriptor overrideDefaultEditorAssociation(String fileName, IContentType contentType, IEditorDescriptor editorDescriptor) { IEditorAssociationOverride[] overrides = getEditorAssociationOverrides(); for (int i = 0; i < overrides.length; i++) { editorDescriptor = overrides[i].overrideDefaultEditor(fileName, contentType, editorDescriptor); } return editorDescriptor; }
@Override public void saveState(IMemento memento) { FileStoreEditorInputFactory.saveState(memento, this); }
/** * Tries to extra a single file from the given resource mapping. * Returns the file if the mapping maps to a single file, or <code>null</code> * if it maps to zero or multiple files. * * @param mapping the resource mapping * @return the file, or <code>null</code> */ private static IFile getFileFromResourceMapping(ResourceMapping mapping) { IResource resource = getResourceFromResourceMapping(mapping); if (resource instanceof IFile) { return (IFile) resource; } return null; }
private IEditorPart showWithoutReuse(IFile file, IWorkbenchPage wbPage, boolean activate) throws PartInitException { return IDE.openEditor(wbPage, file, activate); }
public void run() { IDE.gotoMarker(editor, selectedMarker); } };
/** * Performs the save of the editor parts returned by getScopedResources */ protected void doSave() { if(fSaves != null) { IDE.saveAllEditors(fSaves, false); } }
/** * Applies the <code>org.eclipse.ui.ide.editorAssociationOverride</code> extensions to the given * input. * * @param editorInput the editor input for the editor * @param contentType the content type of the input or <code>null</code> if not available * @param editorDescriptors the current association for the given input * @return the editor descriptors to be used for the given input - can be * <code>editorDescriptors</code>. The order is not relevant. * @see IEditorAssociationOverride#overrideEditors(IEditorInput, IContentType, * IEditorDescriptor[]) * @since 3.8 */ public static IEditorDescriptor[] overrideEditorAssociations(IEditorInput editorInput, IContentType contentType, IEditorDescriptor[] editorDescriptors) { IEditorAssociationOverride[] overrides = getEditorAssociationOverrides(); for (int i = 0; i < overrides.length; i++) { editorDescriptors = overrides[i].overrideEditors(editorInput, contentType, editorDescriptors); } return removeNullEntries(editorDescriptors); }
public void gotoMarker(IMarker marker) { setActivePage(SOURCE_PAGE_INDEX); IDE.gotoMarker(structuredTextEditor, marker); }
/** * Save all dirty editors in the workbench that are open on files that may * be affected by this operation. Opens a dialog to prompt the user if * <code>confirm</code> is true. Return true if successful. Return false * if the user has canceled the command. Must be called from the UI thread. * @param resources the root resources being operated on * @param confirm prompt the user if true * @return boolean false if the operation was canceled. */ public final boolean saveAllEditors(IResource[] resources, boolean confirm) { return IDE.saveAllEditors(resources, confirm); }
/** * Save all dirty editors in the workbench that are open on files that may * be affected by this operation. Opens a dialog to prompt the user if * <code>confirm</code> is true. Return true if successful. Return false * if the user has canceled the command. Must be called from the UI thread. * @param resources the root resources being operated on * @param confirm prompt the user if true * @return boolean false if the operation was canceled. */ public final boolean saveAllEditors(IResource[] resources, boolean confirm) { return IDE.saveAllEditors(resources, confirm); }
/** * Save all dirty editors in the workbench that are open on files that may * be affected by this operation. Opens a dialog to prompt the user if * <code>confirm</code> is true. Return true if successful. Return false * if the user has canceled the command. Must be called from the UI thread. * @param resources the root resources being operated on * @param confirm prompt the user if true * @return boolean false if the operation was canceled. */ public final boolean saveAllEditors(IResource[] resources, boolean confirm) { return IDE.saveAllEditors(resources, confirm); }