Pārlūkot izejas kodu

Add @NoLayout annotation (#12936)

This commit adds support for @NoLayout and updates most framework
components to use the annotation where it makes sense

Change-Id: I99320a6aa6de717da5f2463dd8acfcd412165767
tags/7.4.0.beta1
Leif Åstrand pirms 10 gadiem
vecāks
revīzija
ec1d9a12ca
35 mainītis faili ar 611 papildinājumiem un 15 dzēšanām
  1. 22
    0
      client-compiler/src/com/vaadin/server/widgetsetutils/ConnectorBundleLoaderFactory.java
  2. 4
    0
      client-compiler/src/com/vaadin/server/widgetsetutils/metadata/ClientRpcVisitor.java
  3. 20
    0
      client-compiler/src/com/vaadin/server/widgetsetutils/metadata/ConnectorBundle.java
  4. 55
    13
      client/src/com/vaadin/client/ApplicationConnection.java
  5. 15
    2
      client/src/com/vaadin/client/communication/RpcManager.java
  6. 14
    0
      client/src/com/vaadin/client/metadata/Method.java
  7. 13
    0
      client/src/com/vaadin/client/metadata/Property.java
  8. 54
    0
      client/src/com/vaadin/client/metadata/TypeDataStore.java
  9. 3
    0
      shared/src/com/vaadin/shared/AbstractComponentState.java
  10. 43
    0
      shared/src/com/vaadin/shared/annotations/NoLayout.java
  11. 2
    0
      shared/src/com/vaadin/shared/communication/SharedState.java
  12. 4
    0
      shared/src/com/vaadin/shared/data/DataProviderRpc.java
  13. 2
    0
      shared/src/com/vaadin/shared/ui/AbstractEmbeddedState.java
  14. 4
    0
      shared/src/com/vaadin/shared/ui/AbstractMediaState.java
  15. 3
    0
      shared/src/com/vaadin/shared/ui/MediaControl.java
  16. 2
    0
      shared/src/com/vaadin/shared/ui/TabIndexState.java
  17. 4
    0
      shared/src/com/vaadin/shared/ui/button/ButtonState.java
  18. 3
    0
      shared/src/com/vaadin/shared/ui/datefield/PopupDateFieldState.java
  19. 3
    0
      shared/src/com/vaadin/shared/ui/datefield/TextualDateFieldState.java
  20. 3
    0
      shared/src/com/vaadin/shared/ui/panel/PanelState.java
  21. 2
    0
      shared/src/com/vaadin/shared/ui/popupview/PopupViewState.java
  22. 2
    0
      shared/src/com/vaadin/shared/ui/progressindicator/ProgressBarState.java
  23. 3
    0
      shared/src/com/vaadin/shared/ui/progressindicator/ProgressIndicatorState.java
  24. 5
    0
      shared/src/com/vaadin/shared/ui/slider/SliderState.java
  25. 2
    0
      shared/src/com/vaadin/shared/ui/tabsheet/TabsheetState.java
  26. 2
    0
      shared/src/com/vaadin/shared/ui/textarea/TextAreaState.java
  27. 4
    0
      shared/src/com/vaadin/shared/ui/textfield/AbstractTextFieldState.java
  28. 3
    0
      shared/src/com/vaadin/shared/ui/ui/ScrollClientRpc.java
  29. 15
    0
      shared/src/com/vaadin/shared/ui/window/WindowState.java
  30. 101
    0
      uitest/src/com/vaadin/tests/serialization/NoLayout.java
  31. 84
    0
      uitest/src/com/vaadin/tests/serialization/NoLayoutTest.java
  32. 61
    0
      uitest/src/com/vaadin/tests/widgetset/client/LayoutDetectorConnector.java
  33. 26
    0
      uitest/src/com/vaadin/tests/widgetset/client/NoLayoutRpc.java
  34. 2
    0
      uitest/src/com/vaadin/tests/widgetset/client/RoundTripTesterRpc.java
  35. 26
    0
      uitest/src/com/vaadin/tests/widgetset/server/LayoutDetector.java

+ 22
- 0
client-compiler/src/com/vaadin/server/widgetsetutils/ConnectorBundleLoaderFactory.java Parādīt failu

import com.vaadin.server.widgetsetutils.metadata.WidgetInitVisitor; import com.vaadin.server.widgetsetutils.metadata.WidgetInitVisitor;
import com.vaadin.shared.annotations.Delayed; import com.vaadin.shared.annotations.Delayed;
import com.vaadin.shared.annotations.DelegateToWidget; import com.vaadin.shared.annotations.DelegateToWidget;
import com.vaadin.shared.annotations.NoLayout;
import com.vaadin.shared.communication.ClientRpc; import com.vaadin.shared.communication.ClientRpc;
import com.vaadin.shared.communication.ServerRpc; import com.vaadin.shared.communication.ServerRpc;
import com.vaadin.shared.ui.Connect; import com.vaadin.shared.ui.Connect;
writer.println("var data = {"); writer.println("var data = {");
writer.indent(); writer.indent();


if (property.getAnnotation(NoLayout.class) != null) {
writer.println("noLayout: 1, ");
}

writer.println("setter: function(bean, value) {"); writer.println("setter: function(bean, value) {");
writer.indent(); writer.indent();
property.writeSetterBody(logger, writer, "bean", "value"); property.writeSetterBody(logger, writer, "bean", "value");
writeParamTypes(w, bundle); writeParamTypes(w, bundle);
writeProxys(w, bundle); writeProxys(w, bundle);
writeDelayedInfo(w, bundle); writeDelayedInfo(w, bundle);
writeNoLayoutRpcMethods(w, bundle);


w.println("%s(store);", loadNativeJsMethodName); w.println("%s(store);", loadNativeJsMethodName);


writeOnStateChangeHandlers(logger, w, bundle); writeOnStateChangeHandlers(logger, w, bundle);
} }


