Package org.cfeclipse.cfml.editors

Examples of org.cfeclipse.cfml.editors.CFMLEditor


  public void run() {

    // Get the editor, and the various bits we need such as the document,
    // the selection and the shell
    IEditorPart activeEditor = Workbench.getInstance().getActiveWorkbenchWindow().getActivePage().getActiveEditor();
    CFMLEditor thisEdit = (CFMLEditor) activeEditor;
    IDocument doc = thisEdit.getDocumentProvider().getDocument(thisEdit.getEditorInput());
    ISelection sel = thisEdit.getSelectionProvider().getSelection();
    DocItem docItem = thisEdit.getSelectionCursorListener().getSelectedTag();
    if (docItem != null && docItem instanceof CfmlTagItem) {
      CfmlTagItem tagItem = (CfmlTagItem) docItem;

      int tagStart = tagItem.getStartPosition();
      int tagEnd = tagItem.getEndPosition();
      TextSelection selection;
      int startPos = tagItem.getStartPosition();
      int endPos = tagItem.getEndPosition();
      int start = 0;
      int length = 0;
      if(tagItem.matchingItem != null) {       
        if (tagItem.matchingItem.getStartPosition() < tagItem.getStartPosition()) {
          start = tagItem.matchingItem.getStartPosition();
          length = tagItem.getEndPosition() - tagItem.matchingItem.getStartPosition() + 1;
        } else {
          start = tagItem.getStartPosition();
          length = tagItem.matchingItem.getEndPosition() - tagItem.getStartPosition() + 1;
        }
      } else {
        if (tagItem.matchingItem != null && tagItem.matchingItem.getStartPosition() <= startPos
            && tagItem.matchingItem.getEndPosition() >= startPos) {
          start = tagItem.matchingItem.getStartPosition();
          length = tagItem.matchingItem.getEndPosition() - tagItem.matchingItem.getStartPosition() + 1;
        } else {
          start = tagItem.getStartPosition();
          length = tagItem.getEndPosition() - tagItem.getStartPosition() + 1;
        }       
      }
      // thisEdit.selectAndReveal(tagStart,tagEnd-tagStart+1);
      selection = new TextSelection(start, length);
      ISelectionProvider selectionProvider = thisEdit.getSelectionProvider();
      selectionProvider.setSelection(selection);

      /*
       * Get the actual textual content of the tag
       */
      String tagText = "";
      try {

        tagText = doc.get(selection.getOffset(), selection.getLength());
      } catch (BadLocationException e1) {
        // TODO Auto-generated catch block
        e1.printStackTrace();
      }

      /*
       * Get the attributes as a map TODO: I am not sure if map's keep the
       * ordering... need to check this
       */
      Map attributeMap = CFDocUtils.parseStartTag(tagItem.getName(), tagText);

      /*
       * Now open the TagEditDialog, we know the tag name (as a string)
       * and the tag attributes (as a map) So, we go and get the tag from
       * the dictionary
       */
      Tag tagToEdit = DictionaryManager.getDictionary("CF_DICTIONARY").getTag(tagItem.getName());

      /*
       * Setup the tageditor dialog
       */
      TagEditDialog tagview = new TagEditDialog(shell, tagToEdit);
      tagview.setSelectedattributes(attributeMap);

      /*
       * Once the editor closes, we do this
       */
      if (tagview.open() == IDialogConstants.OK_ID) {
        Properties fieldStore = tagview.getFieldStore(); // The new
                                  // items
        ArrayList propOrder = new ArrayList(); // The order of the itmes
        Properties attributesToRender = new Properties(); // The
                                  // attributes
                                  // that we
                                  // are going
                                  // to be
                                  // formatting

        // Put the original attributes in
        Set oldFieldSet = attributeMap.keySet();
        for (Iterator iter = oldFieldSet.iterator(); iter.hasNext();) {
          String oldElement = (String) iter.next();
          propOrder.add(oldElement);

        }
        attributesToRender.putAll(attributeMap);

        // Loop through the new ones
        Set newFieldsSet = fieldStore.keySet();
        for (Iterator iter = newFieldsSet.iterator(); iter.hasNext();) {
          String element = (String) iter.next();

          if (attributesToRender.containsKey(element)) {
            attributesToRender.setProperty(element, fieldStore.getProperty(element));
          } else {
            propOrder.add(element);
            attributesToRender.put(element, fieldStore.getProperty(element));
          }
        }

        /*
         * Pass in the attributes into a Tag Formatter
         */
        TagFormatter tf = new TagFormatter(tagToEdit, attributesToRender, propOrder);

        // Here is where we actually do the insertion

        if (thisEdit instanceof ITextEditor) {
          try {
            ICFDocument cfd = (ICFDocument) doc;
            cfd.replace(selection.getOffset(), selection.getLength(), tf.getTagStart());
          } catch (BadLocationException e) {
            e.printStackTrace();
          }
          thisEdit.setFocus();
        }
      }
    }

  }
