예제 #1
0
 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')
예제 #2
0
    def draw(self):
        Popup.draw(self)

        namePanel = HorizontalPanel()
        namePanel.add(Label(_('Name') + ':'))
        self.textBox = TextBox()
        self.textBox.setMaxLength(15)
        self.textBox.setStyleAttribute('marginLeft', 10)
        namePanel.add(self.textBox)
        self.center.add(namePanel)

        self.choose = ChooseTypeVarPanel()
        self.center.add(self.choose)

        self.textBox.addInputListener(self)

        self.message = Element(Element=DOM.createDiv())
        self.message.add(Widget(Element=DOM.createDiv(),
                                StyleName='not_image'))
        self.message.add(
            Label(text=_('Name already used'),
                  wordWrap=False,
                  StyleName='not_message'))

        self.onInput()
예제 #3
0
class MenuItenListenerIcon(Element, ClickHandler):
    def __init__(self, feedBack, value, classIcon, **kw):
        Element.__init__(self, Element=DOM.createElement('li'), **kw)
        ClickHandler.__init__(self)
        self.classIcon = classIcon
        self.value = value

        self.icon = Element(Element=DOM.createElement("i"),
                            StyleName=classIcon)
        self.add(self.icon)
        self.title = Element(Element=DOM.createSpan(), StyleName='title')

        DOM.setInnerHTML(self.title.getElement(), self.value)
        self.add(self.title)

        self.addClickListener(self)
        self.feedBack = feedBack

    def getClassIcon(self):
        return self.classIcon

    def setClassIcon(self, classIcon):
        self.classIcon = classIcon
        self.icon.setStyleName(self.classIcon)

    def changeTexts(self):
        DOM.setInnerHTML(self.title.getElement(), _(self.value))

    def onClick(self, sender):  #add selected
        self.feedBack(self.classIcon)
예제 #4
0
class Button(Element, ClickHandler, MouseHandler):

    def __init__(self, text, listener, classIcon=""):
        Element.__init__(self, Element=DOM.createElement('li'), StyleName='btn')
        ClickHandler.__init__(self)
        MouseHandler.__init__(self)
        self.text = text
        self.classIcon = classIcon
        self.draw()
        if listener is not None: self.addClickListener(listener)
        
    def draw(self):
        if self.classIcon != "":
            self.icon = Element(Element=DOM.createElement("i"), StyleName=self.classIcon)
            self.add(self.icon)
        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'))
        
    def setText(self, text):
        self.text = text
        DOM.setInnerHTML(self.title.getElement(), self.text)
        
    def changeIcon(self, classIcon):
        self.classIcon = classIcon
        DOM.setAttribute(self.icon.getElement(), "className", classIcon)
 def __init__(self, color='blue', hasBn=True):
     self.color = color
     Element.__init__(self, Element=DOM.createDiv(), StyleName=self.color)
     drawStatementBlock(self, color, hasBn)
     self.ge = GroupElement()
     self.append(self.ge)
     self.holderArguments = []
예제 #6
0
 def __init__(self,
              subCategoryName='',
              subCategoryClassName='',
              openList=True):
     self.list = VerticalPanel(StyleName='block_list')
     self.list.setStyleAttribute("display", "block")
     VerticalPanel.__init__(self, StyleName='SubCategoryPanel')
     self.subCategoryName = subCategoryName
     if subCategoryName != '':
         self.title = Element(Element=DOM.createElement('dt'),
                              StyleName=subCategoryClassName)
         DOM.setInnerHTML(self.title.getElement(), self.subCategoryName)
         self.collapse = FocusWidget(Element=DOM.createDiv(),
                                     StyleName='collapse close_up')
         self.collapse.addClickListener(self.showHide)
         self.title.add(self.collapse)
         self.add(self.title)
         if openList:
             self.list.setStyleAttribute("display", "block")
             self.collapse.setStyleName('collapse close_up')
         else:
             self.list.setStyleAttribute("display", "none")
             self.collapse.setStyleName('collapse open_down')
     self.add(self.list)
     self.blocks = []
     self.count = 0
예제 #7
0
 def draw(self):
     if self.classIcon != "":
         self.icon = Element(Element=DOM.createElement("i"), StyleName=self.classIcon)
         self.add(self.icon)
     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'))
예제 #8
0
 def __init__(self, text, listener, classIcon=""):
     Element.__init__(self, Element=DOM.createElement('li'), StyleName='btn')
     ClickHandler.__init__(self)
     MouseHandler.__init__(self)
     self.text = text
     self.classIcon = classIcon
     self.draw()
     if listener is not None: self.addClickListener(listener)
예제 #9
0
 def remove(self, widget):  #renomear para removeSubBlock
     #print 'BlockHolder: remove'
     if self.subBlock != widget: return
     Element.remove(self, widget)
     self.subBlock.parentBlock = None
     self.subBlock = None
     if widget.holderSiblingUp:
         widget.holderSiblingUp.argument.enable = True
