Package kiyut.sketsa.loaders

## Class SVGEditorSupport

- java.lang.Object
- - kiyut.sketsa.loaders.SVGEditorSupport

- All Implemented Interfaces:
    `PropertyChangeListener`, `EventListener`, `SaveAsCookie`, `SVGEditorCookie`, `org.netbeans.api.actions.Closable`, `org.netbeans.api.actions.Editable`, `org.netbeans.api.actions.Openable`, `org.openide.cookies.CloseCookie`, `org.openide.cookies.EditCookie`, `org.openide.cookies.OpenCookie`, `org.openide.loaders.SaveAsCapable`, `org.openide.nodes.Node.Cookie`

      public class SVGEditorSupport
      extends Object
      implements org.openide.cookies.OpenCookie, org.openide.cookies.EditCookie, org.openide.cookies.CloseCookie, SVGEditorCookie, org.openide.loaders.SaveAsCapable, SaveAsCookie, PropertyChangeListener

  Support for associating a SVG Editor `kiyut.sketsa.windows.canvas.CanvasTopComponent CanvasTopComponent` and `SVGDocument` to a `DataObject`.
  Author:
    KIYUT

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class | Description
    --- | --- | ---
    `static class` | `SVGEditorSupport.ListenerRegistry` |
    `class` | `SVGEditorSupport.SVGDocumentLoader` | DocumentLoader Helper class
    `class` | `SVGEditorSupport.SVGRevertCookie` |
    `class` | `SVGEditorSupport.SVGSaveCookie` |

  - ### Field Summary

    Fields
    Modifier and Type | Field | Description
    --- | --- | ---
    `protected SVGDataObject` | `dataObject` |
    `protected CanvasTopComponent` | `editorTC` |
    `protected RevertCookie` | `revertCookie` |
    `protected org.openide.cookies.SaveCookie` | `saveCookie` |

  - ### Constructor Summary

    Constructors
    Constructor | Description
    --- | ---
    `SVGEditorSupport​(SVGDataObject dataObject)` |

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `protected void` | `addRevertCookie()` | Add RevertCookie in the DataObject CookieSet
    `protected void` | `addSaveCookie()` | Add SaveCookie in the DataObject CookieSet
    `protected String` | `annotateName​(String label, boolean html, boolean modified)` | Helper only for formating whether HTML (modified-bold) or normal text (modified *)
    `protected boolean` | `canClose()` |
    `boolean` | `close()` | Close and dispose the DataObject
    `protected org.openide.windows.TopComponent` | `createTopComponent()` |
    `void` | `edit()` |
    `CanvasTopComponent` | `getCanvasTopComponent()` | Get `CanvasTopComponent` for this object.
    `static SVGEditorSupport.ListenerRegistry` | `getListenerRegistry()` | Get the `SVGEditorSupport.ListenerRegistry` containing all the registered listener.
    `SVGDataObject` | `getSVGDataObject()` | Return `SVGDataObject` for this object
    `org.openide.awt.UndoRedo` | `getUndoRedo()` | Get `UndoRedo` for this object
    `VectorCanvas` | `getVectorCanvas()` | Get `VectorCanvas` for this object.
    `CanvasTopComponent` | `getVectorCanvasTopComponent()` | Deprecated.
    `boolean` | `isOpened()` | Indicates whether the editor `VectorCanvas` is opened.
    `protected String` | `messageHTMLName()` |
    `protected String` | `messageName()` |
    `protected String` | `messageOpened()` |
    `protected String` | `messageOpening()` |
    `protected String` | `messageSave()` |
    `protected String` | `messageToolTip()` |
    `void` | `open()` | This implementation also open the Document in the separate thread.
    `void` | `propertyChange​(PropertyChangeEvent evt)` |
    `protected void` | `removeRevertCookie()` | Remove RevertCookie from the DataObject CookieSet
    `protected void` | `removeSaveCookie()` | Remove SaveCookie from the DataObject CookieSet
    `void` | `revertDocument()` | Reload the SVGDocument from the source
    `void` | `saveAs()` | Implementation of saveAs, it call saveDocumentAs Invoke saveAs operation, it is up to the implementation to provide the operation eg: open JFileChooser
    `void` | `saveAs​(String path, boolean compress)` | Invoke saveAs operation based on the param
    `void` | `saveAs​(org.openide.filesystems.FileObject folder, String fileName)` |
    `protected void` | `saveDocument()` | Save Document, based on SVGDataObject.getSVGFile, if null it will call saveDocumentAs
    `protected void` | `saveDocument​(String path, boolean compress)` | Save Document
    `protected void` | `saveDocumentAs()` | Save Document As, this method will display JFileChooser
    `protected void` | `updateName​(org.openide.windows.TopComponent component)` |

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### dataObject

          protected SVGDataObject dataObject

    - #### editorTC

          protected CanvasTopComponent editorTC

    - #### saveCookie

          protected org.openide.cookies.SaveCookie saveCookie

    - #### revertCookie

          protected RevertCookie revertCookie

  - ### Constructor Detail

    - #### SVGEditorSupport

          public SVGEditorSupport​(SVGDataObject dataObject)

  - ### Method Detail

    - #### getVectorCanvas

          public VectorCanvas getVectorCanvas()

      Description copied from interface: `SVGEditorCookie`
      Get `VectorCanvas` for this object.
      Specified by:
        `getVectorCanvas` in interface `SVGEditorCookie`
      Returns:
        `VectorCanvas` or `null`

    - #### getVectorCanvasTopComponent

          @Deprecated
          public CanvasTopComponent getVectorCanvasTopComponent()

      Deprecated.
      Description copied from interface: `SVGEditorCookie`
      Get `CanvasTopComponent` for this object.
      Specified by:
        `getVectorCanvasTopComponent` in interface `SVGEditorCookie`
      Returns:
        `CanvasTopComponent` or `null`

    - #### getCanvasTopComponent

          public CanvasTopComponent getCanvasTopComponent()

      Description copied from interface: `SVGEditorCookie`
      Get `CanvasTopComponent` for this object.
      Specified by:
        `getCanvasTopComponent` in interface `SVGEditorCookie`
      Returns:
        `CanvasTopComponent` or `null`

    - #### getUndoRedo

          public org.openide.awt.UndoRedo getUndoRedo()

      Description copied from interface: `SVGEditorCookie`
      Get `UndoRedo` for this object
      Specified by:
        `getUndoRedo` in interface `SVGEditorCookie`
      Returns:
        `UndoRedo`

    - #### isOpened

          public boolean isOpened()

      Description copied from interface: `SVGEditorCookie`
      Indicates whether the editor `VectorCanvas` is opened.
      Specified by:
        `isOpened` in interface `SVGEditorCookie`
      Returns:
        true/false

    - #### getSVGDataObject

          public SVGDataObject getSVGDataObject()

      Description copied from interface: `SVGEditorCookie`
      Return `SVGDataObject` for this object
      Specified by:
        `getSVGDataObject` in interface `SVGEditorCookie`
      Returns:
        `SVGDataObject`

    - #### saveAs

          public void saveAs()
                      throws IOException

      Implementation of saveAs, it call saveDocumentAs Invoke saveAs operation, it is up to the implementation to provide the operation eg: open JFileChooser
      Specified by:
        `saveAs` in interface `SaveAsCookie`
      Throws:
        `IOException` - if an I/O error occured
      See Also:
        `saveDocumentAs()`

    - #### saveAs

          public void saveAs​(String path,
                             boolean compress)
                      throws IOException

      Description copied from interface: `SaveAsCookie`
      Invoke saveAs operation based on the param
      Specified by:
        `saveAs` in interface `SaveAsCookie`
      Parameters:
        `path` - absolute path
        `compress` - true or false
      Throws:
        `IOException` - if an I/O error occured

    - #### saveAs

          public void saveAs​(org.openide.filesystems.FileObject folder,
                             String fileName)
                      throws IOException

      Specified by:
        `saveAs` in interface `org.openide.loaders.SaveAsCapable`
      Throws:
        `IOException`

    - #### open

          public void open()

      This implementation also open the Document in the separate thread.
      Specified by:
        `open` in interface `org.netbeans.api.actions.Openable`

    - #### edit

          public void edit()

      Specified by:
        `edit` in interface `org.netbeans.api.actions.Editable`

    - #### revertDocument

          public void revertDocument()

      Reload the SVGDocument from the source
      See Also:
        `open()`, `edit()`

    - #### createTopComponent

          protected org.openide.windows.TopComponent createTopComponent()

    - #### messageOpening

          protected String messageOpening()

    - #### messageOpened

          protected String messageOpened()

    - #### messageSave

          protected String messageSave()

    - #### messageName

          protected String messageName()

    - #### messageHTMLName

          protected String messageHTMLName()

    - #### annotateName

          protected String annotateName​(String label,
                                        boolean html,
                                        boolean modified)

      Helper only for formating whether HTML (modified-bold) or normal text (modified *)
      Parameters:
        `label` - the name or label to annotate
        `html` - flag for output is HTML or not
        `modified` - flag true or false indicated modified
      Returns:
        the annotateName

    - #### messageToolTip

          protected String messageToolTip()

    - #### propertyChange

          public void propertyChange​(PropertyChangeEvent evt)

      Specified by:
        `propertyChange` in interface `PropertyChangeListener`

    - #### updateName

          protected void updateName​(org.openide.windows.TopComponent component)

    - #### saveDocument

          protected void saveDocument()
                               throws IOException

      Save Document, based on SVGDataObject.getSVGFile, if null it will call saveDocumentAs
      Throws:
        `IOException` - if an I/O error occured
      See Also:
        `saveDocumentAs()`, `saveDocument(String, boolean)`

    - #### saveDocumentAs

          protected void saveDocumentAs()
                                 throws IOException

      Save Document As, this method will display JFileChooser
      Throws:
        `IOException` - if an I/O error occured
      See Also:
        `saveDocument(String, boolean)`

    - #### saveDocument

          protected void saveDocument​(String path,
                                      boolean compress)
                               throws IOException

      Save Document
      Parameters:
        `path` - absolute path
        `compress` - `true` or `false`
      Throws:
        `IOException` - if an I/O error occured

    - #### addSaveCookie

          protected void addSaveCookie()

      Add SaveCookie in the DataObject CookieSet
      See Also:
        `removeSaveCookie()`

    - #### removeSaveCookie

          protected void removeSaveCookie()

      Remove SaveCookie from the DataObject CookieSet
      See Also:
        `addSaveCookie()`

    - #### addRevertCookie

          protected void addRevertCookie()

      Add RevertCookie in the DataObject CookieSet
      See Also:
        `removeRevertCookie()`

    - #### removeRevertCookie

          protected void removeRevertCookie()

      Remove RevertCookie from the DataObject CookieSet
      See Also:
        `addRevertCookie()`

    - #### canClose

          protected boolean canClose()

    - #### close

          public boolean close()

      Close and dispose the DataObject
      Specified by:
        `close` in interface `org.netbeans.api.actions.Closable`

    - #### getListenerRegistry

          public static SVGEditorSupport.ListenerRegistry getListenerRegistry()

      Get the `SVGEditorSupport.ListenerRegistry` containing all the registered listener.
      Returns:
        the ListenerRegistry