001 // Copyright 2004, 2005 The Apache Software Foundation 002 // 003 // Licensed under the Apache License, Version 2.0 (the "License"); 004 // you may not use this file except in compliance with the License. 005 // You may obtain a copy of the License at 006 // 007 // http://www.apache.org/licenses/LICENSE-2.0 008 // 009 // Unless required by applicable law or agreed to in writing, software 010 // distributed under the License is distributed on an "AS IS" BASIS, 011 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 012 // See the License for the specific language governing permissions and 013 // limitations under the License. 014 015 package org.apache.tapestry.junit.mock.c14; 016 017 import java.util.ArrayList; 018 import java.util.Collections; 019 import java.util.List; 020 import java.util.Map; 021 import java.util.ResourceBundle; 022 023 import org.apache.tapestry.html.BasePage; 024 025 /** 026 * Shows user's selected colors in a new page. A bit of duplication with ListEdit, but such is 027 * testing. 028 * 029 * @author Howard Lewis Ship 030 * @since 3.0 031 */ 032 public abstract class ListEditResults extends BasePage 033 { 034 public abstract Map getColorMap(); 035 036 public abstract void setColorMap(Map colorMap); 037 038 public abstract String getColorKey(); 039 040 private ResourceBundle _colorStrings; 041 042 public List getSortedColorKeys() 043 { 044 Map map = getColorMap(); 045 List result = new ArrayList(map.keySet()); 046 047 Collections.sort(result); 048 049 return result; 050 } 051 052 public String getColorName() 053 { 054 String key = getColorKey(); 055 String color = (String) getColorMap().get(key); 056 057 return _colorStrings.getString(color); 058 } 059 060 protected void finishLoad() 061 { 062 _colorStrings = ResourceBundle.getBundle(Color.class.getName() + "Strings", getLocale()); 063 } 064 065 }