private void writeNoLayoutRpcMethods(SplittingSourceWriter w,
ConnectorBundle bundle) {
Map<JClassType, Set<JMethod>> needsNoLayout = bundle
.getNeedsNoLayoutRpcMethods();
for (Entry<JClassType, Set<JMethod>> entry : needsNoLayout.entrySet()) {
JClassType type = entry.getKey();

for (JMethod method : entry.getValue()) {
w.println("store.setNoLayoutRpcMethod(%s, \"%s\");",
getClassLiteralString(type), method.getName());
}

w.splitIfNeeded();
}
}

private void writeOnStateChangeHandlers(TreeLogger logger, private void writeOnStateChangeHandlers(TreeLogger logger,
SplittingSourceWriter w, ConnectorBundle bundle) SplittingSourceWriter w, ConnectorBundle bundle)
throws UnableToCompleteException { throws UnableToCompleteException {

+ 4
- 0
client-compiler/src/com/vaadin/server/widgetsetutils/metadata/ClientRpcVisitor.java Parādīt failu

import com.google.gwt.core.ext.typeinfo.JClassType; import com.google.gwt.core.ext.typeinfo.JClassType;
import com.google.gwt.core.ext.typeinfo.JMethod; import com.google.gwt.core.ext.typeinfo.JMethod;
import com.google.gwt.core.ext.typeinfo.JType; import com.google.gwt.core.ext.typeinfo.JType;
import com.vaadin.shared.annotations.NoLayout;


public class ClientRpcVisitor extends TypeVisitor { public class ClientRpcVisitor extends TypeVisitor {
@Override @Override


bundle.setNeedsInvoker(type, method); bundle.setNeedsInvoker(type, method);
bundle.setNeedsParamTypes(type, method); bundle.setNeedsParamTypes(type, method);
if (method.getAnnotation(NoLayout.class) != null) {
bundle.setNeedsNoLayoutRpcMethod(type, method);
}


JType[] parameterTypes = method.getParameterTypes(); JType[] parameterTypes = method.getParameterTypes();
for (JType paramType : parameterTypes) { for (JType paramType : parameterTypes) {

+ 20
- 0
client-compiler/src/com/vaadin/server/widgetsetutils/metadata/ConnectorBundle.java Parādīt failu

private final Map<JClassType, Set<JMethod>> needsParamTypes = new HashMap<JClassType, Set<JMethod>>(); private final Map<JClassType, Set<JMethod>> needsParamTypes = new HashMap<JClassType, Set<JMethod>>();
private final Map<JClassType, Set<JMethod>> needsDelayedInfo = new HashMap<JClassType, Set<JMethod>>(); private final Map<JClassType, Set<JMethod>> needsDelayedInfo = new HashMap<JClassType, Set<JMethod>>();
private final Map<JClassType, Set<JMethod>> needsOnStateChange = new HashMap<JClassType, Set<JMethod>>(); private final Map<JClassType, Set<JMethod>> needsOnStateChange = new HashMap<JClassType, Set<JMethod>>();
private final Map<JClassType, Set<JMethod>> needsNoLayoutRpcMethods = new HashMap<JClassType, Set<JMethod>>();


private final Set<Property> needsProperty = new HashSet<Property>(); private final Set<Property> needsProperty = new HashSet<Property>();
private final Map<JClassType, Set<Property>> needsDelegateToWidget = new HashMap<JClassType, Set<Property>>(); private final Map<JClassType, Set<Property>> needsDelegateToWidget = new HashMap<JClassType, Set<Property>>();
return Collections.unmodifiableMap(needsOnStateChange); return Collections.unmodifiableMap(needsOnStateChange);
} }


public void setNeedsNoLayoutRpcMethod(JClassType type, JMethod method) {
if (!isNeedsNoLayoutRpcMethod(type, method)) {
addMapping(needsNoLayoutRpcMethods, type, method);
}
}

private boolean isNeedsNoLayoutRpcMethod(JClassType type, JMethod method) {
if (hasMapping(needsNoLayoutRpcMethods, type, method)) {
return true;
} else {
return previousBundle != null
&& previousBundle.isNeedsNoLayoutRpcMethod(type, method);
}
}

public Map<JClassType, Set<JMethod>> getNeedsNoLayoutRpcMethods() {
return Collections.unmodifiableMap(needsNoLayoutRpcMethods);
}

public static JMethod findInheritedMethod(JClassType type, public static JMethod findInheritedMethod(JClassType type,
String methodName, JType... params) { String methodName, JType... params) {



+ 55
- 13
client/src/com/vaadin/client/ApplicationConnection.java Parādīt failu

import com.vaadin.shared.ApplicationConstants; import com.vaadin.shared.ApplicationConstants;
import com.vaadin.shared.JsonConstants; import com.vaadin.shared.JsonConstants;
import com.vaadin.shared.Version; import com.vaadin.shared.Version;
import com.vaadin.shared.annotations.NoLayout;
import com.vaadin.shared.communication.LegacyChangeVariablesInvocation; import com.vaadin.shared.communication.LegacyChangeVariablesInvocation;
import com.vaadin.shared.communication.MethodInvocation; import com.vaadin.shared.communication.MethodInvocation;
import com.vaadin.shared.communication.SharedState; import com.vaadin.shared.communication.SharedState;
} }


Command c = new Command() { Command c = new Command() {
private boolean onlyNoLayoutUpdates = true;

@Override @Override
public void execute() { public void execute() {
assert syncId == -1 || syncId == lastSeenServerSyncId; assert syncId == -1 || syncId == lastSeenServerSyncId;
+ (Duration.currentTimeMillis() - processUidlStart) + (Duration.currentTimeMillis() - processUidlStart)
+ " ms"); + " ms");


Profiler.enter("Layout processing");
try {
LayoutManager layoutManager = getLayoutManager();
layoutManager.setEverythingNeedsMeasure();
layoutManager.layoutNow();
} catch (final Throwable e) {
VConsole.error(e);
if (!onlyNoLayoutUpdates) {
Profiler.enter("Layout processing");
try {
LayoutManager layoutManager = getLayoutManager();
layoutManager.setEverythingNeedsMeasure();
layoutManager.layoutNow();
} catch (final Throwable e) {
VConsole.error(e);
}
Profiler.leave("Layout processing");
} }
Profiler.leave("Layout processing");


if (ApplicationConfiguration.isDebugMode()) { if (ApplicationConfiguration.isDebugMode()) {
Profiler.enter("Dumping state changes to the console"); Profiler.enter("Dumping state changes to the console");
if (connector != null) { if (connector != null) {
continue; continue;
} }

// Always do layouts if there's at least one new
// connector
onlyNoLayoutUpdates = false;

int connectorType = Integer.parseInt(types int connectorType = Integer.parseInt(types
.getString(connectorId)); .getString(connectorId));


JsArray<ValueMap> changes = json.getJSValueMapArray("changes"); JsArray<ValueMap> changes = json.getJSValueMapArray("changes");
int length = changes.length(); int length = changes.length();


// Must always do layout if there's even a single legacy update
if (length != 0) {
onlyNoLayoutUpdates = false;
}

VConsole.log(" * Passing UIDL to Vaadin 6 style connectors"); VConsole.log(" * Passing UIDL to Vaadin 6 style connectors");
// update paintables // update paintables
for (int i = 0; i < length; i++) { for (int i = 0; i < length; i++) {
} }


SharedState state = connector.getState(); SharedState state = connector.getState();
Type stateType = new Type(state.getClass()
.getName(), null);

if (onlyNoLayoutUpdates) {
Profiler.enter("updateConnectorState @NoLayout handling");
Set<String> keySet = stateJson.keySet();
for (String propertyName : keySet) {
Property property = stateType
.getProperty(propertyName);
if (!property.isNoLayout()) {
onlyNoLayoutUpdates = false;
break;
}
}
Profiler.leave("updateConnectorState @NoLayout handling");
}


Profiler.enter("updateConnectorState decodeValue"); Profiler.enter("updateConnectorState decodeValue");
JsonDecoder.decodeValue(new Type(state.getClass()
.getName(), null), stateJson, state,
ApplicationConnection.this);
JsonDecoder.decodeValue(stateType, stateJson,
state, ApplicationConnection.this);
Profiler.leave("updateConnectorState decodeValue"); Profiler.leave("updateConnectorState decodeValue");


if (Profiler.isEnabled()) { if (Profiler.isEnabled()) {


Profiler.leave("updateConnectorHierarchy detach removed connectors"); Profiler.leave("updateConnectorHierarchy detach removed connectors");


if (result.events.size() != 0) {
onlyNoLayoutUpdates = false;
}

Profiler.leave("updateConnectorHierarchy"); Profiler.leave("updateConnectorHierarchy");


return result; return result;
for (int i = 0; i < rpcLength; i++) { for (int i = 0; i < rpcLength; i++) {
try { try {
JSONArray rpcCall = (JSONArray) rpcCalls.get(i); JSONArray rpcCall = (JSONArray) rpcCalls.get(i);
rpcManager.parseAndApplyInvocation(rpcCall,
ApplicationConnection.this);
MethodInvocation invocation = rpcManager
.parseAndApplyInvocation(rpcCall,
ApplicationConnection.this);

if (onlyNoLayoutUpdates
&& !RpcManager.getMethod(invocation)
.isNoLayout()) {
onlyNoLayoutUpdates = false;
}

} catch (final Throwable e) { } catch (final Throwable e) {
VConsole.error(e); VConsole.error(e);
} }

+ 15
- 2
client/src/com/vaadin/client/communication/RpcManager.java Parādīt failu

} }
} }


private Method getMethod(MethodInvocation invocation) {
/**
* Gets the method that an invocation targets.
*
* @param invocation
* the method invocation to get the method for
*
* @since
* @return the method targeted by this invocation
*/
public static Method getMethod(MethodInvocation invocation) {
// Implemented here instead of in MethodInovcation since it's in shared
// and can't use our Method class.
Type type = new Type(invocation.getInterfaceName(), null); Type type = new Type(invocation.getInterfaceName(), null);
Method method = type.getMethod(invocation.getMethodName()); Method method = type.getMethod(invocation.getMethodName());
return method; return method;
} }
} }


public void parseAndApplyInvocation(JSONArray rpcCall,
public MethodInvocation parseAndApplyInvocation(JSONArray rpcCall,
ApplicationConnection connection) { ApplicationConnection connection) {
ConnectorMap connectorMap = ConnectorMap.get(connection); ConnectorMap connectorMap = ConnectorMap.get(connection);


VConsole.log("Server to client RPC call: " + invocation); VConsole.log("Server to client RPC call: " + invocation);
applyInvocation(invocation, connector); applyInvocation(invocation, connector);
} }

return invocation;
} }


private void parseMethodParameters(MethodInvocation methodInvocation, private void parseMethodParameters(MethodInvocation methodInvocation,

+ 14
- 0
client/src/com/vaadin/client/metadata/Method.java Parādīt failu

*/ */
package com.vaadin.client.metadata; package com.vaadin.client.metadata;


import com.vaadin.shared.annotations.NoLayout;

public class Method { public class Method {


private final Type type; private final Type type;
return TypeDataStore.isLastOnly(this); return TypeDataStore.isLastOnly(this);
} }


/**
* Checks whether this method is annotated with {@link NoLayout}.
*
* @since
*
* @return <code>true</code> if this method has a NoLayout annotation;
* otherwise <code>false</code>
*/
public boolean isNoLayout() {
return TypeDataStore.isNoLayoutRpcMethod(this);
}

} }

+ 13
- 0
client/src/com/vaadin/client/metadata/Property.java Parādīt failu

package com.vaadin.client.metadata; package com.vaadin.client.metadata;


import com.vaadin.shared.annotations.DelegateToWidget; import com.vaadin.shared.annotations.DelegateToWidget;
import com.vaadin.shared.annotations.NoLayout;


public class Property { public class Property {
private final Type bean; private final Type bean;
return b.toString(); return b.toString();
} }


/**
* Checks whether this property is annotated with {@link NoLayout}.
*
* @since
*
* @return <code>true</code> if this property has a NoLayout annotation;
* otherwise <code>false</code>
*/
public boolean isNoLayout() {
return TypeDataStore.isNoLayoutProperty(this);
}

} }

+ 54
- 0
client/src/com/vaadin/client/metadata/TypeDataStore.java Parādīt failu

import com.vaadin.client.JsArrayObject; import com.vaadin.client.JsArrayObject;
import com.vaadin.client.annotations.OnStateChange; import com.vaadin.client.annotations.OnStateChange;
import com.vaadin.client.communication.JSONSerializer; import com.vaadin.client.communication.JSONSerializer;
import com.vaadin.shared.annotations.NoLayout;


public class TypeDataStore { public class TypeDataStore {
private static final String CONSTRUCTOR_NAME = "!new"; private static final String CONSTRUCTOR_NAME = "!new";


private final FastStringSet delayedMethods = FastStringSet.create(); private final FastStringSet delayedMethods = FastStringSet.create();
private final FastStringSet lastOnlyMethods = FastStringSet.create(); private final FastStringSet lastOnlyMethods = FastStringSet.create();
private final FastStringSet noLayoutRpcMethods = FastStringSet.create();


private final FastStringMap<Type> returnTypes = FastStringMap.create(); private final FastStringMap<Type> returnTypes = FastStringMap.create();
private final FastStringMap<Invoker> invokers = FastStringMap.create(); private final FastStringMap<Invoker> invokers = FastStringMap.create();
return typeData[beanName][propertyName].setter !== undefined; return typeData[beanName][propertyName].setter !== undefined;
}-*/; }-*/;


private static native boolean hasNoLayout(JavaScriptObject typeData,
String beanName, String propertyName)
/*-{
return typeData[beanName][propertyName].noLayout !== undefined;
}-*/;

private static native Object getJsPropertyValue(JavaScriptObject typeData, private static native Object getJsPropertyValue(JavaScriptObject typeData,
String beanName, String propertyName, Object beanInstance) String beanName, String propertyName, Object beanInstance)
/*-{ /*-{
propertyHandlers.add(method); propertyHandlers.add(method);
} }
} }

/**
* Checks whether the provided method is annotated with {@link NoLayout}.
*
* @param method
* the rpc method to check
*
* @since
*
* @return <code>true</code> if the method has a NoLayout annotation;
* otherwise <code>false</code>
*/
public static boolean isNoLayoutRpcMethod(Method method) {
return get().noLayoutRpcMethods.contains(method.getLookupKey());
}

/**
* Defines that a method is annotated with {@link NoLayout}.
*
* @since
*
* @param type
* the where the method is defined
* @param methodName
* the name of the method
*/
public void setNoLayoutRpcMethod(Class<?> type, String methodName) {
noLayoutRpcMethods.add(new Method(getType(type), methodName)
.getLookupKey());
}

/**
* Checks whether the provided property is annotated with {@link NoLayout}.
*
* @param property
* the property to check
*
* @since
*
* @return <code>true</code> if the property has a NoLayout annotation;
* otherwise <code>false</code>
*/
public static boolean isNoLayoutProperty(Property property) {
return hasNoLayout(get().jsTypeData, property.getBeanType()
.getSignature(), property.getName());
}
} }

