def __init__(self, module, data, structure, *args, **kwargs): """ :param module: Name of the module we shall display data for :type module: str :param data: The data for that entry :type data: dict :param structure: Skeleton structure for that module (as received from the server) :type structure: list """ super( HierarchyItem, self ).__init__( *args, **kwargs ) self.module = module self.data = data self.structure = structure self.expandLink = html5.A() self.expandLink["class"].append("expandlink") self.expandLink.appendChild(html5.TextNode(translate("Expand/Collapse"))) self.appendChild(self.expandLink) #self.element.innerHTML = "%s %s" % (data["name"], data["sortindex"]) self.isLoaded = False self.isExpanded = False self.buildDescription() self.ol = html5.Ol() self.ol["class"].append("subhierarchy") self.appendChild(self.ol) self.currentMargin = None self.ol["style"]["display"] = "none" self["class"].append("hierarchyitem") self["class"].append("unexpaned") self["class"].append("supports_drag") self["class"].append("supports_drop") self["draggable"] = True self.sinkEvent("onDragStart", "onDrop", "onDragOver","onDragLeave")
def __init__(self, module, rootNode=None, isSelector=False, context=None, *args, **kwargs): """ @param module: Name of the modul we shall handle. Must be a hierarchy application! @type module: string @param rootNode: The repository we shall display. If none, we try to select one. @type rootNode: String or None """ super(HierarchyWidget, self).__init__() self.module = module self.rootNode = rootNode self.actionBar = ActionBar(module, "hierarchy") self.appendChild(self.actionBar) self.entryFrame = html5.Ol() self.entryFrame["class"].append("hierarchy") self.appendChild(self.entryFrame) self.selectionChangedEvent = EventDispatcher("selectionChanged") self.selectionActivatedEvent = EventDispatcher("selectionActivated") self.rootNodeChangedEvent = EventDispatcher("rootNodeChanged") self._currentCursor = None self._currentRequests = [] self.addClass("supports_drop") self.isSelector = isSelector self._expandedNodes = [] self.context = context if self.rootNode: self.reloadData() else: NetworkService.request(self.module, "listRootNodes", self.context or {}, successHandler=self.onSetDefaultRootNode, failureHandler=self.showErrorMsg) self.path = [] self.sinkEvent("onClick", "onDblClick") ##Proxy some events and functions of the original table #for f in ["selectionChangedEvent","selectionActivatedEvent","cursorMovedEvent","getCurrentSelection"]: # setattr( self, f, getattr(self.table,f)) self.actionBar.setActions( ["selectrootnode", "add", "edit", "clone", "delete"] + (["select", "close"] if isSelector else []) + ["reload"]) self.sinkEvent("onDrop", "onDragOver")