Search in sources :

Example 1 with Table

use of web.Table in project common by zenlunatics.

the class EMailForm method write.

// --------------------------------------------------------------------
public void write(// TODO: can probably remove show_people_list, must always be true
boolean sender_is_user, // TODO: can probably remove show_people_list, must always be true
boolean show_people_list, // TODO: can probably remove show_people_list, must always be true
Request request) throws // TODO: can probably remove show_people_list, must always be true
IOException {
    HTMLWriter writer = request.writer;
    writer.formOpen("POST", request.getContext() + "/" + m_name);
    writer.hiddenInput("cmd", "send");
    writer.hiddenInput("list", null);
    boolean send_from_local_domain = request.site.getSettings().getString("send from local domain") != null;
    if (sender_is_user)
        if (send_from_local_domain)
            writer.hiddenInput("reply_to", request.db.lookupString("email", m_table, "user_name='" + request.getUser().getUsername() + "'"));
        else
            writer.hiddenInput("from", request.db.lookupString("email", m_table, "user_name='" + request.getUser().getUsername() + "'"));
    Table table = new Table(writer).addStyle("margin", "0 auto").borderSpacing(5).cellPadding(5);
    table.tr();
    if (show_people_list)
        writer.write("<td class=\"db_columnheads\" style=\"vertical-align:top;\">send e-mail to</td>");
    rowOpen(table, sender_is_user ? "subject" : send_from_local_domain ? "reply_to" : "from", writer);
    writer.setAttribute("style", "margin:0;width:500px;");
    writer.textInput(sender_is_user ? "subject" : send_from_local_domain ? "reply_to" : "from", null, null);
    table.tr();
    if (show_people_list) {
        writer.setAttribute("rowspan", sender_is_user ? 3 : 4);
        writer.setAttribute("style", "vertical-align:top;");
        table.td();
        ViewState.setShowCheckBoxes("emailform:" + m_table, "email", "email", request);
        request.site.newView("emailform:" + m_table, request).writeComponent();
    }
    if (!sender_is_user) {
        rowOpen(table, "subject", writer);
        writer.setAttribute("style", "margin:0;width:500px;");
        writer.textInput("subject", null, null);
        table.tr();
    }
    writer.setAttribute("class", "db_columnheads");
    writer.setAttribute("style", "vertical-align:top;");
    table.td("message");
    writer.setAttribute("class", "db_row");
    writer.setAttribute("style", "vertical-align:top;height:300px;");
    table.td();
    writer.setAttribute("style", "height:300px;width:500px;");
    writer.textAreaOpen("message", null, null);
    writer.tagClose();
    writer.js("rich_text('message');");
    if (show_people_list && send_from_local_domain) {
        table.tr();
        rowOpen(table, "individually or group", writer);
        writer.radioButton("individually", "send a single email to selected people (allows \"reply all\")", "0", true, null);
        writer.radioButton("individually", "send separate email to each person (recipients don't see each other)", "1", false, null);
    } else
        writer.hiddenInput("individually", "1");
    table.tr().td("&nbsp;");
    writer.setAttribute("style", "text-align:center;vertical-align:top");
    table.td();
    writer.aButtonOnClick("send", "send_form(this,function(t){eval(t)})");
    table.close();
    writer.tagClose();
}
Also used : HTMLWriter(web.HTMLWriter) Table(web.Table)

Example 2 with Table

use of web.Table in project common by zenlunatics.

the class DaysView method write.