+ 3
- 0
shared/src/com/vaadin/shared/AbstractComponentState.java Parādīt failu



import java.util.List; import java.util.List;


import com.vaadin.shared.annotations.NoLayout;
import com.vaadin.shared.communication.SharedState; import com.vaadin.shared.communication.SharedState;


/** /**
public String height = ""; public String height = "";
public String width = ""; public String width = "";
public boolean readOnly = false; public boolean readOnly = false;
@NoLayout
public boolean immediate = false; public boolean immediate = false;
@NoLayout
public String description = ""; public String description = "";
// Note: for the caption, there is a difference between null and an empty // Note: for the caption, there is a difference between null and an empty
// string! // string!

+ 43
- 0
shared/src/com/vaadin/shared/annotations/NoLayout.java Parādīt failu

/*
* Copyright 2000-2014 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.annotations;

import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Target;

/**
* Annotation used to mark client RPC methods, state fields, or state setter
* methods that should not trigger an layout phase after changes have been
* processed. Whenever there's at least one change that is not marked with this
* annotation, the framework will assume some sizes might have changed an will
* therefore start a layout phase after applying the changes.
* <p>
* This annotation can be used for any RPC method or state property that does
* not cause the size of the component or its children to change. Please note
* that almost anything related to CSS (e.g. adding or removing a stylename) has
* the potential of causing sizes to change with appropriate style definitions
* in the application theme.
*
* @since
*
* @author Vaadin Ltd
*/
@Documented
@Target({ ElementType.METHOD, ElementType.FIELD })
public @interface NoLayout {
// Just an empty marker annotation
}

