/** * Disonnect the CompilationUnitDocumentProvider from the * * @input and disconnect the annotation model from the provider from the IDocument of the * @input. */ protected void disconnect(IEditorInput input) { IDocument doc = cuDocumentProvider.getDocument(input); cuDocumentProvider.getAnnotationModel(input).disconnect(doc); javaWorkingCopyManager.disconnect(input); }
public void connect(IEditorInput input) throws CoreException { fDocumentProvider.connect(input); }
public void disconnect(IEditorInput input) { fDocumentProvider.disconnect(input); }
protected void revert(IEditorInput input) { try { cuDocumentProvider.resetDocument(input); } catch (CoreException e) { Logger.getLogger().logError(e); } IDocument doc = cuDocumentProvider.getDocument(input); IAnnotationModel model = cuDocumentProvider.getAnnotationModel(input); if (model instanceof AbstractMarkerAnnotationModel) { AbstractMarkerAnnotationModel markerModel = (AbstractMarkerAnnotationModel) model; markerModel.resetMarkers(); } model.disconnect(doc); javaWorkingCopyManager.disconnect(input); }
@Override public void setWorkingCopy(IEditorInput input, ICompilationUnit workingCopy) { if (fDocumentProvider.getDocument(input) != null) { if (fMap == null) fMap= new HashMap<>(); fMap.put(input, workingCopy); } }
private IAnnotationModel isInJavaAnnotationModel(ICompilationUnit original) { if (original.isWorkingCopy()) { FileEditorInput editorInput= new FileEditorInput((IFile) original.getResource()); return JavaPlugin.getDefault().getCompilationUnitDocumentProvider().getAnnotationModel(editorInput); } return null; }
protected void saveDocument(IEditorInput input, IProgressMonitor monitor) { IDocument doc = cuDocumentProvider.getDocument(input); boolean canSave = cuDocumentProvider.canSaveDocument(input); try { if (canSave) { ICompilationUnit unit = javaWorkingCopyManager.getWorkingCopy(input); synchronized (unit) { cuDocumentProvider.aboutToChange(input); primSaveDocument(input, doc, monitor); } } } catch (CoreException e) { WTPCommonPlugin.getDefault().getLogger().logError(e); throw new SaveFailedException(e); } finally { if (canSave) cuDocumentProvider.changed(input); } }
@Override public void shutdown() { if (!fIsShuttingDown) { fIsShuttingDown= true; try { if (fMap != null) { fMap.clear(); fMap= null; } fDocumentProvider.shutdown(); } finally { fIsShuttingDown= false; } } }
/** * Returns the working copy remembered for the compilation unit encoded in the * given editor input. * <p> * Note: This method must not be part of the public {@link IWorkingCopyManager} API. * </p> * * @param input the editor input * @param primaryOnly if <code>true</code> only primary working copies will be returned * @return the working copy of the compilation unit, or <code>null</code> if the * input does not encode an editor input, or if there is no remembered working * copy for this compilation unit * @since 3.2 */ public ICompilationUnit getWorkingCopy(IEditorInput input, boolean primaryOnly) { ICompilationUnit unit= fMap == null ? null : (ICompilationUnit) fMap.get(input); if (unit == null) unit= fDocumentProvider.getWorkingCopy(input); if (unit != null && (!primaryOnly || JavaModelUtil.isPrimary(unit))) return unit; return null; }
/** * Adds a listener for problem marker changes. * @param listener the listener to add */ public void addListener(IProblemChangedListener listener) { if (fListeners.isEmpty()) { JavaPlugin.getWorkspace().addResourceChangeListener(this); JavaPlugin.getDefault().getCompilationUnitDocumentProvider().addGlobalAnnotationModelListener(this); } fListeners.add(listener); }
/** * Removes a <code>IProblemChangedListener</code>. * @param listener the listener to remove */ public void removeListener(IProblemChangedListener listener) { fListeners.remove(listener); if (fListeners.isEmpty()) { JavaPlugin.getWorkspace().removeResourceChangeListener(this); JavaPlugin.getDefault().getCompilationUnitDocumentProvider().removeGlobalAnnotationModelListener(this); } }
@Override protected void performSave(boolean overwrite, IProgressMonitor progressMonitor) { IDocumentProvider p= getDocumentProvider(); if (p instanceof ICompilationUnitDocumentProvider) { ICompilationUnitDocumentProvider cp= (ICompilationUnitDocumentProvider) p; cp.setSavePolicy(fSavePolicy); } try { super.performSave(overwrite, progressMonitor); } finally { if (p instanceof ICompilationUnitDocumentProvider) { ICompilationUnitDocumentProvider cp= (ICompilationUnitDocumentProvider) p; cp.setSavePolicy(null); } } }
protected void installTabsToSpacesConverter() { ISourceViewer sourceViewer= getSourceViewer(); SourceViewerConfiguration config= getSourceViewerConfiguration(); if (config != null && sourceViewer instanceof ITextViewerExtension7) { int tabWidth= config.getTabWidth(sourceViewer); TabsToSpacesConverter tabToSpacesConverter= new TabsToSpacesConverter(); tabToSpacesConverter.setNumberOfSpacesPerTab(tabWidth); IDocumentProvider provider= getDocumentProvider(); if (provider instanceof ICompilationUnitDocumentProvider) { ICompilationUnitDocumentProvider cup= (ICompilationUnitDocumentProvider) provider; tabToSpacesConverter.setLineTracker(cup.createLineTracker(getEditorInput())); } else tabToSpacesConverter.setLineTracker(new DefaultLineTracker()); ((ITextViewerExtension7)sourceViewer).setTabsToSpacesConverter(tabToSpacesConverter); updateIndentPrefixes(); } }
@Override public void setWorkingCopy(IEditorInput input, ICompilationUnit workingCopy) { if (fDocumentProvider.getDocument(input) != null) { if (fMap == null) fMap= new HashMap<>(); fMap.put(input, workingCopy); } }
private IAnnotationModel isInJavaAnnotationModel(ICompilationUnit original) { if (original.isWorkingCopy()) { FileEditorInput editorInput= new FileEditorInput((IFile) original.getResource()); return JavaPlugin.getDefault().getCompilationUnitDocumentProvider().getAnnotationModel(editorInput); } return null; }
public void shutdown() { if (!fIsShuttingDown) { fIsShuttingDown= true; try { if (fMap != null) { fMap.clear(); fMap= null; } fDocumentProvider.shutdown(); } finally { fIsShuttingDown= false; } } }
/** * Returns the working copy remembered for the compilation unit encoded in the * given editor input. * <p> * Note: This method must not be part of the public {@link IWorkingCopyManager} API. * </p> * * @param input the editor input * @param primaryOnly if <code>true</code> only primary working copies will be returned * @return the working copy of the compilation unit, or <code>null</code> if the * input does not encode an editor input, or if there is no remembered working * copy for this compilation unit * @since 3.2 */ public ICompilationUnit getWorkingCopy(IEditorInput input, boolean primaryOnly) { ICompilationUnit unit= fMap == null ? null : fMap.get(input); if (unit == null) unit= fDocumentProvider.getWorkingCopy(input); if (unit != null && (!primaryOnly || JavaModelUtil.isPrimary(unit))) return unit; return null; }
/** * Adds a listener for problem marker changes. * @param listener the listener to add */ public void addListener(IProblemChangedListener listener) { if (fListeners.isEmpty()) { JavaPlugin.getWorkspace().addResourceChangeListener(this); JavaPlugin.getDefault().getCompilationUnitDocumentProvider().addGlobalAnnotationModelListener(this); } fListeners.add(listener); }
/** * Removes a <code>IProblemChangedListener</code>. * @param listener the listener to remove */ public void removeListener(IProblemChangedListener listener) { fListeners.remove(listener); if (fListeners.isEmpty()) { JavaPlugin.getWorkspace().removeResourceChangeListener(this); JavaPlugin.getDefault().getCompilationUnitDocumentProvider().removeGlobalAnnotationModelListener(this); } }
@Override protected void performSave(boolean overwrite, IProgressMonitor progressMonitor) { IDocumentProvider p= getDocumentProvider(); if (p instanceof ICompilationUnitDocumentProvider) { ICompilationUnitDocumentProvider cp= (ICompilationUnitDocumentProvider) p; cp.setSavePolicy(fSavePolicy); } try { super.performSave(overwrite, progressMonitor); } finally { if (p instanceof ICompilationUnitDocumentProvider) { ICompilationUnitDocumentProvider cp= (ICompilationUnitDocumentProvider) p; cp.setSavePolicy(null); } } }