1 15 package org.apache.tapestry.workbench.palette; 16 17 import java.util.List ; 18 19 import org.apache.tapestry.IPage; 20 import org.apache.tapestry.IRequestCycle; 21 import org.apache.tapestry.annotations.InjectPage; 22 import org.apache.tapestry.contrib.palette.SortMode; 23 import org.apache.tapestry.form.IPropertySelectionModel; 24 import org.apache.tapestry.form.StringPropertySelectionModel; 25 import org.apache.tapestry.html.BasePage; 26 import org.apache.tapestry.valid.IValidationDelegate; 27 28 31 32 public abstract class Palette extends BasePage 33 { 34 public abstract List getSelectedColors(); 35 36 public abstract String getSort(); 37 38 private IPropertySelectionModel _sortModel; 39 40 43 44 @InjectPage("PaletteResults") 45 public abstract PaletteResults getResultsPage(); 46 47 public IPage advance() 48 { 49 IValidationDelegate delegate = (IValidationDelegate) getBeans().getBean("delegate"); 50 51 if (delegate.getHasErrors()) return null; 52 53 57 PaletteResults results = getResultsPage(); 58 59 results.setSelectedColors(getSelectedColors()); 60 61 return results; 62 } 63 64 private IPropertySelectionModel colorModel; 65 66 private String [] colors = 67 { "Red", "Orange", "Yellow", "Green", "Blue", "Indigo", "Violet" }; 68 69 public IPropertySelectionModel getColorModel() 70 { 71 if (colorModel == null) 72 colorModel = new StringPropertySelectionModel(colors); 73 74 return colorModel; 75 } 76 77 public IPropertySelectionModel getSortModel() 78 { 79 if (_sortModel == null) 80 { 81 String [] options = new String [] 82 { SortMode.NONE, SortMode.LABEL, SortMode.VALUE, SortMode.USER }; 83 84 _sortModel = new StringPropertySelectionModel(options); 85 } 86 87 return _sortModel; 88 } 89 } | Popular Tags |