Exemplo n.º 1
0
    def __init__(self,
                 module,
                 rootNode=None,
                 node=None,
                 isSelector=False,
                 *args,
                 **kwargs):
        """
			@param modul: Name of the modul we shall handle. Must be a list application!
			@type modul: string
			@param rootNode: The rootNode we shall display. If None, we try to select one.
			@type rootNode: String or None
			@param node: The node we shall display at start. Must be a child of rootNode
			@type node: String or None
		"""
        super(TreeWidget, self).__init__()
        self["class"].append("tree")
        self.module = module
        self.rootNode = rootNode
        self.node = node or rootNode
        self.actionBar = ActionBar(module, "tree")
        self.appendChild(self.actionBar)
        self.pathList = html5.Div()
        self.pathList["class"].append("breadcrumb")
        self.appendChild(self.pathList)
        self.entryFrame = SelectableDiv(self.nodeWidget, self.leafWidget)
        self.appendChild(self.entryFrame)
        self.entryFrame.selectionActivatedEvent.register(self)
        self._batchSize = 99
        self._currentCursor = {"node": None, "leaf": None}
        self._currentRequests = []
        self.rootNodeChangedEvent = EventDispatcher("rootNodeChanged")
        self.nodeChangedEvent = EventDispatcher("nodeChanged")
        self.isSelector = isSelector
        if self.rootNode:
            self.reloadData()
        else:
            NetworkService.request(self.module,
                                   "listRootNodes",
                                   successHandler=self.onSetDefaultRootNode)
        self.path = []
        self.sinkEvent("onClick")
        #Proxy some events and functions of the original table
        for f in [
                "selectionChangedEvent", "selectionActivatedEvent",
                "cursorMovedEvent", "getCurrentSelection",
                "selectionReturnEvent"
        ]:
            setattr(self, f, getattr(self.entryFrame, f))
        self.actionBar.setActions(self.defaultActions +
                                  (["select", "close"] if isSelector else []))
Exemplo n.º 2
0
    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")
Exemplo n.º 3
0
	def __init__(self, modul, key):
		super(RepeatDatePopup, self).__init__()
		self.module = modul
		self.editIdx = RepeatDatePopup.__editIdx_ #Iternal counter to ensure unique ids
		RepeatDatePopup.__editIdx_ += 1
		self.key = key
		self._lastData = {} #Dict of structure and values received
		self.closeOnSuccess = False

		h3 = html5.H3()
		h3["class"].append("modul_%s" % self.module)
		h3["class"].append("apptype_list")

		h3.appendChild(html5.TextNode(translate("create recurrent dates")))

		self.wasInitialRequest = True
		self.actionbar = ActionBar( self.module, "list", "repeatdate")
		self.appendChild( self.actionbar )
		self.form = html5.Form()
		self.appendChild(self.form)
		self.actionbar.setActions(["create.recurrent"])
		self.reloadData()
