Exemplo n.º 1
0
 def add(self, tab, text, closable=False):
     t = text
     if closable:
         t += " <a href\=""about:black\" onClick=\"document.modules.main.main.tps.get(%d).removeByKey(%d); return false;\">[x]</a>"%(self.id,self.key)
     TabPanel.add(self, tab, t, closable)
     tab.key = self.key
     self.k2w[self.key]=tab
     self.key+=1
Exemplo n.º 2
0
class Tabs(Sink):
    def __init__(self):
        Sink.__init__(self)

        self.fTabs = TabPanel()
        self.fTabs.addTabListener(self)
        self.fTabs.add(
            self.createImage(self.baseURL() + "rembrandt/JohannesElison.jpg"),
            "1634")
        self.fTabs.add(
            self.createImage(self.baseURL() +
                             "rembrandt/SelfPortrait1640.jpg"), "1640")
        self.fTabs.add(
            self.createImage(self.baseURL() +
                             "rembrandt/LaMarcheNocturne.jpg"), "1642")
        self.fTabs.add(
            self.createImage(self.baseURL() +
                             "rembrandt/TheReturnOfTheProdigalSon.jpg"),
            "1662")
        self.fTabs.add(
            self.createImage(self.baseURL() +
                             "rembrandt/TheReturnOfTheProdigalSon.jpg"),
            "1662 (disabled)")
        self.fTabs.selectTab(0)

        self.fTabs.setWidth("100%")
        self.fTabs.setHeight("100%")
        self.initWidget(self.fTabs)

    def onShow(self):
        pass

    def createImage(self, imageUrl):
        image = Image(imageUrl)
        image.setStyleName("ks-images-Image")

        p = VerticalPanel()
        p.setHorizontalAlignment(HasAlignment.ALIGN_CENTER)
        p.setVerticalAlignment(HasAlignment.ALIGN_MIDDLE)
        p.add(image)
        return p

    def onBeforeTabSelected(self, sender, tabIndex):
        # Returning False disables the tab.
        if tabIndex == 4:
            return False
        return True

    def onTabSelected(self, sender, tabIndex):
        bar = self.fTabs.getTabBar()
        if tabIndex == 0:
            bar.getTabWidget(0).setText('1634 (selected)')
        else:
            bar.getTabWidget(0).setText('1634 (not selected)')
Exemplo n.º 3
0
class ShowCaseApp(object):

    def onModuleLoad(self):
        self.tabs = TabPanel()
        tab_overview=TabContainer()
        self.tabs.add(tab_overview, 'Overview')

        self.tab_events=TabRaphaelContainer()
        self.tab_events.set_headline('Events Example')
        self.tab_events.set_raphael(events.Events(width=600,height=300))
        self.tab_events.set_status('Execute events on Raphael Elemnts')
        self.tabs.add(self.tab_events, 'Events')

        self.tab_graffle=TabRaphaelContainer()
        self.tab_graffle.set_headline('This is a simple example of the Raphael Graffle')
        self.tab_graffle.set_raphael(graffle.Graffle(width=600,height=300))
        self.tabs.add(self.tab_graffle, 'Graffle')

        self.tab_spinner=TabRaphaelContainer()
        self.tab_spinner.set_headline('This Raphael Spinner Example')
        self.tab_spinner.set_raphael(spinner.Spinner(width=600,height=300))
        self.tabs.add(self.tab_spinner, 'Spinner')

        self.tabs.selectTab(0)
        self.tabs.setWidth("100%")
        self.tabs.setHeight("100%")
        RootPanel().add(self.tabs)

    def draw(self):
        self.tab_spinner.raphael.draw()
        self.tab_graffle.raphael.draw()
Exemplo n.º 4
0
class ShowCaseApp(object):
    def onModuleLoad(self):
        self.tabs = TabPanel()
        tab_overview = TabContainer()
        self.tabs.add(tab_overview, 'Overview')

        self.tab_events = TabRaphaelContainer()
        self.tab_events.set_headline('Events Example')
        self.tab_events.set_raphael(events.Events(width=600, height=300))
        self.tab_events.set_status('Execute events on Raphael Elemnts')
        self.tabs.add(self.tab_events, 'Events')

        self.tab_graffle = TabRaphaelContainer()
        self.tab_graffle.set_headline(
            'This is a simple example of the Raphael Graffle')
        self.tab_graffle.set_raphael(graffle.Graffle(width=600, height=300))
        self.tabs.add(self.tab_graffle, 'Graffle')

        self.tab_spinner = TabRaphaelContainer()
        self.tab_spinner.set_headline('This Raphael Spinner Example')
        self.tab_spinner.set_raphael(spinner.Spinner(width=600, height=300))
        self.tabs.add(self.tab_spinner, 'Spinner')

        self.tabs.selectTab(0)
        self.tabs.setWidth("100%")
        self.tabs.setHeight("100%")
        RootPanel().add(self.tabs)

    def draw(self):
        self.tab_spinner.raphael.draw()
        self.tab_graffle.raphael.draw()
