Java Code Examples for com.google.gwt.user.client.ui.RootPanel#get()

The following examples show how to use com.google.gwt.user.client.ui.RootPanel#get() . 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: CubaPopupViewWidget.java    From cuba with Apache License 2.0 6 votes vote down vote up
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 2
Source File: CubaMainTabSheetWidget.java    From cuba with Apache License 2.0 6 votes vote down vote up
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 3
Source File: Modal.java    From putnami-web-toolkit with GNU Lesser General Public License v3.0 6 votes vote down vote up
public void hide() {
	final RootPanel rootPanel = RootPanel.get();

	this.visible = false;
	StyleUtils.removeStyle(Modal.this, Modal.STYLE_VISIBLE);
	StyleUtils.removeStyle(rootPanel, Modal.STYLE_MODAL_OPEN);

	Modal.MODAL_BACKDROP.hide();

	Scheduler.get().scheduleFixedDelay(new RepeatingCommand() {
		@Override
		public boolean execute() {
			Modal.this.getElement().getStyle().clearDisplay();
			rootPanel.remove(getContainerWidget());
			return false;
		}
	}, 150);
}
 
Example 4
Source File: ColorDemo.java    From gwt-traction with Apache License 2.0 5 votes vote down vote up
@Override
   public void onModuleLoad() {

Panel controls = RootPanel.get("controls");

startColor = createTextBox("rgba(255,255,0,1)");
endColor = createTextBox("rgba(255,0,255,0)");
duration = createTextBox("5000");

addTextBox(controls, "Start Color", startColor);
addTextBox(controls, "End Color", endColor);
addTextBox(controls, "Duration", duration);

Button start = new Button("Start");
start.addClickHandler(new ClickHandler() {
    @Override
    public void onClick(ClickEvent event) {
        ColorAnimation animation = new ColorAnimation(new Element[] {
							      Document.get().getElementById("box1"),
							      Document.get().getElementById("box2"),
							      Document.get().getElementById("box3")
							  },
							  "backgroundColor",
							  RgbaColor.from(startColor.getText()),
							  RgbaColor.from(endColor.getText()));
        animation.run(Integer.parseInt(duration.getText()));
    }
});

controls.add(start);
   }
 
Example 5
Source File: MaterialToast.java    From gwt-material with Apache License 2.0 5 votes vote down vote up
public void close() {
    String id = getId();
    if (id != null && !id.isEmpty()) {
        Widget toast = RootPanel.get(id);
        if (toast != null && toast.isAttached()) {
            element.remove();
        }
    }
}
 
Example 6
Source File: UTCDateTimeDemo.java    From gwt-traction with Apache License 2.0 5 votes vote down vote up
@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 7
Source File: MaterialProgressTest.java    From gwt-material with Apache License 2.0 5 votes vote down vote up
public void testProgressBasic() {
    MaterialLoader.progress(true);
    ComplexPanel panel = RootPanel.get();

    // when / then
    checkProgress(panel);
}
 
Example 8
Source File: MaterialLoaderTest.java    From gwt-material with Apache License 2.0 5 votes vote down vote up
public void testLoaderBasic() {
    MaterialLoader.loading(true);
    ComplexPanel panel = RootPanel.get();

    // when / then
    checkLoader(panel);
}
 
Example 9
Source File: SingleListBoxDemo.java    From gwt-traction with Apache License 2.0 5 votes vote down vote up
@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 10
Source File: WordCloudDetailApp.java    From swcv with MIT License 5 votes vote down vote up
private void initializeSettingPanel(WordCloud cloud)
{
    CaptionPanel settingArea = new SettingsPanel().create(setting);
    settingArea.setCaptionText("options");
    
    RootPanel rPanel = RootPanel.get("cloud-setting");
    rPanel.clear();
    rPanel.add(settingArea);
}
 
Example 11
Source File: OpacityDemo.java    From gwt-traction with Apache License 2.0 5 votes vote down vote up
@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 12
Source File: GroupedListBoxDemo.java    From gwt-traction with Apache License 2.0 5 votes vote down vote up
@Override
   public void onModuleLoad() {

groupedListBox1 = new GroupedListBox(false);
groupedListBox2 = new GroupedListBox(true);
RootPanel.get("select1").add(groupedListBox1);
RootPanel.get("select2").add(groupedListBox2);

addItem("Fruits|Apples");
addItem("Fruits|Bananas");
addItem("Fruits|Oranges");
addItem("Fruits|Pears");	
addItem("Vegetables|Tomatoes");	
addItem("Vegetables|Carrots");		

Panel controls = RootPanel.get("controls");
controls.add(createAddButton("Fruits|Blueberries"));
controls.add(createAddButton("Vegetables|Broccoli"));
controls.add(createAddButton("Meats|Chicken"));
controls.add(createAddButton("Meats|Turkey"));

Button remove = new Button("Remove Selected");
remove.addClickHandler(new ClickHandler() {
           
           @Override
           public void onClick(ClickEvent event) {
               removeSelected();
           }
       });

controls.add(remove);
   }
 
