Package ch.unizh.campusmgnt

Source Code of ch.unizh.campusmgnt.ColWithBulkActionForm

/**
* 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;
import org.olat.core.util.bulk.BulkAction;
/**
*
* Description:<br>
* TODO: schneider Class Description for ColWithBulkActionForm
*
* <P>
* Initial Date:  19.12.2005 <br>
*
* @author Alexander Schneider
*/
public class ColWithBulkActionForm extends Form {

  private StaticSingleSelectionElement colSelElement;
  private StaticSingleSelectionElement bulkSelElement;
  /**
   * @param name
   * @param trans
   */
  public ColWithBulkActionForm(String name, Translator translator, List columns, List bulkActions) {
    super(name, translator);
   
    int sizeCols = columns.size();
    String[] cKeys = new String[sizeCols];
    String[] cValues = new String[sizeCols];
    int i = 0;
    for (Iterator iter = columns.iterator(); iter.hasNext();) {
      cKeys[i] = Integer.toString(i);
      cValues[i] = (String)iter.next();
      i++;
    }
    colSelElement = new StaticSingleSelectionElement("form.step3.columns", cKeys, cValues);
    colSelElement.select("0",true);
    addFormElement("form.step3.columns", colSelElement);
   
    int sizeBulkActions = bulkActions.size();
    String[] fKeys = new String[sizeBulkActions];
    String[] fValues = new String[sizeBulkActions];
    int j = 0;
    for (Iterator iter = bulkActions.iterator(); iter.hasNext();) {
      fKeys[j] = Integer.toString(j);
      BulkAction ba = (BulkAction) iter.next();
      fValues[j] = ba.getDisplayName();
      j++;
    }
    bulkSelElement = new StaticSingleSelectionElement("form.step3.bulkactions", fKeys, fValues);
    bulkSelElement.select("0",true);
    addFormElement("form.step3.bulkactions", bulkSelElement);
   
    addSubmitKey("next"); // wizard style

  }
  /**
   * @see org.olat.core.gui.components.Form#validate(org.olat.core.gui.UserRequest)
   */
  public boolean validate() {
    return true;
  }
 
  /**
   * @return selected bulkAction
   */
  public String getSelectedBulkAction() {
    return getSingleSelectionElement("form.step3.bulkactions").getSelectedKey();
  }
 
  /**
   * @return selected column
   */
  public String getSelectedColumn() {
    return getSingleSelectionElement("form.step3.columns").getSelectedKey();
  }
 
}
TOP

Related Classes of ch.unizh.campusmgnt.ColWithBulkActionForm

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.