com.google.gwt.dom.client.DivElement Java Examples

The following examples show how to use com.google.gwt.dom.client.DivElement. 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 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 #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 6 votes vote down vote up
private void updateSpacerBlocks(double dayWidthPx) {
    double spaceLeft = getResolutionDivWidth() - (blocksInRange * dayWidthPx);
    if (spaceLeft > 0) {
        for (DivElement e : spacerBlocks) {
            e.getStyle().clearDisplay();
            e.getStyle().setWidth(spaceLeft, Unit.PX);
        }

        resSpacerDiv = createResolutionBlock();
        resSpacerDiv.addClassName(STYLE_SPACER);
        resSpacerDiv.getStyle().setWidth(spaceLeft, Unit.PX);
        resSpacerDiv.setInnerText(" ");
        resolutionDiv.appendChild(resSpacerDiv);
    } else {
        hideSpacerBlocks();
    }
}
 
Example #4
Source File: CajolerFacade.java    From incubator-retired-wave with Apache License 2.0 6 votes vote down vote up
private void appendToDocument(HTML target, PluginContext pluginContext, CajolerResponse response) {
  DivElement domitaVdocElement = Document.get().createDivElement();
  domitaVdocElement.setClassName("innerHull");

  target.getElement().setInnerHTML("");
  target.getElement().setClassName("outerHull");
  target.getElement().appendChild(domitaVdocElement);

  initializeDoodadEnvironment(
      cajaFrame, domitaVdocElement, pluginContext.getJSOInterface());

  // Render HTML
  domitaVdocElement.setInnerHTML(response.getHtml());

  // Inject JS
  Document cajaFrameDoc = cajaFrame.getContentDocument();
  cajaFrameDoc.getBody().appendChild(cajaFrameDoc.createScriptElement(response.getJs()));
}
 
Example #5
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 #6
Source File: TimelineWidget.java    From gantt with Apache License 2.0 6 votes vote down vote up
private Element getLastResolutionElement() {
    DivElement div = getResolutionDiv();
    if (div == null) {
        return null;
    }
    NodeList<Node> nodeList = div.getChildNodes();
    if (nodeList == null) {
        return null;
    }
    int blockCount = nodeList.getLength();
    if (blockCount < 1) {
        return null;
    }
    if (containsResBlockSpacer()) {
        int index = blockCount - 2;
        if (blockCount > 1 && index >= 0) {
            return Element.as(getResolutionDiv().getChild(index));
        }
        return null;
    }
    return Element.as(getResolutionDiv().getLastChild());
}
 
Example #7
Source File: PerspectivesExplorerView.java    From dashbuilder with Apache License 2.0 6 votes vote down vote up
@Override
public void addPerspective(String name, Command onClicked) {
    AnchorElement anchor = Document.get().createAnchorElement();
    anchor.getStyle().setCursor(Style.Cursor.POINTER);
    anchor.getStyle().setColor("black");
    anchor.getStyle().setProperty("fontSize", "larger");
    anchor.setInnerText(name);

    Event.sinkEvents(anchor, Event.ONCLICK);
    Event.setEventListener(anchor, event -> {
        if(Event.ONCLICK == event.getTypeInt()) {
            onClicked.execute();
        }
    });

    SpanElement icon = Document.get().createSpanElement();
    icon.getStyle().setMarginRight(10, Style.Unit.PX);
    icon.setClassName("pficon-virtual-machine");
    icon.getStyle().setProperty("fontSize", "larger");

    DivElement gi = createItemDiv(new Element[] {icon, anchor});
    perspectivesDiv.appendChild((Node) gi);
}
 
