Class Project


  • @Singleton
    public class Project
    extends java.lang.Object
    Helper for saving and loading a processing pipeline to and from a file.
    • Field Detail

      • xstream

        protected final com.thoughtworks.xstream.XStream xstream
    • Constructor Detail

      • Project

        public Project()
    • Method Detail

      • getFile

        public java.util.Optional<java.io.File> getFile()
        Returns:
        The file that this project is located in, if it was loaded from/saved to a file.
      • setFile

        public void setFile​(java.util.Optional<java.io.File> file)
      • open

        public void open​(java.io.File file)
                  throws java.io.IOException
        Load the project from a file.
        Throws:
        java.io.IOException - if the project file could not be read
      • open

        public void open​(java.lang.String projectXml)
        Loads the project defined by the given XML string. This is intended to be used to be able to programmatically run a pipeline from a remote source. Therefore, this does not save the contents to disk; if it is called in GUI mode, the user will have to manually save the file.
        Parameters:
        projectXml - the XML string defining the project to open
      • trySave

        public boolean trySave​(java.io.File file)
        Tries to save this project to the given file. Unlike save(File), this will not throw an IOException and will instead post a warning event to the event bus.
        Parameters:
        file - the file to save to
        Returns:
        true if the project was successfully saved to the given file, or false if the file could not be written to
      • save

        public void save​(java.io.File file)
                  throws java.io.IOException
        Save the project to a file.
        Throws:
        java.io.IOException - if the file could not written
      • save

        public void save​(java.io.Writer writer)
      • isSaveDirty

        public boolean isSaveDirty()
      • addIsSaveDirtyConsumer

        public void addIsSaveDirtyConsumer​(java.util.function.Consumer<java.lang.Boolean> consumer)
      • onDirtiesSaveEvent

        public void onDirtiesSaveEvent​(DirtiesSaveEvent dirtySaveEvent)