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.

ColorPickerWidgetSet.java 1.1KB

123456789101112131415161718192021222324252627282930313233343536
  1. /*
  2. @ITMillApache2LicenseForJavaFiles@
  3. */
  4. package com.vaadin.demo.colorpicker.gwt.client;
  5. import com.vaadin.demo.colorpicker.gwt.client.ui.VColorPicker;
  6. import com.vaadin.terminal.gwt.client.DefaultWidgetSet;
  7. import com.vaadin.terminal.gwt.client.Paintable;
  8. import com.vaadin.terminal.gwt.client.UIDL;
  9. public class ColorPickerWidgetSet extends DefaultWidgetSet {
  10. /** Resolves UIDL tag name to widget class. */
  11. @Override
  12. protected Class resolveWidgetType(UIDL uidl) {
  13. final String tag = uidl.getTag();
  14. if ("colorpicker".equals(tag)) {
  15. return VColorPicker.class;
  16. }
  17. // Let the DefaultWidgetSet handle resolution of default widgets
  18. return super.resolveWidgetType(uidl);
  19. }
  20. /** Creates a widget instance according to its class object. */
  21. @Override
  22. public Paintable createWidget(UIDL uidl) {
  23. final Class type = resolveWidgetType(uidl);
  24. if (VColorPicker.class == type) {
  25. return new VColorPicker();
  26. }
  27. // Let the DefaultWidgetSet handle creation of default widgets
  28. return super.createWidget(uidl);
  29. }
  30. }