Skip to content

Commit

Permalink
fix: setLastDirectory more often where appropriate
Browse files Browse the repository at this point in the history
  • Loading branch information
bogovicj committed Nov 7, 2024
1 parent bcf6b1a commit b7e566b
Showing 1 changed file with 19 additions and 11 deletions.
30 changes: 19 additions & 11 deletions src/main/java/bigwarp/BigWarp.java
Original file line number Diff line number Diff line change
Expand Up @@ -4012,10 +4012,17 @@ protected void saveLandmarks()

protected void saveLandmarks( final String filename ) throws IOException
{
if( filename.endsWith("csv"))
landmarkModel.save(new File( filename ));
else if( filename.endsWith("json"))
TransformWriterJson.write(landmarkModel, bwTransform, new File( filename ));
final File f = new File( filename );
if( filename.endsWith("csv")) {
landmarkModel.save( f );
setLastDirectory(f.getParentFile());
}
else if( filename.endsWith("json")) {
TransformWriterJson.write(landmarkModel, bwTransform, f);
setLastDirectory(f.getParentFile());
}

// TODO message to users if neither case succeeds
}

protected void loadLandmarks()
Expand Down Expand Up @@ -4051,7 +4058,6 @@ public void loadLandmarks( final String filename )
catch ( URISyntaxException e ) { }

final File file = new File( name );
setLastDirectory( file.getParentFile() );
if( name.endsWith( "csv" ))
{
try
Expand All @@ -4068,6 +4074,8 @@ else if( name.endsWith( "json" ))
TransformWriterJson.read( file, this );
}

setLastDirectory( file.getParentFile() );

final boolean didCompute = restimateTransformation();

// didCompute = false means that there were not enough points
Expand Down Expand Up @@ -4109,13 +4117,11 @@ protected void saveSettingsOrProject( final File proposedFile )
{
final String canonicalPath = settingsFile.getCanonicalPath();
if ( canonicalPath.endsWith( ".xml" ) )
{
saveSettings( canonicalPath );
}
saveSettings(canonicalPath);
else
{
saveSettingsJson( canonicalPath );
}
saveSettingsJson(canonicalPath);

setLastDirectory(settingsFile.getParentFile());
}
catch ( final IOException e )
{
Expand Down Expand Up @@ -4343,6 +4349,8 @@ public void loadSettings( final String jsonOrXmlFilename, boolean overwriteSourc
activeSourcesDialogQ.update();
}

setLastDirectory(new File(jsonOrXmlFilename).getParentFile());

viewerFrameP.repaint();
viewerFrameQ.repaint();
}
Expand Down

0 comments on commit b7e566b

Please sign in to comment.