Java Code Examples for com.google.gwt.dom.client.DivElement#setInnerText()

The following examples show how to use com.google.gwt.dom.client.DivElement#setInnerText() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: InputDatePicker.java    From putnami-web-toolkit with GNU Lesser General Public License v3.0 6 votes vote down vote up
private void redrawMonthPicker() {
	this.monthPicker.getStyle().setWidth(this.calendarTable.getClientWidth(), Unit.PX);
	this.calendarTable.getStyle().setDisplay(Display.NONE);
	this.monthPicker.getStyle().clearDisplay();

	int currentYear = this.cursor.getYear() + InputDatePicker.YEAR_OFFSET;
	if (this.monthPickerInner.getChildCount() == 0) {
		for (int year = currentYear - 100; year < currentYear + 100; year++) {
			DivElement yearDiv = Document.get().createDivElement();
			yearDiv.setInnerText(String.valueOf(year));
			StyleUtils.addStyle(yearDiv, InputDatePicker.STYLE_YEAR_BUTTON);
			Event.sinkEvents(yearDiv, Event.ONCLICK);
			this.monthPickerInner.appendChild(yearDiv);
			yearDiv.setAttribute(InputDatePicker.ATTRIBUTE_DATA_YEAR, String.valueOf(year));
		}
	}
	this.openMonthOfYear(this.cursor.getYear() + InputDatePicker.YEAR_OFFSET);
}
 
Example 2
Source File: TimelineWidget.java    From gantt with Apache License 2.0 6 votes vote down vote up
private void fillDayResolutionBlock(DivElement resBlock, Date date, int index, boolean weekend, int left) {
    resBlock.setInnerText(getLocaleDataProvider().formatDate(date, getDayDateTimeFormat()));

    if (showCurrentTime && getLocaleDataProvider().formatDate(date, DAY_CHECK_FORMAT).equals(currentDate)) {
        resBlock.addClassName(STYLE_NOW);
    } else {
        resBlock.removeClassName(STYLE_NOW);
    }
    if (weekend) {
        resBlock.addClassName(STYLE_WEEKEND);
    } else {
        resBlock.removeClassName(STYLE_WEEKEND);
    }

    if (styleElementForLeft == null && isTimelineOverflowingHorizontally()) {
        resBlock.getStyle().setPosition(Position.RELATIVE);
        resBlock.getStyle().setLeft(left, Unit.PX);
    }
}
 
Example 3
Source File: TimelineWidget.java    From gantt with Apache License 2.0 5 votes vote down vote up
private DivElement createSpacerBlock(String className) {
    DivElement block = DivElement.as(DOM.createDiv());
    block.setClassName(STYLE_ROW + " " + STYLE_YEAR);
    block.addClassName(STYLE_SPACER);
    block.setInnerText(" ");
    block.getStyle().setDisplay(Display.NONE); // not visible by default
    spacerBlocks.add(block);
    return block;
}
 
Example 4
Source File: TimelineWidget.java    From gantt with Apache License 2.0 5 votes vote down vote up
private DivElement createTimelineBlock(String key, String text, String styleSuffix, BlockRowData rowData) {
    DivElement div = DivElement.as(DOM.createDiv());
    div.setClassName(STYLE_ROW + " " + styleSuffix);
    div.setInnerText(text);
    rowData.setBlockLength(key, 1);
    rowData.setBlock(key, div);
    return div;
}
 
Example 5
Source File: TimelineWidget.java    From gantt with Apache License 2.0 5 votes vote down vote up
private void fillWeekResolutionBlock(DivElement resBlock, boolean fillWeekBlock, Date date, int index,
        Weekday weekDay, boolean firstWeek,
        boolean lastBlock, int left, boolean even) {
    if (fillWeekBlock) {
        resBlock.setInnerText(formatWeekCaption(date));

        if (even) {
            resBlock.addClassName(STYLE_EVEN);
        } else {
            resBlock.removeClassName(STYLE_EVEN);
        }

        if (styleElementForLeft == null && isTimelineOverflowingHorizontally()) {
            resBlock.getStyle().setPosition(Position.RELATIVE);
            resBlock.getStyle().setLeft(left, Unit.PX);
        }

        resBlock.removeClassName(STYLE_FIRST);
        resBlock.removeClassName(STYLE_LAST);
    }

    if (firstWeek && (weekDay == Weekday.Last || lastBlock)) {
        Element firstEl = resolutionDiv.getFirstChildElement();
        if (!firstEl.hasClassName(STYLE_FIRST)) {
            firstEl.addClassName(STYLE_FIRST);
        }
    } else if (lastBlock) {
        Element lastEl = Element.as(resolutionDiv.getLastChild());
        if (!lastEl.hasClassName(STYLE_LAST)) {
            lastEl.addClassName(STYLE_LAST);
        }
    }
}
 