Example #8
Source File: Carousel.java    From putnami-web-toolkit with GNU Lesser General Public License v3.0 6 votes vote down vote up
public Carousel() {
	super(DivElement.TAG);
	this.append(this.carouselIndicators);
	this.append(this.carouselInner);
	this.append(this.leftButton);
	this.append(this.rightButton);
	StyleUtils.addStyle(this, Carousel.STYLE_CAROUSEL);
	StyleUtils.addStyle(this.carouselInner, Carousel.STYLE_CAROUSEL_INNER);
	StyleUtils.addStyle(this.carouselIndicators, Carousel.STYLE_CAROUSEL_INDICATORS);
	StyleUtils.addStyle(this.leftButton, Carousel.STYLE_CAROUSEL_CONTROL);
	StyleUtils.addStyle(this.leftButton, LeftRightType.LEFT);
	StyleUtils.addStyle(this.rightButton, Carousel.STYLE_CAROUSEL_CONTROL);
	StyleUtils.addStyle(this.rightButton, LeftRightType.RIGHT);
	this.leftButton.addClickHandler(this);
	this.rightButton.addClickHandler(this);
	this.leftButton.getElement().setInnerHTML("<i class=\"icon-prev\"/>");
	this.rightButton.getElement().setInnerHTML("<i class=\"icon-next\"/>");
}
 
Example #9
Source File: GanttWidget.java    From gantt with Apache License 2.0 6 votes vote down vote up
/**
 * Add new StepWidget into content area.
 *
 * @param stepIndex
 *            Index of step (0 based) (not element index in container)
 * @param widget
 * @param updateAffectedSteps
 *            Updates position of affected steps. Usually it means steps
 *            below the target.
 */
public void addStep(int stepIndex, StepWidget stepWidget, boolean updateAffectedSteps) {
    DivElement bar = DivElement.as(stepWidget.getElement());

    boolean newStep = !bar.hasParentElement();
    boolean moving = !newStep && getStepIndex(stepWidget) != stepIndex;
    boolean insertDOM = newStep || moving;

    if (insertDOM) {
        insert(stepIndex + getAdditonalContentElementCount(), stepWidget);
    }

    deferredUpdateStepTop(stepIndex, updateAffectedSteps, bar, insertDOM);

    if (newStep) {
        registerBarEventListener(bar);
    }
}
 
Example #10
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 #11
Source File: CajolerFacade.java    From swellrt with Apache License 2.0 6 votes vote down vote up
private void appendToDocument(HTML target, PluginContext pluginContext, CajolerResponse response) {
  DivElement domitaVdocElement = Document.get().createDivElement();
  domitaVdocElement.setClassName("innerHull");

  target.getElement().setInnerHTML("");
  target.getElement().setClassName("outerHull");
  target.getElement().appendChild(domitaVdocElement);

  initializeDoodadEnvironment(
      cajaFrame, domitaVdocElement, pluginContext.getJSOInterface());

  // Render HTML
  domitaVdocElement.setInnerHTML(response.getHtml());

  // Inject JS
  Document cajaFrameDoc = cajaFrame.getContentDocument();
  cajaFrameDoc.getBody().appendChild(cajaFrameDoc.createScriptElement(response.getJs()));
}
 
Example #12
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 #13
Source File: PerspectivesExplorerView.java    From dashbuilder with Apache License 2.0 5 votes vote down vote up
@Override
public void showEmpty(String message) {
    SpanElement span = Document.get().createSpanElement();
    span.setInnerText(message);
    DivElement gi = createItemDiv(new Element[] {span});
    perspectivesDiv.appendChild((Node) gi);
}
 
Example #14
Source File: NavTreeWidgetView.java    From dashbuilder with Apache License 2.0 5 votes vote down vote up
protected void addItem(String iconClass, String id, String name, String description, Command onClicked) {
    Element nameEl = onClicked != null ? Document.get().createAnchorElement() : Document.get().createSpanElement();
    nameEl.setInnerText(name);
    nameEl.setClassName(onClicked != null ? "uf-navtree-widget-non-clicked" : "uf-navtree-widget-non-clickable");
    if (description != null && !description.equals(name)) {
        nameEl.setTitle(description);
    }

    SpanElement iconSpan = Document.get().createSpanElement();
    iconSpan.setClassName("uf-navtree-widget-icon " + iconClass);

    DivElement div = Document.get().createDivElement();
    div.appendChild(iconSpan);
    div.appendChild(nameEl);

    navWidget.appendChild((Node) div);
    itemMap.put(id, nameEl);

    if (onClicked != null) {
        Event.sinkEvents(nameEl, Event.ONCLICK);
        Event.setEventListener(nameEl, event -> {
            if (Event.ONCLICK == event.getTypeInt()) {
                onClicked.execute();
            }
        });
    }
}
 