+ 2
- 0
shared/src/com/vaadin/shared/communication/SharedState.java Parādīt failu

import java.util.Set; import java.util.Set;


import com.vaadin.shared.Connector; import com.vaadin.shared.Connector;
import com.vaadin.shared.annotations.NoLayout;


/** /**
* Interface to be implemented by all shared state classes used to communicate * Interface to be implemented by all shared state classes used to communicate
/** /**
* A set of event identifiers with registered listeners. * A set of event identifiers with registered listeners.
*/ */
@NoLayout
public Set<String> registeredEventListeners = null; public Set<String> registeredEventListeners = null;


} }

+ 4
- 0
shared/src/com/vaadin/shared/data/DataProviderRpc.java Parādīt failu



package com.vaadin.shared.data; package com.vaadin.shared.data;


import com.vaadin.shared.annotations.NoLayout;
import com.vaadin.shared.communication.ClientRpc; import com.vaadin.shared.communication.ClientRpc;


/** /**
* @see com.vaadin.shared.ui.grid.GridState#JSONKEY_DATA * @see com.vaadin.shared.ui.grid.GridState#JSONKEY_DATA
* @see com.vaadin.ui.components.grid.Renderer#encode(Object) * @see com.vaadin.ui.components.grid.Renderer#encode(Object)
*/ */
@NoLayout
public void setRowData(int firstRowIndex, String rowDataJson); public void setRowData(int firstRowIndex, String rowDataJson);