Example 13
Source File: Client.java    From unitime with Apache License 2.0 5 votes vote down vote up
public static void reloadMenu() {
	for (final Components c: Components.values()) {
		final RootPanel p = RootPanel.get(c.id());
		if (p != null) {
			for (int i = 0; i < p.getWidgetCount(); i++)
				if (p.getWidget(i) instanceof UniTimeMenu)
					((UniTimeMenu)p.getWidget(i)).reload();
		}
	}
}
 
Example 14
Source File: ConflictBasedStatisticsPage.java    From unitime with Apache License 2.0 5 votes vote down vote up
protected void populate(FilterInterface filter, GwtRpcResponseList<CBSNode> response) {
	iLastFilter = filter;
	iLastResponse = response;
	for (int row = iPanel.getRowCount() - 1; row > 0; row--)
		iPanel.removeRow(row);
	
	RootPanel cpm = RootPanel.get("UniTimeGWT:CustomPageMessages");
	if (cpm != null && iFilterResponse != null) {
		cpm.clear();
		if (iFilterResponse.hasPageMessages()) {
			for (final PageMessage pm: iFilterResponse.getPageMessages()) {
				P p = new P(pm.getType() == PageMessageType.ERROR ? "unitime-PageError" : pm.getType() == PageMessageType.WARNING ? "unitime-PageWarn" : "unitime-PageMessage");
				p.setHTML(pm.getMessage());
				if (pm.hasUrl()) {
					p.addStyleName("unitime-ClickablePageMessage");
					p.addClickHandler(new ClickHandler() {
						@Override
						public void onClick(ClickEvent event) {
							if (pm.hasUrl()) ToolBox.open(GWT.getHostPageBaseURL() + pm.getUrl());
						}
					});
				}
				cpm.add(p);
			}
		}
	}
	
	if (response == null || response.isEmpty()) {
		iFilter.getFooter().setMessage(MESSAGES.errorConflictStatisticsNoDataReturned());
		return;
	}
	
	if (iTree == null) {
		iTree = new ConflictBasedStatisticsTree(iFilterResponse.getSuggestionProperties());
	}
	iTree.setValue(response);
	iPanel.addRow(iTree);
	iPanel.addRow(iLegend);
}
 
Example 15
Source File: WordCloudApp.java    From swcv with MIT License 4 votes vote down vote up
private void createShowAdvancedButton()
{
    final String COOKIE_NAME = "show-adv-options";

    final Anchor showAdvancedButton = Anchor.wrap(Document.get().getElementById("adv_link"));
    final Panel settingArea = RootPanel.get("settingContainer");

    showAdvancedButton.addClickHandler(new ClickHandler()
    {
        public void onClick(ClickEvent event)
        {
            if (showAdvancedButton.getText().equals("Show Advanced Options"))
            {
                settingArea.removeStyleName("hide");
                showAdvancedButton.setText("Hide Advanced Options");
                Cookies.setCookie(COOKIE_NAME, "1", new Date(System.currentTimeMillis() + (86400 * 7 * 1000)));
            }
            else
            {
                settingArea.addStyleName("hide");
                showAdvancedButton.setText("Show Advanced Options");
                Cookies.removeCookie(COOKIE_NAME);
            }
        }
    });

    boolean needToShow = "1".equals(Cookies.getCookie(COOKIE_NAME));
    if (needToShow)
        showAdvancedButton.fireEvent(new GwtEvent<ClickHandler>()
        {
            @Override
            public com.google.gwt.event.shared.GwtEvent.Type<ClickHandler> getAssociatedType()
            {
                return ClickEvent.getType();
            }

            @Override
            protected void dispatch(ClickHandler handler)
            {
                handler.onClick(null);
            }
        });
}
 
