Package org.eclipse.wst.sse.core.internal.provisional.text

Examples of org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument


  }

  private void endRecording(int cursorPosition, int selectionLength) {
    IDocument doc = getDocument();
    if (doc instanceof IStructuredDocument) {
      IStructuredDocument structuredDocument = (IStructuredDocument) doc;
      IStructuredTextUndoManager undoManager = structuredDocument.getUndoManager();

      // https://bugs.eclipse.org/bugs/show_bug.cgi?id=198617
      // undo after paste in document with folds - wrong behavior
      IRegion widgetSelection = new Region(cursorPosition, selectionLength);
      IRegion documentSelection = widgetRange2ModelRange(widgetSelection);
View Full Code Here


  }

  private void beginRecording(String label, String description, int cursorPosition, int selectionLength) {
    IDocument doc = getDocument();
    if (doc instanceof IStructuredDocument) {
      IStructuredDocument structuredDocument = (IStructuredDocument) doc;
      IStructuredTextUndoManager undoManager = structuredDocument.getUndoManager();

      // https://bugs.eclipse.org/bugs/show_bug.cgi?id=198617
      // undo after paste in document with folds - wrong behavior
      IRegion widgetSelection = new Region(cursorPosition, selectionLength);
      IRegion documentSelection = widgetRange2ModelRange(widgetSelection);
View Full Code Here

    }

    super.setDocument(document, annotationModel, modelRangeOffset, modelRangeLength);

    if (document instanceof IStructuredDocument) {
      IStructuredDocument structuredDocument = (IStructuredDocument) document;

      // notify highlighter
      updateHighlighter(structuredDocument);

      // set the formatter again now that document has been set
View Full Code Here

    tempResults.addAll(fPartitionTypes);
    return (String[]) tempResults.toArray(new String[tempResults.size()]);
  }

  protected IStructuredDocument getStructuredDocument() {
    IStructuredDocument sDoc = null;
    IDocument doc = getDocument();
    if (doc instanceof IStructuredDocument)
      sDoc = (IStructuredDocument) getDocument();
    return sDoc;
  }
View Full Code Here

          }
        }
      }
    }
    if (minStart < maxEnd) {
      IStructuredDocument document = (IStructuredDocument) fSourceViewer.getDocument();
      if (document.containsReadOnly(minStart, maxEnd)) {
        Iterator nonDefaultStyleRangeIterator = textPresentation.getNonDefaultStyleRangeIterator();
        while (nonDefaultStyleRangeIterator.hasNext()) {
          StyleRange styleRange = (StyleRange) nonDefaultStyleRangeIterator.next();
          if (document.containsReadOnly(styleRange.start, styleRange.length)) {
            adjustForeground(styleRange);
          }
        }
      }
    }
