Skip to content

Commit

Permalink
Execute "Save Project" and "Save Project As" in a separate thread.
Browse files Browse the repository at this point in the history
  • Loading branch information
maarzt authored and tinevez committed Jan 8, 2024
1 parent 4e3672e commit a8654a3
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions src/main/java/org/mastodon/mamut/io/ProjectActions.java
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,8 @@ public static void installGlobalActions( final Actions actions, final Context co
*/
public static void installAppActions( final Actions actions, final ProjectModel appModel, final Frame parentComponent )
{
final RunnableAction saveProjectAction = new RunnableAction( SAVE_PROJECT, () -> ProjectSaver.saveProject( appModel, parentComponent ) );
final RunnableAction saveProjectAsAction = new RunnableAction( SAVE_PROJECT_AS, () -> ProjectSaver.saveProjectAs( appModel, parentComponent ) );
final RunnableAction saveProjectAction = new RunnableAction( SAVE_PROJECT, runInNewThread( () -> ProjectSaver.saveProject( appModel, parentComponent ) ) );
final RunnableAction saveProjectAsAction = new RunnableAction( SAVE_PROJECT_AS, runInNewThread( () -> ProjectSaver.saveProjectAs( appModel, parentComponent ) ) );
final RunnableAction importTgmmAction = new RunnableAction( IMPORT_TGMM, () -> ProjectImporter.importTgmmDataWithDialog( appModel, parentComponent ) );
final RunnableAction importSimiAction = new RunnableAction( IMPORT_TGMM, () -> ProjectImporter.importSimiDataWithDialog( appModel, parentComponent ) );
final RunnableAction exportMamutAction = new RunnableAction( EXPORT_MAMUT, () -> ProjectExporter.exportMamut( appModel, parentComponent ) );
Expand All @@ -123,6 +123,22 @@ public static void installAppActions( final Actions actions, final ProjectModel
actions.namedAction( exportMamutAction, EXPORT_MAMUT_KEYS );
}

private static Runnable runInNewThread( Runnable o )
{
return () -> {
new Thread( () -> {
try
{
o.run();
}
catch ( Throwable t )
{
t.printStackTrace();
}
} ).start();
};
}

/*
* Command descriptions for all provided commands
*/
Expand Down

0 comments on commit a8654a3

Please sign in to comment.