Java Code Examples for com.google.gwt.user.client.ui.FlexTable#setHTML()

The following examples show how to use com.google.gwt.user.client.ui.FlexTable#setHTML() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: WebTable.java    From unitime with Apache License 2.0 6 votes vote down vote up
public void setCell(int col, Cell cell) {
	iCells[col] = cell;
	if (iTable != null) {
		FlexTable t = iTable.iTable;
		cell.setColIdx(col);
		cell.setRow(this);
		if (cell.getWidget() == null)
			t.setHTML(getRowIdx() + iTable.getHeaderRowsCount(), col, (cell.getValue() == null || cell.getValue().isEmpty() ? " " : cell.getValue()));
		else
			t.setWidget(getRowIdx() + iTable.getHeaderRowsCount(), col, cell.getWidget());
		t.getFlexCellFormatter().setWordWrap(getRowIdx() + iTable.getHeaderRowsCount(), col, cell.getWordWrap());
		t.getFlexCellFormatter().setColSpan(getRowIdx() + iTable.getHeaderRowsCount(), col, cell.getColSpan());
		t.getFlexCellFormatter().setStyleName(getRowIdx() + iTable.getHeaderRowsCount(), col, cell.getStyleName());
		t.getFlexCellFormatter().setWidth(getRowIdx() + iTable.getHeaderRowsCount(), col, cell.getWidth());
		t.getFlexCellFormatter().setVerticalAlignment(getRowIdx() + iTable.getHeaderRowsCount(), col, cell.getVerticalAlignment());
		t.getFlexCellFormatter().setHorizontalAlignment(getRowIdx() + iTable.getHeaderRowsCount(), col, cell.getHorizontalAlignment());
		t.getFlexCellFormatter().getElement(getRowIdx() + iTable.getHeaderRowsCount(), col).setTitle(cell.getTitle());
	}
}
 
Example 2
Source File: StapleTableManager.java    From document-management-system with GNU General Public License v2.0 4 votes vote down vote up
/**
 * addDocument
 */
public static void addDocument(FlexTable table, final GWTStaple staple, final String uuid, boolean enableDelete) {
	int row = table.getRowCount();
	final GWTDocument doc = staple.getDoc();

	if (doc.isCheckedOut()) {
		table.setHTML(row, 0, Util.imageItemHTML("img/icon/edit.png"));
	} else if (doc.isLocked()) {
		table.setHTML(row, 0, Util.imageItemHTML("img/icon/lock.gif"));
	} else {
		table.setHTML(row, 0, " ");
	}

	// Subscribed is a special case, must add icon with others
	if (doc.isSubscribed()) {
		table.setHTML(row, 0, table.getHTML(row, 0) + Util.imageItemHTML("img/icon/subscribed.gif"));
	}

	if (doc.isHasNotes()) {
		table.setHTML(row, 0, table.getHTML(row, 0) + Util.imageItemHTML("img/icon/note.gif"));
	}

	table.setHTML(row, 1, Util.mimeImageHTML(doc.getMimeType()));
	Anchor anchor = new Anchor();
	anchor.setHTML(doc.getName());
	anchor.addClickHandler(new ClickHandler() {
		@Override
		public void onClick(ClickEvent arg0) {
			String docPath = doc.getPath();
			String path = docPath.substring(0, docPath.lastIndexOf("/"));
			GeneralComunicator.openPath(path, doc.getPath());
		}
	});
	anchor.setStyleName("okm-KeyMap-ImageHover");
	table.setWidget(row, 2, anchor);
	table.setHTML(row, 3, Util.formatSize(doc.getActualVersion().getSize()));

	if (enableDelete) {
		Image delete = new Image(OKMBundleResources.INSTANCE.deleteIcon());
		delete.setStyleName("okm-KeyMap-ImageHover");
		delete.addClickHandler(new ClickHandler() {
			@Override
			public void onClick(ClickEvent event) {
				staplingService.removeStaple(String.valueOf(staple.getId()), new AsyncCallback<Object>() {
					@Override
					public void onSuccess(Object result) {
						if (staple.getType().equals(GWTStaple.STAPLE_FOLDER)) {
							Stapling.get().refreshFolder(uuid);
						} else if (staple.getType().equals(GWTStaple.STAPLE_DOCUMENT)) {
							Stapling.get().refreshDocument(uuid);
						} else if (staple.getType().equals(GWTStaple.STAPLE_MAIL)) {
							Stapling.get().refreshMail(uuid);
						}
					}

					@Override
					public void onFailure(Throwable caught) {
						GeneralComunicator.showError("remove", caught);
					}
				});
			}
		});

		table.setWidget(row, 4, delete);
	} else {
		table.setHTML(row, 4, "");
	}

	table.getCellFormatter().setWidth(row, 0, "60px");
	table.getCellFormatter().setWidth(row, 1, "25px");
	table.getCellFormatter().setWidth(row, 4, "25px");

	table.getCellFormatter().setHorizontalAlignment(row, 0, HasHorizontalAlignment.ALIGN_RIGHT);
	table.getCellFormatter().setHorizontalAlignment(row, 1, HasHorizontalAlignment.ALIGN_CENTER);
	table.getCellFormatter().setHorizontalAlignment(row, 2, HasHorizontalAlignment.ALIGN_LEFT);
	table.getCellFormatter().setHorizontalAlignment(row, 3, HasHorizontalAlignment.ALIGN_CENTER);
	table.getCellFormatter().setHorizontalAlignment(row, 4, HasHorizontalAlignment.ALIGN_CENTER);
}
 
