Examples of IDocumentProvider


Examples of org.eclipse.ui.texteditor.IDocumentProvider

   */
  public IContentType getContentType(Object element) throws CoreException {
    FileInfo info= (FileInfo) fFileInfoMap.get(element);
    if (info != null)
      return info.fTextFileBuffer.getContentType();
    IDocumentProvider parent= getParentProvider();
    if (parent instanceof IDocumentProviderExtension4)
      return ((IDocumentProviderExtension4) parent).getContentType(element);
    return null;
  }
View Full Code Here

Examples of org.eclipse.ui.texteditor.IDocumentProvider

   */
  private IContentType getContentType(ITextEditor editor) {
    IEditorInput input= editor.getEditorInput();
    if (input == null)
      return null;
    IDocumentProvider provider= editor.getDocumentProvider();
    if (provider instanceof IDocumentProviderExtension4) {
      IDocumentProviderExtension4 ext= (IDocumentProviderExtension4) provider;
      try {
        return ext.getContentType(input);
      } catch (CoreException x) {
View Full Code Here

Examples of org.eclipse.ui.texteditor.IDocumentProvider

  private DocumentLineDiffer getDiffer(boolean createIfNeeded) {
    // get annotation model
    if (fEditor == null)
      return null;

    IDocumentProvider provider= fEditor.getDocumentProvider();
    IEditorInput editorInput= fEditor.getEditorInput();
    if (provider == null || editorInput == null)
      return null;

    IAnnotationModel m= provider.getAnnotationModel(editorInput);
    IAnnotationModelExtension model= null;
    if (m instanceof IAnnotationModelExtension) {
      model= (IAnnotationModelExtension)m;
    } else {
      return null;
View Full Code Here

Examples of org.eclipse.ui.texteditor.IDocumentProvider

   * @return the displayed document's annotation model if it is an <code>IAnnotationModelExtension</code>, or <code>null</code>
   */
  private IAnnotationModelExtension getModel() {
    if (getTextEditor() == null)
      return null;
    IDocumentProvider provider= getTextEditor().getDocumentProvider();
    IEditorInput editorInput= getTextEditor().getEditorInput();
    IAnnotationModel m= provider.getAnnotationModel(editorInput);
    if (m instanceof IAnnotationModelExtension)
      return (IAnnotationModelExtension)m;
    return null;
  }
View Full Code Here

Examples of org.eclipse.ui.texteditor.IDocumentProvider

   */
  public static void removeAllInActiveEditor(ITextEditor editor, String word) {
    if (editor == null)
      return;
   
    IDocumentProvider documentProvider= editor.getDocumentProvider();
    if (documentProvider == null)
      return;
 
    IEditorInput editorInput= editor.getEditorInput();
    if (editorInput == null)
      return;
   
    IAnnotationModel model= documentProvider.getAnnotationModel(editorInput);
    if (model == null)
      return;
   
    IDocument document= documentProvider.getDocument(editorInput);
    if (document == null)
      return;
 
    boolean supportsBatchReplace= (model instanceof IAnnotationModelExtension);
    List toBeRemovedAnnotations= new ArrayList();
View Full Code Here

Examples of org.eclipse.ui.texteditor.IDocumentProvider

    return super.showPossibleQuickAssists();
  }

  private static IRegion getRegionOfInterest(ITextEditor editor, int invocationLocation)
          throws BadLocationException {
    IDocumentProvider documentProvider = editor.getDocumentProvider();
    if (documentProvider == null) {
      return null;
    }
    IDocument document = documentProvider.getDocument(editor.getEditorInput());
    if (document == null) {
      return null;
    }
    return document.getLineInformationOfOffset(invocationLocation);
  }
View Full Code Here

Examples of org.eclipse.ui.texteditor.IDocumentProvider

      if (sourceElement != null) {
        IEditorPart part = EditorUtility.openInEditor(sourceElement);
        IEditorPart editorPart = EditorUtility.openInEditor(sourceElement);
        if (editorPart instanceof ITextEditor && lineNumber >= 0) {
          ITextEditor textEditor = (ITextEditor) editorPart;
          IDocumentProvider provider = textEditor.getDocumentProvider();
          IEditorInput input = part.getEditorInput();
          provider.connect(input);
          IDocument document = provider.getDocument(input);
          try {
            IRegion line = document.getLineInformation(lineNumber);
            textEditor.selectAndReveal(line.getOffset(), line.getLength());
          } catch (BadLocationException e) {

          }
          provider.disconnect(input);
        }
        return;
      }
      // did not find source
      MessageDialog.openInformation(DLTKDebugUIPlugin.getActiveWorkbenchShell(),
View Full Code Here

Examples of org.eclipse.ui.texteditor.IDocumentProvider

  protected IDocument getDocument() {
    if (!(targetEditor instanceof ITextEditor))
      return null;

    ITextEditor editor = (ITextEditor) targetEditor;
    IDocumentProvider dp = editor.getDocumentProvider();
    return dp.getDocument(editor.getEditorInput());
  }
View Full Code Here

Examples of org.eclipse.ui.texteditor.IDocumentProvider

   
    ISourceViewer sourceViewer= editor.getViewer();
    if (sourceViewer != null)
      sourceViewer.removeTextInputListener(this);
   
    IDocumentProvider documentProvider= editor.getDocumentProvider();
    if (documentProvider != null) {
      IDocument document= documentProvider.getDocument(editor.getEditorInput());
      if (document != null)
        document.removeDocumentListener(this);
    }
     
//    IPreferenceStore preferenceStore= getPreferenceStore();
View Full Code Here

Examples of org.eclipse.ui.texteditor.IDocumentProvider

    if (original != null)
      dialog.setOriginalFile(original);

    dialog.create();

    IDocumentProvider provider = getDocumentProvider();
    if (provider == null) {
      // editor has programatically been closed while the dialog was open
      return;
    }

    if (provider.isDeleted(input) && original != null) {
      String message = "The original file, '" + original.getName() + "' has been deleted";
      dialog.setErrorMessage(null);
      dialog.setMessage(message, IMessageProvider.WARNING);
    }

    if (dialog.open() == Dialog.CANCEL) {
      if (progressMonitor != null)
        progressMonitor.setCanceled(true);
      editor.setSaveAsStatus(MultiPageEditor.SAVE_AS_CANCELLED);
      return;
    }

    IPath filePath = dialog.getResult();
    if (filePath == null) {
      if (progressMonitor != null)
        progressMonitor.setCanceled(true);
      editor.setSaveAsStatus(MultiPageEditor.SAVE_AS_CANCELLED);
      return;
    }

    IWorkspace workspace = ResourcesPlugin.getWorkspace();
    IFile file = workspace.getRoot().getFile(filePath);
    final IEditorInput newInput = new FileEditorInput(file);

    WorkspaceModifyOperation op = new WorkspaceModifyOperation() {
      public void execute(final IProgressMonitor monitor) throws CoreException {
        getDocumentProvider().saveDocument(monitor, newInput,
                getDocumentProvider().getDocument(getEditorInput()), true);
      }
    };

    boolean success = false;
    try {

      provider.aboutToChange(newInput);
      new ProgressMonitorDialog(shell).run(false, true, op);
      success = true;

    } catch (InterruptedException x) {
    } catch (InvocationTargetException x) {

      Throwable targetException = x.getTargetException();

      String title = "Error saving"; // TextEditorMessages.getString("Editor.error.save.title");
      // //$NON-NLS-1$
      String msg = "Error occurred during save operation"; // MessageFormat.format(TextEditorMessages.getString("Editor.error.save.message"),
      // new Object[] {
      // targetException.getMessage()});
      // //$NON-NLS-1$

      if (targetException instanceof CoreException) {
        CoreException coreException = (CoreException) targetException;
        IStatus status = coreException.getStatus();
        if (status != null) {
          switch (status.getSeverity()) {
            case IStatus.INFO:
              MessageDialog.openInformation(shell, title, msg);
              break;
            case IStatus.WARNING:
              MessageDialog.openWarning(shell, title, msg);
              break;
            default:
              MessageDialog.openError(shell, title, msg);
          }
        } else {
          MessageDialog.openError(shell, title, msg);
        }
      }

    } finally {
      provider.changed(newInput);
      if (success) {
        setInput(newInput);
        editor.setSaveAsStatus(MultiPageEditor.SAVE_AS_CONFIRMED);
      } else {
        editor.setSaveAsStatus(MultiPageEditor.SAVE_AS_CANCELLED);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.