View Full Code Here


    // this fires when editor is changed (thanks to addPostSelection in
    // createControl)
    if (selection != null && selection instanceof ITextSelection) {
      IEditorPart curEditor = workbench.getSite().getWorkbenchWindow().getActivePage().getActiveEditor();
      if (curEditor != null && curEditor instanceof CFMLEditor) {
        CFMLEditor curDoc = (CFMLEditor) curEditor;
        DocItem tagItem = curDoc.getSelectionCursorListener().getSelectedTag();
        if (tagItem != null) {
          setSelectedDocItem(tagItem);
        }
      }
    }
View Full Code Here

     
    boolean bAutoload = CFMLPlugin.getDefault().getPreferenceStore().getBoolean("CFUnitAutoload");
   
    if(bAutoload) {
      if(targetEditor instanceof CFMLEditor) {
        CFMLEditor cfe = (CFMLEditor)targetEditor;
       
        String tc = retrieveTestCase( cfe );
       
        if(tc != null) {
          CFUnitTestSuite.getInstence().setTest( tc );
View Full Code Here

  }

  public void partActivated(IWorkbenchPart part) {
    if(part instanceof CFMLEditor){
     
      CFMLEditor openEditor =(CFMLEditor)part;
      openEditor.setStatusLine();
    }
  }
View Full Code Here

  }

  public void partBroughtToTop(IWorkbenchPart part) {
    if(part instanceof CFMLEditor){
     
      CFMLEditor openEditor =(CFMLEditor)part;
      openEditor.setStatusLine();
    }
   
  }
View Full Code Here

  }

  public void partOpened(IWorkbenchPart part) {
    if(part instanceof CFMLEditor){
     
      CFMLEditor openEditor =(CFMLEditor)part;
      openEditor.setStatusLine();
    }
   
   
  }
View Full Code Here

    return result;
  }
   
  private Control createPreviewer(Composite parent) {
    fPreviewViewer = new SourceViewer(parent, null, null, false, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL);
        fEditor = new CFMLEditor();
        ColorManager colorMan = new ColorManager();
    CFConfiguration configuration = new CFConfiguration(colorMan,fEditor);
 
    fPreviewViewer.configure(configuration);
    fPreviewViewer.setEditable(false)
View Full Code Here

      IEditorPart part =  IDE.openEditor(page, file, true);
      if(!(part instanceof CFMLEditor))
        return;
     
      //CFMLEditor cfEditor = (CFMLEditor)part;#
      CFMLEditor cfEditor = (CFMLEditor)part.getSite().getPage().getActiveEditor();
      IEditorInput editorInput = cfEditor.getEditorInput();
      IDocumentProvider docProvider = cfEditor.getDocumentProvider();
      IDocument doc = docProvider.getDocument(editorInput);
      if(!(doc instanceof ICFDocument))
        return;
       
      ICFDocument cfDoc = (ICFDocument)doc;
     
      CFDocument parseResult = cfDoc.getParser().parseDoc();
      if(parseResult == null)
        return;
     
      CFNodeList methods = parseResult.getDocumentRoot().selectNodes("//cffunction");
      Iterator methodIter = methods.iterator();
      while(methodIter.hasNext())
      {
        CfmlTagItem item = (CfmlTagItem)methodIter.next();
       
        String methodName = item.getAttributeValue("name");
        if(methodName.toLowerCase().equals(this.methodName.toLowerCase()))
        {
          /*
           *   ite.setHighlightRange(selectedMethod.getDocumentOffset(),0,true);
        ite.setFocus();
           */
          cfEditor.setHighlightRange(item.getStartPosition(), 0, true);
          cfEditor.setFocus();
        }
      }
    }
    catch (PartInitException e)
    {
View Full Code Here

   */
  public void run() {
    fStore.setValue(TextSelectionPreferenceConstants.P_MARK_OCCURRENCES, isChecked());
    ITextEditor editor= getTextEditor();
    if (editor instanceof CFMLEditor) {
      CFMLEditor cfe = (CFMLEditor) editor;
      if(isChecked()) {       
        (cfe).getSelectionCursorListener().updateOccurrenceAnnotations((ITextSelection) cfe.getSelectionProvider().getSelection(), cfe.getCFModel());
      } else {
        (cfe).getSelectionCursorListener().removeOccurrenceAnnotations();       
      }
    }
  }
View Full Code Here

TOP

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

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.