Package org.rydia.client

Source Code of org.rydia.client.DropdownRenderer

/**
* This file is part of Rydia.
*
* Rydia is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Rydia is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Rydia.  If not, see <http://www.gnu.org/licenses/>.
**/
package org.rydia.client;

import com.google.gwt.user.client.ui.ListBox;
import com.google.gwt.user.client.ui.Widget;
import com.google.gwt.user.client.ui.ChangeListener;

import java.util.List;
import java.util.ArrayList;

/**
* <u><b><font color="red">FOR INTERNAL USE ONLY.</font></b></u>
* Copyright (c)2007, Daniel Kaplan
*
* @author Daniel Kaplan
* @since 7.11.6
*/
public class DropdownRenderer extends Question {

    private static final int FIRST_CHOICE = 10;

    public DropdownRenderer(String[] state, int row, Rydia.ChangeListener changeListener) {
        super(state, row, changeListener);
    }

    public Widget getColumn2() {
        final ListBox listBox = new ListBox(false);
        listBox.setEnabled(isEnabled());
        final List ids = new ArrayList();

        for (int i = FIRST_CHOICE; i < state.length; i += 2) {           
            ids.add(state[i]);
            listBox.addItem(state[i + 1]);
        }
        listBox.setSelectedIndex(ids.indexOf(state[ANSWER]));
        listBox.addChangeListener(new ChangeListener() {
            public void onChange(Widget sender) {
                reactToChange((String) ids.get(listBox.getSelectedIndex()));
            }
        });
        return listBox;
    }

}
TOP

Related Classes of org.rydia.client.DropdownRenderer

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.