def OnTreeRightClick(self, evt): item, _flags = self.HitTest(evt.GetPosition()) if item and item != self.GetSelection(): self.SelectItem(item) cm = Menu(self.frame) if item: snippet = self.GetNode(item) if snippet.IsGroup(): cm.Add(self.OnRenameSnippet, xlt("Rename"), xlt(("Rename group"))) item = cm.Add(self.OnDelSnippet, xlt("Delete"), xlt(("Delete group"))) for s in self.snippets.values(): if s.parent == snippet.id: cm.Enable(item, False) break else: cm.Add(self.OnReplaceSnippet, xlt("Replace"), xlt(("Replace snippet text"))) cm.Add(self.OnRenameSnippet, xlt("Rename"), xlt(("Rename snippet"))) item = cm.Add(self.OnRevertSnippet, xlt("Revert"), xlt(("Revert snippet to previous text"))) cm.Enable(item, snippet.prevText != None) cm.Add(self.OnDelSnippet, xlt("Delete"), xlt( ("Delete snippet"))) cm.AppendSeparator() cm.Add(self.OnAddGroup, xlt("Add group"), xlt(("Add group"))) cm.Popup(evt)
def OnTreeRightClick(self, evt): item, _flags = self.HitTest(evt.GetPosition()) self.currentNode = None self.currentItem = item frame = self.GetFrame() if item: if item != self.GetSelection(): self.SelectItem(item) self.currentNode = self.GetNode(item) if self.currentNode: cm = Menu(frame) registerproc = self.currentNode.moduleinfo( )['serverclass'].Register cm.Add( registerproc, xlt("Register new %s") % self.currentNode.moduleinfo()['name']) cm.Add(self.OnEdit, xlt("Edit registration")) cm.Add(self.OnUnregister, xlt("Remove registration")) if not self.currentNode.settings.get('group'): cm.Add(self.OnAddGroup, xlt("New group")) else: cm = self.GetFrame().registermenu.Dup() if item: menuItem = cm.Add(self.OnDelGroup, xlt("Remove group")) if self.GetChildrenCount(item) > 0: cm.Enable(menuItem, False) else: cm.Add(self.OnAddGroup, xlt("New group")) cm.Popup(evt)
def OnCellRightClick(self, evt): self.GoToCell(evt.Row, evt.Col) self.cmRow=evt.Row self.cmCol=evt.Col colname=self.table.colNames[evt.Col] cd=self.tableSpecs.colSpecs.get(colname) cm=Menu(self.GetParent()) if cd: item=cm.Add(self.OnSetNull, xlt("Set NULL")) if cd.notNull: cm.Enable(item, False) cm.Popup(evt)
def OnItemRightClick(self, evt): if self.node: if hasattr(evt, 'GetIndex'): index = evt.GetIndex() else: index = -1 page = self.pages[self.GetSelection()] if not hasattr(evt, 'page'): evt.page = page if hasattr(page, 'menus'): cm = Menu(self) menus = page.menus for cls in menus: if hasattr(cls, "CheckAvailableOn" ) and not cls.CheckAvailableOn(page): continue cls.OnExecute._classname_ = cls.__name__ item = cm.Add(cls.OnExecute, cls.name, cls.help) if hasattr(cls, "CheckEnabled") and not cls.CheckEnabled(page): cm.Enable(item, False) if cm.GetMenuItemCount(): cm.Popup(evt) elif hasattr(self.node, "OnItemRightClick"): evt.currentPage = page self.node.OnItemRightClick(evt) elif hasattr(self.node, "GetItemNode"): node = self.node.GetItemNode(evt.page, index) if node: node.RefreshVolatile() node.GetProperties() w = adm.GetCurrentFrame(self) cm = w.GetContextMenu(node) w.currentNode = node cm.Popup(evt) w.currentNode = None
def GetContextMenu(self, node): contextMenu=Menu(self) if not len(node.properties): node.GetProperties() newcls=self.getNewClass(node) newmenu=Menu(self) if newcls: newmenu.Add(newcls.New, xlt("New %s") % newcls.shortname, xlt("Create new %s") % newcls.typename) morenew=node.nodeinfo().get('new', []) if isinstance(morenew, list): morenew=list(morenew) # copy else: morenew=[morenew] children=node.nodeinfo().get('children', []) for child in children: childnodeinfo=node.nodeinfo(child) childclass=childnodeinfo['class'] if childclass not in morenew: morenew.append(childclass) childnew=childnodeinfo.get('new', []) if not isinstance(childnew, list): childnew=[childnew] for childclass in childnew: if childclass not in morenew: morenew.append(childclass) for cls in morenew: if cls == newcls: continue if hasattr(cls, "New"): newmenu.Add(cls.New, xlt("New %s") % cls.shortname, xlt("Create new %s") % cls.typename) contextMenu.AppendOneMenu(newmenu, xlt("New Object"), xlt("Creates a new object")) if hasattr(node, "Delete"): if not hasattr(node, "deleteDisable") or not node.deleteDisable: contextMenu.Add(self.OnDelete, xlt("Delete %s") % node.shortname, xlt("Delete %s %s") % (node.typename,node.name)) if hasattr(node, "Disconnect"): contextMenu.Add(self.OnDisconnect, xlt("Disconnect %s") % node.name, xlt("Disconnect %s \"%s\"") % (node.typename,node.name)) if contextMenu.GetMenuItemCount(): contextMenu.AppendSeparator() contextMenu.Add(self.OnRefresh, xlt("Refresh"), xlt("Refresh %s") % node.typename) contextMenu.Add(self.OnDetach, xlt("Detach view"), xlt("Show %s in detached window") % node.typename) needSeparator=True for mi in node.menuinfos(): if self.menuAvailableOnNode(mi, node): if needSeparator: contextMenu.AppendSeparator() needSeparator=False cls=mi['class'] item=contextMenu.Add(cls.OnExecute, cls.name, cls.help) if hasattr(cls, "CheckEnabled") and not cls.CheckEnabled(node): contextMenu.Enable(item, False) if hasattr(node, "Edit"): contextMenu.AppendSeparator() contextMenu.Add(self.OnEdit, xlt("Properties"), xlt("Edit properties of %s") % node.typename) return contextMenu