in modules/jretools/src/main/java/org/apache/harmony/jretools/policytool/control/Controller.java [132:179]
private boolean allowedDirtySensitiveOperation( final String operationName ) {
if ( activeEditorPanel.getHasDirty() ) {
switch ( JOptionPane.showConfirmDialog( mainFrame, "There are unsaved changes. Save before " + operationName + "?", "Warning", JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.WARNING_MESSAGE ) ) {
case JOptionPane.YES_OPTION:
// We chose to save file first
final JFileChooser fileChooser = new JFileChooser();
if ( editedPolicyFile == null ) {
if ( fileChooser.showSaveDialog( mainFrame ) == JFileChooser.APPROVE_OPTION )
editedPolicyFile = fileChooser.getSelectedFile();
}
if ( editedPolicyFile != null ) {
if ( !PolicyFileHandler.savePolicyFile( editedPolicyFile, activeEditorPanel.getPolicyText() ) ) {
switch ( JOptionPane.showConfirmDialog( mainFrame, "Saving failed. Do you still want to " + operationName + "?", "Warning", JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE ) ) {
case JOptionPane.YES_OPTION:
// We chose to still proceed
return true;
case JOptionPane.NO_OPTION:
case JOptionPane.CLOSED_OPTION:
// We chose not to proceed
return false;
}
} else {// Changes saved successfully
activeEditorPanel.setHasDirty( false );
mainFrame.setDisplayedPolicyFile( editedPolicyFile );
return true;
}
}
break;
case JOptionPane.NO_OPTION:
// We chose not to save and proceed
return true;
case JOptionPane.CANCEL_OPTION:
case JOptionPane.CLOSED_OPTION:
// We chose not to proceed
return false;
}
}
return true;
}