public void addData(String hint, String text, DocNode node, int flag) { String plainText = node == null ? Util.stripHtml(text) : node.getText(); csvField(plainText); dbField(mColIdx, plainText); if (mColIdx == 0) { mRow = new TableRow(); mBody.add(mRow); if (mNextRowStyle != null) { mRow.setStyle(mNextRowStyle); mNextRowStyle = null; } if (mNextRowId != null) { mRow.setId(mNextRowId); mNextRowId = null; } } TableCell cell = new TableCell(hint, text, node); mRow.add(cell); Column c = mColumns.get(mColIdx); if (0 != (c.flag & FLAG_ALIGN_RIGHT)) { cell.addStyle("right"); } mColIdx = (mColIdx + 1) % mColumns.size(); if (mColIdx == 0) { csvEOL(); dbEOL(); } mEmpty = false; }
private void addNextCellOnCurrentRow(final TableCell cell) { final GridArea area = new GridArea(currentRow, nextColumn, currentRow + cell.getVerticalSpan() - 1, nextColumn); occupy(area, cell); cell.setGridArea(area); cell.setLayoutGrid(this); updateNextColumn(); }
public void refresh(TableCell cell) { DownloadManager dm = (DownloadManager) cell.getDataSource(); long value = (dm == null) ? 0 : dm.getStats().getSecondsDownloading(); if (!cell.setSortValue(value) && cell.isValid()) return; cell.setText(TimeFormatter.format(value)); }
public void refresh(TableCell cell) { TRHostTorrent item = (TRHostTorrent) cell.getDataSource(); long value = (item == null) ? 0 : item.getAnnounceCount(); if (!cell.setSortValue(value) && cell.isValid()) { return; } cell.setText("" + value); }
private boolean addCellOnCurrentRow( final TableCell cell, final int startColumn, final int endColumn) { final GridArea area = new GridArea(currentRow, startColumn, currentRow + cell.getVerticalSpan() - 1, endColumn); if (isOccupied(area)) { return false; } occupy(area, cell); cell.setGridArea(area); cell.setLayoutGrid(this); updateNextColumn(); return true; }
public void refresh(TableCell cell) { DeviceOfflineDownload od = (DeviceOfflineDownload) cell.getDataSource(); if (od == null) { return; } String text = od.getDownload().getName(); if (text == null || text.length() == 0) { return; } cell.setText(text); }
private boolean onArrowLeft(KeyboardEvent event) { if (noContentCheck()) return true; final int count = model.getRowCount(); if (hotPointY < 0 || hotPointY >= count) { environment.hint(Hints.EMPTY_LINE); return true; } if (hotPointX < initialHotPointX) hotPointX = initialHotPointX; if (getColUnderPos(hotPointX) < 0) hotPointX = initialHotPointX; final int currentCol = getColUnderPos(hotPointX); final int currentColWidth = colWidth[currentCol]; final int colStartPos = getColStartPos(currentCol); final TableCell c = new TableCell( hotPointX - colStartPos, cellShift, currentColWidth, appearance.getCellText(model, currentCol, hotPointY)); if (!c.movePrev()) { if (currentCol <= 0) { environment.hint(Hints.TABLE_BEGIN_OF_ROW); return true; } final String prevColText = appearance.getCellText(model, currentCol - 1, hotPointY); final int prevColWidth = colWidth[currentCol - 1]; final int prevColStartPos = getColStartPos(currentCol - 1); if (prevColText.length() > prevColWidth) { hotPointX = prevColStartPos + prevColWidth; cellShift = prevColText.length() - prevColWidth; } else { cellShift = 0; hotPointX = prevColStartPos + prevColText.length(); } environment.hint(Hints.TABLE_END_OF_COL); environment.onAreaNewContent(this); environment.onAreaNewHotPoint(this); return true; } cellShift = c.shift; hotPointX = c.pos + colStartPos; if (c.pos == c.width) // Should never happen; environment.hint(Hints.TABLE_END_OF_COL); else environment.sayLetter(c.line.charAt(c.pos + c.shift)); environment.onAreaNewContent(this); environment.onAreaNewHotPoint(this); return true; }
public void dispose(TableCell cell) { // only dispose of image here, this method is reused in other methods Graphic graphic = cell.getGraphic(); if (graphic instanceof UISWTGraphic) { final Image img = ((UISWTGraphic) graphic).getImage(); if (img != null && !img.isDisposed()) img.dispose(); } }
private boolean onArrowRight(KeyboardEvent event) { if (noContentCheck()) return true; final int count = model.getRowCount(); if (hotPointY < 0 || hotPointY >= count) { environment.hint(Hints.EMPTY_LINE); return true; } // Checking that hot point not before proper line begin; if (hotPointX < initialHotPointX) hotPointX = initialHotPointX; if (getColUnderPos(hotPointX) < 0) hotPointX = initialHotPointX; final int currentCol = getColUnderPos(hotPointX); final int currentColWidth = colWidth[currentCol]; final int colStartPos = getColStartPos(currentCol); final int nextColStartPos = colStartPos + colWidth[currentCol] + 1; final TableCell c = new TableCell( hotPointX - colStartPos, cellShift, currentColWidth, appearance.getCellText(model, currentCol, hotPointY)); if (!c.moveNext()) { if (currentCol + 1 >= colWidth.length) { environment.hint(Hints.TABLE_END_OF_ROW); return true; } cellShift = 0; hotPointX = nextColStartPos; final String nextColText = appearance.getCellText(model, currentCol + 1, hotPointY); if (!nextColText.isEmpty()) environment.sayLetter(nextColText.charAt(0)); else environment.hint( currentCol + 2 < colWidth.length ? Hints.TABLE_END_OF_COL : Hints.TABLE_END_OF_ROW); environment.onAreaNewContent(this); environment.onAreaNewHotPoint(this); return true; } cellShift = c.shift; hotPointX = c.pos + colStartPos; if (c.pos + c.shift >= c.line.length()) environment.hint( currentCol + 1 < colWidth.length ? Hints.TABLE_END_OF_COL : Hints.TABLE_END_OF_ROW); else environment.sayLetter(c.line.charAt(c.pos + c.shift)); environment.onAreaNewContent(this); environment.onAreaNewHotPoint(this); return true; }
private Block createEntradaIzquierdaCentroDatos() { Block block = new Block(); BaseTable table = new BaseTable(new EntradaReportStyle(), 3, "2.5cm", "1.8cm", "2.1cm"); Block titulo = new Block(); titulo.setFontSize("14pt"); titulo.setFontStyle(FontStyleType.ITALIC); titulo.getContent().add(this.titulo); titulo.setMarginBottom("0.2cm"); table.withNewRow(); table.withNewCell(titulo, "3"); table.withNewRow(); table.withNewCell(ResourceProperties.getProperty(locale, "entrada.fecha")); table.withNewCell(ResourceProperties.getProperty(locale, "entrada.hora")); table.withNewCell(ResourceProperties.getProperty(locale, "entrada.apertura")); table.withNewRow(); table.withNewCell(this.fecha); table.withNewCell(this.hora); table.withNewCell(this.horaApertura); table.withNewRow(); TableCell cell = table.withNewCell(ResourceProperties.getProperty(locale, "entrada.zona"), "3"); cell.setPaddingTop("0.2cm"); Block zona = new Block(); zona.getContent().add(this.zona); zona.setFontSize("12pt"); table.withNewRow(); table.withNewCell(zona, "3"); if (this.fila != null && this.numero != null) { table.withNewRow(); table.withNewCell( ResourceProperties.getProperty(locale, "entrada.butaca", this.fila, this.numero), "3"); } block.getContent().add(table); return block; }
@Override public String toString() { final StringBuilder builder = new StringBuilder(); for (int row = 1; row <= currentRow; row += 1) { final StringBuilder top = new StringBuilder(); final StringBuilder middle = new StringBuilder(); final StringBuilder bottom = new StringBuilder(); for (int column = 1; column <= maxColumn; column += 1) { final GridPosition position = new GridPosition(row, column); final TableCell cell = grid.get(position); if (cell == null) { top.append(" "); middle.append(" "); bottom.append(" "); } else { final GridArea gridArea = cell.getGridArea(); if (row == gridArea.startRow) { top.append("-----"); } else { top.append(" "); } if (row == gridArea.endRow) { bottom.append("-----"); } else { bottom.append(" "); } if (column == gridArea.startColumn) { middle.append("|"); } else { middle.append(" "); } middle.append(Long.toString(cell.hashCode()).substring(0, 3)); if (column == gridArea.endColumn) { middle.append("|"); } else { middle.append(" "); } } } builder.append(top.toString()).append("\n"); builder.append(middle.toString()).append("\n"); builder.append(bottom.toString()).append("\n"); } return builder.toString(); }
private BaseTable createEntradaDerechaArriba() { BaseTable table = new BaseTable(new EntradaReportStyle(), 2, "3.5cm", "2cm"); table.withNewRow(); table.withNewCell(createTextParanimf("18pt")); TableCell cell = table.withNewCell(logoUji()); cell.setTextAlign(TextAlignType.CENTER); cell.setDisplayAlign(DisplayAlignType.CENTER); table.withNewRow(); table.withNewCell(ResourceProperties.getProperty(locale, "entrada.nombreEntidad"), "2"); table.withNewRow(); table.withNewCell(ResourceProperties.getProperty(locale, "entrada.direccion"), "2"); return table; }
// @see // org.gudy.azureus2.plugins.ui.tables.TableCellRefreshListener#refresh(org.gudy.azureus2.plugins.ui.tables.TableCell) public void refresh(TableCell cell) { VuzeActivitiesEntry entry = (VuzeActivitiesEntry) cell.getDataSource(); if (entry == null) return; if (!cell.setSortValue(entry.getTypeID()) && cell.isValid()) { return; } DownloadManager dm = entry.getDownloadManger(); boolean canPlay = PlayUtils.canPlayDS(entry, -1, false); boolean canDL = dm == null && entry.getDownloadManger() == null && (entry.getTorrent() != null || entry.getAssetHash() != null); boolean canRun = !canPlay && dm != null; if (canRun && dm != null && !dm.getAssumedComplete()) { canRun = false; } StringBuffer sb = new StringBuffer(); if (canDL) { if (sb.length() > 0) { sb.append(" | "); } sb.append("<A HREF=\"download\">Download</A>"); } if (canPlay) { if (sb.length() > 0) { sb.append(" | "); } sb.append("<A HREF=\"play\">Play</A>"); } if (canRun) { if (sb.length() > 0) { sb.append(", "); } sb.append("<A HREF=\"launch\">Launch</A>"); } cell.getTableRow().setData("text", sb.toString()); }
private BaseTable createEntradaIzquierdaCentro() { BaseTable table = new BaseTable(new EntradaReportStyle(), 4, "3cm", "7.2cm", "0.2cm", "0.6cm"); table.setMarginTop("0.2cm"); table.withNewRow(); TableCell cellIzquierda = table.withNewCell(createEntradaIzquierdaCentroFoto()); cellIzquierda.setPadding("0.2cm"); cellIzquierda.setBackgroundColor(FONDO_BLANCO); TableCell cellEnmedio = table.withNewCell(createEntradaIzquierdaCentroDatos()); cellEnmedio.setPadding("0.2cm"); cellEnmedio.setBackgroundColor(FONDO_BLANCO); // Espacio a la izquierda de bloque negro table.withNewCell(""); TableCell cell = table.withNewCell(""); cell.setPaddingLeft("0.2cm"); cell.setBackgroundColor("black"); return table; }
/** @return true if the grid unit is the last in column spanning direction */ public boolean isLastGridUnitColSpan() { return (colSpanIndex == cell.getNumberColumnsSpanned() - 1); }
public IStructuralBox getRowChild(final GridPosition position) { final TableCell cell = grid.get(position); if (cell == null) { return null; } return cell.accept( new ParentTraversal<IStructuralBox>() { @Override public IStructuralBox visit(final HorizontalBar box) { return visitStructuralBox(box); } @Override public IStructuralBox visit(final List box) { return visitStructuralBox(box); } @Override public IStructuralBox visit(final ListItem box) { return visitStructuralBox(box); } @Override public IStructuralBox visit(final Paragraph box) { return visitStructuralBox(box); } @Override public IStructuralBox visit(final StructuralFrame box) { return visitStructuralBox(box); } @Override public IStructuralBox visit(final StructuralNodeReference box) { return visitStructuralBox(box); } @Override public IStructuralBox visit(final Table box) { return visitStructuralBox(box); } @Override public IStructuralBox visit(final TableCell box) { return visitStructuralBox(box); } @Override public IStructuralBox visit(final TableColumnSpec box) { return visitStructuralBox(box); } @Override public IStructuralBox visit(final TableRow box) { return null; } @Override public IStructuralBox visit(final TableRowGroup box) { return visitStructuralBox(box); } @Override public IStructuralBox visit(final VerticalBlock box) { return visitStructuralBox(box); } private IStructuralBox visitStructuralBox(final IStructuralBox box) { if (box.getParent() instanceof TableRow) { return box; } return box.getParent().accept(this); } }); }
private BaseTable createEntradaDerechaCentro() { BaseTable table = new BaseTable(new EntradaReportStyle(), 2, "2.5cm", "2.5cm"); String margin = "0.3cm"; table.setMarginTop("0.5cm"); table.setMarginBottom(margin); table.setMarginLeft(margin); table.setMarginRight(margin); table.setBackgroundColor(FONDO_BLANCO); Block titulo = new Block(); titulo.setFontSize("14pt"); titulo.setFontStyle(FontStyleType.ITALIC); titulo.getContent().add(this.titulo); titulo.setMarginBottom("0.2cm"); table.withNewRow(); TableCell tituloCell = table.withNewCell(titulo, "2"); tituloCell.setPaddingTop("0.2cm"); table.withNewRow(); table.withNewCell(ResourceProperties.getProperty(locale, "entrada.fecha")); table.withNewCell(ResourceProperties.getProperty(locale, "entrada.hora")); table.withNewRow(); table.withNewCell(this.fecha); table.withNewCell(this.hora); table.withNewRow(); TableCell aperturaCell = table.withNewCell(ResourceProperties.getProperty(locale, "entrada.apertura"), "2"); aperturaCell.setPaddingTop("0.2cm"); table.withNewRow(); table.withNewCell(this.horaApertura, "2"); table.withNewRow(); TableCell cell = table.withNewCell(ResourceProperties.getProperty(locale, "entrada.zona"), "2"); cell.setPaddingTop("0.2cm"); Block zona = new Block(); zona.getContent().add(this.zona); zona.setFontSize("12pt"); table.withNewRow(); TableCell zonaCell = table.withNewCell(zona, "2"); if (this.fila != null && this.numero != null) { table.withNewRow(); TableCell butacaCell = table.withNewCell( ResourceProperties.getProperty(locale, "entrada.butaca", this.fila, this.numero), "2"); butacaCell.setPaddingBottom("0.2cm"); } else { zonaCell.setPaddingBottom("0.2cm"); } return table; }
// @see // org.gudy.azureus2.plugins.ui.tables.TableCellAddedListener#cellAdded(org.gudy.azureus2.plugins.ui.tables.TableCell) public void cellAdded(TableCell cell) { cell.setMarginHeight(0); }
public Cell(TableCell cell) { cell.setFillCell(true); cell.addListeners(this); }
public void refresh(TableCell cell, boolean sortOnly) { final DiskManagerFileInfo fileInfo = (DiskManagerFileInfo) cell.getDataSource(); int percentDone = 0; if (fileInfo != null && fileInfo.getLength() != 0) percentDone = (int) ((1000 * fileInfo.getDownloaded()) / fileInfo.getLength()); cell.setSortValue(percentDone); if (sortOnly) { dispose(cell); return; } // Compute bounds ... int newWidth = cell.getWidth(); if (newWidth <= 0) return; final int newHeight = cell.getHeight(); final int x1 = newWidth - borderWidth - 1; final int y1 = newHeight - borderWidth - 1; if (x1 < 10 || y1 < 3) return; final DiskManager manager = fileInfo.getDiskManager(); // we want to run through the image part once one the transition from with a disk manager // (running) // to without a disk manager (stopped) in order to clear the pieces view boolean running = manager != null; boolean hasGraphic = false; Graphic graphic = cell.getGraphic(); if (graphic instanceof UISWTGraphic) { Image img = ((UISWTGraphic) graphic).getImage(); hasGraphic = img != null && !img.isDisposed(); } final boolean bImageBufferValid = (lastPercentDone == percentDone) && cell.isValid() && bNoRed && running == was_running && hasGraphic; if (bImageBufferValid) return; was_running = running; lastPercentDone = percentDone; Image piecesImage = null; if (graphic instanceof UISWTGraphic) piecesImage = ((UISWTGraphic) graphic).getImage(); if (piecesImage != null && !piecesImage.isDisposed()) piecesImage.dispose(); if (!running) { cell.setGraphic(null); return; } piecesImage = new Image(SWTThread.getInstance().getDisplay(), newWidth, newHeight); final GC gcImage = new GC(piecesImage); // dm may be null if this is a skeleton file view DownloadManager download_manager = fileInfo.getDownloadManager(); PEPeerManager peer_manager = download_manager == null ? null : download_manager.getPeerManager(); PEPiece[] pe_pieces = peer_manager == null ? null : peer_manager.getPieces(); final long now = SystemTime.getCurrentTime(); if (fileInfo != null && manager != null) { if (percentDone == 1000) { gcImage.setForeground(Colors.blues[Colors.BLUES_DARKEST]); gcImage.setBackground(Colors.blues[Colors.BLUES_DARKEST]); gcImage.fillRectangle(1, 1, newWidth - 2, newHeight - 2); } else { final int firstPiece = fileInfo.getFirstPieceNumber(); final int nbPieces = fileInfo.getNbPieces(); final DiskManagerPiece[] dm_pieces = manager.getPieces(); bNoRed = true; for (int i = 0; i < newWidth; i++) { final int a0 = (i * nbPieces) / newWidth; int a1 = ((i + 1) * nbPieces) / newWidth; if (a1 == a0) a1++; if (a1 > nbPieces && nbPieces != 0) a1 = nbPieces; int nbAvailable = 0; boolean written = false; boolean partially_written = false; if (firstPiece >= 0) for (int j = a0; j < a1; j++) { final int this_index = j + firstPiece; final DiskManagerPiece dm_piece = dm_pieces[this_index]; if (dm_piece.isDone()) nbAvailable++; if (written) continue; if (pe_pieces != null) { PEPiece pe_piece = pe_pieces[this_index]; if (pe_piece != null) written = written || (pe_piece.getLastDownloadTime(now) + 500) > last_draw_time; } if ((!written) && (!partially_written)) { final boolean[] blocks = dm_piece.getWritten(); if (blocks != null) for (int k = 0; k < blocks.length; k++) if (blocks[k]) { partially_written = true; break; } } } // for j else nbAvailable = 1; gcImage.setBackground( written ? Colors.red : partially_written ? Colors.grey : Colors.blues[(nbAvailable * Colors.BLUES_DARKEST) / (a1 - a0)]); gcImage.fillRectangle(i, 1, 1, newHeight - 2); if (written) bNoRed = false; } gcImage.setForeground(Colors.grey); } } else gcImage.setForeground(Colors.grey); if (manager != null) gcImage.drawRectangle(0, 0, newWidth - 1, newHeight - 1); gcImage.dispose(); last_draw_time = now; if (cell instanceof TableCellSWT) ((TableCellSWT) cell).setGraphic(piecesImage); else cell.setGraphic(new UISWTGraphicImpl(piecesImage)); }
/** @return true if the grid unit is the last in row spanning direction */ public boolean isLastGridUnitRowSpan() { return (rowSpanIndex == cell.getNumberRowsSpanned() - 1); }
/** * Creates a new grid unit. * * @param cell table cell which occupies this grid unit * @param colSpanIndex index of this grid unit in the span, in column direction * @param rowSpanIndex index of this grid unit in the span, in row direction */ protected GridUnit(TableCell cell, int colSpanIndex, int rowSpanIndex) { this(colSpanIndex, rowSpanIndex); this.cell = cell; setBorders(cell.getTable()); }
private void creaSeccionEntrada(String urlPublic) { Block entradaBlock = withNewBlock(); EntradaReportStyle style = new EntradaReportStyle(); BaseTable entradaTable = new BaseTable(style, 2, "11.8cm", "6.1cm"); entradaTable.withNewRow(); TableCell cellIzquierda = entradaTable.withNewCell(createEntradaIzquierda(urlPublic)); cellIzquierda.setPadding("0.3cm"); cellIzquierda.setPaddingTop("0.0cm"); cellIzquierda.setBackgroundColor(FONDO_GRIS); TableCell cellDerecha = entradaTable.withNewCell(createEntradaDerecha()); cellDerecha.setPadding("0.3cm"); cellDerecha.setPaddingTop("0.3cm"); cellDerecha.setBackgroundColor(FONDO_GRIS); cellDerecha.setBorderLeftWidth("0.03cm"); cellDerecha.setBorderLeftColor("white"); cellDerecha.setBorderLeftStyle(BorderStyleType.DOTTED); TableRow rowAbajo = entradaTable.withNewRow(); rowAbajo.setBackgroundColor(FONDO_GRIS); entradaTable.withNewCell(ResourceProperties.getProperty(locale, "entrada.entradaValida"), "2"); entradaBlock.getContent().add(entradaTable); }