Java Code Examples for com.google.gwt.user.client.ui.RootPanel
The following examples show how to use
com.google.gwt.user.client.ui.RootPanel. These examples are extracted from open source projects.
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 Project: appinventor-extensions Source File: MockComponentsUtil.java License: Apache License 2.0 | 6 votes |
/** * Returns the preferred size of the specified DOM element in an array of the * form {@code [width, height]}. * * @see #getPreferredSizeOfDetachedWidget(Widget) * @param element the DOM element to compute the size for * @return the natural width and height of the element */ public static int[] getPreferredSizeOfElement(Element element) { Element root = RootPanel.get().getElement(); root.appendChild(element); String[] style = clearSizeStyle(element); int width = element.getOffsetWidth() + 4; int height = element.getOffsetHeight() + 6; if (height < 26) { height = 26; } restoreSizeStyle(element, style); root.removeChild(element); return new int[] { width, height }; }
Example 2
Source Project: gwt-material-addins Source File: MaterialWindow.java License: Apache License 2.0 | 6 votes |
/** * Close the window. */ public void close() { // Turn back the cursor to POINTER RootPanel.get().getElement().getStyle().setCursor(Style.Cursor.DEFAULT); windowCount--; if (closeAnimation == null) { getOpenMixin().setOn(false); if (windowOverlay != null && windowOverlay.isAttached() && windowCount < 1) { windowOverlay.removeFromParent(); } CloseEvent.fire(this, false); } else { closeAnimation.animate(this, () -> { getOpenMixin().setOn(false); if (windowOverlay != null && windowOverlay.isAttached() && windowCount < 1) { windowOverlay.removeFromParent(); } CloseEvent.fire(this, false); }); } }
Example 3
Source Project: unitime Source File: StudentScheduleTable.java License: Apache License 2.0 | 6 votes |
public void insert(final RootPanel panel) { String studentId = panel.getElement().getInnerText().trim(); panel.getElement().setInnerText(null); panel.add(this); sSectioningService.lookupStudent(iOnline, studentId, new AsyncCallback<ClassAssignmentInterface.Student>() { @Override public void onSuccess(Student result) { if (result != null) { panel.setVisible(true); setStudent(result); if (SectioningCookie.getInstance().getEnrollmentCoursesDetails()) { refresh(); } else { clear(); iHeader.clearMessage(); iHeader.setCollapsible(false); } } } @Override public void onFailure(Throwable caught) {} }); }
Example 4
Source Project: cuba Source File: CubaPopupViewWidget.java License: Apache License 2.0 | 6 votes |
protected int getPositionTop(int popupPositionTop) { if (popupPositionTop != -1) { return popupPositionTop; } RootPanel rootPanel = RootPanel.get(); int windowTop = rootPanel.getAbsoluteTop(); int windowHeight = rootPanel.getOffsetHeight(); int windowBottom = windowTop + windowHeight; int popupHeight = popup.getOffsetHeight(); int top = getAbsoluteTop() + (getOffsetHeight() - popupHeight) / 2; if ((top + popupHeight) > windowBottom) { top -= (top + popupHeight) - windowBottom; } if (top < 0) { top = 0; } return top; }
Example 5
Source Project: unitime Source File: MapWidget.java License: Apache License 2.0 | 6 votes |
public static void insert(final RootPanel panel) { RPC.execute(new MapPropertiesRequest(), new AsyncCallback<MapPropertiesInterface>() { @Override public void onFailure(Throwable caught) { } @Override public void onSuccess(MapPropertiesInterface result) { MapWidget map = MapWidget.createMap(TextBox.wrap(Document.get().getElementById("coordX")), TextBox.wrap(Document.get().getElementById("coordY")), result); if (map != null) { panel.add(map); panel.setVisible(true); map.onShow(); } } }); }
Example 6
Source Project: cuba Source File: CubaMainTabSheetWidget.java License: Apache License 2.0 | 6 votes |
public CubaMainTabSheetWidget() { RootPanel rootPanel = RootPanel.get(); dragEndHandler = rootPanel.addBitlessDomHandler(event -> handleBadDD(event.getNativeEvent()), DragEndEvent.getType()); dropHandler = rootPanel.addBitlessDomHandler(event -> handleBadDD(event.getNativeEvent()), DropEvent.getType()); dragLeaveHandler = rootPanel.addBitlessDomHandler(event -> { Element element = event.getRelativeElement(); if (element == null || element == rootPanel.getElement()) { VDragAndDropManager.get().interruptDrag(); } }, DragLeaveEvent.getType()); }
Example 7
Source Project: cuba Source File: CubaFileDownloaderConnector.java License: Apache License 2.0 | 6 votes |
public void downloadFileById(String resourceId) { final String url = getResourceUrl(resourceId); if (url != null && !url.isEmpty()) { final IFrameElement iframe = Document.get().createIFrameElement(); Style style = iframe.getStyle(); style.setVisibility(Style.Visibility.HIDDEN); style.setHeight(0, Style.Unit.PX); style.setWidth(0, Style.Unit.PX); iframe.setFrameBorder(0); iframe.setTabIndex(-1); iframe.setSrc(url); RootPanel.getBodyElement().appendChild(iframe); Timer removeTimer = new Timer() { @Override public void run() { iframe.removeFromParent(); } }; removeTimer.schedule(60 * 1000); } }
Example 8
Source Project: unitime Source File: UniTimeMenuBar.java License: Apache License 2.0 | 6 votes |
private void attach(final RootPanel rootPanel) { RPC.execute(new MenuInterface.MenuRpcRequest(), new AsyncCallback<GwtRpcResponseList<MenuInterface>>() { @Override public void onSuccess(GwtRpcResponseList<MenuInterface> result) { initMenu(iMenu, result, 0); if (iSimple != null) rootPanel.add(iSimple); rootPanel.add(UniTimeMenuBar.this); if (iSimple != null) iSimple.setHeight(iMenu.getOffsetHeight() + "px"); } @Override public void onFailure(Throwable caught) { } }); }
Example 9
Source Project: gwteventbinder Source File: SampleEntryPoint.java License: Apache License 2.0 | 6 votes |
@Override public void onModuleLoad() { // Create the object graph - a real application would use Gin SimpleEventBus eventBus = new SimpleEventBus(); SidebarPresenter sidebarPresenter = new SidebarPresenter(eventBus); Button sidebarView = new Button("Contacts"); sidebarView.getElement().getStyle().setFloat(Style.Float.LEFT); sidebarView.getElement().getStyle().setMarginRight(20, Unit.PX); sidebarPresenter.setView(sidebarView); RootPanel.get().add(sidebarView); ContactsPresenter contactsPresenter = new ContactsPresenter(eventBus); VerticalPanel contactsView = new VerticalPanel(); contactsPresenter.setView(contactsView); RootPanel.get().add(contactsView); // Start listening for events in the presenter contactsPresenter.start(); // Eagerly bind the server proxy ServerProxy server = new ServerProxy(eventBus); }
Example 10
Source Project: gwt-material Source File: MaterialNavBarTest.java License: Apache License 2.0 | 6 votes |
public void testTypes() { final int OFFSET = 100; MaterialNavBarShrink shrinkNavBar = new MaterialNavBarShrink(); MaterialHeader header = new MaterialHeader(); header.add(shrinkNavBar); RootPanel.get().add(header); assertTrue(shrinkNavBar.getStyleName().contains(NavBarType.SHRINK.getCssName())); shrinkNavBar.setScrollOffset(OFFSET); assertEquals(OFFSET, shrinkNavBar.getScrollOffset()); final boolean[] expandFired = {false}; shrinkNavBar.addExpandHandler(event -> expandFired[0] = true); NavBarExpandEvent.fire(shrinkNavBar); assertTrue(expandFired[0]); final boolean[] shrinkFired = {false}; shrinkNavBar.addShrinkHandler(event -> shrinkFired[0] = true); NavBarShrinkEvent.fire(shrinkNavBar); assertTrue(shrinkFired[0]); }
Example 11
Source Project: incubator-retired-wave Source File: FocusManager.java License: Apache License 2.0 | 6 votes |
/** * Installs a key handler for key events on this window. * * @param handler handler to receive key events. */ static void install(KeySignalHandler handler) { // // NOTE: There are three potential candidate elements for sinking keyboard // events: the window, the document, and the document body. IE7 does not // fire events on the window element, and GWT's RootPanel is already a // listener on the body, leaving the document as the only cross-browser // whole-window event-sinking 'element'. // DocumentPanel panel = new DocumentPanel(handler); panel.setElement(Document.get().<Element>cast()); panel.addDomHandler(panel, KeyDownEvent.getType()); panel.addDomHandler(panel, KeyPressEvent.getType()); panel.addDomHandler(panel, KeyUpEvent.getType()); RootPanel.detachOnWindowClose(panel); panel.onAttach(); }
Example 12
Source Project: unitime Source File: RoomSharingWidget.java License: Apache License 2.0 | 6 votes |
public void insert(final RootPanel panel, boolean eventAvailability) { Long locationId = Long.valueOf(panel.getElement().getInnerHTML().trim()); RPC.execute(RoomInterface.RoomSharingRequest.load(locationId, eventAvailability), new AsyncCallback<RoomSharingModel>() { @Override public void onFailure(Throwable caught) { UniTimeNotifications.error(MESSAGES.failedToLoadRoomAvailability(caught.getMessage())); } @Override public void onSuccess(RoomSharingModel result) { panel.getElement().setInnerText(null); setModel(result); panel.add(RoomSharingWidget.this); panel.setVisible(true); } }); }
Example 13
Source Project: swellrt Source File: ImageThumbnailWidget.java License: Apache License 2.0 | 6 votes |
private void cleanUp() { RootPanel.get().remove(doubleLoadedImage); final HandlerRegistration onLoadReg = onLoadHandlerRegistration; final HandlerRegistration onErrorReg = onErrorHandlerRegistration; // HACK(user): There is a bug in GWT which stops us from removing a listener in HOSTED // mode inside the invoke context. Put the remove in a deferred command to avoid this // error ScheduleCommand.addCommand(new Scheduler.Task() { public void execute() { onLoadReg.removeHandler(); onErrorReg.removeHandler(); } }); onLoadHandlerRegistration = null; onErrorHandlerRegistration = null; completed = true; }
Example 14
Source Project: gwt-boot-samples Source File: CollectionWebApp.java License: Apache License 2.0 | 5 votes |
@Inject public CollectionWebApp(Apple apple, HelloWorldView helloWorldView) { this.apple = apple; this.helloWorldView = helloWorldView; // Call apple two times callApple(); callApple(); // Call to JavaScript "tomato.js" injectTomatoScript(); // Add the view to the HTML file RootPanel.get("mainPanel").add(this.helloWorldView); }
Example 15
Source Project: unitime Source File: CourseCurriculaTable.java License: Apache License 2.0 | 5 votes |
public void insert(final RootPanel panel) { initCallbacks(); iOfferingId = Long.valueOf(panel.getElement().getInnerText()); iCourseName = null; if (CurriculumCookie.getInstance().getCurriculaCoursesDetails()) { refresh(); } else { iHeader.clearMessage(); iHeader.setCollapsible(false); } panel.getElement().setInnerText(null); panel.add(this); panel.setVisible(true); }
Example 16
Source Project: unitime Source File: EnrollmentTable.java License: Apache License 2.0 | 5 votes |
public void insert(final RootPanel panel) { iOfferingId = Long.valueOf(panel.getElement().getInnerText()); if (iOfferingId >= 0 && iShowFilter) iHeader.setHeaderTitle(MESSAGES.studentsTable()); if (SectioningCookie.getInstance().getEnrollmentCoursesDetails()) { refresh(); } else { clear(); iHeader.clearMessage(); iHeader.setCollapsible(false); } panel.getElement().setInnerText(null); panel.add(this); panel.setVisible(true); }
Example 17
Source Project: unitime Source File: AssignedClassesPage.java License: Apache License 2.0 | 5 votes |
public static void __search() { final int left = Window.getScrollLeft(); final int top = Window.getScrollTop(); AssignedClassesPage page = (AssignedClassesPage)RootPanel.get("UniTimeGWT:Body").getWidget(0); page.search(new AsyncCallback<Boolean>() { @Override public void onFailure(Throwable caught) { } @Override public void onSuccess(Boolean result) { if (result) Window.scrollTo(left, top); } }); }
Example 18
Source Project: gdx-fireapp Source File: ImageHelper.java License: Apache License 2.0 | 5 votes |
/** * Creates texture region from byte[]. * <p> * GWT platform requires additional step (as far as i know) to deal with Pixmap. It is need to load Image element * and wait until it is loaded. * * @param bytes Image byte[] representation, not null * @param consumer Consumer where you should deal with region, not null */ public static void createTextureFromBytes(byte[] bytes, final Consumer<TextureRegion> consumer) { String base64 = "data:image/png;base64," + new String(Base64Coder.encode(bytes)); final Image image = new Image(); image.setVisible(false); image.addLoadHandler(new LoadHandler() { @Override public void onLoad(LoadEvent event) { ImageElement imageElement = image.getElement().cast(); Pixmap pixmap = new Pixmap(imageElement); GdxFIRLogger.log("Image loaded"); final int orgWidth = pixmap.getWidth(); final int orgHeight = pixmap.getHeight(); int width = MathUtils.nextPowerOfTwo(orgWidth); int height = MathUtils.nextPowerOfTwo(orgHeight); final Pixmap potPixmap = new Pixmap(width, height, pixmap.getFormat()); potPixmap.drawPixmap(pixmap, 0, 0, 0, 0, pixmap.getWidth(), pixmap.getHeight()); pixmap.dispose(); TextureRegion region = new TextureRegion(new Texture(potPixmap), 0, 0, orgWidth, orgHeight); potPixmap.dispose(); RootPanel.get().remove(image); consumer.accept(region); } }); image.setUrl(base64); RootPanel.get().add(image); }
Example 19
Source Project: swellrt Source File: ImageThumbnailWidget.java License: Apache License 2.0 | 5 votes |
/** * Get the thumbnail to load its image from the given url. * @param url */ public void loadImage(final String url) { // Remove the old double loader to stop the last double buffered load. if (onLoadHandlerRegistration != null) { onLoadHandlerRegistration.removeHandler(); onErrorHandlerRegistration.removeHandler(); // We used to set doubleLoadedImage's url to "" here. // It turns out to be a really bad thing to do. Setting an url to null // cause Wfe's bootstrap servelet to get called, which overload the server. RootPanel.get().remove(doubleLoadedImage); } // set up the handler to hide spinning wheel when loading has finished // We need to have the doubleLoadedImage created even if we are loading the image directly // in imageToLoad. This is done because we don't get a event otherwise. DoubleLoadHandler doubleLoadHandler = new DoubleLoadHandler(url); onLoadHandlerRegistration = doubleLoadedImage.addLoadHandler(doubleLoadHandler); onErrorHandlerRegistration = doubleLoadedImage.addErrorHandler(doubleLoadHandler); error.setVisible(false); doubleLoadedImage.setVisible(false); doubleLoadedImage.setUrl(url); RootPanel.get().add(doubleLoadedImage); imageToLoad.getElement().getStyle().setVisibility(Visibility.HIDDEN); // If image is empty, show the url directly. if (imageToLoad.getUrl().length() == 0) { imageToLoad.setUrl(url); } }
Example 20
Source Project: document-management-system Source File: Util.java License: GNU General Public License v2.0 | 5 votes |
/** * Download file by path */ @Deprecated public static void downloadFile(String path, String params) { if (!params.equals("") && !params.endsWith("&")) { params += "&"; } final Element downloadIframe = RootPanel.get("__download").getElement(); String url = RPCService.DownloadServlet + "?" + params + "path=" + URL.encodeQueryString(path); DOM.setElementAttribute(downloadIframe, "src", url); }
Example 21
Source Project: gwt-traction Source File: UTCDateTimeDemo.java License: Apache License 2.0 | 5 votes |
@Override public void onModuleLoad() { eventListBox = new ListBox(true); eventListBox.setVisibleItemCount(20); eventListBox.setWidth("800px"); RootPanel.get("eventlog").add(eventListBox); startDate = createDateBox("start-date"); startTime = createTimeBox("start-time"); endDate = createDateBox("end-date"); endTime = createTimeBox("end-time"); allday = new CheckBox("All Day"); // constructing this will bind all of the events new UTCDateTimeRangeController(startDate, startTime, endDate, endTime, allday); RootPanel startPanel = RootPanel.get("start"); startPanel.add(startDate); startPanel.add(startTime); startPanel.add(allday); RootPanel endPanel = RootPanel.get("end"); endPanel.add(endDate); endPanel.add(endTime); startDate.setValue(UTCDateBox.getValueForToday(), true); startTime.setValue(UTCTimeBox.getValueForNextHour(), true); }
Example 22
Source Project: document-management-system Source File: Util.java License: GNU General Public License v2.0 | 5 votes |
/** * executeReport */ public static void executeReport(long id, Map<String, String> params) { String parameters = ""; if (!params.isEmpty()) { for (String key : params.keySet()) { parameters += "&" + key + "=" + params.get(key); } } final Element downloadIframe = RootPanel.get("__download").getElement(); String url = RPCService.ReportServlet + "?" + "id=" + id + parameters; DOM.setElementAttribute(downloadIframe, "src", url); }
Example 23
Source Project: gwt-material-addins Source File: MaterialPathAnimatorTest.java License: Apache License 2.0 | 5 votes |
@Override protected MaterialPanel createWidget() { source = new MaterialPanel(); target = new MaterialPanel(); RootPanel.get().add(target); return source; }
Example 24
Source Project: unitime Source File: SolutionChangesPage.java License: Apache License 2.0 | 5 votes |
public static void __search() { final int left = Window.getScrollLeft(); final int top = Window.getScrollTop(); SolutionChangesPage page = (SolutionChangesPage)RootPanel.get("UniTimeGWT:Body").getWidget(0); page.search(new AsyncCallback<Boolean>() { @Override public void onFailure(Throwable caught) { } @Override public void onSuccess(Boolean result) { if (result) Window.scrollTo(left, top); } }); }
Example 25
Source Project: jetpad-projectional-open-source Source File: ClipboardSupport.java License: Apache License 2.0 | 5 votes |
public void pasteContent(final Handler<String> handler) { final TextArea pasteArea = createClipboardTextArea(); new Timer() { @Override public void run() { RootPanel.get().remove(pasteArea); $(myTarget).focus(); String text = pasteArea.getText(); handler.handle(text); } }.schedule(20); }
Example 26
Source Project: gwt-traction Source File: SingleListBoxDemo.java License: Apache License 2.0 | 5 votes |
@Override public void onModuleLoad() { eventListBox = new ListBox(true); eventListBox.setVisibleItemCount(20); RootPanel.get("eventlog").add(eventListBox); singleListBox = new SingleListBox(); singleListBox.addItem("Apples"); singleListBox.addItem("Bananas"); singleListBox.addItem("Oranges"); singleListBox.addItem("Pears"); singleListBox.addValueChangeHandler(new ValueChangeHandler<String>() { @Override public void onValueChange(ValueChangeEvent<String> event) { addEvent("ValueChangeEvent: " + event.getValue()); } }); Panel select = RootPanel.get("select"); select.add(singleListBox); Panel toggle = RootPanel.get("toggle"); toggle.add(createSetAddMissingValue(true)); toggle.add(createSetAddMissingValue(false)); Panel controls1 = RootPanel.get("controls1"); controls1.add(createSelectButton("Bananas")); controls1.add(createSelectButton("Pears")); Panel controls2 = RootPanel.get("controls2"); controls2.add(createSelectButton("Kiwis")); controls2.add(createSelectButton("Watermelons")); }
Example 27
Source Project: gwt-traction Source File: OpacityDemo.java License: Apache License 2.0 | 5 votes |
@Override public void onModuleLoad() { Panel controls = RootPanel.get("controls"); startOpacity = createTextBox("1.0"); endOpacity = createTextBox("0.1"); duration = createTextBox("5000"); addTextBox(controls, "Start Opacity", startOpacity); addTextBox(controls, "End Opacity", endOpacity); addTextBox(controls, "Duration", duration); Button start = new Button("Start"); start.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { OpacityAnimation animation = new OpacityAnimation(new Element[] { Document.get().getElementById("box1"), Document.get().getElementById("box2"), Document.get().getElementById("box3") }, Float.parseFloat(startOpacity.getText()), Float.parseFloat(endOpacity.getText())); animation.run(Integer.parseInt(duration.getText())); } }); controls.add(start); }
Example 28
Source Project: incubator-retired-wave Source File: EventDispatcherPanelGwtTest.java License: Apache License 2.0 | 5 votes |
/** Injects some HTML into the DOM. */ private static Element load(SafeHtml html) { Element container = Document.get().createDivElement(); container.setInnerHTML(html.asString()); Element content = container.getFirstChildElement(); RootPanel.get().getElement().appendChild(content); return content; }
Example 29
Source Project: putnami-web-toolkit Source File: ErrorDisplay.java License: GNU Lesser General Public License v3.0 | 5 votes |
public void show() { if (!this.showing) { RootPanel.get().add(this.modal); this.modal.show(); } this.showing = true; }
Example 30
Source Project: gwt-material-addins Source File: MaterialOverlayTest.java License: Apache License 2.0 | 5 votes |
public void testNestedOverlay() { // given MaterialOverlay overlay = getWidget(); MaterialOverlay child = new MaterialOverlay(); overlay.add(child); // when / then overlay.open(); child.open(); child.close(); child.addCloseHandler(closeEvent -> assertEquals("hidden", RootPanel.get().getElement().getStyle().getOverflow())); assertEquals(RootPanel.get(), overlay.getParent()); assertEquals(overlay, child.getParent()); }