Example 3
Source File: StapleTableManager.java    From document-management-system with GNU General Public License v2.0 4 votes vote down vote up
/**
 * addFolder
 */
public static void addFolder(FlexTable table, final GWTStaple staple, final String uuid, boolean enableDelete) {
	int row = table.getRowCount();
	final GWTFolder folder = staple.getFolder();

	// Subscribed is a special case, must add icon with others
	if (folder.isSubscribed()) {
		table.setHTML(row, 0, Util.imageItemHTML("img/icon/subscribed.gif"));
	} else {
		table.setHTML(row, 0, "&nbsp;");
	}

	// Looks if must change icon on parent if now has no childs and properties with user security atention
	if ((folder.getPermissions() & GWTPermission.WRITE) == GWTPermission.WRITE) {
		if (folder.isHasChildren()) {
			table.setHTML(row, 1, Util.imageItemHTML("img/menuitem_childs.gif"));
		} else {
			table.setHTML(row, 1, Util.imageItemHTML("img/menuitem_empty.gif"));
		}
	} else {
		if (folder.isHasChildren()) {
			table.setHTML(row, 1, Util.imageItemHTML("img/menuitem_childs_ro.gif"));
		} else {
			table.setHTML(row, 1, Util.imageItemHTML("img/menuitem_empty_ro.gif"));
		}
	}

	Anchor anchor = new Anchor();
	anchor.setHTML(folder.getName());
	anchor.addClickHandler(new ClickHandler() {
		@Override
		public void onClick(ClickEvent arg0) {
			GeneralComunicator.openPath(folder.getPath(), null);
		}
	});
	anchor.setStyleName("okm-KeyMap-ImageHover");
	table.setWidget(row, 2, anchor);
	table.setHTML(row, 3, "&nbsp;");

	if (enableDelete) {
		Image delete = new Image(OKMBundleResources.INSTANCE.deleteIcon());
		delete.setStyleName("okm-KeyMap-ImageHover");
		delete.addClickHandler(new ClickHandler() {
			@Override
			public void onClick(ClickEvent event) {
				staplingService.removeStaple(String.valueOf(staple.getId()), new AsyncCallback<Object>() {
					@Override
					public void onSuccess(Object result) {
						if (staple.getType().equals(GWTStaple.STAPLE_FOLDER)) {
							Stapling.get().refreshFolder(uuid);
						} else if (staple.getType().equals(GWTStaple.STAPLE_DOCUMENT)) {
							Stapling.get().refreshDocument(uuid);
						} else if (staple.getType().equals(GWTStaple.STAPLE_MAIL)) {
							Stapling.get().refreshMail(uuid);
						}
					}

					@Override
					public void onFailure(Throwable caught) {
						GeneralComunicator.showError("remove", caught);
					}
				});
			}
		});

		table.setWidget(row, 4, delete);
	} else {
		table.setHTML(row, 4, "");
	}

	table.getCellFormatter().setWidth(row, 0, "60px");
	table.getCellFormatter().setWidth(row, 1, "25px");
	table.getCellFormatter().setWidth(row, 4, "25px");

	table.getCellFormatter().setHorizontalAlignment(row, 0, HasHorizontalAlignment.ALIGN_RIGHT);
	table.getCellFormatter().setHorizontalAlignment(row, 1, HasHorizontalAlignment.ALIGN_CENTER);
	table.getCellFormatter().setHorizontalAlignment(row, 2, HasHorizontalAlignment.ALIGN_LEFT);
	table.getCellFormatter().setHorizontalAlignment(row, 3, HasHorizontalAlignment.ALIGN_CENTER);
	table.getCellFormatter().setHorizontalAlignment(row, 4, HasHorizontalAlignment.ALIGN_CENTER);
}
 
Example 4
Source File: StapleTableManager.java    From document-management-system with GNU General Public License v2.0 4 votes vote down vote up
/**
 * addMail
 */
