/** * Set the column headers. * */ private void setHeaders() { CellFormatter cellFormatter = headertable.getCellFormatter(); headertable.setWidget(0, 0, new HTML("")); int column = 0; for (int p = 0; p < headers.length; p++) { if ( headers[p].startsWith("\"")) headers[p] = headers[p].substring(1, headers[p].length()); if ( headers[p].endsWith("\"")) headers[p] = headers[p].substring(0,headers[p].length()-1); if ( headers[p].endsWith("_")) headers[p] = headers[p].substring(0, headers[p].length()-1); if ( headers[p].toLowerCase().equals(wocevar.toLowerCase()) ) { headertable.setWidget(0, 1, new HTML(headers[p])); cellFormatter.addStyleName(0, 1, "nowrap"); } else if (headers[p].toLowerCase().equals(datavar.toLowerCase()) ) { headertable.setWidget(0, 2, new HTML(headers[p])); cellFormatter.addStyleName(0, 2, "nowrap"); } else { headertable.setWidget(0, column + columnOffset, new HTML(headers[p])); cellFormatter.addStyleName(0, column + columnOffset, "nowrap"); column++; } } headertable.setWidget(0, 0, allNone); RowFormatter formatter = headertable.getRowFormatter(); formatter.addStyleName(0, "nowrap"); }
private void formatCell(int row, int column){ CellFormatter cellFormatter = usersFlexTable.getCellFormatter(); RowFormatter rowFormatter = usersFlexTable.getRowFormatter(); cellFormatter.setStyleName(row, column, "rdn-GridItem"); for (int i = 0; i < usersFlexTable.getCellCount(0); i++){ cellFormatter.addStyleName(row, i, "rdn-GridItemFooterBottom"); if (row > 0) { cellFormatter.removeStyleName(row - 1, i, "rdn-GridItemFooterBottom"); } } if (row%2 == 0){ rowFormatter.addStyleName(row, "rdn-GridAlternateRow"); } }
private void applyDataRowStyles(FlexTable grid) { RowFormatter rf = grid.getRowFormatter(); for (int row = 0; row < grid.getRowCount(); ++row) { if ((row % 2) != 0) { rf.addStyleName(row, "FlexTable-OddRow"); } else { rf.addStyleName(row, "FlexTable-EvenRow"); } } }
private void styleLocationDataRow(int row, String value) { RowFormatter fmt = location.getRowFormatter(); if (value == null || value.length() == 0) { fmt.removeStyleName(row, CLASS_MATCH); fmt.removeStyleName(row, CLASS_NO_MATCH); } else if (value.equals(token)) { fmt.addStyleName(row, CLASS_MATCH); } else { fmt.addStyleName(row, CLASS_NO_MATCH); } }
/** * start * * @param path * @param propertyGroup * @param widget * @param propertyGroupWidgetToFire */ private void start(String path, GWTPropertyGroup propertyGroup, Widget widget, PropertyGroupWidgetToFire propertyGroupWidgetToFire) { propertyGroupHandlerExtensionList = new ArrayList<PropertyGroupHandlerExtension>(); manager = new FormManager(); this.path = path; this.propertyGroup = propertyGroup; this.propertyGroupWidgetToFire = propertyGroupWidgetToFire; VerticalPanel vPanel = new VerticalPanel(); vPanel.setWidth("100%"); FlexTable propertyGroupTable = manager.getTable(); propertyGroupTable.setWidth("100%"); FlexTable widgetTable = new FlexTable(); widgetTable.setCellPadding(0); widgetTable.setCellSpacing(0); widgetTable.setWidth("100%"); widgetTable.setWidget(0, 0, widget); widgetTable.getFlexCellFormatter().setColSpan(0, 0, 2); // Widget format widgetTable.getCellFormatter().setHorizontalAlignment(0, 0, HasAlignment.ALIGN_CENTER); widgetTable.getCellFormatter().setVerticalAlignment(0, 0, HasAlignment.ALIGN_MIDDLE); RowFormatter rowFormatter = widgetTable.getRowFormatter(); rowFormatter.setStyleName(0, "okm-Security-Title"); cellFormatter = widgetTable.getCellFormatter(); // Gets the cell formatter // Format borders and margins cellFormatter.addStyleName(0, 0, "okm-Security-Title-RightBorder"); vPanel.add(widgetTable); scrollPropertyGroup = new ScrollPanel(); scrollPropertyGroup.add(propertyGroupTable); vPanel.add(scrollPropertyGroup); initWidget(vPanel); }
public CategoriesWidget(String docPath, Widget widget) { table = new FlexTable(); tableSubscribedCategories = new FlexTable(); assignedCategories = new ArrayList<GWTFolder>(); this.docPath = docPath; cellFormatter = table.getCellFormatter(); // Gets the cell formatter table.setWidth("100%"); table.setCellPadding(0); table.setCellSpacing(2); table.setWidget(0, 0, widget); table.getFlexCellFormatter().setColSpan(0, 0, 2); cellFormatter.addStyleName(0, 0, "okm-Security-Title-RightBorder"); // Border and margins RowFormatter rowFormatter = table.getRowFormatter(); rowFormatter.setStyleName(0, "okm-Security-Title"); // Widget format cellFormatter.setHorizontalAlignment(0, 0, HasAlignment.ALIGN_CENTER); cellFormatter.setVerticalAlignment(0, 0, HasAlignment.ALIGN_MIDDLE); // Categories vPanel = new VerticalPanel(); vPanel.setWidth("390px"); vPanel.setHeight("175px"); scrollDirectoryPanel = new ScrollPanel(); scrollDirectoryPanel.setSize("380px", "150px"); scrollDirectoryPanel.setStyleName("okm-Popup-text"); verticalDirectoryPanel = new VerticalPanel(); verticalDirectoryPanel.setSize("100%", "100%"); folderSelectTree = new FolderSelectTree(); folderSelectTree.setSize("100%", "100%"); verticalDirectoryPanel.add(folderSelectTree); scrollDirectoryPanel.add(verticalDirectoryPanel); actionButton = new Button(Main.i18n("button.add"), new ClickHandler() { @Override public void onClick(ClickEvent event) { addCategory(folderSelectTree.getCategory()); } }); actionButton.setEnabled(false); vPanel.add(scrollDirectoryPanel); vPanel.add(actionButton); vPanel.setCellHorizontalAlignment(scrollDirectoryPanel, HasAlignment.ALIGN_CENTER); vPanel.setCellHorizontalAlignment(actionButton, HasAlignment.ALIGN_CENTER); vPanel.setCellVerticalAlignment(actionButton, HasAlignment.ALIGN_MIDDLE); vPanel.setCellHeight(scrollDirectoryPanel, "150px"); vPanel.setCellHeight(actionButton, "25px"); table.setWidget(1, 0, vPanel); table.getFlexCellFormatter().setColSpan(1, 0, 2); cellFormatter.setHorizontalAlignment(1, 0, HasAlignment.ALIGN_CENTER); table.setHTML(2, 0, " <b>" + Main.i18n("document.categories") + "</b>"); table.getFlexCellFormatter().setColSpan(2, 0, 2); cellFormatter.setHorizontalAlignment(2, 0, HasAlignment.ALIGN_LEFT); table.setWidget(3, 0, tableSubscribedCategories); table.getFlexCellFormatter().setColSpan(3, 0, 2); cellFormatter.setHorizontalAlignment(3, 0, HasAlignment.ALIGN_LEFT); setRowWordWarp(0, 0, true, tableSubscribedCategories); table.setStyleName("okm-DisableSelect"); actionButton.setStyleName("okm-AddButton"); tableSubscribedCategories.setStyleName("okm-DisableSelect"); // Resets to initial tree value folderSelectTree.reset(); initWidget(table); }
private void renderInfoRow( final FileStatInfo info, final FlexTable table, final ClickHandler googleAccountClickHandler ) { final CellFormatter cellFormatter = table.getCellFormatter(); final RowFormatter rowFormatter = table.getRowFormatter(); int column = 0; table.setWidget( row, column++, new Label( userCounter + "." ) ); cellFormatter.setHorizontalAlignment( row, column-1, HasHorizontalAlignment.ALIGN_RIGHT ); final VerticalPanel userPanel = new VerticalPanel(); if ( info.getAddressedBy() != null ) userPanel.add( ClientUtils.styledWidget( new Label( info.getAddressedBy() + ", " + ( info.getCountry() == null ? "-" : info.getCountry() ) ), "explanation" ) ); if ( googleAccountClickHandler == null || userCounter == 0 ) userPanel.add( new Label( info.getGoogleAccount() ) ); else { final Anchor googleAccountAnchor = new Anchor( info.getGoogleAccount() ); googleAccountAnchor.setTitle( googleAccountClickHandler.toString() ); googleAccountAnchor.addClickHandler( googleAccountClickHandler ); userPanel.add( googleAccountAnchor ); } userPanel.add( ClientUtils.styledWidget( ClientUtils.createTimestampWidget( "Updated: ", info.getUpdated() ), "explanation" ) ); userPanel.add( ClientUtils.styledWidget( new Label( ( info.getAccountCreated() == null ? "" : "Created: " + ClientUtils.DATE_FORMAT.format( info.getAccountCreated() ) + ", " ) + "Pkg: " + info.getDbPackageName() + ";" ), "explanation" ) ); if ( info.getComment() != null ) { final Label commentLabel = new Label(); if ( info.getComment().length() <= 40 ) commentLabel.setText( info.getComment() ); else { commentLabel.setText( info.getComment().substring( 0, 40 ) + "..." ); commentLabel.setTitle( info.getComment() ); } userPanel.add( ClientUtils.styledWidget( commentLabel, "explanation" ) ); } table.setWidget( row, column++, userPanel ); final Widget dbPackageWidget = info.getDbPackageIcon() == null ? new Label( info.getDbPackageName() ) : new Image( info.getDbPackageIcon() ); dbPackageWidget.setTitle( "Available storage: " + NUMBER_FORMAT.format( info.getPaidStorage() ) + " bytes" ); table.setWidget( row, column++, dbPackageWidget ); int rowSpan = 1; if ( info.getRepCount () > 0 ) rowSpan++; if ( info.getSmpdCount () > 0 ) rowSpan++; if ( info.getOtherCount() > 0 ) rowSpan++; if ( rowSpan > 1 ) for ( int i = column - 1; i >= 0; i-- ) table.getFlexCellFormatter().setRowSpan( row, i, rowSpan ); userCounter++; for ( int type = 0; type < 4; type++ ) { String fileType = null; int count = 0; long storage = 0; switch ( type ) { case 0 : count = info.getAllCount(); storage = info.getAllStorage(); fileType = "<all>"; break; case 1 : if ( ( count = info.getRepCount () ) == 0 ) continue; storage = info.getRepStorage (); fileType = "rep" ; column = 0; break; case 2 : if ( ( count = info.getSmpdCount () ) == 0 ) continue; storage = info.getSmpdStorage (); fileType = "smpd" ; column = 0; break; case 3 : if ( ( count = info.getOtherCount() ) == 0 ) continue; storage = info.getOtherStorage(); fileType = "other"; column = 0; break; } table.setWidget( row, column++, new Label( fileType ) ); final int firstNumberColumn = column; table.setWidget( row, column++, new Label( NUMBER_FORMAT.format( count ) ) ); table.setWidget( row, column++, new Label( NUMBER_FORMAT.format( storage ) + " bytes" ) ); table.setWidget( row, column++, new Label( NUMBER_FORMAT.format( count == 0 ? 0 : storage / count ) + " bytes" ) ); final int usedPercent = info.getPaidStorage() == 0 ? 0 : (int) ( storage * 100 / info.getPaidStorage() ); table.setWidget( row, column++, new Label( usedPercent + "%" ) ); for ( int i = column - 1; i >= firstNumberColumn; i-- ) cellFormatter.setHorizontalAlignment( row, i, HasHorizontalAlignment.ALIGN_RIGHT ); rowFormatter.addStyleName( row, userCounter == 1 ? "gold" : ( userCounter & 0x01 ) == 0 ? "row0" : "row1" ); row++; } }
private void setHeader() { int i = 0; for (String[] def : header) { if (def[1] != null) { if (GridInfo.CHECKBOX.equals(def[1])) { CheckBox checkAll = new CheckBox(); checkAll.addClickHandler(this); actionMap.put(checkAll, GridInfo.CHECKALLACTION + Integer.toString(i)); usersFlexTable.setWidget(0, i, checkAll); } else { Anchor sortLink = new Anchor(def[0]); sortLink.setStyleName("rdn-GridItemLink"); sortLink.addClickHandler(this); actionMap.put(sortLink, GridInfo.SORTACTION + def[1]); usersFlexTable.setWidget(0, i, sortLink); } } else { if (def[0] == null || def[0].isEmpty()) usersFlexTable.setHTML(0, i, " "); else usersFlexTable.setText(0, i, def[0]); } CellFormatter cellFormatter = usersFlexTable.getCellFormatter(); if (def[0] == null || def[0].isEmpty()) { cellFormatter.setStyleName(0, i, "rdn-GridItemHeaderShort"); } else { cellFormatter.setStyleName(0, i, "rdn-GridItemHeader"); } if (def.length > 2){ ColumnFormatter colFormatter = usersFlexTable.getColumnFormatter(); colFormatter.setWidth(i, def[2]); // for firefox cellFormatter.setWidth(0, i, def[2]); } i++; } RowFormatter rowFormatter = usersFlexTable.getRowFormatter(); rowFormatter.setStyleName(0, "rdn-GridHeader"); }