/** /**
* the number of rows removed from <code>firstRowIndex</code> and * the number of rows removed from <code>firstRowIndex</code> and
* onwards * onwards
*/ */
@NoLayout
public void removeRowData(int firstRowIndex, int count); public void removeRowData(int firstRowIndex, int count);


/** /**
* @param count * @param count
* the number of rows inserted at <code>firstRowIndex</code> * the number of rows inserted at <code>firstRowIndex</code>
*/ */
@NoLayout
public void insertRowData(int firstRowIndex, int count); public void insertRowData(int firstRowIndex, int count);


/** /**

+ 2
- 0
shared/src/com/vaadin/shared/ui/AbstractEmbeddedState.java Parādīt failu

package com.vaadin.shared.ui; package com.vaadin.shared.ui;


import com.vaadin.shared.AbstractComponentState; import com.vaadin.shared.AbstractComponentState;
import com.vaadin.shared.annotations.NoLayout;


public class AbstractEmbeddedState extends AbstractComponentState { public class AbstractEmbeddedState extends AbstractComponentState {


public static final String SOURCE_RESOURCE = "source"; public static final String SOURCE_RESOURCE = "source";


@NoLayout
public String alternateText; public String alternateText;
} }

+ 4
- 0
shared/src/com/vaadin/shared/ui/AbstractMediaState.java Parādīt failu

import java.util.List; import java.util.List;


import com.vaadin.shared.AbstractComponentState; import com.vaadin.shared.AbstractComponentState;
import com.vaadin.shared.annotations.NoLayout;
import com.vaadin.shared.communication.URLReference; import com.vaadin.shared.communication.URLReference;


public class AbstractMediaState extends AbstractComponentState { public class AbstractMediaState extends AbstractComponentState {
public boolean showControls; public boolean showControls;


@NoLayout
public String altText; public String altText;


public boolean htmlContentAllowed; public boolean htmlContentAllowed;


@NoLayout
public boolean autoplay; public boolean autoplay;


@NoLayout
public boolean muted; public boolean muted;


public List<URLReference> sources = new ArrayList<URLReference>(); public List<URLReference> sources = new ArrayList<URLReference>();

+ 3
- 0
shared/src/com/vaadin/shared/ui/MediaControl.java Parādīt failu



package com.vaadin.shared.ui; package com.vaadin.shared.ui;


import com.vaadin.shared.annotations.NoLayout;
import com.vaadin.shared.communication.ClientRpc; import com.vaadin.shared.communication.ClientRpc;


/** /**
/** /**
* Start playing the media. * Start playing the media.
*/ */
@NoLayout
public void play(); public void play();


/** /**
* Pause playback of the media. * Pause playback of the media.
*/ */
@NoLayout
public void pause(); public void pause();
} }

+ 2
- 0
shared/src/com/vaadin/shared/ui/TabIndexState.java Parādīt failu

package com.vaadin.shared.ui; package com.vaadin.shared.ui;


import com.vaadin.shared.AbstractComponentState; import com.vaadin.shared.AbstractComponentState;
import com.vaadin.shared.annotations.NoLayout;


/** /**
* Interface implemented by state classes that support tab indexes. * Interface implemented by state classes that support tab indexes.
/** /**
* The <i>tabulator index</i> of the field. * The <i>tabulator index</i> of the field.
*/ */
@NoLayout
public int tabIndex = 0; public int tabIndex = 0;


} }

+ 4
- 0
shared/src/com/vaadin/shared/ui/button/ButtonState.java Parādīt failu

package com.vaadin.shared.ui.button; package com.vaadin.shared.ui.button;


import com.vaadin.shared.AbstractComponentState; import com.vaadin.shared.AbstractComponentState;
import com.vaadin.shared.annotations.NoLayout;
import com.vaadin.shared.ui.TabIndexState; import com.vaadin.shared.ui.TabIndexState;


/** /**
{ {
primaryStyleName = "v-button"; primaryStyleName = "v-button";
} }
@NoLayout
public boolean disableOnClick = false; public boolean disableOnClick = false;
@NoLayout
public int clickShortcutKeyCode = 0; public int clickShortcutKeyCode = 0;
/** /**
* If caption should be rendered in HTML * If caption should be rendered in HTML
*/ */
public boolean htmlContentAllowed = false; public boolean htmlContentAllowed = false;
@NoLayout
public String iconAltText = ""; public String iconAltText = "";
} }

+ 3
- 0
shared/src/com/vaadin/shared/ui/datefield/PopupDateFieldState.java Parādīt failu

*/ */
package com.vaadin.shared.ui.datefield; package com.vaadin.shared.ui.datefield;


import com.vaadin.shared.annotations.NoLayout;

public class PopupDateFieldState extends TextualDateFieldState { public class PopupDateFieldState extends TextualDateFieldState {
public static final String DESCRIPTION_FOR_ASSISTIVE_DEVICES = "Arrow down key opens calendar element for choosing the date"; public static final String DESCRIPTION_FOR_ASSISTIVE_DEVICES = "Arrow down key opens calendar element for choosing the date";


} }


public boolean textFieldEnabled = true; public boolean textFieldEnabled = true;
@NoLayout
public String descriptionForAssistiveDevices = DESCRIPTION_FOR_ASSISTIVE_DEVICES; public String descriptionForAssistiveDevices = DESCRIPTION_FOR_ASSISTIVE_DEVICES;
} }

+ 3
- 0
shared/src/com/vaadin/shared/ui/datefield/TextualDateFieldState.java Parādīt failu

