Search in sources :

Example 31 with HTMLWriter

use of web.HTMLWriter in project common by zenlunatics.

the class DaysView method writeDayEvents.

// --------------------------------------------------------------------------
private void writeDayEvents(Calendar c, List<Event> events, int start_minutes, int end_minutes, int height, int box_width, List<String> locations, boolean today, Request request) throws IOException {
    HTMLWriter writer = request.writer;
    writer.write("<div style=\"position:relative;top:8px;width:");
    writer.write(box_width);
    writer.write("px;height:");
    writer.write(height);
    writer.write("px\">");
    writeDayGrid(start_minutes, end_minutes, box_width, today, writer);
    int width = 0;
    for (int i = 0; i < events.size(); i++) {
        Event event = events.get(i);
        if (!event.hasStartTime())
            continue;
        int minutes = Util.minuteOfDay(event.getStartDate());
        int length = event.getLength();
        if (length < 1)
            length = 30;
        int left = 0;
        // if (m_state.splitByLocation()) {
        // SelectOption location = event.getLocation();
        // if (location == null)
        // left = locations.size() * width;
        // else
        // left = locations.indexOf(event.getLocation().getText()) * width;
        // } else {
        int overlaps_before = 0;
        int total_overlaps = 0;
        for (int j = 0; j < events.size(); j++) if (j != i) {
            Event event2 = events.get(j);
            if (event.timeOverlaps(event2)) {
                if (j < i)
                    ++overlaps_before;
                ++total_overlaps;
            }
        }
        width = box_width / (total_overlaps + 1);
        left = overlaps_before * width;
        // }
        EventProvider event_provider = event.getEventProvider();
        event.write(c, event_provider != m_event_provider ? event_provider.getDisplayName() : null, length, width, left, minutes - start_minutes, request);
    }
    writer.write("</div>");
}
Also used : HTMLWriter(web.HTMLWriter)

Example 32 with HTMLWriter

use of web.HTMLWriter in project common by zenlunatics.

the class Event method write.

// --------------------------------------------------------------------------
void write(Calendar c, String calendar_name, int height, int width, int left, int top, Request request) throws IOException {
    HTMLWriter writer = request.writer;
    writer.setAttribute("class", "event " + m_event_provider.getName().replace(' ', '_') + "_event");
    String on_click = m_event_provider.getEventEditJS(this, request);
    StringBuilder style = new StringBuilder();
    if (on_click != null) {
        writer.setAttribute("onclick", on_click);
        style.append("cursor:pointer;");
    } else
        style.append("cursor:auto;");
    String color = getColor();
    boolean black_text = Util.blackText(color);
    if (color != null)
        style.append("background-color:").append(color).append(";color:").append(black_text ? "#000000" : "#ffffff").append(';');
    if (height > 0) {
        if (color == null)
            style.append("background-color:#EEEEEE;");
        style.append("height:").append(height).append("px;left:").append(left + 5).append("px;overflow:hidden;position:absolute;top:").append(top).append("px;width:").append(width - 18).append("px;");
        writer.setAttribute("onmouseout", "event_mouseout(event)");
        writer.setAttribute("onmouseover", "event_mouseover(event)");
    }
    if (style.length() > 0)
        writer.setAttribute("style", style.toString());
    if (request.getUser() != null) {
        String tooltip = getTooltip(c, request);
        if (tooltip != null)
            writer.setAttribute("title", tooltip);
    }
    if (m_category != null)
        writer.setAttribute("data-category", m_category.getText());
    if (m_location != null)
        writer.setAttribute("data-location", m_location.getText());
    writer.tagOpen("div");
    StringBuilder s = new StringBuilder();
    if (calendar_name != null)
        s.append("<div class=\"other_calendar_label\" style=\"color:").append(black_text ? "#555555" : "#cccccc").append("\">").append(calendar_name).append(" Calendar</div>");
    appendEventHTML(c, s, black_text, request);
    writer.write(s.toString());
    writer.tagClose();
}
Also used : HTMLWriter(web.HTMLWriter)

Example 33 with HTMLWriter

use of web.HTMLWriter in project common by zenlunatics.

the class EventProvider method writeFilters.

// --------------------------------------------------------------------------
void writeFilters(Request request) throws IOException {
    HTMLWriter writer = request.writer;
    writer.write("<span id=\"calendar_filters\">");
    if (m_events_have_category) {
        writer.write("<span>View categories:&nbsp;");
        web.Select select = new web.Select("calendar_categories", m_categories);
        select.addFirstOption("All", "All");
        select.setOnChange("$('calendar').calendar.set_category(this.options[this.selectedIndex].text)");
        select.write(request);
        writer.write("</span> ");
    }
    if (m_events_have_location) {
        writer.write("<span>View locations:&nbsp;");
        web.Select select = new web.Select("calendar_locations", m_locations);
        select.addFirstOption("All", "All");
        select.setOnChange("$('calendar').calendar.set_location(this.options[this.selectedIndex].text)");
        select.write(request);
        writer.write("</span> ");
    }
    writer.write("</span>");
}
Also used : HTMLWriter(web.HTMLWriter) Select(db.Select)

Example 34 with HTMLWriter

use of web.HTMLWriter in project common by zenlunatics.

the class ListView method write.

// --------------------------------------------------------------------------
@Override
public void write(int year, int month, int date, String category, String location, Request request) throws IOException {
    java.util.Calendar c = request.site.newCalendar();
    c.set(year, month, date);
    java.util.Calendar c2 = null;
    SortedSet<Event> events = new TreeSet<Event>();
    HTMLWriter writer = request.writer;
    writer.setAttribute("style", "margin:0 auto;width:100%;");
    writer.tagOpen("table");
    m_event_provider.addCalendarsEvents(events, c, category, location, request);
    for (Event event : events) {
        Calendar start_date = event.getStartDate();
        if (c2 == null || c2.get(Calendar.YEAR) != start_date.get(Calendar.YEAR) || c2.get(Calendar.DAY_OF_YEAR) != start_date.get(Calendar.DAY_OF_YEAR)) {
            if (c2 != null)
                writer.write("</td></tr>");
            c2 = start_date;
            writer.write("<tr><td class=\"calendar_date\">");
            writeDateDOW(c2, c, request);
            writer.write("</td></tr><tr><td class=\"calendar_events\">");
        }
        EventProvider event_provider = event.getEventProvider();
        event.write(c2, event_provider != m_event_provider ? event_provider.getDisplayName() : null, request);
    }
    writer.write("</td></tr>");
    writer.tagClose();
}
Also used : Calendar(java.util.Calendar) HTMLWriter(web.HTMLWriter) TreeSet(java.util.TreeSet) Calendar(java.util.Calendar)

Example 35 with HTMLWriter

use of web.HTMLWriter in project common by zenlunatics.

the class Admin method writeTableCreateForm.

// --------------------------------------------------------------------------
private void writeTableCreateForm(Request request) throws IOException {
    HTMLWriter writer = request.writer;
    web.Form form = new web.Form(null, "admin", writer).setOnClick("send_form(this,function(t){dialog_alert('','table created');get_nav_list('tables');})").setSubmitText("create").setButtonsLocation(Form.Location.BOTTOM).open();
    writer.hiddenInput("action", "table_create");
    form.rowOpen("table");
    writer.textInput("table", null, null);
    form.rowOpen("columns");
    writer.textAreaOpen("columns", "2", "80");
    writer.tagClose();
    form.close();
}
Also used : HTMLWriter(web.HTMLWriter) Form(db.Form)

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