use of web.HTMLWriter in project common by zenlunatics.
the class FileRenderer method writeValue.
// --------------------------------------------------------------------------
@Override
public void writeValue(View view, ColumnBase<?> column, Request request) throws IOException {
Rows data = view.data();
String filename = data.getString("filename");
HTMLWriter writer = request.writer;
if (data.getBoolean("folder")) {
writer.aOnClickOpen("c_(this).replace('" + view.getViewDef().getURL(request).toString() + "&parent=" + data.getString("id") + "')");
writer.img("folder.gif");
writer.space();
writer.write(filename);
writer.tagClose();
} else {
writer.aOpen(m_path + '/' + filename);
writer.img("file.gif");
writer.space();
writer.write(m_use_titles ? data.getString("title") : filename);
writer.tagClose();
}
}
use of web.HTMLWriter in project common by zenlunatics.
the class ColumnBase method writeInput.
// --------------------------------------------------------------------------
// normally other column types don't override this method
public void writeInput(String default_value, boolean printer_friendly, View view, Form form, Request request) throws IOException {
Mode mode = view.getMode();
HTMLWriter writer = request.writer;
// try {
if (m_pre_text != null) {
writer.write(m_pre_text);
writer.space();
}
if (mode != View.Mode.FILTER_FORM && (printer_friendly || m_is_read_only || mode == View.Mode.EDIT_FORM && !userCanEdit(request))) {
if (mode == View.Mode.ADD_FORM) {
if (default_value != null) {
writer.hiddenInput(m_name, default_value);
if (m_value_renderer != null)
m_value_renderer.writeValue(view, this, request);
else
writer.write(default_value);
}
} else
view.writeColumnHTML(m_name);
} else {
if (m_is_required) {
writer.setAttribute("required", "yes");
writer.setAttribute("data-title", getDisplayName(false));
}
if (m_on_change != null)
writer.setAttribute("onchange", m_on_change);
if (m_show_previous_values_dropdown) {
writeInputWithPreviousDropdown(m_name, view, default_value, request);
return;
}
if (m_input_renderer != null) {
if (!m_input_renderer.writeInput(view, form, this, mode, default_value, request))
return;
} else
writeInput(mode, default_value, view, form, request);
}
if (m_post_text != null) {
writer.space();
writer.write(m_post_text);
}
// } catch (NullPointerException e) {
// throw new RuntimeException("NullPointerException in Column.writeInput, " + view.getViewDef().getName() + ", " + m_name);
// }
}
use of web.HTMLWriter in project common by zenlunatics.
the class ColumnBase method writeInputWithDropdown.
// --------------------------------------------------------------------------
protected static void writeInputWithDropdown(String name, List<String> values, View view, String default_value, Request request) throws IOException {
JDBCColumn jdbc_column = request.db.getTable(view.getViewDef().getFrom()).getColumn(name);
HTMLWriter writer = request.writer;
// flex display is to prevent firefox from expanding div to 100% width
writer.write("<div class=\"input-group\" style=\"display:flex\">");
String id = UUID.randomUUID().toString();
writer.setAttribute("id", id);
if (values.size() > 0)
writer.setAttribute("onkeyup", "fill_choice(this,$(this).getNext().getElement('ul'))");
writer.textInput(name, Integer.toString(jdbc_column.size), getValue(jdbc_column, default_value, view, request));
if (values.size() > 0) {
Dropdown dropdown = new Dropdown(null, "dropdown-toggle", request.writer).setDivClass("input-group-btn").setDropdownMenuRight(true).open();
for (String value : values) dropdown.aOnClick(value, "$(this).ancestor('DIV').getPrevious().value=this.get('text');");
dropdown.close();
}
writer.write("</div>");
}
use of web.HTMLWriter in project common by zenlunatics.
the class ColumnBase method writeInput.
// --------------------------------------------------------------------------
// normally other column types override this method
protected void writeInput(Mode mode, String default_value, View view, Form form, Request request) throws IOException {
JDBCColumn jdbc_column = request.db.getTable(view.getViewDef().getFrom()).getColumn(m_name);
HTMLWriter writer = request.writer;
if (jdbc_column != null && jdbc_column.isBoolean()) {
writer.write("<div class=\"checkbox\" style=\"margin:0;min-height:0;padding-top:0;\"><label style=\"margin:0;\"");
if (m_title != null)
writer.writeAttribute("title", m_title);
writer.write('>');
writer.checkbox(m_name, null, null, mode == View.Mode.EDIT_FORM && view.data().getBoolean(m_name) || mode == View.Mode.ADD_FORM && ("yes".equals(default_value) || "true".equals(default_value)), true);
writer.hiddenInput("db_boolean" + writer.newID(), m_name);
writer.space();
writeLabel(request);
writer.write("</label></div>");
} else {
if (m_title != null)
writer.setAttribute("title", m_title);
writeInput(m_name, default_value, view, request);
}
}
use of web.HTMLWriter in project common by zenlunatics.
the class FileColumn method writeValue.
// --------------------------------------------------------------------------
public void writeValue(Rows data, Request request) throws IOException {
String dir_column_value = null;
String filename = data.getString(m_name);
StringBuilder href = new StringBuilder(request.getContext());
HTMLWriter writer = request.writer;
if (m_directory != null) {
href.append('/');
href.append(m_directory);
}
if (m_dir_column != null) {
dir_column_value = data.getString(m_dir_column);
if (dir_column_value != null && dir_column_value.length() > 0) {
href.append('/');
href.append(dir_column_value);
}
}
href.append('/');
href.append(filename);
if (m_title_column == null)
writer.a(filename, href.toString());
else
writeLink(data.getString(m_title_column), href.toString(), m_print_url, data.getString("id"), request);
if (m_show_date) {
File file = getFile(data, request);
if (file.exists()) {
writer.write(" <span style=\"font-size:smaller\">(");
writer.write(DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT).format(new Date(file.lastModified())));
writer.write(")</span>");
}
}
}
Aggregations