@Override
	public boolean selectFileToSave(OutlinerDocument document, int type) {
		// we'll customize the approve button
		// [srk] this is done here, rather than in configureForOpen/Import, to workaround a bug
		String approveButtonText = null ;
		
		// make sure we're all set up
		lazyInstantiation();
		
		// Setup the File Chooser to save or export
		switch (type) {
			case FileProtocol.SAVE:
				chooser.configureForSave(document, getName(), Preferences.getPreferenceString(Preferences.MOST_RECENT_SAVE_DIR).cur);
				approveButtonText = GUITreeLoader.reg.getText("save");
				break;
				
			case FileProtocol.EXPORT:
				chooser.configureForExport(document, getName(), Preferences.getPreferenceString(Preferences.MOST_RECENT_SAVE_DIR).cur);
				approveButtonText = GUITreeLoader.reg.getText("export");
				break;
				
			default:
				System.out.println("ERROR: invalid save/export type used. (" + type +")");
				return false;
		}
		
		// run the File Chooser
		int option = chooser.showDialog(Outliner.outliner, approveButtonText);
		
		// Update the most recent save dir preference
		// TBD [srk] set up a MOST_RECENT_EXPORT_DIR, then have this code act appropriately
		Preferences.getPreferenceString(Preferences.MOST_RECENT_SAVE_DIR).cur = chooser.getCurrentDirectory().getPath();
		Preferences.getPreferenceString(Preferences.MOST_RECENT_SAVE_DIR).restoreTemporaryToCurrent();
		
		// Handle User Input
		if (option == JFileChooser.APPROVE_OPTION) {
			String filename = chooser.getSelectedFile().getPath();
			
			String lineEnd;
			String encoding;
			String fileFormat;
			
			if (!Outliner.documents.isFileNameUnique(filename) && (!filename.equals(document.getFileName()))) {
				String msg = GUITreeLoader.reg.getText("message_cannot_save_file_already_open");
				msg = Replace.replace(msg,GUITreeComponentRegistry.PLACEHOLDER_1, filename);
				
				JOptionPane.showMessageDialog(Outliner.outliner, msg);
				// We might want to move this test into the approveSelection method of the file chooser.
				return false;
			}
			
			// Pull Preference Values from the file chooser
			switch (type) {
				case FileProtocol.SAVE:
					lineEnd = chooser.getSaveLineEnding();
					encoding = chooser.getSaveEncoding();
					fileFormat = chooser.getSaveFileFormat();
					break;
					
				case FileProtocol.EXPORT:
					lineEnd = chooser.getExportLineEnding();
					encoding = chooser.getExportEncoding();
					fileFormat = chooser.getExportFileFormat();
					break;
					
				default:
					System.out.println("ERROR: invalid save/export type used. (" + type +")");
					return false;
			}
			
			
			// Update the document settings
			if (document.settings.useDocumentSettings()) {
				document.settings.getLineEnd().def = lineEnd;
				document.settings.getLineEnd().cur = lineEnd;
				document.settings.getLineEnd().tmp = lineEnd;
				document.settings.getSaveEncoding().def = encoding;
				document.settings.getSaveEncoding().cur = encoding;
				document.settings.getSaveEncoding().tmp = encoding;
				document.settings.getSaveFormat().def = fileFormat;
				document.settings.getSaveFormat().cur = fileFormat;
				document.settings.getSaveFormat().tmp = fileFormat;
			}
			
			// Update Document Info
			DocumentInfo docInfo = document.getDocumentInfo();
			PropertyContainerUtil.setPropertyAsString(docInfo, DocumentInfo.KEY_PATH, filename);
			PropertyContainerUtil.setPropertyAsString(docInfo, DocumentInfo.KEY_LINE_ENDING, lineEnd);
			PropertyContainerUtil.setPropertyAsString(docInfo, DocumentInfo.KEY_ENCODING_TYPE, encoding);
			PropertyContainerUtil.setPropertyAsString(docInfo, DocumentInfo.KEY_FILE_FORMAT, fileFormat);
			
			return true;
		} else {
			return false;
		}
	}