use of web.HTMLWriter in project common by zenlunatics.
the class PictureColumn method writeValue.
// --------------------------------------------------------------------------
@Override
public boolean writeValue(View view, Map<String, Object> data, Request request) throws IOException {
String file_name = view.data().getString(m_name);
if (file_name.length() > 0) {
String url_path = getURLPath(view, request);
HTMLWriter writer = request.writer;
if (m_thumb_size == 0)
writer.img(file_name, url_path);
else {
if (m_popup_height == 0)
writer.aOpen(url_path + file_name);
else {
writer.jsFunction("show_picture", "u", "var w=window.open('','','width=" + m_popup_width + ",height=" + m_popup_height + ",resize=yes')\n" + "w.document.write('<html><body><img src=\"'+u+'\" width=\"" + (m_popup_width - 20) + "\" height=\"" + (m_popup_height - 100) + "\" />')\n" + "w.document.write('<br /><a href=\"#\" onclick=\"max();document.location=\\''+u+'\\';return false\">view full size image</a>')\n" + "w.document.write('<script>function max(){" + "if(window.screen){" + "window.moveTo(0,0);" + "window.outerHeight=screen.availHeight;" + "window.outerWidth=screen.availWidth;" + "}else\n" + "window.resizeTo(screen.availWidth,screen.availHeight);" + "}</scr');w.document.write('ipt></body></html>');" + "w.document.close();");
writer.aOnClickOpen("show_picture('" + url_path + file_name + "')");
}
writer.img(file_name, url_path + "thumbs/");
writer.tagClose();
}
return true;
}
return false;
}
use of web.HTMLWriter in project common by zenlunatics.
the class ColumnBase method writeInput.
// --------------------------------------------------------------------------
public static void writeInput(String column_name, String default_value, View view, Request request) throws IOException {
JDBCColumn jdbc_column = request.db.getTable(view.getViewDef().getFrom()).getColumn(column_name);
if (jdbc_column == null)
throw new RuntimeException("column " + column_name + " not found in table " + view.getViewDef().getFrom());
String value = getValue(jdbc_column, default_value, view, request);
HTMLWriter writer = request.writer;
if (jdbc_column.isBinary())
TextAreaColumn.writeTextArea(column_name, DBConnection.decodeBinary(value), 40, 5, view, writer);
else if (jdbc_column.isBoolean()) {
writer.checkbox(column_name, column_name.replace('_', ' '), null, value != null && (value.equals("yes") || value.equals("t")), false);
writer.hiddenInput("db_boolean" + writer.newID(), column_name);
} else if (jdbc_column.isDate())
writer.dateInput(column_name, value);
else if (jdbc_column.isInteger())
writer.numberInput(column_name, null, null, value);
else if (jdbc_column.isText())
writer.textAreaExpanding(column_name, "min-width:100px", value);
else if (jdbc_column.isTime()) {
Calendar time = null;
if (view.getMode() == View.Mode.EDIT_FORM) {
Time t = view.data().getTime(column_name);
if (t != null) {
time = Calendar.getInstance();
time.setTime(t);
}
} else if (value != null)
try {
time = Calendar.getInstance();
time.setTime(new SimpleDateFormat("hh:mm a").parse(value));
} catch (ParseException e) {
}
writer.timeInput(column_name, time);
} else
writer.textInput(column_name, Integer.toString(jdbc_column.size), value);
}
use of web.HTMLWriter in project common by zenlunatics.
the class CurrencyColumn method writeInput.
// --------------------------------------------------------------------------
@Override
protected void writeInput(Mode mode, String default_value, View view, Form form, Request request) throws IOException {
NumberFormat nf = NumberFormat.getInstance(Locale.US);
nf.setMaximumFractionDigits(2);
nf.setMinimumFractionDigits(2);
HTMLWriter writer = request.writer;
if (mode == View.Mode.ADD_FORM)
writer.textInput(m_name, "10", default_value);
else if (mode == View.Mode.EDIT_FORM)
writer.textInput(m_name, "10", nf.format(view.data().getDouble(m_name)));
}
use of web.HTMLWriter in project common by zenlunatics.
the class MultiColumnRenderer method writeInput.
// --------------------------------------------------------------------------
@Override
public boolean writeInput(View view, Form form, ColumnBase<?> column, View.Mode mode, String default_value, Request request) throws IOException {
HTMLWriter writer = request.writer;
writer.write("<div style=\"vertical-align:baseline;\">");
for (int i = 0; i < m_columns.length; i++) {
ColumnBase<?> c = view.getColumn(m_columns[i]);
if (i > 0)
writer.space();
if (m_show_labels_for_inputs) {
if (c != null)
c.writeLabel(request);
else if (!request.db.getTable(view.getViewDef().getFrom()).getColumn(m_columns[i]).isBoolean())
writer.write(m_columns[i].replace('_', ' '));
writer.write(": ");
}
form.writeColumnInput(m_columns[i]);
}
writer.write("</div>");
return true;
}
use of web.HTMLWriter in project common by zenlunatics.
the class MultiColumnRenderer method writeValue.
// --------------------------------------------------------------------------
@Override
public void writeValue(View view, ColumnBase<?> column, Request request) throws IOException {
HTMLWriter writer = request.writer;
for (int i = 0; i < m_columns.length; i++) {
ColumnBase<?> c = view.getColumn(m_columns[i]);
if (i > 0)
writer.space();
if (m_show_labels_for_values) {
if (c != null)
c.writeLabel(request);
else
writer.write(m_columns[i].replace('_', ' '));
writer.write(": ");
}
view.writeColumnHTML(m_columns[i]);
}
}
Aggregations