title: How to implement GWT editors for subclasses of a type?
body: <p>Let's say I have an object hierarchy like this:</p>
  
  <p><strong>Account > Site > Supply</strong></p>
  
  <p>An Account is an actual company, a Site is a building they have, and a Supply is either an <code>ElecSupply</code> or <code>GasSupply</code>. Supply is never instantiated and could be an abstract class in theory.</p>
  
  <p>I am using Objectify for persistence, and have a page that displays the list of Supplies for each Site, regardless of whether they are an <code>ElecSupply</code> or <code>GasSupply</code>.</p>
  
  <p>Now I am implementing the <a href="https://developers.google.com/web-toolkit/doc/latest/DevGuideUiEditors" rel="nofollow">GWT Editor Framework</a> and have come up against a problem with this polymorphic entity. How do I implement an Editor and set of sub-editors for an object like this?</p>
  
  <pre><code>@Entity
  public class Supply implements Serializable
  {
      @Id
      protected Long id;
      @Embedded
      protected List&lt;BillingPeriod&gt; billingPeriods = new ArrayList&lt;BillingPeriod&gt;();
  
      public Supply()
      {
  
      }
  // ...
  }
  </code></pre>
  
  <p>The subclasses: (ElecSupply has 5 unique fields and GasSupply has just one)</p>
  
  <pre><code>@Subclass
  public class ElecSupply extends Supply implements Serializable
  {
      private String profile;
      private String mtc;
      private String llf;
      private String area;
      private String core;
  
      public ElecSupply()
      {
  
      }
  }
  </code></pre>
  
  <hr>
  
  <pre><code>@Subclass
  public class GasSupply extends Supply implements Serializable
  {
      private String mpr;
  
      public GasSupply()
      {
  
      }
  // ...
  }
  </code></pre>
  
  <p>So I would like to know if anyone has any experience with this kind of structure? I have tried to make separate editors for <code>ElecSupply</code> and <code>GasSupply</code>, and then show or hide them as part of the edit page.</p>
  
  <p>The other way I was thinking about doing it would be to have a single editor (for Supply), and then load different sub-editors depending on which type of object we are editing.</p>
  
  <p>Any light shed will be gratefully received.</p>