// --------------------------------------------------------------------------
@Override
public void write(int year, int month, int date, String category, String location, Request request) throws IOException {
    java.util.Calendar from = request.site.newCalendar();
    from.set(year, month, date);
    java.util.Calendar today = request.site.newCalendar();
    java.util.Calendar to;
    HTMLWriter writer = request.writer;
    if (m_num_days != 1)
        from.add(java.util.Calendar.DATE, -(from.get(java.util.Calendar.DAY_OF_WEEK) - 1));
    to = (java.util.Calendar) from.clone();
    to.add(java.util.Calendar.DATE, m_num_days);
    TreeSet<Event> events = new TreeSet<Event>();
    m_event_provider.addCalendarsEvents(events, from, to, category, location, request);
    List<List<Event>> days_events = new ArrayList<List<Event>>();
    boolean has_all_day_events = false;
    if (events.size() > 0) {
        for (int i = 0; i < m_num_days; i++) {
            List<Event> event_list = new ArrayList<Event>();
            has_all_day_events |= gather(from, to, events, event_list);
            days_events.add(event_list);
            from.add(java.util.Calendar.DATE, 1);
        }
        from.add(java.util.Calendar.DATE, -m_num_days);
    }
    writer.setAttribute("style", "margin:0 auto;");
    int mark = writer.tagOpen("table");
    writer.write("<tr><td>");
    if (events.size() > 0) {
        int[] start_end = getMinuteBounds(events, from, to);
        int height = start_end[1] - start_end[0];
        Table table = new Table(writer).addClass("days_view");
        if (m_num_days != 1) {
            SimpleDateFormat df = new SimpleDateFormat("EEEEE d");
            table.td("&nbsp;");
            for (int i = 0; i < m_num_days; i++) {
                writer.setAttribute("style", "text-align:center");
                table.td();
                writer.aOnClickOpen("$('calendar').calendar.go(" + from.get(Calendar.YEAR) + "," + from.get(Calendar.MONTH) + "," + from.get(Calendar.DATE) + ",'DAY')");
                writer.write(df.format(from.getTime()));
                writer.tagClose();
                from.add(java.util.Calendar.DATE, 1);
            }
            from.add(java.util.Calendar.DATE, -m_num_days);
        }
        if (has_all_day_events) {
            table.tr();
            writer.setAttribute("style", "text-align:right;padding-right:5px;");
            table.td("all day");
            for (List<Event> day_events : days_events) {
                writer.setAttribute("valign", "top");
                writer.setAttribute("class", Util.dateCompare(from, today) == 0 ? "all_day today" : "all_day");
                table.td();
                writeAllDayEvents(from, day_events, request);
                from.add(java.util.Calendar.DATE, 1);
            }
            from.add(java.util.Calendar.DATE, -m_num_days);
        }
        table.tr();
        writer.setAttribute("valign", "top");
        table.td();
        writeTimes(start_end[0], start_end[1], height, request);
        for (List<Event> day_events : days_events) {
            writer.setAttribute("valign", "top");
            table.td();
            writeDayEvents(from, day_events, start_end[0], start_end[1], height, m_num_days == 1 ? 300 : 150, /*m_state.splitByLocation() ? new ArrayList<String>(locations) :*/
            null, Util.dateCompare(from, today) == 0, request);
            from.add(java.util.Calendar.DATE, 1);
        }
        table.close();
    }
    writer.write("</td></tr>");
    writer.tagsCloseTo(mark);
}
Also used : HTMLWriter(web.HTMLWriter) Table(web.Table) ArrayList(java.util.ArrayList) Calendar(java.util.Calendar) TreeSet(java.util.TreeSet) List(java.util.List) ArrayList(java.util.ArrayList) SimpleDateFormat(java.text.SimpleDateFormat)

Example 3 with Table

use of web.Table in project common by zenlunatics.

the class Admin method exportCSVForm.

// --------------------------------------------------------------------------
public static void exportCSVForm(Request request) throws IOException {
    HTMLWriter writer = request.writer;
    MethodForm method_form = new MethodForm(Admin.class);
    method_form.open("exportCSV", request);
    Table table = new Table(writer);
    table.tr().td("filename").td();
    writer.textInput("filename", null, null);
    table.close();
    method_form.close(writer);
}
Also used : HTMLWriter(web.HTMLWriter) Table(web.Table) JDBCTable(db.JDBCTable)

Example 4 with Table

use of web.Table in project common by zenlunatics.

the class Admin method writeThreads.

// --------------------------------------------------------------------------
private void writeThreads(Request request) throws IOException {
    List<Thread> threads = request.site.getThreads();
    Table table = new Table(request.writer).addClass("table table-condensed table-striped").addStyle("width", "auto");
    for (Thread thread : threads) {
        table.tr().td(thread.getName()).td(thread.getState().toString());
        table.td();
        StackTraceElement[] st = thread.getStackTrace();
        for (StackTraceElement ste : st) {
            request.writer.write(ste.toString());
            request.writer.br();
        }
    }
    table.close();
}
Also used : Table(web.Table) JDBCTable(db.JDBCTable)

Example 5 with Table

use of web.Table in project common by zenlunatics.

the class Admin method writeSessionAttributes.

// --------------------------------------------------------------------------
private void writeSessionAttributes(Request request) throws IOException {
    String remove = request.getParameter("remove");
    if (remove != null)
        request.removeSessionAttribute(remove);
    componentOpen(null, request);
    HTMLWriter writer = request.writer;
    Table table = new Table(writer).addClass("table table-condensed table-striped").addStyle("width", "auto");
    table.th("name").th("value").th("action");
    HttpSession session = request.request.getSession();
    ArrayList<String> l = Collections.list(session.getAttributeNames());
    Collections.sort(l);
    for (String name : l) {
        Object value = session.getAttribute(name);
        table.tr().td(name).td();
        DBObject.write(value, writer);
        table.td();
        writer.aOnClick("remove", componentReplaceJS("action=get_session_attributes&remove=" + name, request));
    }
    table.close();
    writer.tagClose();
}
Also used : HTMLWriter(web.HTMLWriter) Table(web.Table) JDBCTable(db.JDBCTable) HttpSession(javax.servlet.http.HttpSession) DBObject(db.DBObject)

Aggregations

Table (web.Table)16 JDBCTable (db.JDBCTable)12 HTMLWriter (web.HTMLWriter)12 BufferedReader (java.io.BufferedReader)2 File (java.io.File)2 FileReader (java.io.FileReader)2 SQLException (java.sql.SQLException)2 ArrayList (java.util.ArrayList)2 Calendar (java.util.Calendar)2 List (java.util.List)2 Module (app.Module)1 DBObject (db.DBObject)1 Form (db.Form)1 NameValuePairs (db.NameValuePairs)1 RowsSelect (db.RowsSelect)1 Schema (db.Schema)1 Select (db.Select)1 ViewDef (db.ViewDef)1 ResultSet (java.sql.ResultSet)1 ResultSetMetaData (java.sql.ResultSetMetaData)1