%--
***************************************************************************
SeqHound Web Interface
(Based on the Biomolecular Interaction Network Database)
The Blueprint Initiative
522 University Avenue, 9th Floor, Suite 900
Toronto, Ontario, Canada, M5G 1W7
Hogue Lab - University of Toronto Biochemistry Department
Samuel Lunenfeld Research Institute, Mount Sinai Hospital
Copyright Notice:
Copyright 2003, 2004, 2005 Mount Sinai Hospital (MSH)
This program 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 2 of
the License, or any later version.
This program 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 this program; if not, write to the
Free Software Foundation, Inc.,
59 Temple Place, Suite 330, Boston, MA
02111-1307 USA
or visit http://www.gnu.org/copyleft/gpl.html
************************************************************************* --%>
<%@ page import="java.io.*"%>
<%@ page import="java.lang.Integer"%>
<%@ page import="java.util.*"%>
<%@ page import="com.unleashedinformatics.jseqhound.framework.config.BINDDef"%>
<%@ page import="com.unleashedinformatics.jseqhound.framework.*"%>
<%@ page import="com.unleashedinformatics.jseqhound.framework.ui.*"%>
<%@ page import="com.unleashedinformatics.jseqhound.framework.formbeans.*"%>
<%@ page import="org.blueprint.common.*"%>
<%@ page import="com.unleashedinformatics.jseqhound.bbs.formbeans.BBSFormBean"%>
<%@ page import="com.unleashedinformatics.jseqhound.bbs.formbeans.BBSFormBean"%>
<%@ page import="com.unleashedinformatics.jseqhound.bbs.export.ExporterFactory" %>
<%
class BINDWebElements {
private FormView viewmode;
/*This is used to enable the comment input field during validation mode*/
private boolean disable = false;
BINDWebElements() {
/*This allows for non BIND record views to use the WebElements*/
this.viewmode = new FormView();
}
BINDWebElements(FormView viewmode) {
this.viewmode = viewmode;
this.disable = !viewmode.isEditable();
}
String checked(int value) {
if (value > 0) {
return " CHECKED ";
}
return "";
}
String checked(boolean value) {
if (value) {
return " CHECKED ";
}
return "";
}
void printOptionList(JspWriter out, FormBean fbean, SelectOption.OptionList olist, int proptype) throws IOException {
SelectOption opt;
if(olist==null) {
out.println("");
return;
}
if(fbean==null) {
out.println("");
return;
}
for(int x = 0; x < olist.size(); x++) {
opt = (SelectOption) olist.get(x);
if (viewmode.isEditable()) {
%><%
} else {
if(fbean.checkSelection(opt.getStrId(), proptype)) {
out.print(opt.getName());
}
}
}
}
/**
* Emits a multi selection box.
* @param autoSubmit
*/
void printMultiSelectBoxElement(JspWriter out, String name, int size, FormBean fbean, SelectOption.OptionList olist, int proptype) throws IOException
{
%>
<%
}
/**
* Emits a multi selection box.
* @param autoSubmit
*/
void printMultiSelectBox(JspWriter out, String name, int size, FormBean fbean, SelectOption.OptionList olist, int proptype) throws IOException
{
if (viewmode.isEditable()) {
%>
tags, one for the field description and the second for a select box. The
* select box is unique because it is just a selection of numbers, from listFloor ... listCeil
*
* @param listFloor The lowest option value in this select list
* @param listCeil The highest option value in this select list
* @param selectDefault If true, this function will highlight the currently selected option specified by
* the value of the request parameter with the name fieldName.
*/
void printIntegerSelectBoxRow(JspWriter out, HttpServletRequest request, String fieldDesc, String fieldName, int listFloor, int listCeil, boolean selectDefault, ApplicationErrorHandler ferr) throws IOException
{
%>
<% }
/**
* Use this overloaded version if the radio button has no associated action.
*/
void printRadioButton(JspWriter out, String name, String value, FormBean formbean, int prop, int index) throws IOException {
this.printRadioButton(out, null, name, value, formbean, prop, index, -1, false, null, null, null);
}
/**
* Use this overloaded version if selecting a radio button should trigger an action (i.e. submission
* of the form) without requesting confirmation from the user.
*
* @param extraAction A string to be used as Javascript for setting any parameters just before form submission.
*/
void printRadioButton(JspWriter out, String form, String name, String value, FormBean formbean, int prop, int index, boolean blur, String action, String extraAction) throws IOException {
%>><%
}
/**
* Use this overloaded version if the radio button has an associated action (i.e. when selecting
* the button some action should occur.
*
* @param resetIndex Will not be evaluated if (func == null)
* @param func
* @param args
* @param action
* (func, args, action) should be used together to specify a javascript function along with its args and
* the 'butval' to set if func returns true. ResetIndex should also accompany these parameters
* and is the index of the radio button to set if func returns false.
* This function currently assumes that a change to a radio button selection should trigger a "confirm"
* style message returning either true/false. In the false situation this requires a reset of the previously
* selected value, the resetIndex.
*
*/
void printRadioButton(JspWriter out, String form, String name, String value, FormBean formbean, int prop, int index, int resetIndex, boolean blur, String func, String args, String action) throws IOException {
%>onChange="if (<%=func%>(<%=form%>, <%=args%>)) { this.form.butval.value='<%=action%>'; this.form.submit(); } else { this.form.<%=name%>[<%=resetIndex%>].checked=true; }"<%} if ((formbean != null) && formbean.checkSelection(value, prop)) out.print("checked");%>><%
}
void printPassword(JspWriter out, String name, String value, int size) throws IOException {
%>
0) { out.println("size=\"" + size + "\""); }%>>
<%
}
void printTextArea(JspWriter out, String name, String value, int width, int height) throws IOException {
if (value == null) {
value = "";
}
if (viewmode.isEditable() || !disable) {
%>
<%
} else {
//this (wrapping) needs to be changed to something more elegant
%>
<%
}
void printFieldDescr(JspWriter out, String descr, int prop, String mol, String fieldname, ApplicationErrorHandler ehandler) throws IOException {
this.printFieldDescr(out, null, descr, prop, mol, fieldname, ehandler);
}
void printArrayList(JspWriter out, String formname, FormBeanList list, ApplicationErrorHandler ferr, String dataname, String datatype, boolean[] features, int depth) throws IOException {
printArrayList(out, null, formname, list, ferr, dataname, datatype, features[0], features[1], features[2], features[3], depth);
}
void printArrayList(JspWriter out, HttpServletRequest request, String formname, FormBeanList list, ApplicationErrorHandler ferr, String dataname, String datatype, boolean[] features, int depth) throws IOException {
printArrayList(out, request, formname, list, ferr, dataname, datatype, features[0], features[1], features[2], features[3], depth);
}
void printArrayList(JspWriter out, HttpServletRequest request, String formname, FormBeanList list, ApplicationErrorHandler ferr, String dataname, String datatype, boolean add, boolean edit, boolean delete, boolean selection, int depth) throws IOException {
printArrayList(out, request, formname, list, ferr, dataname, datatype, add, edit, delete, selection, depth, null, null, null);
}
/**
* @param specialConfirmList
* @param editConfirm a String used for an edit button as a confirmation message. Should include a '?' if is a question.
* If null, will be ignored and no confirmation will be associated with the edit button.
* @param deleteConfirm a String used for a delete button as a confirmation message. Should include a '?' if is a question.
* If null, will be ignored.
*
* SpecialConfirmList, editConfirm and deleteConfirm are used together. All are expected to have value or all should be null.
* For the indexes in specialConfirmList that are true, those list elements will have the edit and deleteConfirm messages
* used for their respective buttons in place of the standard confirm message.
*/
void printArrayList(JspWriter out, HttpServletRequest request, String formname, FormBeanList list, ApplicationErrorHandler ferr, String dataname, String datatype, boolean add, boolean edit, boolean delete, boolean selection, int depth, boolean[] specialConfirmList, String editConfirm, String deleteConfirm) throws IOException {
int addindex = list.getSize();
if (addindex == -1) {
addindex = 0;
}
String[] args_add = { new String("'" + datatype + "'"), new String("'"+ addindex +"'") };
%>
<%
/*No list*/
if (list.isEmpty() || list.isDiffEmpty()) {
if (add) {
%>
None have been added yet. Please use the add icon to add a new <%=dataname%>.
<%
} else {
%>
None have been added yet.
<%
}
}
int beanCount = 0;
for (int x = 0; x < list.getSize(); x++) {
if (list.getBean(x) == null) {
// Skip placeholder
continue;
} else {
// Count bean
beanCount++;
}
String[] args_del = new String[3];
String[] args_edit;
String[] args_view = { new String("'" + datatype + "'"), new String("'"+ x +"'") };
if ((specialConfirmList != null) && (x < specialConfirmList.length) && specialConfirmList[x] && (deleteConfirm != null)) {
args_del[0] = "'" + deleteConfirm + "'";
} else {
args_del[0] = "'Are you sure you would like to delete this " + dataname + "?'";
}
args_del[1] = "'" + datatype + "'";
args_del[2] = "'"+ x +"'";
if ((specialConfirmList != null) && (x < specialConfirmList.length) && specialConfirmList[x] && (editConfirm != null)) {
args_edit = new String[3];
args_edit[0] = "'" + editConfirm + "'";
args_edit[1] = "'" + datatype + "'";
args_edit[2] = "'" + x + "'";
} else {
args_edit = new String[2];
args_edit[0] = "'" + datatype + "'";
args_edit[1] = "'" + x + "'";
}
%>
<%
}
void printPagination(JspWriter out, int pages, int current, String parameterName, String query) throws IOException {
int maxpages = 10;
int min = 1;
int max = pages;
if (pages == 1) {
return;
}
if (pages > maxpages) {
min = current - 3;
if (min < 1) { min = 1; }
max = current + 3;
if (max > pages) { max = pages; }
}
%>
<%
}
/**
* Prints the pagination tool along with a "jump to page" widget
* @param formName Unique name of the form to use when building the widget
*/
void printPagination(JspWriter out, int pages, int current, String parameterName, String query, String formName) throws IOException {
printPagination(out, pages, current, parameterName, query);
if (pages == 1) {
return;
}
%>
<%
}
/**
* Prints a form input element of type image, using image rollovers.
* NOTE: This function is not used (but maybe used in the future). Please see printButton().
* @param out output stream
* @param buttonName name of this element. This is also used to determine the image names to use
* @param descr description of this button to show the user
* @param path path to the images used for this button
*/
void printFormImageButton (JspWriter out, String buttonName, String descr, String path) throws IOException
{
%>
<%
}
void printFocus(JspWriter out, String form, String element) throws IOException {
%>
<%
}
void jumpToAnchor(JspWriter out, String anchorName) throws IOException {
%>
<%
}
void printBackLink(JspWriter out, HttpServletRequest request, String linkText) throws IOException {
// This method requires a backpg parameter in the request URL
String backPg = (String) request.getParameter("backpg");
if (backPg != null) {
String backLink = "Action?pg=" + backPg;
%><%=linkText%><%
}
}
void checkMessage(JspWriter out, HttpServletRequest request) throws IOException {
ApplicationErrorHandler ehandler = env.getErrorHandler(request);
if (ehandler != null) {
ApplicationError err = ehandler.getApplicationError();
if (err != null) {
if (err.getUFMessage()!=null && !err.getUFMessage().equals("")) {
out.println("");
out.println("