/**
* 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 org.olat.repository;
import org.olat.core.gui.components.form.Form;
import org.olat.core.gui.formelements.CheckBoxElement;
import org.olat.core.gui.formelements.StaticHTMLTextElement;
import org.olat.core.gui.formelements.StaticSingleSelectionElement;
import org.olat.core.gui.translator.Translator;
import org.olat.repository.handlers.RepositoryHandler;
import org.olat.repository.handlers.RepositoryHandlerFactory;
/**
* @author Ingmar Kroll
*
* Comment:
*
*/
public class DisplayInfoForm extends Form {
private RepositoryEntry entry;
private CheckBoxElement canCopy;
private CheckBoxElement canReference;
private CheckBoxElement canLaunch;
private CheckBoxElement canDownload;
private StaticSingleSelectionElement access;
public DisplayInfoForm(String name, Translator translator, RepositoryEntry entry) {
super(name, translator);
this.entry = entry;
init();
setDisplayOnly(true);
}
/**
* Initialize form data based on repository entry.
*/
public void init() {
RepositoryHandler handler = null;
handler = RepositoryHandlerFactory.getInstance().getRepositoryHandler(entry);
canCopy = new CheckBoxElement("cif.canCopy", entry.getCanCopy());
addFormElement("cif_canCopy", canCopy);
canReference = new CheckBoxElement("cif.canReference", entry.getCanReference());
addFormElement("cif_canReference", canReference);
if (handler != null && handler.supportsLaunch()) {
canLaunch = new CheckBoxElement("cif.canLaunch", entry.getCanLaunch());
addFormElement("cif_canLaunch", canLaunch);
} else { // launch not supported
canLaunch = null;
addFormElement("cif_canLaunch", new StaticHTMLTextElement("cif.canLaunch", translate("cif.canLaunch.na"), 255));
}
if (handler != null && handler.supportsDownload()) {
canDownload = new CheckBoxElement("cif.canDownload", entry.getCanDownload());
addFormElement("cif_canDownload", canDownload);
} else { // download not supported
canDownload = null;
addFormElement("cif_canDownload", new StaticHTMLTextElement("cif.canDownload", translate("cif.canDownload.na"), 255));
}
String[] keys = new String[] {
"" + RepositoryEntry.ACC_OWNERS,
"" + RepositoryEntry.ACC_OWNERS_AUTHORS,
"" + RepositoryEntry.ACC_USERS,
"" + RepositoryEntry.ACC_USERS_GUESTS
};
String[] values = new String[] {
translate("cif.access.owners"),
translate("cif.access.owners_authors"),
translate("cif.access.users"),
translate("cif.access.users_guests"),
};
access = new StaticSingleSelectionElement("cif.access", keys, values);
access.select("" + entry.getAccess(), true);
addFormElement("cif_access", access);
addSubmitKey("submit","submit");
}
/**
* @see org.olat.core.gui.components.Form#validate(org.olat.core.gui.UserRequest)
*/
public boolean validate() {
return true;
}
}