Example #15
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 #16
Source File: TimelineWidget.java    From gantt with Apache License 2.0 5 votes vote down vote up
private void createTimelineElementsOnVisibleArea() {
    // create place holder elements that represents weeks/days/hours
    // depending on the resolution in the timeline.
    // Only visible blocks are created, and only once, content will change
    // on scroll.

    // first: detect how many blocks we can fit in the screen
    int blocks = resolutionBlockCount;
    if (isTimelineOverflowingHorizontally()) {
        blocks = (int) (GanttUtil.getBoundingClientRectWidth(getElement().getParentElement())
                / calculateMinimumResolutionBlockWidth());
        if (resolutionBlockCount < blocks) {
            // blocks need to be scaled up to fit the screen
            blocks = resolutionBlockCount;
        } else {
            blocks += 2;
        }
    }

    DivElement element = null;
    for (int i = 0; i < blocks; i++) {
        switch (resolution) {
        case Hour:
            element = createHourResolutionBlock();
            break;
        case Day:
            element = createDayResolutionBlock();
            break;
        case Week:
            element = createWeekResolutionBlock();
            break;
        }
        resolutionDiv.appendChild(element);
    }

    GWT.log(getClass().getSimpleName() + " Added " + blocks + " visible timeline elements for resolution ."
            + String.valueOf(resolution));
}
 
Example #17
Source File: Tooltip.java    From putnami-web-toolkit with GNU Lesser General Public License v3.0 5 votes vote down vote up
public TooltipWidget() {
	this.container = Document.get().createDivElement();
	StyleUtils.addStyle(this.container, Tooltip.STYLE_TOOLTIP);
	StyleUtils.addStyle(this.container, Tooltip.STYLE_FADE);

	DivElement arrow = Document.get().createDivElement();
	StyleUtils.addStyle(arrow, Tooltip.STYLE_ARROW);
	this.container.appendChild(arrow);

	this.inner = Document.get().createDivElement();
	StyleUtils.addStyle(this.inner, Tooltip.STYLE_INNER);
	this.container.appendChild(this.inner);

	this.setElement(this.container);
}
 
Example #18
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 #19
Source File: PerspectivesExplorerView.java    From dashbuilder with Apache License 2.0 5 votes vote down vote up
private DivElement createItemDiv(Element[] items) {
    DivElement mi = Document.get().createDivElement();
    mi.setClassName("list-view-pf-main-info");
    mi.getStyle().setPaddingTop(5, Style.Unit.PX);
    mi.getStyle().setPaddingBottom(5, Style.Unit.PX);
    for (Element item : items) {
        mi.appendChild(item);
    }

    DivElement gi = Document.get().createDivElement();
    gi.setClassName("list-group-item");
    gi.appendChild(mi);
    return gi;
}
 
Example #20
Source File: GwtMockitoTest.java    From gwtmockito with Apache License 2.0 5 votes vote down vote up
@Test
@SuppressWarnings("unused")
public void shouldAllowOnlyJavascriptCastsThatAreValidJavaCasts() {
  // Casts to ancestors should be legal
  JavaScriptObject o = Document.get().createDivElement().cast();
  Node n = Document.get().createDivElement().cast();
  DivElement d = Document.get().createDivElement().cast();

  // Casts to sibling elements shouldn't be legal (even though they are in javascript)
  try {
    IFrameElement i = Document.get().createDivElement().cast();
    fail("Exception not thrown");
  } catch (ClassCastException expected) {}
}
 
Example #21
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 #22
Source File: Table.java    From putnami-web-toolkit with GNU Lesser General Public License v3.0 5 votes vote down vote up
public Table() {
	super(DivElement.TAG);

	this.endConstruct();

	this.setStriped(this.striped);
	this.setHover(this.hover);
	this.setCondensed(this.condensed);
}
 
