You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

ConnectorInitVisitor.java 1.7KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. /*
  2. @VaadinApache2LicenseForJavaFiles@
  3. */
  4. package com.vaadin.server.widgetsetutils.metadata;
  5. import java.util.Map;
  6. import com.google.gwt.core.ext.TreeLogger;
  7. import com.google.gwt.core.ext.TreeLogger.Type;
  8. import com.google.gwt.core.ext.UnableToCompleteException;
  9. import com.google.gwt.core.ext.typeinfo.JClassType;
  10. import com.google.gwt.dev.util.collect.HashMap;
  11. import com.vaadin.shared.ui.Connect;
  12. public class ConnectorInitVisitor extends TypeVisitor {
  13. private Map<String, JClassType> processedConnections = new HashMap<String, JClassType>();
  14. @Override
  15. public void visitConnector(TreeLogger logger, JClassType type,
  16. ConnectorBundle bundle) throws UnableToCompleteException {
  17. Connect connectAnnotation = type.getAnnotation(Connect.class);
  18. if (connectAnnotation != null) {
  19. logger.log(Type.INFO, type.getName() + " will be in the "
  20. + bundle.getName().replaceAll("^_*", "") + " bundle");
  21. String identifier = connectAnnotation.value().getCanonicalName();
  22. JClassType previousMapping = processedConnections.put(identifier,
  23. type);
  24. if (previousMapping != null) {
  25. logger.log(
  26. Type.ERROR,
  27. "Multiple @Connect mappings detected for " + identifier
  28. + ": " + type.getQualifiedSourceName()
  29. + " and "
  30. + previousMapping.getQualifiedSourceName());
  31. throw new UnableToCompleteException();
  32. }
  33. bundle.setIdentifier(type, identifier);
  34. bundle.setNeedsGwtConstructor(type);
  35. }
  36. }
  37. }