check file permission before using auto-save

This commit is contained in:
bancika
2011-08-26 18:31:36 +00:00
parent bea19f326c
commit 7d3a7c30ca
2 changed files with 23 additions and 1 deletions
@@ -8,6 +8,10 @@ import java.awt.event.ActionEvent;
import java.awt.event.ActionListener; import java.awt.event.ActionListener;
import java.awt.event.WindowAdapter; import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent; import java.awt.event.WindowEvent;
import java.io.File;
import java.io.FileOutputStream;
import java.io.OutputStreamWriter;
import java.io.Writer;
import java.util.Arrays; import java.util.Arrays;
import java.util.EnumSet; import java.util.EnumSet;
import java.util.HashMap; import java.util.HashMap;
@@ -101,7 +105,21 @@ public class MainFrame extends JFrame implements ISwingUI {
canvasPlugin = new CanvasPlugin(this); canvasPlugin = new CanvasPlugin(this);
presenter.installPlugin(canvasPlugin); presenter.installPlugin(canvasPlugin);
presenter.installPlugin(new FramePlugin()); presenter.installPlugin(new FramePlugin());
try {
File testFile = new File("test.tmp");
Writer out = new OutputStreamWriter(new FileOutputStream(testFile));
out.write("This is a test");
out.close();
testFile.delete();
presenter.installPlugin(new AutoSavePlugin(this)); presenter.installPlugin(new AutoSavePlugin(this));
} catch (Exception e) {
showMessage(
"The current user does not have permissions to access folder "
+ new File(".").getAbsolutePath()
+ ".\nAuto-save feature will not be available, contact your system administrator.",
"Warning", IView.WARNING_MESSAGE);
}
presenter.createNewProject(); presenter.createNewProject();
@@ -334,6 +334,10 @@
<changeType>IMPROVEMENT</changeType> <changeType>IMPROVEMENT</changeType>
<description>Auto-increment component names when copy-pasting</description> <description>Auto-increment component names when copy-pasting</description>
</com.diyfever.gui.update.Change> </com.diyfever.gui.update.Change>
<com.diyfever.gui.update.Change>
<changeType>IMPROVEMENT</changeType>
<description>Do not attempt to write auto-save files if user does not have permissions to create files</description>
</com.diyfever.gui.update.Change>
<com.diyfever.gui.update.Change> <com.diyfever.gui.update.Change>
<changeType>IMPROVEMENT</changeType> <changeType>IMPROVEMENT</changeType>
<description>Allow zero ohm resistors</description> <description>Allow zero ohm resistors</description>