View Full Code Here

    return fStructuredDocument;
  }

  private IPath getModelPath() {
    IPath path = null;
    IStructuredDocument structuredDocument = getStructuredDocument();
    if (structuredDocument != null) {
      ITextFileBuffer buffer = FileBufferModelManager.getInstance().getBuffer(structuredDocument);
      if (buffer != null) {
        path = buffer.getLocation();
      }
View Full Code Here

      // if underlying StructuredDocument changed, need to reconnect it
      // here...
      // ex. file is modified outside the workbench
      if (event.getType() == ModelLifecycleEvent.MODEL_DOCUMENT_CHANGED) {
        if (changing != null && event.getModel() == changing) {
          IStructuredDocument sDoc = event.getModel().getStructuredDocument();

          if (DEBUG) {
            System.out.println("======================================================"); //$NON-NLS-1$
            System.out.println("StructuredRegionProcessor: DOCUMENT MODEL CHANGED TO: "); //$NON-NLS-1$
            System.out.println(sDoc.get());
            System.out.println("======================================================"); //$NON-NLS-1$
          }
          setDocument(sDoc);
        }
        changing = null;
View Full Code Here

      }
      IStructuredModel model = info.fStructuredModel;
      if (model != null) {
        if (!fReuseModelDocument && element instanceof IStorageEditorInput) {
          Reader reader = null;
          IStructuredDocument innerdocument = null;
          try {
            // update document from input's contents

            CodedReaderCreator codedReaderCreator = new CodedReaderCreator(calculateID((IStorageEditorInput) element), Utilities.getMarkSupportedStream(((IStorageEditorInput) element).getStorage().getContents()));
            reader = codedReaderCreator.getCodedReader();

            innerdocument = model.getStructuredDocument();

            int originalLengthToReplace = innerdocument.getLength();

            /*
             * TODO_future: we could implement with sequential
             * rewrite, if we don't pickup automatically from
             * FileBuffer support, so not so much has to be pulled
             * into memory (as an extra big string), but we need
             * to carry that API through so that StructuredModel
             * is not notified until done.
             */

            // innerdocument.startSequentialRewrite(true);
            // innerdocument.replaceText(this, 0,
            // innerdocument.getLength(), "");
            StringBuffer stringBuffer = new StringBuffer();
            int bufferSize = 2048;
            char[] buffer = new char[bufferSize];
            int nRead = 0;
            boolean eof = false;
            while (!eof) {
              nRead = reader.read(buffer, 0, bufferSize);
              if (nRead == -1) {
                eof = true;
              }
              else {
                stringBuffer.append(buffer, 0, nRead);
                // innerdocument.replaceText(this,
                // innerdocument.getLength(), 0, new
                // String(buffer, 0, nRead));
              }
            }
            // ignore read-only settings if reverting whole
            // document
            innerdocument.replaceText(this, 0, originalLengthToReplace, stringBuffer.toString(), true);
            model.setDirtyState(false);

          }
          catch (CoreException e) {
            Logger.logException(e);
View Full Code Here

    String result = replaceText.trim();
    String preDelimiterWhitespace = ""; //$NON-NLS-1$

    IDocument jspDoc = getJspDocument();
    if (jspDoc instanceof IStructuredDocument) {
      IStructuredDocument sDoc = (IStructuredDocument) jspDoc;
      IStructuredDocumentRegion[] regions = sDoc.getStructuredDocumentRegions(0, jspPos.offset);
      IStructuredDocumentRegion lastRegion = regions[regions.length - 1];

      // only specifically modify scriptlets
      if (lastRegion != null && lastRegion.getType() == DOMJSPRegionContexts.JSP_SCRIPTLET_OPEN) {
        for (int i = regions.length - 1; i >= 0; i--) {
View Full Code Here

      if (info.fModel != null) {
        info.fModel.disconnect(info.fDocument);
      }

      Reader reader = null;
      IStructuredDocument innerdocument = null;
      try {
        // update document from input's contents
        CodedReaderCreator codedReaderCreator = new CodedReaderCreator(calculateID((IStorageEditorInput) element), Utilities.getMarkSupportedStream(((IStorageEditorInput) element).getStorage().getContents()));
        reader = codedReaderCreator.getCodedReader();

        innerdocument = (IStructuredDocument) info.fDocument;

        int originalLengthToReplace = innerdocument.getLength();

        StringBuffer stringBuffer = new StringBuffer();
        int bufferSize = 2048;
        char[] buffer = new char[bufferSize];
        int nRead = 0;
        boolean eof = false;
        while (!eof) {
          nRead = reader.read(buffer, 0, bufferSize);
          if (nRead == -1) {
            eof = true;
          }
          else {
            stringBuffer.append(buffer, 0, nRead);
          }
        }
        innerdocument.replaceText(this, 0, originalLengthToReplace, stringBuffer.toString(), true);
      }
      catch (CoreException e) {
        Logger.logException(e);
      }
      catch (IOException e) {
View Full Code Here

TOP

Related Classes of org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument

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.