001package fi.jyu.mit.fxgui; 002 003import java.util.function.Consumer; 004 005/** 006 * Simple interface for all different choosers 007 * @author terop 008 * @version 13.1.2017 009 * @param <T> mitä luokkaa tallennetaan 010 */ 011public interface Chooser<T> { 012 /** 013 * Adds a single object to the system 014 * @param name name to be displayed in gui 015 * @param object object to be stored 016 */ 017 void add(String name, T object); 018 019 /** 020 * Adds the selection change listener to the component 021 * @param event to listen to 022 */ 023 void addSelectionListener(Consumer<T> event); 024 025 /** 026 * Adds only the object to the system 027 * @param object stored object 028 */ 029 void add(T object); 030 031 /** 032 * Adds an example string to the gui without stored object 033 * @param name string to be shown on gui 034 */ 035 void addExample(String name); 036 037 /** 038 * Clears the components of objects 039 */ 040 void clear(); 041 042 /** 043 * Returns the first seleceted object 044 * @return selected object 045 */ 046 T getSelectedObject(); 047 048 /** 049 * Returns the first selected objects gui text 050 * @return text shown on gui 051 */ 052 String getSelectedText(); 053 054 /** 055 * Returns the first selected index 056 * @return index 057 */ 058 int getSelectedIndex(); 059 060 /** 061 * Sets item in index selected 062 * @param index item to be selected 063 * @return old selected index 064 */ 065 int setSelectedIndex(int index); 066 067 /** 068 * Sets the rows. 069 * 070 * @param jono 071 * A multiline string, each line representing a single row. 072 */ 073 void setRivit(String jono); 074 075 /** 076 * Sets the rows. 077 * 078 * @param rivit 079 * A string arrays, each line representing a single row. 080 */ 081 void setRivit(String[] rivit); 082 083 /** 084 * Poistetaan alleviiva 085 * @param item mistä poistetaan 086 * @return ilman 1. alleviivaa 087 */ 088 String removeMnemonic(String item); 089 090}