001 package org.hackystat.projectbrowser.page.contextsensitive; 002 003 import java.io.Serializable; 004 import java.util.List; 005 006 /** 007 * Provides state information for an individual label/menu pair that appears within a 008 * ContextSensitivePanel. 009 * 010 * @author Philip Johnson 011 */ 012 public class ContextSensitiveMenu implements Serializable { 013 014 /** Support serialization. */ 015 private static final long serialVersionUID = 1L; 016 017 /** The value this user has selected. */ 018 private String selectedValue; 019 020 /** The list of valuesType possibilities. */ 021 private List<String> values; 022 023 /** The name of this menu. */ 024 private String name; 025 026 /** Whether this menu should be visible or not. */ 027 private boolean isVisible = true; 028 029 030 /** 031 * Creates this context sensitive menu. 032 * @param defaultValue The initial selected value, or else null for no selected value. 033 * @param values The list of values to appear. 034 * @param name The label to be associated with this pane. This label is also used to 035 * identify the menu, so it should be unique within the enclosing ContextSensitivePanel. 036 * @param isVisible True if this pane should start out being visible or not visible. 037 */ 038 public ContextSensitiveMenu(String name, String defaultValue, List<String> values, 039 boolean isVisible) { 040 this.selectedValue = defaultValue; 041 this.values = values; 042 this.name = name; 043 this.isVisible = isVisible; 044 } 045 046 /** 047 * Returns the currently selected value of this menu, or null if none selected. 048 * @return The selected value. 049 */ 050 public String getSelectedValue() { 051 return this.selectedValue; 052 } 053 054 /** 055 * Sets the selected value associated with this menu. 056 * @param value The new selected value. 057 */ 058 public void setSelectedValue(String value) { 059 this.selectedValue = value; 060 } 061 062 /** 063 * Returns the list of strings to be displayed in the menu. 064 * @return The values list. 065 */ 066 public List<String> getValues() { 067 return this.values; 068 } 069 070 071 /** 072 * True if this label/menu pair should be displayed. 073 * @return True if displayed. 074 */ 075 public boolean isVisible() { 076 return this.isVisible; 077 } 078 079 /** 080 * Sets whether this label/menu pair should be displayed. 081 * @param visibility True if displayed. 082 */ 083 public void setVisible(boolean visibility) { 084 this.isVisible = visibility; 085 } 086 087 /** 088 * Returns the name of this label/menu pair. Should be unique within a panel. 089 * @return The name. 090 */ 091 public String getName() { 092 return this.name; 093 } 094 }