* @return A new id for the connector
*/
public String createConnectorId(Connector connector) {
- // String connectorId = "C_" + connectorIdSequence++;
String connectorId = String.valueOf(connectorIdSequence++);
Connector oldReference = connectorIdToConnector.put(connectorId,
connector);
import com.vaadin.terminal.PaintException;
import com.vaadin.terminal.PaintTarget;
import com.vaadin.terminal.Paintable;
-import com.vaadin.terminal.Paintable.RepaintRequestEvent;
import com.vaadin.terminal.RequestHandler;
import com.vaadin.terminal.StreamVariable;
import com.vaadin.terminal.StreamVariable.StreamingEndEvent;
* TODO Document better!
*/
@SuppressWarnings("serial")
-public abstract class AbstractCommunicationManager implements
- Paintable.RepaintRequestListener, Serializable {
+public abstract class AbstractCommunicationManager implements Serializable {
private static final String DASHDASH = "--";
private static final String GET_PARAM_ANALYZE_LAYOUTS = "analyzeLayouts";
- // cannot combine with paint queue:
- // this can contain dirty components from any Root
- // TODO Remove, it is now in Root
- // private final ArrayList<Paintable> dirtyPaintables = new
- // ArrayList<Paintable>();
-
- // queue used during painting to keep track of what still needs to be
- // painted within the Root being painted
- // private LinkedList<Connector> paintQueue = new LinkedList<Connector>();
-
- // private final HashMap<String, Paintable> idPaintableMap = new
- // HashMap<String, Paintable>();
-
- private int idSequence = 0;
-
private final Application application;
private List<String> locales;
return seckey;
}
- // for internal use by JsonPaintTarget
- public void queuePaintable(Paintable paintable) {
- // if (!paintQueue.contains(paintable)) {
- // paintQueue.add((Connector) paintable);
- // }
- }
-
public void writeUidlResponse(boolean repaintAll,
final PrintWriter outWriter, Root root, boolean analyzeLayouts)
throws PaintException {
.getDirtyConnectorTracker();
System.out.println("* Creating response to client");
if (repaintAll) {
- System.out.println("Full repaint");
-
getClientCache(root).clear();
-
rootConnectorTracker.markAllComponentsDirty();
// Reset sent locales
legacyPaint(paintTarget, dirtyVisibleConnectors);
if (analyzeLayouts) {
- // TODO Check if this works
invalidComponentRelativeSizes = ComponentSizeValidator
.validateComponentRelativeSizes(root.getContent(), null,
null);
outWriter.print(", "); // close states
// TODO This should be optimized. The type only needs to be
- // sent once for each connector id + on refresh
+ // sent once for each connector id + on refresh. Use the same cache as
+ // widget mapping
JSONObject connectorTypes = new JSONObject();
for (Connector connector : dirtyVisibleConnectors) {
}
sortByHierarchy(paintables);
for (Paintable p : paintables) {
- System.out.println(" * Painting legacy Paintable "
- + p.getClass().getName() + "@"
- + Integer.toHexString(p.hashCode()));
+ logger.info("Painting legacy Paintable " + p.getClass().getName()
+ + "@" + Integer.toHexString(p.hashCode()));
paintTarget.startTag("change");
final String pid = ((Connector) p).getConnectorId();
paintTarget.addAttribute("pid", pid);
return dirtyComponents;
}
- /**
- * @see com.vaadin.terminal.Paintable.RepaintRequestListener#repaintRequested(com.vaadin.terminal.Paintable.RepaintRequestEvent)
- */
- public void repaintRequested(RepaintRequestEvent event) {
- // final Paintable p = event.getPaintable();
- // if (!dirtyPaintables.contains(p)) {
- // dirtyPaintables.add(p);
- // }
- }
-
- /**
- * Internally mark a {@link Paintable} as painted and start collecting new
- * repaint requests for it.
- *
- * @param paintable
- */
- private void paintablePainted(Paintable paintable) {
- // dirtyPaintables.remove(paintable);
- // paintable.requestRepaintRequests();
- }
-
/**
* Queues a locale to be sent to the client (browser) for date and time
* entry etc. All locale specific information is derived from server-side
}
}
- @Deprecated
- public String getPaintableId(Paintable paintable) {
- if (paintable instanceof Connector) {
- return ((Connector) paintable).getConnectorId();
- }
- throw new RuntimeException("Paintable " + paintable
- + " must implement Connector");
- }
}
import com.vaadin.terminal.gwt.client.Connector;
+/**
+ * Interface implemented by all connectors that are capable of communicating
+ * with the client side
+ *
+ * @author Vaadin Ltd
+ * @version @VERSION@
+ * @since 7.0.0
+ *
+ */
public interface ClientConnector extends Connector {
/**
* Returns the list of pending server to client RPC calls and clears the
* list.
*
- * @return unmodifiable ordered list of pending server to client method
+ * @return an unmodifiable ordered list of pending server to client method
* calls (not null)
*
* @since 7.0
import java.io.PrintWriter;
import java.io.Serializable;
import java.io.StringWriter;
-import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
private final Collection<Paintable> paintedComponents = new HashSet<Paintable>();
- // private Collection<Paintable> identifiersCreatedDueRefPaint;
-
- private Collection<Paintable> deferredPaintables;
-
private final Collection<Class<? extends Paintable>> usedPaintableTypes = new LinkedList<Class<? extends Paintable>>();
/**
openPaintables = new Stack<Paintable>();
openPaintableTags = new Stack<String>();
- deferredPaintables = new ArrayList<Paintable>();
-
cacheEnabled = cachingRequired;
}
throws PaintException {
boolean topLevelPaintable = openPaintables.isEmpty();
- System.out.println("startPaintable for "
- + paintable.getClass().getName() + "@"
- + Integer.toHexString(paintable.hashCode()));
+ logger.fine("startPaintable for " + paintable.getClass().getName()
+ + "@" + Integer.toHexString(paintable.hashCode()));
startTag(tagName, true);
openPaintables.push(paintable);
openPaintableTags.push(tagName);
- final String id = manager.getPaintableId(paintable);
- paintable.addListener(manager);
+ final String id = getPaintIdentifier(paintable);
addAttribute("id", id);
// queue for painting later if already painting a paintable
if (!topLevelPaintable) {
- // if (!deferredPaintables.contains(paintable)) {
- // notify manager: add to paint queue instead of painting now
- // manager.queuePaintable(paintable);
- // deferredPaintables.add(paintable);
- // }
return PaintStatus.DEFER;
}
// not a nested paintable, paint the it now
paintedComponents.add(paintable);
- // deferredPaintables.remove(paintable);
if (paintable instanceof CustomLayout) {
customLayoutArgumentsOpen = true;
}
public void endPaintable(Paintable paintable) throws PaintException {
- System.out.println("endPaintable for " + paintable.getClass().getName()
- + "@" + Integer.toHexString(paintable.hashCode()));
+ logger.fine("endPaintable for " + paintable.getClass().getName() + "@"
+ + Integer.toHexString(paintable.hashCode()));
Paintable openPaintable = openPaintables.peek();
if (paintable != openPaintable) {
throw new PaintException("Invalid UIDL: closing wrong paintable: '"
- + manager.getPaintableId(paintable) + "' expected: '"
- + manager.getPaintableId(openPaintable) + "'.");
+ + getPaintIdentifier(paintable) + "' expected: '"
+ + getPaintIdentifier(openPaintable) + "'.");
}
// remove paintable from the stack
openPaintables.pop();
}
public String getPaintIdentifier(Paintable paintable) throws PaintException {
- // if (!manager.hasPaintableId(paintable)) {
- // if (identifiersCreatedDueRefPaint == null) {
- // identifiersCreatedDueRefPaint = new HashSet<Paintable>();
- // }
- // identifiersCreatedDueRefPaint.add(paintable);
- // }
- return manager.getPaintableId(paintable);
+ // TODO This should be unnecessary as Paintable must be a Connector
+ if (paintable instanceof Connector) {
+ return ((Connector) paintable).getConnectorId();
+ }
+ throw new RuntimeException("Paintable " + paintable
+ + " must implement Connector");
}
/*
return usedResources;
}
- // /**
- // * Method to check if paintable is already painted into this target.
- // *
- // * @param p
- // * @return true if is not yet painted into this target and is connected to
- // * app
- // */
- // public boolean needsToBePainted(Paintable p) {
- // if (paintedComponents.contains(p)) {
- // return false;
- // } else if (((Component) p).getApplication() == null) {
- // return false;
- // } else {
- // return true;
- // }
- // }
-
private static final Map<Class<? extends Paintable>, Class<? extends Paintable>> widgetMappingCache = new HashMap<Class<? extends Paintable>, Class<? extends Paintable>>();
@SuppressWarnings("unchecked")
import java.util.Collection;
import java.util.HashSet;
import java.util.Set;
+import java.util.logging.Level;
import java.util.logging.Logger;
import com.vaadin.terminal.Paintable.RepaintRequestEvent;
}
private void markDirty(Component component) {
- // TODO Remove debug info
- if (!dirtyComponents.contains(component)) {
- debug(component, "is now dirty");
-
+ if (getLogger().isLoggable(Level.FINE)) {
+ if (!dirtyComponents.contains(component)) {
+ getLogger()
+ .fine(getDebugInfo(component) + " " + "is now dirty");
+ }
}
- dirtyComponents.add(component);
- }
- private void debug(Component component, String string) {
- getLogger().info(getDebugInfo(component) + " " + string);
+ dirtyComponents.add(component);
}
private void markClean(Component component) {
- // TODO Remove debug info
- if (dirtyComponents.contains(component)) {
- debug(component, "is no longer dirty");
+ if (getLogger().isLoggable(Level.FINE)) {
+ if (dirtyComponents.contains(component)) {
+ getLogger().fine(
+ getDebugInfo(component) + " " + "is no longer dirty");
+ }
}
- dirtyComponents.remove(component);
+ dirtyComponents.remove(component);
}
private String getDebugInfo(Component component) {
public void markAllComponentsDirty() {
markComponentsDirtyRecursively(root);
- System.out.println("All components are now dirty");
-
+ getLogger().fine("All components are now dirty");
}
public void markAllComponentsClean() {
dirtyComponents.clear();
- System.out.println("All components are now clean");
+ getLogger().fine("All components are now clean");
}
/**