public void actionPerformed(ActionEvent arg0)
{
if (!continueUnsavedChangesWarningIfNecessary())
return;
JFileChooser fc = new JasonFileChooser(EditorWindow.this.model.getExpansionDirectory());
int returnValue = fc.showOpenDialog(EditorWindow.this);
if (returnValue != JFileChooser.APPROVE_OPTION)
return;
File file = fc.getSelectedFile();
if (file == null || !file.exists() || file.isDirectory())
{
if (file.isDirectory())
{
showErrorPopup("Unexpected error: The file is a directory.");
}
else
{
showErrorPopup("Unexpected error: The file does not exist.");
}
return;
}
EditorWindow.this.model.trySetAndLoadFile(file);
}
});
mnFile.add(this.mntmOpenFile);
JSeparator separator_1 = new JSeparator();
mnFile.add(separator_1);
this.mntmFSave.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S, InputEvent.CTRL_MASK));
mnFile.add(this.mntmFSave);
this.mntmFSaveAs = new JMenuItem("Save as...");
this.mntmFSaveAs.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e)
{
JFileChooser fc = new OverwriteWarningJasonFileChooser(EditorWindow.this.model.getExpansionDirectory());
int returnValue = fc.showSaveDialog(EditorWindow.this);
if (returnValue != JFileChooser.APPROVE_OPTION)
return;
File file = fc.getSelectedFile();
if (file == null || file.isDirectory())
{
if (file.isDirectory())
{
showErrorPopup("Unexpected error: The file is a directory.");
}
else
{
showErrorPopup("Unexpected error: No file pointer.");
}
return;
}
boolean success = EditorWindow.this.model.longSave(file, true);
if (!success)
{
actionPerformed(e);
}
}
});
mnFile.add(this.mntmFSaveAs);
JMenuItem mntmFSaveACopy = new JMenuItem("Save a backup copy...");
mntmFSaveACopy.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e)
{
JFileChooser fc = new OverwriteWarningJasonFileChooser(EditorWindow.this.model.getExpansionDirectory());
int returnValue = fc.showSaveDialog(EditorWindow.this);
if (returnValue != JFileChooser.APPROVE_OPTION)
return;
File file = fc.getSelectedFile();
if (file == null || file.isDirectory())
{
if (file.isDirectory())
{
showErrorPopup("Unexpected error: The file is a directory.");
}
else
{
showErrorPopup("Unexpected error: No file pointer.");
}
return;
}
boolean success = EditorWindow.this.model.longSave(file, false);
if (!success)
{
actionPerformed(e);
}
}
});
mntmFSaveACopy
.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S, InputEvent.CTRL_MASK | InputEvent.ALT_MASK));
mnFile.add(mntmFSaveACopy);
JSeparator separator_2 = new JSeparator();
mnFile.add(separator_2);
this.mntmReplaceCurrentFile = new JMenuItem("Replace current file with backup... (NOT IMPLEMENTED)");
mnFile.add(this.mntmReplaceCurrentFile);
this.mntmFDiscardChanges = new JMenuItem("Discard changes and reload (NOT IMPLEMENTED)");
mnFile.add(this.mntmFDiscardChanges);
JSeparator separator_7 = new JSeparator();
mnFile.add(separator_7);
JMenuItem mntmMergeAnotherFile = new JMenuItem("Merge another file in...");
mntmMergeAnotherFile.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent arg0)
{
if (!continueUnsavedChangesWarningIfNecessary())
return;
JFileChooser fc = new JasonFileChooser(EditorWindow.this.model.getExpansionDirectory());
int returnValue = fc.showOpenDialog(EditorWindow.this);
if (returnValue != JFileChooser.APPROVE_OPTION)
return;
File file = fc.getSelectedFile();
if (file == null || !file.exists() || file.isDirectory())
{
if (file.isDirectory())
{
showErrorPopup("Unexpected error: The file is a directory.");