Package org.cfeclipse.cfml.editors

Examples of org.cfeclipse.cfml.editors.ICFDocument


   */
  @Override
  public void format() {

    super.format();
    final ICFDocument document = (ICFDocument) fDocuments.removeFirst();
    final IRegion region = (IRegion) fRegions.removeFirst();
    if (region != null) {
      String regionText = "";
      String formattedText = "";
      try {
        regionText = document.get(region.getOffset(), region.getLength());
        StringBuffer currentIndent = XmlDocumentFormatter.getLeadingWhitespace(region.getOffset(), document);
        if (document.getPartition(region.getOffset()).getType().equals(CFPartitionScanner.CF_SCRIPT)) {
          formattedText = formatCFScript(regionText, currentIndent.toString());
        } else {
          formattedText = format(regionText, currentIndent.toString());
        }
        int lineOffset = document.getLineInformationOfOffset(region.getOffset()).getOffset();
        // String formattedText = format(regionText, "");
        if (formattedText != null && !formattedText.equals(regionText)) {
          int newLength = region.getLength() + (region.getOffset() - lineOffset);
          document.replace(lineOffset, newLength, formattedText);
          // ITextEditor editor =
          // (ITextEditor)CFMLPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor();
          // IDocument doc =
          // editor.getDocumentProvider().getDocument(editor.getEditorInput());
          // TextSelection selection = new TextSelection(doc,
          // lineOffset, 10);
          // editor.getSelectionProvider().setSelection(selection);
        }
      } catch (BadLocationException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
      }
    } else {
      if (document != null) {
        String documentText = document.get();
        String formattedText = format(documentText, "");
        if (formattedText != null && !formattedText.equals(documentText)) {
          document.set(formattedText);
        }
      }

    }
  }
View Full Code Here


      iep.addPropertyListener(this);
      getSite().getPage().addPartListener(this);

      ITextEditor ite = (ITextEditor) iep;
      ICFDocument icfd = null;
      CFDocument cfd = null;
      if (ite.getDocumentProvider().getDocument(iep.getEditorInput()) instanceof ICFDocument) {
        icfd = (ICFDocument) ite.getDocumentProvider().getDocument(iep.getEditorInput());
        cfd = icfd.getCFDocument();
      }
      // icfd.clearAllMarkers();
      // icfd.parseDocument();

      if (cfd != null) {
View Full Code Here

    // TODO Auto-generated method stub
    //CFMLEditor curDoc = (CFMLEditor) this.fViewer.getDocument();
    //ICFDocument cfd = (ICFDocument) curDoc.getDocumentProvider().getDocument(curDoc.getEditorInput());
    TextSelection sel = (TextSelection) this.fViewer.getSelection();
    int startPos = sel.getOffset();
    ICFDocument cfd = (ICFDocument) this.fViewer.getDocument();
    DocItem cti = cfd.getTagAt(startPos, startPos, true);
    if(cti != null && this.selectedTag != null) {
      if(cti.getStartPosition() == this.selectedTag.getStartPosition()){       
        this.selectedTagWasSelected = true;
      } else {
        clearTagBeginEndMarkers();
        this.selectedTagWasSelected = false;       
      }
    } else {
      clearTagBeginEndMarkers();     
    }
    this.selectedTag = null;
    try {
      // cfcomponent returns ASTVarDeclaration -- syntax is null for whatever reason (ASTVar's from cfscript?!)
      if(cti != null
        && !cti.getName().equals("CfmlComment") && !cti.getName().equals("cfscript")
          && !cti.getName().startsWith("AST") && !cti.getName().equals("ScriptItem")) {
        if (cti instanceof CfmlTagItem) {
          if (cti.getName().equals("CfmlCustomTag") || ((TagItem) cti).hasClosingTag()) {
            markBeginEndTags((CfmlTagItem) cti);
          }
        }
    }
    } catch (Exception e) {
      System.err.println(cti.getName());
      e.printStackTrace();
    }     
    CFEPartitioner partitioner = (CFEPartitioner)cfd.getDocumentPartitioner();   
    CFEPartition part = partitioner.findClosestPartition(startPos);
    if(part == null) {
      return;
    }
    startPos = part.offset;
    if (cti != null) {
      this.currentDocItem = cti;
      this.selectedTag = cti;
    } else {
      this.currentDocItem = cfd.getTagAt(startPos, startPos, false);
      while (this.currentDocItem == null && startPos >= 0 && part != null) {
        startPos = part.offset;
        this.currentDocItem = cfd.getTagAt(startPos, startPos + part.length + 1, false);
        part = partitioner.getPreviousPartition(startPos);
      }
      this.selectedTag = this.currentDocItem;
    }
  }
