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

The following examples show how to use com.google.gwt.dom.client.DivElement#addClassName() . 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: DomLogger.java    From swellrt with Apache License 2.0 6 votes vote down vote up
/**
 * Appends an entry to the log panel.
 * @param formatted
 * @param level
 */
public static void appendEntry(String formatted, Level level) {
  DivElement entry = Document.get().createDivElement();
  entry.setClassName(RESOURCES.css().entry());
  entry.setInnerHTML(formatted);

  // Add the style name associated with the log level.
  switch (level) {
    case ERROR:
      entry.addClassName(RESOURCES.css().error());
      break;
    case FATAL:
      entry.addClassName(RESOURCES.css().fatal());
      break;
    case TRACE:
      entry.addClassName(RESOURCES.css().trace());
      break;
  }

  // Make fatals detectable by WebDriver, so that tests can early out on
  // failure:
  if (level.equals(Level.FATAL)) {
    latestFatalError = formatted;
  }
  writeOrCacheOutput(entry);
}
 
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: DomLogger.java    From incubator-retired-wave with Apache License 2.0 6 votes vote down vote up
/**
 * Appends an entry to the log panel.
 * @param formatted
 * @param level
 */
public static void appendEntry(String formatted, Level level) {
  DivElement entry = Document.get().createDivElement();
  entry.setClassName(RESOURCES.css().entry());
  entry.setInnerHTML(formatted);

  // Add the style name associated with the log level.
  switch (level) {
    case ERROR:
      entry.addClassName(RESOURCES.css().error());
      break;
    case FATAL:
      entry.addClassName(RESOURCES.css().fatal());
      break;
    case TRACE:
      entry.addClassName(RESOURCES.css().trace());
      break;
  }

  // Make fatals detectable by WebDriver, so that tests can early out on
  // failure:
  if (level.equals(Level.FATAL)) {
    latestFatalError = formatted;
  }
  writeOrCacheOutput(entry);
}
 
Example 4
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 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 4 votes vote down vote up
private DivElement createHourResolutionBlock() {
    DivElement resBlock = createResolutionBlock();
    resBlock.addClassName("h");
    resBlock.addClassName(STYLE_CENTER);
    return resBlock;
}
 
Example 8
Source File: TimelineWidget.java    From gantt with Apache License 2.0 4 votes vote down vote up
private DivElement createDayResolutionBlock() {
    DivElement resBlock = createResolutionBlock();
    resBlock.addClassName(STYLE_CENTER);
    return resBlock;
}
 
Example 9
Source File: TimelineWidget.java    From gantt with Apache License 2.0 4 votes vote down vote up
private DivElement createWeekResolutionBlock() {
    DivElement resBlock = createResolutionBlock();
    resBlock.addClassName("w");
    resBlock.addClassName(STYLE_CENTER);
    return resBlock;
}