home *** CD-ROM | disk | FTP | other *** search
- // Called by the IDE to initialize this editor
- function File_Reload(path)
- {
- gOutput.writeLine("Do_InsertObject(" + path + ") called");
-
- // Load your document
- ReadData(path);
- }
-
- function Event_OnReadOnlyChange(readOnly)
- {
- gOutput.writeLine("Event_OnReadOnlyChange(" + readOnly + ") called");
- }
-
- // Called by the IDE to setup the context menu
- function Application_SetupContextMenu(menu)
- {
- menu.appendSeparator();
- menu.appendItem("Open As XML", gWebEdit.editorPath,
- "Open this document with the XML editor",
- false, "OpenAsText");
- }
-
- // Called to update the state of the dynamic commands (menu, button)
- function DoUpdate(cmdUI)
- {
- gOutput.writeLine("DoUpdate(" + cmdUI.cookie + ") called");
- if (cmdUI.cookie == "InsertObject") // Defined in onLoadMenu
- {
- cmdUI.enable(true);
- return true;
- }
-
- else if (cmdUI.cookie == "OpenAsText") // Defined in SetupContextMenu above
- {
- cmdUI.enable(gWebEdit.destinationPath.length > 0);
- return true;
- }
- return false;
- }
-
- function Do_InsertObject(data)
- {
- gOutput.writeLine("Do_InsertObject(data) called");
- DumpArrayParameter(data);
- }
-
- function Undo_InsertObject(data)
- {
- gOutput.writeLine("Undo_InsertObject(data) called");
- DumpArrayParameter(data);
- }
-
- function DoCommand(id, cookie)
- {
- gOutput.writeLine("DoCommand(" + id + "," + cookie + ") called");
- if (cookie == "InsertObject") // Defined in onLoadMenu.script
- {
- // For all commands that modify the document use the following paradigm
- // so that undo, redo, and repeat will automatically be supported
-
- // First create the data parameter for the command - it can be any JavaScript variable
- // Here we use an Array object
- var data = new Array("name", 1, 2, 3);
-
- // Second call pushUndoCommand
- gWebEdit.pushUndoCommand("Insert Object", data, Do_InsertObject, Undo_InsertObject);
-
- // Third do the command
- Do_InsertObject(data);
- }
-
- else if (cookie == "OpenAsText") // Defined in SetupContextMenu above
- {
- File.openAs(gWebEdit.destinationPath, ".xml", true);
- }
- }
-
- function ReadData(path)
- {
- if (File.exists(path))
- {
- var file = gFileSystem.OpenTextFile(path, 1);
- if (file)
- {
- gOutput.writeLine("Reading from " + path);
- var s = file.ReadLine();
- file.Close();
- }
- }
- }
-
- function WriteData(path)
- {
- if (File.exists(path))
- {
- gOutput.writeLine("File System Object created");
- var file = gFileSystem.CreateTextFile(path, true);
- if (file)
- {
- gOutput.writeLine("Writing to " + path);
- file.WriteLine("<person>");
- file.WriteLine("\t<name>");
- file.WriteLine("\t</name>");
- file.WriteLine("</person>");
- file.Close();
- }
- }
- return true;
- }
-
- function File_Save(path, autoSave)
- {
- // Do not use gWebEdit.destinationPath since File_Save(path)
- // Can be called to do a SaveAs or SaveCopyAs
- gOutput.writeLine("File_Save: " + path + " called");
- return WriteData(path);
- }
-
- function File_Close()
- {
- gOutput.writeLine("File_Close called");
- // This is just a notification call telling you
- // that this editor is going away. The contents have
- // already been saved so there is nothing to do unless
- // you need to save configuration data. Even that
- // is not necessary if you a MapFile to store configuration
- // data.
- }
-
-
-