Exemplo n.º 5
0
class Tabs(Sink):
    def __init__(self):
        Sink.__init__(self)

        self.fTabs = TabPanel()
        self.fTabs.add(self.createImage(self.baseURL() + "rembrandt/JohannesElison.jpg"), "1634")
        self.fTabs.add(self.createImage(self.baseURL() + "rembrandt/SelfPortrait1640.jpg"), "1640")
        self.fTabs.add(self.createImage(self.baseURL() + "rembrandt/LaMarcheNocturne.jpg"), "1642")
        self.fTabs.add(self.createImage(self.baseURL() + "rembrandt/TheReturnOfTheProdigalSon.jpg"), "1662")
        self.fTabs.selectTab(0)

        self.fTabs.setWidth("100%")
        self.fTabs.setHeight("100%")
        self.initWidget(self.fTabs)

    def onShow(self):
        pass

    def createImage(self, imageUrl):
        image = Image(imageUrl)
        image.setStyleName("ks-images-Image")

        p = VerticalPanel()
        p.setHorizontalAlignment(HasAlignment.ALIGN_CENTER)
        p.setVerticalAlignment(HasAlignment.ALIGN_MIDDLE)
        p.add(image)
        return p
Exemplo n.º 6
0
    def __init__(self, **kwargs):
        ZillaWindow.__init__(self, kwargs)
        FocusPanel.__init__(self, kwargs)

        area1 = TextArea()
        area1.setText("Zakładka 1")

        area2 = TextArea()
        area2.setText("Zakładka 2")

        area3 = TextArea()
        area3.setText("Zakładka 2")

        tabs = TabPanel()
        tabs.add(area2, tabText="Gra nr 1")
        tabs.add(area1, tabText="Pokój gier")
        tabs.add(area3, tabText="Pokój gier")

        self.add(tabs)

        lwindow = LoginWindow(centered=True)
        lwindow.setPopupPosition(100, 100)
        lwindow.show()
Exemplo n.º 7
0
    def __init__ (self, **kwargs):
        ZillaWindow.__init__(self, kwargs)
        FocusPanel.__init__(self, kwargs)

        area1 = TextArea()
        area1.setText("Zakładka 1")

        area2 = TextArea()
        area2.setText("Zakładka 2")

        area3 = TextArea()
        area3.setText("Zakładka 2")

        tabs = TabPanel()
        tabs.add(area2, tabText="Gra nr 1")
        tabs.add(area1, tabText="Pokój gier")
        tabs.add(area3, tabText="Pokój gier")

        self.add (tabs)

        lwindow = LoginWindow(centered=True)
        lwindow.setPopupPosition (100, 100)
        lwindow.show()
Exemplo n.º 8
0
    def __init__(self):
        SimplePanel.__init__(self)

        tabs = TabPanel(Width="100%", Height="250px")
        tabs.add(HTML("The quick brown fox jumps over the lazy dog."), "Tab 1")
        tabs.add(HTML("The early bird catches the worm."), "Tab 2")
        tabs.add(HTML("The smart money is on the black horse."), "Tab 3")

        tabs.selectTab(0)

        self.add(tabs)
