def _createWidgets(self): self.blogsLabel = wx.StaticText( self, wx.ID_ANY, _extstr(u"metadata.Blogs")) #$NON-NLS-1$ self.blogsCtrl = ZBlogInfoChooser(self, self.model) self.titleLabel = wx.StaticText( self, wx.ID_ANY, _extstr(u"metadata.Title")) #$NON-NLS-1$ self.titleText = wx.TextCtrl(self, wx.ID_ANY) self.tagwordsLabel = wx.StaticText( self, wx.ID_ANY, _extstr(u"metadata.Tagwords")) #$NON-NLS-1$ self.tagwordsText = wx.TextCtrl(self, wx.ID_ANY) self.staticLine = wx.StaticLine(self, wx.HORIZONTAL)
def _createWidgets(self): self.blogsLabel = wx.StaticText(self, wx.ID_ANY, _extstr(u"metadata.Blogs")) #$NON-NLS-1$ self.blogsCtrl = ZBlogInfoChooser(self, self.model) self.titleLabel = wx.StaticText(self, wx.ID_ANY, _extstr(u"metadata.Title")) #$NON-NLS-1$ self.titleText = wx.TextCtrl(self, wx.ID_ANY) self.tagwordsLabel = wx.StaticText(self, wx.ID_ANY, _extstr(u"metadata.Tagwords")) #$NON-NLS-1$ self.tagwordsText = wx.TextCtrl(self, wx.ID_ANY) self.staticLine = wx.StaticLine(self, wx.HORIZONTAL)
class ZBlogPostMetaDataWidget(wx.Panel): def __init__(self, parent, zblogPostMetaDataModel): self.model = zblogPostMetaDataModel # title or tagwords have been modified. self.dirty = False self.initialTitle = None self.initialTagwords = None wx.Panel.__init__(self, parent, wx.ID_ANY) self._createWidgets() self._layoutWidgets() self._bindWidgetEvents() # end __init__() def getModel(self): u"""getModel() -> ZBlogPostMetaDataModel Returns data model.""" #$NON-NLS-1$ return self.model # end getModel() def _createWidgets(self): self.blogsLabel = wx.StaticText( self, wx.ID_ANY, _extstr(u"metadata.Blogs")) #$NON-NLS-1$ self.blogsCtrl = ZBlogInfoChooser(self, self.model) self.titleLabel = wx.StaticText( self, wx.ID_ANY, _extstr(u"metadata.Title")) #$NON-NLS-1$ self.titleText = wx.TextCtrl(self, wx.ID_ANY) self.tagwordsLabel = wx.StaticText( self, wx.ID_ANY, _extstr(u"metadata.Tagwords")) #$NON-NLS-1$ self.tagwordsText = wx.TextCtrl(self, wx.ID_ANY) self.staticLine = wx.StaticLine(self, wx.HORIZONTAL) # end _createWidgets() def _layoutWidgets(self): panelSizer = wx.BoxSizer(wx.VERTICAL) flexGridSizer = wx.FlexGridSizer(3, 2, 2, 5) flexGridSizer.AddGrowableCol(1) flexGridSizer.AddGrowableRow(0) flexGridSizer.Add(self.blogsLabel, 0, wx.ALIGN_RIGHT | wx.ALIGN_TOP) flexGridSizer.Add(self.blogsCtrl, 0, wx.EXPAND) flexGridSizer.Add(self.titleLabel, 0, wx.ALIGN_RIGHT | wx.ALIGN_CENTER_VERTICAL) flexGridSizer.Add(self.titleText, 0, wx.EXPAND) flexGridSizer.Add(self.tagwordsLabel, 0, wx.ALIGN_RIGHT | wx.ALIGN_CENTER_VERTICAL) flexGridSizer.Add(self.tagwordsText, 0, wx.EXPAND) panelSizer.AddSizer(flexGridSizer, 0, wx.EXPAND | wx.ALL, 3) panelSizer.Add(self.staticLine, 0, wx.EXPAND) self.SetSizer(panelSizer) self.SetAutoLayout(True) self.Layout() # end _layoutWidgets() def _bindWidgetEvents(self): self.Bind(wx.EVT_TEXT, self.onTitleTextChange, self.titleText) self.Bind(wx.EVT_TEXT, self.onTagwordsTextChange, self.tagwordsText) # end _bindWidgetEvents() def getPubMetaDataList(self): return self.blogsCtrl.getPubMetaDataList() # end getPubMetaDataList() def getTitle(self): return self.titleText.GetValue() # end getTitle() def getTagwords(self): return self.tagwordsText.GetValue() # end getTagwords() def onTitleTextChange(self, event): #@UnusedVariable if not self.dirty and self.initialTitle is not None and self.initialTitle != self.titleText.GetValue( ).strip(): self._setDirty(True) fireMetaDataTitleChangedEvent(self, self.getTitle()) # end onTitleTextChange() def onTagwordsTextChange(self, event): #@UnusedVariable if not self.dirty and self.initialTagwords is not None and self.initialTagwords != self.tagwordsText.GetValue( ).strip(): self._setDirty(True) # end onTagwordsTextChange() def refreshUI(self): # clear dirty flag since UI data will be same as model self._setDirty(False) # update UI for title and tags from model self.titleText.SetValue(self.getModel().getTitle()) self.tagwordsText.SetValue(self.getModel().getTagwords()) # save the initial data - used to compare to see if content has been modified. self.initialTitle = self.getModel().getTitle() self.initialTagwords = self.getModel().getTagwords() self.blogsCtrl.refreshUI() # end refreshUI() def updateModel(self): # Get the title and tags and set it in the model self.getModel().setTitle(self.titleText.GetValue().strip()) self.getModel().setTagwords(self.tagwordsText.GetValue().strip()) self.blogsCtrl.updateModel() # end updateModel() def _setDirty(self, dirty): if self.dirty != dirty: self.dirty = dirty if dirty: firePublishingChangeEvent(self) else: self.initialTitle = None self.initialTagwords = None
def _createNonHeaderWidgets(self): # FIXME (PJ) extern this self.publishToStaticBox = wx.StaticBox( self, wx.ID_ANY, u"Publish To Blog(s)") #$NON-NLS-1$ self.pubMetaDataCtrl = ZBlogInfoChooser(self, self.blogInfoModel)
class ZBlogPublishingDialog(ZHeaderDialog): def __init__(self, parent, document, blog): self.blog = blog self.document = document self.blogInfoModel = ZBlogPostMetaDataModel() self.blogInfoModel.setInitDocument(document) self.pubMetaDataCtrl = None #FIXME (PJ) extern this and rest of string in this class/module ZHeaderDialog.__init__( self, parent, wx.ID_ANY, u"Publish Blog Entry", style=wx.DEFAULT_DIALOG_STYLE | wx.RESIZE_BORDER, name=u"ZBlogPublishingDialog") #$NON-NLS-2$ #$NON-NLS-1$ self.Layout() # end __init__() def getPubMetaDataList(self): metaDataList = [] if self.pubMetaDataCtrl is not None: self.pubMetaDataCtrl.updateModel() metaDataList = self.blogInfoModel.getPubMetaDataList() return metaDataList # end getPubMetaDataList def getPubMetaData(self): # Return selected pubmeta data rval = None metaDataList = self.getPubMetaDataList() if metaDataList and len(metaDataList) > 0: rval = metaDataList[0] return rval # end getPubMetaData def _createNonHeaderWidgets(self): # FIXME (PJ) extern this self.publishToStaticBox = wx.StaticBox( self, wx.ID_ANY, u"Publish To Blog(s)") #$NON-NLS-1$ self.pubMetaDataCtrl = ZBlogInfoChooser(self, self.blogInfoModel) # end _createNonHeaderWidgets() def _populateNonHeaderWidgets(self): self.pubMetaDataCtrl.refreshUI() # end _populateNonHeaderWidgets() def _layoutNonHeaderWidgets(self): staticBox = wx.StaticBoxSizer(self.publishToStaticBox, wx.VERTICAL) box = wx.BoxSizer(wx.VERTICAL) box.Add(self.pubMetaDataCtrl, 0, wx.EXPAND | wx.ALL) staticBox.AddSizer(box, 1, wx.EXPAND | wx.ALL, 5) box = wx.BoxSizer(wx.VERTICAL) box.AddSizer(staticBox, 1, wx.EXPAND | wx.ALL, 5) return box # end _layoutNonHeaderWidgets() def _bindWidgetEvents(self): pass # end _bindWidgetEvents() def _setInitialFocus(self): self._getOkButton().SetFocus() # end _setInitialFocus() def _getHeaderTitle(self): return u"Publish Blog Entry" #$NON-NLS-1$ # end _getHeaderTitle() def _getHeaderMessage(self): return u"Use this dialog to configure publishing settings and then publish your blog entry." #$NON-NLS-1$ # end _getHeaderMessage() def _getHeaderImagePath(self): return u"images/dialogs/blogpub/header_image.png" #$NON-NLS-1$ # end _getHeaderImagePath() def _getButtonTypes(self): return ZBaseDialog.OK_BUTTON | ZBaseDialog.CANCEL_BUTTON # end _getButtonTypes() def _getOKButtonLabel(self): return u"Publish" #$NON-NLS-1$
class ZBlogPostMetaDataWidget(wx.Panel): def __init__(self, parent, zblogPostMetaDataModel): self.model = zblogPostMetaDataModel # title or tagwords have been modified. self.dirty = False self.initialTitle = None self.initialTagwords = None wx.Panel.__init__(self, parent, wx.ID_ANY) self._createWidgets() self._layoutWidgets() self._bindWidgetEvents() # end __init__() def getModel(self): u"""getModel() -> ZBlogPostMetaDataModel Returns data model.""" #$NON-NLS-1$ return self.model # end getModel() def _createWidgets(self): self.blogsLabel = wx.StaticText(self, wx.ID_ANY, _extstr(u"metadata.Blogs")) #$NON-NLS-1$ self.blogsCtrl = ZBlogInfoChooser(self, self.model) self.titleLabel = wx.StaticText(self, wx.ID_ANY, _extstr(u"metadata.Title")) #$NON-NLS-1$ self.titleText = wx.TextCtrl(self, wx.ID_ANY) self.tagwordsLabel = wx.StaticText(self, wx.ID_ANY, _extstr(u"metadata.Tagwords")) #$NON-NLS-1$ self.tagwordsText = wx.TextCtrl(self, wx.ID_ANY) self.staticLine = wx.StaticLine(self, wx.HORIZONTAL) # end _createWidgets() def _layoutWidgets(self): panelSizer = wx.BoxSizer(wx.VERTICAL) flexGridSizer = wx.FlexGridSizer(3, 2, 2, 5) flexGridSizer.AddGrowableCol(1) flexGridSizer.AddGrowableRow(0) flexGridSizer.Add(self.blogsLabel, 0, wx.ALIGN_RIGHT | wx.ALIGN_TOP) flexGridSizer.Add(self.blogsCtrl, 0, wx.EXPAND) flexGridSizer.Add(self.titleLabel, 0, wx.ALIGN_RIGHT | wx.ALIGN_CENTER_VERTICAL) flexGridSizer.Add(self.titleText, 0, wx.EXPAND) flexGridSizer.Add(self.tagwordsLabel, 0, wx.ALIGN_RIGHT | wx.ALIGN_CENTER_VERTICAL) flexGridSizer.Add(self.tagwordsText, 0, wx.EXPAND) panelSizer.AddSizer(flexGridSizer, 0, wx.EXPAND | wx.ALL, 3) panelSizer.Add(self.staticLine, 0, wx.EXPAND) self.SetSizer(panelSizer) self.SetAutoLayout(True) self.Layout() # end _layoutWidgets() def _bindWidgetEvents(self): self.Bind(wx.EVT_TEXT, self.onTitleTextChange, self.titleText) self.Bind(wx.EVT_TEXT, self.onTagwordsTextChange, self.tagwordsText) # end _bindWidgetEvents() def getPubMetaDataList(self): return self.blogsCtrl.getPubMetaDataList() # end getPubMetaDataList() def getTitle(self): return self.titleText.GetValue() # end getTitle() def getTagwords(self): return self.tagwordsText.GetValue() # end getTagwords() def onTitleTextChange(self, event): #@UnusedVariable if not self.dirty and self.initialTitle is not None and self.initialTitle != self.titleText.GetValue().strip(): self._setDirty(True) fireMetaDataTitleChangedEvent(self, self.getTitle()) # end onTitleTextChange() def onTagwordsTextChange(self, event): #@UnusedVariable if not self.dirty and self.initialTagwords is not None and self.initialTagwords != self.tagwordsText.GetValue().strip(): self._setDirty(True) # end onTagwordsTextChange() def refreshUI(self): # clear dirty flag since UI data will be same as model self._setDirty(False) # update UI for title and tags from model self.titleText.SetValue( self.getModel().getTitle() ) self.tagwordsText.SetValue( self.getModel().getTagwords() ) # save the initial data - used to compare to see if content has been modified. self.initialTitle = self.getModel().getTitle() self.initialTagwords = self.getModel().getTagwords() self.blogsCtrl.refreshUI() # end refreshUI() def updateModel(self): # Get the title and tags and set it in the model self.getModel().setTitle( self.titleText.GetValue().strip() ) self.getModel().setTagwords( self.tagwordsText.GetValue().strip() ) self.blogsCtrl.updateModel() # end updateModel() def _setDirty(self, dirty): if self.dirty != dirty: self.dirty = dirty if dirty: firePublishingChangeEvent(self) else: self.initialTitle = None self.initialTagwords = None
def _createNonHeaderWidgets(self): # FIXME (PJ) extern this self.publishToStaticBox = wx.StaticBox(self, wx.ID_ANY, u"Publish To Blog(s)") #$NON-NLS-1$ self.pubMetaDataCtrl = ZBlogInfoChooser(self, self.blogInfoModel)
class ZBlogPublishingDialog(ZHeaderDialog): def __init__(self, parent, document, blog): self.blog = blog self.document = document self.blogInfoModel = ZBlogPostMetaDataModel() self.blogInfoModel.setInitDocument(document) self.pubMetaDataCtrl = None #FIXME (PJ) extern this and rest of string in this class/module ZHeaderDialog.__init__(self, parent, wx.ID_ANY, u"Publish Blog Entry", style = wx.DEFAULT_DIALOG_STYLE | wx.RESIZE_BORDER, name = u"ZBlogPublishingDialog") #$NON-NLS-2$ #$NON-NLS-1$ self.Layout() # end __init__() def getPubMetaDataList(self): metaDataList = [] if self.pubMetaDataCtrl is not None: self.pubMetaDataCtrl.updateModel() metaDataList = self.blogInfoModel.getPubMetaDataList() return metaDataList # end getPubMetaDataList def getPubMetaData(self): # Return selected pubmeta data rval = None metaDataList = self.getPubMetaDataList() if metaDataList and len(metaDataList) > 0: rval = metaDataList[0] return rval # end getPubMetaData def _createNonHeaderWidgets(self): # FIXME (PJ) extern this self.publishToStaticBox = wx.StaticBox(self, wx.ID_ANY, u"Publish To Blog(s)") #$NON-NLS-1$ self.pubMetaDataCtrl = ZBlogInfoChooser(self, self.blogInfoModel) # end _createNonHeaderWidgets() def _populateNonHeaderWidgets(self): self.pubMetaDataCtrl.refreshUI() # end _populateNonHeaderWidgets() def _layoutNonHeaderWidgets(self): staticBox = wx.StaticBoxSizer(self.publishToStaticBox, wx.VERTICAL) box = wx.BoxSizer(wx.VERTICAL) box.Add(self.pubMetaDataCtrl, 0, wx.EXPAND | wx.ALL) staticBox.AddSizer(box, 1, wx.EXPAND | wx.ALL, 5) box = wx.BoxSizer(wx.VERTICAL) box.AddSizer(staticBox, 1, wx.EXPAND | wx.ALL, 5) return box # end _layoutNonHeaderWidgets() def _bindWidgetEvents(self): pass # end _bindWidgetEvents() def _setInitialFocus(self): self._getOkButton().SetFocus() # end _setInitialFocus() def _getHeaderTitle(self): return u"Publish Blog Entry" #$NON-NLS-1$ # end _getHeaderTitle() def _getHeaderMessage(self): return u"Use this dialog to configure publishing settings and then publish your blog entry." #$NON-NLS-1$ # end _getHeaderMessage() def _getHeaderImagePath(self): return u"images/dialogs/blogpub/header_image.png" #$NON-NLS-1$ # end _getHeaderImagePath() def _getButtonTypes(self): return ZBaseDialog.OK_BUTTON | ZBaseDialog.CANCEL_BUTTON # end _getButtonTypes() def _getOKButtonLabel(self): return u"Publish" #$NON-NLS-1$