def configuration_wizard(experiment): doc = lc.document( title='Configuration wizard for ARCS_beam', id='instrument-configuration-wizard', ) # button to skip this wizard from . import load_manual_instrument_configuration load_manual_configuration = load_manual_instrument_configuration( experiment.id) skip_button = lc.button( label='skip this wizard', onclick=select(element=doc).replaceBy(load_manual_configuration), ) doc.add(skip_button) # wizard form = doc.form(id='arcs-beam-wizard') form.text(name='fermi_nu', label='Fermi chopper frequency (Hz)', value=600) # form.text(name='fermi_bladeradius', label = 'Fermi choipper blade radius (meter)', value=0.060364) form.text(name='T0_nu', label='T0 chopper frequency (Hz)', value=120) form.text(name='E', label='Desired incident energy (meV)', value=100) form.text(name='emission_time', label='Emission time (microsecond)', value=10) form.submitbutton() form.onsubmit = select(element=form).submit( actor='neutronexperiment/edit/ARCS_beam_wizard', experiment_id=experiment.id) return doc
def _createAPIDocument(self, director): w = self.widget descriptors = w.getDescriptors() descriptors = self._categorizeDescriptors(descriptors) doc = lc.document() tabs = lc.tabs() doc.add(tabs) # tab1 = tabs.tab(label='Introduction') d = self._createIntroductionDocument(descriptors) tab1.add(d) # tab2 = tabs.tab(label='Properties') tab2.onselect = select(element=tab2).replaceContent( load(actor=self.name, routine='propertiesDocument')) # tab3 = tabs.tab(label='Events') tab3.onselect = select(element=tab3).replaceContent( load(actor=self.name, routine='eventsDocument')) # tab4 = tabs.tab(label='Actions') tab4.onselect = select(element=tab4).replaceContent( load(actor=self.name, routine='actionsDocument')) # return doc
def export(self, director): "Displays exports page" return [ select(id=ID_RESULTS).replaceContent( self._contentExport(director)), select(id=ID_OUTPUTS).replaceContent(self._outputLinks(director)) ]
def outputs(self, director): "Displays the content of output files" return [ select(id=ID_RESULTS).replaceContent( self._contentOutput(director)), select(id=ID_OUTPUTS).replaceContent(self._outputLinks(director)) ]
def configuration_wizard(experiment): doc = lc.document( title='Configuration wizard for ARCS_beam', id='instrument-configuration-wizard', ) # button to skip this wizard from . import load_manual_instrument_configuration load_manual_configuration = load_manual_instrument_configuration(experiment.id) skip_button = lc.button( label='skip this wizard', onclick=select(element=doc).replaceBy(load_manual_configuration), ) doc.add(skip_button) # wizard form = doc.form(id='arcs-beam-wizard') form.text(name='fermi_nu', label = 'Fermi chopper frequency (Hz)', value=600) # form.text(name='fermi_bladeradius', label = 'Fermi choipper blade radius (meter)', value=0.060364) form.text(name='T0_nu', label = 'T0 chopper frequency (Hz)', value=120) form.text(name='E', label = 'Desired incident energy (meV)', value=100) form.text(name='emission_time', label = 'Emission time (microsecond)', value=10) form.submitbutton() form.onsubmit = select(element=form).submit( actor='neutronexperiment/edit/ARCS_beam_withmonitor2_wizard', experiment_id = experiment.id) return doc
def getActions(self, document, pathlist): actions = [] actions.append( select(id='path-content').replaceContent(self.path(pathlist))) actions.append(select(id='maindoc').replaceContent(document)) return actions
def _createfield_for_phonons(obj): # this is a method of mold. self = drawer.mold # imports import luban.content as lc from luban.content import load, select from luban.content.FormSelectorField import FormSelectorField # utils orm = self.orm # data record = self.orm(obj) referred_record = record.phonons and record.phonons.id \ and record.phonons.dereference(self.orm.db) # widget doc = lc.document(Class='container', id='phonons-selector-container') sp = doc.splitter() left = sp.section() right = sp.section() # selector = FormSelectorField(label='Phonons:', name='phonons') left.add(selector) # plotcontainer = right.document(Class='container') # loadplot = lambda uid: load( actor='orm/phonons', routine='createGraphicalView', uid=uid) # default selection if referred_record: value = orm.db.getUniqueIdentifierStr(referred_record) plotcontainer.oncreate = select(element=plotcontainer).append( loadplot(value)) else: value = None # choices # get matter matter = orm.db.dereference(record.matter) matterid = matter.id # dynamically load choices entries = load( actor='orm/atomicstructures', routine='getSelectorEntriesForPhonons', id=matterid, include_none_entry=1, ) selector.oncreate = select(element=selector).setAttr( entries=entries, value=value) selector.onchange = select(element=plotcontainer).replaceContent( loadplot(select(element=selector).getAttr('value'))) return doc
def set_contextual_help(page='', label=''): actions = [] changepage = select(id='help-page-text').setAttr(value=page) actions.append(changepage) if label: changelabel = select(id='help-portlet-about-context').setAttr(label=label) actions.append(changelabel) return actions
def _createfield_for_sqe(obj): # this is a method of mold. self = drawer.mold # imports import luban.content as lc from luban.content import load, select from luban.content.FormSelectorField import FormSelectorField # utils orm = self.orm # data record = self.orm(obj) referred_record = record.sqe and record.sqe.id \ and record.sqe.dereference(self.orm.db) # widget doc = lc.document(Class='container', id='sqe-selector-container') sp = doc.splitter() left = sp.section(); right = sp.section() # selector = FormSelectorField(label='Sqe:', name='sqe') left.add(selector) # plotcontainer = right.document(Class='container') # loadplot = lambda uid: load( actor='orm/sqe', routine='createGraphicalView', uid=uid) # default selection if referred_record: value=orm.db.getUniqueIdentifierStr(referred_record) plotcontainer.oncreate = select(element=plotcontainer).append( loadplot(value)) else: value=None # choices # get matter matter = orm.db.dereference(record.matter) matterid = matter.id # dynamically load choices entries = load( actor='orm/atomicstructures', routine='getSelectorEntriesForSqe', id = matterid, include_none_entry = 1, ) selector.oncreate = select(element=selector).setAttr(entries=entries, value=value) selector.onchange = select(element=plotcontainer).replaceContent( loadplot(select(element=selector).getAttr('value'))) return doc
def set_contextual_help(page='', label=''): actions = [] changepage = select(id='help-page-text').setAttr(value=page) actions.append(changepage) if label: changelabel = select(id='help-portlet-about-context').setAttr( label=label) actions.append(changelabel) return actions
def _createfield_for_neutrons(obj): # this is a method of mold. self = drawer.mold # imports import luban.content as lc from luban.content import load, select from luban.content.FormSelectorField import FormSelectorField # utils orm = self.orm # data record = self.orm(obj) referred_record = record.neutrons and record.neutrons.id \ and record.neutrons.dereference(self.orm.db) # widget doc = lc.document(Class='container', id='neutrons-selector-container') sp = doc.splitter(orientation='horizontal') left = sp.section(); right = sp.section() # selector = FormSelectorField(label='Neutrons:', name='neutrons') left.add(selector) # viewcontainer = right.document(Class='container') # loadview = lambda uid: load( actor='orm/neutronstorages', routine='createGraphicalView', uid=uid, start=0, end=2) # default selection if referred_record: value=orm.db.getUniqueIdentifierStr(referred_record) viewcontainer.oncreate = select(element=viewcontainer).append( loadview(value)) else: value=None # choices # dynamically load choices entries = load( actor='orm/neutronplayers', routine='getSelectorEntriesForReference', refname = 'neutrons', include_none_entry = 1, ) selector.oncreate = select(element=selector).setAttr(entries=entries, value=value) selector.onchange = select(element=viewcontainer).replaceContent( loadview(select(element=selector).getAttr('value'))) return doc
def treeview(self, actionname, **kwds): if actionname in self.__class__.nontrivial_action_types: factory = eval('TreeView' + actionname[0].upper() + actionname[1:]) return factory(treeview=self, **kwds) # treeview('select', ...) is obsolete if actionname == 'select': warnings.warn( "element.treeview('select', ...) is obsolete, please use element.treeview('selectNode', node=...)", DeprecationWarning) branch = kwds.get('branch') node = kwds.get('node') if branch and node: raise RuntimeError if branch: del kwds['branch'] kwds['node'] = branch actionname = 'selectNode' node = kwds['node'] if isinstance(node, str): warnings.warn( "element.treeview('select', node/branch=<node id>) is obsolete, please use element.treeview('selectNode', node=<node selector>)", DeprecationWarning) from luban.content import select kwds['node'] = select(id=node) return self.treeview(actionname, **kwds) from .SimpleElementAction import SimpleElementAction return SimpleElementAction(self, actionname, **kwds)
def _postProcessing(self, director): # return a document to show user inputs newcontent = luban.content.document(title='form submitted') newcontent.paragraph(text=['your form was submitted']) # all variables names = [ 'boolvar1', 'boolvar2', 'radiovar', 'selectorvar', 'textvar', 'textareavar', 'password', 'floatvar', 'intvar', ] # get values # values of variables can be accessed thru "self.inventory" vals = [getattr(self.inventory, name) for name in names] # "print" name for k, v in zip(names, vals): p = newcontent.paragraph() p.text = '%s: %s' % (k, v) continue # return an action to replace the maindoc with new document return select(id='maindoc').replaceContent(newcontent)
def createAtomicStructureTable( director, domaccess, order_by=None, reverse_order=None, slice=None, filter=None, label=None, mine=False, publiconly = False): records = domaccess.getAtomicStructureRecords( order_by=order_by, reverse_order=reverse_order, slice=slice, filter=filter, label=label, mine=mine, ) cols = columns args = records, cols, director if publiconly: from vnf.content.visuals.table.atomicstructure_public \ import table as createTableVisual else: from vnf.content.visuals.table.atomicstructure \ import table as createTableVisual thetable = createTableVisual( records, cols, director) thetable.oncellchanged = select(element=thetable).notify( event='row-changed', actor='atomicstructure/table', routine='processRowChange') return thetable
def createAtomicStructureTable(director, domaccess, order_by=None, reverse_order=None, slice=None, filter=None, label=None, mine=False, publiconly=False): records = domaccess.getAtomicStructureRecords( order_by=order_by, reverse_order=reverse_order, slice=slice, filter=filter, label=label, mine=mine, ) cols = columns args = records, cols, director if publiconly: from vnf.content.visuals.table.atomicstructure_public \ import table as createTableVisual else: from vnf.content.visuals.table.atomicstructure \ import table as createTableVisual thetable = createTableVisual(records, cols, director) thetable.oncellchanged = select(element=thetable).notify( event='row-changed', actor='atomicstructure/table', routine='processRowChange') return thetable
def _createTabsForDemoPanelAndCodeViewer(self, func, director, deps=None): '''create a "tabs" widget with one tab for demo, another tab for code func: the function that creates a docuemnt for the demo deps: the functions that "func" depends on. we need to show code for all of them to give a complet view. It is good that func and deps are in the same actor. ''' tabs = lc.tabs() demotab = tabs.tab(label='Demo') demotab.Class = 'demo' funcname = func.im_func.func_name demotab.onselect = select(element=demotab).replaceContent( load(actor=self.name, routine=funcname)) codetab = tabs.tab(label='Code') codetab.Class = 'code' demotab.add(func(director)) lines = getSourceLines(func) blocks = [lines] if deps: for dep in deps: blocks.append(getSourceLines(dep)) codedoc = createCodeDoc(blocks) codetab.add(codedoc) # codetab.onselect = select(element=codetab).replaceContent(codedoc) return tabs
def qedialog(title, text, Class="qe-dialog-output"): "Returns the dialog widget" dialog = lc.dialog(title=title, autoopen=True, Class=Class) dialog.add(text) # Text okbutton = lc.button(label='OK', onclick=select(element=dialog).destroy()) dialog.add(okbutton) return dialog
def qedialog(title, text, Class="qe-dialog-output"): "Returns the dialog widget" dialog = lc.dialog(title=title, autoopen=True, Class=Class) dialog.add(text) # Text okbutton = lc.button( label = 'OK', onclick = select(element=dialog).destroy()) dialog.add(okbutton) return dialog
def select_one(id, ids): """ returns actions that mark only one item as 'selected', and remove 'selected' Class from all others. id: id of the item to select ids: ids of all items """ if id not in ids: raise RuntimeError actions = [] for id1 in ids: if id1 != id: action = select(id=id1).removeClass('selected') else: action = select(id=id1).addClass('selected') actions.append(action) continue return actions
def _fileLink(self, filename, content): "Returns file link" assert filename != None # Contruct dialog title = 'Output for %s task. %s bytes' % (self._task.id, os.path.getsize(filename)) text = lc.htmldocument(text="<pre>%s<pre>" % open(filename).read()) dialog = qedialog(title, text) # dialog to pop up return lc.link(label = 'Output', onclick = select(element=content).append(dialog))
def _fileLink(self, filename, content): "Returns file link" assert filename != None # Contruct dialog title = 'Output for %s task. %s bytes' % (self._task.id, os.path.getsize(filename)) text = lc.htmldocument(text="<pre>%s<pre>" % open(filename).read()) dialog = qedialog(title, text) # dialog to pop up return lc.link(label='Output', onclick=select(element=content).append(dialog))
def removeTreeViewNode(self, node): warnings.warn( "element.removeTreeViewNode is obsolete, please use element.treeview('removeNode', node=...)", DeprecationWarning) if isinstance(node, str): warnings.warn( "element.removeTreeViewNode(node=<node id>) is obsolete, please use element.treeview('removeNode', node=<node selector>)", DeprecationWarning) from luban.content import select node = select(id=node) return TreeViewRemoveNode(treeview=self, node=node)
def _actionToRefreshComponentButtonInComponentChain(self, director): # load component component = director.clerk.orm(self._load(director)) # action to refresh the button in the cmponent chain from mcvineui.visuals.componentchain import \ button_id_formatter_for_component, createComponentButtonLabelElement button_id = button_id_formatter_for_component % self.inventory.id newlabel = createComponentButtonLabelElement(component) from luban.content import select return select(id=button_id).replaceContent(newlabel)
def basic_usage1(self, director): lc = luban.content # container document document = lc.document(title='test form', id='maindoc') # form form = document.form(title='test form') # fields checkbox1 = form.checkbox(name='boolvar1', label='check box 1', checked=False, tip='a tip') checkbox2 = form.checkbox(name='boolvar2', label='check box 2', checked=True, tip='a tip') rad = form.radio( id='radiofield', label='radio', name='radiovar', entries=enumerate(['one', 'two', 'three']), selection=1, tip='a tip', ) sel = form.selector(label='selector', name='selectorvar', entries=enumerate(['one', 'two']), selection=0, tip='a tip') textfield = form.text(label='textfield', name='textvar', tip='a tip') textarea = form.textarea(label='textarea', name='textareavar', tip='a tip') pwfield = form.password(label='password', name='password', tip='a tip') # fields with validators floatfield = form.text(label='float variable', name='floatvar') intfield = form.text(label='int variable', name='intvar') # submit button submit = form.submitbutton(label='submit', tip='a tip') # action when form is submitted # Note: The routine "process" is already defined in # base class FormProcessorInterface, # here we just need to override "_postProcessing". form.onsubmit = select(element=form).submit(actor=self.name, routine='process') return document
def _form(obj): self = drawer.mold # a form for the attributes form = lc.form(Class='bvkbond-form') # self._addfieldstoform(form, obj) # # make sure when A, or B, or Boffset changes, reload constraints updateconstraints = select(element=form)\ .find(name='force-constant-matrix-constraints')\ .replaceContent( select(element=form).submit(actor='orm/bvkbonds', routine='getConstraints', id = self.orm(obj).id) ) for fname in ['A', 'B', 'Boffset_0', 'Boffset_1', 'Boffset_2', 'Boffset_is_fractional']: field = form.getDescendentByName(fname) field.onchange = updateconstraints # when constraints document load, update constraints too form.getDescendentByName('force-constant-matrix-constraints').oncreate = updateconstraints return form
def addTreeViewBranch(self, referencenode, newnode, position=None): warnings.warn( "element.addTreeViewBranch is obsolete, please use element.treeview('addBranche', referencenode=..., newnode=..., position=...)", DeprecationWarning) if isinstance(referencenode, str): warnings.warn( "element.addTreeViewBranch(..., referencenode=<reference id>, ...) is obsolete, please use element.treeview('addBranch', referencenode=<reference node selector>, newnode=<new branch instance>, position=<position string>)", DeprecationWarning) from luban.content import select referencenode = select(id=referencenode) return TreeViewAddBranch(self, referencenode, newnode, position=position)
def _checkForms(self, director): actions = [] messages = [] formids = self.inventory.formids actions += [select(id=id).addClass('highlighted') for id in formids] n = len(formids) if n > 1: msg = 'sorry. there are %s forms to submit.' % n else: msg = 'sorry. there is a form to submit.' msg += 'Please look for highlighted sections.' messages.append(msg) if len(actions): actions.append(alert('\n\n'.join(messages))) return actions
def _createSwitcher(self, director): import inspect # find routines that create panels routines = {} for k, v in self.__class__.__dict__.iteritems(): # skip # - private if k.startswith('_'): continue # - non-method if not inspect.ismethod(v) and not inspect.isfunction(v): continue # - signature sig = 'ispanel' if not hasattr(v, sig): continue if not getattr(v, sig): continue routines[k] = v continue # container container = lc.document() tabs = lc.tabs() container.add(tabs) # if hasattr(self.__class__, 'demo_panels'): panels = self.__class__.demo_panels else: panels = routines.iterkeys() for i, k in enumerate(panels): # call method to get inner document method = getattr(self, k) # use inner document's title as tab's label label = method.title # create tab tab = tabs.tab(label=label) # add the first document if i == 0: inner = method(director) tab.add(inner) else: tab.onselect = select(element=tab).replaceContent( load(actor=self.name, routine=k)) continue return container
def _(self, director): # target frame to change body_frame = select(id='body-frame') # new body skeleton body_skeleton = director.retrieveVisual('body-skeleton', context='atomicstructure', director=director) main_display_area = body_skeleton.find(id='main-display-area') # put stuff into the main display area doc = func(self, director) main_display_area.add(doc) # set portlet body_skeleton.find(id='main-portlet-%s' % portlet).selected = 1 # set page title setpagetitle = select(id='').setAttr(title=title) # help window helpwindow = director.redirect( actor='help', routine='createHelpWindow', nextpagetoshow='UserGuide-atomicstructures', include_credential=False) addhelpwindow = select(id='').append(helpwindow) # news ticker newsticker = director.redirect(actor='news', routine='createTicker', include_credential=False) addnewsticker = select(id='header-news-container').append(newsticker) # logout link logout = load(actor='logout') link = lc.link(label='logout', onclick=logout) addlogout = select(id='header-userinfo').append(link) # show dock showdock = select(id='dock').show() # return [ setpagetitle, showdock, body_frame.replaceContent(body_skeleton), addhelpwindow, addnewsticker, addlogout, ]
def _(self, director): # target frame to change body_frame = select(id='body-frame') # new body skeleton body_skeleton = director.retrieveVisual( 'body-skeleton', context='atomicstructure', director=director) main_display_area = body_skeleton.find(id='main-display-area') # put stuff into the main display area doc = func(self, director) main_display_area.add(doc) # set portlet body_skeleton.find(id='main-portlet-%s' % portlet).selected = 1 # set page title setpagetitle = select(id='').setAttr(title=title) # help window helpwindow = director.redirect( actor='help', routine='createHelpWindow', nextpagetoshow = 'UserGuide-atomicstructures', include_credential=False) addhelpwindow = select(id='').append(helpwindow) # news ticker newsticker = director.redirect( actor='news', routine = 'createTicker', include_credential = False) addnewsticker = select(id='header-news-container').append(newsticker) # logout link logout = load(actor='logout') link = lc.link(label='logout', onclick=logout) addlogout = select(id='header-userinfo').append(link) # show dock showdock = select(id='dock').show() # return [ setpagetitle, showdock, body_frame.replaceContent(body_skeleton), addhelpwindow, addnewsticker, addlogout, ]
def serverLink(director, id): "Returns link to server information" server = None link = "None" settings = director.clerk.getQESettings(where="simulationid='%s'" % id) if not settings: # or not settings[0]: return link setting = settings[0] server = director.clerk.getServers(id=setting.serverid) if not server: return link link = lc.link(label=server.address, Class="action-link", tip="Show details of computational cluster", onclick=select(id='').append( load(actor='server/load', routine='createDialog'))) return link
def getLink(self, id): # simulation id server = None link = "None" settings = self._director.clerk.getQESettings(where="simulationid='%s'" % id ) if not settings:# or not settings[0]: return link setting = settings[0] if setting.serverid is not None: server = self._director.clerk.getServers(id = setting.serverid ) if not server: return link link = Link(label = server.address, Class = "action-link", tip = "Show details of computational cluster", onclick = select(id='').append(load(actor='server/load', routine='createDialog')) ) return link
def serverLink(director, id): "Returns link to server information" server = None link = "None" settings = director.clerk.getQESettings(where="simulationid='%s'" % id ) if not settings:# or not settings[0]: return link setting = settings[0] server = director.clerk.getServers(id = setting.serverid ) if not server: return link link = lc.link(label = server.address, Class = "action-link", tip = "Show details of computational cluster", onclick = select(id='').append(load(actor='server/load', routine='createDialog')) ) return link
def setCoresList(self, director): "Sets cores list depending on server selection" procfield = FormSelectorField(name="numproc", entries = self._procOptions(director)) return select(id=ID_SELECTOR_CORES).replaceContent(procfield)
def default(self, director): "Default routine" return select(id='main-display-area').replaceContent(self.content(director))
def create(self): # computation = self.computation actor = self.actor director = self.director on_all_results_retrieved = self.on_all_results_retrieved # utilities domaccess = director.retrieveDOMAccessor('computation') orm = domaccess.orm db = orm.db # id = computation.id type = computation.getTableName() # the job job = computation.getJob(db) # always good to check the job from vnf.utils.job import check check(job, director) # the document to build doc = lc.document(Class='container', id='computation-results-container') # depending on retrieval status, we need to add some extra things to the document result_retrieval_status = computation.getResultRetrievalStatus(db) if result_retrieval_status is None: from vnf.utils.computation import start_results_retrieval start_results_retrieval(computation, director) result_retrieval_status = 'retrieving' refresh = select(element=doc).replaceBy( load(actor='loadvisual', visual='computation-results', id=id, type=type, on_all_results_retrieved = on_all_results_retrieved, ) ) if result_retrieval_status == 'retrieving': p = doc.paragraph(text=['Still retrieving results...']) from vnf.utils.computation import get_results_retrieval_task task = get_results_retrieval_task(computation, db) if not task: raise RuntimeError, 'there should be an itask working at retrieving '+\ 'results for computation %s, but we found none' % computation.id pbar = lc.progressbar( id = 'itask-%s-pbar' % task.id, status = 'Retrieving results...', percentage = 0, skip = 1000, ) pbar.onchecking = load( actor='itask', routine='checkProgress', id = task.id, ) if on_all_results_retrieved: from vnf.content import safe_eval_action onfinished = safe_eval_action(on_all_results_retrieved) else: onfinished = refresh pbar.onfinished = onfinished pbar.oncanceled = refresh doc.add(pbar) elif result_retrieval_status.find('failed') != -1: p = doc.paragraph(text=['failed to retrieve results']) # the action to load this visual (type: string) refresh_action_in_str = 'select(id="computation-results-container").replaceBy(load(actor="loadvisual", visual="computation-results", id="%s", type="%s", on_all_results_retrieved = "%s"))' % (id, type, on_all_results_retrieved or '') # link to restart retrieval l = lc.link( label = 'restart results retrieval', onclick = [ load(actor='computation', routine='restartResultsRetrieval', type = type, id = id, posterior_action = refresh_action_in_str, ) ], ) doc.add(l) elif result_retrieval_status == 'retrieved': pass else: raise NotImplementedError, 'computation: %s, retrieval status: %s' % ( type, result_retrieval_status) # display results results = computation.results.dereference(db) for k, r in results: ## alertdoc = doc.paragraph( ## text=['loading computation result %s %s. please wait...' % ( ## r.getTableName(), r.id)] ## ) title = '%s %s: expand for details' % (r.__class__.__name__, r.id) doc1 = doc.document( id = 'resultdoc-%s' % r.id, Class='container', title=title, collapsable=True, collapsed=True) doc1.onexpand = [ #select(element=alertdoc).hide(), select(element=doc1).replaceBy( load(actor='orm/%s' % r.getTableName(), routine='createGraphicalView', id = r.id) ) ] continue return doc
def default(self, director): # Redirection doesn't pass value to self.id, so I need to do it manually return select(id='main-display-area').replaceContent( self.content(director))
def default(self, director): # Redirection doesn't pass value to self.id, so I need to do it manually return select(id='main-display-area').replaceContent(self.content(director))
def setCoresList(self, director): "Sets cores list depending on server selection" procfield = FormSelectorField(name="numproc", entries=self._procOptions(director)) return select(id=ID_SELECTOR_CORES).replaceContent(procfield)
def visual(director, name, filter_expr=None, filter_key=None, filter_value=None, label=None, mine=False, order_by=None, reverse_order=None, number_records_per_page=None, page_number=None, publiconly=False, actorname=None): """ name: name of table view """ if actorname is None: actorname = name domaccess = director.retrieveDOMAccessor('atomicstructure') from vnf.components.MasterTable import MasterTableFactory, filtercompiler def countrecords(filter, label=None, mine=False): return domaccess.countAtomicStructures(filter, label=label, mine=mine) def createtable(order_by, reverse_order, slice, filter, label=None, mine=False): return createAtomicStructureTable( director, domaccess, order_by=order_by, reverse_order=reverse_order, slice=slice, filter=filter, label=label, mine=mine, publiconly=publiconly, ) from vnf.content.visuals.table.atomicstructure import model compilefilter = filtercompiler(columns, measure2dbcol, model=model) smartlabelaccess = director.retrieveDOMAccessor('smartlabel') def filterfromlabel(label): return smartlabelaccess.createFilterExprFromLabel(label, name) smartlabels = smartlabelaccess.getLabelNames(name) labelaccess = director.retrieveDOMAccessor('label') labels = labelaccess.getLabelNames(name) factory = MasterTableFactory( name, countrecords, createtable, compilefilter, filtercols, filterfromlabel, smartlabels, labels, sorting_options=[ # ('id', 'ID'), ('short_description', 'Description'), ('chemical_formula', 'Chemical formula'), ('date', 'Date created'), ], polymorphic=False, dbtablename='AtomicStructure.Structure', publiconly=publiconly, ) tableview = factory.create(label=label, mine=mine, filter_expr=filter_expr, filter_key=filter_key, filter_value=filter_value, order_by=order_by, reverse_order=reverse_order, number_records_per_page=number_records_per_page, page_number=page_number) if not publiconly: # add new button toolbar = tableview.find(id='%s-table-toptoolbar' % name) # toolbar.add(Paragraph(text='|', Class='splitter')) # button = luban.content.button(label='New', tip='create new atomic structure', icon='new.png') toolbar.add(button) button.onclick = select(id='main-display-area').replaceContent( load(actor=actorname, routine='newAtomicStructureForm')) else: # add upload button toolbar = tableview.find(id='%s-table-toptoolbar' % name) # button = luban.content.button( label='Upload your structure', tip='upload your atomic structure', icon='new.png', Class='big-button', ) toolbar.add(button) # the upload view uploadview = createPublicUploadView(director) button.onclick = select(id='main-display-area')\ .replaceContent(uploadview) return tableview
def onbutton2(self, input=None): p = lc.paragraph(text=['new paragraph']) action = lc.select(id='doc1').append(p) return self.weaver.weave(action)
def getActions(self, document, pathlist): actions = [] actions.append(select(id='path-content').replaceContent(self.path(pathlist))) actions.append(select(id='maindoc').replaceContent(document)) return actions
def visual( director, name, filter_expr=None, filter_key=None, filter_value=None, label=None, mine=False, order_by=None, reverse_order=None, number_records_per_page=None, page_number=None, publiconly = False, actorname = None ): """ name: name of table view """ if actorname is None: actorname = name domaccess = director.retrieveDOMAccessor('atomicstructure') from vnf.components.MasterTable import MasterTableFactory, filtercompiler def countrecords(filter, label=None, mine=False): return domaccess.countAtomicStructures(filter, label=label, mine=mine) def createtable(order_by, reverse_order, slice, filter, label=None, mine=False): return createAtomicStructureTable( director, domaccess, order_by=order_by, reverse_order=reverse_order, slice=slice, filter=filter, label=label, mine=mine, publiconly = publiconly, ) from vnf.content.visuals.table.atomicstructure import model compilefilter = filtercompiler(columns, measure2dbcol, model=model) smartlabelaccess = director.retrieveDOMAccessor('smartlabel') def filterfromlabel(label): return smartlabelaccess.createFilterExprFromLabel( label, name) smartlabels = smartlabelaccess.getLabelNames(name) labelaccess = director.retrieveDOMAccessor('label') labels = labelaccess.getLabelNames(name) factory = MasterTableFactory( name, countrecords, createtable, compilefilter, filtercols, filterfromlabel, smartlabels, labels, sorting_options = [ # ('id', 'ID'), ('short_description', 'Description'), ('chemical_formula', 'Chemical formula'), ('date', 'Date created'), ], polymorphic = False, dbtablename='AtomicStructure.Structure', publiconly = publiconly, ) tableview = factory.create( label = label, mine=mine, filter_expr=filter_expr, filter_key=filter_key, filter_value=filter_value, order_by=order_by, reverse_order=reverse_order, number_records_per_page=number_records_per_page, page_number=page_number) if not publiconly: # add new button toolbar = tableview.find(id='%s-table-toptoolbar' % name) # toolbar.add(Paragraph(text='|', Class='splitter')) # button = luban.content.button( label='New', tip='create new atomic structure', icon='new.png') toolbar.add(button) button.onclick = select(id='main-display-area').replaceContent( load(actor=actorname, routine='newAtomicStructureForm') ) else: # add upload button toolbar = tableview.find(id='%s-table-toptoolbar' % name) # button = luban.content.button( label='Upload your structure', tip='upload your atomic structure', icon='new.png', Class='big-button', ) toolbar.add(button) # the upload view uploadview = createPublicUploadView(director) button.onclick = select(id='main-display-area')\ .replaceContent(uploadview) return tableview
def default(self, director): "Default routine" return select(id='main-display-area').replaceContent( self.content(director))