Example usage for com.google.gwt.user.client.ui HTML HTML

List of usage examples for com.google.gwt.user.client.ui HTML HTML

Introduction

In this page you can find the example usage for com.google.gwt.user.client.ui HTML HTML.

Prototype

protected HTML(Element element) 

Source Link

Document

This constructor may be used by subclasses to explicitly use an existing element.

Usage

From source file:burrito.client.crud.CrudIndexPanel.java

License:Apache License

protected void init(List<CrudEntityInfo> result) {
    Label descLabel;//w w w. jav a  2 s . c o m
    wrapper.add((descLabel = new Label(messages.chooseEntity())));
    if (result.isEmpty()) {
        wrapper.add((descLabel = new Label(messages.noEntitiesToEdit())));
        wrapper.add(new VerticalSpacer(10));
    }
    descLabel.addStyleName("k5-CrudPanel-indexDesc");
    for (CrudEntityInfo crudEntityInfo : result) {
        HorizontalPanel fp = new HorizontalPanel();
        String underscore = crudEntityInfo.getEntityName().replace('.', '_');
        Hyperlink entityName = new Hyperlink(CrudLabelHelper.getString(underscore),
                crudEntityInfo.getEntityName());
        entityName.addStyleName("k5-CrudPanel-entityName");
        fp.add(entityName);
        String desc = CrudLabelHelper.getNullableString(underscore + "_desc");
        if (desc != null) {
            HTML descHtml = new HTML("&nbsp;-&nbsp;" + desc);
            descHtml.addStyleName("k5-CrudPanel-entityDesc");
            fp.add(descHtml);
        }
        wrapper.add(fp);
        wrapper.add(new VerticalSpacer(10));
    }

    wrapper.add(new VerticalSpacer(30));
    wrapper.add(new Label(messages.administrativeTasksHeader()));

    wrapper.add(new VerticalSpacer(10));
    wrapper.add(new Hyperlink(messages.reindex(), "reindex"));

}

From source file:burrito.client.crud.CrudPanelTop.java

License:Apache License

public void update(String entityName, String entityDisplayString) {
    String entityNameDisplay = null;
    if (entityName == null) {
        breadCrumbs.clear();/*from   w  w  w.  j  a  v a 2s . co  m*/
        breadCrumbs.setVisible(false);
        return;
    }
    entityNameDisplay = CrudLabelHelper.getString(entityName.replace('.', '_'));
    breadCrumbs.clear();
    breadCrumbs.add(new Hyperlink(messages.admin(), ""));
    breadCrumbs.add(new HTML("&nbsp;>&nbsp;"));
    if (entityDisplayString != null) {
        breadCrumbs.add(new Hyperlink(entityNameDisplay, entityName));
        breadCrumbs.add(new HTML("&nbsp;>&nbsp;"));
        breadCrumbs.add(new Label(entityDisplayString));
    } else {
        breadCrumbs.add(new Label(entityNameDisplay));
    }
    breadCrumbs.setVisible(true);
}

From source file:burrito.client.crud.widgets.CrudRichTextArea.java

License:Apache License

