Examples of IDocument


Examples of org.eclipse.jface.text.IDocument

  public ICompletionProposal[] computeCompletionProposals(ITextViewer viewer, int offset) {   
    setErrorMessage(null);
    List<ICompletionProposal> proposals = new ArrayList<ICompletionProposal>();   
    try {
      IDocument document = viewer.getDocument();
      IRegion region = TMLContentAssistProcessor.determineRelatedRegion(offset, document);
      if (isOpenPartition(region, document, "<tml:comment>", "</tml:comment>", TMLPartitionScanner.TML_COMMENT)) {
        proposals.addAll(computeCompletionPropsals(document, region, offset, "<tml:comment>", "</tml:comment>"));
      } else if (isOpenPartition(region, document, "<tml:disable>", "</tml:disable>", TMLPartitionScanner.TML_DISABLE)) {
        proposals.addAll(computeCompletionPropsals(document, region, offset, "<tml:disable>", "</tml:disable>"));
View Full Code Here

Examples of org.eclipse.jface.text.IDocument

  public ICompletionProposal[] computeCompletionProposals(ITextViewer viewer, int offset) {
      List<ICompletionProposal> proposals = new ArrayList<ICompletionProposal>();
    _viewer = viewer;
    setErrorMessage(null);

    IDocument document = viewer.getDocument();
    try {       
      IRegion region = determineRelatedRegion(offset, document);
      if (document.getContentType(region.getOffset()).equals(TMLPartitionScanner.TML_TAG_START)) {
        TMLRegion tmlRegion = TMLRegion.parse(region, document, offset);
        ICompletionProposal[] tmlProposals =  tmlRegion.createProposals(viewer, Plugin.getDefault().getActiveFile());
        if (tmlProposals != null) {
            proposals.addAll(Arrays.asList(tmlProposals));
        }
       
        // already called in tmlRegion
        /*
        if (!tmlRegion.isCursorInAttributeValue()) {          
          ICompletionProposal[] closeProposals = _closeTagProcessor.computeCompletionProposals(viewer, offset);
          if (closeProposals != null) {
              proposals.addAll(Arrays.asList(closeProposals));   
          }
        }*/
      } else {
          // workaround for tmlscript partitions with length 1: <tml:script>c[raisecodecompletion]</tml:script>
          if (offset > 0 && document.getContentType(offset - 1).equals(TMLScriptPartitionScanner.TMLSCRIPT)) {
              return _tmlScriptProcessor.computeCompletionProposals(viewer, offset);
          } else {
              return _closeTagProcessor.computeCompletionProposals(viewer, offset);
          }
      } 
View Full Code Here

Examples of org.eclipse.jface.text.IDocument

    /**
     * in tml-start-tag partionions 'ENTER' and ' ' will be a valid auto activation char
     */
    if (_viewer != null) {
      try {
        IDocument document = _viewer.getDocument();
        ISelection selection =_viewer.getSelectionProvider().getSelection();
        if (selection instanceof TextSelection) {
          TextSelection textSelection = (TextSelection) selection;
          int offset = textSelection.getOffset();
          IRegion region = document.getPartition(offset);
         
          boolean sameLine = document.getLineOfOffset(region.getOffset()) == document.getLineOfOffset(offset);
         
          if (document.getContentType(region.getOffset()).equals(TMLPartitionScanner.TML_TAG_START)) {
            TMLRegion tmlInfo = TMLRegion.parse(region, document, offset);
            if (tmlInfo.isCursorInTagName()) {
              return alphaNumericControlsNoEnter;
            } else if (tmlInfo.isCursorInAttributeValue()) {
               // check if attribute is tmlscript expression
                IFile activeFile = Plugin.getDefault().getActiveFile();
                String tagName = tmlInfo.getTagName();
                if (activeFile != null && tagName != null) {
                    VersionCompliance versionCompliance = WGADesignStructureHelper.getWGAVersionCompliance(activeFile);
                    if (versionCompliance != null) {
                        TMLTag tag = TMLTagDefinitions.getInstance(versionCompliance).getTagByName(tagName);
                        if (tag != null) {
                            String attributeAtCursor = tmlInfo.getAttributeAtCursor();
                            if (attributeAtCursor != null) {
                                TMLTagAttribute attribute = tag.getAttribute(attributeAtCursor);
                                if (attribute != null && attribute.isTmlscriptExpression()) {
                                    return _tmlScriptProcessor.getCompletionProposalAutoActivationCharacters();
                                }
                            }
                        }
                    }
                }
                return alphaNumericControls;
            } else {
                return alphaNumericControls;
            }
          } else if (document.getContentType(region.getOffset()).equals(IDocument.DEFAULT_CONTENT_TYPE) && sameLine) {
            return alphaNumericControlsNoEnter;
          }
        }
      } catch (BadLocationException e) {
      } catch (ParseException e) {
View Full Code Here

Examples of org.eclipse.jface.text.IDocument

  public TMLCommentPartitionContentAssistProcessor() {
  }

  public ICompletionProposal[] computeCompletionProposals(ITextViewer viewer, int offset) {   
    setErrorMessage(null);
    IDocument document = viewer.getDocument();
    try {       
      IRegion region = document.getPartition(offset);
      // fallback to current edit line if partition has length 0 - for e.g. end of document
      if (region.getLength() == 0) {         
        region = document.getLineInformationOfOffset(offset);
      }
     
      ITypedRegion previousPartition = document.getPartition(offset - 1);
     
      // check if tml comment partition is open
      String content = document.get(region.getOffset(), region.getLength());
      if (!content.trim().endsWith("</tml:comment>") && (content.trim().startsWith("<tml:comment>") || previousPartition.getType().equals(TMLPartitionScanner.TML_COMMENT))) {       
        String replacement = "</tml:comment>";
        String alreadyTyped = document.get(region.getOffset(), offset-region.getOffset());
        if (alreadyTyped.contains("\n")) {
          alreadyTyped = alreadyTyped.substring(alreadyTyped.lastIndexOf("\n"));
        }
        int completionStartPos = -1;
        if (alreadyTyped.indexOf(">") == -1) {
View Full Code Here

Examples of org.eclipse.jface.text.IDocument

  public TMLScriptContentAssistProcessor() {
  }

  public ICompletionProposal[] computeCompletionProposals(ITextViewer viewer, int offset) {   
    setErrorMessage(null);
    IDocument document = viewer.getDocument();
           
        try {
            IRegion region = document.getPartition(offset);
           
            // search backwards to document start or partition of type TML - this is neccessary bc. our current script may contain TMLscript comments
            ITypedRegion prevPartition = null;
            int previousOffset = region.getOffset() - 1;
            while (previousOffset > 0) {
                prevPartition = document.getPartition(previousOffset);
                if (prevPartition.getType().equals(TMLPartitionScanner.TML_TAG_START)) {
                    break;
                }
                previousOffset = prevPartition.getOffset() - 1;
            }
View Full Code Here

Examples of org.eclipse.jface.text.IDocument


public class TMLDocumentProvider extends FileDocumentProvider {

  protected IDocument createDocument(Object element) throws CoreException {
    IDocument document = super.createDocument(element);
    if (document != null) {
      IDocumentPartitioner partitioner =
        new TMLDocumentPartitioner(
          new TMLPartitionScanner(), TMLPartitionScanner.PARTITIONS);
      partitioner.connect(document);
      document.setDocumentPartitioner(partitioner);
    }
    return document;
  }
View Full Code Here

Examples of org.eclipse.jface.text.IDocument

  }
 
  protected abstract String[] getKeyBindingScopes();

  protected IDocument getInputDocument() {
    IDocument document = getDocumentProvider().getDocument(getEditorInput());
    return document;
  }
View Full Code Here

Examples of org.eclipse.jface.text.IDocument

    fIsEditable = false;

    AbstractMarkerAnnotationModel model = getAnnotationModel();
    IAnnotationAccessExtension annotationAccess = getAnnotationAccessExtension();

    IDocument document = getDocument();
    if (model == null)
      return;

    Iterator iter = model.getAnnotationIterator();
    int layer = Integer.MIN_VALUE;
View Full Code Here

Examples of org.eclipse.jface.text.IDocument

import org.eclipse.ui.editors.text.FileDocumentProvider;

public class TMLScriptDocumentProvider extends FileDocumentProvider {

  protected IDocument createDocument(Object element) throws CoreException {
    IDocument document = super.createDocument(element);
    if (document != null) {
      IDocumentPartitioner partitioner =
        new TMLScriptDocumentPartitioner(
          new TMLScriptPartitionScanner(),
          TMLScriptPartitionScanner.PARTITIONS);
      partitioner.connect(document);
      document.setDocumentPartitioner(partitioner);
    }
    return document;
  }
View Full Code Here

Examples of org.eclipse.jface.text.IDocument

    if (editorPart != null && editorPart instanceof ITextEditor) {
      ITextEditor editor = (ITextEditor) editorPart;
      ISelection selection = editor.getEditorSite().getSelectionProvider().getSelection();
      if (selection != null && selection instanceof ITextSelection) {
        ITextSelection textSelection = (ITextSelection) selection;
        IDocument doc = editor.getDocumentProvider().getDocument(editor.getEditorInput());
        if (doc != null) {
          if(textSelection.getLength()>0){
            new LabelingDialog(editor.getEditorSite().getShell(), textSelection, doc).open();
          }
        }
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.