public void setProfileDirty(SimObject profile, bool value, bool noCheck) { PersistenceManager GuiEditorProfilesPM = "GuiEditorProfilesPM"; GuiEditorProfiles.GuiEditorProfilesTree GuiEditorProfilesTree = "GuiEditorProfilesTree"; GuiEditorProfiles.GuiEditorProfileChangeManager GuiEditorProfileChangeManager = "GuiEditorProfileChangeManager"; if (!GuiEditorProfilesPM.isObject()) GuiEditorProfilesPM = new ObjectCreator("PersistenceManager", "GuiEditorProfilesPM").Create(); if (value) { if (!GuiEditorProfilesPM.isDirty(profile) || noCheck) { // If the profile hasn't yet been associated with a file, // put it in the default file. if (profile.getFilename() == "") profile.setFilename(sGlobal["$GUI_EDITOR_DEFAULT_PROFILE_FILENAME"]); // Add the profile to the dirty set. GuiEditorProfilesPM.setDirty(profile); // Show the item as dirty in the tree. int id = GuiEditorProfilesTree.findItemByValue(profile.getId().AsString()); GuiEditorProfilesTree.editItem(id, GuiEditorProfilesTree.getItemText(id) + ' ' + "*", profile.getId().AsString()); // Count the number of unsaved profiles. If this is // the first one, indicate in the window title that // we have unsaved profiles. this.increaseNumDirtyProfiles(); } } else { if (GuiEditorProfilesPM.isDirty(profile) || noCheck) { // Remove from dirty list. GuiEditorProfilesPM.removeDirty(profile); // Clear the dirty marker in the tree. int id = GuiEditorProfilesTree.findItemByValue(profile.getId().AsString()); string text = GuiEditorProfilesTree.getItemText(id); GuiEditorProfilesTree.editItem(id, Util.getSubStr(text, 0, Util.strlen(text) - 2), profile.getId().AsString()); // Count saved profiles. If this was the last unsaved profile, // remove the unsaved changes indicator from the window title. this.decreaseNumDirtyProfiles(); // Remove saved edits from the change manager. GuiEditorProfileChangeManager.clearEdits(profile); } } }
public void saveProfile(SimObject profile, string fileName) { PersistenceManager GuiEditorProfilesPM = "GuiEditorProfilesPM"; if (!GuiEditorProfilesPM.isObject()) GuiEditorProfilesPM = new ObjectCreator("PersistenceManager", "GuiEditorProfilesPM").Create(); if (!GuiEditorProfilesPM.isDirty(profile) && (fileName == "" || fileName == profile.getFilename())) return; // Update the filename, if requested. if (fileName != "") { profile.setFilename(fileName); GuiEditorProfilesPM.setDirty(profile, fileName); } // Save the object. GuiEditorProfilesPM.saveDirtyObject(profile); // Clear its dirty state. this.setProfileDirty(profile, false, true); }