Package ch.unizh.campusmgnt

Source Code of ch.unizh.campusmgnt.KeyWithColumnForm

/**
* OLAT - Online Learning and Training<br>
* http://www.olat.org
* <p>
* Licensed under the Apache License, Version 2.0 (the "License"); <br>
* you may not use this file except in compliance with the License.<br>
* You may obtain a copy of the License at
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing,<br>
* software distributed under the License is distributed on an "AS IS" BASIS, <br>
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. <br>
* See the License for the specific language governing permissions and <br>
* limitations under the License.
* <p>
* Copyright (c) since 2004 at Multimedia- & E-Learning Services (MELS),<br>
* University of Zurich, Switzerland.
* <p>
*/

package ch.unizh.campusmgnt;

import java.util.Iterator;
import java.util.List;

import org.olat.core.gui.components.form.Form;
import org.olat.core.gui.formelements.StaticSingleSelectionElement;
import org.olat.core.gui.translator.Translator;
/**
*
* Description:<br>
* TODO: schneider Class Description for KeyWithColumnForm
*
* <P>
* Initial Date:  19.12.2005 <br>
*
* @author Alexander Schneider
*/
public class KeyWithColumnForm extends Form {

  private StaticSingleSelectionElement keySelElement;
  private StaticSingleSelectionElement colSelElement;
  /**
   * @param name
   * @param trans
   */
  public KeyWithColumnForm(String name, Translator translator, List olatKeys, List columns) {
    super(name, translator);
   
    int sizeCols = columns.size();
    String[] cKeys = new String[sizeCols];
    String[] cValues = new String[sizeCols];
    int j = 0;
    for (Iterator iter = columns.iterator(); iter.hasNext();) {
      cKeys[j] = Integer.toString(j);
      cValues[j] = (String)iter.next();
      j++;
    }
    colSelElement = new StaticSingleSelectionElement("form.step2.columns", cKeys, cValues);
    colSelElement.select("0",true);
    addFormElement("form.step2.columns", colSelElement);
   
    int sizeOlKs = olatKeys.size();
    String[] oKeys = new String[sizeOlKs];
    String[] oValues = new String[sizeOlKs];
    int i = 0;
    for (Iterator iter = olatKeys.iterator(); iter.hasNext();) {
      oKeys[i] = Integer.toString(i);
      oValues[i] = (String)iter.next();
      i++;
    }
    keySelElement = new StaticSingleSelectionElement("form.step2.olatkeys", oKeys, oValues);
    keySelElement.select("0",true);
    addFormElement("form.step2.olatkeys", keySelElement);
   
    addSubmitKey("next"); // wizard style

  }
  /**
   * @see org.olat.core.gui.components.Form#validate(org.olat.core.gui.UserRequest)
   */
  public boolean validate() {
    return true;
  }
 
  /**
   * @return selected olatKey
   */
  public String getSelectedOlatKey() {
    return getSingleSelectionElement("form.step2.olatkeys").getSelectedKey();
  }
 
  /**
   * @return selected value of olatKey
   */
  public String getSelectedValueOfOlatKey(int key) {
    return getSingleSelectionElement("form.step2.olatkeys").getValue(key);
  }
 
 
  /**
   * @return selected column
   */
  public String getSelectedColumn() {
    return getSingleSelectionElement("form.step2.columns").getSelectedKey();
  }
 
}
TOP

Related Classes of ch.unizh.campusmgnt.KeyWithColumnForm

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.