예제 #10
0
 def __init__(self, name, color):
     Element.__init__(self, Element=DOM.createDiv())
     self.addStyleName('block')
     self.holderArguments = []
     self.ge = GroupElement()
     self.varName = name
     self.color = color
     self.dropDownVarName = None
예제 #11
0
    def __init__(self, feedBack, value, **kw):
        Element.__init__(self, Element=DOM.createElement('li'), **kw)
        ClickHandler.__init__(self)
        self.value = value

        DOM.setInnerHTML(self.getElement(), _(value).replace(' ', ' '))

        self.addClickListener(self)
        self.feedBack = feedBack
예제 #12
0
 def __init__(self):
     Element.__init__(self,
                      Element=DOM.createDiv(),
                      StyleName='drophere2',
                      Width="100%",
                      Height="100%")
     DropWidget.__init__(self)
     DragContainer.__init__(self)
     self.setID('hardwares_pad')
예제 #13
0
 def __init__(self, accepts, **kw):
     Element.__init__(self, Element=DOM.createDiv(), **kw)
     DropHandler.__init__(self)
     DragContainer.__init__(self)
     self.addDropListener(self)
     self.accepts = accepts
     self.addStyleName('argument')
     self.enable = True
     self.block = None
 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()
예제 #15
0
 def __init__(self, arg, block, up=False):
     Element.__init__(self, Element=DOM.createDiv(), StyleName='holder')
     self.block = block
     self.up = up  #nao faz sentido aqui, passar para o argumento
     self.subBlock = None
     self.argument = arg
     self.append(self.argument)
     self.argument.addDropListener(self)
     self.argument.block = block
 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)
예제 #17
0
 def __init__(self, popupEditorBlock=False):
     Element.__init__(self,
                      Element=DOM.createDiv(),
                      StyleName='drophere2',
                      Width="100%",
                      Height="100%")
     DropWidget.__init__(self)
     DragContainer.__init__(self)
     self.setID('blocks_pad')
     self.popupEditorBlock = popupEditorBlock  # dado um determinado pad, saber qual � seu popup
예제 #18
0
class PopupNewVar(Popup):
    def __init__(self, okClick, cancelClick):
        Popup.__init__(self, '<b>Nova Vari&aacute;vel</b>', okClick,
                       cancelClick, CONFIRM_CANCEL)

    def draw(self):
        Popup.draw(self)

        namePanel = HorizontalPanel()
        namePanel.add(Label(_('Name') + ':'))
        self.textBox = TextBox()
        self.textBox.setMaxLength(15)
        self.textBox.setStyleAttribute('marginLeft', 10)
        namePanel.add(self.textBox)
        self.center.add(namePanel)

        self.choose = ChooseTypeVarPanel()
        self.center.add(self.choose)

        self.textBox.addInputListener(self)

        self.message = Element(Element=DOM.createDiv())
        self.message.add(Widget(Element=DOM.createDiv(),
                                StyleName='not_image'))
        self.message.add(
            Label(text=_('Name already used'),
                  wordWrap=False,
                  StyleName='not_message'))

        self.onInput()

    def onInput(self, sender):
        if self.textBox.getText().count(' ') == len(self.textBox.getText()):
            self.okButton.addStyleName('disabled')
            self.south.remove(self.message)
        elif self.textBox.getText() in vars or self.textBox.getText(
        ) in createdBlocks:
            self.okButton.addStyleName('disabled')
            self.south.add(self.message)
        else:
            self.okButton.removeStyleName('disabled')
            self.south.remove(self.message)

    def myOkClick(self):
        if 'disabled' not in self.okButton.getStyleName():
            Popup.myOkClick(self)
            self.okClick(self.textBox.getText(), self.choose.selectedType)

    def myCancelClick(self):
        Popup.myCancelClick(self)
        if self.cancelClick is not None: self.cancelClick()

    def show(self):
        Popup.show(self)
        self.textBox.setFocus(True)
예제 #19
0
 def __init__(self, name, text, mode, listBlockName=[], original=True):
     Element.__init__(self, Element=DOM.createDiv())
     DragWidget.__init__(self)
     self.original = original
     self.name = name
     self.text = text
     self.mode = mode
     self.listBlockName = listBlockName
     self.number = None
     drawComponentBlock(self)
     self.argumentList = []
예제 #20
0
 def addBlock(self, block, left, top, original):
     if original:
         block.original = False
         getWorkspace().addBlock(block)
         if isinstance(block, MainBlock):
             getWorkspace().setMainBlock(block)
             getWorkspace().getBlockList().hideMainBlock(
             )  # passar para dentro do setMainBlock
     else:
         block.removeFromParent()
     block.setStyleAttribute({'left': left, 'top': top})
     block.blockPad = self
     Element.add(self, block)
