@Override public boolean equals(Object obj) { try { return (obj == this || obj != null && (obj instanceof IStorageEditorInput) && storage.equals(((IStorageEditorInput)obj).getStorage())); } catch (CoreException e) { return false; } }
/** * Returns the persisted encoding for the given element. * * @param element the element for which to get the persisted encoding * @return the persisted encoding * @since 2.1 */ protected String getPersistedEncoding(Object element) { if (element instanceof IStorageEditorInput) { IStorage storage; try { storage= ((IStorageEditorInput)element).getStorage(); if (storage instanceof IEncodedStorage) return ((IEncodedStorage)storage).getCharset(); } catch (CoreException e) { return null; } } return null; }
public String text(IStorageEditorInput editorInput) { try { return editorInput.getStorage().getFullPath().lastSegment(); } catch (CoreException e) { LOG.error("Error resolving IStorage from IStorageEditorInput", e); } return null; }
protected URI getResourceURI(XtextEditor editor) { IEditorInput editorInput = editor.getEditorInput(); if (editorInput instanceof IStorageEditorInput) { try { return storage2UriMapper.getUri(((IStorageEditorInput) editorInput).getStorage()); } catch (CoreException e) { LOG.error("Error getting URI for storage", e); } } return null; }
private Object getInputFromEditor(IEditorInput editorInput) { Object input= JavaUI.getEditorInputJavaElement(editorInput); if (input == null) { input= editorInput.getAdapter(IFile.class); } if (input == null && editorInput instanceof IStorageEditorInput) { try { input= ((IStorageEditorInput) editorInput).getStorage(); } catch (CoreException e) { // ignore } } return input; }
private Properties loadContent() { IStorageEditorInput input = (IStorageEditorInput) getEditorInput(); Properties properties = new Properties(); try { IStorage storage = input.getStorage(); try (InputStream is = storage.getContents()) { properties.load(is); } catch (IOException e) { PDEPlugin.logException(e); } } catch (CoreException e) { PDEPlugin.logException(e); } return properties; }
public Object getAdapter(Object element, Class key) { updateLazyLoadedAdapters(); if (fSearchPageScoreComputer != null && ISearchPageScoreComputer.class.equals(key)) return fSearchPageScoreComputer; if (IJavaElement.class.equals(key) && element instanceof IEditorInput) { IJavaElement je= JavaUI.getWorkingCopyManager().getWorkingCopy((IEditorInput)element); if (je != null) return je; if (element instanceof IStorageEditorInput) { try { return ((IStorageEditorInput)element).getStorage().getAdapter(key); } catch (CoreException ex) { // Fall through } } } return null; }
private IBaseModel createStorageModel(IStorageEditorInput input) { try { IStorage storage = input.getStorage(); StorageSchemaDescriptor sd = new StorageSchemaDescriptor(storage); ISchema schema = sd.getSchema(false); return schema; } catch (CoreException e) { PDEPlugin.logException(e); return null; } }
private Object getInputFromEditor(IEditorInput editorInput) { Object input= editorInput.getAdapter(IFile.class); if (input == null && editorInput instanceof FileRevisionEditorInput) { IFileRevision fileRevision = ((FileRevisionEditorInput)editorInput).getFileRevision(); if (fileRevision instanceof ResourceVariantFileRevision) return ((ResourceVariantFileRevision) fileRevision).getVariant(); } if (input == null && editorInput instanceof IStorageEditorInput) { try { input= ((IStorageEditorInput) editorInput).getStorage(); } catch (CoreException e) { // ignore } } return input; }
private IPath getEditorInputPath() { if (getEditor() == null) return null; IEditorInput input= getEditor().getEditorInput(); if (input instanceof IStorageEditorInput) { try { return ((IStorageEditorInput)input).getStorage().getFullPath(); } catch (CoreException ex) { JavaPlugin.log(ex.getStatus()); } } return null; }
/** * Updates the internal cache for the given input. * * @param input the input whose cache will be updated * @throws CoreException if the storage cannot be retrieved from the input * @since 2.0 */ protected void updateCache(IStorageEditorInput input) throws CoreException { StorageInfo info= (StorageInfo) getElementInfo(input); if (info != null) { try { IStorage storage= input.getStorage(); if (storage != null) { boolean readOnly= storage.isReadOnly(); info.fIsReadOnly= readOnly; info.fIsModifiable= !readOnly; } } catch (CoreException x) { handleCoreException(x, TextEditorMessages.StorageDocumentProvider_updateCache); } info.fUpdateCache= false; } }
private IPath getEditorInputPath() { if (getEditor() == null) return null; IEditorInput input= getEditor().getEditorInput(); if (input instanceof IStorageEditorInput) { try { return ((IStorageEditorInput)input).getStorage().getFullPath(); } catch (CoreException ex) { JavaPlugin.log(ex.getStatus()); } } return null; }
private IPath getEditorInputPath() { if (getEditor() == null) return null; IEditorInput input= getEditor().getEditorInput(); if (input instanceof IStorageEditorInput) { try { return ((IStorageEditorInput)input).getStorage().getFullPath(); } catch (CoreException ex) { JavaPlugin.log(ex.getStatus()); } } return null; }
@Override @SuppressWarnings("unchecked") public <T> T getAdapter(Object element, Class<T> key) { updateLazyLoadedAdapters(); if (fSearchPageScoreComputer != null && ISearchPageScoreComputer.class.equals(key) && element instanceof IEditorInput && JavaUI.getEditorInputJavaElement((IEditorInput)element) != null) return (T) fSearchPageScoreComputer; if (IJavaElement.class.equals(key) && element instanceof IEditorInput) { IJavaElement je= JavaUI.getWorkingCopyManager().getWorkingCopy((IEditorInput)element); if (je != null) return (T) je; if (element instanceof IStorageEditorInput) { try { return ((IStorageEditorInput)element).getStorage().getAdapter(key); } catch (CoreException ex) { // Fall through } } } return null; }
public IResource getBreakpointResource(IEditorInput input) throws CoreException { Object adapter = input.getAdapter(IResource.class); if (adapter != null) return (IResource) adapter; if (input instanceof IStorageEditorInput) { IStorage storage = ((IStorageEditorInput) input).getStorage(); if (storage instanceof IResource) return (IResource) storage; if (storage instanceof IJarEntryResource) { IResource underlyingResource = ((IJarEntryResource) storage).getPackageFragmentRoot().getUnderlyingResource(); if (underlyingResource != null) return underlyingResource; } } else if (input instanceof IClassFileEditorInput) { IClassFile classFile = ((IClassFileEditorInput) input).getClassFile(); return getBreakpointResource(classFile.findPrimaryType()); } return ResourcesPlugin.getWorkspace().getRoot(); }
private static boolean isEclipseNLSAvailable(IStorageEditorInput editorInput) { IStorage storage; try { storage= editorInput.getStorage(); } catch (CoreException ex) { return false; } if (!(storage instanceof IJarEntryResource)) return false; IJavaProject javaProject= ((IJarEntryResource) storage).getPackageFragmentRoot().getJavaProject(); if (javaProject == null || !javaProject.exists()) return false; try { return javaProject.findType("org.eclipse.osgi.util.NLS") != null; //$NON-NLS-1$ } catch (JavaModelException e) { return false; } }
private static boolean isEclipseNLSAvailable(IStorageEditorInput editorInput) { IStorage storage; try { storage= editorInput.getStorage(); } catch (CoreException ex) { return false; } if (!(storage instanceof IJarEntryResource)) return false; IJavaProject javaProject= ((IJarEntryResource) storage).getPackageFragmentRoot().getJavaProject(); if (javaProject == null || !javaProject.exists()) return false; try { return javaProject.findType("org.eclipse.osgi.util.NLS") != null; //$NON-NLS-1$ } catch (JavaModelException e) { return false; } }
@Override protected IBaseModel createModel(IEditorInput input) throws CoreException { IBaseModel model = null; InputStream is = null; if (input instanceof IFileEditorInput) { IFile file = ((IFileEditorInput) input).getFile(); is = new BufferedInputStream(file.getContents()); model = createWorkspaceModel(file, is, true); } else if (input instanceof IStorageEditorInput) { is = new BufferedInputStream(((IStorageEditorInput) input).getStorage().getContents()); model = createStorageModel(is); } else if (input instanceof IURIEditorInput) { IFileStore store = EFS.getStore(((IURIEditorInput) input).getURI()); is = store.openInputStream(EFS.CACHE, new NullProgressMonitor()); model = createStorageModel(is); } return model; }
private Object getInputFromEditor(IEditorInput editorInput) { Object input= JavaUI.getEditorInputJavaElement(editorInput); if (input instanceof ICompilationUnit) { ICompilationUnit cu= (ICompilationUnit) input; if (!cu.getJavaProject().isOnClasspath(cu)) { // test needed for Java files in non-source folders (bug 207839) input= cu.getResource(); } } if (input == null) { input= editorInput.getAdapter(IFile.class); } if (input == null && editorInput instanceof IStorageEditorInput) { try { input= ((IStorageEditorInput) editorInput).getStorage(); } catch (CoreException e) { // ignore } } return input; }
@Override public String getEncoding(Object element) { String encoding = super.getEncoding(element); if (encoding == null && element instanceof IStorageEditorInput) { try { IStorage storage = ((IStorageEditorInput) element).getStorage(); URI uri = storage2UriMapper.getUri(storage); if (uri != null) { encoding = encodingProvider.getEncoding(uri); } else if (storage instanceof IEncodedStorage) { encoding = ((IEncodedStorage)storage).getCharset(); } } catch (CoreException e) { throw new WrappedException(e); } } return encoding; }