import java.util.Date; import java.util.Date;


import com.vaadin.shared.AbstractFieldState; import com.vaadin.shared.AbstractFieldState;
import com.vaadin.shared.annotations.NoLayout;


public class TextualDateFieldState extends AbstractFieldState { public class TextualDateFieldState extends AbstractFieldState {
{ {
* Start range that has been cleared, depending on the resolution of the * Start range that has been cleared, depending on the resolution of the
* date field * date field
*/ */
@NoLayout
public Date rangeStart = null; public Date rangeStart = null;


/* /*
* End range that has been cleared, depending on the resolution of the date * End range that has been cleared, depending on the resolution of the date
* field * field
*/ */
@NoLayout
public Date rangeEnd = null; public Date rangeEnd = null;
} }

+ 3
- 0
shared/src/com/vaadin/shared/ui/panel/PanelState.java Parādīt failu

package com.vaadin.shared.ui.panel; package com.vaadin.shared.ui.panel;


import com.vaadin.shared.AbstractComponentState; import com.vaadin.shared.AbstractComponentState;
import com.vaadin.shared.annotations.NoLayout;


public class PanelState extends AbstractComponentState { public class PanelState extends AbstractComponentState {
{ {
primaryStyleName = "v-panel"; primaryStyleName = "v-panel";
} }
@NoLayout
public int tabIndex; public int tabIndex;
@NoLayout
public int scrollLeft, scrollTop; public int scrollLeft, scrollTop;
} }

+ 2
- 0
shared/src/com/vaadin/shared/ui/popupview/PopupViewState.java Parādīt failu

package com.vaadin.shared.ui.popupview; package com.vaadin.shared.ui.popupview;


import com.vaadin.shared.AbstractComponentState; import com.vaadin.shared.AbstractComponentState;
import com.vaadin.shared.annotations.NoLayout;


public class PopupViewState extends AbstractComponentState { public class PopupViewState extends AbstractComponentState {


public String html; public String html;
@NoLayout
public boolean hideOnMouseOut; public boolean hideOnMouseOut;


} }

+ 2
- 0
shared/src/com/vaadin/shared/ui/progressindicator/ProgressBarState.java Parādīt failu

package com.vaadin.shared.ui.progressindicator; package com.vaadin.shared.ui.progressindicator;


import com.vaadin.shared.AbstractFieldState; import com.vaadin.shared.AbstractFieldState;
import com.vaadin.shared.annotations.NoLayout;
import com.vaadin.shared.communication.SharedState; import com.vaadin.shared.communication.SharedState;


/** /**
primaryStyleName = PRIMARY_STYLE_NAME; primaryStyleName = PRIMARY_STYLE_NAME;
} }
public boolean indeterminate = false; public boolean indeterminate = false;
@NoLayout
public Float state = 0.0f; public Float state = 0.0f;


} }

+ 3
- 0
shared/src/com/vaadin/shared/ui/progressindicator/ProgressIndicatorState.java Parādīt failu

*/ */
package com.vaadin.shared.ui.progressindicator; package com.vaadin.shared.ui.progressindicator;


import com.vaadin.shared.annotations.NoLayout;

@Deprecated @Deprecated
public class ProgressIndicatorState extends ProgressBarState { public class ProgressIndicatorState extends ProgressBarState {
public static final String PRIMARY_STYLE_NAME = "v-progressindicator"; public static final String PRIMARY_STYLE_NAME = "v-progressindicator";
primaryStyleName = PRIMARY_STYLE_NAME; primaryStyleName = PRIMARY_STYLE_NAME;
} }


@NoLayout
public int pollingInterval = 1000; public int pollingInterval = 1000;
} }

+ 5
- 0
shared/src/com/vaadin/shared/ui/slider/SliderState.java Parādīt failu

package com.vaadin.shared.ui.slider; package com.vaadin.shared.ui.slider;


import com.vaadin.shared.AbstractFieldState; import com.vaadin.shared.AbstractFieldState;
import com.vaadin.shared.annotations.NoLayout;