public CrudRichTextArea(String value) {
    textArea = new FormattedRichTextArea();
    textArea.setHTML(value);//  w  w w .  ja  v  a  2s.  c o  m
    formatter = textArea.getFormatter();
    richTextDock.add(createCommandsArea(), DockPanel.NORTH);
    textArea.addKeyDownHandler(new KeyDownHandler() {

        public void onKeyDown(KeyDownEvent event) {
            toggleButtons();
            checkForKeyBoardCombinations(event);
        }
    });
    textArea.addClickHandler(new ClickHandler() {

        public void onClick(ClickEvent event) {
            toggleButtons();
        }
    });
    textAreaWrapper.setWidget(textArea);
    richTextDock.add(textAreaWrapper, DockPanel.CENTER);
    HTML richTextHeader = new HTML(labels.richText());
    richTextHeader.addClickHandler(new ClickHandler() {

        public void onClick(ClickEvent event) {
            if (rawVisible) {
                textArea.setHTML(raw.getText());
                textAreaWrapper.clear();
                textAreaWrapper.setWidget(textArea);
            }
            rawVisible = false;
        }
    });
    tabPanel.add(richTextDock, richTextHeader);
    HTML rawHeader = new HTML(labels.rawHtml());
    rawHeader.addClickHandler(new ClickHandler() {

        public void onClick(ClickEvent event) {
            if (!rawVisible) {
                raw.setText(textArea.getHTML());
            }
            rawVisible = true;
        }
    });
    tabPanel.add(raw, rawHeader);

    imagePicker = new ImagePickerPopup(800, 800, false);
    imagePicker.addSaveHandler(new ImagePickerPopup.SaveHandler() {

        public void saved(String value) {
            formatter.insertImage("/blobstore/image?key=" + value);
        }
    });

    wrapper.add(tabPanel);

    ToggleButton maximize = new ToggleButton(labels.maximize(), labels.minimize());
    maximize.addClickHandler(new ClickHandler() {
        boolean max = false;

        public void onClick(ClickEvent event) {
            if (max) {
                raw.setSize("400px", "250px");
                textArea.setSize("400px", "250px");

            } else {
                raw.setSize("800px", "440px");
                textArea.setSize("800px", "440px");
            }
            max = !max;
        }
    });
    maximize.setWidth("80px");
    wrapper.add(maximize);
    initWidget(wrapper);
    addStyleName("k5-CrudRichTextArea");
    raw.setSize("400px", "250px");
    textArea.setSize("400px", "250px");
    tabPanel.selectTab(0);
}

From source file:burrito.client.crud.widgets.LinkedEntityValue.java

License:Apache License

public LinkedEntityValue(String json) {
    this.json = json;
    wrapper.add(label);/*www .  j av a 2 s.co m*/
    Anchor edit = new Anchor(labels.editLink());
    edit.addClickHandler(new ClickHandler() {

        public void onClick(ClickEvent event) {
            LinkedEntityWidgetPopup popup = new LinkedEntityWidgetPopup(
                    new LinkedEntityWidgetPopup.SaveHandler() {

                        public void saved(String json) {
                            LinkedEntityValue.this.json = json;
                            load();
                        }
                    });
            popup.fromJson(LinkedEntityValue.this.json);
            popup.center();
            popup.show();
        }
    });
    wrapper.add(new HTML("&nbsp;"));
    wrapper.add(edit);
    wrapper.add(new HTML("&nbsp;"));
    load();

    initWidget(wrapper);
    addStyleName("k5-LinkedEntityValue");
}

From source file:burrito.client.sitelet.SiteletDragAndDropPanel.java

License:Apache License

public SiteletDragAndDropPanel(final String containerName) {
    super();/*from   ww  w  .j  a v  a 2 s  .  c  om*/
    widgetCreator.setContainerName(containerName);
    Hyperlink addSitelet = new Hyperlink(labels.addSitelet(), "-1");

    wrapper.add(addSitelet);

    saveOrderButton = new Button(labels.saveOrder(), new ClickHandler() {

        @Override
        public void onClick(ClickEvent event) {
            service.saveSiteletOrder(containerName, currentOrder, new AsyncCallback<Void>() {

                @Override
                public void onSuccess(Void result) {
                    InfoMessagePopup popup = new InfoMessagePopup();
                    popup.setTextAndShow(labels.orderSaved());
                    orderChangedPanel.setVisible(false);
                }

                @Override
                public void onFailure(Throwable caught) {
                    throw new RuntimeException("Failed to save order", caught);
                }
            });

        }
    });
    orderChangedPanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);
    orderChangedPanel.add(new Label(labels.orderChanged()));
    orderChangedPanel.add(new HTML("&nbsp;"));
    orderChangedPanel.add(saveOrderButton);
    orderChangedPanel.setVisible(false);

    service.getSitelets(containerName, new AsyncCallback<List<SiteletDescription>>() {

        @Override
        public void onSuccess(final List<SiteletDescription> result) {
            currentModel = result;
            render();
        }

        @Override
        public void onFailure(Throwable caught) {
            throw new RuntimeException("Failed to load sitelets for container " + containerName, caught);
        }
    });
    wrapper.add(siteletsContainer);
    wrapper.add(orderChangedPanel);
    initWidget(wrapper);
}