View Full Code Here

    if ((e.stateMask & SWT.MOD1) != 0) {

      CFMLPropertyManager propertyManager = new CFMLPropertyManager();
      String dict = propertyManager.getCurrentDictionary(((IFileEditorInput) editor.getEditorInput()).getFile().getProject());
      CFMLParser fCfmlParser = CFMLPlugin.newCFMLParser(dict);
      ICFDocument cfd = (ICFDocument) this.fViewer.getDocument();
      CFMLSource cfmlSource = fCfmlParser.addCFMLSource(cfd.getCFDocument().getFilename(),cfd.get());
      ParserTag tag = cfmlSource.getEnclosingTag(startpos);
      int start = 0;
      int length = 0;
      if (tag != null) {
View Full Code Here

      tagClose.put(IMarker.LOCATION, "line " + tagItem.getMatchingItem().getLineNumber() + ", Chars " + tagItem.getMatchingItem().getStartPosition() + "-" + tagItem.getMatchingItem().getEndPosition());
      tagClose.put(IMarker.CHAR_START, Integer.toString(tagItem.getMatchingItem().getStartPosition()));
      tagClose.put(IMarker.CHAR_END, Integer.toString(tagItem.getMatchingItem().getEndPosition()));
     
      try {
        ICFDocument doc = ((ICFDocument) this.fViewer.getDocument());
        MarkerUtilities.createMarker(doc.getResource(), tagOpen, SelectionCursorListener.tagBeginEndAnnotation);
        MarkerUtilities.createMarker(doc.getResource(), tagClose, SelectionCursorListener.tagBeginEndAnnotation);
      } catch (CoreException excep) {
        excep.printStackTrace();
      } catch (Exception anyExcep) {
        anyExcep.printStackTrace();
      }   
View Full Code Here

   *
   * @param e The CFML editor to get the test case from
   * @return The test case currently in the editor.
   */
  private String retrieveTestCase(CFMLEditor e) {
    ICFDocument icfd = null;
    CFDocument cfd = null;
   
    if (e.getDocumentProvider().getDocument(e.getEditorInput()) instanceof ICFDocument) {
      icfd = (ICFDocument)e.getDocumentProvider().getDocument(e.getEditorInput());
      cfd = icfd.getCFDocument();
    }
   
    org.cfeclipse.cfml.parser.docitems.DocItem docRoot = cfd.getDocumentRoot();
    CFNodeList nodes = docRoot.selectNodes("//cfcomponent");   
   
    // Check if this document is a CFC (contains a <cfcomponent> tag)
    if(nodes.size() > 0) {
      CfmlTagItem tag = (CfmlTagItem)nodes.get(0);
     
      // If the CFC has a tester argument, return that as the test case
      String t = tag.getAttributeValue("tester");
      if(t != null) {
        return t;
      }
     
      // If the CFC extends a TestCase, return the current document's name
      String sc = tag.getAttributeValue("extends");
      if(sc != null) {
        if(sc.matches(".*\\.TestCase.*")) {
          return CFUnitTestCase.getResourceFullName( icfd.getResource() );
        }
      }
    }
   
    return null;
View Full Code Here

    fPreviewerUpdater= new CFPreviewerUpdater(fPreviewViewer, configuration, store);
   
    String content= loadPreviewContentFromFile("FormatPreviewCode.txt"); //$NON-NLS-1$
    content= formatContent(content, store);
    //IDocument document = new Document(content);      
    ICFDocument document = new ICFDocument(content);
    new CFDocumentSetupParticipant().setup(document);
    fPreviewViewer.setDocument(document);
   
    return fPreviewViewer.getControl();
  }
View Full Code Here

  private ICFDocument getRootInput() {

    try {
      IEditorPart iep = this.getViewSite().getWorkbenchWindow().getActivePage().getActiveEditor();
      ITextEditor ite = (ITextEditor)iep;
      ICFDocument icfd = (ICFDocument)ite.getDocumentProvider().getDocument(iep.getEditorInput());

    return icfd;
    }
    catch (Exception e) {
      //System.err.println("No valid CF document found for CFCMethodsView");
View Full Code Here

   * Gets the ColdFusion document from a file
   * @param f The file to get a CFDocument from
   * @return CFDocument The ColdFusion document
   */
  private CFDocument getCFFile(IFile f) {
    ICFDocument idoc = new ICFDocument();
   
    try {
      String contents = "";
      String line;
     
      java.io.BufferedReader in = new java.io.BufferedReader(new java.io.InputStreamReader( f.getContents() ));
     
      line = in.readLine();
      while(line != null) {
        contents += line;
        line = in.readLine();
      }
     
      idoc.setParserResource( f );
      idoc.set( contents );
      idoc.parseDocument();
     
    } catch(org.eclipse.core.runtime.CoreException e) {
      System.out.println("ERROR {org.cfeclipse.cfml.wizards.cfunit.getCFFile():CoreException}: "+e.toString());
    } catch(java.io.IOException e) {
      System.out.println("ERROR {org.cfeclipse.cfml.wizards.cfunit.getCFFile():IOException}: "+e.toString());
    }
   
    return idoc.getCFDocument();
  }
View Full Code Here

  public void setActiveEditor(IAction action, IEditorPart targetEditor) {
    this.editor = (ITextEditor)targetEditor;
    IDocument doc = editor.getDocumentProvider().getDocument(
        editor.getEditorInput());

    ICFDocument cfd = (ICFDocument) doc;

    this.partitioner = (CFEPartitioner)cfd.getDocumentPartitioner();
   
  }
View Full Code Here

TOP

Related Classes of org.cfeclipse.cfml.editors.ICFDocument

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.