Exemplo n.º 4
0
Arquivo: list.py Projeto: Xeon2003/vi
    def __init__(self,
                 module,
                 filter=None,
                 columns=None,
                 isSelector=False,
                 filterID=None,
                 filterDescr=None,
                 batchSize=None,
                 context=None,
                 autoload=True,
                 *args,
                 **kwargs):
        """
			@param module: Name of the modul we shall handle. Must be a list application!
			@type module: string
		"""
        if not module in conf["modules"].keys():
            conf["mainWindow"].log(
                "error",
                translate("The module '{module}' does not exist.",
                          module=module))
            assert module in conf["modules"].keys()

        super(ListWidget, self).__init__()
        self._batchSize = batchSize or conf[
            "batchSize"]  # How many rows do we fetch at once?
        self.isDetaching = False  #If set, this widget is beeing about to be removed - dont issue nextBatchNeeded requests
        self.module = module
        self.context = context

        self.actionBar = ActionBar(module, "list", currentAction="list")
        self.appendChild(self.actionBar)

        self.sideBar = SideBar()
        self.appendChild(self.sideBar)

        myView = None

        if filterID:
            if conf["modules"] and module in conf["modules"].keys():
                if "views" in conf["modules"][module].keys(
                ) and conf["modules"][module]["views"]:
                    for v in conf["modules"][module]["views"]:
                        if v["__id"] == filterID:
                            myView = v
                            break
            if myView and "extendedFilters" in myView.keys(
            ) and myView["extendedFilters"]:
                self.appendChild(CompoundFilter(myView, module, embed=True))

        checkboxes = (conf["modules"] and module in conf["modules"].keys() and
                      "checkboxSelection" in conf["modules"][module].keys()
                      and conf["modules"][module]["checkboxSelection"])
        indexes = (conf["modules"] and module in conf["modules"].keys()
                   and "indexes" in conf["modules"][module].keys()
                   and conf["modules"][module]["indexes"])

        self.table = DataTable(checkboxes=checkboxes,
                               indexes=indexes,
                               *args,
                               **kwargs)
        self.appendChild(self.table)
        self._currentCursor = None
        self._structure = None
        self._currentRequests = []
        self.columns = []

        if isSelector and filter is None and columns is None:
            #Try to select a reasonable set of cols / filter
            if conf["modules"] and module in conf["modules"].keys():
                tmpData = conf["modules"][module]
                if "columns" in tmpData.keys():
                    columns = tmpData["columns"]
                if "filter" in tmpData.keys():
                    filter = tmpData["filter"]

        self.table.setDataProvider(self)
        self.filter = filter.copy() if isinstance(filter, dict) else {}
        self.columns = columns[:] if isinstance(columns, list) else []
        self.filterID = filterID  #Hint for the sidebarwidgets which predefined filter is currently active
        self.filterDescr = filterDescr  #Human-readable description of the current filter
        self._tableHeaderIsValid = False
        self.isSelector = isSelector

        #Proxy some events and functions of the original table
        for f in [
                "selectionChangedEvent", "selectionActivatedEvent",
                "cursorMovedEvent", "tableChangedEvent", "getCurrentSelection"
        ]:
            setattr(self, f, getattr(self.table, f))

        self.actionBar.setActions(self.getDefaultActions(myView))

        if isSelector:
            self.selectionActivatedEvent.register(self)

        self.emptyNotificationDiv = html5.Div()
        self.emptyNotificationDiv.appendChild(
            html5.TextNode(translate("Currently no entries")))
        self.emptyNotificationDiv["class"].append("emptynotification")
        self.appendChild(self.emptyNotificationDiv)
        self.emptyNotificationDiv["style"]["display"] = "none"
        self.table["style"]["display"] = "none"
        self.filterDescriptionSpan = html5.Span()
        self.appendChild(self.filterDescriptionSpan)
        self.filterDescriptionSpan["class"].append("filterdescription")
        self.updateFilterDescription()

        if autoload:
            self.reloadData()
