Search in sources :

Example 91 with HTMLWriter

use of web.HTMLWriter in project common by zenlunatics.

the class MonthView method weekRowOpen.

// --------------------------------------------------------------------------
private void weekRowOpen(java.util.Calendar c, Request request) throws IOException {
    HTMLWriter writer = request.writer;
    writer.tagOpen("tr");
// if (allowViewSwitching()) {
// writer.write("<td class=\"week\">");
// writer.aOnClick(Integer.toString(c.get(Calendar.WEEK_OF_YEAR)), "$('calendar').calendar.go(" + c.get(Calendar.YEAR) + "," + c.get(Calendar.MONTH) + "," + c.get(Calendar.DATE) + ",'WEEK')");
// writer.write("</td>");
// }
}
Also used : HTMLWriter(web.HTMLWriter)

Example 92 with HTMLWriter

use of web.HTMLWriter in project common by zenlunatics.

the class MonthView method writeDay.

// --------------------------------------------------------------------------
private void writeDay(TreeSet<Event> events, Calendar c, Calendar today, boolean in_month, boolean show_add, Request request) throws IOException {
    HTMLWriter writer = request.writer;
    writer.write("<td class=\"");
    writer.write(in_month ? m_event_provider.getDayCSSClass(c, today) : "non_day");
    writer.write("\" valign=\"top\" style=\"height:80px\"");
    if (show_add)
        writer.write(" onmouseout=\"day_mouseout(event)\" onmouseover=\"day_mouseover(event)\"");
    writer.write(">");
    if (show_add)
        writer.setAttribute("style", "visibility:hidden;float:right;").buttonOnClick("add", "$('calendar').calendar.add('" + HTMLWriter.escapeJSString(m_event_provider.getName()) + "','" + HTMLWriter.escapeJSString(m_event_provider.getDisplayName()) + "','" + request.date_time_formatter.short_date.format(c.getTime()) + "')");
    if (allowViewSwitching() && request.getUser() != null) {
        writer.setAttribute("style", "font-weight:bold");
        writer.aOnClick(Integer.toString(c.get(java.util.Calendar.DATE)), "$('calendar').calendar.go(" + c.get(Calendar.YEAR) + "," + c.get(Calendar.MONTH) + "," + c.get(Calendar.DATE) + ",'DAY')");
    } else
        writer.write("<span style=\"font-weight:bold;\">").write(c.get(java.util.Calendar.DATE)).write("</span>");
    if (events.size() > 0) {
        Event event = events.first();
        while (event.occursOn(c)) {
            EventProvider event_event_provider = event.getEventProvider();
            event.write(c, event_event_provider != m_event_provider ? event_event_provider.getDisplayName() : null, request);
            events.remove(event);
            if (events.size() == 0)
                break;
            event = events.first();
        }
    }
    writer.write("</td>");
}
Also used : HTMLWriter(web.HTMLWriter)

Example 93 with HTMLWriter

use of web.HTMLWriter in project common by zenlunatics.

the class ReminderWhenColumn method writeInput.

