-/*
+/*
* Copyright 2011 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
public void onStateChanged(StateChangeEvent stateChangeEvent) {
super.onStateChanged(stateChangeEvent);
- Set<String> newNames = getState().getNames();
+ Set<String> newNames = getState().names;
// Current names now only contains orphan callbacks
currentNames.removeAll(newNames);
public void onStateChanged(StateChangeEvent stateChangeEvent) {
super.onStateChanged(stateChangeEvent);
- for (int i = 0; i < getState().getSources().size(); i++) {
- URLReference source = getState().getSources().get(i);
- String sourceType = getState().getSourceTypes().get(i);
+ for (int i = 0; i < getState().sources.size(); i++) {
+ URLReference source = getState().sources.get(i);
+ String sourceType = getState().sourceTypes.get(i);
getWidget().addSource(source.getURL(), sourceType);
}
- setAltText(getState().getAltText());
+ setAltText(getState().altText);
}
@Override
if (altText == null || "".equals(altText)) {
altText = getDefaultAltHtml();
- } else if (!getState().isHtmlContentAllowed()) {
+ } else if (!getState().htmlContentAllowed) {
altText = Util.escapeHTML(altText);
}
getWidget().setAltText(altText);
Style style = getWidget().getElement().getStyle();
// Make sure that the controls are not clipped if visible.
- if (getState().isShowControls()
+ if (getState().showControls
&& (style.getHeight() == null || "".equals(style.getHeight()))) {
if (BrowserInfo.get().isChrome()) {
style.setHeight(32, Unit.PX);
-/*\r
- * Copyright 2011 Vaadin Ltd.\r
- * \r
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not\r
- * use this file except in compliance with the License. You may obtain a copy of\r
- * the License at\r
- * \r
- * http://www.apache.org/licenses/LICENSE-2.0\r
- * \r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT\r
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the\r
- * License for the specific language governing permissions and limitations under\r
- * the License.\r
- */\r
-\r
-package com.vaadin.server;\r
-\r
-import com.vaadin.Application;\r
-import com.vaadin.ui.UI;\r
-\r
-public abstract class AbstractUIProvider implements UIProvider {\r
-\r
- @Override\r
- public UI instantiateUI(Application application, Class<? extends UI> type,\r
- WrappedRequest request) {\r
- try {\r
- return type.newInstance();\r
- } catch (InstantiationException e) {\r
- throw new RuntimeException("Could not instantiate root class", e);\r
- } catch (IllegalAccessException e) {\r
- throw new RuntimeException("Could not access root class", e);\r
- }\r
- }\r
-}\r
+/*
+ * Copyright 2011 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.Application;
+import com.vaadin.ui.UI;
+
+public abstract class AbstractUIProvider implements UIProvider {
+
+ @Override
+ public UI instantiateUI(Application application, Class<? extends UI> type,
+ WrappedRequest request) {
+ try {
+ return type.newInstance();
+ } catch (InstantiationException e) {
+ throw new RuntimeException("Could not instantiate root class", e);
+ } catch (IllegalAccessException e) {
+ throw new RuntimeException("Could not access root class", e);
+ }
+ }
+}
-/*\r
- * Copyright 2011 Vaadin Ltd.\r
- * \r
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not\r
- * use this file except in compliance with the License. You may obtain a copy of\r
- * the License at\r
- * \r
- * http://www.apache.org/licenses/LICENSE-2.0\r
- * \r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT\r
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the\r
- * License for the specific language governing permissions and limitations under\r
- * the License.\r
- */\r
-\r
-package com.vaadin.server;\r
-\r
-import com.vaadin.Application;\r
-import com.vaadin.UIRequiresMoreInformationException;\r
-import com.vaadin.ui.UI;\r
-\r
-public class DefaultUIProvider extends AbstractUIProvider {\r
-\r
- @Override\r
- public Class<? extends UI> getUIClass(Application application,\r
- WrappedRequest request) throws UIRequiresMoreInformationException {\r
- Object uiClassNameObj = application\r
- .getProperty(Application.UI_PARAMETER);\r
-\r
- if (uiClassNameObj instanceof String) {\r
- String uiClassName = uiClassNameObj.toString();\r
-\r
- ClassLoader classLoader = request.getDeploymentConfiguration()\r
- .getClassLoader();\r
- if (classLoader == null) {\r
- classLoader = getClass().getClassLoader();\r
- }\r
- try {\r
- Class<? extends UI> uiClass = Class.forName(uiClassName, true,\r
- classLoader).asSubclass(UI.class);\r
-\r
- return uiClass;\r
- } catch (ClassNotFoundException e) {\r
- throw new RuntimeException("Could not find UI class", e);\r
- }\r
- }\r
-\r
- return null;\r
- }\r
-}\r
+/*
+ * Copyright 2011 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.Application;
+import com.vaadin.UIRequiresMoreInformationException;
+import com.vaadin.ui.UI;
+
+public class DefaultUIProvider extends AbstractUIProvider {
+
+ @Override
+ public Class<? extends UI> getUIClass(Application application,
+ WrappedRequest request) throws UIRequiresMoreInformationException {
+ Object uiClassNameObj = application
+ .getProperty(Application.UI_PARAMETER);
+
+ if (uiClassNameObj instanceof String) {
+ String uiClassName = uiClassNameObj.toString();
+
+ ClassLoader classLoader = request.getDeploymentConfiguration()
+ .getClassLoader();
+ if (classLoader == null) {
+ classLoader = getClass().getClassLoader();
+ }
+ try {
+ Class<? extends UI> uiClass = Class.forName(uiClassName, true,
+ classLoader).asSubclass(UI.class);
+
+ return uiClass;
+ } catch (ClassNotFoundException e) {
+ throw new RuntimeException("Could not find UI class", e);
+ }
+ }
+
+ return null;
+ }
+}
-/*\r
- * Copyright 2011 Vaadin Ltd.\r
- * \r
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not\r
- * use this file except in compliance with the License. You may obtain a copy of\r
- * the License at\r
- * \r
- * http://www.apache.org/licenses/LICENSE-2.0\r
- * \r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT\r
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the\r
- * License for the specific language governing permissions and limitations under\r
- * the License.\r
- */\r
-\r
-package com.vaadin.server;\r
-\r
-import com.vaadin.Application;\r
-import com.vaadin.UIRequiresMoreInformationException;\r
-import com.vaadin.ui.UI;\r
-\r
-public interface UIProvider {\r
- public Class<? extends UI> getUIClass(Application application,\r
- WrappedRequest request) throws UIRequiresMoreInformationException;\r
-\r
- public UI instantiateUI(Application application, Class<? extends UI> type,\r
- WrappedRequest request);\r
-}\r
+/*
+ * Copyright 2011 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.Application;
+import com.vaadin.UIRequiresMoreInformationException;
+import com.vaadin.ui.UI;
+
+public interface UIProvider {
+ public Class<? extends UI> getUIClass(Application application,
+ WrappedRequest request) throws UIRequiresMoreInformationException;
+
+ public UI instantiateUI(Application application, Class<? extends UI> type,
+ WrappedRequest request);
+}
}
private void clearSources() {
- getState().getSources().clear();
- getState().getSourceTypes().clear();
+ getState().sources.clear();
+ getState().sourceTypes.clear();
}
/**
*/
public void addSource(Resource source) {
if (source != null) {
- List<URLReference> sources = getState().getSources();
+ List<URLReference> sources = getState().sources;
sources.add(new ResourceReference(source, this, Integer
.toString(sources.size())));
- getState().getSourceTypes().add(source.getMIMEType());
+ getState().sourceTypes.add(source.getMIMEType());
}
}
WrappedResponse response, String path) throws IOException {
Matcher matcher = Pattern.compile("(\\d+)(/.*)?").matcher(path);
if (matcher.matches()) {
- List<URLReference> sources = getState().getSources();
+ List<URLReference> sources = getState().sources;
int sourceIndex = Integer.parseInt(matcher.group(1));
*/
public List<Resource> getSources() {
ArrayList<Resource> sources = new ArrayList<Resource>();
- for (URLReference ref : getState().getSources()) {
+ for (URLReference ref : getState().sources) {
sources.add(((ResourceReference) ref).getResource());
}
return sources;
* @param showControls
*/
public void setShowControls(boolean showControls) {
- getState().setShowControls(showControls);
+ getState().showControls = showControls;
}
/**
* @return true if the browser is to show native media controls.
*/
public boolean isShowControls() {
- return getState().isShowControls();
+ return getState().showControls;
}
/**
* @param altText
*/
public void setAltText(String altText) {
- getState().setAltText(altText);
+ getState().altText = altText;
}
/**
* HTML5.
*/
public String getAltText() {
- return getState().getAltText();
+ return getState().altText;
}
/**
* @param htmlContentAllowed
*/
public void setHtmlContentAllowed(boolean htmlContentAllowed) {
- getState().setHtmlContentAllowed(htmlContentAllowed);
+ getState().htmlContentAllowed = htmlContentAllowed;
}
/**
* be rendered as HTML.
*/
public boolean isHtmlContentAllowed() {
- return getState().isHtmlContentAllowed();
+ return getState().htmlContentAllowed;
}
/**
* @param autoplay
*/
public void setAutoplay(boolean autoplay) {
- getState().setAutoplay(autoplay);
+ getState().autoplay = autoplay;
}
/**
* @return true if the media is set to automatically start playback.
*/
public boolean isAutoplay() {
- return getState().isAutoplay();
+ return getState().autoplay;
}
/**
* @param muted
*/
public void setMuted(boolean muted) {
- getState().setMuted(muted);
+ getState().muted = muted;
}
/**
* @return true if the audio is muted.
*/
public boolean isMuted() {
- return getState().isMuted();
+ return getState().muted;
}
/**
-/*
+/*
* Copyright 2011 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
*/
public void addFunction(String name, JavaScriptFunction function) {
functions.put(name, function);
- getState().getNames().add(name);
+ getState().names.add(name);
}
/**
*/
public void removeFunction(String name) {
functions.remove(name);
- getState().getNames().remove(name);
+ getState().names.remove(name);
}
/**
-/*
+/*
* Copyright 2011 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
-/*
+/*
* Copyright 2011 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
import com.vaadin.shared.communication.SharedState;
public class JavaScriptManagerState extends SharedState {
- private Set<String> names = new HashSet<String>();
-
- public Set<String> getNames() {
- return names;
- }
-
- public void setNames(Set<String> names) {
- this.names = names;
- }
+ public Set<String> names = new HashSet<String>();
}
import java.util.List;
import com.vaadin.shared.ComponentState;
-import com.vaadin.shared.annotations.DelegateToWidget;
import com.vaadin.shared.communication.URLReference;
public class AbstractMediaState extends ComponentState {
- private boolean showControls;
+ public boolean showControls;
- private String altText;
+ public String altText;
- private boolean htmlContentAllowed;
+ public boolean htmlContentAllowed;
- private boolean autoplay;
+ public boolean autoplay;
- private boolean muted;
+ public boolean muted;
- private List<URLReference> sources = new ArrayList<URLReference>();
- private List<String> sourceTypes = new ArrayList<String>();
-
- public boolean isShowControls() {
- return showControls;
- }
-
- @DelegateToWidget("setControls")
- public void setShowControls(boolean showControls) {
- this.showControls = showControls;
- }
-
- public String getAltText() {
- return altText;
- }
-
- public void setAltText(String altText) {
- this.altText = altText;
- }
-
- public boolean isHtmlContentAllowed() {
- return htmlContentAllowed;
- }
-
- public void setHtmlContentAllowed(boolean htmlContentAllowed) {
- this.htmlContentAllowed = htmlContentAllowed;
- }
-
- public boolean isAutoplay() {
- return autoplay;
- }
-
- @DelegateToWidget
- public void setAutoplay(boolean autoplay) {
- this.autoplay = autoplay;
- }
-
- public boolean isMuted() {
- return muted;
- }
-
- @DelegateToWidget
- public void setMuted(boolean muted) {
- this.muted = muted;
- }
-
- public List<URLReference> getSources() {
- return sources;
- }
-
- public void setSources(List<URLReference> sources) {
- this.sources = sources;
- }
-
- public List<String> getSourceTypes() {
- return sourceTypes;
- }
-
- public void setSourceTypes(List<String> sourceTypes) {
- this.sourceTypes = sourceTypes;
- }
+ public List<URLReference> sources = new ArrayList<URLReference>();
+ public List<String> sourceTypes = new ArrayList<String>();
}
-package com.vaadin.tests.components.loginform;\r
-\r
-import com.vaadin.tests.components.TestBase;\r
-import com.vaadin.ui.Label;\r
-import com.vaadin.ui.LoginForm;\r
-import com.vaadin.ui.LoginForm.LoginEvent;\r
-import com.vaadin.ui.LoginForm.LoginListener;\r
-import com.vaadin.ui.UI;\r
-\r
-public class LoginFormUIInLoginHandler extends TestBase {\r
-\r
- @Override\r
- protected void setup() {\r
- LoginForm lf = new LoginForm();\r
- lf.addListener(new LoginListener() {\r
-\r
- @Override\r
- public void onLogin(LoginEvent event) {\r
- UI r1 = UI.getCurrent();\r
- if (r1 != null) {\r
- addComponent(new Label("UI.getCurrent().data: "\r
- + r1.getData()));\r
- } else {\r
- addComponent(new Label("UI.getCurrent() is null"));\r
- }\r
- UI r2 = ((LoginForm) event.getSource()).getUI();\r
- if (r2 != null) {\r
- addComponent(new Label("event.getSource().data: "\r
- + r2.getData()));\r
- } else {\r
- addComponent(new Label(\r
- "event.getSource().getRoot() is null"));\r
- }\r
- }\r
- });\r
- addComponent(lf);\r
- getLayout().getUI().setData("This UI");\r
- }\r
-\r
- @Override\r
- protected String getDescription() {\r
- // TODO Auto-generated method stub\r
- return null;\r
- }\r
-\r
- @Override\r
- protected Integer getTicketNumber() {\r
- // TODO Auto-generated method stub\r
- return null;\r
- }\r
-\r
-}\r
+package com.vaadin.tests.components.loginform;
+
+import com.vaadin.tests.components.TestBase;
+import com.vaadin.ui.Label;
+import com.vaadin.ui.LoginForm;
+import com.vaadin.ui.LoginForm.LoginEvent;
+import com.vaadin.ui.LoginForm.LoginListener;
+import com.vaadin.ui.UI;
+
+public class LoginFormUIInLoginHandler extends TestBase {
+
+ @Override
+ protected void setup() {
+ LoginForm lf = new LoginForm();
+ lf.addListener(new LoginListener() {
+
+ @Override
+ public void onLogin(LoginEvent event) {
+ UI r1 = UI.getCurrent();
+ if (r1 != null) {
+ addComponent(new Label("UI.getCurrent().data: "
+ + r1.getData()));
+ } else {
+ addComponent(new Label("UI.getCurrent() is null"));
+ }
+ UI r2 = ((LoginForm) event.getSource()).getUI();
+ if (r2 != null) {
+ addComponent(new Label("event.getSource().data: "
+ + r2.getData()));
+ } else {
+ addComponent(new Label(
+ "event.getSource().getRoot() is null"));
+ }
+ }
+ });
+ addComponent(lf);
+ getLayout().getUI().setData("This UI");
+ }
+
+ @Override
+ protected String getDescription() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+}