예제 #21
0
    def __init__(self, ws):

        VerticalPanel.__init__(self, Width='100%', Height='100%')

        self.codeTextArea = Element(Element=DOM.createDiv(),
                                    StyleName='codePanel')
        self.codeTextArea.setID('clip_text')
        #self.codeTextArea.setReadonly(True)
        #self.codeTextArea.addClickListener(listener=lambda:self.codeTextArea.selectAll())
        ws.setCodePanel(self.codeTextArea)

        self.header = Header(self.changeLanguage)
        getWorkspace().setHeaderPanel(self.header)

        self.blockList = BlockList()
        self.hardwareList = HardwareList()
        self.hardwareList.addStyleName('invisible')
        self.left = Element(Element=DOM.createDiv(),
                            Width='100%',
                            Height='100%')
        ws.setBlockList(self.blockList)
        ws.setHardwaresList(self.hardwareList)

        self.serialMonitor = Element(Element=DOM.createDiv(),
                                     StyleName='serialMonitor')

        self.blocksPad = BlocksPad()
        self.hardwaresPad = HardwaresPad()
        self.hardwaresPad.addStyleName('invisible')
        self.middle = Element(Element=DOM.createDiv(),
                              Width='100%',
                              Height='100%')
        ws.setBlocksPad(self.blocksPad)
        ws.setHardwaresPad(self.hardwaresPad)
예제 #22
0
def drawDropdownStringArgument(s, v, b, i):
    s.dropdown = Element(Element=DOM.createDiv(), StyleName='dropdown')
    for value in v:
        s.dropdown.append(MenuItenListener(i, value, StyleName='dropdownItem'))
    s.btn = MenuButtonListener(b, StyleName='dropdown_btn')
    s.btn.append(s.dropdown)
    s.append(s.btn)
예제 #23
0
 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()
예제 #24
0
 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')
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()
            
예제 #26
0
 def draw(self):
     self.setHTML(self.title)
     panelSouth = VerticalPanel(StyleName='dialog_south')
     self.south = Element(Element=DOM.createDiv(), Width='100%')     
     
     if (self.options == CONFIRM_CANCEL):
         cancel = Button(_('Cancel'), self.myCancelClick, classIcon="icon-cancel")
         cancel.addStyleName('float_right')
         self.south.add(cancel)
          
     self.okButton = Button(_('Confirm'), self.myOkClick, classIcon="icon-ok")
     self.okButton.addStyleName('float_right')
     self.south.add(self.okButton)
     
     panelSouth.add(self.south)
     panelSouth.setCellHorizontalAlignment(self.south, HasHorizontalAlignment.ALIGN_RIGHT)
     
     widget = VerticalPanel(Width='100%')
     widget.add(self.center)
     widget.add(panelSouth)
     self.setWidget(widget)
예제 #27
0
    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 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)
예제 #29
0
def drawStatementBlock(s, c, hasBn=True):
    s.addStyleName('statement ' + c)

    s.t = Widget(Element=DOM.createDiv(), StyleName='t')
    l = Widget(Element=DOM.createDiv(), StyleName='l')
    r = Widget(Element=DOM.createDiv(), StyleName='r')
    s.tl = Element(Element=DOM.createDiv(), StyleName='tl')
    s.tr = Widget(Element=DOM.createDiv(), StyleName='tr')  #provisorio pra hat
    b = Widget(Element=DOM.createDiv(), StyleName='b')
    br = Widget(Element=DOM.createDiv(), StyleName='br')
    s.bl = Element(Element=DOM.createDiv(), StyleName='bl')

    s.append(s.t)
    s.append(l)
    s.append(r)
    s.append(s.tl)
    s.append(s.tr)
    s.append(b)
    s.append(br)
    if hasBn:
        s.bn = Widget(Element=DOM.createDiv(), StyleName='bn')
        s.append(s.bn)
    s.append(s.bl)
예제 #30
0
 def __init__(self, name, blockType, original=True, **kw):
     Element.__init__(self, Element=DOM.createDiv(), **kw)
     DragWidget.__init__(self)
     ClickHandler.__init__(self)
     MouseHandler.__init__(self)
     self.blockType = blockType
     self.addStyleName('block')
     self.ge = GroupElement()
     self.addDoubleClickListener(self)
     self.addMouseListener(self)
     self.holderArguments = []
     self.holderSiblingUp = None
     self.holderSiblingDown = None
     self.holderChildren = []
     self.isStartingDrag = False
     self.original = original  # identifica se o bloco sera copiado ou movido quando arrastado
     self.name = name  # nome do metodo que criou o bloco
     self.varName = ''  #nome da variavel OU #nome do bloco
     self.componetHardware = None  # nome do harware correspondente, p tratamento de erro
     self.dropDownVarName = None  # combobox para escolher a var ou o comp
     self.color = None
     self.blockPad = None
     self.custom = False  # indica se o bloco eh um bloco personalizado
     self.buttonRightDown = None