List of usage examples for com.google.gwt.user.client Window open
public static void open(String url, String name, String features)
From source file:com.vaadin.client.ui.ui.UIConnector.java
License:Apache License
@Override public void updateFromUIDL(final UIDL uidl, ApplicationConnection client) { getWidget().id = getConnectorId();// ww w .ja v a 2 s. co m boolean firstPaint = getWidget().connection == null; getWidget().connection = client; getWidget().immediate = getState().immediate; getWidget().resizeLazy = uidl.hasAttribute(UIConstants.RESIZE_LAZY); // this also implicitly removes old styles String styles = ""; styles += getWidget().getStylePrimaryName() + " "; if (ComponentStateUtil.hasStyles(getState())) { for (String style : getState().styles) { styles += style + " "; } } if (!client.getConfiguration().isStandalone()) { styles += getWidget().getStylePrimaryName() + "-embedded"; } getWidget().setStyleName(styles.trim()); getWidget().makeScrollable(); clickEventHandler.handleEventHandlerRegistration(); // Process children int childIndex = 0; // Open URL:s boolean isClosed = false; // was this window closed? while (childIndex < uidl.getChildCount() && "open".equals(uidl.getChildUIDL(childIndex).getTag())) { final UIDL open = uidl.getChildUIDL(childIndex); final String url = client.translateVaadinUri(open.getStringAttribute("src")); final String target = open.getStringAttribute("name"); if (target == null) { // source will be opened to this browser window, but we may have // to finish rendering this window in case this is a download // (and window stays open). Scheduler.get().scheduleDeferred(new Command() { @Override public void execute() { VUI.goTo(url); } }); } else if ("_self".equals(target)) { // This window is closing (for sure). Only other opens are // relevant in this change. See #3558, #2144 isClosed = true; VUI.goTo(url); } else { String options; boolean alwaysAsPopup = true; if (open.hasAttribute("popup")) { alwaysAsPopup = open.getBooleanAttribute("popup"); } if (alwaysAsPopup) { if (open.hasAttribute("border")) { if (open.getStringAttribute("border").equals("minimal")) { options = "menubar=yes,location=no,status=no"; } else { options = "menubar=no,location=no,status=no"; } } else { options = "resizable=yes,menubar=yes,toolbar=yes,directories=yes,location=yes,scrollbars=yes,status=yes"; } if (open.hasAttribute("width")) { int w = open.getIntAttribute("width"); options += ",width=" + w; } if (open.hasAttribute("height")) { int h = open.getIntAttribute("height"); options += ",height=" + h; } Window.open(url, target, options); } else { open(url, target); } } childIndex++; } if (isClosed) { // We're navigating away, so stop the application. client.setApplicationRunning(false); return; } // Handle other UIDL children UIDL childUidl; while ((childUidl = uidl.getChildUIDL(childIndex++)) != null) { String tag = childUidl.getTag().intern(); if (tag == "actions") { if (getWidget().actionHandler == null) { getWidget().actionHandler = new ShortcutActionHandler(getWidget().id, client); } getWidget().actionHandler.updateActionMap(childUidl); } else if (tag == "notifications") { for (final Iterator<?> it = childUidl.getChildIterator(); it.hasNext();) { final UIDL notification = (UIDL) it.next(); VNotification.showNotification(client, notification); } } else if (tag == "css-injections") { injectCSS(childUidl); } } if (uidl.hasAttribute("focused")) { // set focused component when render phase is finished Scheduler.get().scheduleDeferred(new Command() { @Override public void execute() { ComponentConnector connector = (ComponentConnector) uidl.getPaintableAttribute("focused", getConnection()); if (connector == null) { // Do not try to focus invisible components which not // present in UIDL return; } final Widget toBeFocused = connector.getWidget(); /* * Two types of Widgets can be focused, either implementing * GWT Focusable of a thinner Vaadin specific Focusable * interface. */ if (toBeFocused instanceof com.google.gwt.user.client.ui.Focusable) { final com.google.gwt.user.client.ui.Focusable toBeFocusedWidget = (com.google.gwt.user.client.ui.Focusable) toBeFocused; toBeFocusedWidget.setFocus(true); } else if (toBeFocused instanceof Focusable) { ((Focusable) toBeFocused).focus(); } else { getLogger().severe("Server is trying to set focus to the widget of connector " + Util.getConnectorString(connector) + " but it is not focusable. The widget should implement either " + com.google.gwt.user.client.ui.Focusable.class.getName() + " or " + Focusable.class.getName()); } } }); } // Add window listeners on first paint, to prevent premature // variablechanges if (firstPaint) { Window.addWindowClosingHandler(getWidget()); Window.addResizeHandler(getWidget()); } if (uidl.hasAttribute("scrollTo")) { final ComponentConnector connector = (ComponentConnector) uidl.getPaintableAttribute("scrollTo", getConnection()); scrollIntoView(connector); } if (uidl.hasAttribute(UIConstants.LOCATION_VARIABLE)) { String location = uidl.getStringAttribute(UIConstants.LOCATION_VARIABLE); String newFragment; int fragmentIndex = location.indexOf('#'); if (fragmentIndex >= 0) { // Decode fragment to avoid double encoding (#10769) newFragment = URL.decodePathSegment(location.substring(fragmentIndex + 1)); if (newFragment.isEmpty() && Location.getHref().indexOf('#') == -1) { // Ensure there is a trailing # even though History and // Location.getHash() treat null and "" the same way. Location.assign(Location.getHref() + "#"); } } else { // No fragment in server-side location, but can't completely // remove the browser fragment since that would reload the page newFragment = ""; } getWidget().currentFragment = newFragment; if (!newFragment.equals(History.getToken())) { History.newItem(newFragment, true); } } if (firstPaint) { // Queue the initial window size to be sent with the following // request. Scheduler.get().scheduleDeferred(new ScheduledCommand() { @Override public void execute() { getWidget().sendClientResized(); } }); } }
From source file:com.vaadin.client.ui.VLink.java
License:Apache License
@Override public void onClick(ClickEvent event) { if (enabled) { if (target == null) { target = "_self"; }/* w ww . j a va2 s . com*/ String features; switch (borderStyle) { case NONE: features = "menubar=no,location=no,status=no"; break; case MINIMAL: features = "menubar=yes,location=no,status=no"; break; default: features = ""; break; } if (targetWidth > 0) { features += (features.length() > 0 ? "," : "") + "width=" + targetWidth; } if (targetHeight > 0) { features += (features.length() > 0 ? "," : "") + "height=" + targetHeight; } if (features.length() > 0) { // if 'special features' are set, use window.open(), unless // a modifier key is held (ctrl to open in new tab etc) Event e = DOM.eventGetCurrentEvent(); if (!e.getCtrlKey() && !e.getAltKey() && !e.getShiftKey() && !e.getMetaKey()) { Window.open(src, target, features); e.preventDefault(); } } } }
From source file:com.vaadin.terminal.gwt.client.ui.VLink.java
License:Open Source License
public void onClick(ClickEvent event) { if (enabled && !readonly) { if (target == null) { target = "_self"; }//w w w. ja va 2 s. c o m String features; switch (borderStyle) { case BORDER_STYLE_NONE: features = "menubar=no,location=no,status=no"; break; case BORDER_STYLE_MINIMAL: features = "menubar=yes,location=no,status=no"; break; default: features = ""; break; } if (targetWidth > 0) { features += (features.length() > 0 ? "," : "") + "width=" + targetWidth; } if (targetHeight > 0) { features += (features.length() > 0 ? "," : "") + "height=" + targetHeight; } if (features.length() > 0) { // if 'special features' are set, use window.open(), unless // a modifier key is held (ctrl to open in new tab etc) Event e = DOM.eventGetCurrentEvent(); if (!e.getCtrlKey() && !e.getAltKey() && !e.getShiftKey() && !e.getMetaKey()) { Window.open(src, target, features); e.preventDefault(); } } } }
From source file:com.vaadin.terminal.gwt.client.ui.VView.java
License:Open Source License
public void updateFromUIDL(final UIDL uidl, ApplicationConnection client) { rendering = true;//from ww w .j a va 2 s. c o m id = uidl.getId(); boolean firstPaint = connection == null; connection = client; immediate = uidl.hasAttribute("immediate"); resizeLazy = uidl.hasAttribute(RESIZE_LAZY); String newTheme = uidl.getStringAttribute("theme"); if (theme != null && !newTheme.equals(theme)) { // Complete page refresh is needed due css can affect layout // calculations etc reloadHostPage(); } else { theme = newTheme; } if (uidl.hasAttribute("style")) { setStyleName(getStylePrimaryName() + " " + uidl.getStringAttribute("style")); } clickEventHandler.handleEventHandlerRegistration(client); if (!isEmbedded() && uidl.hasAttribute("caption")) { // only change window title if we're in charge of the whole page com.google.gwt.user.client.Window.setTitle(uidl.getStringAttribute("caption")); } // Process children int childIndex = 0; // Open URL:s boolean isClosed = false; // was this window closed? while (childIndex < uidl.getChildCount() && "open".equals(uidl.getChildUIDL(childIndex).getTag())) { final UIDL open = uidl.getChildUIDL(childIndex); final String url = client.translateVaadinUri(open.getStringAttribute("src")); final String target = open.getStringAttribute("name"); if (target == null) { // source will be opened to this browser window, but we may have // to finish rendering this window in case this is a download // (and window stays open). Scheduler.get().scheduleDeferred(new Command() { public void execute() { goTo(url); } }); } else if ("_self".equals(target)) { // This window is closing (for sure). Only other opens are // relevant in this change. See #3558, #2144 isClosed = true; goTo(url); } else { String options; if (open.hasAttribute("border")) { if (open.getStringAttribute("border").equals("minimal")) { options = "menubar=yes,location=no,status=no"; } else { options = "menubar=no,location=no,status=no"; } } else { options = "resizable=yes,menubar=yes,toolbar=yes,directories=yes,location=yes,scrollbars=yes,status=yes"; } if (open.hasAttribute("width")) { int w = open.getIntAttribute("width"); options += ",width=" + w; } if (open.hasAttribute("height")) { int h = open.getIntAttribute("height"); options += ",height=" + h; } Window.open(url, target, options); } childIndex++; } if (isClosed) { // don't render the content, something else will be opened to this // browser view rendering = false; return; } // Draw this application level window UIDL childUidl = uidl.getChildUIDL(childIndex); final Paintable lo = client.getPaintable(childUidl); if (layout != null) { if (layout != lo) { // remove old client.unregisterPaintable(layout); // add new setWidget((Widget) lo); layout = lo; } } else { setWidget((Widget) lo); layout = lo; } layout.updateFromUIDL(childUidl, client); if (!childUidl.getBooleanAttribute("cached")) { updateParentFrameSize(); } // Save currently open subwindows to track which will need to be closed final HashSet<VWindow> removedSubWindows = new HashSet<VWindow>(subWindows); // Handle other UIDL children while ((childUidl = uidl.getChildUIDL(++childIndex)) != null) { String tag = childUidl.getTag().intern(); if (tag == "actions") { if (actionHandler == null) { actionHandler = new ShortcutActionHandler(id, client); } actionHandler.updateActionMap(childUidl); } else if (tag == "execJS") { String script = childUidl.getStringAttribute("script"); eval(script); } else if (tag == "notifications") { for (final Iterator<?> it = childUidl.getChildIterator(); it.hasNext();) { final UIDL notification = (UIDL) it.next(); VNotification.showNotification(client, notification); } } else { // subwindows final Paintable w = client.getPaintable(childUidl); if (subWindows.contains(w)) { removedSubWindows.remove(w); } else { subWindows.add((VWindow) w); } w.updateFromUIDL(childUidl, client); } } // Close old windows which where not in UIDL anymore for (final Iterator<VWindow> rem = removedSubWindows.iterator(); rem.hasNext();) { final VWindow w = rem.next(); client.unregisterPaintable(w); subWindows.remove(w); w.hide(); } if (uidl.hasAttribute("focused")) { // set focused component when render phase is finished Scheduler.get().scheduleDeferred(new Command() { public void execute() { final Paintable toBeFocused = uidl.getPaintableAttribute("focused", connection); /* * Two types of Widgets can be focused, either implementing * GWT HasFocus of a thinner Vaadin specific Focusable * interface. */ if (toBeFocused instanceof com.google.gwt.user.client.ui.Focusable) { final com.google.gwt.user.client.ui.Focusable toBeFocusedWidget = (com.google.gwt.user.client.ui.Focusable) toBeFocused; toBeFocusedWidget.setFocus(true); } else if (toBeFocused instanceof Focusable) { ((Focusable) toBeFocused).focus(); } else { VConsole.log("Could not focus component"); } } }); } // Add window listeners on first paint, to prevent premature // variablechanges if (firstPaint) { Window.addWindowClosingHandler(this); Window.addResizeHandler(this); } onResize(); // finally set scroll position from UIDL if (uidl.hasVariable("scrollTop")) { scrollable = true; scrollTop = uidl.getIntVariable("scrollTop"); DOM.setElementPropertyInt(getElement(), "scrollTop", scrollTop); scrollLeft = uidl.getIntVariable("scrollLeft"); DOM.setElementPropertyInt(getElement(), "scrollLeft", scrollLeft); } else { scrollable = false; } // Safari workaround must be run after scrollTop is updated as it sets // scrollTop using a deferred command. if (BrowserInfo.get().isSafari()) { Util.runWebkitOverflowAutoFix(getElement()); } scrollIntoView(uidl); if (uidl.hasAttribute(FRAGMENT_VARIABLE)) { currentFragment = uidl.getStringAttribute(FRAGMENT_VARIABLE); if (!currentFragment.equals(History.getToken())) { History.newItem(currentFragment, true); } } else { // Initial request for which the server doesn't yet have a fragment // (and haven't shown any interest in getting one) currentFragment = History.getToken(); // Include current fragment in the next request client.updateVariable(id, FRAGMENT_VARIABLE, currentFragment, false); } rendering = false; }
From source file:com.vaadin.terminal.gwt.client.ui.VWindow.java
License:Open Source License
public void updateFromUIDL(UIDL uidl, ApplicationConnection client) { id = uidl.getId();/*from www. j a va2 s .com*/ this.client = client; // Workaround needed for Testing Tools (GWT generates window DOM // slightly different in different browsers). DOM.setElementProperty(closeBox, "id", id + "_window_close"); if (uidl.hasAttribute("invisible")) { hide(); return; } if (!uidl.hasAttribute("cached")) { if (uidl.getBooleanAttribute("modal") != vaadinModality) { setVaadinModality(!vaadinModality); } if (!isAttached()) { setVisible(false); // hide until possible centering show(); } if (uidl.getBooleanAttribute("resizable") != resizable) { setResizable(!resizable); } resizeLazy = uidl.hasAttribute(VView.RESIZE_LAZY); setDraggable(!uidl.hasAttribute("fixedposition")); // Caption must be set before required header size is measured. If // the caption attribute is missing the caption should be cleared. setCaption(uidl.getStringAttribute("caption"), uidl.getStringAttribute("icon")); } visibilityChangesDisabled = true; if (client.updateComponent(this, uidl, false)) { return; } visibilityChangesDisabled = false; clickEventHandler.handleEventHandlerRegistration(client); immediate = uidl.hasAttribute("immediate"); setClosable(!uidl.getBooleanAttribute("readonly")); // Initialize the position form UIDL int positionx = uidl.getIntVariable("positionx"); int positiony = uidl.getIntVariable("positiony"); if (positionx >= 0 || positiony >= 0) { if (positionx < 0) { positionx = 0; } if (positiony < 0) { positiony = 0; } setPopupPosition(positionx, positiony); } boolean showingUrl = false; int childIndex = 0; UIDL childUidl = uidl.getChildUIDL(childIndex++); while ("open".equals(childUidl.getTag())) { // TODO multiple opens with the same target will in practice just // open the last one - should we fix that somehow? final String parsedUri = client.translateVaadinUri(childUidl.getStringAttribute("src")); if (!childUidl.hasAttribute("name")) { final Frame frame = new Frame(); DOM.setStyleAttribute(frame.getElement(), "width", "100%"); DOM.setStyleAttribute(frame.getElement(), "height", "100%"); DOM.setStyleAttribute(frame.getElement(), "border", "0px"); frame.setUrl(parsedUri); contentPanel.setWidget(frame); showingUrl = true; } else { final String target = childUidl.getStringAttribute("name"); Window.open(parsedUri, target, ""); } childUidl = uidl.getChildUIDL(childIndex++); } final Paintable lo = client.getPaintable(childUidl); if (layout != null) { if (layout != lo) { // remove old client.unregisterPaintable(layout); contentPanel.remove((Widget) layout); // add new if (!showingUrl) { contentPanel.setWidget((Widget) lo); } layout = lo; } } else if (!showingUrl) { contentPanel.setWidget((Widget) lo); layout = lo; } dynamicWidth = !uidl.hasAttribute("width"); dynamicHeight = !uidl.hasAttribute("height"); layoutRelativeWidth = uidl.hasAttribute("layoutRelativeWidth"); layoutRelativeHeight = uidl.hasAttribute("layoutRelativeHeight"); if (dynamicWidth && layoutRelativeWidth) { /* * Relative layout width, fix window width before rendering (width * according to caption) */ setNaturalWidth(); } layout.updateFromUIDL(childUidl, client); if (!dynamicHeight && layoutRelativeWidth) { /* * Relative layout width, and fixed height. Must update the size to * be able to take scrollbars into account (layout gets narrower * space if it is higher than the window) -> only vertical scrollbar */ client.runDescendentsLayout(this); } /* * No explicit width is set and the layout does not have relative width * so fix the size according to the layout. */ if (dynamicWidth && !layoutRelativeWidth) { setNaturalWidth(); } if (dynamicHeight && layoutRelativeHeight) { // Prevent resizing until height has been fixed resizable = false; } // we may have actions and notifications if (uidl.getChildCount() > 1) { final int cnt = uidl.getChildCount(); for (int i = 1; i < cnt; i++) { childUidl = uidl.getChildUIDL(i); if (childUidl.getTag().equals("actions")) { if (shortcutHandler == null) { shortcutHandler = new ShortcutActionHandler(id, client); } shortcutHandler.updateActionMap(childUidl); } } } // setting scrollposition must happen after children is rendered contentPanel.setScrollPosition(uidl.getIntVariable("scrollTop")); contentPanel.setHorizontalScrollPosition(uidl.getIntVariable("scrollLeft")); // Center this window on screen if requested // This has to be here because we might not know the content size before // everything is painted into the window if (uidl.getBooleanAttribute("center")) { // mark as centered - this is unset on move/resize centered = true; center(); } else { // don't try to center the window anymore centered = false; } updateShadowSizeAndPosition(); setVisible(true); boolean sizeReduced = false; // ensure window is not larger than browser window if (getOffsetWidth() > Window.getClientWidth()) { setWidth(Window.getClientWidth() + "px"); sizeReduced = true; } if (getOffsetHeight() > Window.getClientHeight()) { setHeight(Window.getClientHeight() + "px"); sizeReduced = true; } if (dynamicHeight && layoutRelativeHeight) { /* * Window height is undefined, layout is 100% high so the layout * should define the initial window height but on resize the layout * should be as high as the window. We fix the height to deal with * this. */ int h = contents.getOffsetHeight() + getExtraHeight(); int w = getElement().getOffsetWidth(); client.updateVariable(id, "height", h, false); client.updateVariable(id, "width", w, true); } if (sizeReduced) { // If we changed the size we need to update the size of the child // component if it is relative (#3407) client.runDescendentsLayout(this); } Util.runWebkitOverflowAutoFix(contentPanel.getElement()); client.getView().scrollIntoView(uidl); if (uidl.hasAttribute("bringToFront")) { /* * Focus as a side-efect. Will be overridden by * ApplicationConnection if another component was focused by the * server side. */ contentPanel.focus(); bringToFrontSequence = uidl.getIntAttribute("bringToFront"); deferOrdering(); } }
From source file:com.webwoz.wizard.client.wizardlayouts.DefaultWizardScreen.java
License:Apache License
private void openPrintView() { Window.open("/webwozwizard/webwozwizard/experimentReport?p1=user&p2=" + expId + "&p3=" + userId, "", ""); }
From source file:com.webwoz.wizard.client.wizardlayouts.DefaultWizardScreen.java
License:Apache License
private void openExport() { Window.open("/webwozwizard/webwozwizard/excelExport?p1=user&p2=" + expId + "&p3=" + userId, "", ""); }
From source file:com.webwoz.wizard.client.wizardlayouts.DefaultWizardScreen.java
License:Apache License
private void exportNotes() { Window.open("/webwozwizard/webwozwizard/notesExport?p1=" + expId + "&p2=" + userId, "", ""); }
From source file:com.xpn.xwiki.watch.client.ui.articles.ArticleListWidget.java
License:Open Source License
protected void updateRightActionsPanel(final FlowPanel actionsPanel, final FeedArticle article) { Image extLinkImage = new Image(watch.getSkinFile(Constants.IMAGE_EXT_LINK)); extLinkImage.setTitle(watch.getTranslation("articlelist.open")); extLinkImage.addStyleName("clickable"); extLinkImage.addClickListener(new ClickListener() { public void onClick(Widget widget) { Window.open(article.getUrl(), "_blank", ""); }/*from w w w.j a va 2s. c o m*/ }); actionsPanel.add(extLinkImage); Image trashImage = new Image(watch.getSkinFile( (article.getFlagStatus() == -1) ? Constants.IMAGE_TRASH_ON : Constants.IMAGE_TRASH_OFF)); // add the trash button only if the user has the right to edit if (watch.getConfig().getHasEditRight()) { Image trashLoadingImage = new Image(watch.getSkinFile(Constants.IMAGE_LOADING_SPINNER)); trashImage .setTitle(watch.getTranslation((article.getFlagStatus() == -1) ? "article.trash.remove.caption" : "article.trash.add.caption")); final LoadingWidget trashLoadingWidget = new DefaultLoadingWidget(watch, trashImage, trashLoadingImage); trashLoadingWidget.addStyleName(watch.getStyleName("article-trash")); trashImage.addStyleName("clickable"); trashImage.addClickListener(new ClickListener() { public void onClick(Widget widget) { // trash/untrash article int flagstatus = article.getFlagStatus(); final int newflagstatus; if (flagstatus == -1) { // the article is trashed, untrash it newflagstatus = 0; } else { //the article isn't trashed, it can be trashed newflagstatus = -1; } watch.getDataManager().updateArticleFlagStatus(article, newflagstatus, new LoadingAsyncCallback(trashLoadingWidget) { public void onFailure(Throwable caught) { super.onFailure(caught); } public void onSuccess(Object result) { super.onSuccess(result); article.setFlagStatus(newflagstatus); actionsPanel.clear(); updateRightActionsPanel(actionsPanel, article); } }); } }); actionsPanel.add(trashLoadingWidget); } else { //otherwise add just the image actionsPanel.add(trashImage); } }
From source file:cz.cas.lib.proarc.webapp.client.action.FoxmlViewAction.java
License:Open Source License
public void view(String pid, String batchId) { if (pid == null) { throw new IllegalArgumentException("pid"); }/*from ww w . j a v a2s .com*/ StringBuilder sb = new StringBuilder(); sb.append(RestConfig.URL_DIGOBJECT_DISSEMINATION); sb.append('?').append(DigitalObjectResourceApi.DIGITALOBJECT_PID).append('=').append(pid); if (batchId != null) { sb.append('&').append(DigitalObjectResourceApi.BATCHID_PARAM).append('=').append(batchId); } Window.open(sb.toString(), "_blanc", ""); }