Example 16
Source File: Login.java    From document-management-software with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Override
public void onModuleLoad() {
	if (RootPanel.get("loadingwrapper-login") == null)
		return;

	GWT.setUncaughtExceptionHandler(new UncaughtExceptionHandler() {
		@Override
		public void onUncaughtException(Throwable caught) {
			SC.warn("Error", caught.getMessage());
		}

	});

	instance = this;

	declareShowLostDialog(this);

	// Tries to capture locale parameter
	final String lang = Util.detectLocale();
	I18N.setLocale(lang);

	// Tries to capture tenant parameter
	final String tenant = Util.detectTenant();

	// Get grid of scrollbars, and clear out the window's built-in margin,
	// because we want to take advantage of the entire client area.
	Window.enableScrolling(false);
	Window.setMargin("0px");

	InfoService.Instance.get().getInfo(I18N.getLocale(), tenant, true, new AsyncCallback<GUIInfo>() {
		@Override
		public void onFailure(Throwable error) {
			SC.warn(error.getMessage());
		}

		@Override
		public void onSuccess(final GUIInfo info) {
			CookiesManager.saveRelease(info);

			I18N.init(info);

			WindowUtils.setTitle(info, null);

			Feature.init(info);
			Session.get().setInfo(info);

			WindowUtils.setFavicon(info);

			if ("mobile".equals(Util.getJavascriptVariable("j_layout")))
				loginPanel = new MobileLoginPanel(info);
			else
				loginPanel = new LoginPanel(info);

			Login.this.showLogin();
		}

	});
}
 
Example 17
Source File: Client.java    From unitime with Apache License 2.0 4 votes vote down vote up
public void onModuleLoadDeferred() {
	// register triggers
	GWT.runAsync(new RunAsyncCallback() {
		@Override
		public void onSuccess() {
			for (Triggers t: Triggers.values())
				t.register();
			callGwtOnLoadIfExists();
		}
		@Override
		public void onFailure(Throwable reason) {
		}
	});
	
	// load page
	if (RootPanel.get("UniTimeGWT:Body") != null) {
		LoadingWidget.getInstance().show(MESSAGES.waitLoadingPage());
		Scheduler.get().scheduleDeferred(new ScheduledCommand() {
			@Override
			public void execute() {
				initPageAsync(Window.Location.getParameter("page"));
			}
		});
	}
	
	// load components
	for (final Components c: Components.values()) {
		final RootPanel p = RootPanel.get(c.id());
		if (p != null) {
			Scheduler.get().scheduleDeferred(new ScheduledCommand() {
				@Override
				public void execute() {
					initComponentAsync(p, c);
				}
			});
		}
		if (p == null && c.isMultiple()) {
			NodeList<Element> x = getElementsByName(c.id());
			if (x != null && x.getLength() > 0)
				for (int i = 0; i < x.getLength(); i++) {
					Element e = x.getItem(i);
					e.setId(DOM.createUniqueId());
					final RootPanel q = RootPanel.get(e.getId());
					Scheduler.get().scheduleDeferred(new ScheduledCommand() {
						@Override
						public void execute() {
							initComponentAsync(q, c);
						}
					});
				}
		}
	}
	
	Window.addWindowClosingHandler(new Window.ClosingHandler() {
		@Override
		public void onWindowClosing(Window.ClosingEvent event) {
			if (isLoadingDisplayed() || LoadingWidget.getInstance().isShowing()) return;
			LoadingWidget.showLoading(MESSAGES.waitPlease());
			iPageLoadingTimer = new Timer() {
				@Override
				public void run() {
					RPC.execute(new IsSessionBusyRpcRequest(), new AsyncCallback<GwtRpcResponseBoolean>() {
						@Override
						public void onFailure(Throwable caught) {
							LoadingWidget.hideLoading();
						}
						@Override
						public void onSuccess(GwtRpcResponseBoolean result) {
							if (result.getValue()) {
								iPageLoadingTimer.schedule(500);
							} else {
								LoadingWidget.hideLoading();
							}
						}
					});
				}
			};
			iPageLoadingTimer.schedule(500);
		}
	});
}
 
Example 18
Source File: Module.java    From shortyz with GNU General Public License v3.0 4 votes vote down vote up
@Override
public RootPanel get() {
    return RootPanel.get();
}
 
Example 19
Source File: Module.java    From shortyz with GNU General Public License v3.0 4 votes vote down vote up
@Override
public RootPanel get() {
    return RootPanel.get();
}
 
Example 20
Source File: Module.java    From shortyz with GNU General Public License v3.0 4 votes vote down vote up
@Override
public RootPanel get() {
    return RootPanel.get();
}