Package org.cfeclipse.cfml.editors.partitioner

Examples of org.cfeclipse.cfml.editors.partitioner.CFEPartitioner


    final ICFDocument cfd = (ICFDocument) doc;
    final ITextSelection sel = (ITextSelection) editor.getSelectionProvider()
        .getSelection();
    int startpos = sel.getOffset();
    int len = Math.max(sel.getLength(),1);
    CFEPartitioner partitioner = (CFEPartitioner)cfd.getDocumentPartitioner();
   
    CFEPartition part = partitioner.findClosestPartition(startpos);
    return part;
  }
View Full Code Here


          ITextSelection sel = (ITextSelection) editor.getSelectionProvider()
              .getSelection();
              */
          int startpos = sel.getOffset();
          int len = Math.max(sel.getLength(),1);
          CFEPartitioner partitioner = (CFEPartitioner)cfd.getDocumentPartitioner();
          CFEPartition[] partitioning = partitioner.getCFEPartitions(startpos,startpos+len);
            String info = "Partitioning info from offset " + startpos + " to " + Integer.toString(startpos + len) + "\n\n";
            CFEPartition part = partitioner.findClosestPartition(startpos);
            info += "(Closest partition: " + part.getType() + " = " + part.getTagName() + ")\n";
          for (int i=0;i<partitioning.length;i++) {
              info += partitioning[i].getType();
              info += " starting at ";
              info += partitioning[i].getOffset();
              info += " ending at ";
              info += Integer.toString(partitioning[i].getOffset() + partitioning[i].getLength());
              if (partitioning[i].getTagName() != null) {
                  info += " (";
                  info += partitioning[i].getTagName();
                  info += ") ";
              }
              info += "\n";
          }
           
            String[] labels = new String[1];
          labels[0] = "OK";
            MessageDialog msg = new MessageDialog(
              Display.getCurrent().getActiveShell(),
              "Partition info",
              null,
              info,
              MessageDialog.WARNING,
              labels,
              0);
            msg.open();
        }
      };
      menu.add(act);

     
      /*
       * TODO: re-write this so the edit this tag action can be called from different places
       * Edit this tag action start
       */
      act = new Action("Edit this tag", null){
        public void run() {
       
            EditTagAction eta = new EditTagAction();
            eta.run();
          
        }
      };
     
      //Only display if you are at the start tag
      int startpos = sel.getOffset();
      CFEPartitioner partitioner = (CFEPartitioner)cfd.getDocumentPartitioner();
      CFEPartition part = partitioner.findClosestPartition(startpos);
//      ITypedRegion part = cfd.getDocumentPartitioner(CFDocumentSetupParticipant.CFML_PARTITIONING).getPartition(startpos);
     
      if(part != null && EditableTags.isEditable(part.getType())){
        menu.add(act);
      }
View Full Code Here

  private void handleEnterBetweenTags(IDocument doc,
      DocumentCommand docCommand) {
    if (doc instanceof ICFDocument
        && this.isUseSmartIndent()) {
      ICFDocument cfd = (ICFDocument) doc;
      CFEPartitioner partitioner = (CFEPartitioner) cfd
          .getDocumentPartitioner();
      CFEPartition prevPartition = partitioner
          .getPreviousPartition(docCommand.offset);
      CFEPartition nextPartition = null;
      if (prevPartition != null) {
        nextPartition = partitioner
            .getNextPartition(prevPartition.offset);
      }
      //System.out.println("Command at offset: " + docCommand.offset);
      //System.out.println(prevPartition);
      //System.out.println(nextPartition);
      if (nextPartition != null
          && prevPartition != null) {
        if (prevPartition.getType().endsWith("start_tag_end")) {
          try {
            boolean doIndent = true;
            if (nextPartition.getType().endsWith("end_tag")
                && nextPartition.offset == docCommand.offset) {
              doIndent = false;
            }
            if (doc.getLineOfOffset(prevPartition.offset) != doc
                .getLineOfOffset(docCommand.offset)) {
              doIndent = false;
            }
            if (doIndent) {
              CFEPartition closer = partitioner
                  .getCloser(prevPartition);
              if (closer != null) {

                String prevLineWhitespace = getPrevLineWhiteSpace(
                    doc, docCommand.offset);
                docCommand.text += indentString
                    + guessNewIndentWhitespace(prevLineWhitespace);
                return;

              }
            }
          } catch (BadLocationException e) {
            //
          }
        }
       
        if (nextPartition.getType().endsWith("end_tag")
            && nextPartition.offset == docCommand.offset) {
         
          try {
            CFEPartition opener = partitioner
                .getOpener(nextPartition);

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

  boolean doIndent(IDocument doc, DocumentCommand docCommand) {

    boolean doIndent = true;
    if (doc instanceof ICFDocument && this.isUseSmartIndent()) {
      ICFDocument cfd = (ICFDocument) doc;
      CFEPartitioner partitioner = (CFEPartitioner) cfd.getDocumentPartitioner();
      CFEPartition prevPartition = partitioner.getPreviousPartition(docCommand.offset);
      CFEPartition nextPartition = null;
      if (prevPartition != null) {
        nextPartition = partitioner.getNextPartition(prevPartition.offset);
      }
      // System.out.println("Command at offset: " + docCommand.offset);
      // System.out.println(prevPartition);
      // System.out.println(nextPartition);
      if (nextPartition != null && prevPartition != null) {
View Full Code Here

   
    assistState.setOffset(offset);
    assistState.setDoc(viewer.getDocument());
    assistState.setTextViewer(viewer);

        CFEPartitioner partitioner = (CFEPartitioner)document.getDocumentPartitioner();
        CFEPartition[] partitions = partitioner.getTagPartitions(assistState.getOffset());
        if (partitions != null) {
          int start = partitions[0].getOffset();
          int end = partitions[partitions.length-1].getOffset() + partitions[partitions.length-1].getLength();
          end = assistState.getOffset();
          try {
View Full Code Here

    }
    } 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

*     our partitioner looks to be from eclipse 2 or so.

*/
//    return new FastPartitioner(
//        new CFPartitionScanner(), PartitionTypes.ALL_PARTITION_TYPES);
    return new CFEPartitioner(
        new CFPartitionScanner(), PartitionTypes.ALL_PARTITION_TYPES
      );
  }
View Full Code Here

TOP

Related Classes of org.cfeclipse.cfml.editors.partitioner.CFEPartitioner

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.