Package org.eclipse.ui.texteditor

Examples of org.eclipse.ui.texteditor.ITextEditor


      if (page != null) {
        try {
          IFileStore fileStore = EFS.getLocalFileSystem().getStore(this.uri);
          IEditorPart editorPart = IDE.openEditorOnFileStore(page, fileStore);
          if (this.line > 0) {
            ITextEditor textEditor = null;
            if (editorPart instanceof ITextEditor)
              textEditor = (ITextEditor) editorPart;
            else
              textEditor = (ITextEditor) editorPart.getAdapter(ITextEditor.class);

            if (textEditor != null) {
              IEditorInput input = editorPart.getEditorInput();
              IDocumentProvider provider = textEditor.getDocumentProvider();
              try {
                provider.connect(input);
              } catch (CoreException e) {
                e.printStackTrace();
                // unable to link
                //DebugUIPlugin.log(e);
                return;
              }
              IDocument document = provider.getDocument(input);
              int offset = -1, lenght = -1;

              try {
                IRegion region= document.getLineInformation(this.line - 1);
                offset = region.getOffset();
                lenght = region.getLength();
              } catch (BadLocationException e) {
                // unable to link
                //DebugUIPlugin.log(e);
                e.printStackTrace();
              }
              provider.disconnect(input);
              if (offset >= 0 && lenght >=0) {
                textEditor.selectAndReveal(offset, lenght);
              }
            }

          }
        } catch (PartInitException e) {
View Full Code Here


        } else {
            return null;
        }
       
        String functionName = getWord(Util.getActiveDocument(event).get(), tselection.getOffset());
        ITextEditor targetEditor = null;
        try {
            CompletionDictionary dict = CompletionDictionary.getInstance(Util.getActiveFile().getProject().getName());
            String fileName = dict.getFileData(Util.getActiveFile().getLocation().toFile().getAbsolutePath()).getFunctionOwner(functionName, dict);
            if (fileName == null)
                return null;
            targetEditor = (ITextEditor)openEditor(fileName);
        } catch (CoreException ce) {
            logger.logError("Error while trying to get Completion dictionary object", ce);
        }
       
        if (targetEditor != null) {
            int offset = Util.getActiveDocument(event).get().indexOf(functionName + "(");
            targetEditor.setHighlightRange(offset, functionName.length(), true);
        }
       
        return null;
    }
View Full Code Here

          if (cexFile == null)
            return;
          IEditorPart editor = IDE.openEditor(page, cexFile);

          if (editor instanceof ITextEditor) {
            ITextEditor textEditor = (ITextEditor) editor;

            IDocumentProvider documentProvider =
              textEditor.getDocumentProvider();
            IDocument document =
              documentProvider.getDocument(editor.getEditorInput());

            FindReplaceDocumentAdapter searchAdapter =
              new FindReplaceDocumentAdapter(document);
View Full Code Here

    return false;
  }

  @Override
  public void toggleLineBreakpoints(IWorkbenchPart part, ISelection selection) throws CoreException {
    ITextEditor textEditor = getEditor(part);
    if (textEditor != null) {
      IResource resource = (IResource) textEditor.getEditorInput().getAdapter(IResource.class);
      ITextSelection textSelection = (ITextSelection) selection;
      int lineNumber = textSelection.getStartLine() + 1;
      IBreakpoint[] breakpoints = DebugPlugin.getDefault().getBreakpointManager().getBreakpoints(IXVRConstants.ID_XVR_DEBUG_MODEL);
      for (int i = 0; i < breakpoints.length; i++) {
        IBreakpoint breakpoint = breakpoints[i];
View Full Code Here

  }
 
  private ITextEditor getEditor(IWorkbenchPart part) {
    if (part instanceof ITextEditor) {
      ITextEditor editorPart = (ITextEditor) part;
      IResource resource = (IResource) editorPart.getEditorInput().getAdapter(IResource.class);
      if (resource != null) {
        String extension = resource.getFileExtension();
        if (extension != null && extension.equals("s3d")) {
          return editorPart;
        }
View Full Code Here

public class XVRBreakpointAdapterFactory implements IAdapterFactory {

  @Override
  public Object getAdapter(Object adaptableObject, @SuppressWarnings("rawtypes") Class adapterType) {
    if (adaptableObject instanceof ITextEditor) {
      ITextEditor editorPart = (ITextEditor) adaptableObject;
      IResource resource = (IResource) editorPart.getEditorInput().getAdapter(IResource.class);
      if (resource != null) {
        String extension = resource.getFileExtension();
        if (extension != null && extension.equals("s3d")) {
          return new XVRLineBreakpointAdapter();
        }
View Full Code Here

            lastRemoteEditTimes.put(path, System.currentTimeMillis());

            for (IEditorPart editorPart : editorPool.getEditors(path)) {

                if (editorPart instanceof ITextEditor) {
                    ITextEditor textEditor = (ITextEditor) editorPart;
                    IAnnotationModel model = textEditor.getDocumentProvider()
                        .getAnnotationModel(textEditor.getEditorInput());
                    contributionAnnotationManager.insertAnnotation(model,
                        offset, text.length(), source);
                }
            }
            IAnnotationModel model = provider.getAnnotationModel(input);
View Full Code Here

        if (!(editorPart instanceof ITextEditor)) {
            return;
        }

        ITextEditor textEditor = (ITextEditor) editorPart;

        IDocumentProvider docProvider = textEditor.getDocumentProvider();

        if (docProvider != null) {
            IEditorInput input = textEditor.getEditorInput();
            IAnnotationModel model = docProvider.getAnnotationModel(input);

            if (model == null) {
                return;
            }
View Full Code Here

        if (!(editorPart instanceof ITextEditor)) {
            return TextSelection.emptySelection();
        }

        ITextEditor textEditor = (ITextEditor) editorPart;
        ISelectionProvider selectionProvider = textEditor
            .getSelectionProvider();
        if (selectionProvider != null) {
            return (ITextSelection) selectionProvider.getSelection();
        }
View Full Code Here

public abstract class FindOccurrencesHandler extends AbstractHandler {
 
  public Object execute(ExecutionEvent event) throws ExecutionException {
    IEditorPart editorPart = HandlerUtil.getActiveEditor(event);
    ITextEditor textEditor = null;
    if (editorPart instanceof ITextEditor)
      textEditor = (ITextEditor) editorPart;
    else {
      Object o = editorPart.getAdapter(ITextEditor.class);
      if (o != null)
        textEditor = (ITextEditor) o;
    }
    boolean okay = false;
    if (textEditor != null) {
      IDocument document = textEditor.getDocumentProvider().getDocument(textEditor.getEditorInput());
      if (document != null) {
        ITextSelection textSelection = getTextSelection(textEditor);
        FindOccurrencesProcessor findOccurrenceProcessor = getProcessorForCurrentSelection(document, textSelection);
        if (findOccurrenceProcessor != null) {
          if (textEditor.getEditorInput() instanceof IFileEditorInput) {
            IFile file = ((IFileEditorInput) textEditor.getEditorInput()).getFile();
            okay = findOccurrenceProcessor.findOccurrences(document, textSelection, file);
          }
        }
      }
    }
View Full Code Here

TOP

Related Classes of org.eclipse.ui.texteditor.ITextEditor

Copyright © 2018 www.massapicom. 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.