PackageReadyWidget(MonitorItem monItem, int idx, boolean markAlreadyActivated) { _monItem= monItem; _idx= idx; BackgroundStatus bgStat= monItem.getStatus(); PackageProgress bundle= bgStat.getPartProgress(idx); FlexTable fp= new FlexTable(); HTMLTable.CellFormatter formatter= fp.getCellFormatter(); String desc= bgStat.getPackageCount()==1 ? "" : ZIP_ROOT_TXT + (idx+1); fp.setWidget(0,0,makeDownloadNowButton(bundle.getURL(),desc,idx)); formatter.setWidth(0,0,"100px"); fp.setWidget(0,4,_icon); setShowRetrivedIcon(markAlreadyActivated ? FileDownloadStatus.DONE : FileDownloadStatus.NONE); formatter.setWidth(0,4,"20px"); formatter.setHorizontalAlignment(0,4, HasHorizontalAlignment.ALIGN_RIGHT); Label dSize= new Label(StringUtils.getSizeAsString(bundle.getFinalCompressedBytes(),true)); fp.setWidget(0,2,dSize); formatter.setWidth(0,2,"65px"); formatter.setHorizontalAlignment(0,2, HasHorizontalAlignment.ALIGN_RIGHT); initWidget(fp); }
public void createTopGrid(HashMap<Metrics,Metric> metric){ //build top grid this.setWidth("410px"); this.setStyleName("statistics-panel-top"); //this.setStyleName("table-row-highlight"); //NumberFormat numFormat = NumberFormat.getDecimalFormat(); //NumberFormat sciNotFormat = NumberFormat.getScientificFormat(); HTMLTable.ColumnFormatter colF = this.getColumnFormatter(); colF.setWidth(0, "110px"); colF.setWidth(2,"135px"); //Grid Row 1 Cell 0,0 Mean Metric mean = metric.get(Metrics.MEAN); this.setHTML(0,0,"<b>"+_prop.getName("mean-flux")+"</b><br>" + WebDefaultMouseReadoutHandler.formatFlux(mean.getValue()) + " " + mean.getUnits()); //Grid Row 1 Cell 0,1 Std Dev Metric stdDev = metric.get(Metrics.STDEV); this.setHTML(0,1,"<b>" + _prop.getName("std-dev") + "</b><br>" + WebDefaultMouseReadoutHandler.formatFlux(stdDev.getValue()) + " " + stdDev.getUnits()); //Grid Row 1 Cell 0,2 Integrated Flux Metric integrated = metric.get(Metrics.INTEGRATED_FLUX); this.setHTML(0,2,"<b>" + _prop.getName("int-flux") + "</b><br>" + WebDefaultMouseReadoutHandler.formatFlux(integrated.getValue()) + " " + integrated.getUnits()); }
/** * Executes on clicking a cell. * * @param cell the cell clicked on. */ private void cellClicked(HTMLTable.Cell cell) { if (cell != null) { int row = cell.getRowIndex(); int column = cell.getCellIndex(); // Ignore headers. if (row > 0 && column > 0) { // Unhighlight currently selected cell. if (selectedCell != null) { baseGrid.getCellFormatter().removeStyleName(selectedCell.getFirst(), selectedCell.getSecond(), "tty-RiskCellSelected"); } baseGrid.getCellFormatter().addStyleName(row, column, "tty-RiskCellSelected"); selectedCell = new Pair<Integer, Integer>(row, column); ValueChangeEvent.fire(this, selectedCell); } } }
/** * Applies the CSS header styles to a GWT table. * * @param table * The GWT table. * @param applyToRows * If the first column contains also headers (double entry array). */ public static void applyHeaderStyles(HTMLTable table, boolean applyToRows) { // Rows. if (applyToRows) { for (int row = 0; row < table.getRowCount(); row++) { applyRowStyles(table, row); applyRowHeaderStyles(table, row, 0); // for (int column = 0; column < table.getCellCount(row); column++) { // // } } } // Columns. for (int column = 0; column < table.getCellCount(0); column++) { applyColumnHeaderStyles(table, 0, column); } }
/** * Applies the CSS content style to a cell. * * @param table * The GWT table. * @param row * The row index. * @param column * The column index. * @param first * If the cell is the first of its row. * @param last * If the cell is the last of its row. */ public static void applyCellStyles(HTMLTable table, int row, int column, boolean first, boolean last) { table.getCellFormatter().addStyleName(row, column, "x-grid3-col"); table.getCellFormatter().addStyleName(row, column, "x-grid3-cell"); table.getCellFormatter().addStyleName(row, column, "html-table-cell"); if (first) { table.getCellFormatter().addStyleName(row, column, "x-grid3-cell-first"); } if (last) { table.getCellFormatter().addStyleName(row, column, "x-grid3-cell-last"); table.getCellFormatter().addStyleName(row, column, "html-table-cell-last"); } final Widget w = table.getWidget(row, column); if (w != null) { w.addStyleName("x-grid3-cell-inner"); } }
/** * {@inheritDoc} */ @Override public HTMLTable buildBannerTable(final int rows, final int cols) { final Grid gridLayout = new Grid(rows, cols); gridLayout.addStyleName(ProjectView.STYLE_HEADER_BANNER_FLEX); gridLayout.setCellPadding(0); gridLayout.setCellSpacing(0); gridLayout.setWidth("100%"); gridLayout.setHeight("100%"); for (int i = 0; i < gridLayout.getColumnCount() - 1; i++) { gridLayout.getColumnFormatter().setWidth(i, "325px"); } return gridLayout; }
@Test public void testAddBottomAndRightPaddingToTableCells() throws Exception { final Element cellOne = mock(Element.class); final Element cellTwo = mock(Element.class); final HTMLTable.CellFormatter cellFormatter = mock(HTMLTable.CellFormatter.class); final FlexTable testedTable = mock(FlexTable.class); doReturn(1).when(testedTable).getRowCount(); doReturn(2).when(testedTable).getCellCount(0); doReturn(cellFormatter).when(testedTable).getCellFormatter(); doReturn(cellOne).when(cellFormatter).getElement(0, 0); doReturn(cellTwo).when(cellFormatter).getElement(0, 1); ScenarioUtils.addBottomAndRightPaddingToTableCells(testedTable); verify(cellOne).setAttribute("style", ScenarioUtils.BOTTOM_RIGHT_PADDING); verify(cellTwo).setAttribute("style", ScenarioUtils.BOTTOM_RIGHT_PADDING); }
/** * Sets the horizontal alignment of all cells of the specified table. * @param table table whose cells to be aligned * @param hAlignment horizontal alignment to be set */ public static void alignTableCells( final HTMLTable table, final HorizontalAlignmentConstant hAlignment ) { final CellFormatter cellFormatter = table.getCellFormatter(); for ( int i = table.getRowCount() - 1; i >= 0; i-- ) for ( int j = table.getCellCount( i ) - 1; j >= 0; j-- ) cellFormatter.setHorizontalAlignment( i, j, hAlignment ); }
private void loadTableIntoPanel(DataSet ds, double pixScale, long fileSize){ //set column widths List<BaseTableData.RowData> rows = ds.getModel().getRows(); int rowLength = 170; int dataLength; String rowValue; for(BaseTableData.RowData row : rows){ rowValue = row.getValue(3); dataLength = rowValue.length()*6; //set column width to size of text if(dataLength > rowLength){ rowLength = dataLength; } } TableDataView.Column c = ds.getColumn(0); c.setWidth(25); c = ds.getColumn(1); c.setWidth(100); c = ds.getColumn(2); c.setWidth(100); c = ds.getColumn(3); c.setWidth(rowLength); BasicTable table = new BasicTable(ds); table.setSize("470px", "375px"); // String[] str = values.split(";"); Grid grid = new Grid (1,2); HTMLTable.ColumnFormatter colF = grid.getColumnFormatter(); colF.setWidth(0, "200px"); grid.setHTML(0,0,"<b>Pixel Size:</b> " + _nfPix.format(pixScale)+ "''"); grid.setHTML(0,1,"<b>File Size:</b> " + StringUtils.getSizeAsString(fileSize)); _panel.add(grid); _panel.add(table); }
private VerticalPanel loadTable(DataSet ds, double pixScale, long fileSize){ VerticalPanel vp = new FitsHeaderPanel(); //set column widths List<BaseTableData.RowData> rows = ds.getModel().getRows(); int rowLength = 170; int dataLength; String rowValue; for(BaseTableData.RowData row : rows){ rowValue = row.getValue(3); dataLength = rowValue.length()*6; //set column width to size of text if(dataLength > rowLength){ rowLength = dataLength; } } TableDataView.Column c = ds.getColumn(0); c.setWidth(25); c = ds.getColumn(1); c.setWidth(75); c = ds.getColumn(2); c.setWidth(100); c = ds.getColumn(3); c.setWidth(rowLength); BasicTable table = new BasicTable(ds); table.setSize("400px", "375px"); Grid grid = new Grid (1,2); HTMLTable.ColumnFormatter colF = grid.getColumnFormatter(); colF.setWidth(0, "200px"); grid.setHTML(0,0,"<b>Pixel Size:</b> " + _nfPix.format(pixScale)+ "''"); grid.setHTML(0,1,"<b>File Size:</b> " + StringUtils.getSizeAsString(fileSize)); vp.add(grid); vp.add(table); return vp; }
public void onClick(ClickEvent ev) { HTMLTable.Cell cell= grid.getCellForEvent(ev); if (cell!=null) { int row= cell.getRowIndex(); int col= cell.getCellIndex(); float sat= (float)col / 15.0f; float val= 1.0f - (float)row / 15.0f; setSaturationAndValue(sat, val); ValueChangeEvent.fire(this, sat + " " + val); } }
public void onClick(ClickEvent ev) { HTMLTable.Cell cell= grid.getCellForEvent(ev); if (cell!=null) { int row= cell.getRowIndex(); // int col= cell.getCellIndex(); if (row>0) { float hue= (float)(row-1) / 18.0f * 360.0f; setHue(hue); ValueChangeEvent.fire(this,hue+""); } } }
/** * Applies the CSS column-header styles to a cell. * * @param table * The GWT table. * @param row * The row index. * @param column * The column index. */ public static void applyColumnHeaderStyles(HTMLTable table, int row, int column) { table.getCellFormatter().addStyleName(row, column, "x-grid3-header"); table.getCellFormatter().addStyleName(row, column, "x-grid3-hd"); table.getCellFormatter().addStyleName(row, column, "x-grid3-hd-row"); table.getCellFormatter().addStyleName(row, column, "x-grid3-td-favorite"); table.getCellFormatter().addStyleName(row, column, "x-grid3-cell"); final Widget w = table.getWidget(row, column); if (w != null) { w.addStyleName("x-grid3-hd-inner"); w.addStyleName("x-grid3-hd-favorite "); w.addStyleName("x-component"); } }
public SubmissionAdminTable(SubmissionUISummary summary) { ArrayList<Column> tableHeaders = summary.getHeaders(); ArrayList<SubmissionUI> tableSubmissions = summary.getSubmissions(); addStyleName("dataTable"); getElement().setId("submission_table"); // setup header int headerIndex = 0; setHTML(0, headerIndex++, BLANK_VALUE); // delete button setHTML(0, headerIndex++, BLANK_VALUE); // mark submission as complete for (Column column : tableHeaders) { setText(0, headerIndex++, column.getDisplayHeader().replace(":", "\n")); } setHTML(0, headerIndex, BLANK_VALUE); setColumnFormatter(new HTMLTable.ColumnFormatter()); getColumnFormatter().addStyleName(headerIndex, "blank-submission-column"); getRowFormatter().addStyleName(0, "titleBar"); // create rows int rowPosition = 1; for (SubmissionUI row : tableSubmissions) { int valueIndex = 0; // index matches to column headers int columnPosition = 0; // position matches to position in table // add delete button DeleteSubmissionButton deleteButton = new DeleteSubmissionButton(row.getSubmissionKeyAsString()); setWidget(rowPosition, columnPosition, deleteButton); columnPosition++; // add mark complete button MarkSubmissionCompleteButton markCompleteButton = new MarkSubmissionCompleteButton(row.getSubmissionKeyAsString()); setWidget(rowPosition, columnPosition, markCompleteButton); columnPosition++; // generate row for (final String value : row.getValues()) { switch (tableHeaders.get(valueIndex++).getUiDisplayType()) { case BINARY: if (value == null) { setText(rowPosition, columnPosition, BasicConsts.EMPTY_STRING); } else { Image image = new Image(value + UIConsts.PREVIEW_SET); image.addClickHandler(new BinaryPopupClickHandler(value, false)); setWidget(rowPosition, columnPosition, image); } break; case REPEAT: if (value == null) { setText(rowPosition, columnPosition, BasicConsts.EMPTY_STRING); } else { RepeatViewButton repeat = new RepeatViewButton(value); setWidget(rowPosition, columnPosition, repeat); } break; default: setText(rowPosition, columnPosition, value); } columnPosition++; } setHTML(rowPosition, columnPosition, BLANK_VALUE); if (rowPosition % 2 == 0) { getRowFormatter().setStyleName(rowPosition, "evenTableRow"); } rowPosition++; } }
public static Widget buildActivationUI(String text, String tip, final MonitorItem monItem, final int idx, final BackgroundActivation bActivate, boolean markAlreadyActivated) { final Image icon= new Image(RETRIEVED_ICON); icon.setVisible(markAlreadyActivated); Widget button= GwtUtil.makeLinkButton(text, tip, new ClickHandler() { public void onClick(ClickEvent event) { bActivate.activate(monItem,idx, false); icon.setVisible(true); } }); WebEventListener autoActListener= new WebEventListener() { public void eventNotify(WebEvent ev) { if (ev.getSource()==monItem && ev.getName()==Name.MONITOR_ITEM_UPDATE) { if (monItem.isDone() && monItem.isActivated(idx)) { icon.setVisible(true); WebEventManager.getAppEvManager().removeListener(Name.MONITOR_ITEM_UPDATE, monItem,this); } } } }; WebEventManager.getAppEvManager().addListener(Name.MONITOR_ITEM_UPDATE,monItem,autoActListener); FlexTable fp= new FlexTable(); HTMLTable.CellFormatter formatter= fp.getCellFormatter(); fp.setWidget(0,0,button); formatter.setWidth(0,0,"100px"); fp.setWidget(0,4,icon); formatter.setWidth(0,4,"20px"); formatter.setHorizontalAlignment(0,4, HasHorizontalAlignment.ALIGN_RIGHT); return fp; }
/** @return the existing inner HTML of a table cell. */ public static SafeHtml get(HTMLTable t, int row, int col) { return new SafeHtmlString(t.getHTML(row, col)); }
/** Set the inner HTML of a table cell. */ public static <T extends HTMLTable> T set(final T t, int row, int col, SafeHtml str) { t.setHTML(row, col, str.asString()); return t; }
public HTMLTable.CellFormatter getCellFormatter() { return this.table.getCellFormatter(); }
public HTMLTable.ColumnFormatter getColumnFormatter() { return this.table.getColumnFormatter(); }
public HTMLTable.RowFormatter getRowFormatter() { return this.table.getRowFormatter(); }
/** * Returns a collection of classes whose non-abstract methods should always be replaced with * no-ops. By default, this list includes {@link Composite}, {@link DOM} {@link UIObject}, * {@link Widget}, {@link Image}, and most subclasses of {@link Panel}. It will also include any * classes specified via the {@link WithClassesToStub} annotation on the test class. This makes * it much safer to test code that uses or extends these types. * <p> * This list can be customized via {@link WithClassesToStub} or by defining a new test runner * extending {@link GwtMockitoTestRunner} and overriding this method. This allows users to * explicitly stub out particular classes that are causing problems in tests. If you override this * method, you will probably want to retain the classes that are stubbed here by doing something * like this: * * <pre> * @Override * protected Collection<Class<?>> getClassesToStub() { * Collection<Class<?>> classes = super.getClassesToStub(); * classes.add(MyBaseWidget.class); * return classes; * } * </pre> * * @return a collection of classes whose methods should be stubbed with no-ops while running tests */ protected Collection<Class<?>> getClassesToStub() { Collection<Class<?>> classes = new LinkedList<Class<?>>(); classes.add(Composite.class); classes.add(DOM.class); classes.add(UIObject.class); classes.add(Widget.class); classes.add(DataGrid.class); classes.add(HTMLTable.class); classes.add(Image.class); classes.add(AbsolutePanel.class); classes.add(CellList.class); classes.add(CellPanel.class); classes.add(CellTable.class); classes.add(ComplexPanel.class); classes.add(DeckLayoutPanel.class); classes.add(DeckPanel.class); classes.add(DecoratorPanel.class); classes.add(DockLayoutPanel.class); classes.add(DockPanel.class); classes.add(FlowPanel.class); classes.add(FocusPanel.class); classes.add(HorizontalPanel.class); classes.add(HTMLPanel.class); classes.add(LayoutPanel.class); classes.add(Panel.class); classes.add(PopupPanel.class); classes.add(RenderablePanel.class); classes.add(ResizeLayoutPanel.class); classes.add(SimpleLayoutPanel.class); classes.add(SimplePanel.class); classes.add(SplitLayoutPanel.class); classes.add(StackPanel.class); classes.add(VerticalPanel.class); classes.add(ValueListBox.class); WithClassesToStub annotation = unitTestClass.getAnnotation(WithClassesToStub.class); if (annotation != null) { classes.addAll(Arrays.asList(annotation.value())); } return classes; }
/** * Applies the CSS row-header styles to a cell. * * @param table * The GWT table. * @param row * The row index. * @param column * The column index. */ public static void applyRowHeaderStyles(HTMLTable table, int row, int column) { applyColumnHeaderStyles(table, row, column); table.getCellFormatter().addStyleName(row, column, "html-grid-header-row"); }
/** * Applies the CSS row styles to a row. * * @param table * The GWT table. * @param row * The row index. */ public static void applyRowStyles(HTMLTable table, int row) { table.getRowFormatter().addStyleName(row, "x-grid3-hd-row"); table.getRowFormatter().addStyleName(row, "x-grid3-row"); }
HTMLTable buildBannerTable(final int rows, final int cols);