Exemplo n.º 9
0
Arquivo: Tabs.py Projeto: Afey/pyjs
class Tabs(Sink):
    def __init__(self):
        Sink.__init__(self)

        self.fTabs = TabPanel()
        self.fTabs.addTabListener(self)
        self.fTabs.add(self.createImage(self.baseURL() + "rembrandt/JohannesElison.jpg"), "1634")
        self.fTabs.add(self.createImage(self.baseURL() + "rembrandt/SelfPortrait1640.jpg"), "1640")
        self.fTabs.add(self.createImage(self.baseURL() + "rembrandt/LaMarcheNocturne.jpg"), "1642")
        self.fTabs.add(self.createImage(self.baseURL() + "rembrandt/TheReturnOfTheProdigalSon.jpg"), "1662")
        self.fTabs.add(self.createImage(self.baseURL() + "rembrandt/TheReturnOfTheProdigalSon.jpg"), "1662 (disabled)")
        self.fTabs.selectTab(0)

        self.fTabs.setWidth("100%")
        self.fTabs.setHeight("100%")
        self.initWidget(self.fTabs)

    def onShow(self):
        pass

    def createImage(self, imageUrl):
        image = Image(imageUrl)
        image.setStyleName("ks-images-Image")

        p = VerticalPanel()
        p.setHorizontalAlignment(HasAlignment.ALIGN_CENTER)
        p.setVerticalAlignment(HasAlignment.ALIGN_MIDDLE)
        p.add(image)
        return p

    def onBeforeTabSelected(self, sender, tabIndex):
        # Returning False disables the tab.
        if tabIndex == 4:
            return False
        return True

    def onTabSelected(self, sender, tabIndex):
        bar = self.fTabs.getTabBar()
        if tabIndex == 0:
            bar.getTabWidget(0).setText('1634 (selected)')
        else:
            bar.getTabWidget(0).setText('1634 (not selected)')
Exemplo n.º 10
0
class Tabs(Sink):
    def __init__(self):
        Sink.__init__(self)

        self.fTabs = TabPanel()
        self.fTabs.add(
            self.createImage(self.baseURL() + "rembrandt/JohannesElison.jpg"),
            "1634")
        self.fTabs.add(
            self.createImage(self.baseURL() +
                             "rembrandt/SelfPortrait1640.jpg"), "1640")
        self.fTabs.add(
            self.createImage(self.baseURL() +
                             "rembrandt/LaMarcheNocturne.jpg"), "1642")
        self.fTabs.add(
            self.createImage(self.baseURL() +
                             "rembrandt/TheReturnOfTheProdigalSon.jpg"),
            "1662")
        self.fTabs.selectTab(0)

        self.fTabs.setWidth("100%")
        self.fTabs.setHeight("100%")
        self.initWidget(self.fTabs)

    def onShow(self):
        pass

    def createImage(self, imageUrl):
        image = Image(imageUrl)
        image.setStyleName("ks-images-Image")

        p = VerticalPanel()
        p.setHorizontalAlignment(HasAlignment.ALIGN_CENTER)
        p.setVerticalAlignment(HasAlignment.ALIGN_MIDDLE)
        p.add(image)
        return p
Exemplo n.º 11
0
    def onModuleLoad(self):
        self.popupsubtraca = PopupSub(id="sub",datasrc="fsubtracao.pjs")
        self.popupsoma = PopupSoma(id="soma",datasrc="fsoma.pjs")
        self.popupmultescalar = PopupEscalar(id="escalar",datasrc="fmultescalar.pjs")
        self.popupmult = PopupProduto(id="mult",datasrc="fmult.pjs")
        self.popupsoma.iniciado = False;

        tabpanel = TabPanel()
        grid = Grid(4,2)
        imgbtnSoma =  Image("images/Soma_Matriz_sum_matrix.png",StyleName="gwt-ImageButton")
        imgbtnSubtracao =  Image("images/subtracao_Matriz_subtract_matrix.png",StyleName="gwt-ImageButton")
        imgbtnMultiplicacao =  Image("images/multiplicacao_Matriz_product_matrix.png",StyleName="gwt-ImageButton")
        imgbtnMultiplicacaoPorEscalar =  Image("images/multiplicacao_por_escalar.png",StyleName="gwt-ImageButton")
        
        #eventos
        imgbtnSoma.addClickListener(self.onSomaButtonClick)
        imgbtnSubtracao.addClickListener(self.onSubtracaoButtonClick)
        imgbtnMultiplicacao.addClickListener(self.onMultiplicacaoButtonClick)
        imgbtnMultiplicacaoPorEscalar.addClickListener(self.onMulPorEscalarButtonClick)
        
        contents = VerticalPanel()
        contents.setSpacing(4)
        contents.add(HTML('You can place any contents you like in a dialog box.'))
        
        grid.setWidget(0,0,imgbtnSoma)
        grid.setWidget(0,1,imgbtnSubtracao)
        grid.setWidget(2,0,imgbtnMultiplicacao)
        grid.setWidget(2,1,imgbtnMultiplicacaoPorEscalar)
        
        grid.setStyleName(element)
        tabpanel.add(HTML("Modulo de introducao a matrizes"),"<h2>Modulo de introducao a Matrizes</h2>", True)
        tabpanel.add(grid,"<h2>  Matrizes  </h2>", True)
        tabpanel.add(HTML("Modulo de introducao a matrizes"),"<h2>Ajuda para usar a ferramenta</h2>", True)
        tabpanel.setSize("90%"," 70%")
        
        tabpanel.selectTab(1)
        #self.popupsoma.show()
        
        RootPanel("conteudo").add(tabpanel)
