rem: window.editorShell.Init(); 
context: function ComposeStartup(){	dump("Compose: ComposeStartup\n");	//dump("Get arguments\n");	var args = GetArgs();    //dump("fill in Identity menulist\n");    var identityList = document.getElementById("msgIdentity");    var identityListPopup = document.getElementById("msgIdentityPopup");    if (identityListPopup) {        fillIdentityListPopup(identityListPopup);    }    var identity = null;    if (args.preselectid)        identity = getIdentityForKey(args.preselectid);    else    {       // no preselect, so use the default account       var identities = accountManager.defaultAccount.identities;            if (identities.Count() >= 1)    	  identity = identities.QueryElementAt(0, Components.interfaces.nsIMsgIdentity);    	else    	{        identities = GetIdentities();        identity = identities[0];      }	      }       for (i=0;i<identityListPopup.childNodes.length;i++) {        var item = identityListPopup.childNodes[i];        var id = item.getAttribute('id');        if (id == identity.key) {            identityList.selectedItem = item;            break;        }    }    LoadIdentity(true);	if (msgComposeService)	{        // this is frustrating, we need to convert the preselect identity key        // back to an identity, to pass to initcompose        // it would be nice if there was some way to actually send the        // identity through "args"        		msgCompose = msgComposeService.InitCompose(window, args.originalMsg, args.type, args.format, args.fieldsAddr, identity);		if (msgCompose)		{			//Creating a Editor Shell      var editorShell = Components.classes["@mozilla.org/editor/editorshell;1"].createInstance();      editorShell = editorShell.QueryInterface(Components.interfaces.nsIEditorShell);			if (!editorShell)			{				dump("Failed to create editorShell!\n");				return;			}						// save the editorShell in the window. The editor JS expects to find it there.			window.editorShell = editorShell;			window.editorShell.Init();			dump("Created editorShell\n");			// setEditorType MUST be call before setContentWindow			if (msgCompose.composeHTML)			{				window.editorShell.editorType = "htmlmail";				dump("editor initialized in HTML mode\n");			}			else			{			    //Remove HTML toolbar, format and insert menus as we are editing in plain text mode			    document.getElementById("FormatToolbar").setAttribute("hidden", true);			    document.getElementById("formatMenu").setAttribute("hidden", true);			    document.getElementById("insertMenu").setAttribute("hidden", true);			    document.getElementById("menu_showFormatToolbar").setAttribute("checked", false);				window.editorShell.editorType = "textmail";				dump("editor initialized in PLAIN TEXT mode\n");			}			window.editorShell.webShellWindow = window;			window.editorShell.contentWindow = window._content;      // Do setup common to Message Composer and Web Composer      EditorSharedStartup();	    	var msgCompFields = msgCompose.compFields;	    	if (msgCompFields)	    	{	    		if (args.body) //We need to set the body before setting                               //msgCompose.editor;                {                    if (args.bodyislink == "true")					{						if (msgCompose.composeHTML)							msgCompFields.SetBody("<BR><A HREF=\"" + args.body +													  "\">" + unescape(args.body)													  + "</A><BR>");						else							msgCompFields.SetBody("\n<" + args.body + ">\n");					}                    else                        msgCompFields.SetBody(args.body);                }	    		if (args.to)	    			msgCompFields.SetTo(args.to);	    		if (args.cc)	    			msgCompFields.SetCc(args.cc);	    		if (args.bcc)	    			msgCompFields.SetBcc(args.bcc);	    		if (args.newsgroups)	    			msgCompFields.SetNewsgroups(args.newsgroups);	    		if (args.subject)	    			msgCompFields.SetSubject(args.subject);	    		if (args.attachment)	    			msgCompFields.SetAttachments(args.attachment);				dump("args newshost = " + args.newshost + "\n");				if (args.newshost)					msgCompFields.SetNewshost(args.newshost);							var subjectValue = msgCompFields.GetSubject();				if (subjectValue != "") {					document.getElementById("msgSubject").value = subjectValue;				}                var attachmentValue = msgCompFields.GetAttachments();                if (attachmentValue != "") {                   var atts =  attachmentValue.split(",");                    for (var i=0; i < atts.length; i++)                    {                        AddAttachment(atts[i]);                    }                }			} 						// Now that we have an Editor AppCore, we can finish to initialize the Compose AppCore			msgCompose.editor = window.editorShell;						msgCompose.RegisterStateListener(stateListener);			// call updateCommands to disable while we're loading the page		  try {			window.updateCommands("create");  		} catch(e) {}			//	    SetupCommandUpdateHandlers();			WaitFinishLoadingDocument(args.type);		}	}}
meta: 8395	/local1/tlutelli/issta_data/temp/all_js/javascript/2006_temp/2006/8395/a388c1b7dd66396d599b3472e3af9d981aa6a190/MsgComposeCommands.js/buggy/mailnews/compose/resources/content/MsgComposeCommands.js