mirror of
https://github.com/AppleCommander/AppleCommander.git
synced 2024-12-22 08:30:35 +00:00
The disk image may now be saved if changes have occurred.
This commit is contained in:
parent
73f8e7974d
commit
b180c501b9
@ -21,6 +21,7 @@ package com.webcodepro.applecommander.ui.swt;
|
|||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileOutputStream;
|
import java.io.FileOutputStream;
|
||||||
|
import java.io.IOException;
|
||||||
import java.io.OutputStream;
|
import java.io.OutputStream;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
@ -82,6 +83,7 @@ public class DiskExplorerTab {
|
|||||||
private ToolItem exportToolItem;
|
private ToolItem exportToolItem;
|
||||||
private ToolItem importToolItem;
|
private ToolItem importToolItem;
|
||||||
private ToolItem deleteToolItem;
|
private ToolItem deleteToolItem;
|
||||||
|
private ToolItem saveToolItem;
|
||||||
private ImageManager imageManager;
|
private ImageManager imageManager;
|
||||||
|
|
||||||
private UserPreferences userPreferences = UserPreferences.getInstance();
|
private UserPreferences userPreferences = UserPreferences.getInstance();
|
||||||
@ -798,14 +800,14 @@ public class DiskExplorerTab {
|
|||||||
});
|
});
|
||||||
item = new ToolItem(toolBar, SWT.SEPARATOR);
|
item = new ToolItem(toolBar, SWT.SEPARATOR);
|
||||||
|
|
||||||
item = new ToolItem(toolBar, SWT.PUSH);
|
saveToolItem = new ToolItem(toolBar, SWT.PUSH);
|
||||||
item.setImage(imageManager.getSaveImageIcon());
|
saveToolItem.setImage(imageManager.getSaveImageIcon());
|
||||||
item.setText("Save");
|
saveToolItem.setText("Save");
|
||||||
item.setToolTipText("Save disk image");
|
saveToolItem.setToolTipText("Save disk image");
|
||||||
item.setEnabled(false);
|
saveToolItem.setEnabled(disk.hasChanged());
|
||||||
item.addSelectionListener(new SelectionAdapter () {
|
saveToolItem.addSelectionListener(new SelectionAdapter () {
|
||||||
public void widgetSelected(SelectionEvent e) {
|
public void widgetSelected(SelectionEvent e) {
|
||||||
// not available yet
|
save();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -833,4 +835,29 @@ public class DiskExplorerTab {
|
|||||||
fillFileTable(fileList);
|
fillFileTable(fileList);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* Handle save.
|
||||||
|
*/
|
||||||
|
protected void save() {
|
||||||
|
try {
|
||||||
|
disk.save();
|
||||||
|
saveToolItem.setEnabled(disk.hasChanged());
|
||||||
|
} catch (IOException ex) {
|
||||||
|
Shell finalShell = shell;
|
||||||
|
String errorMessage = ex.getMessage();
|
||||||
|
if (errorMessage == null) {
|
||||||
|
errorMessage = ex.getClass().getName();
|
||||||
|
}
|
||||||
|
MessageBox box = new MessageBox(finalShell,
|
||||||
|
SWT.ICON_ERROR | SWT.CLOSE);
|
||||||
|
box.setText("Unable to save disk image!");
|
||||||
|
box.setMessage(
|
||||||
|
"Unable to save '" + disk.getFilename() + "'.\n\n"
|
||||||
|
+ "AppleCommander was unable to save the disk\n"
|
||||||
|
+ "image. The system error given was '"
|
||||||
|
+ errorMessage + "'\n\n"
|
||||||
|
+ "Sorry!");
|
||||||
|
box.open();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user