コード例 #1
0
 def RemoveCustomBlock(self, sender):
     self.list.remove(sender.block.getParent())
     self.blocks.remove(sender.block)
     if len(self.blocks) == 0:
         self.getParent().reload()
     del createdBlocks[sender.block.varName]
     stateChange()
コード例 #2
0
 def onDrop(self, event):
     #print "BlockHolder: onDrop"
     DOM.eventStopPropagation(
         event)  # nao deixar ir para o onDrop de BlocksPad
     if self.subBlock == getWorkspace().getMovingBlock():
         return  # retirou e colocou o mesmo bloco
     #---------------------------------------------------
     if getWorkspace().getMovingBlock().original:
         getWorkspace().setMovingBlock(getWorkspace().cloneBlock(
             getWorkspace().getMovingBlock()))
         #undo = (getWorkspace().getBlockList().removeBlocks, [getWorkspace().getMovingBlock()])
     #else: undo = getWorkspace().getUndo()
     #---------------------------------------------------
     if self.up:  #self.argument.statementArgumentType == UP_ARG
         #undo = (self.removeUpperBlock, [undo, self.block.getStyleAttribute('left'), self.block.getStyleAttribute('top'), getWorkspace().getMovingBlock().original])
         #do = (self.addUpperBlock, [getWorkspace().getMovingBlock(), getWorkspace().getMovingBlock().original, event])
         self.addUpperBlock(getWorkspace().getMovingBlock(),
                            getWorkspace().getMovingBlock().original,
                            event)  #
     else:
         #do = (self.addSubBlock, [getWorkspace().getMovingBlock(), getWorkspace().getMovingBlock().original])
         self.addSubBlock(getWorkspace().getMovingBlock(),
                          getWorkspace().getMovingBlock().original)  #
     #---------------------------------------------------
     #history.add(do, undo)
     from edu.uca.util.Serializable import stateChange
     stateChange()
コード例 #3
0
    def onDrop(self, event):
        #print "Right: onDrop"

        if getWorkspace().getMovingBlock() is None:

            ####################################################################################
            import json
            from edu.uca.util.Serializable import loadStackBlock, stateChange
            stackBlock = loadStackBlock(
                json.loads(event.dataTransfer.getData('text'))['stackBlock'])
            stackBlock.changeTexts()
            self.addBlock(stackBlock, getDropPosition(self, event), True)
            stateChange()
            ####################################################################################

            return

        #soundOut.play()
        if getWorkspace().getMovingBlock().original:
            self.removeStyleName('dragover2')
            getWorkspace().setMovingBlock(getWorkspace().cloneBlock(
                getWorkspace().getMovingBlock()))
            #undo = (getWorkspace().getBlockList().removeBlocks, [getWorkspace().getMovingBlock()])
        #else: undo = getWorkspace().getUndo()
        left, top = getDropPosition(self, event)
        #history.add((self.addBlock, [getWorkspace().getMovingBlock(), left, top, getWorkspace().getMovingBlock().original]), undo)
        self.addBlock(getWorkspace().getMovingBlock(), left, top,
                      getWorkspace().getMovingBlock().original)
        #for action in history._actions:
        #    print action._do
        #    print action._undo

        from edu.uca.util.Serializable import stateChange
        stateChange()
コード例 #4
0
 def itemClick(self, value):
     if hasattr(self.block, 'original') and not self.block.original:
         oldValue = self.block.varName
         self.setValue(value)
         if oldValue != value:
             from edu.uca.util.Serializable import stateChange
             stateChange()
コード例 #5
0
    def popupConfirmNewVar(self, text, typeVar, saveChange=True):  #add var
        if typeVar == Block.NUMBER_BLOCK: self.addGenericNumericBlocks(text)
        elif typeVar == Block.BOOLEAN_BLOCK: self.addGenericLogicBlocks(text)
        elif typeVar == Block.STRING_BLOCK:
            self.addGenericAlphaNumericBlocks(text)

        vars[text] = ''
        if len(vars) > 0:
            self.dropdownRemoveVar.setStyleAttribute('display', 'block')

        if saveChange:
            from edu.uca.util.Serializable import stateChange
            stateChange()
コード例 #6
0
 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()
         
コード例 #7
0
    def itemClick(self, value):  #remove var
        del vars[value]
        if len(vars) == 0:
            self.dropdownRemoveVar.setStyleAttribute('display', 'none')

        if value in alphaNumericVars:
            self.removeGenericAlphaNumericBlocks(value)
        elif value in numericVars:
            self.removeGenericNumericBlocks(value)
        elif value in logicVars:
            self.removeGenericLogicBlocks(value)

        from edu.uca.util.Serializable import stateChange
        stateChange()
