#Initialization and configuration + - def __init__(self, parent, id, title):
global logger global _tree + - wxFrame.__init__(self, parent, -1, title, size = (840,640),
style=wxDEFAULT_FRAME_STYLE|wxNO_FULL_REPAINT_ON_RESIZE)
|
self.cwd = os.getcwd() self.schematable={} self.history=[] self.forwardhistory=[] self.historyoffset=0 self.userhome=os.environ['HOME'] autoconfig=0 + - if wxPlatform != '__WXMSW__':
cfgfile=self.userhome+'/buzz.cfg' self.userhome=self.userhome+'/' + - if not self.LoadConfig(cfgfile):
icon = wxIcon(self.buzzdir+'buzz.xpm', wxBITMAP_TYPE_XPM) self.SetIcon(icon) EVT_IDLE(self, self.OnIdle)
|
+ - else:
cfgfile=self.userhome+'\\buzz.cfg' self.userhome=self.userhome+'\\' + - if not self.LoadConfig(cfgfile):
icon = wxIcon(self.buzzdir+'buzz.ico', wxBITMAP_TYPE_ICO) self.SetIcon(icon)
|
self.curOverview = '' self.otherWin = None EVT_CLOSE(self, self.OnClose) self.Centre(wxBOTH) self.CreateStatusBar(1, wxST_SIZEGRIP) splitter2 = wxSplitterWindow(self, -1, style=wxNO_3D | wxSP_3D) self.dying = false self.mainmenu = wxMenuBar() menu = wxMenu() xmlmenu = wxMenu() setxmarkID = wxNewId() xmarksID = wxNewId() delxmarksID = wxNewId() opmlmenu = wxMenu() optionsmenu = wxMenu() self.Popup= wxMenu() popupinsertchildID=wxNewId() popupsiblingID=wxNewId() popupcopyID=wxNewId() popuppasteID=wxNewId() popupcutID=wxNewId() exitID = wxNewId() openID = wxNewId() newID = wxNewId() newxmlID = wxNewId() saveID = wxNewId() saveasID = wxNewId() savehtmlID = wxNewId() saveasXMLID = wxNewId() importID = wxNewId() importnonutfID = wxNewId() exportID = wxNewId() exportoutlineID = wxNewId() importoutlineID = wxNewId() exporthtmlID = wxNewId() exportcsvID=wxNewId() importhtmlID = wxNewId() importhtmlcsvID = wxNewId() importcsvID = wxNewId() printID = wxNewId() webifyID = wxNewId() webifyxmlID = wxNewId() dtID = wxNewId() importdtID = wxNewId() exportdtID = wxNewId() exportshadowID = wxNewId() importshadowID = wxNewId() importlproID = wxNewId() exportlproID = wxNewId() urlID=wxNewId() recentID=wxNewId() recenturlID=wxNewId() schemaID=wxNewId() setschemaID=wxNewId() schemaexampleID=wxNewId() attschemaexampleID=wxNewId() renderxslID=wxNewId() renderfileID=wxNewId() renderxslinplaceID=wxNewId() renderdirID=wxNewId() xrenderdirID=wxNewId() fopID=wxNewId() xslfoID=wxNewId() findandreplaceID=wxNewId() textentryID=wxNewId() casesensitiveID=wxNewId() freeformxmlID=wxNewId() wrapopenID=wxNewId() dclickactivateID=wxNewId() davID=wxNewId() renderopenID=wxNewId() previewID=wxNewId() popuppasteclipID=wxNewId() popupexpandID=wxNewId() popupfreetextID=wxNewId() xmlpastetextID=wxNewId() expandkeyID=wxNewId() vcalexportID=wxNewId() configurationID=wxNewId() self.Popup.Append(popupexpandID,'Expand','Expand') self.Popup.Append(popupinsertchildID,'Insert Child','Insert Child') self.Popup.Append(popupsiblingID,'Insert Sibling','Insert Sibling') self.Popup.Append(popupcopyID,'Copy Node','Copy Node') self.Popup.Append(popupcutID,'Cut Node','Cut Node') self.Popup.Append(popuppasteID,'Paste Node','Paste Node') self.Popup.Append(popuppasteclipID,'Paste Clipboard','Paste Clipboard') self.Popup.Append(popupfreetextID,'Free Text','Free Text') optionsmenu.Append(findandreplaceID, '&Toggle Interactive Find and Replace', 'Find and Replace') optionsmenu.Append(casesensitiveID, '&Toggle Case Sensitive Find', 'Case Sensitive') optionsmenu.Append(freeformxmlID, '&Toggle Free Form XML', 'XML Free Form') optionsmenu.Append(wrapopenID, '&Wrap Text fields in XML', 'Toggle Wrap Text fields') #optionsmenu.Append(textentryID, '&Toggle Continuous Text Entry', 'Text Entry Mode') #optionsmenu.Append(dclickactivateID, '&Toggle Always insert with DClick', 'Insert On Double Click') optionsmenu.Append(configurationID, '&Configure Buzz', 'Configure') menu.Append(openID, '&Open', 'Open a file') menu.Append(newID, '&New OPML', 'New OPML file') xmlmenu.Append(importnonutfID, '&Open XML', 'Import non latin1') xmlmenu.Append(newxmlID, '&New Generic XML', 'New XML file') menu.Append(recentID, '&Choose Recent File','Choose') menu.Append(recenturlID, '&Choose Recent URL','Choose') menu.Append(urlID, '&Open URL', 'Open File at URL') menu.Append(renderopenID, '&Render Open', 'Render Open') menu.Append(printID, '&Print OPML','Print file') menu.Append(previewID, '&Preview HTML ','Preview') menu.Append(webifyID, '&Webify', 'Prepare for web publication') opmlmenu.Append(importID, '&Import Text File', 'Import text file') opmlmenu.Append(exportID, '&Export Text File', 'Export text file') opmlmenu.Append(exporthtmlID, '&Export Smart HTML', 'Export Smart HTML') opmlmenu.Append(importhtmlID, '&Import HTML', 'Import HTML') xmlmenu.Append(webifyxmlID, '&Webify XML(+ XML to OPML)', 'Prepare for web publication') xmlmenu.Append(dtID, '&Preview Decision Tree', 'Make OpNote Decision Tree') opmlmenu.Append(importdtID, '&Import Decision Tree', 'Import OpNote Decision Tree') opmlmenu.Append(exportdtID, '&Export Decision Tree', 'Export OpNote Decision Tree') opmlmenu.Append(exportshadowID, '&Export Shadow', 'Export Shadow Plan') opmlmenu.Append(importshadowID, '&Import Shadow', 'Import Shadow Plan') opmlmenu.Append(exportlproID, '&Export Lpro', 'Export Lpro') opmlmenu.Append(importlproID, '&Import Lpro', 'Import Lpro') opmlmenu.Append(exportoutlineID, '&Export MS Word HTML', 'Export HTML Outline') opmlmenu.Append(importoutlineID, '&Import MS Word HTML', 'Import HTML Outline') opmlmenu.Append(importhtmlcsvID, '&Import CSV to HTML', 'Import CSV to HTML') opmlmenu.Append(importcsvID, '&Import CSV to XML', 'Import CSV to XML') opmlmenu.Append(exportcsvID, '&Export XML to CSV', 'Export XML to CSV') opmlmenu.Append(vcalexportID, '&Export OPML to vCal', 'Export OPML to vCal') opmlmenu.Append(fopID, '&FOP to Acrobat', 'Render Via FOP') opmlmenu.Append(xslfoID, '&Render to Acrobat', 'Render Via XSLFO') opmlmenu.Append(renderxslID, '&Render to Browser', 'Render Via XSL') opmlmenu.Append(renderfileID, '&Render to File', 'Render to File') opmlmenu.Append(renderxslinplaceID, '&Render in Place', 'Render Via XSL') opmlmenu.Append(renderdirID, '&Render Directory', 'Render Directory') opmlmenu.Append(xrenderdirID, '&X Render Directory', 'Render Directory') menu.Append(saveID, '&Save', 'Save file') menu.Append(saveasID, 'Save &As','Save as') menu.Append(savehtmlID, 'Save &HTML','Save as') xmlmenu.Append(saveasXMLID, 'Save as XML','Save as XML') #menu.Append(davID, 'Save to DAV','Save to DAV') xmlmenu.Append(schemaID, 'New from Schema','Set Schema') xmlmenu.Append(setschemaID, 'Set Schema','Set Schema') xmlmenu.Append(xmarksID, '&X Favorites','Favorites') xmlmenu.Append(delxmarksID, '&Delete Favorites','Del Favorites') menu.Append(exitID, 'E&xit', 'Get the heck outta here!') xmlmenu.Append(setxmarkID, '&Add Favorite') xmlmenu.Append(schemaexampleID, '&Schema from example') xmlmenu.Append(attschemaexampleID, '&Schema from example with attributes') xmlmenu.Append(expandkeyID, '&Set XML Expand Node') EVT_MENU(self, popupinsertchildID, self.OnRightInsert) EVT_MENU(self, vcalexportID, self.OnExportVcal) EVT_MENU(self, expandkeyID, self.OnSetExpandKey) EVT_MENU(self, popupexpandID, self.OnExpand) EVT_MENU(self, popupsiblingID, self.OnSibling) EVT_MENU(self, popupcutID, self.OnDelete) EVT_MENU(self, popupcopyID, self.OnCopy) EVT_MENU(self, popuppasteID, self.OnLocalPaste) EVT_MENU(self, popuppasteclipID, self.OnPaste) EVT_MENU(self, popupfreetextID, self.OnFreeText) EVT_MENU(self, renderopenID, self.OnRenderOpen) EVT_MENU(self, setxmarkID, self.OnSetXMark) EVT_MENU(self, schemaexampleID, self.OnSchemaExample) EVT_MENU(self, attschemaexampleID, self.OnAttSchemaExample) EVT_MENU(self, findandreplaceID, self.OnFindAndReplace) EVT_MENU(self, casesensitiveID, self.OnCaseSensitive) EVT_MENU(self, freeformxmlID, self.OnFreeFormXML) EVT_MENU(self, wrapopenID, self.OnWrapOpen) EVT_MENU(self, dclickactivateID, self.OnDClickActivate) EVT_MENU(self, textentryID, self.OnTextEntry) EVT_MENU(self, recentID, self.OnRecent) EVT_MENU(self, davID, self.OnSavetoDAV) EVT_MENU(self, xmarksID, self.OnXmarks) EVT_MENU(self, delxmarksID, self.OnDeleteXmarks) EVT_MENU(self, recentID, self.OnRecent) EVT_MENU(self, recenturlID, self.OnRecentURL) EVT_MENU(self, newID, self.OnNew) EVT_MENU(self, newxmlID, self.OnNewXML) EVT_MENU(self, importID, self.OnImport) EVT_MENU(self, exportID, self.OnExport) EVT_MENU(self, exportoutlineID, self.OnExportOutline) EVT_MENU(self, importoutlineID, self.OnImportOutline) EVT_MENU(self, importhtmlcsvID, self.OnImportHTMLCSV) EVT_MENU(self, importcsvID, self.OnImportCSV) EVT_MENU(self, exportcsvID, self.OnExportCSV) EVT_MENU(self, exporthtmlID, self.OnExportHTML) EVT_MENU(self, importhtmlID, self.OnImportHTML) EVT_MENU(self,fopID, self.OnFOP) EVT_MENU(self,xslfoID, self.OnXSLFO) EVT_MENU(self,renderxslID, self.OnRenderXSL) EVT_MENU(self,renderfileID, self.OnRenderFile) EVT_MENU(self,renderxslinplaceID, self.OnRenderInPlace) EVT_MENU(self,renderdirID, self.OnRenderDir) EVT_MENU(self,xrenderdirID, self.OnXRenderDir) EVT_MENU(self,importnonutfID, self.OnNonUTF) EVT_MENU(self, webifyID, self.OnWebify) EVT_MENU(self, webifyxmlID, self.OnWebifyXML) EVT_MENU(self, dtID, self.OnDT) EVT_MENU(self, importdtID, self.OnImportDT) EVT_MENU(self, exportdtID, self.OnExportDT) EVT_MENU(self, printID, self.OnPrint) EVT_MENU(self, exportshadowID, self.OnExportShadow) EVT_MENU(self, importshadowID, self.OnImportShadow) EVT_MENU(self, exportlproID, self.OnExportLpro) EVT_MENU(self, importlproID, self.OnImportLpro) EVT_MENU(self, urlID, self.OnURL) EVT_MENU(self, openID, self.OnOpen) EVT_MENU(self, saveID, self.OnSave) EVT_MENU(self, saveasID, self.OnSaveAs) EVT_MENU(self, savehtmlID, self.OnSaveHTML) EVT_MENU(self, saveasXMLID, self.OnSaveAsXML) EVT_MENU(self, schemaID, self.OnSchema) EVT_MENU(self, setschemaID, self.OnSetSchema) EVT_MENU(self, exitID, self.OnFileExit) EVT_MENU(self, previewID, self.OnPreviewHTML) EVT_MENU(self, configurationID, self.OnConfigure) editmenu=wxMenu() manilamenu=wxMenu() pasteID=wxNewId() copyID=wxNewId() attachID=wxNewId() imgID=wxNewId() manpostID=wxNewId() mansaveID=wxNewId() findID=wxNewId() insertfileID=wxNewId() findrepID=wxNewId() xsearchID=wxNewId() inserturlfileID=wxNewId() editmenu.Append(pasteID, '&Paste Clipboard Ctrl-P', 'Paste from clipboard - Ctrl-P') editmenu.Append(xmlpastetextID, '&Paste clipboard as CDATA') EVT_MENU(self, xmlpastetextID, self.OnPasteCDATA) manilamenu.Append(manpostID, '&Post to Manila Site', 'Post') manilamenu.Append(mansaveID, '&Save to Manila Site', 'Save') editmenu.Append(copyID, '&Copy', 'Copy') editmenu.Append(attachID, '&Insert URL Ctrl-U', 'Create a reference to an external object') editmenu.Append(imgID, '&Insert Object/Image Ctrl-O', 'Insert Image') editmenu.Append(insertfileID, '&Insert File F12', 'Insert File') editmenu.Append(inserturlfileID, '&Insert File from URL F11', 'Insert File') editmenu.Append(findID, '&Find Item Ctrl-F', 'Find') editmenu.Append(findrepID, '&Find and Replace Item', 'Find and Replace') editmenu.Append(xsearchID, 'X Search', 'X search') EVT_MENU(self, manpostID, self.OnPost) EVT_MENU(self, mansaveID, self.OnManilaSave) EVT_MENU(self, pasteID, self.OnPaste) EVT_MENU(self, copyID, self.OnCopy) EVT_MENU(self, attachID, self.OnAttach) EVT_MENU(self, imgID, self.OnImage) EVT_MENU(self, findID, self.OnFind) EVT_MENU(self, findrepID, self.OnFindRep) EVT_MENU(self, xsearchID, self.OnXSearch) EVT_MENU(self, insertfileID, self.OnInsertFile) EVT_MENU(self, inserturlfileID, self.OnExpandURL) self.mainmenu.Append(menu, '&File') self.mainmenu.Append(opmlmenu, '&Import/Export') self.mainmenu.Append(editmenu, '&Edit') self.mainmenu.Append(xmlmenu, '&XML') self.mainmenu.Append(optionsmenu, '&Options') self.mainmenu.Append(manilamenu, '&Manila') helpmenu=wxMenu() helpID=wxNewId() fullhelpID=wxNewId() helpmenu.Append(helpID, '&Quick Help','QuickHelp') helpmenu.Append(fullhelpID, '&Help File','Help File') EVT_MENU(self, helpID, self.OnHelp) EVT_MENU(self, fullhelpID, self.OnFullHelp) self.mainmenu.Append(helpmenu, '&Help') self.SetMenuBar(self.mainmenu) self.lastfoundroot=0 self.currentfindstr='' self.findcount=1 self.casesensitive=0 self.currentfind=0 self.modified=0 self.lastitem=0 self.textentrymode=0 splitter3 = wxSplitterWindow(splitter2, -1, style=wxNO_3D |wxSP_3D) toolID=wxNewId() toolforwardID=wxNewId() toolrecentID=wxNewId() homeID=wxNewId() toolrecentfileID=wxNewId() toolopenID=wxNewId() toolnewID=wxNewId() toolschemaID=wxNewId() toolsaveID=wxNewId() toolwebID=wxNewId() toolprintID=wxNewId() toolrootfindID=wxNewId() toolrepeatID=wxNewId() toolpasteID=wxNewId() toolpictureID=wxNewId() toolcopyID=wxNewId() toollocalpasteID=wxNewId() tooldeleteID=wxNewId() toolfreetextID=wxNewId() toolxmarksID=wxNewId() toolxmarkID=wxNewId() toolattrID=wxNewId() tooltextID=wxNewId() toolinsertxlinkID=wxNewId() tooljoinID=wxNewId() tooloneID=wxNewId() tooltwoID=wxNewId() toolthreeID=wxNewId() toolfourID=wxNewId() self.tb = wxToolBarSimple(splitter3, -1, wxDefaultPosition, wxDefaultSize, wxTB_HORIZONTAL | wxRAISED_BORDER | wxTB_FLAT) self.tb.AddSimpleTool(toolID,wxBitmap(self.buzzdir+'backarrow.bmp',wxBITMAP_TYPE_BMP) , "Last", "History Back") self.tb.AddSeparator() self.tb.AddSimpleTool(toolforwardID,wxBitmap(self.buzzdir+'forwardarrow.bmp',wxBITMAP_TYPE_BMP) , "Last", "History Forward") self.tb.AddSeparator() self.tb.AddSimpleTool(toolrecentID,wxBitmap(self.buzzdir+'recent.bmp',wxBITMAP_TYPE_BMP) , "Recent", "History") self.tb.AddSeparator() self.tb.AddSimpleTool(homeID,wxBitmap(self.buzzdir+'home.bmp',wxBITMAP_TYPE_BMP) , "Home", "Home") self.tb.AddSeparator() self.tb.AddSimpleTool(toolrecentfileID,wxBitmap(self.buzzdir+'recentfile.bmp',wxBITMAP_TYPE_BMP) , "Recent", "Recent Files") self.tb.AddSeparator() self.tb.AddSimpleTool(toolopenID,wxBitmap(self.buzzdir+'open.bmp',wxBITMAP_TYPE_BMP) , "Open", "Open File") self.tb.AddSeparator() self.tb.AddSimpleTool(toolnewID,wxBitmap(self.buzzdir+'newopml.bmp',wxBITMAP_TYPE_BMP) , "New", " New OPML") self.tb.AddSeparator() self.tb.AddSimpleTool(toolschemaID,wxBitmap(self.buzzdir+'newxml.bmp',wxBITMAP_TYPE_BMP) , "Schema", " New XML from Schema") self.tb.AddSeparator() self.tb.AddSimpleTool(toolsaveID,wxBitmap(self.buzzdir+'save.bmp',wxBITMAP_TYPE_BMP) , "Save", "Save") self.tb.AddSeparator() self.tb.AddSimpleTool(toolwebID,wxBitmap(self.buzzdir+'globe.bmp',wxBITMAP_TYPE_BMP) , "Webify", "Render to Web Format") self.tb.AddSeparator() self.tb.AddSimpleTool(toolprintID,wxBitmap(self.buzzdir+'print.bmp',wxBITMAP_TYPE_BMP) , "Print", "Render to Print Format") self.tb.AddSeparator() self.tb.AddSimpleTool(toolrootfindID,wxBitmap(self.buzzdir+'rootfind.bmp',wxBITMAP_TYPE_BMP) , "Find", " Find in Document") self.tb.AddSeparator() self.tb.AddSimpleTool(toolrepeatID,wxBitmap(self.buzzdir+'repeat.bmp',wxBITMAP_TYPE_BMP) , "Repeat", " Repeat Find") self.tb.AddSeparator() self.tb.AddSimpleTool(toolpasteID,wxBitmap(self.buzzdir+'paste.bmp',wxBITMAP_TYPE_BMP) , "Paste", " Paste External Clipboard") self.tb.AddSeparator() self.tb.AddSimpleTool(toolpictureID,wxBitmap(self.buzzdir+'picture.bmp',wxBITMAP_TYPE_BMP) , "Insert Image", " Insert Image") self.tb.AddSeparator() self.tb.AddSimpleTool(toolcopyID,wxBitmap(self.buzzdir+'copy.bmp',wxBITMAP_TYPE_BMP) , "Copy", " Copy") self.tb.AddSeparator() self.tb.AddSimpleTool(toollocalpasteID,wxBitmap(self.buzzdir+'localpaste.bmp',wxBITMAP_TYPE_BMP) , "Local Paste", " Paste") self.tb.AddSeparator() self.tb.AddSimpleTool(tooldeleteID,wxBitmap(self.buzzdir+'delete.bmp',wxBITMAP_TYPE_BMP) , "Delete", " Delete") self.tb.AddSeparator() self.tb.AddSimpleTool(toolfreetextID,wxBitmap(self.buzzdir+'freetext.bmp',wxBITMAP_TYPE_BMP) , "Free Text", " Enter Free Form Text") self.tb.AddSeparator() self.tb.AddSimpleTool(toolxmarksID,wxBitmap(self.buzzdir+'xmarks.bmp',wxBITMAP_TYPE_BMP) , "Favorites", " Favorites") self.tb.AddSeparator() self.tb.AddSimpleTool(toolxmarkID,wxBitmap(self.buzzdir+'setxmark.bmp',wxBITMAP_TYPE_BMP) , "Set Favorite", "Set Favorite") self.tb.AddSeparator() self.tb.AddSimpleTool(toolattrID,wxBitmap(self.buzzdir+'attr.bmp',wxBITMAP_TYPE_BMP) , "Attribute", " Add XML Attribute") self.tb.AddSeparator() self.tb.AddSimpleTool(tooltextID,wxBitmap(self.buzzdir+'text.bmp',wxBITMAP_TYPE_BMP) , "Text", " Add XML CDATA/Text ") self.tb.AddSeparator() self.tb.AddSimpleTool(toolinsertxlinkID,wxBitmap(self.buzzdir+'xlink.bmp',wxBITMAP_TYPE_BMP) , "Insert Xlink", " Insert Xlink") self.tb.AddSeparator() self.tb.AddSimpleTool(tooljoinID,wxBitmap(self.buzzdir+'join.bmp',wxBITMAP_TYPE_BMP) , "Join Nodes", " Join two nodes") self.tb.AddSeparator() self.tb.AddSimpleTool(tooloneID,wxBitmap(self.buzzdir+'one.bmp',wxBITMAP_TYPE_BMP) , "One", " Expand One down") self.tb.AddSeparator() self.tb.AddSimpleTool(tooltwoID,wxBitmap(self.buzzdir+'two.bmp',wxBITMAP_TYPE_BMP) , "Two", " Expand Two Levels down") self.tb.AddSeparator() self.tb.AddSimpleTool(toolthreeID,wxBitmap(self.buzzdir+'three.bmp',wxBITMAP_TYPE_BMP) , "Three", " Three") self.tb.AddSeparator() self.tb.AddSimpleTool(toolfourID,wxBitmap(self.buzzdir+'four.bmp',wxBITMAP_TYPE_BMP) , "Four", " Four") EVT_TOOL(self, toolID, self.OnHistoryBackward) EVT_TOOL(self, toolnewID, self.OnNew) EVT_TOOL(self, toolforwardID, self.OnHistoryForward) EVT_TOOL(self, toolrecentID, self.OnHistory) EVT_TOOL(self, toolrecentfileID, self.OnRecent) EVT_TOOL(self, toolsaveID, self.OnSave) EVT_TOOL(self, toolopenID, self.OnOpen) EVT_TOOL(self, toolprintID, self.OnPrint) EVT_TOOL(self, homeID, self.OnHome) EVT_TOOL(self, toolxmarkID, self.OnSetXMark) EVT_TOOL(self, toolxmarksID, self.OnXmarks) EVT_TOOL(self, toolrootfindID, self.OnRootFind) EVT_TOOL(self, toolrepeatID, self.OnFindAgain) EVT_TOOL(self, toolpasteID, self.OnPaste) EVT_TOOL(self, toolpictureID, self.OnImage) EVT_TOOL(self, toolschemaID, self.OnSchema) EVT_TOOL(self, toolcopyID, self.OnCopy) EVT_TOOL(self, toollocalpasteID, self.OnLocalPaste) EVT_TOOL(self, tooldeleteID, self.OnDelete) EVT_TOOL(self, toolattrID, self.OnAttr) EVT_TOOL(self, tooltextID, self.OnText) EVT_TOOL(self, toolinsertxlinkID, self.OnInsertXlink) EVT_TOOL(self, tooljoinID, self.OnJoin) EVT_TOOL(self, toolwebID, self.OnWebify) EVT_TOOL(self, toolfreetextID, self.OnFreeText) EVT_TOOL(self,tooloneID,self.OnOne) EVT_TOOL(self,tooltwoID,self.OnTwo) EVT_TOOL(self,toolthreeID,self.OnThree) EVT_TOOL(self,toolfourID,self.OnFour) EVT_TOOL_ENTER(self,-1,self.OnMyToolEnter) self.tb.Realize() + - self.log = wxTextCtrl(splitter2, -1,
style = wxTE_MULTILINE|wxTE_READONLY|wxHSCROLL)
|
logger = self.log wxLog_SetActiveTarget(wxLogTextCtrl(self.log)) tID = NewId() + - if len(sys.argv) > 2:
highlight =int(sys.argv[2])
|
+ - else:
self.schema=None self.tree = XMLTreeCtrl(splitter3, tID,highlight) _tree = self.tree opener=None self.filename = None self.file_buffers=['','','','','','','','','',''] self.url_buffers=['','','','','','','','','',''] self.xmarks=[] + - for i in range(50):
self.xmarks.append(("",""))
|
self.LoadRecent() self.LoadRecentURL() self.LoadXmarks() self.cut_buffers=[None,None,None,None,None,None,None,None,None,None] self.currentcut=0 self.modified = 0 self.inedit=0 self.InsertonActivate=0 self.findandreplace=0 self.expandkey="" self.wrapopen=0 + - if len(sys.argv) > 1:
+ - if not opener:
+ - if len(self.file_buffers[0]):
opener=self.file_buffers[0]
|
+ - else:
opener=self.buzzdir+'buzz.opml'
|
|
self.item=self.tree.root EVT_KEY_DOWN(self.tree,self.OnKey) #EVT_TREE_KEY_DOWN(self.tree,tID,self.OnKey) EVT_TREE_SEL_CHANGED (self.tree, tID, self.OnSelChanged) EVT_TREE_BEGIN_LABEL_EDIT(self.tree, tID, self.OnBeginEdit) #EVT_TREE_END_LABEL_EDIT(self.tree, tID, self.OnEndEdit) EVT_TREE_ITEM_ACTIVATED (self.tree, tID, self.OnActivate) + - if wxPlatform == '__WXMSW__':
EVT_LEFT_DCLICK (self.tree, self.OnDClick)
|
EVT_RIGHT_DOWN(self.tree, self.OnRightClick) EVT_RIGHT_UP(self.tree, self.OnRightUp) splitter3.SplitHorizontally(self.tb,self.tree ) splitter3.SetMinimumPaneSize(20) splitter2.SplitHorizontally(splitter3 ,self.log) splitter3.SetSashPosition(25,true) splitter2.SetSashPosition(510, true) splitter2.SetMinimumPaneSize(20) self.splitter2=splitter2 self.splitter3=splitter3 self.Show(true) + - if autoconfig:
self.SetCurrentFile(opener) self.tree.SetFocus()
|
+ - def ImportCSV(self,html=0):
+ - if self.modified:
dlg = wxMessageDialog(self, 'Save before Opening?', 'Save?', wxYES_NO | wxICON_INFORMATION) + - if dlg.ShowModal() == wxID_YES:
+ - if not self.SaveFile():
|
|
filename = self.FileSelector('Open', 'Choose a csv file to open','*',self.cwd,wxOPEN,0) + - if filename:
+ - try:
headings="" + - if not html:
dlg = wxTextEntryDialog(self, 'Root XML Element','Root',"Rows") + - if dlg.ShowModal() == wxID_OK:
+ - else:
dlg = wxTextEntryDialog(self, 'Row XML Element','Row',"Row") + - if dlg.ShowModal() == wxID_OK:
+ - else:
|
+ - else:
rootel="foo" rowel="baz" headings="table"
|
self.log_write('Starting Import') retval=self.MySystem(self.buzzdir+'csv2xml '+self.buzzdir+' '+self.AddSlashes(filename)+' '+rootel+' '+rowel+' '+headings) self.log_write('Completed Import') + - if not retval:
self.SetCurrentFile(filename+'.xml')
|
+ - else:
self.log_write('Import failed. Usually because the csv file is malformed use icsv2xml.py') return None
|
|
+ - except:
self.log_write('Failed to import.') return None
|
|
+ - else:
|
+ - def OnImportCSV(self, *event):
+ - def OnIdle(self,event):
#hack to fix wxGTK focus loss after editlabel + - if not wxWindow_FindFocus():
|
+ - def OnMyToolEnter(self,event):
id=event.GetSelection() + - if id!=-1:
self.SetStatusText(self.tb.GetToolLongHelp(id))
|
+ - else:
|
+ - def OnExportCSV(self, *event):
+ - def ExportCSV(self):
+ - try:
+ - if not self.SaveFile():
self.log_write('Starting Export') retval=self.MySystem(self.buzzdir+'xml2csv '+self.AddSlashes(self.filename)+' '+self.AddSlashes(self.buzzdir)) + - if retval:
self.log.Write('Could not export file')
|
+ - else:
self.log_write('Export completed.')
|
|
+ - except:
self.log_write('Could not export file')
|
|
+ - def OnImportHTMLCSV(self, *event):
+ - def OnPasteCDATA(self, evt):
+ - def OnSetExpandKey(self, evt):
dlg = wxTextEntryDialog(self, 'XML Tag for Expansion','Tag',"") + - if dlg.ShowModal() == wxID_OK:
self.expandkey=dlg.GetValue()
|
|
+ - def PasteXMLText(self):
do = wxTextDataObject() wxTheClipboard.Open() + - if wxPlatform != '__WXMSW__':
wxTheClipboard.UsePrimarySelection(1) success = wxTheClipboard.GetData(do) + - if not success:
wxTheClipboard.UsePrimarySelection(0)
|
|
success = wxTheClipboard.GetData(do) wxTheClipboard.Close() + - if success:
curritem=self.tree.GetSelection() + - if curritem.IsOk():
self.PasteCDATA(curritem,do.GetText()) self.modified=1
|
|
+ - else:
wxMessageBox('There is no data in the clipboard in the required format', 'Error')
|
|
+ - def PasteCDATA(self,item,text):
filename=self.tmpdir+'buzzpaste' outfile = open(filename,'w') + - if outfile:
outfile.write(text) outfile.close() self.log_write("Importing CDATA") retval=self.MySystem(self.buzzdir+'text2cdata '+self.AddSlashes(filename)+' '+self.buzzdir) + - if not retval:
self.tree.nodeStack = [self.item] self.tree.LoadTree(filename+'.xml') self.PromoteClipboard(item) self.tree.Expand(self.item) self.modified=1
|
+ - else:
self.log_write("Import failed")
|
|
|
+ - def LoadConfig(self, filename):
import glob + - if os.path.exists(filename):
fp=open(filename,'r') cfglines=fp.readlines() fp.close() self.buzzdir=cfglines[0][:-1] self.bashcmd=cfglines[1][:-1] self.tmpdir=cfglines[2][:-1] self.fileexpander=cfglines[3][:-1] self.freeformxml=int(cfglines[4][:-1]) self.expanddepth=int(cfglines[5][:-1]) self.home=cfglines[6][:-1] self.manilasite=cfglines[7][:-1] self.manilauser=cfglines[8][:-1] self.usesize=int(cfglines[9][:-1]) schemas=glob.glob(self.buzzdir+'*schema') + - for i in schemas:
(foo,filename)=os.path.split(i) splitline=filename.split('.') self.schematable[splitline[0].upper()]=self.buzzdir+filename
|
return 1
|
+ - else:
sys.stderr.write("Configuration file, buzz.cfg, not found in HOME directory: Using Defaults., Edit Configuration from Options \n") + - if wxPlatform == '__WXMSW__':
self.buzzdir='c:\\cygwin\\usr\\share\\buzz\\' self.bashcmd='c:\\cygwin\\bin\\bash --login -i' self.tmpdir='c:\\cygwin\\tmp\\' self.fileexpander='explorer ' self.freeformxml=1 self.expanddepth=3 self.home='c:\cygwin\usr\share\buzz\buzz.opml' self.manilasite='' self.manilauser='' self.usesize=0 schemas=glob.glob(self.buzzdir+'*schema') + - for i in schemas:
(foo,filename)=os.path.split(i) splitline=filename.split('.') self.schematable[splitline[0].upper()]=self.buzzdir+filename
|
|
+ - else:
self.buzzdir='/usr/share/buzz/' self.bashcmd='' self.tmpdir='/tmp/' self.fileexpander='konqueror ' self.freeformxml=1 self.expanddepth=3 self.home='/usr/share/buzz/buzz.opml' self.manilasite='' self.manilauser='' self.usesize=0 schemas=glob.glob(self.buzzdir+'*schema') + - for i in schemas:
(foo,filename)=os.path.split(i) splitline=filename.split('.') self.schematable[splitline[0].upper()]=self.buzzdir+filename
|
|
return 0
|
|
#manila functions + - def OnPost(self,*event):
import xmlrpclib dlg = wxTextEntryDialog(self, 'Text?','text',"") + - if dlg.ShowModal() == wxID_OK:
dlg = wxTextEntryDialog(self, 'Password?','Password',"") + - if dlg.ShowModal() == wxID_OK:
rpcServer=xmlrpclib.Server(self.manilasite+"RPC2") rstatus=rpcServer.manila.homePage.addToHomePage(self.manilauser,passwd,self.manilasite,s) + - if not rstatus:
self.log_write("Unable to post to site")
|
|
+ - def OnManilaSave(self,*event):
import xmlrpclib + - if self.modified:
+ - dlg = wxMessageDialog(self, 'Save before Converting?',
'Save?', wxYES_NO | wxICON_INFORMATION)
|
+ - if dlg.ShowModal() == wxID_YES:
+ - if not self.SaveFile():
|
|
dlg = wxTextEntryDialog(self, 'Post Name?','Post',"") + - if dlg.ShowModal() == wxID_OK:
dlg = wxTextEntryDialog(self, 'Password?','Password',"") + - if dlg.ShowModal() == wxID_OK:
rpcServer=xmlrpclib.Server(self.manilasite+"RPC2") sitename = rpcServer.manila.getSiteName(self.manilasite) fp=open(self.filename,"r") opmltext=fp.read() fp.close() rstatus = rpcServer.manila.message.create( self.manilauser, passwd, sitename, postname, opmltext, "text/x-opml", 0, 0, 0) + - if not rstatus:
self.log_write("Unable to post to site")
|
|
+ - def OnGetManilaPage(self,*event):
import xmlrpclib + - if self.modified:
+ - dlg = wxMessageDialog(self, 'Save before Converting?',
'Save?', wxYES_NO | wxICON_INFORMATION)
|
+ - if dlg.ShowModal() == wxID_YES:
+ - if not self.SaveFile():
|
|
dlg = wxTextEntryDialog(self, 'Post Name?','Post',"") + - if dlg.ShowModal() == wxID_OK:
dlg = wxTextEntryDialog(self, 'Password?','Password',"") + - if dlg.ShowModal() == wxID_OK:
dlg = wxTextEntryDialog(self, 'Message #?','#',"") + - if dlg.ShowModal() == wxID_OK:
rpcServer=xmlrpclib.Server(self.manilasite+"RPC2") sitename = rpcServer.manila.getSiteName(self.manilasite) f = open ('/tmp/manila.opml', 'w') msgStruct = rpcServer.manila.message.get (self.manilauser, passwd, siteName, messnum) f.write (msgStruct ['body']) f.close ()
|
#Low level interface + - def log_write(self,str):
self.log.write(str) + - if wxPlatform != '__WXMSW__':
|
+ - def OnSelChanged(self, event):
newitem = event.GetItem() + - if (not self.lastitem) or self.item!=newitem:
self.item=newitem
|
+ - def OnSavetoDAV(self,event):
+ - def OnBeginEdit(self, event):
self.modified=1 + - if self.findandreplace:
|
+ - def OnEndEdit(self, event):
+ - def OnKey(self,evt):
global _tree,app key = evt.KeyCode() controldown=evt.HasModifiers() # hack for wxGTK + - if (key < 26) and (key != 8) and (key!=9) and (key!=13):
#self.log_write("Keys is %i and controldown is %i"%(key,controldown)) item = self.tree.GetSelection() + - if not item.IsOk():
#self.log.WriteText('Key %i ' % key ) + - if (key == 348) or (key == ord('D') and controldown):
+ - if self.schema:
data_node=self.tree.GetPyData(item) + - if item == self.tree.root:
+ - else:
tagname=self.tree.GetItemText(item) + - if (data_node.EltType=="__outline"):
|
wrapper=self.schema.ValidChild(self,tagname) + - if wrapper:
+ - if data_node.EltType=="__attr":
currtext=self.tree.GetItemText(item) newtext=currtext+wrapper.Name self.tree.SetItemText(item,newtext) newitem=item
|
+ - else:
isattribute=None + - if wrapper.EltType == "__attr":
# this tells InsertTree to insert item as first child isattribute=-1
|
newitem=self.tree.InsertTree(item,wrapper,isattribute)
|
self.modified=1
|
+ - else:
|
+ - else:
newitem=self.tree.PrependItem(item,' ') self.tree.SetPyData(newitem,ElementWrapper('New Item','__outline')) self.tree.SelectItem(newitem) self.tree.EnsureVisible(newitem) self.tree.EditLabel(newitem) self.tree.SetItemFont(newitem,self.tree.leaffont) self.tree.HighlightTree(item,0)
|
self.tree.SelectItem(newitem) self.tree.EnsureVisible(newitem)
|
+ - elif (key == ord('J') and controldown):
youngersibling = self.tree.GetNextSibling(item) + - if youngersibling.IsOk():
self.currentcut = (self.currentcut + 1) % 10 self.cut_buffers[self.currentcut] = self.CopyModel(youngersibling,0) siblingtext=self.tree.GetItemText(youngersibling) self.tree.Delete(youngersibling) newtext=self.tree.GetItemText(item)+' '+siblingtext self.tree.SetItemText(item,newtext) self.modified=1
|
|
+ - elif (key == ord('J') and evt.ShiftDown()):
cookie=0 (firstchild,flags) = self.tree.GetFirstChild(item,cookie) + - if firstchild.IsOk():
self.currentcut = (self.currentcut + 1) % 10 self.cut_buffers[self.currentcut] = self.CopyModel(firstchild,0) siblingtext=self.tree.GetItemText(firstchild) self.tree.Delete(firstchild) newtext=self.tree.GetItemText(item)+siblingtext self.tree.SetItemText(item,newtext) self.modified=1
|
|
+ - elif (key == 324) or (key == ord('B') and controldown):
+ - if self.cut_buffers[self.currentcut]:
self.modified=1 parentitem=self.tree.GetItemParent(item) + - if not parentitem.IsOk():
newitem=self.tree.InsertTree(item,self.cut_buffers[self.currentcut]) self.modified=1
|
+ - else:
newitem=self.tree.InsertTree(parentitem,self.cut_buffers[self.currentcut],item) self.modified=1
|
self.tree.UnselectAll() self.tree.SelectItem(newitem)
|
self.currentcut=(self.currentcut-1) % 10
|
+ - elif (key == ord('V') and controldown):
+ - if self.cut_buffers[self.currentcut]:
self.modified=1 parentitem=self.tree.GetItemParent(item) + - if not parentitem.IsOk():
newitem=self.tree.InsertTree(item,self.cut_buffers[self.currentcut]) self.modified=1
|
+ - else:
newitem=self.tree.InsertTree(parentitem,self.cut_buffers[self.currentcut],item)
|
self.tree.UnselectAll() self.tree.SelectItem(newitem)
|
|
+ - elif ((key==127) or (key == ord('X') and controldown)) and (item != self.tree.root):
nextitem = self.tree.GetNextSibling(item) previtem = self.tree.GetPrevSibling(item) parent = self.tree.GetItemParent(item) self.currentcut = (self.currentcut + 1) % 10 self.cut_buffers[self.currentcut] = self.CopyModel(item,0) self.CopyToClipboard() + - if nextitem.IsOk():
+ - elif previtem.IsOk():
+ - elif parent.IsOk():
+ - else:
ensureitem=self.tree.root
|
self.tree.Delete(item) self.tree.SelectItem(ensureitem) + - if parent.IsOk():
self.tree.HighlightTree(parent,0)
|
self.tree.EnsureVisible(ensureitem) self.tree.Refresh() self.modified=1
|
+ - elif (key == ord('A') and controldown):
newitem=self.tree.PrependItem(item,'AttributeName=Value') self.tree.SetPyData(newitem,ElementWrapper('New Item','__attr')) self.tree.UnselectAll() self.tree.SelectItem(newitem) self.tree.EditLabel(newitem)
|
+ - elif(key == ord('R') and controldown):
+ - elif(key == ord('U') and controldown):
+ - if item.IsOk():
self.AttachFileObject(item)
|
|
+ - elif(key == ord('O') and controldown):
+ - elif(key == ord('P') and controldown):
+ - elif(key == ord('E') and controldown):
+ - elif (key==353):
+ - elif (key == ord('F') and controldown):
self.lastfoundroot=None self.FindDialog(item)
|
+ - elif key==344:
+ - elif (key == ord('T') and controldown):
newitem=self.tree.AppendItem(item,' ') self.tree.SetPyData(newitem,ElementWrapper('New Item','__data')) self.tree.UnselectAll() self.tree.SelectItem(newitem) self.tree.EditLabel(newitem) self.modified=1
|
+ - elif (key == 342) or (key == ord('S') and controldown):
+ - elif (key == ord('C') and controldown):
self.currentcut=(self.currentcut+1) %10 self.cut_buffers[self.currentcut] = self.CopyModel(item,0) self.CopyToClipboard() self.log_write('Copied Node\n')
|
+ - elif (key==345):
url=self.tree.GetItemText(item) os.system(self.fileexpander+self.AddSlashes(url))
|
+ - elif key==344:
+ - elif key==350:
+ - elif key == 351:
+ - elif key == 343:
+ - if item.IsOk():
self.ExpandAll(item,0,self.expanddepth)
|
|
+ - elif key==352:
+ - elif key == 346:
parentitem=self.tree.GetItemParent(item) grandparentitem=self.tree.GetItemParent(parentitem) + - if grandparentitem.IsOk():
+ - if self.schema:
data_node=self.tree.GetPyData(grandparentitem) tagname=data_node.EltType wrapper=self.schema.ValidChild(self,tagname) + - if wrapper:
isattribute=None + - if wrapper.EltType == "__attr":
# this tells InsertTree to insert item as first child isattribute=-1
|
newitem=self.tree.InsertTree(grandparentitem,wrapper,isattribute) self.modified=1
|
+ - else:
|
+ - else:
newitem=self.tree.InsertItem(grandparentitem,parentitem,' ') self.tree.SetPyData(newitem,ElementWrapper('New Item','__outline')) self.tree.EnsureVisible(newitem) self.tree.EditLabel(newitem) self.tree.SetItemFont(newitem,self.tree.leaffont) self.tree.HighlightTree(grandparentitem,0)
|
self.tree.SelectItem(newitem)
|
|
+ - elif (key == 347) or ((key == ord('O') and controldown)):
parentitem=self.tree.GetItemParent(item) + - if self.schema:
data_node=self.tree.GetPyData(parentitem) tagname=data_node.EltType wrapper=self.schema.ValidChild(self,tagname) + - if wrapper:
+ - if wrapper.EltType == "__attr":
# this tells InsertTree to insert item as first child item=-1
|
newitem=self.tree.InsertTree(parentitem,wrapper,item) self.modified=1
|
+ - else:
|
+ - else:
newitem=self.tree.InsertItem(parentitem,item,' ') self.tree.SetPyData(newitem,ElementWrapper('New Item','__outline')) self.tree.EnsureVisible(newitem) self.tree.EditLabel(newitem) self.tree.SetItemFont(newitem,self.tree.leaffont)
|
self.tree.SelectItem(newitem)
|
+ - elif key == 349:
+ - if self.lastitem and self.lastitem.IsOk():
self.tree.SelectItem(self.lastitem) self.tree.EnsureVisible(self.lastitem)
|
|
+ - elif key == 8:
father = self.tree.GetItemParent(item) grandfather=self.tree.GetItemParent(father) + - if grandfather.IsOk():
tmpbuffer = self.CopyModel(item,0) self.tree.Delete(item) newitem=self.tree.InsertTree(grandfather,tmpbuffer,father) self.modified=1 self.tree.SelectItem(newitem)
|
|
+ - elif key == 9:
parentitem = self.tree.GetPrevSibling(item) + - if parentitem.IsOk():
tmpbuffer = self.CopyModel(item,0) self.tree.Delete(item) newitem=self.tree.InsertTree(parentitem,tmpbuffer) self.modified=1 self.tree.SelectItem(newitem)
|
|
+ - elif key == 314:
parentitem = self.tree.GetItemParent(item) youngersibling = self.tree.GetNextSibling(item) + - if parentitem.IsOk() and youngersibling.IsOk():
tmpbuffer = self.CopyModel(item,0) self.tree.Delete(item) newitem=self.tree.InsertTree(parentitem,tmpbuffer,youngersibling) self.tree.SelectItem(newitem) self.modified=1
|
|
+ - elif key == 315:
parentitem = self.tree.GetItemParent(item) oldersibling = self.tree.GetPrevSibling(item) olderoldersibling = self.tree.GetPrevSibling(oldersibling) + - if parentitem.IsOk() and oldersibling.IsOk():
tmpbuffer = self.CopyModel(item,0) self.tree.Delete(item) newitem=self.tree.InsertTree(parentitem,tmpbuffer,olderoldersibling) self.tree.SelectItem(newitem) self.modified=1
|
|
+ - elif key == 13:
self.tree.EditLabel(item)
|
+ - else:
self.tree.Refresh()
|
+ - def OnRightClick(self, event):
pt = event.GetPosition() item, flags = self.tree.HitTest(pt) self.tree.SelectItem(item)
|
+ - def OnConfigure(self, event):
+ - def Configure(self):
dlg = wxTextEntryDialog(self, 'Enter Directory where buzz is found','Directory',self.buzzdir) + - if dlg.ShowModal() != wxID_OK:
self.buzzdir=dlg.GetValue() dlg = wxTextEntryDialog(self, 'Enter Bash Command ','Directory',self.bashcmd) + - if dlg.ShowModal() != wxID_OK:
self.bashcmd=dlg.GetValue() dlg = wxTextEntryDialog(self, 'Enter Temp Directory ','Directory',self.tmpdir) + - if dlg.ShowModal() != wxID_OK:
self.tmpdir=dlg.GetValue() dlg = wxTextEntryDialog(self, 'Enter program to expand files ','Directory',self.fileexpander) + - if dlg.ShowModal() != wxID_OK:
self.fileexpander=dlg.GetValue() dlg = wxMessageDialog(self, 'Allow Free Form XML?', 'Allow?', wxYES_NO | wxICON_INFORMATION) + - if dlg.ShowModal() == wxID_YES:
+ - else:
dlg = wxTextEntryDialog(self, 'Depth to expand on F10 ','Depth',"%i"%self.expanddepth) + - if dlg.ShowModal() != wxID_OK:
self.expanddepth=int(dlg.GetValue()) filename = self.FileSelector('Open', 'Choose the home file','*',self.cwd,wxOPEN,0) + - if not filename:
self.home=filename dlg = wxTextEntryDialog(self, 'Enter Manila Site ','Manila',self.manilasite) + - if dlg.ShowModal() != wxID_OK:
self.manilasite='' dlg = wxTextEntryDialog(self, 'Enter Manila User','User',self.manilauser) + - if dlg.ShowModal() != wxID_OK:
self.manilauser=dlg.GetValue() dlg = wxMessageDialog(self, 'Use Dynamic Window Resizing?', 'Resize?', wxYES_NO | wxICON_INFORMATION) + - if dlg.ShowModal() == wxID_YES:
+ - else:
+ - try:
outfile = open(self.userhome+'buzz.cfg','w') outfile.write(self.buzzdir+'\n') outfile.write(self.bashcmd+'\n') outfile.write(self.tmpdir+'\n') outfile.write(self.fileexpander+'\n') outfile.write("%i\n"%self.freeformxml) outfile.write("%i\n"%self.expanddepth) outfile.write(self.home+'\n') outfile.write(self.manilasite+'\n') outfile.write(self.manilauser+'\n') outfile.write("%i\n"%self.usesize) outfile.close()
|
+ - except:
self.log_write('Could not save configuration')
|
|
+ - def OnAttr(self,*event):
item=self.tree.GetSelection() newitem=self.tree.PrependItem(item,'AttributeName=Value') self.tree.SetPyData(newitem,ElementWrapper('New Item','__attr')) self.tree.UnselectAll() self.tree.SelectItem(newitem) self.tree.EditLabel(newitem) self.modified=1
|
+ - def OnText(self,*event):
item=self.tree.GetSelection() newitem=self.tree.AppendItem(item,' ') self.tree.SetPyData(newitem,ElementWrapper('New Item','__data')) self.tree.UnselectAll() self.tree.SelectItem(newitem) self.tree.EditLabel(newitem) self.modified=1
|
+ - def OnLocalPaste(self,*event):
item=self.tree.GetSelection() + - if not item.IsOk():
+ - if self.cut_buffers[self.currentcut]:
self.modified=1 parentitem=self.tree.GetItemParent(item) + - if not parentitem.IsOk():
newitem=self.tree.InsertTree(item,self.cut_buffers[self.currentcut]) self.modified=1
|
+ - else:
newitem=self.tree.InsertTree(parentitem,self.cut_buffers[self.currentcut],item)
|
self.tree.UnselectAll() self.tree.SelectItem(newitem)
|
|
+ - def OnRightUp(self, event):
pt = event.GetPosition() item, flags = self.tree.HitTest(pt) self.tree.SelectItem(item) + - if item.IsOk():
self.PopupMenu(self.Popup,pt)
|
|
+ - def OnRightInsert(self, event):
item=self.tree.GetSelection() newitem=item + - if item.IsOk():
+ - if self.schema:
data_node=self.tree.GetPyData(item) + - if item == self.tree.root:
+ - else:
tagname=self.tree.GetItemText(item) + - if (data_node.EltType=="__outline"):
|
wrapper=self.schema.ValidChild(self,tagname) + - if wrapper:
+ - if data_node.EltType=="__attr":
currtext=self.tree.GetItemText(item) newtext=currtext+wrapper.Name self.tree.SetItemText(item,newtext) newitem=item
|
+ - else:
isattribute=None + - if wrapper.EltType == "__attr":
# this tells InsertTree to insert item as first child isattribute=-1
|
newitem=self.tree.InsertTree(item,wrapper,isattribute)
|
self.modified=1
|
+ - else:
|
+ - else:
newitem=self.tree.PrependItem(item,' ') self.tree.SetPyData(newitem,ElementWrapper('New Item','__outline')) self.tree.SelectItem(newitem) self.tree.EnsureVisible(newitem) self.tree.EditLabel(newitem) self.tree.SetItemFont(newitem,self.tree.leaffont) self.tree.HighlightTree(item,0)
|
self.tree.SelectItem(newitem) self.tree.EnsureVisible(newitem)
|
|
+ - def OnInsertXlink(self,*event):
+ - def OnDClick(self, event):
pt = event.GetPosition(); item, flags = self.tree.HitTest(pt) + - if self.tree.IsExpanded(item):
+ - else:
event.Skip()
|
+ - def FollowXlink(self,xlink,addtohistory=1):
xlinkarray=xlink.split('#') url=xlinkarray[0] xpath=xlinkarray[1] filename=url + - if self.modified:
+ - dlg = wxMessageDialog(self, 'Save before Opening?',
'Save?', wxYES_NO | wxICON_INFORMATION)
|
+ - if dlg.ShowModal() == wxID_YES:
+ - if not self.SaveFile():
|
|
+ - if filename.find("http:") !=-1:
filename,msg=urllib.urlretrieve(url)
|
+ - if not os.path.exists(filename):
filename=os.path.join(self.cwd,filename)
|
+ - if filename and os.path.exists(filename):
self.log_write("Following Xlink") + - if filename!=self.filename:
self.SetCurrentFile(filename,addtohistory)
|
curritem=self.Xpath(self.tree.root,xpath) self.log_write("Path :"+xpath) + - if curritem and curritem.IsOk():
self.item=curritem self.tree.EnsureVisible(curritem) self.tree.SelectItem(curritem) self.tree.SetFocus()
|
return filename
|
+ - else:
self.log_write("Target doesn't exist") return None
|
|
+ - def OnSibling(self,evt):
item=self.tree.GetSelection() parentitem=self.tree.GetItemParent(item) + - if self.schema:
data_node=self.tree.GetPyData(parentitem) tagname=data_node.EltType wrapper=self.schema.ValidChild(self,tagname) + - if wrapper:
+ - if wrapper.EltType == "__attr":
# this tells InsertTree to insert item as first child item=-1
|
newitem=self.tree.InsertTree(parentitem,wrapper,item) self.modified=1
|
+ - else:
|
+ - else:
newitem=self.tree.InsertItem(parentitem,item,' ') self.tree.SetPyData(newitem,ElementWrapper('New Item','__outline')) self.tree.EnsureVisible(newitem) self.tree.EditLabel(newitem) self.tree.SetItemFont(newitem,self.tree.leaffont)
|
self.tree.SelectItem(newitem)
|
+ - def OnActivate(self, evt):
item = evt.GetItem() self.ExpandNode(item)
|
+ - def OnExpand(self,evt):
item=self.tree.GetSelection() + - if item.IsOk():
|
+ - def ExpandNode(self,item):
numkids=self.tree.GetChildrenCount(item,0) url=self.GetXPathValue(item,'/@url[1]') xlink=self.GetXPathValue(item,'/@xlink[1]') href=self.GetXPathValue(item,'/@href[1]') + - if xlink:
+ - if self.filename:
xpath=self.GenerateXpath(item) thisxlink=self.filename+'#'+xpath self.AddHistory(thisxlink)
|
urloffset=xlink.find('=')+1 + - if urloffset:
return self.FollowXlink(xlink[urloffset:])
|
|
+ - else:
+ - if href or url:
+ - if href:
urloffset=url.find('=')+1 url=url[urloffset:] + - if (url.lower().find('.opml')!=-1):
+ - if self.filename:
(self.cwd,foo)=os.path.split(self.filename)
|
filename=os.path.join(self.cwd,url) + - if self.modified:
+ - dlg = wxMessageDialog(self, 'Save before Opening?',
'Save?', wxYES_NO | wxICON_INFORMATION)
|
+ - if dlg.ShowModal() == wxID_YES:
+ - if not self.SaveFile():
|
|
self.SetCurrentFile(filename) return
|
+ - else:
+ - if (url.find(":") == -1) and not os.path.exists(url):
url=os.path.join(self.cwd,url)
|
os.system(self.fileexpander+self.AddSlashes(url))
|
|
|
+ - if self.tree.IsExpanded(item):
+ - else:
|
+ - def OnCaseSensitive(self,*event):
self.casesensitive=not self.casesensitive self.log_write("Case sensitive is %i"%self.casesensitive)
|
+ - def OnFreeFormXML(self,*event):
self.freeformxml=not self.freeformxml self.log_write("Free form XML is %i"%self.freeformxml)
|
+ - def OnWrapOpen(self,*event):
self.wrapopen=not self.wrapopen self.log_write("Wrap Open is %i"%self.wrapopen)
|
+ - def OnDClickActivate(self,*event):
self.InsertonActivate=not self.InsertonActivate self.log_write("Free form XML is %i"%self.InsertonActivate)
|
+ - def OnTextEntry(self,*event):
self.textentrymode=not self.textentrymode self.log_write("Continuous Text Entry is %i"%self.textentrymode)
|
+ - def OnFindAndReplace(self,*event):
self.findandreplace=not self.findandreplace self.log_write("Find and Replace is %i"%self.findandreplace)
|
+ - def SetCurrentFile(self,filename,addtohistory=1):
+ - if not os.path.exists(filename):
self.log_write("Invalid File Name: %s"%filename) return 0
|
+ - if self.filename:
xpath=self.GenerateXpath(self.item) xlink=self.filename+'#'+xpath + - if addtohistory:
|
+ - if filename:
self.AddFile(filename) self.filename=filename (self.cwd,foo)=os.path.split(self.filename) self.tree.DeleteChildren(self.tree.root) self.tree.nodeStack = [self.tree.root] self.filetype=self.tree.LoadTree(filename) self.tree.SetItemText(self.tree.root,filename) self.tree.Expand(self.tree.root) self.tree.EnsureVisible(self.tree.root) self.tree.SelectItem(self.tree.root) self.tree.SetFocus() + - if self.filetype.lower()=="opml":
lastxpath=self.GetXPathValue(self.tree.root,"/opml[1]/head[1]/expansionState[1]/text()[1]") windowTop=int(self.GetXPathValue(self.tree.root,"/opml[1]/head[1]/windowTop[1]/text()[1]")) windowLeft=int(self.GetXPathValue(self.tree.root,"/opml[1]/head[1]/windowLeft[1]/text()[1]")) windowBottom=int(self.GetXPathValue(self.tree.root,"/opml[1]/head[1]/windowBottom[1]/text()[1]")) windowRight=int(self.GetXPathValue(self.tree.root,"/opml[1]/head[1]/windowRight[1]/text()[1]")) + - if self.usesize and (windowTop > 0) and (windowLeft > 0) and ((windowRight-windowLeft) > 0) and ((windowBottom-windowTop) > 0):
self.SetDimensions(windowLeft,windowTop,windowRight-windowLeft,windowBottom-windowTop)
|
+ - elif self.usesize:
self.log_write("could not set size %i %i %i %i"%(windowTop,windowLeft,windowBottom,windowRight))
|
+ - if lastxpath and lastxpath[0] == '/':
curritem=self.Xpath(self.tree.root,lastxpath) + - if curritem and curritem.IsOk():
self.item=curritem self.tree.SelectItem(curritem) self.tree.ScrollTo(curritem) self.tree.EnsureVisible(curritem) self.tree.Refresh()
|
|
+ - else:
curritem=self.Xpath(self.tree.root,"/opml[1]/body[1]") + - if curritem and curritem.IsOk():
self.item=curritem self.tree.SelectItem(curritem) self.tree.ScrollTo(curritem) self.tree.EnsureVisible(curritem) self.tree.Refresh() #self.ExpandAll(curritem,0,self.expanddepth)
|
|
|
+ - else:
self.ExpandAll(self.tree.root,0,1)
|
self.modified=0 self.findcount=1 self.lastfoundroot=None self.GetSchema(self.filetype) self.log_write("Opened %s"%filename)
|
|
+ - def OnHistory(self,*event):
+ - def OnJoin(self,*event):
item=self.tree.GetSelection() youngersibling = self.tree.GetNextSibling(item) + - if youngersibling.IsOk():
self.currentcut = (self.currentcut + 1) % 10 self.cut_buffers[self.currentcut] = self.CopyModel(youngersibling,0) siblingtext=self.tree.GetItemText(youngersibling) self.tree.Delete(youngersibling) newtext=self.tree.GetItemText(item)+' '+siblingtext self.tree.SetItemText(item,newtext) self.modified=1
|
|
+ - def OnDelete(self,*event):
item=self.tree.GetSelection() + - if not item.IsOk():
nextitem = self.tree.GetNextVisible(item) parent = self.tree.GetItemParent(item) self.currentcut = (self.currentcut + 1) % 10 self.cut_buffers[self.currentcut] = self.CopyModel(item,0) self.CopyToClipboard() self.tree.Delete(item) self.tree.SelectItem(nextitem) self.modified=1 + - if parent.IsOk():
self.tree.HighlightTree(parent,0)
|
|
+ - def OnHistoryBackward(self,*event):
xpath=self.GenerateXpath(self.item) xlink=self.filename+'#'+xpath self.HistoryBackward(xlink)
|
+ - def OnHistoryForward(self,*event):
xpath=self.GenerateXpath(self.item) xlink=self.filename+'#'+xpath self.HistoryForward(xlink)
|
+ - def History(self):
history=self.history[:] + - if not len(self.history):
+ - if not len(self.forwardhistory):
+ - else:
history=self.forwardhistory[:]
|
|
history.reverse() self.tmphistory=history win = mySingleChoice(self, -1, "Choose Xlink", size=(500, 250), style = wxFRAME_FLOAT_ON_PARENT,use_file=0) win.Show(true)
|
+ - def HistoryForward(self,xlink):
+ - if not len(self.forwardhistory):
thislink=self.forwardhistory.pop() self.FollowXlink(thislink)
|
+ - def HistoryBackward(self,xlink):
+ - if not len(self.history):
thislink=self.history.pop() self.AddForwardHistory(xlink) # add thislink to historyforward # an independent load should clear historyforward self.FollowXlink(thislink,0)
|
+ - def AddHistory(self,path):
self.history.insert(len(self.history),path)
|
+ - def AddForwardHistory(self,path):
self.forwardhistory.insert(len(self.forwardhistory),path)
|
#Importing and Exporting + - def ConvertOPML(self):
self.ConvertModelOPML(self.tree.root,0) self.log_write('Model converted to OPML')
|
+ - def ConvertXML(self):
self.ConvertModelXML(self.tree.root,0) self.log_write('Model converted to XML')
|
+ - def OnImportOutline(self,*event):
+ - def OnSchemaExample(self,*event):
self.SchemaExample("buzzdepend")
|
+ - def OnAttSchemaExample(self,*event):
self.SchemaExample("attbuzzdepend")
|
+ - def OnExportDT(self,*event):
+ - def OnNonUTF(self,*event):
+ - def OnExportLpro(self, *event):
+ - def OnRenderOpen(self, *event):
+ - def OnRenderXSL(self, *event):
+ - def OnXSLFO(self, *event):
+ - def OnFOP(self, *event):
+ - def OnRenderFile(self, *event):
+ - def OnRenderInPlace(self, *event):
+ - def OnRenderDir(self, *event):
+ - def OnXRenderDir(self, *event):
+ - def OnImportLpro(self, *event):
+ - def OnImportShadow(self, *event):
+ - def OnExportShadow(self, *event):
+ - def OnToolClick(self, *event):
+ - def OnImportDT(self, *event):
+ - def OnInsertFile(self, *event):
+ - def ConvertModelOPML(self,item,depth):
data_node=self.tree.GetPyData(item) newvalue = self.tree.GetItemText(item) + - if data_node.EltType[0:2] != '__':
isattr=newvalue.find('=') + - if isattr !=-1:
data_node.EltType='__attr'
|
+ - else:
data_node.EltType='__outline'
|
|
self.tree.SetPyData(item,data_node) cookie=depth (kid,flags) = self.tree.GetFirstChild(item,cookie) numkids=self.tree.GetChildrenCount(item,0) + - for i in range(numkids):
self.ConvertModelOPML(kid,cookie) + - if i < (numkids -1):
kid=self.tree.GetNextSibling(kid)
|
|
return(data_node)
|
+ - def ConvertModelXML(self,item,depth):
data_node=self.tree.GetPyData(item) newvalue = self.tree.GetItemText(item) if (data_node.EltType == '__outline') or ((len(data_node.EltType) > 1) and + - (data_node.EltType[0:2] != '__')):
isattr=newvalue.find('=') + - if isattr !=-1:
data_node.EltType='__attr'
|
+ - else:
data_node.EltType=newvalue
|
|
self.tree.SetPyData(item,data_node) cookie=depth (kid,flags) = self.tree.GetFirstChild(item,cookie) numkids=self.tree.GetChildrenCount(item,0) + - for i in range(numkids):
self.ConvertModelXML(kid,cookie) + - if i < (numkids -1):
kid=self.tree.GetNextSibling(kid)
|
|
return(data_node)
|
+ - def OnExportVcal(self, *event):
+ - def ExportVcal(self):
global vcalcount vcalcount=0 + - if self.modified:
+ - dlg = wxMessageDialog(self, 'Save before Opening?',
'Save?', wxYES_NO | wxICON_INFORMATION)
|
+ - if dlg.ShowModal() == wxID_YES:
+ - if not self.SaveFile():
|
|
filename = self.FileSelector('Open', 'Choose a vCalendar filename','*.vcal',self.cwd,wxOPEN,0) + - try:
outfile = open(filename,'w') outfile.write("BEGIN:VCALENDAR\nPRODID\n :-//K Desktop Environment//NONSGML KOrganizer 2.2.1//EN\nVERSION\n :2.0\n") curritem=self.Xpath(self.tree.root,"/opml[1]/body[1]") self.ExportVcalCore(curritem,outfile,vcalcount,0) outfile.write("END:VCALENDAR\n") self.log_write('Exported %s'%filename) return 1
|
+ - except:
self.log_write('Could not Export, This is usually secondary to lines in the CSV files that do not have the same number of \n fields as the header') return 0
|
|
+ - def ExportVcalCore(self,item,outfile,parent,depth):
global vcalcount vcalcount=vcalcount+1 cookie=depth (kid,flags) = self.tree.GetFirstChild(item,cookie) numkids=self.tree.GetChildrenCount(item,0) + - for i in range(numkids):
outfile.write('BEGIN:VTODO\n') outfile.write('CREATED\n') outfile.write(' :20011204T230730\n') outfile.write('UID\n') outfile.write(' :Buzz-%i\n'%vcalcount) outfile.write('SEQUENCE\n') outfile.write(' :0\n') outfile.write('LAST-MODIFIED\n') outfile.write(' :20011204T230730\n') outfile.write('DTSTAMP\n') outfile.write(' :20011204T230810\n') outfile.write('ORGANIZER\n') outfile.write(' :MAILTO:nobody@nowhere\n') outfile.write('DTSTART\n') outfile.write(' ;VALUE=DATE\n') outfile.write(' :20011204\n') outfile.write('SUMMARY\n') outfile.write(' :%s\n'%self.tree.GetItemText(kid)) outfile.write('CLASS\n') outfile.write(' :PUBLIC\n') outfile.write('PRIORITY\n') outfile.write(' :3\n') + - if parent:
outfile.write('RELATED-TO\n') outfile.write(' :Buzz-%i\n'%parent)
|
outfile.write('X-PILOTID\n') outfile.write(' :0\n') outfile.write('X-PILOTSTAT\n') outfile.write(' :1\n') outfile.write('PERCENT-COMPLETE\n') outfile.write(' :0\n') outfile.write('END:VTODO\n') self.ExportVcalCore(kid,outfile,vcalcount,depth+1) + - if i < (numkids -1):
kid=self.tree.GetNextSibling(kid)
|
|
|
+ - def ExpandAll(self,item,depth,maxdepth):
global bracket_open cookie=depth + - if maxdepth and (depth > maxdepth):
+ - #if depth:
+ - #if self.tree.IsExpanded(item):
#self.tree.Collapse(item)
|
#else:
|
+ - if self.expandkey:
+ - if (self.expandkey == self.tree.GetItemText(item)):
#if not self.tree.IsExpanded(item): self.tree.Expand(item) self.tree.EnsureVisible(item)
|
|
#elif not self.tree.IsExpanded(item): + - else:
(kid,flags) = self.tree.GetFirstChild(item,cookie) numkids=self.tree.GetChildrenCount(item,0) + - for i in range(numkids):
self.ExpandAll(kid,depth+1,maxdepth) + - if i < (numkids -1):
kid=self.tree.GetNextSibling(kid)
|
|
|
+ - def OnOne(self,*event):
item=self.tree.GetSelection() + - if item.IsOk():
self.tree.Collapse(item) self.ExpandAll(item,0,1)
|
|
+ - def OnTwo(self,*event):
item=self.tree.GetSelection() + - if item.IsOk():
self.tree.Collapse(item) self.ExpandAll(item,0,2)
|
|
+ - def OnThree(self,*event):
item=self.tree.GetSelection() + - if item.IsOk():
self.tree.Collapse(item) self.ExpandAll(item,0,3)
|
|
+ - def OnFour(self,*event):
item=self.tree.GetSelection() + - if item.IsOk():
self.tree.Collapse(item) self.ExpandAll(item,0,4)
|
|
+ - def CopyModel(self,item,depth):
global bracket_open data_node=self.tree.GetPyData(item) newvalue = self.tree.GetItemText(item) data_node.SetName(newvalue) cookie=depth (kid,flags) = self.tree.GetFirstChild(item,cookie) numkids=self.tree.GetChildrenCount(item,0) data_node.children = [] + - for i in range(numkids):
data_node.AppendChild(self.CopyModel(kid,cookie)) + - if i < (numkids -1):
kid=self.tree.GetNextSibling(kid)
|
|
return(data_node)
|
+ - def OnPreviewHTML(self, *event):
+ - if self.modified:
+ - dlg = wxMessageDialog(self, 'Save before Converting?',
'Save?', wxYES_NO | wxICON_INFORMATION)
|
+ - if dlg.ShowModal() == wxID_YES:
+ - if not self.SaveHTML():
|
|
+ - if self.filename:
os.system(self.fileexpander+self.AddSlashes(self.filename))
|
|
+ - def WebifyXML(self, *event):
+ - if self.modified:
+ - dlg = wxMessageDialog(self, 'Save before Converting?',
'Save?', wxYES_NO | wxICON_INFORMATION)
|
+ - if dlg.ShowModal() == wxID_YES:
+ - if not self.SaveFile():
|
|
global bracket_open global lastend lastend = "__data" bracket_open=0 + - if self.filename:
origfile=self.filename tmpfile=self.filename+'.opml' + - try:
retval=self.MySystem(self.buzzdir+'xml2opml '+self.AddSlashes(self.filename)+' '+self.AddSlashes(tmpfile)+' '+self.buzzdir) self.log_write(self.bashcmd+self.buzzdir+'xml2opml '+self.AddSlashes(self.filename)+' '+self.AddSlashes(tmpfile)+' '+self.buzzdir) + - if retval:
self.log.Write('Could not export file') return None
|
+ - else:
self.log_write('Export completed.')
|
|
+ - except:
self.log_write('Could not export file') return None
|
self.filename=self.filename+'.opml' + - try:
textname=self.filename textname=textname+'.html' self.log_write('Starting Export') self.log_write(self.bashcmd+self.buzzdir+'opml2html '+self.AddSlashes(self.filename)+' '+self.AddSlashes(textname)) retval=self.MySystem(self.buzzdir+'opml2web '+self.AddSlashes(self.filename)+' '+self.AddSlashes(textname)+' '+self.buzzdir+' &') + - if retval:
self.log.Write("Could not print file")
|
+ - else:
self.log_write('Print started.') os.system(self.fileexpander+textname)
|
|
+ - except:
self.log_write("Could not print")
|
self.filename=origfile
|
|
+ - def OnImport(self, *event):
+ - def OnLastFile(self, *event):
+ - def OnHome(self, *event):
+ - if self.modified:
+ - dlg = wxMessageDialog(self, 'Save before Opening?',
'Save?', wxYES_NO | wxICON_INFORMATION)
|
+ - if dlg.ShowModal() == wxID_YES:
+ - if not self.SaveFile():
|
|
self.SetCurrentFile(self.home)
|
+ - def ExportHTML(self):
+ - try:
+ - if not self.SaveFile():
textname=self.filename[:-5] textname=textname+'.html' self.log_write('Starting Export') self.log_write(self.bashcmd+self.buzzdir+'opml2html '+self.AddSlashes(self.filename)+' '+self.AddSlashes(textname)) retval=self.MySystem(self.buzzdir+'opml2html '+self.AddSlashes(self.filename)+' '+self.AddSlashes(textname)+' '+self.buzzdir) + - if retval:
self.log.Write('Could not export file')
|
+ - else:
self.log_write('Export completed.')
|
|
+ - except:
self.log_write('Could not export file')
|
|
+ - def ImportNonUTF(self):
+ - if self.modified:
+ - dlg = wxMessageDialog(self, 'Save before Opening?',
'Save?', wxYES_NO | wxICON_INFORMATION)
|
+ - if dlg.ShowModal() == wxID_YES:
+ - if not self.SaveFile():
|
|
filename = self.FileSelector('Choose an XML file to open', 'Choose an xml file to open','*',self.cwd,wxOPEN,0) + - if filename:
+ - try:
self.log_write('Starting Import') + - if self.wrapopen:
transcommand='wraplatin1 '
|
+ - else:
retval=self.MySystem(self.buzzdir+transcommand+self.AddSlashes(filename)+' '+self.buzzdir) self.log_write('Completed Import') self.SetCurrentFile(filename+'.utf')
|
+ - except:
self.log_write('Failed to import.') return None
|
|
+ - else:
|
+ - def ImportHTML(self):
+ - if self.modified:
+ - dlg = wxMessageDialog(self, 'Save before Opening?',
'Save?', wxYES_NO | wxICON_INFORMATION)
|
+ - if dlg.ShowModal() == wxID_YES:
+ - if not self.SaveFile():
|
|
filename = self.FileSelector('Open', 'Choose an html file to open','*',self.cwd,wxOPEN,0) + - if filename:
+ - try:
self.log_write('Starting Import') retval=self.MySystem(self.buzzdir+'html2xml '+self.AddSlashes(filename)+' '+self.buzzdir) self.log_write('Completed Import') self.filename=filename+'.xhtml' self.SetCurrentFile(self.filename)
|
+ - except:
self.log_write('Failed to import.') return None
|
|
+ - else:
|
+ - def ExportOutline(self):
+ - try:
+ - if not self.SaveFile():
textname=self.filename[:-5] textname=textname+'.html' self.log_write('Starting Export') self.log_write(self.bashcmd+self.buzzdir+'opml2htmloutline '+self.AddSlashes(self.filename)+' '+self.AddSlashes(textname)) retval=self.MySystem(self.buzzdir+'opml2htmloutline '+self.AddSlashes(self.filename)+' '+self.AddSlashes(textname)+' '+self.buzzdir) + - if retval:
self.log.Write('Could not export file')
|
+ - else:
self.log_write('Export completed.')
|
|
+ - except:
self.log_write('Could not export file')
|
|
+ - def ExportTextFile(self):
+ - try:
+ - if not self.SaveFile():
textname=self.filename[:-5] self.log_write('Starting Export') retval=self.MySystem(self.buzzdir+'opml2text '+self.AddSlashes(self.filename)+' '+self.AddSlashes(textname)+' '+self.buzzdir) self.log_write(self.bashcmd+self.buzzdir+'opml2text '+self.AddSlashes(self.filename)+' '+self.AddSlashes(textname)+' '+self.buzzdir) + - if retval:
self.log.Write('Could not export file')
|
+ - else:
self.log_write('Export completed.')
|
|
+ - except:
self.log_write('Could not export file')
|
|
+ - def ImportDT(self):
+ - if self.modified:
+ - dlg = wxMessageDialog(self, 'Save before Opening?',
'Save?', wxYES_NO | wxICON_INFORMATION)
|
+ - if dlg.ShowModal() == wxID_YES:
+ - if not self.SaveFile():
|
|
filename = self.FileSelector('Open', 'Choose a Decision Tree to open','*dt',self.cwd,wxOPEN,0) + - if filename:
+ - try:
self.log_write('Starting Import') filename=filename[:-3] retval=self.MySystem(self.buzzdir+'dt2xml '+self.AddSlashes(filename)+' '+self.buzzdir) self.log_write('Completed Import') + - if not retval:
self.SetCurrentFile(filename+'.opnote')
|
+ - else:
self.log_write('Could not open file') return None
|
|
+ - except:
self.log_write('Failed to import.') return None
|
|
+ - else:
|
+ - def ExportDT(self):
filename = self.FileSelector('Save', 'Choose a filename','*.opex',self.cwd,wxSAVE,0) + - if filename:
+ - try:
outfile = open(filename,'w') root=self.CopyModel(self.tree.root,0) self.log_write(' Copied model') self.tree.TreeToOpNote(root,outfile,0) self.log_write('Exported %s'%filename) return 1
|
+ - except:
self.log_write('Could not Export') return 0
|
|
+ - else:
|
+ - def ImportOutline(self):
+ - if self.modified:
+ - dlg = wxMessageDialog(self, 'Save before Opening?',
'Save?', wxYES_NO | wxICON_INFORMATION)
|
+ - if dlg.ShowModal() == wxID_YES:
+ - if not self.SaveFile():
|
|
filename = self.FileSelector('Open', 'Choose a text file to open','*htm',self.cwd,wxOPEN,0) + - if filename:
+ - try:
self.log_write('Starting Import') filename=filename[:-4] retval=self.MySystem(self.buzzdir+'msword2opml '+self.AddSlashes(filename)+' '+self.buzzdir) self.log_write('Completed Import') + - if not retval:
self.filename=filename+'.opml' return self.SetCurrentFile(self.filename)
|
+ - else:
self.log_write('Could not open file') return None
|
|
+ - except:
self.log_write('Failed to import.') return None
|
|
+ - else:
|
+ - def ImportLpro(self):
+ - if self.modified:
+ - dlg = wxMessageDialog(self, 'Save before Opening?',
'Save?', wxYES_NO | wxICON_INFORMATION)
|
+ - if dlg.ShowModal() == wxID_YES:
+ - if not self.SaveFile():
|
|
filename = self.FileSelector('Open', 'Choose an Lpro file to open','*',self.cwd,wxOPEN,0) + - if filename:
+ - try:
self.log_write('Starting Import') retval=self.MySystem(self.buzzdir+'lpro2opml '+self.AddSlashes(filename)+' '+self.buzzdir) self.log_write('Completed Import') + - if not retval:
self.SetCurrentFile(filename+'.opml')
|
+ - else:
self.log_write('Could not open file') return None
|
|
+ - except:
self.log_write('Failed to import.') return None
|
|
+ - else:
|
+ - def ImportShadow(self):
+ - if self.modified:
+ - dlg = wxMessageDialog(self, 'Save before Opening?',
'Save?', wxYES_NO | wxICON_INFORMATION)
|
+ - if dlg.ShowModal() == wxID_YES:
+ - if not self.SaveFile():
|
|
filename = self.FileSelector('Open', 'Choose a Shadow file to open','*',self.cwd,wxOPEN,0) + - if filename:
+ - try:
self.log_write('Starting Import') retval=self.MySystem(self.buzzdir+'sml2opml '+self.AddSlashes(filename)+' '+self.buzzdir) self.log_write('Completed Import') + - if not retval:
self.filename=filename+'.opml' self.SetCurrentFile(self.filename)
|
+ - else:
self.log_write('Could not open file') return None
|
|
+ - except:
self.log_write('Failed to import.') return None
|
|
+ - else:
|
+ - def ImportTextFile(self):
+ - if self.modified:
+ - dlg = wxMessageDialog(self, 'Save before Opening?',
'Save?', wxYES_NO | wxICON_INFORMATION)
|
+ - if dlg.ShowModal() == wxID_YES:
+ - if not self.SaveFile():
|
|
filename = self.FileSelector('Open', 'Choose a text file to open','*',self.cwd,wxOPEN,0) + - if filename:
+ - try:
self.log_write('Starting Import') retval=self.MySystem(self.buzzdir+'text2opml '+self.AddSlashes(filename)+' '+self.buzzdir) self.log_write(self.bashcmd+self.buzzdir+'text2opml '+self.AddSlashes(filename)+' '+self.buzzdir) self.log_write('Completed Import') + - if not retval:
self.SetCurrentFile(filename+'.opml')
|
+ - else:
self.log_write('Could not open file') return None
|
|
+ - except:
self.log_write('Failed to import.') return None
|
|
+ - else:
|
+ - def OnExport(self, *event):
+ - def OnXSearch(self, *event):
+ - def OnSaveHTML(self, *event):
+ - def SaveHTML(self):
global bracket_open global lastend lastend = "__data" bracket_open = 0 filename = self.FileSelector('Save', 'Choose a filename','*.'+self.filetype,self.cwd,wxSAVE) + - if filename:
+ - if os.path.exists(filename):
dlg = wxMessageDialog(self, 'File %s Exists. Replace It?'%filename, 'Save?', wxYES_NO | wxICON_INFORMATION) + - if dlg.ShowModal() == wxID_NO:
|
+ - try:
outfile = open(filename,'w') self.SaveModel(self.tree.root,outfile,0) self.log_write('Saved as %s'%filename) #retval=self.MySystem('python '+self.buzzdir+'cleanhtml.py '+self.AddSlashes(self.filename)+' > '+self.AddSlashes(filename)) return filename
|
+ - except:
self.log_write('Could not Save %s'%filename) return None
|
|
|
+ - def OnExportOutline(self, *event):
+ - def OnExportHTML(self, *event):
+ - def OnImportHTML(self, *event):
+ - def ExportLpro(self):
+ - try:
+ - if not self.SaveFile():
textname=self.filename[:-5] textname=textname+'.lpro' self.log_write('Starting Export') self.log_write(self.bashcmd+self.buzzdir+'opml2lpro '+self.AddSlashes(self.filename)+' '+self.AddSlashes(textname)+' '+self.buzzdir) retval=self.MySystem(self.buzzdir+'opml2lpro '+self.AddSlashes(self.filename)+' '+self.AddSlashes(textname)+' '+self.buzzdir) + - if retval:
self.log.Write('Could not export file')
|
+ - else:
self.log_write('Export completed.')
|
|
+ - except:
self.log_write('Could not export file')
|
|
+ - def RenderOpen(self):
+ - if self.modified:
+ - dlg = wxMessageDialog(self, 'Save before Opening?',
'Save?', wxYES_NO | wxICON_INFORMATION)
|
+ - if dlg.ShowModal() == wxID_YES:
+ - if not self.SaveFile():
|
|
+ - try:
cleanbuzzdir=string.replace(self.buzzdir,"\\\\","\\") filename1 = self.FileSelector('Open', 'Choose a file','*',self.cwd,wxOPEN,0) + - if not self.filename:
filename = self.FileSelector('Open', 'Choose an xsl file','*.xsl',cleanbuzzdir,wxOPEN,0) + - if not filename:
self.log_write('Starting Import') filename2=os.path.join(self.cwd,'tmp.xml') self.log_write(self.bashcmd+' saxon '+self.AddSlashes(filename1)+' '+self.AddSlashes(filename)+' > '+self.AddSlashes(filename2) ) retval=self.MySystem(self.buzzdir+'renderopen '+self.AddSlashes(filename1)+' '+self.AddSlashes(filename)+' > '+self.AddSlashes(filename2) ) + - if retval:
self.log_write('Could not import file')
|
+ - else:
self.log_write('Import Completed') self.SetCurrentFile(filename2) self.modified=1 self.filename=None
|
|
+ - except:
self.log_write('Could not import file')
|
|
+ - def RenderXSL(self):
+ - try:
+ - if not self.SaveFile():
cleanbuzzdir=string.replace(self.buzzdir,"\\\\","\\") filename = self.FileSelector('Open', 'Choose an xsl file','*.xsl',cleanbuzzdir,wxOPEN,0) self.log_write('Starting Export') retval=self.MySystem(self.buzzdir+'renderxsl '+self.AddSlashes(self.filename)+' '+self.AddSlashes(filename)+' '+self.buzzdir) + - if retval:
self.log.Write('Could not export file')
|
+ - else:
os.system(self.fileexpander+self.filename+'.html') self.log_write('Export completed.')
|
|
+ - except:
self.log_write('Could not export file')
|
|
+ - def XSLFO(self):
+ - try:
+ - if not self.SaveFile():
cleanbuzzdir=string.replace(self.buzzdir,"\\\\","\\") filename = self.FileSelector('Open', 'Choose an xslfo file','*.xslfo',cleanbuzzdir,wxOPEN,0) self.log_write('Starting Export') retval=self.MySystem(self.buzzdir+'renderxslfo '+self.AddSlashes(self.filename)+' '+self.AddSlashes(filename)+' '+self.buzzdir) + - if retval:
self.log.Write('Could not export file')
|
+ - else:
os.system(self.fileexpander+self.filename+'.pdf') self.log_write('Export completed.')
|
|
+ - except:
self.log_write('Could not export file')
|
|
+ - def FOP(self):
+ - try:
+ - if not self.SaveFile():
textname=self.filename textname=textname+'.pdf' self.log_write('Starting Export') retval=self.MySystem(self.buzzdir+'fop '+self.AddSlashes(self.filename)+' '+self.AddSlashes(textname)) + - if retval:
self.log.Write('Could not print file')
|
+ - else:
self.log_write('Print started.') os.system(self.fileexpander+textname)
|
|
+ - except:
self.log_write('Could not print')
|
|
+ - def SchemaExample(self,command):
+ - if self.modified:
+ - dlg = wxMessageDialog(self, 'Save before Opening?',
'Save?', wxYES_NO | wxICON_INFORMATION)
|
+ - if dlg.ShowModal() == wxID_YES:
+ - if not self.SaveFile():
|
|
+ - try:
cleanbuzzdir=string.replace(self.buzzdir,"\\\\","\\") filenames = self.MultiFileSelector('Choose XML Files', 'Choose files','*',self.cwd,wxOPEN) outfile = self.FileSelector('Choose an Output File', 'Choose an output schema file','*.schema',self.cwd,wxSAVE,0) self.log_write('Starting Export') filestr="" + - for thisfile in filenames:
filestr=filestr+" "+self.AddSlashes(thisfile)
|
retval=self.MySystem('python /usr/share/buzz/buzzdepend.py '+self.AddSlashes(self.buzzdir)+' '+command+' '+filestr+' > '+self.AddSlashes(outfile)) self.log_write('Export Completed') + - if retval:
self.log.Write('Could not export file')
|
|
+ - except:
self.log_write('Could not export file')
|
|
+ - def RenderFile(self):
+ - try:
+ - if not self.SaveFile():
cleanbuzzdir=string.replace(self.buzzdir,"\\\\","\\") filename = self.FileSelector('Choose an XSL File', 'Choose an xsl file','*.xsl',cleanbuzzdir,wxOPEN,0) outfile = self.FileSelector('Choose an Output File', 'Choose an output file','*',self.cwd,wxSAVE,0) self.log_write('Starting Export') retval=self.MySystem(self.buzzdir+'renderfile '+self.AddSlashes(self.filename)+' '+self.AddSlashes(filename)+' '+self.AddSlashes(outfile)+' '+self.buzzdir) self.log_write('Export Completed') + - if retval:
self.log.Write('Could not export file')
|
|
+ - except:
self.log_write('Could not export file')
|
|
+ - def RenderInPlace(self):
+ - try:
+ - if not self.SaveFile():
filename = self.FileSelector('Open', 'Choose an xsl file','*.xsl',self.cwd,wxOPEN,0) self.log_write('Starting Export') retval=self.MySystem(self.buzzdir+'renderinplace '+self.AddSlashes(self.filename)+' '+self.AddSlashes(filename)+' '+self.buzzdir) + - if retval:
self.log.Write('Could not export file')
|
+ - else:
self.log_write('Starting Import') self.filename=self.filename+'.xml' self.tree.DeleteChildren(self.tree.root) self.tree.nodeStack = [self.tree.root] self.filetype=self.tree.LoadTree(self.filename) self.tree.Expand(self.tree.root) self.tree.SetItemText(self.tree.root,self.filename) self.modified=1 self.log_write('Export completed.')
|
|
+ - except:
self.log_write('Could not export file')
|
|
+ - def RenderDir(self):
tmpdir=self.RecentDir() + - if tmpdir == -1:
+ - try:
+ - if not self.SaveFile():
self.log_write('Starting Render') retval=self.MySystem(self.buzzdir+'renderdir '+self.AddSlashes(tmpdir)+' '+self.buzzdir) self.log_write('Render Completed') filename=os.path.join(tmpdir,'directory.opml') self.SetCurrentFile(filename)
|
+ - except:
self.log_write('Could not export file')
|
|
+ - def XRenderDir(self):
+ - if self.modified:
+ - dlg = wxMessageDialog(self, 'Save before Opening?',
'Save?', wxYES_NO | wxICON_INFORMATION)
|
+ - if dlg.ShowModal() == wxID_YES:
+ - if not self.SaveFile():
|
|
tmpdir=self.RecentDir() + - if tmpdir == -1:
self.cwd=tmpdir + - try:
dlg = wxTextEntryDialog(self, 'File Extension?','Extension',"") filestr="" + - if dlg.ShowModal() == wxID_OK:
+ - else:
self.log_write('Starting Render') retval=self.MySystem(self.buzzdir+'xrenderdir '+self.AddSlashes(self.cwd)+' '+self.AddSlashes(self.buzzdir)+' '+filestr) self.log_write('Render Completed') filename=os.path.join(tmpdir,'directory.opml') self.SetCurrentFile(filename) + - if retval:
self.log.Write('Could not export file')
|
|
+ - except:
self.log_write('Could not export file')
|
|
+ - def ExportShadow(self):
+ - try:
+ - if not self.SaveFile():
self.log_write('Starting Export') self.log_write(self.bashcmd+self.buzzdir+'opml2sml '+self.AddSlashes(self.filename)+' '+self.buzzdir) retval=self.MySystem(self.buzzdir+'opml2sml '+self.AddSlashes(self.filename)+' '+self.buzzdir) + - if retval:
self.log.Write('Could not export file')
|
+ - else:
self.log_write('Export completed.')
|
|
+ - except:
self.log_write('Could not export file')
|
|
# Printing + - def MakeDT(self):
+ - try:
+ - if not self.SaveFile():
textname=self.filename textname=textname+'.html' self.log_write('Starting Export') self.log_write(self.bashcmd+self.buzzdir+'xml2dt '+self.AddSlashes(self.filename)+' '+self.AddSlashes(textname)) retval=self.MySystem(self.buzzdir+'xml2dt '+self.AddSlashes(self.filename)+' '+self.AddSlashes(textname)+' '+self.buzzdir) + - if retval:
self.log.Write("Could not print file")
|
+ - else:
self.log_write('Print started.') os.system(self.fileexpander+textname)
|
|
+ - except:
self.log_write("Could not print")
|
|
+ - def Webify(self):
+ - try:
+ - if not self.SaveFile():
textname=self.filename textname=textname+'.html' self.log_write('Starting Export') self.log_write(self.bashcmd+self.buzzdir+'opml2html '+self.AddSlashes(self.filename)+' '+self.AddSlashes(textname)) retval=self.MySystem(self.buzzdir+'opml2web '+self.AddSlashes(self.filename)+' '+self.AddSlashes(textname)+' '+self.buzzdir) + - if retval:
self.log.Write('Could not print file')
|
+ - else:
self.log_write('Print started.') os.system(self.fileexpander+textname)
|
|
+ - except:
self.log_write('Could not print')
|
|
+ - def Print(self):
+ - try:
+ - if not self.SaveFile():
textname=self.filename+'.html' self.log_write('Starting Export') self.log_write(self.bashcmd+self.buzzdir+'opml2html '+self.AddSlashes(self.filename)+' '+self.AddSlashes(textname)) retval=self.MySystem(self.buzzdir+'opml2htmlprint '+self.AddSlashes(self.filename)+' '+self.AddSlashes(textname)+' '+self.buzzdir) + - if retval:
self.log.Write('Could not print file')
|
+ - else:
self.log_write('Print started.') os.system(self.fileexpander+textname)
|
|
+ - except:
self.log_write('Could not print')
|
|
+ - def OnPrint(self, *event):
+ - def OnWebify(self, *event):
+ - def OnWebifyXML(self, *event):
+ - def OnDT(self, *event):
# File System Functions + - def SavetoDAV(self):
import davlib import qp_xml + - if self.modified:
+ - dlg = wxMessageDialog(self, 'Save before Opening?',
'Save?', wxYES_NO | wxICON_INFORMATION)
|
+ - if dlg.ShowModal() == wxID_YES:
+ - if not self.SaveFile():
|
|
dlg = wxTextEntryDialog(self, 'Host for Save','Host','') + - if dlg.ShowModal() == wxID_OK:
host=dlg.GetValue() dlg = wxTextEntryDialog(self, 'Remote File','File','') + - if dlg.ShowModal() == wxID_OK:
filename=dlg.GetValue() fp=open(self.filename,'r') contents=fp.read() fp.close() response=davlib.DAV(host,80).put(filename,contents)
|
|
|
+ - def AddFile(self,filename):
+ - if wxPlatform == '__WXMSW__':
filename=filename.lower()
|
+ - if not filename in self.file_buffers:
self.file_buffers.insert(0,filename)
|
+ - else:
self.ReSortRecent(self.file_buffers.index(filename))
|
|
+ - def AddURL(self,filename):
+ - if not filename in self.url_buffers:
self.url_buffers.insert(0,filename)
|
+ - else:
self.ReSortRecentURL(self.url_buffers.index(filename))
|
|
+ - def AddXmark(self,xmark,text):
+ - if not (text,xmark) in self.xmarks:
+ - for i in range(50):
(thistext,foo)=self.xmarks[i] + - if not thistext:
self.xmarks[i]=(text,xmark) return
|
|
self.log_write("Xmarks are full")
|
|
+ - def OpenHelpFile(self):
+ - if self.modified:
+ - dlg = wxMessageDialog(self, 'Save before Opening?',
'Save?', wxYES_NO | wxICON_INFORMATION)
|
+ - if dlg.ShowModal() == wxID_YES:
+ - if not self.SaveFile():
|
|
filename = self.buzzdir+'buzz.opml' + - if filename:
return self.SetCurrentFile(filename)
|
+ - else:
|
+ - def ReSortRecent(self,index):
newrecent=[self.file_buffers[index]] + - for i in range(10):
+ - if i != index:
newrecent.append(self.file_buffers[i])
|
|
self.file_buffers=newrecent
|
+ - def ReSortRecentURL(self,index):
newrecent=[self.url_buffers[index]] + - for i in range(10):
+ - if i != index:
newrecent.append(self.url_buffers[i])
|
|
self.url_buffers=newrecent
|
+ - def Recent(self):
+ - if self.modified:
+ - dlg = wxMessageDialog(self, 'Save before Opening?',
'Save?', wxYES_NO | wxICON_INFORMATION)
|
+ - if dlg.ShowModal() == wxID_YES:
+ - if not self.SaveFile():
|
|
win = mySingleChoice(self, -1, "Choose File", size=(500, 250), style = wxFRAME_FLOAT_ON_PARENT,use_file=1) win.Show(true)
|
+ - def RecentURL(self):
+ - if self.modified:
+ - dlg = wxMessageDialog(self, 'Save before Opening?',
'Save?', wxYES_NO | wxICON_INFORMATION)
|
+ - if dlg.ShowModal() == wxID_YES:
+ - if not self.SaveFile():
|
|
#filenames=['','','','','','','','','',''] + - #for i in range(10):
#(thispath,thisfile)=os.path.split(self.file_buffers[i]) #filenames[i]=self.file_buffers[i]
|
dlg = wxSingleChoiceDialog(self, 'Choose File', 'Choose File', self.url_buffers) + - if dlg.ShowModal() == wxID_OK:
index=dlg.GetSelection() filename=self.url_buffers[index] + - if index:
self.ReSortRecentURL(index)
|
dlg.Destroy() dlg = wxTextEntryDialog(self, 'Retrieve URL','Retrieve',filename) + - if dlg.ShowModal() == wxID_OK:
urlstr=dlg.GetValue() import urllib filename,msg=urllib.urlretrieve(urlstr) + - if filename:
retval=self.MySystem(self.buzzdir+'utf8 '+self.AddSlashes(filename)+' '+self.buzzdir) filename=filename+'.utf' self.AddURL(urlstr) self.tree.DeleteChildren(self.tree.root) self.tree.nodeStack = [self.tree.root] self.filetype=self.tree.LoadTree(filename) self.tree.Expand(self.tree.root) self.tree.SetItemText(self.tree.root,filename) self.filename=None self.modified=1 return filename
|
+ - else:
|
|
|
+ - def OnSetXMark(self,*evt):
+ - def SetXMark(self):
+ - if not self.filename:
xpath=self.GenerateXpath(self.item) text=self.tree.GetItemText(self.item) text=self.filename+' - '+text[:60] xlink=self.filename+'#'+xpath self.AddXmark(xlink,text) self.log_write("Xmark Added")
|
+ - def OnXmarks(self,*evt):
+ - def OnDeleteXmarks(self,*evt):
+ - def InsertXlink(self):
choices=range(50) + - for i in range(50):
(choices[i],foo)=self.xmarks[i]
|
dlg = wxSingleChoiceDialog(self, 'Choose Xlink', 'Choose Xlink', choices) + - if dlg.ShowModal() == wxID_OK:
index=dlg.GetSelection() (foo,xlink)=self.xmarks[index] item=self.tree.GetSelection() + - if item.IsOk():
parentitem=self.tree.GetItemParent(item) newitem=self.tree.InsertItem(parentitem,item,foo) self.tree.SetPyData(newitem,ElementWrapper(foo,'__outline')) newnewitem=self.tree.PrependItem(newitem,'xlink='+xlink) self.tree.SetPyData(newnewitem,ElementWrapper('xlink='+xlink,'__attr')) newnewitem=self.tree.PrependItem(newitem,'type=xlink') self.tree.SetPyData(newnewitem,ElementWrapper('type=xlink','__attr')) self.tree.EnsureVisible(newitem) self.tree.EditLabel(newitem) self.tree.SetItemFont(newitem,self.tree.leaffont)
|
|
|
+ - def Xmarks(self):
choices=range(50) + - for i in range(50):
(xmarkstr,foo)=self.xmarks[i] offset=xmarkstr.find("-") (path,filename)=os.path.split(xmarkstr[:offset]) choices[i]=filename+xmarkstr[offset:]
|
dlg = wxSingleChoiceDialog(self, 'Choose Mark', 'Choose Mark', choices) + - if dlg.ShowModal() == wxID_OK:
index=dlg.GetSelection() (foo,xlink)=self.xmarks[index] return self.FollowXlink(xlink)
|
|
+ - def DeleteXmarks(self):
choices=range(50) + - for i in range(50):
(choices[i],foo)=self.xmarks[i]
|
dlg = wxSingleChoiceDialog(self, 'Choose Mark', 'Choose Mark', choices) + - if dlg.ShowModal() == wxID_OK:
index=dlg.GetSelection() del self.xmarks[index] self.xmarks.append(("",""))
|
|
+ - def OnRecent(self,*evt):
+ - def OnExpandURL(self,*evt):
+ - def OnRecentURL(self,*evt):
+ - def AddSlashes(self,str):
recspace=re.compile(' ') + - if wxPlatform != '__WXMSW__':
return (recspace.sub('\ ',str))
|
+ - else:
|
+ - def ExpandURL(self):
urlstr=self.tree.GetItemText(self.item) import urllib filename,msg=urllib.urlretrieve(urlstr) + - if filename:
self.tree.nodeStack = [self.item] self.tree.LoadTree(filename) self.tree.Expand(self.item) self.modified=1 return filename
|
+ - else:
|
+ - def OpenURL(self):
+ - if self.modified:
+ - dlg = wxMessageDialog(self, 'Save before Opening?',
'Save?', wxYES_NO | wxICON_INFORMATION)
|
+ - if dlg.ShowModal() == wxID_YES:
+ - if not self.SaveFile():
|
|
dlg = wxTextEntryDialog(self, 'Retrieve URL','Retrieve','') + - if dlg.ShowModal() == wxID_OK:
urlstr=dlg.GetValue() import urllib filename,msg=urllib.urlretrieve(urlstr) + - if filename:
retval=self.MySystem(self.buzzdir+'utf8 '+self.AddSlashes(filename)+' '+self.buzzdir) filename=filename+'.utf' self.AddURL(urlstr) self.tree.DeleteChildren(self.tree.root) self.tree.nodeStack = [self.tree.root] self.filetype=self.tree.LoadTree(filename) self.tree.Expand(self.tree.root) self.tree.SetItemText(self.tree.root,filename) self.filename=None self.modified=1 return filename
|
+ - else:
|
|
+ - def InsertFile(self):
filename = self.FileSelector('Open', 'Choose a tree to insert','*.opml',self.cwd,0) + - if filename:
self.tree.nodeStack = [self.item] self.tree.LoadTree(filename) self.tree.Expand(self.item) self.modified=1 return filename
|
+ - else:
|
+ - def FileSelector(self,header,prompt,exp='*.*',dir='',button=wxOPEN,doaddfile=1):
global _tree returnpath=None dlg = wxFileDialog(_tree, prompt, dir, '', exp, button) + - if dlg.ShowModal() == wxID_OK:
returnpath=dlg.GetPath() + - if doaddfile and os.path.exists(returnpath):
+ - if wxPlatform != '__WXMSW__' and exp!="*":
#wxGTK hack expending=exp[exp.rfind("."):] + - if returnpath.find(".")==-1:
returnpath=returnpath+expending
|
|
|
dlg.Destroy() return returnpath
|
+ - def MultiFileSelector(self,header,prompt,exp='*.*',dir='',button=wxOPEN):
global _tree returnpaths=[] dlg = wxFileDialog(_tree, prompt, dir, '', exp, button | wxMULTIPLE) + - if dlg.ShowModal() == wxID_OK:
returnpaths = dlg.GetPaths()
|
dlg.Destroy() return returnpaths
|
+ - def PromoteClipboard(self,item):
cookie=0 (clipboard,flags) = self.tree.GetFirstChild(item,cookie) + - if not clipboard.IsOk():
numkids=self.tree.GetChildrenCount(item,0) + - for i in range(numkids):
+ - if i < (numkids -1):
clipboard=self.tree.GetNextSibling(clipboard)
|
|
cookie2=0 (kid,flags) = self.tree.GetFirstChild(clipboard,cookie2) numkids=self.tree.GetChildrenCount(clipboard,0) + - for i in range(numkids):
tmpbuffer = self.CopyModel(kid,0) + - if i < (numkids -1):
nextkid=self.tree.GetNextSibling(kid)
|
self.tree.Delete(kid) newitem=self.tree.InsertTree(item,tmpbuffer) + - if i < (numkids -1):
|
self.modified=1 self.tree.Delete(clipboard)
|
+ - def InsertTextFile(self,filename,item):
+ - if filename:
+ - try:
self.log_write('Starting Import') retval=self.MySystem(self.buzzdir+'text2outline '+self.AddSlashes(filename)+' '+self.buzzdir) self.log_write('Completed Import') + - if not retval:
filename=filename+'.opml' self.tree.nodeStack = [item] self.tree.LoadTree(filename) self.PromoteClipboard(item) self.tree.Expand(item) self.modified=0 return filename
|
+ - else:
self.log_write('Could not open file') return None
|
|
+ - except:
self.log_write('Failed to import.') return None
|
|
|
+ - def RecentDir(self):
paths={} + - for i in range(10):
(thispath,thisfile)=os.path.split(self.file_buffers[i]) paths[thispath]=thispath
|
patharray=[] + - for thispath in paths.keys():
patharray.append(thispath)
|
dlg = wxSingleChoiceDialog(self, 'Choose Start Directory', 'Choose Start Directory', patharray) + - if dlg.ShowModal() == wxID_OK:
path=patharray[dlg.GetSelection()] dlg.Destroy() return path
|
+ - else:
|
+ - def LastFile(self):
+ - if self.modified:
+ - dlg = wxMessageDialog(self, 'Save before Opening?',
'Save?', wxYES_NO | wxICON_INFORMATION)
|
+ - if dlg.ShowModal() == wxID_YES:
+ - if not self.SaveFile():
|
|
filename=self.file_buffers[1] + - if filename:
self.ReSortRecent(1) return self.SetCurrentFile(filename)
|
+ - else:
|
+ - def OpenFile(self):
+ - if self.modified:
+ - dlg = wxMessageDialog(self, 'Save before Opening?',
'Save?', wxYES_NO | wxICON_INFORMATION)
|
+ - if dlg.ShowModal() == wxID_YES:
+ - if not self.SaveFile():
|
|
tmpdir=self.RecentDir() + - if tmpdir==-1:
self.cwd=tmpdir filename = self.FileSelector('Open', 'Choose a tree to open','*.opml',self.cwd) + - if filename:
return self.SetCurrentFile(filename)
|
+ - else:
|
+ - def SaveFile(self):
global bracket_open global lastend lastend = "__data" bracket_open=0 newname=0 oldname=self.filename + - if self.tree.GetChildrenCount(self.tree.root,0) > 1:
dlg = wxMessageDialog(self, 'XML can have only one root element', 'OK?', wxYES_NO | wxICON_INFORMATION) dlg.ShowModal() return
|
+ - if not self.filename:
self.filename = self.FileSelector('Save', 'Choose a filename','*.'+self.filetype,self.cwd,wxSAVE)
|
+ - if oldname !=self.filename:
+ - if self.filename:
+ - try:
+ - if newname and os.path.exists(self.filename):
+ - dlg = wxMessageDialog(self, 'File %s Exists. Replace It?'%self.filename,
'Save?', wxYES_NO | wxICON_INFORMATION)
|
+ - if dlg.ShowModal() == wxID_NO:
|
+ - elif os.path.exists(self.filename):
from shutil import copyfile backup=self.filename+"~" copyfile(self.filename,backup)
|
outfile = open(self.filename,'w') outfile.write("<?xml version='1.0' encoding='ISO-8859-1'?>\n") + - if (self.filename.lower().find('.opml') != -1):
#outfile.write('<?xml:stylesheet type='text/xsl' href='opml.xslt' version='1.0'?>') self.SaveModel(self.tree.root,outfile,0) outfile.close() self.tree.SetItemText(self.tree.root,self.filename) self.log_write('Saved %s'%self.filename) self.modified=0 return 1
|
+ - except:
self.log_write('Could not Save %s'%self.filename) self.filename=None return 0
|
|
+ - else:
|
+ - def LoadRecent(self):
+ - try:
outfile = open(self.userhome+'.buzz','r') retval=9 + - for i in range(10):
tmpline=outfile.readline() self.file_buffers[i]=tmpline[:-1] + - if len(tmpline[:-1]):
|
return retval
|
+ - except:
self.log_write('Could not Open Recent List')
|
|
+ - def LoadRecentURL(self):
+ - try:
outfile = open(self.userhome+'.buzzurl','r') retval=9 + - for i in range(10):
tmpline=outfile.readline() self.url_buffers[i]=tmpline[:-1] + - if len(tmpline[:-1]):
|
return retval
|
+ - except:
self.log_write('Could not Save Recent List')
|
|
+ - def LoadXmarks(self):
+ - try:
outfile = open(self.userhome+'.buzzxmarks','r') retval=49 + - for i in range(50):
text=outfile.readline() xlink=outfile.readline() self.xmarks[i]=(text[:-1],xlink[:-1]) + - if len(xlink[:-1]):
|
return retval
|
+ - except:
self.log_write('Could not open Xmark List')
|
|
+ - def SaveRecent(self):
+ - try:
outfile = open(self.userhome+'.buzz','w') + - for i in range(10):
outfile.write(self.file_buffers[i]+'\n')
|
|
+ - except:
self.log_write('Could not Save Recent List')
|
|
+ - def SaveRecentURL(self):
+ - try:
outfile = open(self.userhome+'.buzzurl','w') + - for i in range(10):
outfile.write(self.url_buffers[i]+'\n')
|
|
+ - except:
self.log_write('Could not Save Recent URL List')
|
|
+ - def SaveXmarks(self):
+ - try:
outfile = open(self.userhome+'.buzzxmarks','w') + - for i in range(50):
(text,xlink)=self.xmarks[i] outfile.write(text+'\n') outfile.write(xlink+'\n')
|
|
+ - except:
self.log_write('Could not save Xmarks')
|
|
+ - def SaveModel(self,item,outfile,depth):
global bracket_open data_node=self.tree.GetPyData(item) newvalue = self.tree.GetItemText(item) data_node.startsave(outfile,newvalue) cookie=depth (kid,flags) = self.tree.GetFirstChild(item,cookie) numkids=self.tree.GetChildrenCount(item,0) + - for i in range(numkids):
self.SaveModel(kid,outfile,depth+1) + - if i < (numkids -1):
kid=self.tree.GetNextSibling(kid)
|
|
data_node.endsave(outfile,newvalue)
|
+ - def AttachFileObject(self,item):
dlg = wxTextEntryDialog(self, 'URL?','Done','') + - if dlg.ShowModal() == wxID_OK:
filename=dlg.GetValue() newitem=self.tree.AppendItem(item,filename) self.tree.SetPyData(newitem,ElementWrapper(filename,'__outline')) self.tree.SelectItem(newitem) attitem=self.tree.PrependItem(newitem,'type=link') self.tree.SetPyData(attitem,ElementWrapper('New Item','__attr')) attitem=self.tree.PrependItem(newitem,'url='+filename) self.tree.SetPyData(attitem,ElementWrapper('New Item','__attr')) self.modified=1
|
|
+ - def OnURL(self,*event):
+ - def OnSave(self, *event):
+ - def OnFileExit(self, *event):
+ - def OnSaveAsXML(self, *event):
+ - def SaveAsXML(self):
global bracket_open global lastend lastend = "__data" bracket_open=0 self.ConvertXML() + - if self.tree.GetChildrenCount(self.tree.root,0) > 1:
dlg = wxMessageDialog(self, 'XML can have only one root element', 'OK?', wxYES_NO | wxICON_INFORMATION) dlg.ShowModal() return
|
+ - if not self.filename:
self.filename = self.FileSelector('Save', 'Choose a filename','*.*',self.cwd,wxSAVE)
|
+ - if self.filename:
+ - if os.path.exists(self.filename):
dlg = wxMessageDialog(self, 'File %s Exists. Replace It?'%self.filename, 'Save?', wxYES_NO | wxICON_INFORMATION) + - if dlg.ShowModal() == wxID_NO:
|
+ - try:
outfile = open(self.filename,'w') outfile.write("<?xml version='1.0' encoding='ISO-8859-1'?>\n") self.SaveModel(self.tree.root,outfile,0) self.log_write('Saved %s'%self.filename) self.tree.SetItemText(self.tree.root,self.filename) self.modified=0 return 1
|
+ - except:
self.log_write('Could not Save %s'%self.filename) self.filename=None return 0
|
|
|
+ - def OnSaveAs(self, *event):
global bracket_open global lastend lastend = "__data" bracket_open = 0 filename = self.FileSelector('Save', 'Choose a filename','*'+self.filetype,self.cwd,wxSAVE) + - if filename:
+ - if os.path.exists(filename):
dlg = wxMessageDialog(self, 'File %s Exists. Replace It?'%filename, 'Save?', wxYES_NO | wxICON_INFORMATION) + - if dlg.ShowModal() == wxID_NO:
|
+ - try:
outfile = open(filename,'w') outfile.write("<?xml version='1.0' encoding='ISO-8859-1'?>\n") self.SaveModel(self.tree.root,outfile,0) self.log_write('Saved as %s'%filename) self.filename=filename self.modified=0 self.tree.SetItemText(self.tree.root,filename)
|
+ - except:
self.log_write('Could not Save %s'%filename)
|
|
|
+ - def OnNew(self, *event):
+ - if self.modified:
+ - dlg = wxMessageDialog(self, 'Save before Opening?',
'Save?', wxYES_NO | wxICON_INFORMATION)
|
+ - if dlg.ShowModal() == wxID_YES:
+ - if not self.SaveFile():
|
|
filename=self.buzzdir+'empty.opml' #self.tree.DeleteChildren(self.tree.root) #self.tree.nodeStack = [self.tree.root] #self.filetype=self.tree.LoadTree(filename) #self.tree.Expand(self.tree.root) #self.tree.SetItemText(self.tree.root,'Unsaved New File') #self.tree.SelectItem(self.tree.root) #self.item=self.tree.root #self.modified=0 self.SetCurrentFile(filename) self.filename='' self.GetSchema(self.filetype) self.log_write('New OPML file')
|
+ - def OnNewXML(self, *event):
+ - if self.modified:
+ - dlg = wxMessageDialog(self, 'Save before Opening?',
'Save?', wxYES_NO | wxICON_INFORMATION)
|
+ - if dlg.ShowModal() == wxID_YES:
+ - if not self.SaveFile():
|
|
self.filename='' self.tree.DeleteChildren(self.tree.root) self.tree.nodeStack = [self.tree.root] self.tree.SetItemText(self.tree.root,'Unsaved New File') self.modified=0 self.schema=SchemaCtrl(self.buzzdir+'genericxml.schema',self.freeformxml) + - if self.schema:
self.log_write('Set schema to %s'%filename) (thispath,thisfile)=os.path.split(filename) filesplit=thisfile.split('.') self.filetype=filesplit[0].upper() return filename
|
+ - else:
self.log_write('Failed to set schema') return None
|
|
+ - def OnOpen(self, *event):
filename=self.OpenFile() + - if filename:
self.filename=filename (self.cwd,foo)=os.path.split(filename)
|
|
+ - def OnImage(self, event):
item=self.tree.GetSelection() + - if item.IsOk():
|
+ - def OnAttach(self, event):
item=self.tree.GetSelection() + - if item.IsOk():
self.AttachFileObject(item)
|
|
+ - def OnClose(self, event):
# Schema Functions + - def SetSchema(self):
cleanbuzzdir=string.replace(self.buzzdir,"\\\\","\\") filename = self.FileSelector('Open', 'Choose an XML schema','*.schema',cleanbuzzdir,wxOPEN,0) + - if filename:
self.schema=SchemaCtrl(filename,self.freeformxml) + - if self.schema:
self.log_write('Set schema to %s'%filename) (thispath,thisfile)=os.path.split(filename) filesplit=thisfile.split('.') self.filetype=filesplit[0].upper() return filename
|
+ - else:
self.log_write('Failed to set schema') return None
|
|
+ - else:
self.schema=None return None
|
|
+ - def GetSchema(self,filetype):
+ - if self.schematable.has_key(filetype.upper()):
filename=self.schematable[filetype.upper()] self.schema=SchemaCtrl(filename,self.freeformxml) + - if self.schema:
self.log_write('Set schema to %s'%filename) return filename
|
+ - else:
self.log_write('Failed to set schema') return None
|
|
+ - else:
|
+ - def OnSchema(self, *event):
+ - if self.modified:
+ - dlg = wxMessageDialog(self, 'Save before Opening?',
'Save?', wxYES_NO | wxICON_INFORMATION)
|
+ - if dlg.ShowModal() == wxID_YES:
+ - if not self.SaveFile():
|
|
self.filename='' self.tree.DeleteChildren(self.tree.root) self.tree.nodeStack = [self.tree.root] self.tree.SetItemText(self.tree.root,'Unsaved New File') self.modified=0 self.SetSchema()
|
+ - def OnSetSchema(self, *event):
# Editting Functions + - def OnPaste(self, evt):
+ - def OnCopy(self, evt):
item=self.tree.GetSelection() self.currentcut=(self.currentcut+1) %10 self.cut_buffers[self.currentcut] = self.CopyModel(item,0) self.CopyToClipboard() self.log_write('Copied Node\n')
|
+ - def Paste(self):
do = wxTextDataObject() wxTheClipboard.Open() + - if wxPlatform != '__WXMSW__':
wxTheClipboard.UsePrimarySelection(1) success = wxTheClipboard.GetData(do) + - if not success:
wxTheClipboard.UsePrimarySelection(0)
|
|
success = wxTheClipboard.GetData(do) wxTheClipboard.Close() + - if success:
curritem=self.tree.GetSelection() + - if curritem.IsOk():
self.PasteText(curritem,do.GetText()) self.modified=1
|
|
+ - else:
wxMessageBox('There is no data in the clipboard in the required format', 'Error')
|
|
+ - def CopyToClipboard(self):
+ - if wxPlatform != '__WXMSW__':
wxTheClipboard.UsePrimarySelection(1) wxTheClipboard.Clear() wxTheClipboard.UsePrimarySelection(0)
|
+ - if wxTheClipboard.Open():
wxTheClipboard.Clear() clipstr='' clipstr=self.tree.TreeToClipboard(self.cut_buffers[self.currentcut],0) wxTheClipboard.AddData(wxTextDataObject(clipstr)) wxTheClipboard.Close()
|
+ - else:
self.log_write('Unable to open clipboard')
|
|
+ - def Image(self,item):
filename = self.FileSelector('Save', 'Choose a filename','*',self.cwd,wxOPEN,0) + - if filename:
(foo,filename)=os.path.split(filename) newitem=self.tree.AppendItem(item,filename) self.tree.SetPyData(newitem,ElementWrapper(filename,'__outline')) self.tree.SelectItem(newitem) attitem=self.tree.PrependItem(newitem,'type=img') self.tree.SetPyData(attitem,ElementWrapper('New Item','__attr')) attitem=self.tree.PrependItem(newitem,'url='+filename) self.tree.SetPyData(attitem,ElementWrapper('New Item','__attr')) self.modified=1
|
|
+ - def CloseWin(self):
+ - if self.modified:
+ - dlg = wxMessageDialog(self, 'Save before Quitting?',
'Save?', wxYES_NO | wxICON_INFORMATION)
|
+ - if dlg.ShowModal() == wxID_YES:
+ - while not self.SaveFile():
|
|
self.dying = true self.window = None self.mainmenu = None self.SaveRecent() self.SaveXmarks() self.SaveRecentURL() + - if hasattr(self, 'tbicon'):
self.Destroy()
|
+ - def SetNodeTextChild(self,attribname,value):
self.currentfind=0 self.findcount=1 founditem=self.FindInModel(self.tree.root,attribname,0,1) + - if founditem and founditem.IsOk():
(kid,flags) = self.tree.GetFirstChild(founditem,0) self.tree.SetItemText(kid,value)
|
|
+ - def GetXPathValue(self,startroot,xpath):
founditem=self.Xpath(startroot,xpath) + - if founditem and founditem.IsOk():
return self.tree.GetItemText(founditem)
|
+ - else:
|
+ - def SetXPathValue(self,startroot,xpath,value):
founditem=self.Xpath(startroot,xpath) + - if founditem and founditem.IsOk():
self.tree.SetItemText(founditem,value)
|
|
+ - def GetNodeTextChild(self,attribname):
self.currentfind=0 self.findcount=1 founditem=self.FindInModel(self.tree.root,attribname,0,1) + - if founditem and founditem.IsOk():
(kid,flags) = self.tree.GetFirstChild(founditem,0) return self.tree.GetItemText(kid)
|
+ - else:
|
+ - def SetHeader(self,setcreated=0):
(baz,filename)=os.path.split(self.filename) self.SetXPathValue(self.tree.root,'/opml[1]/head[1]/title[1]/text()[1]',filename) thisnow=strftime('%a, %d %b %Y %H:%M:%S ', localtime()) (posx,posy)=self.GetPosition() (sizex,sizey)=self.GetSize() self.SetXPathValue(self.tree.root,'/opml[1]/head[1]/windowTop[1]/text()[1]',"%i"%posy) self.SetXPathValue(self.tree.root,'/opml[1]/head[1]/windowLeft[1]/text()[1]',"%i"%posx) self.SetXPathValue(self.tree.root,'/opml[1]/head[1]/windowBottom[1]/text()[1]',"%i"%(posy+sizey)) self.SetXPathValue(self.tree.root,'/opml[1]/head[1]/windowRight[1]/text()[1]',"%i"%(posx+sizex)) self.SetXPathValue(self.tree.root,'/opml[1]/head[1]/dateModified[1]/text()[1]',thisnow) + - if self.item and self.item.IsOk():
xpath=self.GenerateXpath(self.item) self.SetXPathValue(self.tree.root,'/opml[1]/head[1]/expansionState[1]/text()[1]',xpath)
|
+ - if setcreated:
self.SetXPathValue(self.tree.root,'/opml[1]/head[1]/dateCreated[1]/text()[1]',thisnow)
|
+ - try:
owner=os.environ['USER'] self.SetXPathValue(self.tree.root,'/opml[1]/head[1]/ownerName[1]/text()[1]',owner)
|
+ - except:
self.log_write('USER environment variable not set')
|
|
+ - def GenerateXpath(self,startitem):
+ - if startitem == self.tree.root or not startitem.IsOk():
currentparent=self.tree.GetItemParent(startitem) xpath="" + - while startitem != self.tree.root and currentparent.IsOk():
cookie=0 (offset,thisname)=self.GetNumOfChild(currentparent,startitem,cookie) xpath="/"+thisname+"["+repr(offset)+"]"+xpath startitem=currentparent + - if currentparent.IsOk():
currentparent=self.tree.GetItemParent(startitem)
|
|
return xpath
|
+ - def Xpath(self,startitem,xpath):
+ - if xpath == '/':
+ - if len(xpath) and xpath[0] != '/':
self.log_write("Invalid XPath %s"%xpath) return None
|
pathcomponents=xpath.split('/') + - for node in pathcomponents[1:]:
tmparray=node.split('[') name=tmparray[0] tmparray=tmparray[1].split(']') offset=tmparray[0] cookie=0 startitem=self.GetChildNum(startitem,name,int(offset),cookie) + - if not startitem or not startitem.IsOk():
|
return startitem
|
+ - def GetChildNum(self,item,thisname,offset,cookie):
currentnum=0 (kid,flags) = self.tree.GetFirstChild(item,cookie) numkids=self.tree.GetChildrenCount(item,0) + - for i in range(numkids):
ew = self.tree.GetPyData(kid) + - if ew.EltType=="__attr":
currtext=self.tree.GetItemText(kid) valarray=currtext.split('=') newvalue='@'+valarray[0]
|
+ - else:
+ - if ew.EltType=="__outline":
+ - else:
+ - if ew.EltType=="__data":
+ - else:
|
|
+ - if newvalue.lower().strip() == thisname.lower().strip():
currentnum=currentnum+1 + - if (currentnum == offset):
|
+ - if i < (numkids -1):
kid=self.tree.GetNextSibling(kid)
|
|
return(None)
|
+ - def GetNumOfChild(self,parent,child,cookie):
currentnum=0 ew = self.tree.GetPyData(child) + - if ew.EltType=="__attr":
currtext=self.tree.GetItemText(child) valarray=currtext.split('=') thisname='@'+valarray[0]
|
+ - else:
+ - if ew.EltType=="__outline":
+ - else:
+ - if ew.EltType=="__data":
+ - else:
|
|
(kid,flags) = self.tree.GetFirstChild(parent,cookie) numkids=self.tree.GetChildrenCount(parent,0) + - for i in range(numkids):
ew = self.tree.GetPyData(kid) + - if ew.EltType=="__attr":
currtext=self.tree.GetItemText(kid) valarray=currtext.split('=') newvalue='@'+valarray[0]
|
+ - else:
+ - if ew.EltType=="__outline":
+ - else:
+ - if ew.EltType=="__data":
+ - else:
|
|
+ - if newvalue.lower().strip() == thisname.lower().strip():
+ - if (kid == child):
return(currentnum,thisname)
|
+ - if i < (numkids -1):
kid=self.tree.GetNextSibling(kid)
|
|
self.log_write("Didn't find %s"%thisname) return(0,"")
|
+ - def FindInModel(self,item,needle,depth,casesensitive=0):
newvalue = self.tree.GetItemText(item) cookie=depth + - if not casesensitive:
found=newvalue.lower().find(needle)
|
+ - else:
found=newvalue.find(needle)
|
+ - if found != - 1:
self.currentfind=self.currentfind+1 + - if self.currentfind==self.findcount:
|
(kid,flags) = self.tree.GetFirstChild(item,cookie) numkids=self.tree.GetChildrenCount(item,0) + - for i in range(numkids):
found=self.FindInModel(kid,needle,cookie,casesensitive) + - if found and found.IsOk():
+ - if i < (numkids -1):
kid=self.tree.GetNextSibling(kid)
|
|
return(None)
|
+ - def FindInModelReplace(self,item,needle,depth,casesensitive=0,replacestr=""):
newvalue = self.tree.GetItemText(item) cookie=depth found=newvalue.find(needle) + - if found != - 1:
newvalue=string.replace(newvalue,needle,replacestr) self.tree.SetItemText(item,newvalue)
|
(kid,flags) = self.tree.GetFirstChild(item,cookie) numkids=self.tree.GetChildrenCount(item,0) + - for i in range(numkids):
found=self.FindInModelReplace(kid,needle,cookie,casesensitive,replacestr) + - if i < (numkids -1):
kid=self.tree.GetNextSibling(kid)
|
|
return(None)
|
+ - def OnFind(self,*evt):
item = self.tree.GetSelection() self.currentfindstr="" self.FindDialog(item)
|
+ - def OnFindAgain(self,*evt):
item = self.tree.GetSelection() + - if self.lastfoundroot and self.lastfoundroot.IsOk():
findroot=self.lastfoundroot self.findcount=self.findcount+1 self.currentfind=0 founditem=self.FindInModel(findroot,self.currentfindstr,0,self.casesensitive) + - if founditem and founditem.IsOk():
self.tree.EnsureVisible(founditem) self.tree.SelectItem(founditem) self.tree.Refresh() self.tree.SetFocus() self.lastfoundroot=findroot
|
+ - else:
rootlabel=self.tree.GetItemText(findroot) self.log_write('More than %i %s not found below %s. Resetting.\n'%(self.currentfind,self.currentfindstr,rootlabel)) self.lastfoundroot=None self.findcount=1
|
|
|
+ - def OnRootFind(self,*evt):
item = self.tree.root #self.currentfindstr="" self.lastfoundroot=None self.FindDialog(item)
|
+ - def OnFindRep(self,*evt):
item = self.tree.GetSelection() self.FindReplaceDialog(item)
|
+ - def FindReplaceDialog(self,item):
dlg = wxTextEntryDialog(self, 'Find?','Find',"") + - if dlg.ShowModal() != wxID_OK:
findstr=dlg.GetValue() dlg.Destroy() dlg = wxTextEntryDialog(self, 'Replace With?','Replace',"") + - if dlg.ShowModal() == wxID_OK:
replacestr=dlg.GetValue() self.findcount=1 findroot=item self.currentfind=0 founditem=self.FindInModelReplace(findroot,findstr,0,self.casesensitive,replacestr) self.modified=1
|
dlg.Destroy()
|
+ - def MySystem(self,cmd):
+ - if wxPlatform == '__WXMSW__':
os.system(self.bashcmd+"'"+cmd+"'")
|
+ - else:
os.system(self.bashcmd+cmd)
|
|
+ - def FindDialog(self,item):
dlg = wxTextEntryDialog(self, 'Find?','Find',self.currentfindstr) + - if dlg.ShowModal() == wxID_OK:
findstr=dlg.GetValue() + - if not self.casesensitive:
+ - if self.currentfindstr==findstr and self.lastfoundroot and self.lastfoundroot.IsOk():
findroot=self.lastfoundroot self.findcount=self.findcount+1
|
+ - else:
findroot=item self.findcount=1 self.currentfindstr=findstr
|
self.currentfind=0 founditem=self.FindInModel(findroot,self.currentfindstr,0,self.casesensitive) + - if founditem and founditem.IsOk():
self.tree.EnsureVisible(founditem) self.tree.SelectItem(founditem) self.tree.Refresh() self.tree.SetFocus() self.lastfoundroot=findroot
|
+ - else:
rootlabel=self.tree.GetItemText(findroot) self.log_write('More than %i %s not found below %s.\n'%(self.currentfind,self.currentfindstr,rootlabel)) self.lastfoundroot=None self.findcount=1
|
|
dlg.Destroy()
|
+ - def PasteText(self,item,text):
filename=self.tmpdir+'buzzpaste' outfile = open(filename,'w') + - if outfile:
outfile.write(text) outfile.close() self.InsertTextFile(filename,item)
|
|
+ - def XSearch(self):
curritem=self.tree.GetSelection() + - if curritem and curritem.IsOk() and self.SaveFile():
dlg = wxTextEntryDialog(self, 'Find?','Find',self.currentfindstr) + - if dlg.ShowModal() == wxID_OK:
findstr=dlg.GetValue() + - if not self.casesensitive:
+ - try:
self.log_write('Starting Search') retval=self.MySystem(self.buzzdir+'xsearch '+self.AddSlashes(findstr)+' '+self.AddSlashes(self.filename)+' '+repr(self.casesensitive)+' '+self.buzzdir) self.log_write('Completed Search') cleanbuzzdir=string.replace(self.userhome,"\\\\","\\") filename=cleanbuzzdir+'searchresults.opml' self.SetCurrentFile(filename)
|
+ - except:
self.log_write('Failed to Search.') return None
|
|
+ - else:
|
|
#Help Functions + - def OnFullHelp(self,event):
+ - def OnHelp(self,event):
win = wxDialog(self, -1, 'Help', wxDefaultPosition, wxSize(600,600)) helpfile=open(self.buzzdir+'buzz.hlp','r') helpstr=helpfile.read() wxStaticText(win, -1, helpstr, wxPoint(20, 20)) wxButton(win, wxID_OK, ' OK ', wxPoint(500, 120), wxDefaultSize).SetDefault() win.ShowModal()
|
+ - def OnFreeText(self,event):
item=self.tree.GetSelection() + - if item.IsOk():
|
+ - def EnterText(self,item):
win = FreeText(self, -1, "Enter Text", size=(500, 500), style = wxFRAME_FLOAT_ON_PARENT) win.SetCallBack(self,item) win.Show(true)
|
|