use of com.google.gwt.resources.client.ImageResource in project gwt-test-utils by gwt-test-utils.
the class MyOverridedClientBundleTest method testImageResource_OverrideWithAnnotation.
@Test
public void testImageResource_OverrideWithAnnotation() {
// Given
ImageResource testImageResource = MyOverridedClientBundle.INSTANCE.imageResource();
// When
String name = testImageResource.getName();
String url = testImageResource.getSafeUri().asString();
int heigh = testImageResource.getHeight();
int left = testImageResource.getLeft();
int width = testImageResource.getWidth();
int top = testImageResource.getTop();
// Then
assertThat(name).isEqualTo("imageResource");
assertThat(url).isEqualTo("http://127.0.0.1:8888/gwt_test_utils_module/override_testImageResource.gif");
assertThat(heigh).isEqualTo(0);
assertThat(left).isEqualTo(0);
assertThat(width).isEqualTo(0);
assertThat(top).isEqualTo(0);
assertThat(MyOverridedClientBundle.INSTANCE.imageResource()).isEqualTo(testImageResource);
}
use of com.google.gwt.resources.client.ImageResource in project gwt-test-utils by gwt-test-utils.
the class ClientBundleTest method rootClasspathImg.
@Test
public void rootClasspathImg() {
// Given
ImageResource rootClasspathImg = MyClientBundle.INSTANCE.rootClasspathImg();
// When
String name = rootClasspathImg.getName();
String url = rootClasspathImg.getSafeUri().asString();
int heigh = rootClasspathImg.getHeight();
int left = rootClasspathImg.getLeft();
int width = rootClasspathImg.getWidth();
int top = rootClasspathImg.getTop();
String toString = rootClasspathImg.toString();
// Then
assertThat(name).isEqualTo("rootClasspathImg");
assertThat(url).isEqualTo("http://127.0.0.1:8888/gwt_test_utils_module/root-classpath-img.png");
assertThat(heigh).isEqualTo(0);
assertThat(left).isEqualTo(0);
assertThat(width).isEqualTo(0);
assertThat(top).isEqualTo(0);
assertThat(toString).isEqualTo("com.googlecode.gwt.test.internal.resources.ImageResourceCallback generated for 'com.googlecode.gwt.test.resources.MyClientBundle.rootClasspathImg()'");
assertThat(MyClientBundle.INSTANCE.rootClasspathImg()).isEqualTo(rootClasspathImg);
}
use of com.google.gwt.resources.client.ImageResource in project perun by CESNET.
the class TabManager method addTabWhenPrepared.
/**
* Adding a tab
* With this method, the authorization must be already granted
*
* @param tab
* @param open
* @return
*/
private boolean addTabWhenPrepared(TabItem tab, boolean open) {
// store place
final Widget widget;
ImageResource tabIcon;
// overlay tab
final SimplePanel overlayTab = new SimplePanel();
overlayTab.addStyleName("tab-overlay");
final AbsolutePanel overlayShield = new AbsolutePanel();
overlayShield.addStyleName("tab-overlay-shield");
overlayShield.add(overlayTab);
overlayTab.getElement().getStyle().setLeft(5, Unit.PCT);
// authorization when not already opened
if (tab.isAuthorized() == true) {
// widget itself
widget = tab.getWidget();
tabIcon = tab.getIcon();
// load page content
tab.draw();
} else {
widget = new NotAuthorizedWidget();
tabIcon = SmallIcons.INSTANCE.errorIcon();
}
// panel with overlay and widget contents
final AbsolutePanel ap = new AbsolutePanel();
ap.add(widget, 5, 5);
ap.add(overlayShield, 0, -2000);
// overlayShield.getElement().getStyle().setLeft(5, Unit.PCT);
// set sizes
ap.setSize("100%", "100%");
widget.setWidth("100%");
// update overlay position
UiElements.addResizeCommand(new Command() {
@Override
public void execute() {
// empty
if (overlayTab.getWidget() == null) {
return;
}
int clientWidth = (Window.getClientWidth() > WebGui.MIN_CLIENT_WIDTH) ? Window.getClientWidth() : WebGui.MIN_CLIENT_WIDTH;
// if small, then fixed size in the center
if (!overlayTab.getStyleName().contains("tab-overlay-large")) {
int overlayWidth = overlayTab.getElement().getOffsetWidth();
// main menu width
int left = (clientWidth - MainMenu.MENU_WIDTH - overlayWidth) / 2;
overlayShield.setWidgetPosition(overlayTab, left, overlayShield.getWidgetTop(overlayTab));
return;
}
}
}, tab);
// has a help widget?
if (tab instanceof TabItemWithHelp) {
helpCounter++;
final String helpWrapperId = "helpWidgetWrapper-" + helpCounter;
TabItemWithHelp tabWithHelp = (TabItemWithHelp) tab;
final AbsolutePanel helpWidgetWrapper = new AbsolutePanel();
ap.add(helpWidgetWrapper, 100000, 0);
helpWidgetWrapper.addStyleName("helpWidgetWrapper");
helpWidgetWrapper.addStyleName(helpWrapperId);
// help widget
// FlexTable helpWidget = new FlexTable();
VerticalPanel helpWidget = new VerticalPanel();
helpWidget.setWidth("100%");
final ScrollPanel sp = new ScrollPanel(helpWidget);
// header
// Image img = new Image(LargeIcons.INSTANCE.helpIcon());
// helpWidget.setWidget(0, 0, img);
// helpWidget.getCellFormatter().setWidth(0, 0, "40px");
HTML helpHeader = new HTML("<h3>Quick help</h3>");
helpWidget.add(helpHeader);
helpWidget.setCellHeight(helpHeader, "45px");
// content
// helpWidget.getFlexCellFormatter().setColSpan(1, 0, 2);
// helpWidget.getFlexCellFormatter().setVerticalAlignment(1, 0, HasVerticalAlignment.ALIGN_TOP);
helpWidget.add(tabWithHelp.getHelpWidget());
final SimplePanel helpWidgetInnerWrapper = new SimplePanel(sp);
helpWidgetInnerWrapper.setStyleName("helpWidget");
helpWidgetWrapper.add(helpWidgetInnerWrapper, 0, 0);
/*helpWidgetInnerWrapper.setSize("100%", "100%");*/
// open help widget button
PushButton helpWidgetButton = new PushButton(new Image(HELP_WIDGET_BUTTON_IMAGE));
final SimplePanel helpWidgetButtonWrapper = new SimplePanel(helpWidgetButton);
helpWidgetButton.setStyleName("helpWidgetButton");
helpWidgetButton.setTitle("Open / close Quick help");
helpWidgetWrapper.add(helpWidgetButtonWrapper, -30, 0);
helpWidgetButton.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
toggleHelp(helpWrapperId);
}
});
UiElements.addResizeCommand(new Command() {
public void execute() {
int helpWidgetWidth = 400;
int clientWidth = (Window.getClientWidth() > WebGui.MIN_CLIENT_WIDTH) ? Window.getClientWidth() : WebGui.MIN_CLIENT_WIDTH;
// int clientHeight = (Window.getClientHeight() > WebGui.MIN_CLIENT_HEIGHT) ? Window.getClientHeight() : WebGui.MIN_CLIENT_HEIGHT;
clientWidth -= MainMenu.MENU_WIDTH;
int newLeft = clientWidth;
if (isHelpOpened(helpWrapperId)) {
newLeft -= helpWidgetWidth;
}
// update widget position
ap.setWidgetPosition(helpWidgetWrapper, newLeft, 0);
session.getUiElements().resizeSmallTabPanel(sp, 200);
// update button top position
// helpWidgetWrapper.setWidgetPosition(helpWidgetButtonWrapper, helpWidgetWrapper.getWidgetLeft(helpWidgetButtonWrapper), (clientHeight - 200) / 2);
}
});
}
// add
int tabId = session.getUiElements().contentAddTab(ap, tab.getTitle(), open, tabIcon);
// add to current map
this.tabs.put(tab, tabId);
if (open) {
activeTab = tab;
// call the event
if (tab.isAuthorized()) {
tab.open();
}
// DO NOT CHANGE MENU, IT'S HANDLED BY TAB
// ON IT'S OWN VIA tab.open()
// session.getUiElements().getMenu().updateLinks();
}
tabOverlays.put(tabId, overlayShield);
// refresh URL
refreshUrl();
return true;
}
use of com.google.gwt.resources.client.ImageResource in project perun by CESNET.
the class PerunAppTypeCell method render.
@Override
public void render(com.google.gwt.cell.client.Cell.Context context, String status, SafeHtmlBuilder sb) {
// selects the image according to the status
ImageResource ir = null;
if (status.equalsIgnoreCase("INITIAL")) {
ir = INITIAL;
} else if (status.equalsIgnoreCase("EXTENSION")) {
ir = EXTENSION;
} else if (status.equalsIgnoreCase("EMBEDDED")) {
ir = EMBEDDED;
}
// if status not available
if (ir == null) {
return;
}
// append the image
Element imageElement = new Image(ir).getElement();
imageElement.setTitle(status);
SafeHtml image = SafeHtmlUtils.fromSafeConstant((imageElement.getString()));
sb.appendHtmlConstant("<div class=\"" + "customClickableTextCell" + "\">");
sb.append(image);
sb.appendHtmlConstant("</div>");
}
use of com.google.gwt.resources.client.ImageResource in project perun by CESNET.
the class PerunAppStateCell method render.
@Override
public void render(com.google.gwt.cell.client.Cell.Context context, String status, SafeHtmlBuilder sb) {
// selects the image according to the status
ImageResource ir = null;
if (status.equalsIgnoreCase("NEW")) {
ir = NEW;
} else if (status.equalsIgnoreCase("VERIFIED")) {
ir = VERIFIED;
} else if (status.equalsIgnoreCase("APPROVED")) {
ir = APPROVED;
} else if (status.equalsIgnoreCase("REJECTED")) {
ir = REJECTED;
}
// if status not available
if (ir == null) {
return;
}
// append the image
Element imageElement = new Image(ir).getElement();
imageElement.setTitle(status);
SafeHtml image = SafeHtmlUtils.fromSafeConstant((imageElement.getString()));
sb.appendHtmlConstant("<div class=\"" + "customClickableTextCell" + "\">");
sb.append(image);
sb.appendHtmlConstant("</div>");
}
Aggregations