Example #1
0
    def __init__(self):
        inner = Grid(10, 5)
        outer = FlexTable()

        outer.setWidget(
            0, 0, Image(self.baseURL() + "rembrandt/LaMarcheNocturne.jpg"))
        outer.getFlexCellFormatter().setColSpan(0, 0, 2)
        outer.getFlexCellFormatter().setHorizontalAlignment(
            0, 0, HasHorizontalAlignment.ALIGN_CENTER)

        outer.setHTML(
            1, 0, "Look to the right...<br>That's a nested table component ->")
        outer.setWidget(1, 1, inner)
        outer.getCellFormatter().setColSpan(1, 1, 2)

        for i in range(10):
            for j in range(5):
                inner.setText(i, j, "" + i + "," + j)

        inner.setWidth("100%")
        outer.setWidth("100%")

        inner.setBorderWidth(1)
        outer.setBorderWidth(1)

        self.setWidget(outer)
Example #2
0
class GridTest:
	def onModuleLoad(self):
		self.page=0
		self.min_page=1
		self.max_page=10
		
		self.add=Button("Next >", self)
		self.sub=Button("< Prev", self)
		
		self.g=Grid()
		self.g.resize(5, 5)
		self.g.setHTML(0, 0, "<b>Grid Test</b>")
		self.g.setBorderWidth(2)
		self.g.setCellPadding(4)
		self.g.setCellSpacing(1)
		
		self.updatePageDisplay()
		RootPanel().add(self.sub)
		RootPanel().add(self.add)
		RootPanel().add(self.g)

	def onClick(self, sender):

		print "click", sender, self.add, self.sub

		if sender==self.add:
			self.page+=1
		elif sender==self.sub:
			self.page-=1
		print sender, self.page
		self.updatePageDisplay()
		

	def updatePageDisplay(self):
		if self.page<self.min_page: self.page=self.min_page
		elif self.page>self.max_page: self.page=self.max_page
		total_pages=(self.max_page-self.min_page) + 1
		
		self.g.setHTML(0, 4, "<b>page " + str(self.page) + ' of ' + str(total_pages) + "</b>")
		
		if self.page>=self.max_page:
			self.add.setEnabled(False)
		else:
			self.add.setEnabled(True)
			
		if self.page<=self.min_page:
			self.sub.setEnabled(False)
		else:
			self.sub.setEnabled(True)

		for y in range(1, 5):
			for x in range(5):
				txt = str(self.page) + ' (' + str(y) + ',' + str(x) + ')'
				print txt
				self.g.setText(y, x, txt)
Example #3
0
class GridTest:
    def onModuleLoad(self):
        self.page = 0
        self.min_page = 1
        self.max_page = 10

        self.add = Button("Next >", self)
        self.sub = Button("< Prev", self)

        self.g = Grid()
        self.g.resize(5, 5)
        self.g.setHTML(0, 0, "<b>Grid Test</b>")
        self.g.setBorderWidth(2)
        self.g.setCellPadding(4)
        self.g.setCellSpacing(1)

        self.updatePageDisplay()
        RootPanel().add(self.sub)
        RootPanel().add(self.add)
        RootPanel().add(self.g)

    def onClick(self, sender):
        if sender == self.add:
            self.page += 1
        elif sender == self.sub:
            self.page -= 1
        self.updatePageDisplay()

    def updatePageDisplay(self):
        if self.page < self.min_page: self.page = self.min_page
        elif self.page > self.max_page: self.page = self.max_page
        total_pages = (self.max_page - self.min_page) + 1

        self.g.setHTML(0, 4,
                       "<b>page " + self.page + ' of ' + total_pages + "</b>")

        if self.page >= self.max_page:
            self.add.setEnabled(False)
        else:
            self.add.setEnabled(True)

        if self.page <= self.min_page:
            self.sub.setEnabled(False)
        else:
            self.sub.setEnabled(True)

        for y in range(1, 5):
            for x in range(5):
                self.g.setText(y, x, self.page + ' (' + y + ',' + x + ')')
