Advertisement
Guest User

FilteredHeader

a guest
Mar 4th, 2011
295
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.81 KB | None | 0 0
  1. public class FilterableHeader extends Header<String>
  2. {
  3.     /**
  4.      * Image resources.
  5.      */
  6.     public static interface Resources extends ClientBundle
  7.     {
  8.         ImageResource downArrow();
  9.         ImageResource upArrow();
  10.     }
  11.  
  12.     private static final Resources RESOURCES = GWT.create(Resources.class);
  13.     private static final int IMAGE_WIDTH = 16;
  14.     private static final String DOWN_ARROW = makeImage(RESOURCES.downArrow());
  15.     private static final String UP_ARROW = makeImage(RESOURCES.upArrow());
  16.  
  17.     private static String makeImage(ImageResource resource)
  18.     {
  19.         AbstractImagePrototype proto = AbstractImagePrototype.create(resource);
  20.         return proto.getHTML().replace("style='", "style='position:absolute;right:0px;top:0px;");
  21.     }
  22.  
  23.     private String text;
  24.  
  25.     public FilterableHeader(String text)
  26.     {
  27.         super(makeMyCell());
  28.         this.text = text;
  29.     }
  30.  
  31.     @Override
  32.     public String getValue()
  33.     {
  34.         return text;
  35.     }
  36.  
  37.     public static CompositeCell makeMyCell()
  38.     {
  39.         final ArrayList<HasCell<Resource, ?>> cells = new ArrayList<HasCell<Resource, ?>>();
  40.         cells.add(new NameCell());
  41.         // TODO: add another cell for filtering
  42.  
  43.         return new CompositeCell<Resource>(cells);
  44.  
  45.     }
  46.  
  47.     public static class NameCell implements HasCell<Resource, String>
  48.     {
  49.         public NameCell()
  50.         {
  51.         }
  52.  
  53.         @Override
  54.         public Cell<String> getCell()
  55.         {
  56.             return new ClickableTextCell();
  57.         }
  58.  
  59.         @Override
  60.         public FieldUpdater<Resource, String> getFieldUpdater()
  61.         {
  62.             return null;
  63.         }
  64.  
  65.         @Override
  66.         public String getValue(Resource resource)
  67.         {
  68.             return resource.getStafferName();
  69.         }
  70.     }
  71.  
  72.  
  73. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement