List of usage examples for com.google.gwt.dom.client NodeList getLength
public int getLength()
From source file:org.silverpeas.mobile.client.components.IframePage.java
License:Open Source License
@Override protected void setViewport() { NodeList<Element> metas = Document.get().getHead().getElementsByTagName("meta"); for (int i = 0; i < metas.getLength(); i++) { if (metas.getItem(i).getAttribute("name").equals("viewport")) { metas.getItem(i).setAttribute("content", "width=device-width, target-densitydpi=device-dpi, initial-scale=1.0, maximum-scale=5.0, user-scalable=1"); }//from w ww . j a v a 2 s .c om } }
From source file:org.silverpeas.mobile.client.SpMobil.java
License:Open Source License
/** * Init. spmobile.//from w ww . j a v a 2 s. com */ public void onModuleLoad() { instance = this; shortcutAppId = Window.Location.getParameter("shortcutAppId"); shortcutContentType = Window.Location.getParameter("shortcutContentType"); shortcutContentId = Window.Location.getParameter("shortcutContentId"); msg = GWT.create(ApplicationMessages.class); EventBus.getInstance().addHandler(ExceptionEvent.TYPE, new ErrorManager()); EventBus.getInstance().addHandler(AbstractAuthenticationErrorEvent.TYPE, this); loadIds(null); NodeList<Element> tags = Document.get().getElementsByTagName("meta"); for (int i = 0; i < tags.getLength(); i++) { MetaElement metaTag = ((MetaElement) tags.getItem(i)); if (metaTag.getName().equals("viewport")) { viewport = metaTag.getContent(); } } orientation = MobilUtils.getOrientation(); Window.addResizeHandler(new ResizeHandler() { @Override public void onResize(final ResizeEvent resizeEvent) { if (!MobilUtils.getOrientation().equals(orientation)) { orientation = MobilUtils.getOrientation(); EventBus.getInstance().fireEvent(new OrientationChangeEvent(orientation)); } } }); // Instanciate apps apps.add(new DocumentsApp()); apps.add(new MediaApp()); apps.add(new NewsApp()); apps.add(new NavigationApp()); apps.add(new TasksApp()); apps.add(new FavoritesApp()); apps.add(new WebPageApp()); apps.add(new BlogApp()); apps.add(new WorkflowApp()); apps.add(new HyperLinkApp()); apps.add(new AgendaApp()); }
From source file:org.silverpeas.mobile.client.SpMobil.java
License:Open Source License
public static void showFullScreen(final Widget content, final boolean zoomable, String bodyClass, String bodyId) {/*w w w . j a v a2 s . co m*/ PageHistory.getInstance().gotoToFullScreen("viewer"); RootPanel.get().clear(); RootPanel.get().add(content); if (zoomable) { NodeList<Element> tags = Document.get().getElementsByTagName("meta"); for (int i = 0; i < tags.getLength(); i++) { MetaElement metaTag = ((MetaElement) tags.getItem(i)); if (metaTag.getName().equals("viewport")) { metaTag.setContent(""); } } } SpMobil.bodyClass = Document.get().getBody().getClassName(); SpMobil.bodyId = Document.get().getBody().getId(); Document.get().getBody().setClassName(bodyClass); Document.get().getBody().setId(bodyId); Document.get().getBody().getStyle().setPaddingTop(0, Style.Unit.PX); }
From source file:org.silverpeas.mobile.client.SpMobil.java
License:Open Source License
public static void restoreMainPage() { RootPanel.get().clear();/* w w w.j a v a 2 s . c o m*/ RootPanel.get().add(SpMobil.getMainPage()); Document.get().getBody().setId(bodyId); Document.get().getBody().setClassName(bodyClass); Document.get().getBody().getStyle().clearPaddingTop(); NodeList<Element> tags = Document.get().getElementsByTagName("meta"); for (int i = 0; i < tags.getLength(); i++) { MetaElement metaTag = ((MetaElement) tags.getItem(i)); if (metaTag.getName().equals("viewport")) { metaTag.setContent(viewport); } } }
From source file:org.uberfire.client.plugin.RuntimePluginsServiceProxyClientImpl.java
License:Apache License
private void findAndFetchContent(final String relativeUri, final String filenameExtension, final String fileType, final ParameterizedCommand<Collection<String>> doWhenFinished) { RequestBuilder rb = new RequestBuilder(RequestBuilder.GET, relativeUri); try {//from www.jav a 2s. co m rb.sendRequest(null, new RequestCallback() { @Override public void onResponseReceived(Request request, Response response) { final List<String> pluginUrls = new ArrayList<String>(); final List<String> pluginContents = new ArrayList<String>(); final int[] contentErrors = new int[1]; Element detachedDiv = DOM.createDiv(); detachedDiv.setInnerHTML(response.getText()); NodeList<com.google.gwt.dom.client.Element> links = detachedDiv.getElementsByTagName("a"); for (int i = 0; i < links.getLength(); i++) { AnchorElement aElem = (AnchorElement) links.getItem(i); // DOM spec says these are already absolutized for us. Nice! String href = aElem.getHref(); if (href.endsWith(filenameExtension)) { pluginUrls.add(href); } } if (pluginUrls.size() == 0) { doWhenFinished.execute(Collections.<String>emptyList()); return; } for (final String href : pluginUrls) { RequestBuilder contentRb = new RequestBuilder(RequestBuilder.GET, href); try { contentRb.sendRequest(null, new RequestCallback() { @Override public void onResponseReceived(Request request, Response response) { if (response.getStatusCode() == 200) { pluginContents.add(response.getText()); } else { contentErrors[0]++; } if (pluginContents.size() >= pluginUrls.size() + contentErrors[0]) { doWhenFinished.execute(pluginContents); } } @Override public void onError(Request request, Throwable exception) { logger.warn("Error in " + fileType + " content request for " + href); contentErrors[0]++; if (pluginContents.size() >= pluginUrls.size() + contentErrors[0]) { doWhenFinished.execute(pluginContents); } } }); } catch (RequestException ex) { logger.warn("Failed to send request for " + fileType + " " + href, ex); contentErrors[0]++; if (pluginContents.size() >= pluginUrls.size() + contentErrors[0]) { doWhenFinished.execute(pluginContents); } } } } @Override public void onError(Request request, Throwable ex) { logger.warn("Error in " + fileType + " list request. Not loading JS " + fileType + "s.", ex); doWhenFinished.execute(Collections.<String>emptyList()); } }); } catch (RequestException ex) { logger.warn("Couldn't load JS " + fileType + ". Continuing without runtime " + fileType + "s.", ex); doWhenFinished.execute(Collections.<String>emptyList()); } }
From source file:org.unitime.timetable.gwt.client.Client.java
License:Apache License
public void onModuleLoadDeferred() { // register triggers GWT.runAsync(new RunAsyncCallback() { @Override/*w w w . j a v a 2 s . c o m*/ 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); } }); } } } }
From source file:org.unitime.timetable.gwt.client.rooms.RoomSharingWidget.java
License:Apache License
protected void addPreferenceIfNeeded(P line, final RoomSharingOption option) { if (option.hasPreference() && iModel.getPreferences() != null) { final ListBox pref = new ListBox(); pref.setStyleName("unitime-TextBox"); pref.addStyleName("preference"); for (PreferenceInterface p : iModel.getPreferences()) { pref.addItem(p.getName(), p.getId().toString()); }/*from ww w . j a va2 s. c om*/ SelectElement selectElement = SelectElement.as(pref.getElement()); NodeList<OptionElement> items = selectElement.getOptions(); for (int i = 0; i < items.getLength(); i++) { PreferenceInterface p = iModel.getPreferences().get(i); if (p.getColor() != null) items.getItem(i).getStyle().setBackgroundColor(p.getColor()); if (items.getItem(i).getValue().equals(option.getPreference().toString())) pref.setSelectedIndex(i); } pref.addChangeHandler(new ChangeHandler() { @Override public void onChange(ChangeEvent event) { option.setPreference(iModel.getPreferences().get(pref.getSelectedIndex()).getId()); } }); line.add(pref); } }
From source file:org.unitime.timetable.gwt.mobile.client.MobileClient.java
License:Apache License
@Override public void onModuleLoadDeferred() { MGWTSettings settings = new MGWTSettings(); settings.setViewPort(new Viewport()); settings.setFullscreen(true);/*ww w . ja v a 2s. c om*/ settings.setPreventScrolling(false); settings.setIconUrl("images/unitime-phone.png"); settings.setFixIOS71BodyBug(true); MGWT.applySettings(settings); MGWT.addOrientationChangeHandler(new OrientationChangeHandler() { @Override public void onOrientationChanged(OrientationChangeEvent event) { NodeList<Element> tags = Document.get().getElementsByTagName("meta"); for (int i = 0; i < tags.getLength(); i++) { MetaElement meta = (MetaElement) tags.getItem(i); if (meta.getName().equals("viewport")) { meta.setContent(new Viewport().getContent()); } } } }); super.onModuleLoadDeferred(); // load components for (final MobileComponents c : MobileComponents.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); } }); } } } }
From source file:org.vaadin.addon.gwtgraphics.client.impl.SVGImpl.java
License:Apache License
public void add(Element root, Element element) { NodeList<Node> list = root.getChildNodes(); for (int i = 0; i < list.getLength(); i++) { Node node = list.getItem(i); if ("defs".equals(node.getNodeName())) { node.appendChild(element);/*from w w w . ja va2 s. co m*/ return; } } }
From source file:org.vaadin.addon.gwtgraphics.client.impl.util.VMLUtil.java
License:Apache License
protected static Element getChildElementWithTagName(Element element, String name) { NodeList<Node> nodes = element.getChildNodes(); for (int i = 0; i < nodes.getLength(); i++) { Node node = nodes.getItem(i); if (node.getNodeName().equals(name)) { return Element.as(node); }/*w w w . j a v a 2s .co m*/ } return null; }