Package org.eclipse.jface.text

Examples of org.eclipse.jface.text.ITextViewer


   *         textviewer's document or null if the offset is not within the
   *         document
   */
  private IRegion getDocumentRangeFromWidgetRange(int offset, int length) {
    IRegion styleRegion = null;
    ITextViewer viewer = getTextViewer();
    if (viewer instanceof ITextViewerExtension5) {
      // get document range, taking into account folding regions in
      // viewer
      ITextViewerExtension5 extension = (ITextViewerExtension5) viewer;
      styleRegion = extension.widgetRange2ModelRange(new Region(offset, length));
    }
    else {
      // get document range, taking into account viewer visible region
      // get visible region in viewer
      IRegion vr = null;
      if (viewer != null)
        vr = viewer.getVisibleRegion();
      else
        vr = new Region(0, getDocument().getLength());

      // if offset is not within visible region, then we don't really
      // care
View Full Code Here


      CompletionProposalInvocationContext context,
      IProgressMonitor monitor) {
   
    List results = new ArrayList(0);
    if(isValidContext(context)) {
      ITextViewer viewer = context.getViewer();
      int documentPosition = context.getInvocationOffset();
      IndexedRegion treeNode = ContentAssistUtils.getNodeAt(viewer, documentPosition);
     
      // get results from JSP completion processor
      results = computeJavaCompletionProposals(viewer, documentPosition, 0);

      IDOMNode xNode = null;
      IStructuredDocumentRegion flat = null;
      if (treeNode instanceof IDOMNode) {
        xNode = (IDOMNode) treeNode;
        flat = xNode.getFirstStructuredDocumentRegion();
        if (flat != null && flat.getType() == DOMJSPRegionContexts.JSP_CONTENT) {
          flat = flat.getPrevious();
        }
      }

      // this is in case it's a <%@, it will be a region container...
      ITextRegion openRegion = null;
      if (flat != null && flat instanceof ITextRegionContainer) {
        ITextRegionList v = ((ITextRegionContainer) flat).getRegions();
        if (v.size() > 0)
          openRegion = v.get(0);
      }

      // ADD CDATA PROPOSAL IF IT'S AN XML-JSP TAG
      if (flat != null && flat.getType() != DOMJSPRegionContexts.JSP_SCRIPTLET_OPEN &&
          flat.getType() != DOMJSPRegionContexts.JSP_DECLARATION_OPEN &&
          flat.getType() != DOMJSPRegionContexts.JSP_EXPRESSION_OPEN &&
          flat.getType() != DOMRegionContext.BLOCK_TEXT &&
          (openRegion != null &&
              openRegion.getType() != DOMJSPRegionContexts.JSP_DIRECTIVE_OPEN) &&
              !inAttributeRegion(flat, documentPosition)) {
       
        // determine if cursor is before or after selected range
        int adjustedDocPosition = documentPosition;
        int realCaretPosition = viewer.getTextWidget().getCaretOffset();
        int selectionLength = viewer.getSelectedRange().y;
        if (documentPosition > realCaretPosition) {
          adjustedDocPosition -= selectionLength;
        }

        CustomCompletionProposal cdataProposal = createCDATAProposal(adjustedDocPosition, selectionLength);
View Full Code Here

   */
  public List computeContextInformation(
      CompletionProposalInvocationContext context,
      IProgressMonitor monitor) {
 
    ITextViewer viewer = context.getViewer();
    int documentOffset = context.getInvocationOffset();
   
    List results = new ArrayList();
    // need to compute context info here, if it's JSP, call java computer
    IDocument doc = viewer.getDocument();
    IDocumentPartitioner dp = null;
    if (doc instanceof IDocumentExtension3) {
      dp = ((IDocumentExtension3) doc).getDocumentPartitioner(IStructuredPartitioning.DEFAULT_STRUCTURED_PARTITIONING);
    }
    if (dp != null) {
View Full Code Here

   * JSP Java proposals, <code>false</code> otherwise.  <code>true</code>
   * is the default response if a specific case for <code>false</code> is
   * not found.
   */
  private boolean isValidContext(CompletionProposalInvocationContext context) {
    ITextViewer viewer = context.getViewer();
    int documentPosition = context.getInvocationOffset();
   
    String partitionType = getPartitionType(viewer, documentPosition);
    if (partitionType == IJSPPartitions.JSP_CONTENT_JAVA)
      return true;
    IStructuredDocument structuredDocument = (IStructuredDocument) viewer.getDocument();
    IStructuredDocumentRegion fn = structuredDocument.getRegionAtCharacterOffset(documentPosition);
    IStructuredDocumentRegion sdRegion = ContentAssistUtils.getStructuredDocumentRegion(viewer, documentPosition);
    // ////////////////////////////////////////////////////////////////////////////
    // ANOTHER WORKAROUND UNTIL PARTITIONING TAKES CARE OF THIS
    // check for xml-jsp tags...
View Full Code Here

   */
  public List computeCompletionProposals(
      CompletionProposalInvocationContext context,
      IProgressMonitor monitor) {

    ITextViewer viewer = context.getViewer();
    int documentPosition = context.getInvocationOffset();

    // get results from JSP completion processor
    // 3 for the "get" at the beginning of the java proposal
    List results = new ArrayList(computeJavaCompletionProposals(viewer,
View Full Code Here

      String contentTypeId = getContentType(getDocument());
      if (contentTypeId == null) {
        contentTypeId = IContentTypeManager.CT_TEXT;
      }
     
      ITextViewer viewer = getTextViewer();
      if(viewer instanceof ProjectionViewer) {
        ExtendedConfigurationBuilder builder = ExtendedConfigurationBuilder.getInstance();
       
        IContentType type = Platform.getContentTypeManager().getContentType(contentTypeId);
        while(fFoldingStrategy == null && type != null) {
View Full Code Here

  }

  private void ensureAnnotationModelInstalled() {
    LinkedPositionAnnotations lpa= fCurrentTarget.fAnnotationModel;
    if (lpa != null) {
      ITextViewer viewer= fCurrentTarget.getViewer();
      if (viewer instanceof ISourceViewer) {
        ISourceViewer sv= (ISourceViewer) viewer;
        IAnnotationModel model= sv.getAnnotationModel();
        if (model instanceof IAnnotationModelExtension) {
          IAnnotationModelExtension ext= (IAnnotationModelExtension) model;
View Full Code Here

      }
    }
  }

  private void uninstallAnnotationModel(LinkedModeUITarget target) {
    ITextViewer viewer= target.getViewer();
    if (viewer instanceof ISourceViewer) {
      ISourceViewer sv= (ISourceViewer) viewer;
      IAnnotationModel model= sv.getAnnotationModel();
      if (model instanceof IAnnotationModelExtension) {
        IAnnotationModelExtension ext= (IAnnotationModelExtension) model;
View Full Code Here

      }
    }
  }

  private void select() {
    ITextViewer viewer= fCurrentTarget.getViewer();
    if (viewer instanceof ITextViewerExtension5) {
      ITextViewerExtension5 extension5= (ITextViewerExtension5) viewer;
      extension5.exposeModelRange(new Region(fFramePosition.offset, fFramePosition.length));
    } else if (!viewer.overlapsWithVisibleRegion(fFramePosition.offset, fFramePosition.length)) {
      viewer.resetVisibleRegion();
    }
    viewer.revealRange(fFramePosition.offset, fFramePosition.length);
    viewer.setSelectedRange(fFramePosition.offset, fFramePosition.length);
  }
View Full Code Here

      fCurrentTarget.fAnnotationModel.switchToPosition(fModel, fFramePosition);
  }

  private void connect() {
    Assert.isNotNull(fCurrentTarget);
    ITextViewer viewer= fCurrentTarget.getViewer();
    Assert.isNotNull(viewer);
    fCurrentTarget.fWidget= viewer.getTextWidget();
    if (fCurrentTarget.fWidget == null)
      leave(ILinkedModeListener.EXIT_ALL);

    if (fCurrentTarget.fKeyListener == null) {
      fCurrentTarget.fKeyListener= new KeyListener();
      ((ITextViewerExtension) viewer).prependVerifyKeyListener(fCurrentTarget.fKeyListener);
    } else
      fCurrentTarget.fKeyListener.setEnabled(true);

    registerAutoEditVetoer(viewer);

    ((IPostSelectionProvider) viewer).addPostSelectionChangedListener(fSelectionListener);

    createAnnotationModel();

    showSelection();

    fCurrentTarget.fShell= fCurrentTarget.fWidget.getShell();
    if (fCurrentTarget.fShell == null)
      leave(ILinkedModeListener.EXIT_ALL);
    fCurrentTarget.fShell.addShellListener(fCloser);

    fAssistant.install(viewer);

    viewer.addTextInputListener(fCloser);

    viewer.getDocument().addDocumentListener(fDocumentListener);
  }
View Full Code Here

TOP

Related Classes of org.eclipse.jface.text.ITextViewer

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.