1 jls.loader.provide('jls.gui.CommonDialog'); 2 3 jls.loader.require('jls.win32.WindowElement'); 4 jls.loader.require('jls.win32.CommonDialog'); 5 6 /** 7 * @class CommonDialog helps to deal with standard dialogs. 8 */ 9 jls.gui.CommonDialog = jls.lang.Class.create({}); 10 11 Object.extend(jls.gui.CommonDialog, /** @lends jls.gui.CommonDialog.prototype */ 12 { 13 /** 14 * Prompts the user for a file to open then returns the selected filename. 15 * 16 * @param {jls.gui.Element} [element] The parent element. 17 * @returns {String} The selected filename. 18 */ 19 getOpenFileName : function(element) { 20 var window = null; 21 if (element && (element instanceof jls.win32.WindowElement)) { 22 window = element._window; 23 } 24 var flags = 0; 25 return jls.win32.CommonDialog.getOpenFileName(window, flags); 26 }, 27 /** 28 * Prompts the user for a file to save then returns the selected filename. 29 * 30 * @param {jls.gui.Element} [element] The parent element. 31 * @param {Boolean} [confirmOverwrite] true if the user must confirm when an existing file is selected. 32 * @returns {String} The selected filename. 33 */ 34 getSaveFileName : function(element, confirmOverwrite) { 35 var window = null; 36 if (element && (element instanceof jls.win32.WindowElement)) { 37 window = element._window; 38 } 39 var flags = 0; 40 if (confirmOverwrite) { 41 flags |= jls.win32.CommonDialog.OFN_OVERWRITEPROMPT; 42 } 43 return jls.win32.CommonDialog.getSaveFileName(window, flags); 44 } 45 }); 46