Exemplo n.º 12
0
class HardwareList(DropWidget, DragContainer, VerticalPanel):
    def __init__(self):
        VerticalPanel.__init__(self, StyleName='drophere')
        DropWidget.__init__(self)
        DragContainer.__init__(self)

    def changeTexts(self):
        for category in self.tabs.getChildren():
            category.changeTexts()

        for i in range(1, self.tabs.getTabBar().panel.getWidgetCount() - 1):
            self.tabs.getTabBar().panel.getWidget(
                i).getFocusablePanel().getWidget().changeTexts()

    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')

    def reload(self):
        pass

    def onDragStart(self, event):
        setDragStartPosition(event)

    def onDragEnd(self, event):
        getWorkspace().setMovingBlock(None)

    def onDragOver(self, event):
        if getWorkspace().getMovingBlock() is None: return
        dt = event.dataTransfer
        dt.dropEffect = 'copy'
        if hasattr(getWorkspace().getMovingBlock(), 'original'):
            if not getWorkspace().getMovingBlock().original:
                self.addStyleName('dragover')
                self.trashCan.setStyleName('trashCanOpen')
        DOM.eventPreventDefault(event)

    def onDragLeave(self, event):
        dt = event.dataTransfer
        dt.dropEffect = 'none'
        if hasattr(getWorkspace().getMovingBlock(), 'original'):
            if not getWorkspace().getMovingBlock().original:
                self.removeStyleName('dragover')
                self.trashCan.setStyleName('trashCanClose trashCanCloseFadeIn')

    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)
Exemplo n.º 13
0
class OpenPowerSystem:
    """ Defines the main panel for OpenPowerSystem.
    """

    def __init__(self):
        """ Constructs a new OpenPowerSystem instance.
        """
        self.TEXT_WAITING = "Waiting for response..."
        self.TEXT_ERROR = "Server Error"

        self.base_panel = HorizontalPanel()

        self.tab_panel = TabPanel()
        self.tab_panel.add(self.get_upload_panel(), "Upload")
#        self.tab_panel.add(self.get_home_panel(), "OpenPowerSystem")
#        self.tab_panel.add(self.get_map_panel(), "Map")
#        self.tab_panel.add(self.get_edit_panel(), "Edit")
        self.tab_panel.selectTab(0)

        self.base_panel.add(self.tab_panel)

        RootPanel().add(self.base_panel)


    def get_home_panel(self):
        panel = VerticalPanel()

        title = HTML("""OpenPowerSystem""")
        panel.add(title)

        subtitle = HTML("""The Open Power System data repository.""")
        panel.add(subtitle)

        return panel


#    def get_map_panel(self):
#        panel = VerticalPanel()
#
#        self.map = OpenMap(Width="900px", Height="900px")
#        panel.add(self.map)
#
#        self.wms = OpenWMSLayer("OpenLayers WMS",
#            "http://labs.metacarta.com/wms/vmap0", layers="basic")
#        self.map.addLayer(self.wms)
#
#        return panel


