@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; } }
@Override protected void createStorageContexts(InputContextManager manager, IStorageEditorInput input) { String name = input.getName().toLowerCase(Locale.ENGLISH); if (name.startsWith("site.xml")) { //$NON-NLS-1$ manager.putContext(input, new SiteInputContext(this, input, true)); } }
/** * 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; }
@Override protected void createStorageContexts(InputContextManager manager, IStorageEditorInput input) { if (input.getName().endsWith(".product")) { //$NON-NLS-1$ manager.putContext(input, new ProductInputContext(this, input, true)); } }
/** * 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; }
@Override protected void createStorageContexts(InputContextManager manager, IStorageEditorInput input) { String name = input.getName().toLowerCase(Locale.ENGLISH); if (name.equals(ICoreConstants.BUILD_FILENAME_DESCRIPTOR)) { manager.putContext(input, new BuildInputContext(this, input, true)); } else if (name.startsWith(ICoreConstants.FEATURE_FILENAME_DESCRIPTOR)) { manager.putContext(input, new FeatureInputContext(this, input, true)); } }
public String text(IStorageEditorInput editorInput) { try { return editorInput.getStorage().getFullPath().lastSegment(); } catch (CoreException e) { LOG.error("Error resolving IStorage from IStorageEditorInput", e); } return null; }
@Override protected void createStorageContexts(InputContextManager manager, IStorageEditorInput input) { if (input instanceof JarEntryEditorInput) { createJarEntryContexts(manager, (JarEntryEditorInput) input); return; } String name = input.getName().toLowerCase(Locale.ENGLISH); if (name.startsWith(ICoreConstants.MANIFEST_FILENAME_LOWER_CASE)) { manager.putContext(input, new BundleInputContext(this, input, true)); } else if (name.startsWith(ICoreConstants.BUILD_FILENAME_DESCRIPTOR)) { manager.putContext(input, new BuildInputContext(this, input, true)); } else if (name.startsWith(ICoreConstants.PLUGIN_FILENAME_DESCRIPTOR)) { manager.putContext(input, new PluginInputContext(this, input, true, false)); } else if (name.startsWith(ICoreConstants.FRAGMENT_FILENAME_DESCRIPTOR)) { manager.putContext(input, new PluginInputContext(this, input, true, true)); } }
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; }
/** * Creates a new properties key hyperlink. * * @param region the region * @param key the properties key * @param editor the text editor */ public PropertyKeyHyperlink(IRegion region, String key, ITextEditor editor) { Assert.isNotNull(region); Assert.isNotNull(key); Assert.isNotNull(editor); fRegion= region; fPropertiesKey= key; fEditor= editor; IStorageEditorInput storageEditorInput= (IStorageEditorInput)fEditor.getEditorInput(); fShell= fEditor.getEditorSite().getShell(); try { fStorage= storageEditorInput.getStorage(); } catch (CoreException e) { fStorage= null; } }
/** * Initializes the given document from the given editor input using the given character encoding. * * @param document the document to be initialized * @param editorInput the input from which to derive the content of the document * @param encoding the character encoding used to read the editor input * @return <code>true</code> if the document content could be set, <code>false</code> otherwise * @throws CoreException if the given editor input cannot be accessed * @since 2.0 */ protected boolean setDocumentContent(IDocument document, IEditorInput editorInput, String encoding) throws CoreException { if (editorInput instanceof IStorageEditorInput) { IStorage storage= ((IStorageEditorInput) editorInput).getStorage(); InputStream stream= storage.getContents(); try { setDocumentContent(document, stream, encoding); } finally { try { stream.close(); } catch (IOException x) { } } return true; } return false; }
/** * Initializes the given document from the given editor input using the given character encoding. * * @param document the document to be initialized * @param editorInput the input from which to derive the content of the document * @param encoding the character encoding used to read the editor input * @return <code>true</code> if the document content could be set, <code>false</code> otherwise * @throws CoreException if the given editor input cannot be accessed * @since 2.0 */ protected boolean setDocumentContent(IDocument document, IEditorInput editorInput, String encoding) throws CoreException { if (editorInput instanceof IStorageEditorInput) { IStorage storage= ((IStorageEditorInput) editorInput).getStorage(); InputStream stream= storage.getContents(); try { setDocumentContent(document, stream, encoding); } finally { try { stream.close(); } catch (IOException x) { } } return true; } return false; }
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; }
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; } }
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; }
/** * Creates a new properties key hyperlink. * * @param region the region * @param key the properties key * @param editor the text editor */ public PropertyKeyHyperlink(IRegion region, String key, ITextEditor editor) { Assert.isNotNull(region); Assert.isNotNull(key); Assert.isNotNull(editor); fRegion= region; fPropertiesKey= key; fEditor= editor; fIsFileEditorInput= fEditor.getEditorInput() instanceof IFileEditorInput; IStorageEditorInput storageEditorInput= (IStorageEditorInput)fEditor.getEditorInput(); fShell= fEditor.getEditorSite().getShell(); try { fStorage= storageEditorInput.getStorage(); } catch (CoreException e) { fStorage= null; } }
/** * Creates a new properties key hyperlink. * * @param region the region * @param key the properties key * @param editor the text editor */ public PropertyKeyHyperlink(IRegion region, String key, ITextEditor editor) { Assert.isNotNull(region); Assert.isNotNull(key); Assert.isNotNull(editor); fRegion= region; fPropertiesKey= key; fEditor= editor; fIsFileEditorInput= fEditor.getEditorInput() instanceof IFileEditorInput; IStorageEditorInput storageEditorInput= (IStorageEditorInput)fEditor.getEditorInput(); fShell= fEditor.getEditorSite().getShell(); try { fStorage= storageEditorInput.getStorage(); } catch (CoreException e) { fStorage= 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; }