From source file:burrito.client.sitelet.SiteletEditPanel.java

License:Apache License

private void addEntityOption(CrudEntityInfo crudEntityInfo) {
    HorizontalPanel fp = new HorizontalPanel();
    String underscore = crudEntityInfo.getEntityName().replace('.', '_');
    fp.add(createTypeLink(crudEntityInfo.getEntityName(), CrudLabelHelper.getString(underscore)));
    String desc = CrudLabelHelper.getNullableString(underscore + "_desc");
    if (desc != null) {
        fp.add(new HTML("&nbsp;-&nbsp;" + desc));
    }//w ww . ja  va  2  s  . co  m
    types.add(fp);
    types.add(new VerticalSpacer(10));
}

From source file:ca.upei.ic.timetable.client.ApplicationView.java

License:Apache License

public ApplicationView(ApplicationController app) {
    app_ = app;/*from   w w  w .  java  2  s . c  o m*/

    // hide the root panel first
    hide();

    // create the application view elements
    // we are using a horizontal split panel to host the left side (course view)
    // and the right side (calendar view)
    DockPanel panel = GWT.create(DockPanel.class);
    panel.setSize("980px", "580px");

    final View findCourseView = app_.getFindCourseController().getView();

    // find course button
    final Button findCourseButton = GWT.create(Button.class);
    findCourseButton.setText("Find Course...");
    findCourseButton.setPixelSize(250, 28);
    findCourseButton.addClickListener(new ClickListener() {

        public void onClick(Widget sender) {
            findCourseView.show();
        }

    });
    // message view
    final View messageView = app_.getMessageController().getView();

    // course view
    final View courseView = app_.getCourseController().getView();
    courseView.getWidget().setWidth("340px");

    // calendar view
    final View calendarView = app_.getCourseCalendarController().getView();

    // top panel
    HorizontalPanel topPanel = GWT.create(HorizontalPanel.class);
    topPanel.add(findCourseButton);
    headerPanel_ = GWT.create(HorizontalPanel.class);
    SimplePanel topleft = PanelUtils.simplePanel(new HTML(""), 61, 28);
    headerPanel_.add(topleft);

    // add headers
    for (int i = 1; i < 6; i++) {
        SimplePanel header = GWT.create(SimplePanel.class);
        header.addStyleName("gridHeaderCell");
        header.setPixelSize(128, 28);
        header.add(new HTML(headerStrings[i]));
        headerPanel_.add(header);
    }

    topPanel.add(headerPanel_);

    // add elements to the dock panel
    // to north (top bar)
    panel.add(PanelUtils.horizontalPanel(findCourseButton, headerPanel_), DockPanel.NORTH);
    // to west (left side bar)
    panel.add(PanelUtils.verticalPanel(
            PanelUtils.decoratorPanel(PanelUtils.scrollPanel(courseView.getWidget(), 240, 555)),
            PanelUtils.horizontalPanel(ButtonUtils.button("Clear", 125, 25, new ClickListener() {
                public void onClick(Widget sender) {
                    app_.getCourseController().clear();
                }
            }, null), ButtonUtils.button("Print...", 125, 25, new ClickListener() {
                public void onClick(Widget sender) {
                    Element wrapper = DOM.createDiv();
                    Element header = (Element) headerPanel_.getElement().cloneNode(true);
                    wrapper.appendChild(header);
                    CalendarPanel calendar = (CalendarPanel) app_.getCourseCalendarController().getView()
                            .getWidget();
                    int height = calendar.getRealHeight();
                    Element calendarElement = (Element) calendar.getElement().cloneNode(true);
                    DOM.setStyleAttribute(calendarElement, "page-break-inside", "avoid");
                    DOM.setStyleAttribute(calendarElement, "height", (height + 50) + "px");
                    wrapper.appendChild(calendarElement);
                    app_.print("Main.css", wrapper.getInnerHTML());
                }
            }, null))), DockPanel.WEST);
    // to center (content)
    panel.add(calendarView.getWidget(), DockPanel.CENTER);

    // to footer (copyright)
    panel.add(new HTML(
            "&copy; 2008 University of Prince Edward Island. This is an <a href=\"http://github.com/upei/\">open-source project</a> licensed under Apache License 2.0."),
            DockPanel.SOUTH);

    // add the horizontal panel
    RootPanel.get().add(panel);
}