Example 6
Source File: TimelineWidget.java    From gantt with Apache License 2.0 5 votes vote down vote up
private void fillHourResolutionBlock(DivElement resBlock, Date date, int index, int hourCounter, boolean lastBlock,
        int left, boolean even) {
    resBlock.setInnerText(formatHourCaption(date));

    if (showCurrentTime
            && getLocaleDataProvider().formatDate(date, HOUR_CHECK_FORMAT).equals(currentDate + currentHour)) {
        resBlock.addClassName(STYLE_NOW);
    } else {
        resBlock.removeClassName(STYLE_NOW);
    }
    if (even) {
        resBlock.addClassName(STYLE_EVEN);
    } else {
        resBlock.removeClassName(STYLE_EVEN);

    }

    if (firstDay && (hourCounter == 24 || lastBlock)) {
        firstDay = false;
        firstResBlockCount = index + 1;
    } else if (lastBlock) {
        lastResBlockCount = (index + 1 - firstResBlockCount) % 24;
    }

    if (styleElementForLeft == null && isTimelineOverflowingHorizontally()) {
        resBlock.getStyle().setPosition(Position.RELATIVE);
        resBlock.getStyle().setLeft(left, Unit.PX);
    }
}
 
Example 7
Source File: TimelineWidget.java    From gantt with Apache License 2.0 5 votes vote down vote up
private int calculateResolutionMinWidth() {

        boolean removeResolutionDiv = false;
        if (!resolutionDiv.hasParentElement()) {
            removeResolutionDiv = true;
            getElement().appendChild(resolutionDiv);
        }
        DivElement resBlockMeasure = DivElement.as(DOM.createDiv());
        if (resolution == Resolution.Week) {
            // configurable with '.col.w.measure' selector
            resBlockMeasure.setClassName(STYLE_COL + " " + STYLE_WEEK + " " + STYLE_MEASURE);
        } else {
            // measure for text 'MM'
            resBlockMeasure.setInnerText("MM");
            // configurable with '.col.measure' selector
            resBlockMeasure.setClassName(STYLE_COL + " " + STYLE_MEASURE);
        }
        resolutionDiv.appendChild(resBlockMeasure);
        int width = resBlockMeasure.getClientWidth();
        if (resolution == Resolution.Week) {
            // divide given width by number of days in week
            width = width / DAYS_IN_WEEK;
        }
        width = (width < resolutionWeekDayblockWidth) ? resolutionWeekDayblockWidth : width;
        resBlockMeasure.removeFromParent();
        if (removeResolutionDiv) {
            resolutionDiv.removeFromParent();
        }
        return width;
    }
 
Example 8
Source File: OverlayExample.java    From gwt-ol with Apache License 2.0 4 votes vote down vote up
@Override
public void show(String exampleId) {

    // create a OSM-layer
    XyzOptions osmSourceOptions = OLFactory.createOptions();

    Osm osmSource = new Osm(osmSourceOptions);
    LayerOptions osmLayerOptions = OLFactory.createOptions();
    osmLayerOptions.setSource(osmSource);

    Tile osmLayer = new Tile(osmLayerOptions);

    // create a view
    View view = new View();

    Coordinate centerCoordinate = OLFactory.createCoordinate(2.3, 51.507222);
    Coordinate transformedCenterCoordinate = Projection.transform(centerCoordinate, DemoConstants.EPSG_4326, DemoConstants.EPSG_3857);

    view.setCenter(transformedCenterCoordinate);
    view.setZoom(10);

    // create the map
    MapOptions mapOptions = OLFactory.createOptions();
    mapOptions.setTarget(exampleId);
    mapOptions.setView(view);

    Map map = new Map(mapOptions);

    map.addLayer(osmLayer);

    // add some controls
    map.addControl(OLFactory.createScaleLine());
    DemoUtils.addDefaultControls(map.getControls());

    Attribution attribution = new Attribution();
    attribution.setCollapsed(true);

    map.addControl(attribution);

    // add some interactions
    map.addInteraction(OLFactory.createKeyboardPan());
    map.addInteraction(OLFactory.createKeyboardZoom());

    DivElement overlay = Document.get().createDivElement();
    overlay.setClassName("overlay-font");
    overlay.setInnerText("Created with GWT SDK " + GWT.getVersion());

    OverlayOptions overlayOptions = OLFactory.createOptions();
    overlayOptions.setElement(overlay);
    overlayOptions.setPosition(transformedCenterCoordinate);
    overlayOptions.setOffset(OLFactory.createPixel(-300, 0));

    map.addOverlay(new Overlay(overlayOptions));

}
 
