def fileSave(self, event=None, view=None, fileType=None, filenameFromInstance=False, *ignore):
        if view is None:
            view = getattr(self, "currentView", None)
        if view is not None:
            filename = None
            modelXbrl = None
            try:
                modelXbrl = view.modelXbrl
            except AttributeError:
                pass
            if filenameFromInstance:
                try:
                    modelXbrl = view.modelXbrl
                    filename = modelXbrl.modelDocument.filepath
                    if filename.endswith('.xsd'): # DTS entry point, no instance saved yet!
                        filename = None
                except AttributeError:
                    pass
            if isinstance(view, ViewWinRenderedGrid.ViewRenderedGrid):
                initialdir = os.path.dirname(modelXbrl.modelDocument.uri)
                if fileType in ("html", "xml", None):
                    if fileType == "html" and filename is None:
                        filename = self.uiFileDialog("save",
                                title=_("arelle - Save HTML-rendered Table"),
                                initialdir=initialdir,
                                filetypes=[(_("HTML file .html"), "*.html"), (_("HTML file .htm"), "*.htm")],
                                defaultextension=".html")
                    elif fileType == "xml" and filename is None:
                        filename = self.uiFileDialog("save",
                                title=_("arelle - Save Table Layout Model"),
                                initialdir=initialdir,
                                filetypes=[(_("Layout model file .xml"), "*.xml")],
                                defaultextension=".xml")
                    else: # ask file type
                        if filename is None:
                            filename = self.uiFileDialog("save",
                                    title=_("arelle - Save XBRL Instance or HTML-rendered Table"),
                                    initialdir=initialdir,
                                    filetypes=[(_("XBRL instance .xbrl"), "*.xbrl"), (_("XBRL instance .xml"), "*.xml"), (_("HTML table .html"), "*.html"), (_("HTML table .htm"), "*.htm")],
                                    defaultextension=".html")
                        if filename and (filename.endswith(".xbrl") or filename.endswith(".xml")):
                            view.saveInstance(filename)
                            return True
                    if not filename:
                        return False
                    try:
                        ViewFileRenderedGrid.viewRenderedGrid(modelXbrl, filename, lang=self.labelLang, sourceView=view)
                    except (IOError, EnvironmentError) as err:
                        tkinter.messagebox.showwarning(_("arelle - Error"),
                                        _("Failed to save {0}:\n{1}").format(
                                        filename, err),
                                        parent=self.parent)
                    return True
                elif fileType == "xbrl":
                    return self.uiFileDialog("save",
                            title=_("arelle - Save Instance"),
                            initialdir=initialdir,
                            filetypes=[(_("XBRL instance .xbrl"), "*.xbrl"), (_("XBRL instance .xml"), "*.xml")],
                            defaultextension=".xbrl")
            elif isinstance(view, ViewWinTests.ViewTests) and modelXbrl.modelDocument.type in (ModelDocument.Type.TESTCASESINDEX, ModelDocument.Type.TESTCASE):
                filename = self.uiFileDialog("save",
                        title=_("arelle - Save Test Results"),
                        initialdir=os.path.dirname(self.modelManager.modelXbrl.modelDocument.uri),
                        filetypes=[(_("CSV file"), "*.csv")],
                        defaultextension=".csv")
                if not filename:
                    return False
                try:
                    ViewFileTests.viewTests(self.modelManager.modelXbrl, filename)
                except (IOError, EnvironmentError) as err:
                    tkinter.messagebox.showwarning(_("arelle - Error"),
                                        _("Failed to save {0}:\n{1}").format(
                                        filename, err),
                                        parent=self.parent)
                return True
            elif isinstance(view, ViewWinTree.ViewTree):
                filename = self.uiFileDialog("save",
                        title=_("arelle - Save {0}").format(view.tabTitle),
                        initialdir=os.path.dirname(self.modelManager.modelXbrl.modelDocument.uri),
                        filetypes=[(_("CSV file"), "*.csv"),(_("HTML file"), "*.html"),(_("XML file"), "*.xml"),(_("JSON file"), "*.json")],
                        defaultextension=".csv")
                if not filename:
                    return False
                try:
                    if isinstance(view, ViewWinRoleTypes.ViewRoleTypes):
                        ViewFileRoleTypes.viewRoleTypes(modelXbrl, filename, view.tabTitle, view.isArcrole, lang=view.lang)
                    elif isinstance(view, ViewWinConcepts.ViewConcepts):
                        ViewFileConcepts.viewConcepts(modelXbrl, filename, labelrole=view.labelrole, lang=view.lang)
                    elif isinstance(view, ViewWinFactList.ViewFactList):
                        ViewFileFactList.viewFacts(modelXbrl, filename, labelrole=view.labelrole, lang=view.lang)
                    else:
                        ViewFileRelationshipSet.viewRelationshipSet(modelXbrl, filename, view.tabTitle, view.arcrole, labelrole=view.labelrole, lang=view.lang)
                except (IOError, EnvironmentError) as err:
                    tkinter.messagebox.showwarning(_("arelle - Error"),
                                        _("Failed to save {0}:\n{1}").format(
                                        filename, err),
                                        parent=self.parent)
                return True
                
            elif isinstance(view, ViewWinXml.ViewXml) and self.modelManager.modelXbrl.formulaOutputInstance:
                filename = self.uiFileDialog("save",
                        title=_("arelle - Save Formula Result Instance Document"),
                        initialdir=os.path.dirname(self.modelManager.modelXbrl.modelDocument.uri),
                        filetypes=[(_("XBRL output instance .xml"), "*.xml"), (_("XBRL output instance .xbrl"), "*.xbrl")],
                        defaultextension=".xml")
                if not filename:
                    return False
                try:
                    from arelle import XmlUtil
                    with open(filename, "w") as fh:
                        XmlUtil.writexml(fh, self.modelManager.modelXbrl.formulaOutputInstance.modelDocument.xmlDocument, encoding="utf-8")
                    self.addToLog(_("[info] Saved formula output instance to {0}").format(filename) )
                except (__HOLE__, EnvironmentError) as err:
                    tkinter.messagebox.showwarning(_("arelle - Error"),
                                    _("Failed to save {0}:\n{1}").format(
                                    self.filename, err),
                                    parent=self.parent)
                return True
        tkinter.messagebox.showwarning(_("arelle - Save what?"), 
                                       _("Nothing has been selected that can be saved.  \nPlease select a view pane that can be saved."),
                                       parent=self.parent)
        '''
        if self.filename is None:
            filename = self.uiFileDialog("save",
                    title=_("arelle - Save File"),
                    initialdir=".",
                    filetypes=[(_("Xbrl file"), "*.x*")],
                    defaultextension=".xbrl")
            if not filename:
                return False
            self.filename = filename
            if not self.filename.endswith(".xbrl"):
                self.filename += ".xbrl"
        try:
            with open(self.filename, "wb") as fh:
                pickle.dump(self.data, fh, pickle.HIGHEST_PROTOCOL)
            self.dirty = False
            self.uiShowStatus(_("Saved {0} items to {1}").format(
                                len(self.data),
                                self.filename), clearAfter=5000)
            self.parent.title(_("arelle - {0}").format(
                                os.path.basename(self.filename)))
        except (EnvironmentError, pickle.PickleError) as err:
            tkinter.messagebox.showwarning(_("arelle - Error"),
                                _("Failed to save {0}:\n{1}").format(
                                self.filename, err),
                                parent=self.parent)
        return True;
        '''
dataset/ETHPy150Open Arelle/Arelle/arelle/CntlrWinMain.py/CntlrWinMain.fileSave