#    def get_edit_panel(self):
#        edit_page = edit_panel.EditPanel()
#        return edit_page.panel


    def get_upload_panel(self):
        # Create a FormPanel and point it at a service.
        self.form = FormPanel()
        self.form.setAction("/upload")

        # Add an event handler to the form.
        handler = UploadFormHandler()
        handler.form = self.form
        self.form.addFormHandler(handler)

        # Because we're going to add a FileUpload widget, we'll need to set the
        # form to use the POST method, and multipart MIME encoding.
        self.form.setEncoding(FormPanel.ENCODING_MULTIPART)
        self.form.setMethod(FormPanel.METHOD_POST)

        panel = VerticalPanel()
        panel.setSpacing(8)
        panel.setStyleName("panel") # same name as in OpenPowerSystem.css.
        self.form.setWidget(panel)

        info = HTML(r'Upload CIM RDF/XML instance file.')
        panel.add(info)

        # Create a list box for choice of profile.
        self.profiles = [("UCTE (CIM 14)", "ucte"),
                         ("CPSM (CIM13)", "cpsm"),
                         ("CDPSM (CIM 14)", "cdpsm"),
                         ("Dynamics (CIM 14)", "dynamics")]
        self.profile = ListBox(VisibleItemCount=1)
        self.profile.setName("profileType")
        for n, v in self.profiles:
            self.profile.addItem(n, v)
        panel.add(self.profile)

        # Create a FileUpload widget.
        rdfxml_file = FileUpload()
        rdfxml_file.setName("uploadFormElement")
        panel.add(rdfxml_file)

        # Add a 'submit' button.
        upload = Button("Upload", handler)
        panel.add(upload)

        return self.form
Exemplo n.º 14
0
class BlockList(DropWidget, DragContainer, VerticalPanel):

    _blockDragListeners = []

    def __init__(self):
        VerticalPanel.__init__(self, StyleName='drophere')
        DropWidget.__init__(self)
        DragContainer.__init__(self)

    def changeTexts(self):
        for category in self.tabs.getChildren():
            category.changeTexts()

        for i in range(1, self.tabs.getTabBar().panel.getWidgetCount() - 1):
            self.tabs.getTabBar().panel.getWidget(
                i).getFocusablePanel().getWidget().changeTexts()

    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 refreshComponentBlocks(self, components):
        self.input.removeAllSubComp()
        self.output.removeAllSubComp()
        listName = set([])
        for comp in components:
            if hasattr(comp, 'listBlockName'):
                for name in comp.listBlockName:
                    if not listName.__contains__(name):
                        listName.add(name)
                        block = getattr(ArduinoBlocks, name)()
                        block.changeTexts()
                        if comp.mode == INPUT:
                            self.input.getSubComp(comp.text).addBlock(block)
                        elif comp.mode == OUTPUT:
                            self.output.getSubComp(comp.text).addBlock(block)
        self.input.changeTexts()
        self.output.changeTexts()

    def reload(self):
        self.showMainBlock()
        for cat in self.tabs.children:
            cat.reload()

    def onDragStart(self, event):
        #print "Left: onDragStart"
        setDragStartPosition(
            event
        )  #verificar se realmente � necess�rio REMOVI (talvez tenha que colocar para undo)
        for listener in self._blockDragListeners:
            listener.onBlockDragStart(event, getWorkspace().getMovingBlock())

    def onDragEnd(self, event):
        for listener in self._blockDragListeners:
            listener.onBlockDragEnd(event, getWorkspace().getMovingBlock())
        getWorkspace().setMovingBlock(None)

    def onDragEnter(self, event):
        DOM.eventPreventDefault(event)

    def onDragOver(self, event):
        if getWorkspace().getMovingBlock() is None: return
        dt = event.dataTransfer
        dt.dropEffect = 'copy'
        if not getWorkspace().getMovingBlock().original:
            self.addStyleName('dragover')
            self.trashCan.setStyleName('trashCanOpen')

        DOM.eventPreventDefault(event)

    def onDragLeave(self, event):
        #print "Left: onDragLeave"
        if getWorkspace().getMovingBlock() is None: return
        dt = event.dataTransfer
        dt.dropEffect = 'none'
        if not getWorkspace().getMovingBlock().original:
            self.removeStyleName('dragover')
            self.trashCan.setStyleName('trashCanClose trashCanCloseFadeIn')

    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")

    def removeBlocks(
            self, root):  # remove o bloco e seus subblocos da lista de blocos
        if root is None: return
        getWorkspace().removeBlock(root)  # Tentando remover um bloco original
        for holder in root.holderArguments:
            self.removeBlocks(holder.subBlock)
        for holder in root.holderChildren:
            self.removeBlocks(holder.subBlock)
        if root.holderSiblingDown is not None:
            self.removeBlocks(root.holderSiblingDown.subBlock)
        if isinstance(root, MainBlock):
            self.showMainBlock()
            getWorkspace().setMainBlock(None)
        root.removeFromParent()

