class OperationElement(Element, ClickHandler): def __init__(self, text, group, groupLabel, block): Element.__init__(self, Element=DOM.createElement('code'), StyleName='group_operation') ClickHandler.__init__(self) self.addClickListener(self) self.text = text self.group = group self.groupLabel = groupLabel self.block = block self.draw() def changeTexts(self): if self.text != '': DOM.setInnerHTML(self.title.getElement(), _(self.text)) def draw(self): self.title = Element(Element=DOM.createSpan(), StyleName='title') DOM.setInnerHTML(self.title.getElement(), self.text) self.add(self.title) self.tip = PopupPanel(Element=DOM.createElement('code'), autoHide=True, modal=False, rootpanel=self) div = Element(Element=DOM.createElement('div'), StyleName='joyride-tip-guide') div.add(Widget(Element=DOM.createSpan(), StyleName='joyride-nub left')) self.tipItens = Element(Element=DOM.createElement('div'), StyleName='tip-itens') div.add(self.tipItens) self.tip.add(div) def onClick(self, sender): if self.tip.showing: self.tip.hide() else: if self.groupLabel is None: self.addValues(self.group) else: self.addValues(self.groupLabel) self.tip.show() def addValues(self, values): self.tipItens.removeAll() if len(values)==2: self.tip.getWidget().addStyleName('two_itens') else: self.tip.getWidget().removeStyleName('two_itens') if len(values)==3: self.tip.getWidget().addStyleName('tree_itens') else: self.tip.getWidget().removeStyleName('tree_itens') for value in values.keys(): self.tipItens.append(MenuItenListener(self.itemClick, value, StyleName='tip-item')) def itemClick(self, value): if self.block.original: return oldValue = self.block.name if self.groupLabel is None: DOM.setInnerHTML(self.title.getElement(), _(value)) self.block.name = self.group[value] else: DOM.setInnerHTML(self.title.getElement(), _(self.groupLabel[value])) self.block.name = self.group[self.groupLabel[value]] if oldValue != value: from edu.uca.util.Serializable import stateChange stateChange()
def draw(self): DOM.setAttribute(self.getElement(), 'border', 0) DOM.setAttribute(self.getElement(), 'cellPadding', 0) DOM.setAttribute(self.getElement(), 'cellSpacing', 0) body = Element(Element=DOM.createTBody()) self.row = Element(Element=DOM.createTR(), StyleName='code_row') body.append(self.row) self.append(body)
def drawComponentBlock(s): s.addStyleName('hardware_block block simple_hardware_block') table = Element(Element=DOM.createTable()) body = Element(Element=DOM.createTBody()) row = Element(Element=DOM.createTR(), StyleName='simple_hardware_row') td = Element(Element=DOM.createTD(), StyleName='simple_hardware_icon ' + s.name) row.append(td) s.td = Element(Element=DOM.createTD(), StyleName='simple_hardware_name') DOM.setInnerHTML(s.td.getElement(), s.text) row.append(s.td) body.append(row) table.append(body) s.append(table) tableArguments = Element(Element=DOM.createTable(), StyleName='simple_hardware_pins') s.bodyArguments = Element(Element=DOM.createTBody()) tableArguments.append(s.bodyArguments) s.append(tableArguments)
def __init__(self): HorizontalPanel.__init__(self, StyleName="type_block select_block") self.add(Label(_('Type') + ':')) fake = Element(Element=DOM.createDiv()) self.color = 'grey' self.commandBlock = getattr(ArduinoBlocks, 'commandType')('comando', 'grey', off=True) fake.append(self.commandBlock) self.commandType = RadioButton("groupType", fake.getElement().innerHTML, True) self.commandType.setChecked(True) self.commandType.addClickListener(getattr(self, "onClickCommandType")) self.add(self.commandType) fake.removeAll() self.booleanBlock = getattr(ArduinoBlocks, 'logicType')('logico', 'grey', off=True) fake.append(self.booleanBlock) self.logicType = RadioButton("groupType", fake.getElement().innerHTML, True) self.logicType.addClickListener(getattr(self, "onClickLogicType")) self.add(self.logicType) fake.removeAll() self.numberBlock = getattr(ArduinoBlocks, 'numericType')('numerico', 'grey', off=True) fake.append(self.numberBlock) self.numericType = RadioButton("groupType", fake.getElement().innerHTML, True) self.numericType.addClickListener(getattr(self, "onClickNumericType")) self.add(self.numericType) fake.removeAll() self.stringBlock = getattr(ArduinoBlocks, 'alphaNumericType')('alfanumerico', 'grey', off=True) fake.append(self.stringBlock) self.alphaNumericType = RadioButton("groupType", fake.getElement().innerHTML, True) self.alphaNumericType.addClickListener( getattr(self, "onClickAlphanumericType")) self.add(self.alphaNumericType) self.onClickCommandType()
def onLoad(self): self.tabs = TabPanel(FlowTabBar()) self.tabs.getTabBar().addStyleName('shortcuts') self.tabs.getDeckPanel().addStyleName('blockDrawer') #------------------------------------------------------------------------------------------ self.input = CategoriesHardware.Input() self.tabs.add(self.input, CategoriesHardware.TabTitle(_('Input'), 'input_btn')) #------------------------------------------------------------------------------------------ self.output = CategoriesHardware.Output() self.tabs.add(self.output, CategoriesHardware.TabTitle(_('Output'), 'output_btn')) #------------------------------------------------------------------------------------------ self.tabs.selectTab(0) panel = Element(Element=DOM.createDiv(), Width='100%', Height='100%') panel.append(self.tabs) #------------------------------------------------------------------------------------------ self.trashCan = Widget(Element=DOM.createDiv(), StyleName='trashCanClose') panel.append(self.trashCan) self.add(panel) #------------------------------------------------------------------------------------------ bottom = Element(Element=DOM.createDiv(), StyleName='drawer_bottom') resize = ResizeWidget(self.parent, 200, 600) resize.addStyleName('float_right') bottom.append(resize) self.add(bottom) self.setCellHeight(bottom, '20px')
class GroupElement(Element): def __init__(self): Element.__init__(self, Element=DOM.createTable(), StyleName='line_table') self.draw() self.subElements = [] def draw(self): DOM.setAttribute(self.getElement(), 'border', 0) DOM.setAttribute(self.getElement(), 'cellPadding', 0) DOM.setAttribute(self.getElement(), 'cellSpacing', 0) body = Element(Element=DOM.createTBody()) self.row = Element(Element=DOM.createTR(), StyleName='code_row') body.append(self.row) self.append(body) def drawSubElement(self, element): td = Element(Element=DOM.createTD()) td.append(element) self.row.append(td) self.subElements.append(element)
def addArgument(s, arg): mode = 'input' if s.mode == INPUT else 'output' row = Element(Element=DOM.createTR(), StyleName='simple_hardware_pin') td = Element(Element=DOM.createTD(), StyleName='simple_hardware_pin_left') row.append(td) td = Element(Element=DOM.createTD(), StyleName='simple_hardware_pin_label simple_' + mode + '_pin') DOM.setInnerText(td.getElement(), arg.label) row.append(td) td = Element(Element=DOM.createTD(), StyleName='dropdown_holder simple_' + mode + '_pin') td.add(arg) row.append(td) s.bodyArguments.append(row)
def onLoad(self): self.tabs = TabPanel(FlowTabBar()) # self.tabs.getTabBar().addStyleName('shortcuts') === gwt-TabBar # self.tabs.getDeckPanel().addStyleName('blockDrawer') === gwt-TabPanelBottom{ #------------------------------------------------------------------------------------------ self.control = CategoriesBlock.Control() self.tabs.add(self.control, CategoriesBlock.TabTitle(_('Control'), 'control_btn')) #------------------------------------------------------------------------------------------ self.operators = CategoriesBlock.Operators() self.tabs.add( self.operators, CategoriesBlock.TabTitle(_('Operators'), 'operators_btn')) #------------------------------------------------------------------------------------------ self.input = CategoriesBlock.Input() self.tabs.add(self.input, CategoriesBlock.TabTitle(_('Input'), 'input_btn')) #------------------------------------------------------------------------------------------ self.output = CategoriesBlock.Output() self.tabs.add(self.output, CategoriesBlock.TabTitle(_('Output'), 'output_btn')) #------------------------------------------------------------------------------------------ self.utilities = CategoriesBlock.Setup() self.tabs.add(self.utilities, CategoriesBlock.TabTitle(_('Utilities'), 'config_btn')) #------------------------------------------------------------------------------------------ self.variables = CategoriesBlock.Variables() self.tabs.add( self.variables, CategoriesBlock.TabTitle(_('Variables'), 'variables_btn')) #------------------------------------------------------------------------------------------ self.tabs.selectTab(0) panel = Element(Element=DOM.createDiv(), Width='100%', Height='100%') panel.append(self.tabs) #------------------------------------------------------------------------------------------ self.trashCan = Widget(Element=DOM.createDiv(), StyleName='trashCanClose') panel.append(self.trashCan) self.add(panel) #------------------------------------------------------------------------------------------ bottom = Element(Element=DOM.createDiv(), StyleName='drawer_bottom') resize = ResizeWidget(self.parent, 200, 510) resize.addStyleName('float_right') bottom.append(resize) self.add(bottom) self.setCellHeight(bottom, '20px')
def drawCompoundStatementBlock(s, color='orange', hasBn=True, loop=False): s.bn.addStyleName('i') s.bl.addStyleName('i') c = Element(Element=DOM.createDiv(), StyleName='c ' + color) bi = Widget(Element=DOM.createDiv(), StyleName='bi') ti = Widget(Element=DOM.createDiv(), StyleName='ti') s.code = Element(Element=DOM.createDiv(), StyleName='codeBlockContents ' + color) s.block = StatementElement(color, hasBn) s.block.addStyleName('codeBlockEnd') c.append(ti) c.append(s.code) s.block.append(bi) if loop: s.block.append(Widget(Element=DOM.createDiv(), StyleName='loop')) c.append(s.block) s.bl.append(c)
def enableRadioButton(self, radio, block, enable): fake = Element(Element=DOM.createDiv()) if enable: block.removeStyleName('disabled') else: block.addStyleName('disabled') fake.append(block) radio.setHTML(fake.getElement().innerHTML)
def onLoad(self): self.add(self.header) self.setCellHeight(self.header, '38px') self.left.add(self.blockList) self.left.add(self.hardwareList) self.mainPanel = HorizontalPanel(Width='100%', Height='100%') self.mainPanel.add(self.left) self.mainPanel.setCellWidth(self.left, '250') self.middle.add(self.blocksPad) self.middle.add(self.hardwaresPad) self.center = VerticalPanel(Width='100%', Height='100%', StyleName="center_panel") self.center.add(self.middle) #--------------------------------------------------------------------------------------------------------- bottom = Element(Element=DOM.createDiv(), StyleName='drawer_bottom') self.showHideLeft = FocusWidget(Element=DOM.createDiv(), StyleName='control_bar close_left') self.showHideLeft.addClickListener(self.showHidePanelLeft) self.showHideLeft.setStyleAttribute('float', 'lef') bottom.add(self.showHideLeft) self.showHideRight = FocusWidget(Element=DOM.createDiv(), StyleName='control_bar') self.showHideRight.addClickListener(self.showHidePanelRight) bottom.add(self.showHideRight) self.showHideMonitor = FocusWidget(Element=DOM.createDiv(), StyleName='control_bar') self.showHideMonitor.addClickListener(self.showHidePanelMonitor) bottom.add(self.showHideMonitor) self.resizeMonitor = ResizeWidget(self.serialMonitor, 100, 400, invert=True, horizontal=False) DOM.setStyleAttribute(self.resizeMonitor.getElement(), "display", "none") bottom.add(self.resizeMonitor) self.center.add(bottom) self.center.setCellHeight(bottom, '20px') usbFlash = FocusWidget(Element=DOM.createDiv()) usbFlash.setID('cb_cf') DOM.setElemAttribute(usbFlash.getElement(), 'data-sections', 'usbflash serialmonitor') self.serialMonitor.add(usbFlash) progress = Element(Element=DOM.createDiv(), StyleName='progress progress-striped active') progress.setID('progress') DOM.setStyleAttribute(progress.getElement(), "display", "none") progress_val = Element(Element=DOM.createDiv(), StyleName='bar') progress_val.setID('progress_val') progress.add(progress_val) self.serialMonitor.add(progress) monitor = Element(Element=DOM.createDiv()) monitor.setID('monitor') self.serialMonitor.add(monitor) self.center.add(self.serialMonitor) self.center.setCellHeight(self.serialMonitor, '100') self.showHidePanelMonitor() #--------------------------------------------------------------------------------------------------------- self.mainPanel.add(self.center) #--------------------------------------------------------------------------------------------------------- self.cod = VerticalPanel(Width='100%', Height='100%', StyleName="right_panel") divCode = Element(Element=DOM.createDiv(), Width='100%', Height='100%', StyleName="download-button-container") divCode.add(self.codeTextArea) divButtonDownload = FocusWidget(Element=DOM.createDiv(), StyleName="download-button") #divButtonDownload.addClickListener(listener=lambda:exportWiringCode(self.codeTextArea.getText())) divButtonDownload.addClickListener(listener=lambda: exportWiringCode()) DOM.setInnerText(divButtonDownload.getElement(), 'download') divCode.add(divButtonDownload) self.cod.add(divCode) bot = Element(Element=DOM.createDiv(), StyleName='drawer_bottom') res = ResizeWidget(self.cod, 100, 500, invert=True) res.setStyleAttribute('float', 'left') bot.append(res) self.cod.add(bot) self.cod.setCellHeight(bot, '20px') self.mainPanel.add(self.cod) self.mainPanel.setCellWidth(self.cod, '200') self.showHidePanelRight() self.header.buttonBlocks.addClickListener(self.showBlocksList) self.header.buttonHarwares.addClickListener(self.showHardwaresList) self.header.buttonTranslate.addClickListener(self.showPanelRight) #self.header.buttonReload.addClickListener(self.hidePanelRight) #--------------------------------------------------------------------------------------------------------- self.add(self.mainPanel) stateChange() self.changeLanguage('pt_BR')
def drawSubElement(self, element): td = Element(Element=DOM.createTD()) td.append(element) self.row.append(td) self.subElements.append(element)
class Dropdown(Element, ClickHandler, MouseHandler): def __init__(self, text, menuClick, itemClick, classIcon="", rootPanel=None, **kw): Element.__init__(self, Element=DOM.createElement('li'), **kw) ClickHandler.__init__(self) MouseHandler.__init__(self) self.text = text self.itemClick = itemClick self.menuClick = menuClick self.addClickListener(self) self.classIcon = classIcon self.rootPanel = rootPanel self.draw() def onClick(self, sender): if self.popup.showing: self.popup.hide() else: if self.menuClick is not None: self.menuClick() self.popup.show() def draw(self): if self.classIcon != "": self.icon = Element(Element=DOM.createElement("i"), StyleName=self.classIcon) self.add(self.icon) if self.rootPanel is None: self.popup = PopupPanel(autoHide=True, modal=False, rootpanel=self, StyleName='dropdown_btn') DOM.setStyleAttribute(self.popup.element, "position", "static") else: #o poup nao esta fechando! self.popup = PopupPanel(autoHide=True, modal=False, rootpanel=self.rootPanel, StyleName='dropdown_btn') self.dropdown_arrow = Element(Element=DOM.createElement('div'), StyleName='dropdown_arrow') self.title = Element(Element=DOM.createSpan(), StyleName='title') DOM.setInnerHTML(self.title.getElement(), self.text) self.add(self.title) self.add(Widget(Element=DOM.createDiv(), StyleName='r')) self.add(Widget(Element=DOM.createDiv(), StyleName='coverup')) self.popup.add(self.dropdown_arrow) def changeIcon(self, classIcon): DOM.setAttribute(self.icon.getElement(), "className", classIcon) def setText(self): DOM.setInnerHTML(self.title.getElement(), self.text) def changeTexts(self): for iten in self.dropdown_arrow.children: iten.changeTexts() def ItenClick(self, value): self.itemClick(value) def getValues(self): return self.dropdown_arrow.children def addValues(self, values): self.removeValues() for value in values: self.addValue(value) def addValue(self, value, classIcon=''): if classIcon == '': self.dropdown_arrow.append( MenuItenListener(self.ItenClick, value, StyleName='dropdownItem')) else: self.dropdown_arrow.append( MenuItenListenerIcon(self.ItenClick, value, classIcon, StyleName='dropdownItem')) def removeValues(self): self.dropdown_arrow.removeAll()
def __init__(self, categoryChangeListener): HorizontalPanel.__init__(self, StyleName="category_block select_block", Width='100%') self.categoryChangeListener = categoryChangeListener self.add(Label('Categoria:')) verticalPanel = VerticalPanel(Width='100%') self.add(verticalPanel) horizontalPanel = HorizontalPanel(Width='100%') verticalPanel.add(horizontalPanel) fake = Element(Element=DOM.createDiv()) self.control = getattr(ArduinoBlocks, 'alphaNumericType')('Controle', 'orange', off=True) fake.append(self.control) self.controlType = RadioButton("groupCategory", fake.getElement().innerHTML, True) self.controlType.setChecked(True) self.controlType.addClickListener(getattr(self, "onClickControlType")) horizontalPanel.add(self.controlType) fake.removeAll() self.operators = getattr(ArduinoBlocks, 'alphaNumericType')('Operadores', 'green', off=True) fake.append(self.operators) self.operatorsType = RadioButton("groupCategory", fake.getElement().innerHTML, True) self.operatorsType.addClickListener( getattr(self, "onClickOperatorsType")) horizontalPanel.add(self.operatorsType) horizontalPanel = HorizontalPanel(Width='100%') verticalPanel.add(horizontalPanel) fake.removeAll() self.input = getattr(ArduinoBlocks, 'alphaNumericType')('Entrada', 'purple', off=True) fake.append(self.input) self.inputType = RadioButton("groupCategory", fake.getElement().innerHTML, True) self.inputType.addClickListener(getattr(self, "onClickInputType")) horizontalPanel.add(self.inputType) fake.removeAll() self.output = getattr(ArduinoBlocks, 'alphaNumericType')('Saida', 'blue', off=True) fake.append(self.output) self.outputType = RadioButton("groupCategory", fake.getElement().innerHTML, True) self.outputType.addClickListener(getattr(self, "onClickOutputType")) horizontalPanel.add(self.outputType) horizontalPanel = HorizontalPanel(Width='100%') verticalPanel.add(horizontalPanel) fake.removeAll() self.utilities = getattr(ArduinoBlocks, 'alphaNumericType')('Utilitarios', 'darkblue', off=True) fake.append(self.utilities) self.utilitiesType = RadioButton("groupCategory", fake.getElement().innerHTML, True) self.utilitiesType.addClickListener( getattr(self, "onClickUtilitiesType")) horizontalPanel.add(self.utilitiesType) fake.removeAll() self.variables = getattr(ArduinoBlocks, 'alphaNumericType')('Variaveis', 'red', off=True) fake.append(self.variables) self.variablesType = RadioButton("groupCategory", fake.getElement().innerHTML, True) self.variablesType.addClickListener( getattr(self, "onClickVariablesType")) horizontalPanel.add(self.variablesType) self.onClickControlType()