class DynaTableWidget(Composite):
    def __init__(self, provider, columns, columnStyles, rowCount):
        Composite.__init__(self)

        self.acceptor = RowDataAcceptorImpl(self)
        self.outer = DockPanel()
        self.startRow = 0
        self.grid = Grid()
        self.navbar = NavBar(self)

        self.provider = provider
        self.setWidget(self.outer)
        self.grid.setStyleName("table")
        self.outer.add(self.navbar, DockPanel.NORTH)
        self.outer.add(self.grid, DockPanel.CENTER)
        self.initTable(columns, columnStyles, rowCount)
        self.setStyleName("DynaTable-DynaTableWidget")

    def initTable(self, columns, columnStyles, rowCount):
        self.grid.resize(rowCount + 1, len(columns))
        for i in range(len(columns)):
            caption = columns[i]
            self.grid.setText(0, i, columns[i])
            if columnStyles:
                self.grid.cellFormatter.setStyleName(
                    0, i, columnStyles[i] + "header")

    def setStatusText(self, text):
        self.navbar.status.setText(text)

    def clearStatusText(self, text):
        self.navbar.status.setHTML("&nbsp;")

    def refresh(self):
        self.navbar.gotoFirst.setEnabled(False)
        self.navbar.gotoPrev.setEnabled(False)
        self.navbar.gotoNext.setEnabled(False)

        self.setStatusText("Please wait...")
        self.provider.updateRowData(self.startRow,
                                    self.grid.getRowCount() - 1, self.acceptor)

    def setRowCount(self, rows):
        self.grid.resizeRows(rows)

    def getDataRowCount(self):
        return self.grid.getRowCount() - 1
Example #5
0
class DynaTableWidget(Composite):

    def __init__(self, provider, columns, columnStyles, rowCount):
        Composite.__init__(self)
    
        self.acceptor = RowDataAcceptorImpl(self)
        self.outer = DockPanel()
        self.startRow = 0
        self.grid = Grid()
        self.navbar = NavBar(self)
        
        self.provider = provider
        self.setWidget(self.outer)
        self.grid.setStyleName("table")
        self.outer.add(self.navbar, DockPanel.NORTH)
        self.outer.add(self.grid, DockPanel.CENTER)
        self.initTable(columns, columnStyles, rowCount)
        self.setStyleName("DynaTable-DynaTableWidget")
        
    def initTable(self, columns, columnStyles, rowCount):
        self.grid.resize(rowCount + 1, len(columns))
        for i in range(len(columns)):
            caption = columns[i]
            self.grid.setText(0, i, columns[i])
            if columnStyles:
                self.grid.cellFormatter.setStyleName(0, i, columnStyles[i] + "header")

    def setStatusText(self, text):
        self.navbar.status.setText(text)
        
    def clearStatusText(self, text):
        self.navbar.status.setHTML("&nbsp;")
        
    def refresh(self):
        self.navbar.gotoFirst.setEnabled(False)
        self.navbar.gotoPrev.setEnabled(False)
        self.navbar.gotoNext.setEnabled(False)
        
        self.setStatusText("Please wait...")
        self.provider.updateRowData(self.startRow, self.grid.getRowCount() - 1, self.acceptor)
        
    def setRowCount(self, rows):
        self.grid.resizeRows(rows)
        
    def getDataRowCount(self):
        return self.grid.getRowCount() - 1
Example #6
0
    def __init__(self):
        inner = Grid(10, 5)
        outer = FlexTable()

        outer.setWidget(0, 0, Image(self.baseURL() + "rembrandt/LaMarcheNocturne.jpg"))
        outer.getFlexCellFormatter().setColSpan(0, 0, 2)
        outer.getFlexCellFormatter().setHorizontalAlignment(0, 0, HasHorizontalAlignment.ALIGN_CENTER)

        outer.setHTML(1, 0, "Look to the right...<br>That's a nested table component ->")
        outer.setWidget(1, 1, inner)
        outer.getCellFormatter().setColSpan(1, 1, 2)
        
        for i in range(10):
            for j in range(5):
                inner.setText(i, j, "" + i + "," + j)

        inner.setWidth("100%")
        outer.setWidth("100%")

        inner.setBorderWidth(1)
        outer.setBorderWidth(1)

        self.setWidget(outer)