#--------------------------------------------------------------------------------------------------------------

    def hideMainBlock(self):
        self.control.hideMainBlock()

    def showMainBlock(self):
        self.control.showMainBlock()

#--------------------------------------------------------------------------------------------------------------

    def addBlockDragListener(self, listener):
        self._blockDragListeners.append(listener)

    def removeBlockDragListener(self, listener):
        self._blockDragListeners.remove(listener)
Exemplo n.º 15
0
 def make_tabs(self):
     tabs = TabPanel()
     tabs.add(self.make_alarm_widget(), 'alarms')
     tabs.add(self.make_test_widget(), 'test')
     tabs.selectTab(0)
     return tabs
Exemplo n.º 16
0
class Pylon:
    def __init__(self):
        self.remote_case = CaseService()

        self.base_panel = VerticalPanel()
        self.tab_panel = TabPanel()
        self.base_panel.add(self.tab_panel)
        self.tab_panel.add(self.get_case_panel(), "Case")
        self.tab_panel.add(self.get_buses_panel(), "Buses")
        self.tab_panel.selectTab(0)
        self.status = Label()
        self.base_panel.add(self.status)
        RootPanel().add(self.base_panel)

    def get_case_panel(self):
        panel = VerticalPanel()
        title = HTML("""Case""")
        panel.add(title)
        tree = self.get_case_tree()
        panel.add(tree)
        return panel

    def get_case_tree(self):
        tree = self.tree = Tree()
        case_item = TreeItem("Case_1")
        tree.addItem(case_item)
        buses = self.buses = TreeItem("Buses")
        case_item.addItem(buses)
        id = self.remote_case.buses("name", self)
        return tree

    def create_item(self, proto):
        proto.item = TreeItem(proto.text)
        proto.item.setUserObject(proto)
        if len(proto.children) > 0:
            proto.item.addItem(PendingItem())

    def get_buses_panel(self):
        panel = VerticalPanel()
        title = HTML("""Buses""")
        panel.add(title)
        return panel

    # JSON handler interface --------------------------------------------------

    # The handler object should implement
    #     onRemoteResponse(value, requestInfo)
    # to accept the return value of the remote method, and
    #     onRemoteError(code, error_dict, requestInfo)
    #          code = http-code or 0
    #          error_dict is an jsonrpc 2.0 error dict:
    #              {
    #                'code': jsonrpc-error-code (integer) ,
    #                'message': jsonrpc-error-message (string) ,
    #                'data' : extra-error-data
    #              }
    # to handle errors.

    def onRemoteResponse(self, response, request_info):
        print "RESPONSE:", response
        #        self.tree.clear()
        self.buses.removeItems()
        for bus_name in response:
            proto = Proto(str(bus_name))
            self.create_item(proto)
            self.buses.addItem(proto.item)

    def onRemoteError(self, code, errobj, request_info):
        print "ERROR:", errobj['message']

        message = errobj['message']
        if code != 0:
            self.status.setText("HTTP error %d: %s" % (code, message))
        else:
            code = errobj['code']
            self.status.setText("JSONRPC Error %s: %s" % (code, message))
Exemplo n.º 17
0
class Pylon:
    def __init__(self):
        self.remote_case = CaseService()

        self.base_panel = VerticalPanel()
        self.tab_panel = TabPanel()
        self.base_panel.add(self.tab_panel)
        self.tab_panel.add(self.get_case_panel(), "Case")
        self.tab_panel.add(self.get_buses_panel(), "Buses")
        self.tab_panel.selectTab(0)
        self.status = Label()
        self.base_panel.add(self.status)
        RootPanel().add(self.base_panel)


    def get_case_panel(self):
        panel = VerticalPanel()
        title = HTML("""Case""")
        panel.add(title)
        tree = self.get_case_tree()
        panel.add(tree)
        return panel


    def get_case_tree(self):
        tree = self.tree = Tree()
        case_item = TreeItem("Case_1")
        tree.addItem(case_item)
        buses = self.buses = TreeItem("Buses")
        case_item.addItem(buses)
        id = self.remote_case.buses("name", self)
        return tree


    def create_item(self, proto):
        proto.item = TreeItem(proto.text)
        proto.item.setUserObject(proto)
        if len(proto.children) > 0:
            proto.item.addItem(PendingItem())



    def get_buses_panel(self):
        panel = VerticalPanel()
        title = HTML("""Buses""")
        panel.add(title)
        return panel

    # JSON handler interface --------------------------------------------------

    # The handler object should implement
    #     onRemoteResponse(value, requestInfo)
    # to accept the return value of the remote method, and
    #     onRemoteError(code, error_dict, requestInfo)
    #          code = http-code or 0
    #          error_dict is an jsonrpc 2.0 error dict:
    #              {
    #                'code': jsonrpc-error-code (integer) ,
    #                'message': jsonrpc-error-message (string) ,
    #                'data' : extra-error-data
    #              }
    # to handle errors.

    def onRemoteResponse(self, response, request_info):
        print "RESPONSE:", response
