Change-Id: I9aaef478e0b67462641239802b924b8461cb9225tags/8.0.0.alpha1
@@ -31,10 +31,10 @@ import elemental.json.JsonValue; | |||
* Generates type data for renderer connectors. | |||
* <ul> | |||
* <li>Stores the return type of the overridden | |||
* {@link AbstractRendererConnector#getRenderer() getRenderer} method to enable | |||
* automatic creation of an instance of the proper renderer type. | |||
* {@link AbstractGridRendererConnector#getRenderer() getRenderer} method to | |||
* enable automatic creation of an instance of the proper renderer type. | |||
* <li>Stores the presentation type of the connector to enable the | |||
* {@link AbstractRendererConnector#decode(elemental.json.JsonValue) decode} | |||
* {@link AbstractGridRendererConnector#decode(elemental.json.JsonValue) decode} | |||
* method to work without having to implement a "getPresentationType" method. | |||
* </ul> | |||
* | |||
@@ -63,11 +63,12 @@ public class RendererVisitor extends TypeVisitor { | |||
// Needs GWT constructor if createRenderer is not overridden | |||
if (createRendererClass.getQualifiedSourceName() | |||
.equals(AbstractRendererConnector.class.getCanonicalName())) { | |||
// createRenderer not overridden | |||
JMethod getRenderer = ConnectorBundle.findInheritedMethod(type, | |||
"getRenderer"); | |||
if (getRenderer.getEnclosingType().getQualifiedSourceName().equals( | |||
AbstractRendererConnector.class.getCanonicalName())) { | |||
// getRenderer not overridden | |||
logger.log(Type.ERROR, type.getQualifiedSourceName() | |||
+ " must override either createRenderer or getRenderer"); | |||
throw new UnableToCompleteException(); | |||
@@ -84,7 +85,7 @@ public class RendererVisitor extends TypeVisitor { | |||
} | |||
} | |||
private void doPresentationType(TreeLogger logger, JClassType type, | |||
private static void doPresentationType(TreeLogger logger, JClassType type, | |||
ConnectorBundle bundle) throws UnableToCompleteException { | |||
JType presentationType = getPresentationType(type, logger); | |||
bundle.setPresentationType(type, presentationType); |
@@ -23,25 +23,14 @@ import com.vaadin.client.metadata.Type; | |||
import com.vaadin.client.metadata.TypeData; | |||
import com.vaadin.client.metadata.TypeDataStore; | |||
import com.vaadin.client.renderers.Renderer; | |||
import com.vaadin.client.widgets.Grid.Column; | |||
import elemental.json.JsonObject; | |||
import elemental.json.JsonValue; | |||
/** | |||
* An abstract base class for renderer connectors. A renderer connector is used | |||
* to link a client-side {@link Renderer} to a server-side | |||
* {@link com.vaadin.ui.components.grid.Renderer Renderer}. As a connector, it | |||
* can use the regular Vaadin RPC and shared state mechanism to pass additional | |||
* state and information between the client and the server. This base class | |||
* itself only uses the basic {@link com.vaadin.shared.communication.SharedState | |||
* SharedState} and no RPC interfaces. | |||
* An abstract base class for renderer connectors. | |||
* | |||
* @param <T> | |||
* the presentation type of the renderer | |||
* | |||
* @since 7.4 | |||
* @author Vaadin Ltd | |||
*/ | |||
public abstract class AbstractRendererConnector<T> | |||
extends AbstractExtensionConnector { | |||
@@ -136,46 +125,4 @@ public abstract class AbstractRendererConnector<T> | |||
// NOOP | |||
} | |||
/** | |||
* Gets the row key for a row object. | |||
* <p> | |||
* In case this renderer wants be able to identify a row in such a way that | |||
* the server also understands it, the row key is used for that. Rows are | |||
* identified by unified keys between the client and the server. | |||
* | |||
* @param row | |||
* the row object | |||
* @return the row key for the given row | |||
*/ | |||
protected String getRowKey(JsonObject row) { | |||
final ServerConnector parent = getParent(); | |||
if (parent instanceof GridConnector) { | |||
return ((GridConnector) parent).getRowKey(row); | |||
} else { | |||
throw new IllegalStateException( | |||
"Renderers can only be used " + "with a Grid."); | |||
} | |||
} | |||
/** | |||
* Gets the column id for a column. | |||
* <p> | |||
* In case this renderer wants be able to identify a column in such a way | |||
* that the server also understands it, the column id is used for that. | |||
* Columns are identified by unified ids between the client and the server. | |||
* | |||
* @param column | |||
* the column object | |||
* @return the column id for the given column | |||
*/ | |||
protected String getColumnId(Column<?, JsonObject> column) { | |||
final ServerConnector parent = getParent(); | |||
if (parent instanceof GridConnector) { | |||
return ((GridConnector) parent).getColumnId(column); | |||
} else { | |||
throw new IllegalStateException( | |||
"Renderers can only be used " + "with a Grid."); | |||
} | |||
} | |||
} |
@@ -12,7 +12,7 @@ | |||
<packaging>jar</packaging> | |||
<properties> | |||
<widgetset.name>com.vaadin.v7.Vaadin7WidgetSet</widgetset.name> | |||
<widgetset.name>com.vaadin.Vaadin7WidgetSet</widgetset.name> | |||
<widgetset.style>OBF</widgetset.style> | |||
<widgetset.local.workers>6</widgetset.local.workers> | |||
</properties> |
@@ -43,6 +43,33 @@ | |||
</executions> | |||
</plugin> | |||
<plugin> | |||
<artifactId>maven-resources-plugin</artifactId> | |||
<executions> | |||
<!-- Copy .java files to package --> | |||
<execution> | |||
<id>copy-sources</id> | |||
<!-- here the phase you need --> | |||
<phase>prepare-package</phase> | |||
<goals> | |||
<goal>copy-resources</goal> | |||
</goals> | |||
<configuration> | |||
<outputDirectory>${project.build.outputDirectory}</outputDirectory> | |||
<resources> | |||
<resource> | |||
<directory>src/main/resources</directory> | |||
<filtering>false</filtering> | |||
</resource> | |||
<resource> | |||
<directory>src/main/java</directory> | |||
<filtering>false</filtering> | |||
</resource> | |||
</resources> | |||
</configuration> | |||
</execution> | |||
</executions> | |||
</plugin> | |||
<plugin> | |||
<groupId>org.apache.maven.plugins</groupId> | |||
<artifactId>maven-surefire-plugin</artifactId> |
@@ -0,0 +1,84 @@ | |||
/* | |||
* Copyright 2000-2016 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.connectors; | |||
import com.vaadin.client.ServerConnector; | |||
import com.vaadin.client.renderers.Renderer; | |||
import com.vaadin.client.widgets.Grid.Column; | |||
import elemental.json.JsonObject; | |||
/** | |||
* An abstract base class for renderer connectors. A renderer connector is used | |||
* to link a client-side {@link Renderer} to a server-side | |||
* {@link com.vaadin.ui.components.grid.Renderer Renderer}. As a connector, it | |||
* can use the regular Vaadin RPC and shared state mechanism to pass additional | |||
* state and information between the client and the server. This base class | |||
* itself only uses the basic {@link com.vaadin.shared.communication.SharedState | |||
* SharedState} and no RPC interfaces. | |||
* | |||
* @param <T> | |||
* the presentation type of the renderer | |||
* | |||
* @since 7.4 | |||
* @author Vaadin Ltd | |||
*/ | |||
public abstract class AbstractGridRendererConnector<T> | |||
extends AbstractRendererConnector<T> { | |||
/** | |||
* Gets the row key for a row object. | |||
* <p> | |||
* In case this renderer wants be able to identify a row in such a way that | |||
* the server also understands it, the row key is used for that. Rows are | |||
* identified by unified keys between the client and the server. | |||
* | |||
* @param row | |||
* the row object | |||
* @return the row key for the given row | |||
*/ | |||
protected String getRowKey(JsonObject row) { | |||
final ServerConnector parent = getParent(); | |||
if (parent instanceof GridConnector) { | |||
return ((GridConnector) parent).getRowKey(row); | |||
} else { | |||
throw new IllegalStateException( | |||
"Renderers can only be used " + "with a Grid."); | |||
} | |||
} | |||
/** | |||
* Gets the column id for a column. | |||
* <p> | |||
* In case this renderer wants be able to identify a column in such a way | |||
* that the server also understands it, the column id is used for that. | |||
* Columns are identified by unified ids between the client and the server. | |||
* | |||
* @param column | |||
* the column object | |||
* @return the column id for the given column | |||
*/ | |||
protected String getColumnId(Column<?, JsonObject> column) { | |||
final ServerConnector parent = getParent(); | |||
if (parent instanceof GridConnector) { | |||
return ((GridConnector) parent).getColumnId(column); | |||
} else { | |||
throw new IllegalStateException( | |||
"Renderers can only be used " + "with a Grid."); | |||
} | |||
} | |||
} |
@@ -34,7 +34,7 @@ import elemental.json.JsonObject; | |||
* @author Vaadin Ltd | |||
*/ | |||
public abstract class ClickableRendererConnector<T> | |||
extends AbstractRendererConnector<T> { | |||
extends AbstractGridRendererConnector<T> { | |||
HandlerRegistration clickRegistration; | |||
@@ -95,8 +95,8 @@ import com.vaadin.shared.ui.grid.GridStaticSectionState; | |||
import com.vaadin.shared.ui.grid.GridStaticSectionState.CellState; | |||
import com.vaadin.shared.ui.grid.GridStaticSectionState.RowState; | |||
import com.vaadin.shared.ui.grid.ScrollDestination; | |||
import com.vaadin.ui.LegacyGrid; | |||
import elemental.json.JsonObject; | |||
import elemental.json.JsonValue; | |||
@@ -161,14 +161,14 @@ public class GridConnector extends AbstractHasComponentsConnector | |||
private final String id; | |||
private AbstractRendererConnector<Object> rendererConnector; | |||
private AbstractGridRendererConnector<Object> rendererConnector; | |||
private AbstractComponentConnector editorConnector; | |||
private HandlerRegistration errorStateHandler; | |||
public CustomGridColumn(String id, | |||
AbstractRendererConnector<Object> rendererConnector) { | |||
AbstractGridRendererConnector<Object> rendererConnector) { | |||
super(rendererConnector.getRenderer()); | |||
this.rendererConnector = rendererConnector; | |||
this.id = id; | |||
@@ -181,7 +181,7 @@ public class GridConnector extends AbstractHasComponentsConnector | |||
* a renderer connector object | |||
*/ | |||
public void setRenderer( | |||
AbstractRendererConnector<Object> rendererConnector) { | |||
AbstractGridRendererConnector<Object> rendererConnector) { | |||
setRenderer(rendererConnector.getRenderer()); | |||
this.rendererConnector = rendererConnector; | |||
} | |||
@@ -1050,7 +1050,7 @@ public class GridConnector extends AbstractHasComponentsConnector | |||
private void addColumnFromStateChangeEvent(GridColumnState state) { | |||
@SuppressWarnings("unchecked") | |||
CustomGridColumn column = new CustomGridColumn(state.id, | |||
((AbstractRendererConnector<Object>) state.rendererConnector)); | |||
((AbstractGridRendererConnector<Object>) state.rendererConnector)); | |||
columnIdToColumn.put(state.id, column); | |||
/* | |||
@@ -1076,9 +1076,9 @@ public class GridConnector extends AbstractHasComponentsConnector | |||
column.setMaximumWidth(state.maxWidth); | |||
column.setExpandRatio(state.expandRatio); | |||
assert state.rendererConnector instanceof AbstractRendererConnector : "GridColumnState.rendererConnector is invalid (not subclass of AbstractRendererConnector)"; | |||
assert state.rendererConnector instanceof AbstractGridRendererConnector : "GridColumnState.rendererConnector is invalid (not subclass of AbstractGridRendererConnector)"; | |||
column.setRenderer( | |||
(AbstractRendererConnector<Object>) state.rendererConnector); | |||
(AbstractGridRendererConnector<Object>) state.rendererConnector); | |||
column.setSortable(state.sortable); | |||
@@ -45,7 +45,7 @@ import elemental.json.JsonValue; | |||
// are not always instanceof JsonValue, we need to accept Object | |||
@Connect(AbstractJavaScriptRenderer.class) | |||
public class JavaScriptRendererConnector | |||
extends AbstractRendererConnector<Object> | |||
extends AbstractGridRendererConnector<Object> | |||
implements HasJavaScriptConnectorHelper { | |||
private final JavaScriptConnectorHelper helper = new JavaScriptConnectorHelper( | |||
this); |
@@ -26,7 +26,7 @@ import com.vaadin.shared.ui.Connect; | |||
*/ | |||
@Connect(com.vaadin.ui.renderers.ProgressBarRenderer.class) | |||
public class ProgressBarRendererConnector | |||
extends AbstractRendererConnector<Double> { | |||
extends AbstractGridRendererConnector<Double> { | |||
@Override | |||
public ProgressBarRenderer getRenderer() { |
@@ -25,7 +25,7 @@ import com.vaadin.shared.ui.Connect; | |||
* @author Vaadin Ltd | |||
*/ | |||
@Connect(com.vaadin.ui.renderers.TextRenderer.class) | |||
public class TextRendererConnector extends AbstractRendererConnector<String> { | |||
public class TextRendererConnector extends AbstractGridRendererConnector<String> { | |||
@Override | |||
public TextRenderer getRenderer() { |
@@ -27,7 +27,7 @@ import com.vaadin.shared.ui.Connect; | |||
*/ | |||
@Connect(com.vaadin.ui.renderers.HtmlRenderer.class) | |||
public class UnsafeHtmlRendererConnector | |||
extends AbstractRendererConnector<String> { | |||
extends AbstractGridRendererConnector<String> { | |||
public static class UnsafeHtmlRenderer implements Renderer<String> { | |||
@Override |
@@ -21,12 +21,29 @@ | |||
<artifactId>vaadin-server</artifactId> | |||
<version>${project.version}</version> | |||
</dependency> | |||
<dependency> | |||
<groupId>${project.groupId}</groupId> | |||
<artifactId>vaadin-server</artifactId> | |||
<version>${project.version}</version> | |||
<classifier>tests</classifier> | |||
<scope>test</scope> | |||
</dependency> | |||
<dependency> | |||
<groupId>${project.groupId}</groupId> | |||
<artifactId>vaadin-compatibility-shared</artifactId> | |||
<version>${project.version}</version> | |||
</dependency> | |||
<dependency> | |||
<groupId>javax.servlet</groupId> | |||
<artifactId>javax.servlet-api</artifactId> | |||
<scope>provided</scope> | |||
</dependency> | |||
<!-- Bean Validation API --> | |||
<dependency> | |||
<groupId>javax.validation</groupId> | |||
<artifactId>validation-api</artifactId> | |||
<scope>provided</scope> | |||
</dependency> | |||
</dependencies> | |||
<build> |
@@ -13,7 +13,7 @@ | |||
* License for the specific language governing permissions and limitations under | |||
* the License. | |||
*/ | |||
package com.vaadin.data; | |||
package com.vaadin.data.fieldgroup; | |||
import java.lang.reflect.Constructor; | |||
import java.util.Date; |