Class ExportManager
- java.lang.Object
-
- pulse.io.export.ExportManager
-
public class ExportManager extends Object
Manages export operations. Provides tools to find a specific exporter suitable for a given target and shortcuts for export operations.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <T extends Descriptive>
voidaskToExport(T target, JFrame parentWindow, String fileTypeLabel)Finds an exporter matching totargetand allows the user to select the location of export.static <T extends Descriptive>
voidexport(T target, File directory, Extension extension)Attempts to export the giventargetto thedirectoryby saving the contents in a file with the givenExtension.static voidexportAllResults(File directory, Extension extension)Exports all results generated previously during task execution for all tasks listed by the TaskManager, provided those tasks had the respective result assigned to them.static voidexportAllTasks(File directory, Extension extension)This will invokeexportGroupon each task listed by theTaskManager.static voidexportCurrentTask(File directory)Exports the currently selected task as a group of objects using the default export extension.static voidexportCurrentTask(File directory, Extension extension)Exports the currently selected task as a group of objects.static voidexportGroup(Group group, File directory, Extension extension)Fully exportsgroupand all its contents to the rootdirectoryrequesting the files to be saved with theextension.static <T extends Descriptive>
Exporter<T>findExporter(Class<T> target)Finds an exporter that can work withtarget.static <T extends Descriptive>
Exporter<T>findExporter(T target)Finds a suitable exporter for a non-nulltargetby callingfindExporter(target.getClass()).
-
-
-
Method Detail
-
findExporter
public static <T extends Descriptive> Exporter<T> findExporter(T target)
Finds a suitable exporter for a non-nulltargetby callingfindExporter(target.getClass()).- Type Parameters:
T- an instance ofDescriptive- Parameters:
target- the exported target- Returns:
- an exporter that works for
target - See Also:
<T>findExporter(T)
-
findExporter
public static <T extends Descriptive> Exporter<T> findExporter(Class<T> target)
Finds an exporter that can work withtarget.Searches through available instances of the
Exporterclass contained in this package and checks if any of those have their target set to the argument of this method, then returns the first occurrence. If nothing matches exactly the same class as specified, searches for exporters of any classes assignable fromtarget.- Type Parameters:
T- an instance ofDescriptive- Parameters:
target- the target glass- Returns:
- an instance of the Exporter class that can work worth the type T, null if nothing has been found
-
askToExport
public static <T extends Descriptive> void askToExport(T target, JFrame parentWindow, String fileTypeLabel)
Finds an exporter matching totargetand allows the user to select the location of export.- Type Parameters:
T- aDescriptivetype- Parameters:
target- the target to be exportedparentWindow- a frame to which the file chooser dialog will be attachedfileTypeLabel- a brief description of the exported file types- Throws:
IllegalArgumentException- if no exporter can be found- See Also:
<T>findExporter(T)
-
export
public static <T extends Descriptive> void export(T target, File directory, Extension extension)
Attempts to export the giventargetto thedirectoryby saving the contents in a file with the givenExtension.The file is formatted according to the inherent format, i.e. if it is an
Extension.HTMLfile, it will contain HTML tags, etc. Ifextensionis not present in the list of supported extension of an exporter matchingtarget, this will revert to the first supported extension. This method will not have any result if no exporter has been found fottarget.- Type Parameters:
T- the target type- Parameters:
target- the exported targetdirectory- a pre-selected directoryextension- the desired extension
-
exportAllTasks
public static void exportAllTasks(File directory, Extension extension)
This will invokeexportGroupon each task listed by theTaskManager.- Parameters:
directory- a pre-selected directoryextension- the desired extension- See Also:
exportGroup(pulse.util.Group,java.io.File,pulse.io.export.Extension),TaskManager
-
exportCurrentTask
public static void exportCurrentTask(File directory, Extension extension)
Exports the currently selected task as a group of objects.- Parameters:
directory- a pre-selected directoryextension- the desired extension- See Also:
exportGroup(pulse.util.Group,java.io.File,pulse.io.export.Extension)
-
exportCurrentTask
public static void exportCurrentTask(File directory)
Exports the currently selected task as a group of objects using the default export extension.- Parameters:
directory- a pre-selected directory- See Also:
exportGroup(pulse.util.Group,java.io.File,pulse.io.export.Extension)
-
exportAllResults
public static void exportAllResults(File directory, Extension extension)
Exports all results generated previously during task execution for all tasks listed by the TaskManager, provided those tasks had the respective result assigned to them.- Parameters:
directory- a pre-selected directoryextension- the desired extension
-
exportGroup
public static void exportGroup(Group group, File directory, Extension extension)
Fully exportsgroupand all its contents to the rootdirectoryrequesting the files to be saved with theextension.If an
Exporterexists that accepts thegroupas its argument, this will create files in the rootdirectoryin accordance to the rootExporterrules. All contents of thegroupwill then be processed in a similar manner and the output will be stored in an internal directory, the name of which conforms to the respective description. Note this method is NOT recursive and it calls theexportmethod of theExportManager.- Parameters:
group- a groupdirectory- a pre-selected root directoryextension- the desired extension- Throws:
IllegalArgumentException- ifdirectoryis not a directory
-
-