public static void addMail(FlexTable table, final GWTStaple staple, final String uuid, boolean enableDelete) {
	int row = table.getRowCount();
	final GWTMail mail = staple.getMail();

	// Mail is never checkout or subscribed ( because can not be changed )
	table.setHTML(row, 0, "&nbsp;");

	if (mail.getAttachments().size() > 0) {
		table.setHTML(row, 1, Util.imageItemHTML("img/email_attach.gif"));
	} else {
		table.setHTML(row, 1, Util.imageItemHTML("img/email.gif"));
	}

	Anchor anchor = new Anchor();
	anchor.setHTML(mail.getSubject());
	anchor.addClickHandler(new ClickHandler() {
		@Override
		public void onClick(ClickEvent arg0) {
			String docPath = mail.getPath();
			String path = docPath.substring(0, docPath.lastIndexOf("/"));
			GeneralComunicator.openPath(path, docPath);
		}
	});
	anchor.setStyleName("okm-KeyMap-ImageHover");
	table.setWidget(row, 2, anchor);
	table.setHTML(row, 3, Util.formatSize(mail.getSize()));


	if (enableDelete) {
		Image delete = new Image(OKMBundleResources.INSTANCE.deleteIcon());
		delete.setStyleName("okm-KeyMap-ImageHover");
		delete.addClickHandler(new ClickHandler() {
			@Override
			public void onClick(ClickEvent event) {
				staplingService.removeStaple(String.valueOf(staple.getId()), new AsyncCallback<Object>() {
					@Override
					public void onSuccess(Object result) {
						if (staple.getType().equals(GWTStaple.STAPLE_FOLDER)) {
							Stapling.get().refreshFolder(uuid);
						} else if (staple.getType().equals(GWTStaple.STAPLE_DOCUMENT)) {
							Stapling.get().refreshDocument(uuid);
						} else if (staple.getType().equals(GWTStaple.STAPLE_MAIL)) {
							Stapling.get().refreshMail(uuid);
						}
					}

					@Override
					public void onFailure(Throwable caught) {
						GeneralComunicator.showError("remove", caught);
					}
				});
			}
		});

		table.setWidget(row, 4, delete);
	} else {
		table.setHTML(row, 4, "");
	}

	table.getCellFormatter().setWidth(row, 0, "60px");
	table.getCellFormatter().setWidth(row, 1, "25px");
	table.getCellFormatter().setWidth(row, 4, "25px");

	table.getCellFormatter().setHorizontalAlignment(row, 0, HasHorizontalAlignment.ALIGN_RIGHT);
	table.getCellFormatter().setHorizontalAlignment(row, 1, HasHorizontalAlignment.ALIGN_CENTER);
	table.getCellFormatter().setHorizontalAlignment(row, 2, HasHorizontalAlignment.ALIGN_LEFT);
	table.getCellFormatter().setHorizontalAlignment(row, 3, HasHorizontalAlignment.ALIGN_CENTER);
	table.getCellFormatter().setHorizontalAlignment(row, 4, HasHorizontalAlignment.ALIGN_CENTER);
}
 
Example 5
Source File: PlainColumnView.java    From core with GNU Lesser General Public License v2.1 4 votes vote down vote up
@Override
public Widget asWidget() {


    VerticalPanel layout = new VerticalPanel();
    layout.setStyleName("fill-layout-width");

    layout.add(new HTML("<div class='metric-table-title'>"+title+"</div>"));

    grid = new FlexTable();
    grid.getElement().setAttribute("width", width+unit.getType()+"");

    // header columns
    grid.setHTML(0, 0, "Metric");
    grid.setHTML(0, 1, "Actual");
    grid.setHTML(0, 2, "&nbsp;");

    grid.getCellFormatter().setHorizontalAlignment(0, 1, HasHorizontalAlignment.ALIGN_RIGHT);

    // actual values
    int row = ROW_OFFSET;
    for(Column c : columns)
    {
        grid.setHTML(row, 0, "<div class='metric-table-label'>"+c.getLabel() + ":</div>");
        grid.setHTML(row, 1, "");

        stacks.add(new StackedBar());

        if(c.getComparisonColumn()!=null)
        {
            StackedBar stack = stacks.get(row - ROW_OFFSET);
            grid.setWidget(row, 2, stack.asWidget());
            stack.setRatio(0,0);
        }
        else
            grid.setText(row, 2, "");

        grid.getCellFormatter().setHorizontalAlignment(row, 1, HasHorizontalAlignment.ALIGN_RIGHT);

        if(!c.isVisible())
            grid.getRowFormatter().setVisible(row, false);
        if(c.isBaseline())
            grid.getRowFormatter().addStyleName(row, "metric-table-baseline");


        row++;
    }

    grid.getCellFormatter().setStyleName(0,0,"metric-table-header");
    grid.getCellFormatter().setStyleName(0,1,"metric-table-header");
    grid.getCellFormatter().setStyleName(0,2,"metric-table-header");
    grid.getCellFormatter().setWidth(0, 2, "50%");


    if(null==staticHelp && address!=null)
    {
        MetricHelpPanel helpPanel = new MetricHelpPanel(address, this.columns);
        //helpPanel.setAligned(true);
        layout.add(helpPanel.asWidget());
    }
    else if(staticHelp!=null)
    {
        layout.add(staticHelp.asWidget());
    }

    layout.add(grid);

   return layout;
}