From source file:ca.upei.ic.timetable.client.CalendarPanel.java

License:Apache License

/**
 * This method must be called after all settings done.
 *///w  w  w . j a  v a 2 s  .c o  m
void init() {

    calendarInnerHeight_ = Calendar.RESOLUTION * 14 * 4;
    calendarInnerWidth_ = width_ - 17;

    // create the horizontalPanel
    panel_ = GWT.create(HorizontalPanel.class);

    // add panels
    for (int i = 0; i < 7; i++) {
        panel_.add((Widget) GWT.create(AbsolutePanel.class));
    }

    // create the scroll panel
    outerPanel_ = GWT.create(ScrollPanel.class);

    // create the absolute wrapper
    AbsolutePanel wrapper = GWT.create(AbsolutePanel.class);
    wrapper.setPixelSize(calendarInnerWidth_, calendarInnerHeight_);

    // set the calendar width and height
    panel_.setPixelSize(calendarInnerWidth_ - calendarLeftDescriptionWidth_, calendarInnerHeight_);

    // add the sub panel and set size
    outerPanel_.add(wrapper);
    outerPanel_.setPixelSize(width_, height_);

    // deal with type
    switch (calendar_.getType()) {
    case Calendar.FIVE:
        panel_.getWidget(0).setSize("0px", "0px");

        courseWidth_ = (calendarInnerWidth_ - calendarLeftDescriptionWidth_) / 5; // minus
        // the
        // scroll
        // bar
        // width
        for (int i = 1; i < 6; i++) {
            panel_.getWidget(i).setPixelSize(courseWidth_, calendarInnerHeight_);
        }
        panel_.getWidget(6).setSize("0px", "0px");

        break;
    case Calendar.SEVEN:
        courseWidth_ = (calendarInnerWidth_ - calendarLeftDescriptionWidth_) / 7;
        for (int i = 0; i < 7; i++) {
            panel_.getWidget(i).setPixelSize(courseWidth_, calendarInnerHeight_);
        }
        break;
    default:
        throw new IllegalArgumentException("Calendar type is invalid.");
    }

    // add to observer list
    calendar_.addObserver("itemDidAdd", this);
    calendar_.addObserver("itemDidRemove", this);

    // create the grid
    HorizontalPanel grid = new HorizontalPanel();
    grid.setPixelSize(calendarInnerWidth_ - calendarLeftDescriptionWidth_, calendarInnerHeight_);
    grid.addStyleName("grid");

    // FIXME tricky part, needs to change
    for (int i = 0; i < 5; i++) {
        VerticalPanel gridColumn = GWT.create(VerticalPanel.class);
        gridColumn.addStyleName("gridColumn");
        gridColumn.setHeight(Integer.toString(calendarInnerHeight_) + "px");
        gridColumn.setWidth(Integer.toString(courseWidth_ - 1) + "px");

        for (int j = 0; j < 14 * 60 / Calendar.RESOLUTION / 2; j++) {
            SimplePanel cell = GWT.create(SimplePanel.class);
            cell.addStyleName("gridCell");
            cell.setHeight(Integer.toString(Calendar.RESOLUTION * 2 - 1) + "px");
            cell.setWidth(Integer.toString(courseWidth_ - 1) + "px");

            final int day = i;
            final int hour = j;

            gridColumn.add(PanelUtils.focusPanel(cell, new ClickListener() {

                public void onClick(Widget sender) {
                    if (cellClickListener_ != null) {
                        Map<String, Integer> params = new HashMap<String, Integer>();
                        params.put("day", day);
                        params.put("hour", hour);
                        cellClickListener_.setContext(params);
                        cellClickListener_.onClick(sender);
                    }
                }

            }, null, null, null));
        }
        grid.add(gridColumn);
    }

    // create the with description panel
    HorizontalPanel panelWithDescription = GWT.create(HorizontalPanel.class);
    VerticalPanel leftDescription = GWT.create(VerticalPanel.class);
    leftDescription.setPixelSize(calendarLeftDescriptionWidth_, calendarInnerHeight_);
    leftDescription.addStyleName("timeColumn");
    // first row
    SimplePanel firstTimeCell = GWT.create(SimplePanel.class);
    firstTimeCell.addStyleName("timeCell");
    firstTimeCell.setPixelSize(calendarLeftDescriptionWidth_ - 1, Calendar.RESOLUTION);
    leftDescription.add(firstTimeCell);

    for (int i = 0; i < 14 * 60 / Calendar.RESOLUTION / 2; i++) {
        SimplePanel cell = GWT.create(SimplePanel.class);
        cell.addStyleName("timeCell");
        cell.setPixelSize(calendarLeftDescriptionWidth_ - 1, Calendar.RESOLUTION * 2);

        String half;

        if (i % 2 == 0) {
            half = "30";
        } else {
            half = "00";
        }

        // half time adjustment
        int tp = i / 2 + 8;
        tp = tp + i % 2;

        String ampm = "am";

        if (tp >= 12) {
            ampm = "pm";
        }
        if (tp > 12) {
            tp -= 12;
        }

        cell.add(new HTML(Integer.toString(tp) + ":" + half + ampm + "&nbsp;"));

        leftDescription.add(cell);
    }

    panelWithDescription.add(leftDescription);
    panelWithDescription.add(panel_);

    // add the elements
    wrapper.add(grid, calendarLeftDescriptionWidth_, 0);
    wrapper.add(panelWithDescription, 0, 0);

    initWidget(outerPanel_);

    // set the style primary name
    outerPanel_.setStylePrimaryName("wi-CalendarPanel");
    // create the map
    itemWidgets_ = new HashMap<CalendarItem, Set<Widget>>();
}

