+++ /dev/null
-/*
- * Copyright 2012 Vaadin Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-
-package com.vaadin.client.extensions;
-
-import com.google.gwt.event.dom.client.ClickEvent;
-import com.google.gwt.event.dom.client.ClickHandler;
-import com.google.gwt.user.client.Window;
-import com.google.gwt.user.client.ui.Widget;
-import com.vaadin.client.ComponentConnector;
-import com.vaadin.client.ServerConnector;
-import com.vaadin.server.BrowserPopupOpener;
-import com.vaadin.shared.ui.BrowserPopupExtensionState;
-import com.vaadin.shared.ui.Connect;
-
-/**
- * Client-side code for {@link BrowserPopupOpener}
- *
- * @author Vaadin Ltd
- * @since 7.0.0
- */
-@Connect(BrowserPopupOpener.class)
-public class BrowserPopupOpenerConnector extends AbstractExtensionConnector
- implements ClickHandler {
-
- @Override
- protected void extend(ServerConnector target) {
- final Widget targetWidget = ((ComponentConnector) target).getWidget();
-
- targetWidget.addDomHandler(this, ClickEvent.getType());
- }
-
- @Override
- public BrowserPopupExtensionState getState() {
- return (BrowserPopupExtensionState) super.getState();
- }
-
- @Override
- public void onClick(ClickEvent event) {
- String url = getResourceUrl("popup");
- if (url != null) {
- Window.open(url, getState().target, getState().features);
- }
- }
-}
--- /dev/null
+/*
+ * Copyright 2012 Vaadin Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+
+package com.vaadin.client.extensions;
+
+import com.google.gwt.event.dom.client.ClickEvent;
+import com.google.gwt.event.dom.client.ClickHandler;
+import com.google.gwt.user.client.Window;
+import com.google.gwt.user.client.ui.Widget;
+import com.vaadin.client.ComponentConnector;
+import com.vaadin.client.ServerConnector;
+import com.vaadin.server.BrowserWindowOpener;
+import com.vaadin.shared.ui.BrowserWindowOpenerState;
+import com.vaadin.shared.ui.Connect;
+
+/**
+ * Client-side code for {@link BrowserWindowOpener}
+ *
+ * @author Vaadin Ltd
+ * @since 7.0.0
+ */
+@Connect(BrowserWindowOpener.class)
+public class BrowserWindowOpenerConnector extends AbstractExtensionConnector
+ implements ClickHandler {
+
+ @Override
+ protected void extend(ServerConnector target) {
+ final Widget targetWidget = ((ComponentConnector) target).getWidget();
+
+ targetWidget.addDomHandler(this, ClickEvent.getType());
+ }
+
+ @Override
+ public BrowserWindowOpenerState getState() {
+ return (BrowserWindowOpenerState) super.getState();
+ }
+
+ @Override
+ public void onClick(ClickEvent event) {
+ String url = getResourceUrl(BrowserWindowOpenerState.locationResource);
+ if (url != null) {
+ Window.open(url, getState().target, getState().features);
+ }
+ }
+}
+++ /dev/null
-/*
- * Copyright 2012 Vaadin Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-
-package com.vaadin.server;
-
-import com.vaadin.shared.ApplicationConstants;
-import com.vaadin.shared.ui.BrowserPopupExtensionState;
-import com.vaadin.ui.AbstractComponent;
-import com.vaadin.ui.UI;
-
-/**
- * Component extension that opens a browser popup window when the extended
- * component is clicked.
- *
- * @author Vaadin Ltd
- * @since 7.0.0
- */
-public class BrowserPopupOpener extends AbstractExtension {
-
- private final BrowserPopupUIProvider uiProvider;
-
- /**
- * Creates a popup opener that will open popups containing the provided UI
- * class
- *
- * @param uiClass
- * the UI class that should be opened when the extended component
- * is clicked
- */
- public BrowserPopupOpener(Class<? extends UI> uiClass) {
- this(uiClass, generateUIClassUrl(uiClass));
- }
-
- /**
- * Creates a popup opener that will open popups containing the provided UI
- * using the provided path
- *
- * @param uiClass
- * the UI class that should be opened when the extended component
- * is clicked
- * @param path
- * the path that the UI should be bound to
- */
- public BrowserPopupOpener(Class<? extends UI> uiClass, String path) {
- // Create a Resource with a translated URL going to the VaadinService
- this(new ExternalResource(ApplicationConstants.APP_PROTOCOL_PREFIX
- + path), new BrowserPopupUIProvider(uiClass, path));
- }
-
- /**
- * Creates a popup opener that will open popups to the provided URL
- *
- * @param url
- * the URL to open in the popup
- */
- public BrowserPopupOpener(String url) {
- this(new ExternalResource(url));
- }
-
- /**
- * Creates a popup opener that will open popups to the provided resource
- *
- * @param resource
- * the resource to open in the popup
- */
- public BrowserPopupOpener(Resource resource) {
- this(resource, null);
- }
-
- private BrowserPopupOpener(Resource resource,
- BrowserPopupUIProvider uiProvider) {
- this.uiProvider = uiProvider;
- setResource("popup", resource);
- }
-
- public void extend(AbstractComponent target) {
- super.extend(target);
- }
-
- /**
- * Sets the target window name that will be used when opening the popup. If
- * a popup has already been opened with the same name, the contents of that
- * window will be replaced instead of opening a new window. If the name is
- * <code>null</code> or <code>"blank"</code>, the popup will always be
- * opened in a new window.
- *
- * @param popupName
- * the target name for the popups
- */
- public void setPopupName(String popupName) {
- getState().target = popupName;
- }
-
- /**
- * Gets the popup target name.
- *
- * @see #setPopupName(String)
- *
- * @return the popup target string
- */
- public String getPopupName() {
- return getState().target;
- }
-
- // Avoid breaking url to multiple lines
- // @formatter:off
- /**
- * Sets the features for opening the popup. See e.g.
- * {@link https://developer.mozilla.org/en-US/docs/DOM/window.open#Position_and_size_features}
- * for a description of the commonly supported features.
- *
- * @param features a string with popup features, or <code>null</code> to use the default features.
- */
- // @formatter:on
- public void setFeatures(String features) {
- getState().features = features;
- }
-
- /**
- * Gets the popup features.
- *
- * @see #setFeatures(String)
- * @return
- */
- public String getFeatures() {
- return getState().features;
- }
-
- @Override
- protected BrowserPopupExtensionState getState() {
- return (BrowserPopupExtensionState) super.getState();
- }
-
- @Override
- public void attach() {
- super.attach();
- if (uiProvider != null
- && !getSession().getUIProviders().contains(uiProvider)) {
- getSession().addUIProvider(uiProvider);
- }
- }
-
- @Override
- public void detach() {
- if (uiProvider != null) {
- getSession().removeUIProvider(uiProvider);
- }
- super.detach();
- }
-
- private static String generateUIClassUrl(Class<? extends UI> uiClass) {
- return "popup/" + uiClass.getSimpleName();
- }
-
-}
+++ /dev/null
-/*
- * Copyright 2012 Vaadin Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-
-package com.vaadin.server;
-
-import com.vaadin.ui.UI;
-
-public class BrowserPopupUIProvider extends UIProvider {
-
- private final String path;
- private final Class<? extends UI> uiClass;
-
- public BrowserPopupUIProvider(Class<? extends UI> uiClass, String path) {
- this.path = ensureInitialSlash(path);
- this.uiClass = uiClass;
- }
-
- private static String ensureInitialSlash(String path) {
- if (path == null) {
- return null;
- } else if (!path.startsWith("/")) {
- return '/' + path;
- } else {
- return path;
- }
- }
-
- @Override
- public Class<? extends UI> getUIClass(UIClassSelectionEvent event) {
- String requestPathInfo = event.getRequest().getPathInfo();
- if (path.equals(requestPathInfo)) {
- return uiClass;
- } else {
- return null;
- }
- }
-}
--- /dev/null
+/*
+ * Copyright 2012 Vaadin Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+
+package com.vaadin.server;
+
+import com.vaadin.shared.ApplicationConstants;
+import com.vaadin.shared.ui.BrowserWindowOpenerState;
+import com.vaadin.ui.AbstractComponent;
+import com.vaadin.ui.UI;
+
+/**
+ * Component extension that opens a browser popup window when the extended
+ * component is clicked.
+ *
+ * @author Vaadin Ltd
+ * @since 7.0.0
+ */
+public class BrowserWindowOpener extends AbstractExtension {
+
+ private static class BrowserWindowOpenerUIProvider extends UIProvider {
+
+ private final String path;
+ private final Class<? extends UI> uiClass;
+
+ public BrowserWindowOpenerUIProvider(Class<? extends UI> uiClass, String path) {
+ this.path = ensureInitialSlash(path);
+ this.uiClass = uiClass;
+ }
+
+ private static String ensureInitialSlash(String path) {
+ if (path == null) {
+ return null;
+ } else if (!path.startsWith("/")) {
+ return '/' + path;
+ } else {
+ return path;
+ }
+ }
+
+ @Override
+ public Class<? extends UI> getUIClass(UIClassSelectionEvent event) {
+ String requestPathInfo = event.getRequest().getPathInfo();
+ if (path.equals(requestPathInfo)) {
+ return uiClass;
+ } else {
+ return null;
+ }
+ }
+ }
+
+ private final BrowserWindowOpenerUIProvider uiProvider;
+
+ /**
+ * Creates a window opener that will open windows containing the provided UI
+ * class
+ *
+ * @param uiClass
+ * the UI class that should be opened when the extended component
+ * is clicked
+ */
+ public BrowserWindowOpener(Class<? extends UI> uiClass) {
+ this(uiClass, generateUIClassUrl(uiClass));
+ }
+
+ /**
+ * Creates a window opener that will open windows containing the provided UI
+ * using the provided path
+ *
+ * @param uiClass
+ * the UI class that should be opened when the extended component
+ * is clicked
+ * @param path
+ * the path that the UI should be bound to
+ */
+ public BrowserWindowOpener(Class<? extends UI> uiClass, String path) {
+ // Create a Resource with a translated URL going to the VaadinService
+ this(new ExternalResource(ApplicationConstants.APP_PROTOCOL_PREFIX
+ + path), new BrowserWindowOpenerUIProvider(uiClass, path));
+ }
+
+ /**
+ * Creates a window opener that will open windows to the provided URL
+ *
+ * @param url
+ * the URL to open in the window
+ */
+ public BrowserWindowOpener(String url) {
+ this(new ExternalResource(url));
+ }
+
+ /**
+ * Creates a window opener that will open window to the provided resource
+ *
+ * @param resource
+ * the resource to open in the window
+ */
+ public BrowserWindowOpener(Resource resource) {
+ this(resource, null);
+ }
+
+ private BrowserWindowOpener(Resource resource,
+ BrowserWindowOpenerUIProvider uiProvider) {
+ this.uiProvider = uiProvider;
+ setResource(BrowserWindowOpenerState.locationResource, resource);
+ }
+
+ public void extend(AbstractComponent target) {
+ super.extend(target);
+ }
+
+ /**
+ * Sets the target window name that will be used. If a window has already
+ * been opened with the same name, the contents of that window will be
+ * replaced instead of opening a new window. If the name is
+ * <code>null</code> or <code>"_blank"</code>, a new window will always be
+ * opened.
+ *
+ * @param windowName
+ * the target name for the window
+ */
+ public void setWindowName(String windowName) {
+ getState().target = windowName;
+ }
+
+ /**
+ * Gets the target window name.
+ *
+ * @see #setWindowName(String)
+ *
+ * @return the window target string
+ */
+ public String getWindowName() {
+ return getState().target;
+ }
+
+ // Avoid breaking url to multiple lines
+ // @formatter:off
+ /**
+ * Sets the features for opening the window. See e.g.
+ * {@link https://developer.mozilla.org/en-US/docs/DOM/window.open#Position_and_size_features}
+ * for a description of the commonly supported features.
+ *
+ * @param features a string with window features, or <code>null</code> to use the default features.
+ */
+ // @formatter:on
+ public void setFeatures(String features) {
+ getState().features = features;
+ }
+
+ /**
+ * Gets the window features.
+ *
+ * @see #setFeatures(String)
+ * @return
+ */
+ public String getFeatures() {
+ return getState().features;
+ }
+
+ @Override
+ protected BrowserWindowOpenerState getState() {
+ return (BrowserWindowOpenerState) super.getState();
+ }
+
+ @Override
+ public void attach() {
+ super.attach();
+ if (uiProvider != null
+ && !getSession().getUIProviders().contains(uiProvider)) {
+ getSession().addUIProvider(uiProvider);
+ }
+ }
+
+ @Override
+ public void detach() {
+ if (uiProvider != null) {
+ getSession().removeUIProvider(uiProvider);
+ }
+ super.detach();
+ }
+
+ private static String generateUIClassUrl(Class<? extends UI> uiClass) {
+ return "popup/" + uiClass.getSimpleName();
+ }
+
+}
+++ /dev/null
-/*
- * Copyright 2012 Vaadin Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-
-package com.vaadin.shared.ui;
-
-import com.vaadin.shared.AbstractComponentState;
-
-public class BrowserPopupExtensionState extends AbstractComponentState {
-
- public String target = "_blank";
-
- public String features;
-
-}
--- /dev/null
+/*
+ * Copyright 2012 Vaadin Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+
+package com.vaadin.shared.ui;
+
+import com.vaadin.shared.AbstractComponentState;
+
+public class BrowserWindowOpenerState extends AbstractComponentState {
+ public static final String locationResource = "url";
+
+ public String target = "_blank";
+
+ public String features;
+
+}
import java.util.ArrayList;
import java.util.List;
-import com.vaadin.server.BrowserPopupOpener;
+import com.vaadin.server.BrowserWindowOpener;
import com.vaadin.server.VaadinRequest;
import com.vaadin.tests.components.AbstractTestUI;
import com.vaadin.tests.components.popupview.ReopenPopupView;
addComponents(components, "http://vaadin.com/download/nightly/");
Button uiClassButton = new Button("Open UI class");
- new BrowserPopupOpener(ReopenPopupView.class).extend(uiClassButton);
+ new BrowserWindowOpener(ReopenPopupView.class).extend(uiClassButton);
addComponent(uiClassButton);
Button uiWithPath = new Button("Open UI class with path");
- new BrowserPopupOpener(ReopenPopupView.class, "foobar")
+ new BrowserWindowOpener(ReopenPopupView.class, "foobar")
.extend(uiWithPath);
addComponent(uiWithPath);
Button withPopupFeaturesButton = new Button("Open with features");
- BrowserPopupOpener featuresPopup = new BrowserPopupOpener(
+ BrowserWindowOpener featuresPopup = new BrowserWindowOpener(
"http://vaadin.com/download/nightly/");
featuresPopup.setFeatures("width=400,height=400");
featuresPopup.extend(withPopupFeaturesButton);
c.setHeight("100px");
hl.addComponent(c);
- new BrowserPopupOpener(URL).extend(c);
+ new BrowserWindowOpener(URL).extend(c);
if (c instanceof Button) {
((Button) c).addClickListener(new ClickListener() {
@Override
protected String getTestDescription() {
- return "Test for " + BrowserPopupOpener.class.getSimpleName()
+ return "Test for " + BrowserWindowOpener.class.getSimpleName()
+ " features";
}
package com.vaadin.tests.minitutorials.v7b6;
-import com.vaadin.server.BrowserPopupOpener;
+import com.vaadin.server.BrowserWindowOpener;
import com.vaadin.server.VaadinRequest;
import com.vaadin.ui.Button;
import com.vaadin.ui.UI;
protected void init(VaadinRequest request) {
Button popupButton = new Button("Open popup with MyPopupUI");
- BrowserPopupOpener popupOpener = new BrowserPopupOpener(MyPopupUI.class);
+ BrowserWindowOpener popupOpener = new BrowserWindowOpener(MyPopupUI.class);
popupOpener.setFeatures("height=300,width=300");
popupOpener.extend(popupButton);