Package edu.wpi.grip.core.serialization
Class Project
- java.lang.Object
-
- edu.wpi.grip.core.serialization.Project
-
@Singleton public class Project extends java.lang.ObjectHelper for saving and loading a processing pipeline to and from a file.
-
-
Field Summary
Fields Modifier and Type Field Description protected com.thoughtworks.xstream.XStreamxstream
-
Constructor Summary
Constructors Constructor Description Project()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddIsSaveDirtyConsumer(java.util.function.Consumer<java.lang.Boolean> consumer)java.util.Optional<java.io.File>getFile()voidinitialize(StepConverter stepConverter, SourceConverter sourceConverter, SocketConverter socketConverter, ConnectionConverter connectionConverter, ProjectSettingsConverter projectSettingsConverter, CodeGenerationSettingsConverter codeGenerationSettingsConverter)booleanisSaveDirty()voidonDirtiesSaveEvent(DirtiesSaveEvent dirtySaveEvent)voidopen(java.io.File file)Load the project from a file.voidopen(java.lang.String projectXml)Loads the project defined by the given XML string.voidsave(java.io.File file)Save the project to a file.voidsave(java.io.Writer writer)voidsetFile(java.util.Optional<java.io.File> file)booleantrySave(java.io.File file)Tries to save this project to the given file.
-
-
-
Method Detail
-
initialize
@Inject public void initialize(StepConverter stepConverter, SourceConverter sourceConverter, SocketConverter socketConverter, ConnectionConverter connectionConverter, ProjectSettingsConverter projectSettingsConverter, CodeGenerationSettingsConverter codeGenerationSettingsConverter)
-
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.IOExceptionLoad 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. Unlikesave(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.IOExceptionSave 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)
-
-