|
From: creedon <icr...@us...> - 2005-10-02 18:57:56
|
Update of /cvsroot/frontierkernel/odbs/frontierRoot/system/verbs/builtins/Frontier/tools/windowTypes/commands In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11871 Modified Files: revert saveAs close Log Message: added support for some Frontier File/Edit menu items to call scripts Index: close =================================================================== RCS file: /cvsroot/frontierkernel/odbs/frontierRoot/system/verbs/builtins/Frontier/tools/windowTypes/commands/close,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** close 26 Mar 2005 19:42:54 -0000 1.1.1.1 --- close 1 Oct 2005 17:26:02 -0000 1.2 *************** *** 1,3 **** FrontierVcsFile:1:scpt:system.verbs.builtins.Frontier.tools.windowTypes.commands.close ! on close (adr=nil) { ÇClose a window. ÇChanges: Ç09/30/00; 12:51:56 PM by PBS ÇCall callbacks. Ç11/30/00; 12:09:26 AM by JES ÇDereference callback addresses in a try block in case a tool's odb is not opened Ç07/03/01; 12:32:56 AM by JES ÇMigrated form pike.commands.close. if adr == nil { //close the frontmost window adr = window.frontmost ()}; if not defined (adr^) { //close the Find & Replace Dialog or the About window window.close (adr); return (true)}; on runCallbacks (adrCallbackTable, adrWindow) { if defined (adrCallbackTable^) { local (flConsumed = false); local (adrScript); for adrScript in adrCallbackTable { try { //11/30/00 JES while typeOf (adrScript^) == addressType { //follow addresses adrScript = adrScript^}; return (adrScript^ (adrWindow))}}}; //address is parameter return (false)}; if runCallbacks (@user.tools.commandCallbacks.close, adr) { return (true)}; if system.environment.isRadio { //legacy support for user.pike.commandCallbacks if defined (user.pike) { if defined (user.pike.commandCallbacks) { if runCallbacks (@user.pike.commandCallbacks.close, adr) { return (true)}}}}; if nameOf (adr^) != "/atts" { //if the windowType defines a close script, do that, and otherwise ask to save local (type, adrType); local (title = window.getTitle (adr), flSaveWindow=false, flCloseWindow=true); if not window.attributes.getOne ("title", @title, adr) { title = window.getTitle (adr)}; if window.attributes.getOne ("type", @type, adr) { if Frontier.tools.windowTypes.findWindowType (type, @adrType, adr) { local (flDirty = Frontier.tools.windowTypes.isWindowDirty (adr)); if not defined (adrType^.save) { //temp windows can't be saved unless the windowType can do it if table.tableContains (@system.temp, adr) { flDirty = false}}; if flDirty { //ask the user if they want to save the window case dialog.yesNoCancel ("Save " + title + " before closing?") { 1 { //yes flSaveWindow = true}; 2 { //no flSaveWindow = false}; 3 { //cancel flSaveWindow = false; flCloseWindow = false}}}; if flSaveWindow { if defined (adrType^.save) { //the windowType knows how to save flCloseWindow = Frontier.tools.windowTypes.commands.save (adr, true)} else { //save the database containing the window fileMenu.saveMyRoot (adr)}}; if flCloseWindow { //close the window, deleting tables in system.temp.windowTypes.windows if defined (adrType^.close) { //the windowType adds to the close behavior -- it has a chance to clean up flCloseWindow = adrType^.close (adr)}; if flCloseWindow { //clean up if we're still supposed to close the window if defined (adr^) { //don't do anything unless the window still exists if table.tableContains (@system.temp.windowTypes, adr) { delete (parentOf (adr^)); return (true)}}}} else { //the user cancelled the ask to save dialog or the save failed, so we do nothing return (false)}}}}; try { //hide database windows -- try because this will error for About or Find if sizeOf (string.parseAddress (window.frontmost ())) == 1 { window.hide (adr); return (true)}}; if defined (adr^) { //close the window if it still exists, run callbacks if flRunCallbacks is true window.close (adr)}; //no fancy logic happened -- just close the window return (true)}; bundle { //debugging close ()} \ No newline at end of file --- 1,3 ---- FrontierVcsFile:1:scpt:system.verbs.builtins.Frontier.tools.windowTypes.commands.close ! on close (adr=nil) { ÇClose a window. ÇChanges Ç9/14/05; 3:40:04 PM by TAC Çuse new window.close flDialog parameter Çonly hide database windows if system.environment.isRadio is true Ç07/03/01; 12:32:56 AM by JES ÇMigrated form pike.commands.close. Ç11/30/00; 12:09:26 AM by JES ÇDereference callback addresses in a try block in case a tool's odb is not opened Ç09/30/00; 12:51:56 PM by PBS ÇCall callbacks. if adr == nil { //close the frontmost window adr = window.frontmost ()}; if not defined (adr^) { //close the Find & Replace Dialog or the About window window.close (adr); return (true)}; on runCallbacks (adrCallbackTable, adrWindow) { if defined (adrCallbackTable^) { local (flConsumed = false); local (adrScript); for adrScript in adrCallbackTable { try { //11/30/00 JES while typeOf (adrScript^) == addressType { //follow addresses adrScript = adrScript^}; return (adrScript^ (adrWindow))}}}; //address is parameter return (false)}; if runCallbacks (@user.tools.commandCallbacks.close, adr) { return (true)}; if system.environment.isRadio { //legacy support for user.pike.commandCallbacks if defined (user.pike) { if defined (user.pike.commandCallbacks) { if runCallbacks (@user.pike.commandCallbacks.close, adr) { return (true)}}}}; if nameOf (adr^) != "/atts" { //if the windowType defines a close script, do that, and otherwise ask to save local (type, adrType); local (title = window.getTitle (adr), flSaveWindow=false, flCloseWindow=true); if not window.attributes.getOne ("title", @title, adr) { title = window.getTitle (adr)}; if window.attributes.getOne ("type", @type, adr) { if Frontier.tools.windowTypes.findWindowType (type, @adrType, adr) { local (flDirty = Frontier.tools.windowTypes.isWindowDirty (adr)); if not defined (adrType^.save) { //temp windows can't be saved unless the windowType can do it if table.tableContains (@system.temp, adr) { flDirty = false}}; if flDirty { //ask the user if they want to save the window case dialog.yesNoCancel ("Save " + title + " before closing?") { 1 { //yes flSaveWindow = true}; 2 { //no flSaveWindow = false}; 3 { //cancel flSaveWindow = false; flCloseWindow = false}}}; if flSaveWindow { if defined (adrType^.save) { //the windowType knows how to save flCloseWindow = Frontier.tools.windowTypes.commands.save (adr, true)} else { //save the database containing the window fileMenu.saveMyRoot (adr)}}; if flCloseWindow { //close the window, deleting tables in system.temp.windowTypes.windows if defined (adrType^.close) { //the windowType adds to the close behavior -- it has a chance to clean up flCloseWindow = adrType^.close (adr)}; if flCloseWindow { //clean up if we're still supposed to close the window if defined (adr^) { //don't do anything unless the window still exists if table.tableContains (@system.temp.windowTypes, adr) { delete (parentOf (adr^)); return (true)}}}} else { //the user cancelled the ask to save dialog or the save failed, so we do nothing return (false)}}}}; if system.environment.isRadio { try { //hide database windows -- try because this will error for About or Find if sizeOf (string.parseAddress (window.frontmost ())) == 1 { window.hide (adr); return (true)}}}; if defined (adr^) { //close the window if it still exists local (flDialog = false); if not (system.environment.isRadio) { flDialog = true}; window.close (adr, flDialog)}; //no fancy logic happened -- just close the window return (true)}; Çbundle // testing Çclose () \ No newline at end of file Index: revert =================================================================== RCS file: /cvsroot/frontierkernel/odbs/frontierRoot/system/verbs/builtins/Frontier/tools/windowTypes/commands/revert,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** revert 26 Mar 2005 19:42:55 -0000 1.1.1.1 --- revert 1 Oct 2005 17:26:02 -0000 1.2 *************** *** 1,3 **** FrontierVcsFile:1:scpt:system.verbs.builtins.Frontier.tools.windowTypes.commands.revert ! on revert (adr = nil) { ÇRevert a window. ÇChanges: Ç03/24/00; 7:24:20 PM by PBS ÇThis command was seriously broken -- now it's fixed. It works again for advanced items and stories. ÇFri, Jul 7, 2000 at 11:00:09 PM by AR ÇCall any scripts in user.pike.commandCallbacks.revert ÇIf one of the scripts returns true, we're done Ç07/24/00; 12:37:39 PM by PBS ÇHandle reverting local XML outline documents. Ç10/03/00; 6:39:09 PM by PBS ÇCallbacks can be addresses. Ç11/30/00; 12:17:04 AM by JES ÇDereference callback addresses in a try block in case a tool's odb is not opened if adr == nil { try { adr = window.frontmost ()} else { return (false)}}; on askForConfirmation (s) { return (dialog.twoWay ("Discard all changes made to " + s + "?", "Discard", "Cancel"))}; on runCallbacks (adrcallbacks) { if defined (adrcallbacks^) { local (adrcallback); for adrcallback in adrcallbacks { try { //11/30/00 JES while typeOf (adrcallback^) == addressType { //follow addresses adrcallback = adrcallback^}; flConsumed = adrcallback^ (adr)}; if flConsumed { return (true)}}}; return (false)}; if runCallbacks (@user.tools.commandCallbacks.revert) { return (true)}; if system.environment.isRadio { if defined (user.pike.commandCallbacks) { if runCallbacks (@user.pike.commandCallbacks.revert) { return (true)}}}; bundle { //run the windowType script if it exists local (type); if window.attributes.getOne ("type", @type, adr) { local (adrtype); if Frontier.tools.windowTypes.findWindowType (type, @adrtype, adr) { if defined (adrtype^.revert) { if Frontier.tools.windowTypes.isWindowDirty (adr) { local (title = window.getTitle (adr)); window.attributes.getOne ("title", @title, adr); //we don't care if this doesn't work if askForConfirmation (title) { local (adrNewWindow); if adrtype^.revert (adr, @adrNewWindow) { ÇlastSaved may already have been set by the windowType, but we do it here too just in case. window.attributes.setOne ("lastSaved", timeModified (adrNewWindow), adrNewWindow); return (true)}}}}}}}; return (false); Çbundle //old code for reverting Manila windows Çif adrItem!= nil Çlocal (flConsumed = false) Çif defined (user.pike.commandCallbacks.revert) Çlocal (adrcallback) Çfor adrcallback in @user.pike.commandCallbacks.revert Çtry //11/30/00 JES Çwhile typeOf (adrcallback^) == addressType //follow addresses Çadrcallback = adrcallback^ ÇflConsumed = adrcallback^ (adrItem) Çif flConsumed Çbreak Çif not flConsumed Çon askForConfirmation (s) Çreturn (dialog.twoWay ("Discard all changes made to " + s + "?", "Discard", "Cancel")) Ç Çbundle //PBS 07/24/00: handle local outlines Çif pike.isLocalOutline (adrItem) Çlocal (adrTable = parentOf (adrItem^)) Çif defined (adrTable^.f) Çif file.exists (adrTable^.f) Çlocal (title = adrTable^.title) Çif askForConfirmation (title) Çwindow.close (adrItem) Çpike.commands.open (adrTable^.f) ÇfileMenu.save () Çreturn (true) Ç Çlocal (windowType = pike.getWindowType (adrItem)) Çif windowType != "" Çlocal (adrTable = parentOf (adrItem^)) Çcase windowType //can't revert "newStories" Ç"advancedItems" Çif not askForConfirmation ("the " + adrTable^.iteminfo.type) Çreturn (false) Çlocal (handlerName = pike.advancedItemToHandlerName (adrTable^.itemInfo.type)) Çlocal (t = manila.[handlerName].get (@adrTable^.siteInfo)) ÇadrTable^.itemInfo.body = string (t.body) Çpike.commands.editAdvancedItem (adrTable^.siteInfo, adrTable^.itemInfo, false) Ç"savedStories" Çlocal (adrStory = @adrTable^.storyinfo) Çif not askForConfirmation ("\"" + adrStory^.subject + "\"") Çreturn (false) ÇadrStory^ = manila.message.get (@adrTable^.siteinfo, adrStory^.msgnum) Çif defined (adrStory^.bodyType) Çif string.lower (adrStory^.bodyType) == "text/x-outline-tabbed" ÇadrStory^.body = string (adrStory^.outline) Çpike.commands.editStory (adrTable^.siteInfo, adrTable^.storyInfo, false) Ç ÇfileMenu.save () Ç Çreturn (true)}; bundle { //debugging revert (window.frontmost ())} \ No newline at end of file --- 1,3 ---- FrontierVcsFile:1:scpt:system.verbs.builtins.Frontier.tools.windowTypes.commands.revert ! on revert (adr = nil) { ÇChanges Ç9/21/05; 3:24:55 PM by TAC Çchanged confirmatation dialog to do the safe option by default Çchanged to actually do a revert for Frontier Ç2000 Ç11/30/00; 12:17:04 AM by JES ÇDereference callback addresses in a try block in case a tool's odb is not opened Ç10/03/00; 6:39:09 PM by PBS ÇCallbacks can be addresses. Ç07/24/00; 12:37:39 PM by PBS ÇHandle reverting local XML outline documents. ÇFri, Jul 7, 2000 at 11:00:09 PM by AR ÇCall any scripts in user.pike.commandCallbacks.revert ÇIf one of the scripts returns true, we're done Ç03/24/00; 7:24:20 PM by PBS ÇThis command was seriously broken -- now it's fixed. It works again for advanced items and stories. ÇRevert a window. if adr == nil { try { adr = window.frontmost ()} else { return (false)}}; on askForConfirmation (s) { return (!dialog.twoWay ("Discard all changes made to " + s + "?", "Cancel", "Discard"))}; on runCallbacks (adrcallbacks) { if defined (adrcallbacks^) { local (adrcallback); for adrcallback in adrcallbacks { try { //11/30/00 JES while typeOf (adrcallback^) == addressType { //follow addresses adrcallback = adrcallback^}; flConsumed = adrcallback^ (adr)}; if flConsumed { return (true)}}}; return (false)}; if runCallbacks (@user.tools.commandCallbacks.revert) { return (true)}; if system.environment.isRadio { if defined (user.pike.commandCallbacks) { if runCallbacks (@user.pike.commandCallbacks.revert) { return (true)}}}; bundle { //run the windowType script if it exists local (type); if window.attributes.getOne ("type", @type, adr) { local (adrtype); if Frontier.tools.windowTypes.findWindowType (type, @adrtype, adr) { if defined (adrtype^.revert) { if Frontier.tools.windowTypes.isWindowDirty (adr) { local (title = window.getTitle (adr)); window.attributes.getOne ("title", @title, adr); //we don't care if this doesn't work if askForConfirmation (title) { local (adrNewWindow); if adrtype^.revert (adr, @adrNewWindow) { ÇlastSaved may already have been set by the windowType, but we do it here too just in case. window.attributes.setOne ("lastSaved", timeModified (adrNewWindow), adrNewWindow); return (true)}}}}}}}; if system.environment.isRadio { return (false)} else { local (s = file.fileFromPath (window.getFile (adr))); if askForConfirmation (s) { fileMenu.revert ()}}; return (true); Çbundle //old code for reverting Manila windows Çif adrItem!= nil Çlocal (flConsumed = false) Çif defined (user.pike.commandCallbacks.revert) Çlocal (adrcallback) Çfor adrcallback in @user.pike.commandCallbacks.revert Çtry //11/30/00 JES Çwhile typeOf (adrcallback^) == addressType //follow addresses Çadrcallback = adrcallback^ ÇflConsumed = adrcallback^ (adrItem) Çif flConsumed Çbreak Çif not flConsumed Çon askForConfirmation (s) Çreturn (dialog.twoWay ("Discard all changes made to " + s + "?", "Discard", "Cancel")) Ç Çbundle //PBS 07/24/00: handle local outlines Çif pike.isLocalOutline (adrItem) Çlocal (adrTable = parentOf (adrItem^)) Çif defined (adrTable^.f) Çif file.exists (adrTable^.f) Çlocal (title = adrTable^.title) Çif askForConfirmation (title) Çwindow.close (adrItem) Çpike.commands.open (adrTable^.f) ÇfileMenu.save () Çreturn (true) Ç Çlocal (windowType = pike.getWindowType (adrItem)) Çif windowType != "" Çlocal (adrTable = parentOf (adrItem^)) Çcase windowType //can't revert "newStories" Ç"advancedItems" Çif not askForConfirmation ("the " + adrTable^.iteminfo.type) Çreturn (false) Çlocal (handlerName = pike.advancedItemToHandlerName (adrTable^.itemInfo.type)) Çlocal (t = manila.[handlerName].get (@adrTable^.siteInfo)) ÇadrTable^.itemInfo.body = string (t.body) Çpike.commands.editAdvancedItem (adrTable^.siteInfo, adrTable^.itemInfo, false) Ç"savedStories" Çlocal (adrStory = @adrTable^.storyinfo) Çif not askForConfirmation ("\"" + adrStory^.subject + "\"") Çreturn (false) ÇadrStory^ = manila.message.get (@adrTable^.siteinfo, adrStory^.msgnum) Çif defined (adrStory^.bodyType) Çif string.lower (adrStory^.bodyType) == "text/x-outline-tabbed" ÇadrStory^.body = string (adrStory^.outline) Çpike.commands.editStory (adrTable^.siteInfo, adrTable^.storyInfo, false) Ç ÇfileMenu.save () Ç Çreturn (true)}; Çbundle // testing Çrevert (window.frontmost ()) \ No newline at end of file Index: saveAs =================================================================== RCS file: /cvsroot/frontierkernel/odbs/frontierRoot/system/verbs/builtins/Frontier/tools/windowTypes/commands/saveAs,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** saveAs 26 Mar 2005 19:42:56 -0000 1.1.1.1 --- saveAs 1 Oct 2005 17:26:02 -0000 1.2 *************** *** 1,3 **** FrontierVcsFile:1:scpt:system.verbs.builtins.Frontier.tools.windowTypes.commands.saveAs ! on saveAs (adrItem=nil) { ÇHandle the Save As command. if adrItem == nil { //default to frontmost window adrItem = window.frontmost ()}; on saveDatabase () { msg ("Saving database..."); if typeOf (adrItem) == addressType { fileMenu.saveMyRoot (adritem)} else { fileMenu.save ()}; msg ("")}; //clear the feedback message if not defined (adrItem^) { //save Radio.root adrItem = @root; saveDatabase (); return (true)}; on runCallbacks (adrCallback) { //call callbacks if defined (adrCallback^) { local (flConsumed = false); local (adrScript); for adrScript in adrCallback { try { //11/30/00 JES while typeOf (adrScript^) == addressType { //follow addresses adrScript = adrScript^}; flConsumed = adrScript^ (adrItem, flClosing)}; if flConsumed { return (true)}}}; return (false)}; if runCallbacks (@user.tools.commandCallbacks.saveAs) { return (true)}; if system.environment.isRadio { if defined (user.pike.commandCallbacks) { if runCallbacks (@user.pike.commandCallbacks.saveAs) { return (true)}}}; bundle { //look for a windowType that handles this command local (type, adrType); if window.attributes.getOne ("type", @type, adrItem) { if Frontier.tools.windowTypes.findWindowType (type, @adrType, adrItem) { if defined (adrType^.save) { if adrType^.saveAs (adrItem) { window.attributes.setOne ("lastSaved", timeModified (adrItem), adrItem); saveDatabase (); return (true)} else { return (false)}}}}}; bundle { //if this is an outline window, save as an opml file local (adrType); if Frontier.tools.windowTypes.findWindowType ("outlinerFile", @adrType) { if adrType^.saveAs (adrItem) { return (true)}}}; ÇDo we want to call the odb-export code here? export.commands.export (); saveDatabase (); return (true); }; Çbundle //debugging ÇsaveAs () \ No newline at end of file --- 1,3 ---- FrontierVcsFile:1:scpt:system.verbs.builtins.Frontier.tools.windowTypes.commands.saveAs ! on saveAs (adrItem=nil) { ÇChanges Ç9/21/05; 11:34:38 AM by TAC Çchanged to actually do a save as, as opposed to a save Çonly do export for non Frontier envrionments ÇHandle the Save As command. if adrItem == nil { //default to frontmost window adrItem = window.frontmost ()}; on saveDatabaseAs () { local (f = file.fileFromPath (window.getFile (table.getRootAddress (adrItem)))); if file.putFileDialog ("", @f) { fileMenu.saveCopy (f)}}; if not defined (adrItem^) { // save root adrItem = @root; saveDatabaseAs (); return (true)}; on runCallbacks (adrCallback) { //call callbacks if defined (adrCallback^) { local (flConsumed = false); local (adrScript); for adrScript in adrCallback { try { //11/30/00 JES while typeOf (adrScript^) == addressType { //follow addresses adrScript = adrScript^}; flConsumed = adrScript^ (adrItem, flClosing)}; if flConsumed { return (true)}}}; return (false)}; if runCallbacks (@user.tools.commandCallbacks.saveAs) { return (true)}; if system.environment.isRadio { if defined (user.pike.commandCallbacks) { if runCallbacks (@user.pike.commandCallbacks.saveAs) { return (true)}}}; bundle { //look for a windowType that handles this command local (type, adrType); if window.attributes.getOne ("type", @type, adrItem) { if Frontier.tools.windowTypes.findWindowType (type, @adrType, adrItem) { if defined (adrType^.save) { if adrType^.saveAs (adrItem) { window.attributes.setOne ("lastSaved", timeModified (adrItem), adrItem); saveDatabase (); return (true)} else { return (false)}}}}}; bundle { //if this is an outline window, save as an opml file local (adrType); if Frontier.tools.windowTypes.findWindowType ("outlinerFile", @adrType) { if adrType^.saveAs (adrItem) { return (true)}}}; if system.environment.isRadio { export.commands.export ()}; // Do we want to call the odb-export code here? saveDatabaseAs (); return (true)}; Çbundle // testing ÇsaveAs () \ No newline at end of file |