//--------------------------------------------------------------------------------------------- // [ConsoleInteraction] public string createUndo <T>(string desc) { omni.Util.pushInstantGroup(); ObjectCreator ocf = new ObjectCreator("UndoScriptAction", "", typeof(T)); //ocf["class"] = className; ocf["superClass"] = "BaseDatablockEdAction"; ocf["actionName"] = desc; ocf["editor"] = "DatablockEditorPlugin"; ocf["treeview"] = "DatablockEditorTree"; ocf["inspector"] = "DatablockEditorInspector"; UndoScriptAction action = ocf.Create(); omni.Util.popInstantGroup(); return(action); }
public void createDatablockFinish(string name, string copySource) { GuiTreeViewCtrl DatablockEditorTypeTree = "DatablockEditorTypeTree"; GuiControl DatablockEditorCreatePrompt = "DatablockEditorCreatePrompt"; string className = DatablockEditorTypeTree.getItemText(DatablockEditorTypeTree.getSelectedItem()); if (className != "") { UndoScriptAction action = this.createUndo <DatablockEditorUndo.ActionCreateDatablock>("Create New Datablock"); string dbType; if ( ((GuiCheckBoxCtrl) DatablockEditorCreatePrompt.findObjectByInternalName("ClientSideCheckBox", true)).isStateOn()) { dbType = "singleton "; } else { dbType = "datablock "; } string eval; if (copySource != "") { eval = dbType + className + "(" + name + " : " + copySource + ") { canSaveDynamicFields = \"1\"; };"; } else { eval = dbType + className + "(" + name + ") { canSaveDynamicFields = \"1\"; };"; } string res = omni.Util.eval(eval); action["db"] = name.getID().AsString(); action["dbName"] = name; action["fname"] = omni.sGlobal["$DATABLOCK_EDITOR_DEFAULT_FILENAME"]; this.submitUndo(action); action.redo(); } }
public void deleteDatablock() { GuiTreeViewCtrl tree = "DatablockEditorTree"; editor Editor = "Editor"; // If we have more than single datablock selected, // turn our undos into a compound undo. int numSelected = tree.getSelectedItemsCount(); if (numSelected > 1) { Editor.getUndoManager().pushCompound("Delete Multiple Datablocks"); } for (int i = 0; i < numSelected; i++) { int id = tree.getSelectedItem(i); SimObject db = tree.getItemValue(id); string fileName = db.getFilename(); // Remove the datablock from the tree. tree.removeItem(id); // Create undo. UndoScriptAction action = this.createUndo <DatablockEditorUndo.ActionDeleteDatablock>("Delete Datablock"); action["db"] = db; action["dbName"] = db.getName(); action["fname"] = fileName; this.submitUndo(action); // Kill the datablock in the file. if (fileName != "") { this.PM.removeObjectFromFile(db); } ((SimSet)"UnlistedDatablocks").add(db); // Show some confirmation. if (numSelected == 1) { messageBox.MessageBoxOK("Datablock Deleted", "The datablock (" + db.getName() + ") has been removed from " + "it's file (" + db.getFilename() + ") and upon restart will cease to exist"); } } // Close compound, if we were deleting multiple datablocks. if (numSelected > 1) { Editor.getUndoManager().popCompound(); } // Show confirmation for multiple datablocks. if (numSelected > 1) { messageBox.MessageBoxOK("Datablocks Deleted", "The datablocks have been deleted and upon restart will cease to exist."); } // Clear selection. this.resetSelectedDatablock(); }
public void submitUndo(UndoScriptAction action) { editor Editor = "Editor"; action.addToManager(Editor.getUndoManager()); }