From source file:ca.upei.ic.timetable.client.CalendarPanel.java

License:Apache License

protected void itemDidAdd(Calendar calendar, CalendarItem item) {
    // create the widget pool
    if (!itemWidgets_.containsKey(item)) {
        itemWidgets_.put(item, new HashSet<Widget>());
    }/*from  ww w . j av a  2 s  .  co  m*/

    // iterate all entries in the item
    for (Map.Entry<Integer, Day> entry : item.getDays().entrySet()) {
        int day = entry.getKey();
        // get the parent panel
        AbsolutePanel parent = (AbsolutePanel) panel_.getWidget(day);

        // build the widgets
        Set<TimeInterval> intervals = entry.getValue().getTimeIntervals();
        // iterate all time intervals of a day.
        for (TimeInterval ti : intervals) {
            // create the widget
            SimplePanel widget = GWT.create(SimplePanel.class);

            HTML html = new HTML("<h3>" + item.getTitle() + "</h3><p>" + item.getContent() + "</p>");
            widget.setWidget(html);

            // set the style
            widget.setStylePrimaryName("wi-CalendarPanel");
            widget.addStyleDependentName("selectedCourse");

            int begin = 0;
            if (ti.begin() < 480 / Calendar.RESOLUTION) { // if it's an
                // afternoon
                // course
                begin = ti.begin() + 240 / Calendar.RESOLUTION;
            } else { // no it's a morning course.
                begin = ti.begin() - 480 / Calendar.RESOLUTION;
            }

            int end;
            if ((ti.end() <= 540 / Calendar.RESOLUTION) || (begin >= 600 / Calendar.RESOLUTION)) { // it it ends
                // before
                // 930 or
                // begin at
                // 600pm
                end = ti.end() + 240 / Calendar.RESOLUTION;
            } else {
                end = ti.end() - 480 / Calendar.RESOLUTION;
            }
            // set the size
            int height = (end - begin) * Calendar.RESOLUTION;
            widget.setPixelSize(courseWidth_ - 2, height - 2); // minus the
            // border
            // width

            parent.add(widget, 0, begin * Calendar.RESOLUTION);

            // add to widget pool
            itemWidgets_.get(item).add(widget);
        }
    }

    // reorganize all panels
    for (int i = 0; i < panel_.getWidgetCount(); i++) {
        AbsolutePanel panel = (AbsolutePanel) panel_.getWidget(i);
        reorganizePanel(panel);
    }
}