Example 9
Source File: InputDatePicker.java    From putnami-web-toolkit with GNU Lesser General Public License v3.0 4 votes vote down vote up
private void redrawCalendarPicker() {
	this.monthPicker.getStyle().setDisplay(Display.NONE);
	this.calendarTable.getStyle().clearDisplay();

	this.calendatBody.removeAllChildren();

	int firstDayOfWeek = InputDatePicker.DATE_TIME_FORMAT_INFO.firstDayOfTheWeek();
	int lastDayOfWeek = (firstDayOfWeek + InputDatePicker.DAYS_IN_WEEK) % InputDatePicker.DAYS_IN_WEEK;

	/* Display month */
	this.monthPickerButton.setInnerHTML(InputDatePicker.MONTH_YEAR_FORMAT.format(this.cursor)
		+ "<span class=\"caret\"></span>");

	Date lastMonth = new Date(this.cursor.getTime());
	CalendarUtil.addMonthsToDate(lastMonth, -1);
	this.pagePreviusMonthLi.setAttribute(InputDatePicker.ATTRIBUTE_DATA_CURSOR, InputDatePicker.ATTRIBUTE_DATE_FORMAT
		.format(lastMonth));
	this.pageTodayLi.setAttribute(InputDatePicker.ATTRIBUTE_DATA_CURSOR, InputDatePicker.ATTRIBUTE_DATE_FORMAT
		.format(this.today));
	Date nextMonth = new Date(this.cursor.getTime());
	CalendarUtil.addMonthsToDate(nextMonth, 1);
	this.pageNextMonthLi.setAttribute(InputDatePicker.ATTRIBUTE_DATA_CURSOR, InputDatePicker.ATTRIBUTE_DATE_FORMAT
		.format(nextMonth));

	/* Draw daypicker */
	Date dateToDrow = new Date(this.cursor.getTime());
	int selectedMonth = dateToDrow.getMonth();
	int firstMonthToDisplay = (selectedMonth + 11) % 12;
	int lastMonthToDisplay = (selectedMonth + 13) % 12;
	do {
		CalendarUtil.addDaysToDate(dateToDrow, -1);
	} while (firstMonthToDisplay != dateToDrow.getMonth() || dateToDrow.getDay() != firstDayOfWeek);

	// drow calendarTable
	TableRowElement headRow = null;
	while (dateToDrow.getMonth() != lastMonthToDisplay || dateToDrow.getDay() != lastDayOfWeek
		|| dateToDrow.getDate() == 1 && dateToDrow.getDay() == firstDayOfWeek) {
		if (headRow == null || dateToDrow.getDay() == firstDayOfWeek) {
			headRow = Document.get().createTRElement();
			this.calendatBody.appendChild(headRow);
		}
		TableCellElement td = Document.get().createTDElement();
		headRow.appendChild(td);
		DivElement div = Document.get().createDivElement();
		td.appendChild(div);
		div.setInnerText(String.valueOf(dateToDrow.getDate()));
		div.setAttribute(InputDatePicker.ATTRIBUTE_DATA_DATE, InputDatePicker.ATTRIBUTE_DATE_FORMAT.format(dateToDrow));
		if (dateToDrow.getMonth() != selectedMonth) {
			StyleUtils.addStyle(td, InputDatePicker.STYLE_MUTED);
		}
		if (dateToDrow.equals(this.cursor)) {
			StyleUtils.addStyle(td, InputDatePicker.STYLE_SELECTED);
		}
		if (this.today.equals(dateToDrow)) {
			StyleUtils.addStyle(td, InputDatePicker.STYLE_TODAY);
		}
		Event.sinkEvents(div, Event.ONCLICK);

		CalendarUtil.addDaysToDate(dateToDrow, 1);
	}
}
 
Example 10
Source File: Popover.java    From putnami-web-toolkit with GNU Lesser General Public License v3.0 4 votes vote down vote up
public void setContent(String content) {
	DivElement contentElement = Document.get().createDivElement();
	this.container.appendChild(contentElement);
	StyleUtils.addStyle(contentElement, Popover.STYLE_INNER);
	contentElement.setInnerText(content);
}