#        self.tree.clear()
        self.buses.removeItems()
        for bus_name in response:
            proto = Proto(str(bus_name))
            self.create_item(proto)
            self.buses.addItem(proto.item)


    def onRemoteError(self, code, errobj, request_info):
        print "ERROR:", errobj['message']

        message = errobj['message']
        if code != 0:
            self.status.setText("HTTP error %d: %s" % (code, message))
        else:
            code = errobj['code']
            self.status.setText("JSONRPC Error %s: %s" % (code, message))
Exemplo n.º 18
0
class OpenPowerSystem:
    """ Defines the main panel for OpenPowerSystem.
    """
    def __init__(self):
        """ Constructs a new OpenPowerSystem instance.
        """
        self.TEXT_WAITING = "Waiting for response..."
        self.TEXT_ERROR = "Server Error"

        self.base_panel = HorizontalPanel()

        self.tab_panel = TabPanel()
        self.tab_panel.add(self.get_upload_panel(), "Upload")
        #        self.tab_panel.add(self.get_home_panel(), "OpenPowerSystem")
        #        self.tab_panel.add(self.get_map_panel(), "Map")
        #        self.tab_panel.add(self.get_edit_panel(), "Edit")
        self.tab_panel.selectTab(0)

        self.base_panel.add(self.tab_panel)

        RootPanel().add(self.base_panel)

    def get_home_panel(self):
        panel = VerticalPanel()

        title = HTML("""OpenPowerSystem""")
        panel.add(title)

        subtitle = HTML("""The Open Power System data repository.""")
        panel.add(subtitle)

        return panel

#    def get_map_panel(self):
#        panel = VerticalPanel()
#
#        self.map = OpenMap(Width="900px", Height="900px")
#        panel.add(self.map)
#
#        self.wms = OpenWMSLayer("OpenLayers WMS",
#            "http://labs.metacarta.com/wms/vmap0", layers="basic")
#        self.map.addLayer(self.wms)
#
#        return panel

#    def get_edit_panel(self):
#        edit_page = edit_panel.EditPanel()
#        return edit_page.panel

    def get_upload_panel(self):
        # Create a FormPanel and point it at a service.
        self.form = FormPanel()
        self.form.setAction("/upload")

        # Add an event handler to the form.
        handler = UploadFormHandler()
        handler.form = self.form
        self.form.addFormHandler(handler)

        # Because we're going to add a FileUpload widget, we'll need to set the
        # form to use the POST method, and multipart MIME encoding.
        self.form.setEncoding(FormPanel.ENCODING_MULTIPART)
        self.form.setMethod(FormPanel.METHOD_POST)

        panel = VerticalPanel()
        panel.setSpacing(8)
        panel.setStyleName("panel")  # same name as in OpenPowerSystem.css.
        self.form.setWidget(panel)

        info = HTML(r'Upload CIM RDF/XML instance file.')
        panel.add(info)

        # Create a list box for choice of profile.
        self.profiles = [("UCTE (CIM 14)", "ucte"), ("CPSM (CIM13)", "cpsm"),
                         ("CDPSM (CIM 14)", "cdpsm"),
                         ("Dynamics (CIM 14)", "dynamics")]
        self.profile = ListBox(VisibleItemCount=1)
        self.profile.setName("profileType")
        for n, v in self.profiles:
            self.profile.addItem(n, v)
        panel.add(self.profile)

        # Create a FileUpload widget.
        rdfxml_file = FileUpload()
        rdfxml_file.setName("uploadFormElement")
        panel.add(rdfxml_file)

        # Add a 'submit' button.
        upload = Button("Upload", handler)
        panel.add(upload)

        return self.form