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

The following examples show how to use com.google.gwt.user.client.ui.FlexTable#getRowCount() . 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: SettingsPanel.java    From swcv with MIT License 5 votes vote down vote up
private void addTooltips(FlexTable layout)
{
    for (int i = 0; i < layout.getRowCount(); i++)
    {
        layout.getWidget(i, 0).setTitle(layout.getWidget(i, 1).getTitle());
        layout.getWidget(i, 2).setTitle(layout.getWidget(i, 3).getTitle());
        layout.getWidget(i, 4).setTitle(layout.getWidget(i, 5).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, "&nbsp;");
	}

	// 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: HasApiCallStatInfoTablePage.java    From sc2gears with Apache License 2.0 4 votes vote down vote up
/**
 * Builds the API call stat info table.
 * 
 * <p>On first call the table is initialized, on later calls its content is first removed.</p>
 * 
 * @param apiCallStatInfoList       API call stat info list to build the table from
 * @param table                     table to build
 * @param googleAccountClickHandler if provided, google accounts will be rendered as links (@link {@link Anchor}),
 * 		and clicking on them will call this handler; the tool tip of links will be <code>googleAccountClickHandler.toString()</code>
 */
protected void buildApiCallStatInfoTable( final List< ApiCallStatInfo > apiCallStatInfoList, final FlexTable table, final ClickHandler googleAccountClickHandler ) {
	// Build table
	if ( table.getRowCount() == 0 ) {
		// Init table
		table.setBorderWidth( 1 );
		table.setCellSpacing( 0 );
		table.setCellPadding( 3 );
		add( table );
	}
	else
		table.removeAllRows();
	
	final RowFormatter rowFormatter = table.getRowFormatter();
	
	int column = 0;
	table.setWidget( 0, column++, new Label( "#"               ) );
	table.setWidget( 0, column++, new Label( "User"            ) );
	table.setWidget( 0, column++, new Label( "Paid Ops"        ) );
	table.setWidget( 0, column++, new Label( "∑Calls"          ) );
	table.setWidget( 0, column++, new Label( "Used Ops"        ) );
	table.setWidget( 0, column++, new Label( "Avg Time"        ) );
	table.setWidget( 0, column++, new Label( "Denied"          ) );
	table.setWidget( 0, column++, new Label( "Errors"          ) );
	table.setWidget( 0, column++, new Label( "Info"            ) );
	table.setWidget( 0, column++, new Label( "Avg Info T"      ) );
	table.setWidget( 0, column++, new Label( "Map info"        ) );
	table.setWidget( 0, column++, new Label( "Avg Map info T"  ) );
	table.setWidget( 0, column++, new Label( "Parse rep"       ) );
	table.setWidget( 0, column++, new Label( "Avg Parse rep T" ) );
	table.setWidget( 0, column++, new Label( "Prof info"       ) );
	table.setWidget( 0, column++, new Label( "Avg Prof info T" ) );
	table.setWidget( 0, column++, new Label( "Share"           ) );
	rowFormatter.addStyleName( 0, "headerRow" );
	
	final CellFormatter cellFormatter = table.getCellFormatter();
	
	final int rowsCount = apiCallStatInfoList.size();
	int userCounter = 0;
	for ( int row = 1; row <= rowsCount; row++ ) {
		final ApiCallStatInfo info = apiCallStatInfoList.get( row - 1 );
		column = 0;
		
		table.setWidget( row, column++, new Label( userCounter + "." ) );
		cellFormatter.setHorizontalAlignment( row, column-1, HasHorizontalAlignment.ALIGN_RIGHT );
		if ( googleAccountClickHandler == null || userCounter == 0 )
			table.setWidget( row, column++, new Label( info.getGoogleAccount() ) );
		else {
			final Anchor googleAccountAnchor = new Anchor( info.getGoogleAccount() );
			googleAccountAnchor.setTitle( googleAccountClickHandler.toString() );
			googleAccountAnchor.addClickHandler( googleAccountClickHandler );
			table.setWidget( row, column++, googleAccountAnchor );
		}
		userCounter++;
		
		final int firstNumberColumn = column;
		table.setWidget( row, column++, new Label( NUMBER_FORMAT.format( info.getPaidOps            () )         ) );
		table.setWidget( row, column++, new Label( NUMBER_FORMAT.format( info.getCalls              () )         ) );
		table.setWidget( row, column++, new Label( NUMBER_FORMAT.format( info.getUsedOps            () )         ) );
		table.setWidget( row, column++, new Label( NUMBER_FORMAT.format( info.getAvgExecTime        () ) + " ms" ) );
		table.setWidget( row, column++, new Label( NUMBER_FORMAT.format( info.getDeniedCalls        () )         ) );
		table.setWidget( row, column++, new Label( NUMBER_FORMAT.format( info.getErrors             () )         ) );
		table.setWidget( row, column++, new Label( NUMBER_FORMAT.format( info.getInfoCalls          () )         ) );
		table.setWidget( row, column++, new Label( NUMBER_FORMAT.format( info.getAvgInfoExecTime    () ) + " ms" ) );
		table.setWidget( row, column++, new Label( NUMBER_FORMAT.format( info.getMapInfoCalls       () )         ) );
		table.setWidget( row, column++, new Label( NUMBER_FORMAT.format( info.getAvgMapInfoExecTime () ) + " ms" ) );
		table.setWidget( row, column++, new Label( NUMBER_FORMAT.format( info.getParseRepCalls      () )         ) );
		table.setWidget( row, column++, new Label( NUMBER_FORMAT.format( info.getAvgParseRepExecTime() ) + " ms" ) );
		table.setWidget( row, column++, new Label( NUMBER_FORMAT.format( info.getProfInfoCalls      () )         ) );
		table.setWidget( row, column++, new Label( NUMBER_FORMAT.format( info.getAvgProfInfoExecTime() ) + " ms" ) );
		table.setWidget( row, column++, new Label( ( info.getPaidOps() == 0 ? 0 : 100 * info.getUsedOps() / info.getPaidOps() ) + "%" ) );
		
		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" );
	}
}
 
Example 6
Source File: InfoPanelImpl.java    From unitime with Apache License 2.0 4 votes vote down vote up
public InfoPanelImpl() {
	super("cell");
	iText = new P("text");
	add(iText);
	
	iHint = new ClickableHint(""); iHint.setStyleName("hint");
	add(iHint);
	
	iUpdateInfo = new Callback() {
		@Override
		public void execute(Callback callback) {
			if (callback != null) callback.execute(null);
		}
	};
	
	iInfo = new FlexTable();
	iInfo.setStyleName("unitime-InfoTable");
	// iUpdateInfo = updateInfo;
	iInfoPanel = new PopupPanel();
	iInfoPanel.setWidget(iInfo);
	iInfoPanel.setStyleName("unitime-PopupHint");
	sinkEvents(Event.ONMOUSEOVER);
	sinkEvents(Event.ONMOUSEOUT);
	sinkEvents(Event.ONMOUSEMOVE);
	iShowInfo = new Timer() {
		@Override
		public void run() {
			if (iInfo.getRowCount() == 0) return;
			iUpdateInfo.execute(new Callback() {
				public void execute(Callback callback) {
					iInfoPanel.setPopupPositionAndShow(new PopupPanel.PositionCallback() {
						@Override
						public void setPosition(int offsetWidth, int offsetHeight) {
							int maxX = Window.getScrollLeft() + Window.getClientWidth() - offsetWidth - 10;
							iInfoPanel.setPopupPosition(Math.min(iX, maxX), iY);
						}
					});
					if (callback != null) callback.execute(null);
				}
			});
		}
	};
	iHideInfo = new Timer() {
		@Override
		public void run() {
			iInfoPanel.hide();
		}
	};
	
	iDefaultClickHandler = new ClickHandler() {
		@Override
		public void onClick(ClickEvent event) {
			if (iUrl != null && !iUrl.isEmpty())
				ToolBox.open(GWT.getHostPageBaseURL() + iUrl);
		}
	};
	iTextClick = iHint.addClickHandler(iDefaultClickHandler);
	iHintClick = iText.addClickHandler(iDefaultClickHandler);
	iHint.setTabIndex(-1);
}