Example #23
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 #24
Source File: AbstractStepWidget.java    From gantt with Apache License 2.0 5 votes vote down vote up
public AbstractStepWidget() {
    DivElement bar = DivElement.as(DOM.createDiv());
    bar.setClassName(STYLE_BAR);
    setElement(bar);

    caption = DivElement.as(DOM.createDiv());
    caption.setClassName(STYLE_BAR_LABEL);
    bar.appendChild(caption);

    // hide by default
    bar.getStyle().setVisibility(Visibility.HIDDEN);
}
 
Example #25
Source File: MockForm.java    From appinventor-extensions with Apache License 2.0 5 votes vote down vote up
private static int getVerticalScrollbarWidth() {
  // We only calculate the vertical scroll bar width once, then we store it in the static field
  // verticalScrollbarWidth. If the field is non-zero, we don't need to calculate it again.
  if (verticalScrollbarWidth == 0) {
    // The following code will calculate (on the fly) the width of a vertical scroll bar.
    // We'll create two divs, one inside the other and add the outer div to the document body,
    // but off-screen where the user won't see it.
    // We'll measure the width of the inner div twice: (first) when the outer div's vertical
    // scrollbar is hidden and (second) when the outer div's vertical scrollbar is visible.
    // The width of inner div will be smaller when outer div's vertical scrollbar is visible.
    // By subtracting the two measurements, we can calculate the width of the vertical scrollbar.

    // I used code from the following websites as reference material:
    // http://jdsharp.us/jQuery/minute/calculate-scrollbar-width.php
    // http://www.fleegix.org/articles/2006-05-30-getting-the-scrollbar-width-in-pixels

    Document document = Document.get();

    // Create an outer div.
    DivElement outerDiv = document.createDivElement();
    Style outerDivStyle = outerDiv.getStyle();
    // Use absolute positioning and set the top/left so that it is off-screen.
    // We don't want the user to see anything while we do this calculation.
    outerDivStyle.setProperty("position", "absolute");
    outerDivStyle.setProperty("top", "-1000px");
    outerDivStyle.setProperty("left", "-1000px");
    // Set the width and height of the outer div to a fixed size in pixels.
    outerDivStyle.setProperty("width", "100px");
    outerDivStyle.setProperty("height", "50px");
    // Hide the outer div's scrollbar by setting the "overflow" property to "hidden".
    outerDivStyle.setProperty("overflow", "hidden");

    // Create an inner div and put it inside the outer div.
    DivElement innerDiv = document.createDivElement();
    Style innerDivStyle = innerDiv.getStyle();
    // Set the height of the inner div to be 4 times the height of the outer div so that a
    // vertical scrollbar will be necessary (but hidden for now) on the outer div.
    innerDivStyle.setProperty("height", "200px");
    outerDiv.appendChild(innerDiv);

    // Temporarily add the outer div to the document body. It's off-screen so the user won't
    // actually see anything.
    Element bodyElement = document.getElementsByTagName("body").getItem(0);
    bodyElement.appendChild(outerDiv);

    // Get the width of the inner div while the outer div's vertical scrollbar is hidden.
    int widthWithoutScrollbar = innerDiv.getOffsetWidth();
    // Show the outer div's vertical scrollbar by setting the "overflow" property to "auto".
    outerDivStyle.setProperty("overflow", "auto");
    // Now, get the width of the inner div while the vertical scrollbar is visible.
    int widthWithScrollbar = innerDiv.getOffsetWidth();

    // Remove the outer div from the document body.
    bodyElement.removeChild(outerDiv);

    // Calculate the width of the vertical scrollbar by subtracting the two widths.
    verticalScrollbarWidth = widthWithoutScrollbar - widthWithScrollbar;
  }

  return verticalScrollbarWidth;
}
 
