1 6 package com.nightlabs.ipanema.person.search; 7 8 import org.eclipse.swt.widgets.Composite; 9 import org.eclipse.swt.widgets.Control; 10 11 import com.nightlabs.ipanema.person.AbstractPersonStructField; 12 import com.nightlabs.jdo.search.SearchFilterItem; 13 14 23 public class PersonStructFieldSearchItemEditorManager extends 24 PersonStructFieldSearchItemEditorHelper { 25 26 29 public PersonStructFieldSearchItemEditorManager() { 30 super(); 31 } 32 33 36 public PersonStructFieldSearchItemEditorManager( 37 AbstractPersonStructField personStructField) { 38 super(personStructField); 39 } 40 41 42 private PersonSearchFilterItemEditorHelper helper; 43 private Control helperControl; 44 45 52 public Control getControl(Composite parent) { 53 if (helper != null) 54 if (helperControl != null) 55 return helperControl; 56 57 PersonSearchFilterItemEditorHelperRegistry registry = PersonSearchFilterItemEditorHelperRegistry.getSharedInstance(); 58 if (personStructField == null) 59 throw new IllegalStateException ("Member personStructField is null. init(personStructField) might not have been called."); 60 61 try { 62 helper = registry.getEditorHelper(personStructField.getClass()); 63 } catch (PersonSearchFilterItemEditorHelperNotFoundException e) { 64 IllegalStateException ill = new IllegalStateException ("No helper found for class "+personStructField.getClass().getName()); 65 ill.initCause(e); 66 throw ill; 67 } 68 helper = helper.newInstance(); 69 if (helper instanceof PersonStructFieldSearchItemEditorHelper) 70 ((PersonStructFieldSearchItemEditorHelper)helper).init(this.personStructField); 71 helperControl = helper.getControl(parent); 73 return helperControl; 74 } 75 76 81 public SearchFilterItem getSearchFilterItem() { 82 if (helper == null) 83 throw new IllegalStateException ("SearchItemEditorHelper is null and can not be asked for the SearchFilterItem"); 84 85 return helper.getSearchFilterItem(); 86 } 87 88 91 public void close() { 92 } 93 94 } 95 | Popular Tags |