コード例 #8
0
    def onDrop(self, event):
        if getWorkspace().getMovingBlock() is None: return
        self.removeStyleName('dragover')
        if hasattr(getWorkspace().getMovingBlock(), 'original'):
            if not getWorkspace().getMovingBlock().original:
                getWorkspace().getMovingBlock().removeFromParent()
                del hardwares[getWorkspace().getMovingBlock().getCompleteText(
                )]  # remove da lista de componentes
                getWorkspace().setMovingBlock(None)

                from edu.uca.util.Serializable import stateChange
                stateChange()

                self.trashCan.setStyleName("trashCanClose")

        DOM.eventPreventDefault(event)
コード例 #9
0
    def onDrop(self, event):
        #print "Left: onDrop"
        if getWorkspace().getMovingBlock() is None: return
        self.removeStyleName('dragover')
        if not getWorkspace().getMovingBlock().original:

            #do = (self.removeBlocks, [getWorkspace().getMovingBlock()])
            self.removeBlocks(getWorkspace().getMovingBlock())  #
            #history.add(do, getWorkspace().getUndo()) # � preciso saber de onde vem

            for listener in self._blockDragListeners:
                listener.onBlockDragEnd(event, getWorkspace().getMovingBlock())
            getWorkspace().getMovingBlock().onDragEnd()  #finaliza - para undo
            getWorkspace().setMovingBlock(None)

            from edu.uca.util.Serializable import stateChange
            stateChange()

            self.trashCan.setStyleName("trashCanClose")
コード例 #10
0
    def onDrop(self, event):

        if getWorkspace().getMovingBlock() is None:

            ####################################################################################
            import json
            from edu.uca.util.Serializable import loadComponent, stateChange
            comp = loadComponent(
                json.loads(
                    event.dataTransfer.getData('text'))['componetHardware'])
            comp.changeTexts()
            x, y = getDropPosition(self, event)
            comp.setStyleAttribute({'left': x, 'top': y})
            self.add(comp)
            stateChange()
            ####################################################################################

            return

        if getWorkspace().getMovingBlock() is None: return
        self.removeStyleName('dragover2')
        left, top = getDropPosition(self, event)
        if hasattr(getWorkspace().getMovingBlock(), 'original'):
            if getWorkspace().getMovingBlock().original:
                getWorkspace().setMovingBlock(
                    getattr(ArduinoHardwares,
                            getWorkspace().getMovingBlock().name)())
                getWorkspace().getMovingBlock().original = False
                self.add(getWorkspace().getMovingBlock())
                self.refreshCount(getWorkspace().getMovingBlock())
                hardwares[getWorkspace().getMovingBlock().getCompleteText(
                )] = getWorkspace().getMovingBlock(
                )  # adiciona na lista de componentes
                getWorkspace().getMovingBlock().changeTexts()
        getWorkspace().getMovingBlock().setStyleAttribute({
            'left': left,
            'top': top
        })
        DOM.eventPreventDefault(event)

        if isinstance(getWorkspace().getMovingBlock(), ComponentBlock):
            from edu.uca.util.Serializable import stateChange
            stateChange()
コード例 #11
0
def popupConfirmNewBlock(nameBlock, categoryBlock, typeBlock, showPopup=True):
    if categoryBlock == ChooseCategoryBlockPanel.CONTROL: color = 'orange'
    elif categoryBlock == ChooseCategoryBlockPanel.OPERATORS: color = 'green'
    elif categoryBlock == ChooseCategoryBlockPanel.INPUT: color = 'purple'
    elif categoryBlock == ChooseCategoryBlockPanel.OUTPUT: color = 'blue'
    elif categoryBlock == ChooseCategoryBlockPanel.UTILITIES:
        color = 'darkblue'
    elif categoryBlock == ChooseCategoryBlockPanel.VARIBLES:
        color = 'red'

    if typeBlock == Block.STATEMENT_BLOCK: attribute = 'commandType'
    elif typeBlock == Block.NUMBER_BLOCK: attribute = 'numericType'
    elif typeBlock == Block.BOOLEAN_BLOCK: attribute = 'logicType'
    elif typeBlock == Block.STRING_BLOCK: attribute = 'alphaNumericType'

    block = getattr(ArduinoBlocks, attribute)(nameBlock, color)
    getattr(getWorkspace().getBlockList(), categoryBlock).addSubCategory(block)

    popup = PopupBlockEditor(block, categoryBlock, True)
    createdBlocks[nameBlock] = popup

    if showPopup:
        from edu.uca.util.Serializable import stateChange
        stateChange()
コード例 #12
0
 def reloadClick(self, sender):
     getWorkspace().reload()
     from edu.uca.util.Serializable import stateChange
     stateChange()
コード例 #13
0
 def onChange(self, sender):
     from edu.uca.util.Serializable import stateChange
     stateChange()
コード例 #14
0
    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')