Example #26
Source File: GanttWidget.java    From gantt with Apache License 2.0 5 votes vote down vote up
private void updateStepTop(int stepIndex, boolean updateAffectedSteps, DivElement bar, boolean insertDOM) {
    // Update top
    int stepsInContainer = getChildren().size() - getAdditionalWidgetContentElementCount();
    int indexInWidgetContainer = stepIndex + getAdditionalWidgetContentElementCount();
    // bar height should be defined in css
    int height = getElementHeightWithMargin(bar);

    if (stepIndex == 0) {
        bar.getStyle().setTop(0, Unit.PX);
        if (updateAffectedSteps) {
            updateTopForAllStepsBelow(indexInWidgetContainer + 1, height);
        }
    } else if (stepIndex < stepsInContainer) {
        // update top by the previous step top + step height.
        // Requires that previous steps top is already correct.
        int prevWidgetIndex = indexInWidgetContainer - 1;
        Widget w = getWidget(prevWidgetIndex);
        if (w instanceof StepWidget) {
            double top = parseSize(w.getElement().getStyle().getTop(), "px");
            top += getElementHeightWithMargin(w.getElement());
            bar.getStyle().setTop(top, Unit.PX);

            if (updateAffectedSteps) {
                updateTopForAllStepsBelow(indexInWidgetContainer + 1, height);
            }
        }
    }

    if (insertDOM) {
        contentHeight += height;
    }
}
 
Example #27
Source File: GanttWidget.java    From gantt with Apache License 2.0 5 votes vote down vote up
private void deferredUpdateStepTop(int stepIndex, boolean updateAffectedSteps, DivElement bar, boolean insertDOM) {
    Scheduler.get().scheduleDeferred(new ScheduledCommand() {
        @Override
        public void execute() {
            updateStepTop(stepIndex, updateAffectedSteps, bar, insertDOM);
        }
    });
}
 
Example #28
Source File: Modal.java    From putnami-web-toolkit with GNU Lesser General Public License v3.0 5 votes vote down vote up
public Modal() {
	super(DivElement.TAG);

	StyleUtils.addStyle(this, Modal.STYLE_MODAL);
	StyleUtils.addStyle(this, Modal.STYLE_FADE);

	this.append(this.dialogContainer);
	this.dialogContainer.append(this.contentContainer);

	StyleUtils.addStyle(this.dialogContainer, Modal.STYLE_DIALOG);
	StyleUtils.addStyle(this.contentContainer, Modal.STYLE_CONTENT);
	StyleUtils.addStyle(this.bodyContainer, Modal.STYLE_BODY);
}
 
Example #29
Source File: Alert.java    From putnami-web-toolkit with GNU Lesser General Public License v3.0 5 votes vote down vote up
public Alert(String html) {
	super(DivElement.TAG, html);
	StyleUtils.addStyle(this, Alert.STYLE_ALERT);
	StyleUtils.addStyle(this, Alert.STYLE_FADE);
	StyleUtils.addStyle(this, Alert.STYLE_VISIBLE);
	this.setType(Type.INFO);
}
 
Example #30
Source File: GanttWidget.java    From gantt with Apache License 2.0 5 votes vote down vote up
public GanttWidget() {

        setElement(DivElement.as(DOM.createDiv()));
        setStyleName(STYLE_GANTT);

        nowElement.setClassName(STYLE_NOW_ELEMENT);

        moveElement.setClassName(STYLE_MOVE_ELEMENT);
        // not visible by default
        moveElement.getStyle().setDisplay(Display.NONE);

        timeline = GWT.create(TimelineWidget.class);

        container = DivElement.as(DOM.createDiv());
        container.setClassName(STYLE_GANTT_CONTAINER);

        content = DivElement.as(DOM.createDiv());
        content.setClassName(STYLE_GANTT_CONTENT);
        container.appendChild(content);

        content.appendChild(moveElement);
        content.appendChild(nowElement);

        scrollbarSpacer = DivElement.as(DOM.createDiv());
        scrollbarSpacer.getStyle().setHeight(AbstractNativeScrollbar.getNativeScrollbarHeight(), Unit.PX);
        scrollbarSpacer.getStyle().setDisplay(Display.NONE);

        getElement().appendChild(timeline.getElement());
        getElement().appendChild(container);
        getElement().appendChild(scrollbarSpacer);
    }