Class DiffStreamSource

java.lang.Object
org.netbeans.api.diff.StreamSource
uno.anahata.asi.nb.ui.render.DiffStreamSource

public class DiffStreamSource extends org.netbeans.api.diff.StreamSource
A flexible StreamSource implementation for providing string-based content to the NetBeans Diff API. It supports optional editability and live document synchronization to trigger the Merger UI (red crosses and arrows).
Author:
anahata
  • Field Details

    • name

      private final String name
      The display name of the resource.
    • title

      private final String title
      The title to be displayed in the diff viewer pane header.
    • content

      private final String content
      The raw string content of the source.
    • mimeType

      private final String mimeType
      The MIME type of the content, used to locate the correct EditorKit.
    • document

      private Document document
      The live document associated with this source, used for synchronization.
    • editable

      private boolean editable
      Whether this source should be considered editable by the diff visualizer.
  • Constructor Details

    • DiffStreamSource

      public DiffStreamSource(String name, String title, String content, String mimeType)
      Constructs a new stream source for the NetBeans Diff API.
      Parameters:
      name - The name of the source.
      title - The title for the UI pane.
      content - The initial text content.
      mimeType - The MIME type for syntax highlighting.
  • Method Details

    • getName

      public String getName()
      Specified by:
      getName in class org.netbeans.api.diff.StreamSource
    • getTitle

      public String getTitle()
      Specified by:
      getTitle in class org.netbeans.api.diff.StreamSource
    • getMIMEType

      public String getMIMEType()
      Specified by:
      getMIMEType in class org.netbeans.api.diff.StreamSource
    • createReader

      public Reader createReader() throws IOException
      Specified by:
      createReader in class org.netbeans.api.diff.StreamSource
      Throws:
      IOException
    • createWriter

      public Writer createWriter(org.netbeans.api.diff.Difference[] conflicts) throws IOException
      Implementation details: If isEditable() returns true, this method provides a StringWriter that syncs back to the document on close. This ensures that "Merge" actions in the UI are reflected in the live document.
      Specified by:
      createWriter in class org.netbeans.api.diff.StreamSource
      Throws:
      IOException
    • isEditable

      public boolean isEditable()
      Overrides:
      isEditable in class org.netbeans.api.diff.StreamSource
    • getLookup

      public org.openide.util.Lookup getLookup()
      Overrides:
      getLookup in class org.netbeans.api.diff.StreamSource