Exemplo n.º 5
0
	def __init__(self, module, applicationType, key=0, node=None, skelType=None, clone=False,
	                hashArgs=None, context=None, logaction = "Entry saved!", *args, **kwargs):
		"""
			Initialize a new Edit or Add-Widget for the given module.
			:param module: Name of the module
			:type module: str
			:param applicationType: Defines for what application this Add / Edit should be created. This hides additional complexity introduced by the hierarchy / tree-application
			:type applicationType: Any of EditWidget.appList, EditWidget.appHierarchy, EditWidget.appTree or EditWidget.appSingleton
			:param id: ID of the entry. If none, it will add a new Entry.
			:type id: Number
			:param rootNode: If applicationType==EditWidget.appHierarchy, the new entry will be added under this node, if applicationType==EditWidget,appTree the final node is derived from this and the path-parameter.
			Has no effect if applicationType is not appHierarchy or appTree or if an id have been set.
			:type rootNode: str
			:param path: Specifies the path from the rootNode for new entries in a treeApplication
			:type path: str
			:param clone: If true, it will load the values from the given id, but will save a new entry (i.e. allows "cloning" an existing entry)
			:type clone: bool
			:param hashArgs: Dictionary of parameters (usually supplied by the window.hash property) which should prefill values.
			:type hashArgs: dict
		"""
		if not module in conf["modules"].keys():
			conf["mainWindow"].log("error", translate("The module '{module}' does not exist.", module=module))
			assert module in conf["modules"].keys()

		super(EditWidget, self ).__init__(*args, **kwargs)
		self.module = module

		# A Bunch of santy-checks, as there is a great chance to mess around with this widget
		assert applicationType in [ EditWidget.appList, EditWidget.appHierarchy, EditWidget.appTree, EditWidget.appSingleton ] #Invalid Application-Type?

		if applicationType==EditWidget.appHierarchy or applicationType==EditWidget.appTree:
			assert key is not None or node is not None #Need either an id or an node

		if clone:
			assert key is not None #Need an id if we should clone an entry
			assert not applicationType==EditWidget.appSingleton # We cant clone a singleton
			if applicationType==EditWidget.appHierarchy or applicationType==EditWidget.appTree:
				assert node is not None #We still need a rootNode for cloning
			if applicationType==EditWidget.appTree:
				assert node is not None #We still need a path for cloning #FIXME

			self.clone_of = key
		else:
			self.clone_of = None

		# End santy-checks
		self.editIdx = EditWidget.__editIdx_ #Internal counter to ensure unique ids
		EditWidget.__editIdx_ += 1
		self.applicationType = applicationType
		self.key = key
		self.mode = "edit" if self.key or applicationType == EditWidget.appSingleton else "add"
		self.modified = False
		self.node = node
		self.skelType = skelType
		self.clone = clone
		self.bones = {}
		self.closeOnSuccess = False
		self.logaction = logaction
		self.sinkEvent("onChange")

		self.context = context
		self.views = {}

		self._lastData = {} #Dict of structure and values received

		if hashArgs:
			self._hashArgs = parseHashParameters(hashArgs)
		else:
			self._hashArgs = None

		self.editTaskID = None
		self.wasInitialRequest = True #Wherever the last request attempted to save data or just fetched the form

		# Action bar
		self.actionbar = ActionBar(self.module, self.applicationType, (self.mode if not clone else "clone"))
		self.appendChild(self.actionbar)

		editActions = []

		if self.mode == "edit":
			editActions.append("refresh")

		if module in conf["modules"] and conf["modules"][module]:
			editActions.extend(conf["modules"][module].get("editActions", []))

		if applicationType == EditWidget.appSingleton:
			self.actionbar.setActions(["save.singleton"] + editActions)
		else:
			self.actionbar.setActions(["save.close", "save.continue"] + editActions)

		# Set path
		if applicationType == EditWidget.appSingleton:
			conf["theApp"].setPath(module + "/" + self.mode)
		elif self.mode == "edit":
			conf["theApp"].setPath(module + "/" + (self.mode if not clone else "clone") + "/" + self.key)
		else:
			conf["theApp"].setPath(module + "/" + self.mode)

		# Input form
		self.form = html5.Form()
		self.appendChild(self.form)

		# Engage
		self.reloadData()
Exemplo n.º 6
0
    def __init__(self,
                 editHtml,
                 actionBarHint=translate("Text Editor"),
                 *args,
                 **kwargs):
        super(Wysiwyg, self).__init__(*args, **kwargs)
        self.cursorMovedEvent = EventDispatcher("cursorMoved")
        self.saveTextEvent = EventDispatcher("saveText")
        self.abortTextEvent = EventDispatcher("abortText")
        self.textActions = ["style.text.bold",
                            "style.text.italic"]+\
                           ["style.text.h%s" % x for x in range(0,4)]+\
                           ["text.removeformat",
             "style.text.justifyCenter",
             "style.text.justifyLeft",
             "style.text.justifyRight",
                         "style.text.blockquote",
                         "text.orderedList",
                         "text.unorderedList",
                         "text.indent",
                         "text.outdent",
                         "text.image",
                         "text.link",
                         "text.table",
                         "text.flipView",
                         "text.undo",
                         "text.redo",
                         "text.abort",
                         "text.save"]

        #self["type"] = "text"
        self.actionbar = ActionBar(None, None, actionBarHint)
        self.isWysiwygMode = True
        self.discardNextClickEvent = False
        self.appendChild(self.actionbar)
        self.tableDiv = html5.Div()
        self.tableDiv["class"].append("tableeditor")
        self.appendChild(self.tableDiv)
        for c in [
                TableInsertRowBeforeAction, TableInsertRowAfterAction,
                TableInsertColBeforeAction, TableInsertColAfterAction,
                TableRemoveRowAction, TableRemoveColAction
        ]:
            self.tableDiv.appendChild(c())
        self.tableDiv["style"]["display"] = "none"
        self.linkEditor = LinkEditor()
        self.appendChild(self.linkEditor)
        self.imgEditor = ImageEditor()
        self.appendChild(self.imgEditor)

        self.editor = Editor(editHtml)

        self.appendChild(self.editor)
        self.actionbar.setActions(self.textActions)
        #btn = html5.ext.Button("Apply", self.saveText)
        #btn["class"].append("icon apply")
        #self.appendChild( btn )
        self.currentImage = None
        self.cursorImage = None
        self.lastMousePos = None
        self.sinkEvent("onMouseDown", "onMouseUp", "onMouseMove", "onClick")