// --------------------------------------------------------------------------
@Override
protected void writeInput(Mode mode, String default_value, View view, Form form, Request request) throws IOException {
    HTMLWriter writer = request.writer;
    boolean can_repeat = m_always_can_repeat;
    if (m_events_can_repeat && !can_repeat) {
        int one_id;
        if (mode == Mode.ADD_FORM) {
            ViewState state = (ViewState) request.getState(ViewState.class, m_event_provider_name);
            one_id = Integer.parseInt(state.key_value);
        } else
            one_id = view.data().getInt(m_event_table + "_id");
        String repeat = request.db.lookupString(new db.Select("repeat").from(m_event_table).whereIdEquals(one_id));
        can_repeat = repeat != null && !repeat.equals("never");
    }
    int num = 0;
    if (mode != Mode.ADD_FORM)
        num = view.data().getInt("num");
    boolean on_the_day = mode == Mode.ADD_FORM || "day".equals(view.data().getString("unit")) && num == 0;
    String id = UUID.randomUUID().toString();
    writer.setAttribute("id", id);
    writer.select("num", (String[]) null, null).space();
    if (m_events_have_time)
        new Select("unit", num == 1 ? new String[] { "day", "hour", "minute", "week" } : new String[] { "days", "hours", "minutes", "weeks" }, new String[] { "day", "hour", "minute", "week" }).setSelectedOption(null, mode == Mode.ADD_FORM ? "day" : view.data().getString("unit")).write(request);
    else
        new Select("unit", num == 1 ? new String[] { "day", "week" } : new String[] { "days", "weeks" }, new String[] { "day", "week" }).setSelectedOption(null, mode == Mode.ADD_FORM ? "day" : view.data().getString("unit")).write(request);
    writer.space();
    String on_the_day_label = can_repeat ? "on the day of" : "on the day";
    new Select("before", new String[] { on_the_day_label, "before", "after" }, new String[] { on_the_day_label, "true", "false" }).setSelectedOption(on_the_day ? on_the_day_label : mode == Mode.ADD_FORM ? "before" : view.data().getBoolean("before") ? "before" : "after", null).write(request);
    if (can_repeat)
        writer.space().select("repeat_days", new String[] { "each event", "first event", "last event" }, mode == Mode.ADD_FORM ? "each event" : view.data().getString("repeat_days"));
    writer.js("new ReminderWhen('" + id + "'," + (mode == Mode.ADD_FORM ? 0 : view.data().getInt("num")) + ");");
}
Also used : HTMLWriter(web.HTMLWriter) Select(web.Select) ViewState(db.ViewState)

Example 94 with HTMLWriter

use of web.HTMLWriter in project common by zenlunatics.

the class ReminderWhenColumn method writeValue.

// --------------------------------------------------------------------------
@Override
public boolean writeValue(View view, Map<String, Object> data, Request request) throws IOException {
    int num = view.data().getInt("num");
    String repeat = null;
    String unit = view.data().getString("unit");
    HTMLWriter writer = request.writer;
    if (m_events_can_repeat)
        repeat = request.db.lookupString(new db.Select("repeat").from(m_event_table).whereIdEquals(view.data().getInt(m_event_table + "_id")));
    if (num == 0 && "day".equals(unit))
        writer.write(!m_events_can_repeat || "never".equals(repeat) ? "on the day" : "on the day of");
    else {
        writer.write(num).space().write(unit);
        if (num != 1)
            writer.write('s');
        writer.write(view.data().getBoolean("before") ? " before" : " after");
    }
    if (m_events_can_repeat && !"never".equals(repeat))
        writer.space().write(view.data().getString("repeat_days"));
    return true;
}
Also used : HTMLWriter(web.HTMLWriter)

Example 95 with HTMLWriter

use of web.HTMLWriter in project common by zenlunatics.

the class MethodForm method open.

// --------------------------------------------------------------------------
public void open(String method_name, Request request) throws IOException {
    HTMLWriter writer = request.writer;
    writer.write("<form method=\"POST\">");
    writer.hiddenInput("method", method_name);
    if (m_module != null)
        writer.hiddenInput("module", m_module.getName());
    else if (m_object_class != null)
        writer.hiddenInput("class", m_object_class.getSimpleName());
    Enumeration<String> parameter_names = request.getParameterNames();
    while (parameter_names.hasMoreElements()) {
        String parameter_name = parameter_names.nextElement();
        if (!parameter_name.equals("action") && !parameter_name.equals("class") && !parameter_name.equals("method") && !parameter_name.equals("module"))
            request.writer.hiddenInput(parameter_name, request.getParameter(parameter_name));
    }
    writer.h3((m_object_class != null ? m_object_class.getSimpleName() : m_module.getClass().getSimpleName()) + '.' + method_name);
}
Also used : HTMLWriter(web.HTMLWriter)

Aggregations

HTMLWriter (web.HTMLWriter)109 Select (db.Select)18 SQLException (java.sql.SQLException)16 ResultSet (java.sql.ResultSet)14 Table (web.Table)12 JDBCTable (db.JDBCTable)10 Person (app.Person)7 Calendar (java.util.Calendar)7 ArrayList (java.util.ArrayList)6 JDBCColumn (db.JDBCColumn)5 View (db.View)5 DBObject (db.DBObject)4 Form (db.Form)4 File (java.io.File)4 AdminTask (web.AdminTask)4 FilePathStringBuilder (web.FilePathStringBuilder)4 Select (web.Select)4 Mode (db.View.Mode)3 IOException (java.io.IOException)3 NumberFormat (java.text.NumberFormat)3