public class SliderState extends AbstractFieldState { public class SliderState extends AbstractFieldState {
{ {
primaryStyleName = "v-slider"; primaryStyleName = "v-slider";
} }


@NoLayout
public double value; public double value;


@NoLayout
public double maxValue = 100; public double maxValue = 100;
@NoLayout
public double minValue = 0; public double minValue = 0;


/** /**
* The number of fractional digits that are considered significant. Must be * The number of fractional digits that are considered significant. Must be
* non-negative. * non-negative.
*/ */
@NoLayout
public int resolution = 0; public int resolution = 0;


public SliderOrientation orientation = SliderOrientation.HORIZONTAL; public SliderOrientation orientation = SliderOrientation.HORIZONTAL;

+ 2
- 0
shared/src/com/vaadin/shared/ui/tabsheet/TabsheetState.java Parādīt failu

import java.util.List; import java.util.List;


import com.vaadin.shared.AbstractComponentState; import com.vaadin.shared.AbstractComponentState;
import com.vaadin.shared.annotations.NoLayout;


public class TabsheetState extends AbstractComponentState { public class TabsheetState extends AbstractComponentState {
public static final String PRIMARY_STYLE_NAME = "v-tabsheet"; public static final String PRIMARY_STYLE_NAME = "v-tabsheet";
* Index of the component when switching focus - not related to Tabsheet * Index of the component when switching focus - not related to Tabsheet
* tabs. * tabs.
*/ */
@NoLayout
public int tabIndex; public int tabIndex;


public List<TabState> tabs = new ArrayList<TabState>(); public List<TabState> tabs = new ArrayList<TabState>();

+ 2
- 0
shared/src/com/vaadin/shared/ui/textarea/TextAreaState.java Parādīt failu

package com.vaadin.shared.ui.textarea; package com.vaadin.shared.ui.textarea;


import com.vaadin.shared.annotations.DelegateToWidget; import com.vaadin.shared.annotations.DelegateToWidget;
import com.vaadin.shared.annotations.NoLayout;
import com.vaadin.shared.ui.textfield.AbstractTextFieldState; import com.vaadin.shared.ui.textfield.AbstractTextFieldState;


public class TextAreaState extends AbstractTextFieldState { public class TextAreaState extends AbstractTextFieldState {
* Tells if word-wrapping should be used in the text area. * Tells if word-wrapping should be used in the text area.
*/ */
@DelegateToWidget @DelegateToWidget
@NoLayout
public boolean wordwrap = true; public boolean wordwrap = true;


} }

+ 4
- 0
shared/src/com/vaadin/shared/ui/textfield/AbstractTextFieldState.java Parādīt failu

package com.vaadin.shared.ui.textfield; package com.vaadin.shared.ui.textfield;


import com.vaadin.shared.AbstractFieldState; import com.vaadin.shared.AbstractFieldState;
import com.vaadin.shared.annotations.NoLayout;


public class AbstractTextFieldState extends AbstractFieldState { public class AbstractTextFieldState extends AbstractFieldState {
{ {
/** /**
* Maximum character count in text field. * Maximum character count in text field.
*/ */
@NoLayout
public int maxLength = -1; public int maxLength = -1;


/** /**
/** /**
* The prompt to display in an empty field. Null when disabled. * The prompt to display in an empty field. Null when disabled.
*/ */
@NoLayout
public String inputPrompt = null; public String inputPrompt = null;


/** /**
* The text in the field * The text in the field
*/ */
@NoLayout
public String text = null; public String text = null;
} }

+ 3
- 0
shared/src/com/vaadin/shared/ui/ui/ScrollClientRpc.java Parādīt failu



package com.vaadin.shared.ui.ui; package com.vaadin.shared.ui.ui;


import com.vaadin.shared.annotations.NoLayout;
import com.vaadin.shared.communication.ClientRpc; import com.vaadin.shared.communication.ClientRpc;


public interface ScrollClientRpc extends ClientRpc { public interface ScrollClientRpc extends ClientRpc {


@NoLayout
public void setScrollTop(int scrollTop); public void setScrollTop(int scrollTop);


@NoLayout
public void setScrollLeft(int scrollLeft); public void setScrollLeft(int scrollLeft);
} }

+ 15
- 0
shared/src/com/vaadin/shared/ui/window/WindowState.java Parādīt failu

package com.vaadin.shared.ui.window; package com.vaadin.shared.ui.window;


import com.vaadin.shared.Connector; import com.vaadin.shared.Connector;
import com.vaadin.shared.annotations.NoLayout;
import com.vaadin.shared.ui.panel.PanelState; import com.vaadin.shared.ui.panel.PanelState;


public class WindowState extends PanelState { public class WindowState extends PanelState {
primaryStyleName = "v-window"; primaryStyleName = "v-window";
} }


@NoLayout
public boolean modal = false; public boolean modal = false;
@NoLayout
public boolean resizable = true; public boolean resizable = true;
@NoLayout
public boolean resizeLazy = false; public boolean resizeLazy = false;
@NoLayout
public boolean draggable = true; public boolean draggable = true;
@NoLayout
public boolean centered = false; public boolean centered = false;
@NoLayout
public int positionX = -1; public int positionX = -1;
@NoLayout
public int positionY = -1; public int positionY = -1;
public WindowMode windowMode = WindowMode.NORMAL; public WindowMode windowMode = WindowMode.NORMAL;


@NoLayout
public String assistivePrefix = ""; public String assistivePrefix = "";
@NoLayout
public String assistivePostfix = ""; public String assistivePostfix = "";
@NoLayout
public Connector[] contentDescription = new Connector[0]; public Connector[] contentDescription = new Connector[0];
@NoLayout
public WindowRole role = WindowRole.DIALOG; public WindowRole role = WindowRole.DIALOG;
@NoLayout
public boolean assistiveTabStop = false; public boolean assistiveTabStop = false;
@NoLayout
public String assistiveTabStopTopText = "Top of dialog"; public String assistiveTabStopTopText = "Top of dialog";
@NoLayout
public String assistiveTabStopBottomText = "Bottom of Dialog"; public String assistiveTabStopBottomText = "Bottom of Dialog";
} }

+ 101
- 0
uitest/src/com/vaadin/tests/serialization/NoLayout.java Parādīt failu

/*
* Copyright 2000-2014 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.tests.serialization;

import com.vaadin.annotations.Widgetset;
import com.vaadin.data.Property.ValueChangeEvent;
import com.vaadin.data.Property.ValueChangeListener;
import com.vaadin.server.VaadinRequest;
import com.vaadin.tests.components.AbstractTestUI;
import com.vaadin.tests.widgetset.TestingWidgetSet;
import com.vaadin.tests.widgetset.server.LayoutDetector;
import com.vaadin.ui.Button;
import com.vaadin.ui.Button.ClickEvent;
import com.vaadin.ui.CheckBox;
import com.vaadin.ui.JavaScript;

@Widgetset(TestingWidgetSet.NAME)
public class NoLayout extends AbstractTestUI {
private final LayoutDetector layoutDetector = new LayoutDetector();

@Override
protected void setup(VaadinRequest request) {
addComponent(layoutDetector);

CheckBox uiPolling = new CheckBox("UI polling enabled");
uiPolling.addValueChangeListener(new ValueChangeListener() {
@Override
public void valueChange(ValueChangeEvent event) {
if (event.getProperty().getValue() == Boolean.TRUE) {
setPollInterval(100);
} else {
setPollInterval(-1);
}
}
});
addComponent(uiPolling);

addComponent(new Button("Change regular state",
new Button.ClickListener() {
@Override
public void buttonClick(ClickEvent event) {
event.getButton().setCaption(
String.valueOf(System.currentTimeMillis()));
}
}));
addComponent(new Button("Change @NoLayout state",
new Button.ClickListener() {
@Override
public void buttonClick(ClickEvent event) {
event.getButton().setDescription(
String.valueOf(System.currentTimeMillis()));
}
}));
addComponent(new Button("Do regular RPC", new Button.ClickListener() {
@Override
public void buttonClick(ClickEvent event) {
JavaScript.eval("");
}
}));

addComponent(new Button("Do @NoLayout RPC", new Button.ClickListener() {
@Override
public void buttonClick(ClickEvent event) {
layoutDetector.doNoLayoutRpc();
}
}));

addComponent(new Button("Update LegacyComponent",
new Button.ClickListener() {
@Override
public void buttonClick(ClickEvent event) {
// Assumes UI is a LegacyComponent
markAsDirty();
}
}));
}

@Override
protected String getTestDescription() {
return "Checks which actions trigger a layout phase";
}

@Override
protected Integer getTicketNumber() {
return Integer.valueOf(12936);
}

}

+ 84
- 0
uitest/src/com/vaadin/tests/serialization/NoLayoutTest.java Parādīt failu

/*
* Copyright 2000-2014 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.tests.serialization;

import org.junit.Assert;
import org.junit.Test;
import org.openqa.selenium.By;

import com.vaadin.testbench.elements.ButtonElement;
import com.vaadin.testbench.elements.CheckBoxElement;
import com.vaadin.tests.tb3.MultiBrowserTest;

public class NoLayoutTest extends MultiBrowserTest {
@Test
public void testNoLayout() {
openTestURL();
assertCounts(1, 0);

$(CheckBoxElement.class).caption("UI polling enabled").first()
.findElement(By.tagName("input")).click();

// Toggling check box requires layout
assertCounts(2, 0);

try {
Thread.sleep(2000);
} catch (InterruptedException e) {
e.printStackTrace();
}
// Count should not change even with polling enabled
assertCounts(2, 0);

// Disable polling
$(CheckBoxElement.class).caption("UI polling enabled").first()
.findElement(By.tagName("input")).click();
// Toggling checkbox layotus again
assertCounts(3, 0);

$(ButtonElement.class).caption("Change regular state").first().click();
// Updating normal state layouts
assertCounts(4, 0);

$(ButtonElement.class).caption("Change @NoLayout state").first();
// Updating @NoLayout state does not layout
assertCounts(4, 0);

$(ButtonElement.class).caption("Do regular RPC").first().click();
// Doing normal RPC layouts
assertCounts(5, 0);

$(ButtonElement.class).caption("Do @NoLayout RPC").first().click();
// Doing @NoLayout RPC does not layout, but updates the RPC count
assertCounts(5, 1);

$(ButtonElement.class).caption("Update LegacyComponent").first()
.click();
// Painting LegacyComponent layouts
assertCounts(6, 1);
}

private void assertCounts(int layoutCount, int rpcCount) {
Assert.assertEquals("Unexpected layout count", layoutCount,
getCount("layoutCount"));
Assert.assertEquals("Unexpected RPC count", rpcCount,
getCount("rpcCount"));
}

private int getCount(String id) {
return Integer.parseInt(getDriver().findElement(By.id(id)).getText());
}
}

+ 61
- 0
uitest/src/com/vaadin/tests/widgetset/client/LayoutDetectorConnector.java Parādīt failu

/*
* Copyright 2000-2014 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.tests.widgetset.client;

import com.google.gwt.user.client.ui.HTML;
import com.vaadin.client.ui.AbstractComponentConnector;
import com.vaadin.client.ui.PostLayoutListener;
import com.vaadin.shared.ui.Connect;
import com.vaadin.tests.widgetset.server.LayoutDetector;

@Connect(LayoutDetector.class)
public class LayoutDetectorConnector extends AbstractComponentConnector
implements PostLayoutListener {
private int layoutCount = 0;
private int rpcCount = 0;

@Override
protected void init() {
super.init();
updateText();

registerRpc(NoLayoutRpc.class, new NoLayoutRpc() {
@Override
public void doRpc() {
rpcCount++;
updateText();
}
});
}

@Override
public HTML getWidget() {
return (HTML) super.getWidget();
}

@Override
public void postLayout() {
layoutCount++;
updateText();
}

private void updateText() {
getWidget().setHTML(
"Layout count: <span id='layoutCount'>" + layoutCount
+ "</span><br />RPC count: <span id='rpcCount'>"
+ rpcCount + "</span>");
}
}

+ 26
- 0
uitest/src/com/vaadin/tests/widgetset/client/NoLayoutRpc.java Parādīt failu

/*
* Copyright 2000-2014 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.tests.widgetset.client;

import com.vaadin.shared.annotations.NoLayout;
import com.vaadin.shared.communication.ClientRpc;

public interface NoLayoutRpc extends ClientRpc {

@NoLayout
public void doRpc();

}

+ 2
- 0
uitest/src/com/vaadin/tests/widgetset/client/RoundTripTesterRpc.java Parādīt failu

*/ */
package com.vaadin.tests.widgetset.client; package com.vaadin.tests.widgetset.client;


import com.vaadin.shared.annotations.NoLayout;
import com.vaadin.shared.communication.ClientRpc; import com.vaadin.shared.communication.ClientRpc;
import com.vaadin.shared.communication.ServerRpc; import com.vaadin.shared.communication.ServerRpc;


public interface RoundTripTesterRpc extends ServerRpc, ClientRpc { public interface RoundTripTesterRpc extends ServerRpc, ClientRpc {
@NoLayout
public void ping(int nr, String payload); public void ping(int nr, String payload);


public void done(); public void done();

+ 26
- 0
uitest/src/com/vaadin/tests/widgetset/server/LayoutDetector.java Parādīt failu

/*
* Copyright 2000-2014 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.tests.widgetset.server;

import com.vaadin.tests.widgetset.client.NoLayoutRpc;
import com.vaadin.ui.AbstractComponent;

public class LayoutDetector extends AbstractComponent {

public void doNoLayoutRpc() {
getRpcProxy(NoLayoutRpc.class).doRpc();
}
}

Notiek ielāde…
Atcelt
Saglabāt