From source file:ca.upei.ic.timetable.client.CourseDetailModelView.java

License:Apache License

public void loadJSON(JSONValue value) {
    // get all the parameters
    JSONObject object = (JSONObject) value;
    boolean success = ((JSONBoolean) object.get("success")).booleanValue();

    if (!success) {
        // do nothing and exit
        throw new RuntimeException("This course id does not exist.");
    }//w  w w  .j a  va2  s  .com

    String department = ((JSONString) object.get("department")).stringValue();
    String name = ((JSONString) object.get("name")).stringValue();
    String title = ((JSONString) object.get("title")).stringValue();
    String location = ((JSONString) object.get("location")).stringValue();
    String time = ((JSONString) object.get("time")).stringValue();
    String semester = ((JSONString) object.get("semester")).stringValue();
    String status = ((JSONString) object.get("status")).stringValue();
    String description = ((JSONString) object.get("description")).stringValue();
    String instructors = ((JSONString) object.get("instructors")).stringValue();

    // build the dialog box
    clear(); // clear the dialog box first.

    // build the panels
    VerticalPanel panel = PanelUtils.verticalPanel(
            PanelUtils.simplePanel(new HTML("<strong>Name</strong>"), 100, -1),
            PanelUtils.simplePanel(new HTML(name), 300, -1),
            PanelUtils.simplePanel(new HTML("<strong>Title</strong>"), 100, -1),
            PanelUtils.simplePanel(new HTML(title), 300, -1),
            PanelUtils.simplePanel(new HTML("<strong>Status</strong>"), 100, -1),
            PanelUtils.simplePanel(new HTML(status), 300, -1),
            PanelUtils.simplePanel(new HTML("<strong>Department</strong>"), 100, -1),
            PanelUtils.simplePanel(new HTML(department), 300, -1),
            PanelUtils.simplePanel(new HTML("<strong>Instructors</strong>"), 100, -1),
            PanelUtils.simplePanel(new HTML(instructors), 300, -1),
            PanelUtils.simplePanel(new HTML("<strong>Semester</strong>"), 100, -1),
            PanelUtils.simplePanel(new HTML(semester), 300, -1),
            PanelUtils.simplePanel(new HTML("<strong>Location</strong>"), 100, -1),
            PanelUtils.simplePanel(new HTML(location), 300, -1),
            PanelUtils.simplePanel(new HTML("<strong>Time</strong>"), 100, -1),
            PanelUtils.simplePanel(new HTML(time), 300, -1),
            PanelUtils.simplePanel(new HTML("<strong>Description</strong>"), 100, -1),
            PanelUtils.simplePanel(new HTML(description), 300, -1));

    dialogBox_.setWidget(panel);
}