From: <chr...@us...> - 2006-08-27 15:57:51
|
Revision: 287 Author: christianhujer Date: 2006-08-27 08:57:43 -0700 (Sun, 27 Aug 2006) ViewCVS: http://svn.sourceforge.net/gridarta/?rev=287&view=rev Log Message: ----------- File when saving a map must not be null. Modified Paths: -------------- trunk/crossfire/src/cfeditor/CMainControl.java trunk/crossfire/src/cfeditor/CMapFileEncode.java trunk/crossfire/src/cfeditor/map/MapControl.java Modified: trunk/crossfire/src/cfeditor/CMainControl.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainControl.java 2006-08-27 15:53:13 UTC (rev 286) +++ trunk/crossfire/src/cfeditor/CMainControl.java 2006-08-27 15:57:43 UTC (rev 287) @@ -60,6 +60,7 @@ import net.sf.japi.util.filter.file.EndingFileFilter; import org.apache.log4j.Logger; import org.jetbrains.annotations.Nullable; +import org.jetbrains.annotations.NotNull; /** * The main controller of the level editor. Basically the main application. @@ -1020,7 +1021,7 @@ * @param file File to save to * @param mapModel MapModel to save */ - public void encodeMapFile(final File file, final MapModel mapModel) { + public void encodeMapFile(@NotNull final File file, final MapModel mapModel) { mapFileEncoder.encodeMapFile(file, mapModel); } @@ -1134,6 +1135,7 @@ if (returnVal == JFileChooser.APPROVE_OPTION) { hasChangedDir = true; // user has chosen an active dir final File file = fileChooser.getSelectedFile(); + assert file != null; level.saveAs(file); level.setMapFileName(file.getName()); // window title and file name //level.setMapName(file.getName()); // map name (internal) Modified: trunk/crossfire/src/cfeditor/CMapFileEncode.java =================================================================== --- trunk/crossfire/src/cfeditor/CMapFileEncode.java 2006-08-27 15:53:13 UTC (rev 286) +++ trunk/crossfire/src/cfeditor/CMapFileEncode.java 2006-08-27 15:57:43 UTC (rev 287) @@ -41,6 +41,7 @@ import java.util.Iterator; import net.sf.gridarta.Size2D; import org.apache.log4j.Logger; +import org.jetbrains.annotations.NotNull; /** * The <code>CMapFileEncode</code> @@ -69,15 +70,10 @@ * @param file mapfile * @param mapModel the MapModel to encode */ - public void encodeMapFile(File file, final MapModel mapModel) { + public void encodeMapFile(@NotNull final File file, final MapModel mapModel) { final MapArchObject map = mapModel.getMapArchObject(); try { - if (file == null) { - // if the file doesn't yet exist, we create it in the map-folder - file = new File(mainControl.getMapDefaultFolder(), map.getFileName()); - } - fname = file.getAbsolutePath(); fileWriter = new FileWriter(file); bufferedWriter = new BufferedWriter(fileWriter); Modified: trunk/crossfire/src/cfeditor/map/MapControl.java =================================================================== --- trunk/crossfire/src/cfeditor/map/MapControl.java 2006-08-27 15:53:13 UTC (rev 286) +++ trunk/crossfire/src/cfeditor/map/MapControl.java 2006-08-27 15:57:43 UTC (rev 287) @@ -39,6 +39,7 @@ import java.util.Iterator; import java.util.List; import net.sf.gridarta.Size2D; +import org.jetbrains.annotations.NotNull; /** * The <code>MapControl</code> @@ -571,6 +572,7 @@ } else { CMainStatusbar.getInstance().setText("Saving map '" + getMapFileName() + "'..."); } + assert mapFile != null; mainControl.encodeMapFile(mapFile, mapModel); mapModel.resetLevelChangedFlag(); mapView.changedFlagNotify(); @@ -580,7 +582,7 @@ * Save the file with the given file name. * @param file the file to be saved to */ - public void saveAs(final File file) { + public void saveAs(@NotNull final File file) { CMainStatusbar.getInstance().setText("Saving the map to a file..."); mainControl.encodeMapFile(file, mapModel); mapModel.resetLevelChangedFlag(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |