Java Code Examples for com.google.gwt.dom.client.Style.setProperty()

The following are Jave code examples for showing how to use setProperty() of the com.google.gwt.dom.client.Style class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: document-management-system   File: KeywordsPopup.java   View Source Code Vote up 6 votes
/**
 * Draws a tag cloud
 */
private void drawTagCloud(Collection<String> keywords) {
	// Deletes all tag clouds keys
	keywordsCloud.clear();
	keywordsCloud.setMinFrequency(Main.get().mainPanel.dashboard.keyMapDashboard.getTotalMinFrequency());
	keywordsCloud.setMaxFrequency(Main.get().mainPanel.dashboard.keyMapDashboard.getTotalMaxFrequency());

	for (Iterator<String> it = keywords.iterator(); it.hasNext(); ) {
		String keyword = it.next();
		HTML tagKey = new HTML(keyword);
		tagKey.setStyleName("okm-cloudTags");
		Style linkStyle = tagKey.getElement().getStyle();
		int fontSize = keywordsCloud.getLabelSize(Main.get().mainPanel.dashboard.keyMapDashboard
				.getKeywordRate(keyword));
		linkStyle.setProperty("fontSize", fontSize + "pt");
		linkStyle.setProperty("color", keywordsCloud.getColor(fontSize));
		if (fontSize > 0) {
			linkStyle.setProperty("top", (keywordsCloud.getMaxFontSize() - fontSize) / 2 + "px");
		}
		keywordsCloud.add(tagKey);
	}
}
 
Example 2
Project: document-management-system   File: KeywordsWidget.java   View Source Code Vote up 6 votes
/**
 * Draws a tag cloud
 */
private void drawTagCloud(Collection<String> keywords) {
	// Deletes all tag clouds keys
	keywordsCloud.clear();
	keywordsCloud.setMinFrequency(Main.get().mainPanel.dashboard.keyMapDashboard.getTotalMinFrequency());
	keywordsCloud.setMaxFrequency(Main.get().mainPanel.dashboard.keyMapDashboard.getTotalMaxFrequency());

	for (Iterator<String> it = keywords.iterator(); it.hasNext(); ) {
		String keyword = it.next();
		HTML tagKey = new HTML(keyword);
		tagKey.setStyleName("okm-cloudTags");
		Style linkStyle = tagKey.getElement().getStyle();
		int fontSize = keywordsCloud.getLabelSize(Main.get().mainPanel.dashboard.keyMapDashboard.getKeywordRate(keyword));
		linkStyle.setProperty("fontSize", fontSize + "pt");
		linkStyle.setProperty("color", keywordsCloud.getColor(fontSize));
		if (fontSize > 0) {
			linkStyle.setProperty("top", (keywordsCloud.getMaxFontSize() - fontSize) / 2 + "px");
		}
		keywordsCloud.add(tagKey);
	}
}
 
Example 3
Project: document-management-system   File: WidgetUtil.java   View Source Code Vote up 6 votes
/**
 * Draws a tag cloud
 */
public static void drawTagCloud(final TagCloud keywordsCloud, Collection<String> keywords) {
	// Deletes all tag clouds keys
	keywordsCloud.clear();
	keywordsCloud.setMinFrequency(Main.get().mainPanel.dashboard.keyMapDashboard.getTotalMinFrequency());
	keywordsCloud.setMaxFrequency(Main.get().mainPanel.dashboard.keyMapDashboard.getTotalMaxFrequency());

	for (Iterator<String> it = keywords.iterator(); it.hasNext(); ) {
		String keyword = it.next();
		HTML tagKey = new HTML(keyword);
		tagKey.setStyleName("okm-cloudTags");
		Style linkStyle = tagKey.getElement().getStyle();
		int fontSize = keywordsCloud.getLabelSize(Main.get().mainPanel.dashboard.keyMapDashboard.getKeywordRate(keyword));
		linkStyle.setProperty("fontSize", fontSize + "pt");
		linkStyle.setProperty("color", keywordsCloud.getColor(fontSize));
		if (fontSize > 0) {
			linkStyle.setProperty("top", (keywordsCloud.getMaxFontSize() - fontSize) / 2 + "px");
		}
		keywordsCloud.add(tagKey);
	}
}
 
Example 4
Project: cuba   File: TableWidgetDelegate.java   View Source Code Vote up 6 votes
public void reassignHeaderCellWidth(int colIndex, VScrollTable.HeaderCell hcell, int minWidth) {
    if (tableWidget.isCustomColumn(colIndex)) {
        return;
    }

    for (Widget rowWidget : (tableWidget).getRenderedRows()) {
        if (tableWidget.isGenericRow(rowWidget)) {
            VScrollTable.VScrollTableBody.VScrollTableRow row = (VScrollTable.VScrollTableBody.VScrollTableRow) rowWidget;

            double realColWidth = row.getRealCellWidth(colIndex);
            if (realColWidth > 0) {
                if (realColWidth > minWidth) {
                    Style hStyle = hcell.getElement().getStyle();

                    hStyle.setProperty("width", realColWidth + "px");
                    hStyle.setProperty("minWidth", realColWidth + "px");
                    hStyle.setProperty("maxWidth", realColWidth + "px");
                }

                break;
            }
        }
    }
}
 
Example 5
Project: appformer   File: BaseDOMElement.java   View Source Code Vote up 6 votes
/**
 * Attach the DOMElement to the GWT container, if not already attached.
 */
public void attach() {
    final Iterator<Widget> itr = domElementContainer.iterator();
    while (itr.hasNext()) {
        if (itr.next().equals(widgetContainer)) {
            return;
        }
    }
    //When an Element is detached it's Position configuration is cleared, so reset it
    final Style style = widgetContainer.getElement().getStyle();
    style.setPosition(Style.Position.ABSOLUTE);
    style.setProperty("WebkitUserSelect",
                      "none");
    style.setProperty("MozUserSelect",
                      "none");
    style.setProperty("MsUserSelect",
                      "none");

    domElementContainer.add(widgetContainer);
}
 
Example 6
Project: appformer   File: WorkbenchLayoutImpl.java   View Source Code Vote up 6 votes
/**
 * Restores to {@code w} all style values to those most recently set on this instance.
 * @param w the widget to restore styles on.
 */
public void restore(final Widget w) {
    final Style style = w.getElement().getStyle();
    style.setProperty("position",
                      position);
    style.setProperty("top",
                      top);
    style.setProperty("left",
                      left);
    style.setProperty("width",
                      width);
    style.setProperty("height",
                      height);
    style.setProperty("zIndex",
                      zIndex);
}
 
Example 7
Project: empiria.player   File: TutorViewImpl.java   View Source Code Vote up 5 votes
@Override
public void setBackgroundImage(String src, Size size) {
    Style style = content.getElement().getStyle();
    String srcWithUrlInside = "url(" + src + ")";
    style.setBackgroundImage(srcWithUrlInside);
    style.setProperty("backgroundPosition", 0 + DIMENSIONS_UNIT);

    setSizeOfContent(size);
}
 
Example 8
Project: empiria.player   File: MediaProgressBarImpl.java   View Source Code Vote up 5 votes
private void setAfterButtonPositionAndStyle(final int leftOffsetForProgressButton) {
    Style afterButtonStyle = afterButton.getElement().getStyle();

    double percentWidth = positionCalculator.getPercentWidth(leftOffsetForProgressButton);
    afterButtonStyle.setWidth(100 - percentWidth, Unit.PCT);

    afterButtonStyle.setProperty(positionCalculator.getPositionPropertyForAfterProgressElement(), "0px");
}
 
Example 9
Project: empiria.player   File: MediaProgressBarImpl.java   View Source Code Vote up 5 votes
private void setBeforeButtonPositionAndStyle(final int leftOffsetForProgressButton) {
    Style beforeButtonStyle = beforeButton.getElement().getStyle();

    double percentWidth = positionCalculator.getPercentWidth(leftOffsetForProgressButton);
    beforeButtonStyle.setWidth(percentWidth, Unit.PCT);

    beforeButtonStyle.setProperty(positionCalculator.getPositionPropertyForBeforeProgressElement(), "0px");
}
 
Example 10
Project: Wiab.pro   File: FullStructure.java   View Source Code Vote up 5 votes
private static void kickWebkit(Element element) {
  if (UserAgent.isWebkit()) {

    Style style = element.getStyle();
    String oldDisplay = style.getDisplay();

    // Erase layout. Querying getOffsetParent() forces layout.
    style.setDisplay(Display.NONE);
    element.getOffsetParent();

    // Restore layout.
    style.setProperty("display", oldDisplay);
  }
}
 
Example 11
Project: forplay   File: HtmlImageLayerDom.java   View Source Code Vote up 5 votes
private void applyBackgroundSize() {
  Style style = element().getStyle();

  // Set background-repeat to get the right repeating behavior.
  String repeat = repeatX ? "repeat-x " : "";
  repeat += repeatY ? "repeat-y" : "";
  style.setProperty("backgroundRepeat", repeat);

  // Set background-size to get the right pinning behavior.
  if (sourceRectSet) {
    float wratio = widthSet ? (width / sw) : (image().width() / sw);
    float hratio = heightSet ? (height / sh) : (image().height() / sh);
    if (wratio == 0) {
      wratio = 1;
    }
    if (hratio == 0) {
      hratio = 1;
    }
    float backWidth = image().width() * wratio;
    float backHeight = image().height() * hratio;

    style.setProperty("backgroundSize", backWidth + "px " + backHeight + "px");
    style.setProperty("backgroundPosition", (-sx * wratio) + "px " + (-sy * hratio) + "px");
  } else {
    String size = repeatX ? image().width() + "px " : "100% ";
    size += repeatY ? image().height() + "px" : "100%";
    style.setProperty("backgroundSize", size);
    style.clearProperty("backgroundPosition");
  }
}
 
Example 12
Project: che   File: QuickDocViewImpl.java   View Source Code Vote up 5 votes
@Inject
public QuickDocViewImpl() {
  super(true, true);
  addCloseHandler(
      new CloseHandler<PopupPanel>() {
        @Override
        public void onClose(CloseEvent<PopupPanel> event) {
          if (delegate != null) {
            delegate.onCloseView();
          }
        }
      });

  setSize("400px", "200px");
  Style style = getElement().getStyle();
  style.setProperty("resize", "both");
  style.setPaddingBottom(0, Style.Unit.PX);
  style.setPaddingTop(3, Style.Unit.PX);
  style.setPaddingLeft(3, Style.Unit.PX);
  style.setPaddingRight(3, Style.Unit.PX);
  createFrame();
  add(frame);
}
 
Example 13
Project: appformer   File: TextBoxDOMElement.java   View Source Code Vote up 5 votes
public TextBoxDOMElement(final TextBox widget,
                         final GridLayer gridLayer,
                         final GridWidget gridWidget) {
    super(widget,
          gridLayer,
          gridWidget);
    final Style style = widget.getElement().getStyle();
    style.setWidth(100,
                   Style.Unit.PCT);
    style.setHeight(HEIGHT,
                    Style.Unit.PX);
    style.setPaddingLeft(2,
                         Style.Unit.PX);
    style.setPaddingRight(2,
                          Style.Unit.PX);
    style.setFontSize(10,
                      Style.Unit.PX);

    // --- Workaround for BS2 ---
    style.setPosition(Style.Position.RELATIVE);
    style.setPaddingTop(0,
                        Style.Unit.PX);
    style.setPaddingBottom(0,
                           Style.Unit.PX);
    style.setProperty("WebkitBoxSizing",
                      "border-box");
    style.setProperty("MozBoxSizing",
                      "border-box");
    style.setProperty("boxSizing",
                      "border-box");
    style.setProperty("lineHeight",
                      "normal");
    // --- End workaround ---

    getContainer().getElement().getStyle().setPaddingLeft(5,
                                                          Style.Unit.PX);
    getContainer().getElement().getStyle().setPaddingRight(5,
                                                           Style.Unit.PX);
    getContainer().setWidget(widget);
}
 
Example 14
Project: appformer   File: CheckBoxDOMElement.java   View Source Code Vote up 5 votes
public CheckBoxDOMElement(final CheckBox widget,
                          final GridLayer gridLayer,
                          final GridWidget gridWidget) {
    super(widget,
          gridLayer,
          gridWidget);
    final Style style = widget.getElement().getStyle();
    style.setMarginTop(0,
                       Style.Unit.PX);
    style.setMarginLeft(2,
                        Style.Unit.PX);
    style.setWidth(SIZE,
                   Style.Unit.PX);
    style.setHeight(SIZE,
                    Style.Unit.PX);

    // --- Workaround for BS2 ---
    style.setPosition(Style.Position.RELATIVE);
    style.setPaddingTop(0,
                        Style.Unit.PX);
    style.setPaddingBottom(0,
                           Style.Unit.PX);
    style.setProperty("WebkitBoxSizing",
                      "border-box");
    style.setProperty("MozBoxSizing",
                      "border-box");
    style.setProperty("boxSizing",
                      "border-box");
    style.setProperty("lineHeight",
                      "normal");
    // --- End workaround ---

    getContainer().setWidget(widget);
}
 
Example 15
Project: appformer   File: ListBoxDOMElement.java   View Source Code Vote up 5 votes
public ListBoxDOMElement(final ListBox widget,
                         final GridLayer gridLayer,
                         final GridWidget gridWidget) {
    super(widget,
          gridLayer,
          gridWidget);
    final Style style = widget.getElement().getStyle();
    style.setWidth(100,
                   Style.Unit.PCT);
    style.setHeight(HEIGHT,
                    Style.Unit.PX);
    style.setPaddingLeft(2,
                         Style.Unit.PX);
    style.setPaddingRight(2,
                          Style.Unit.PX);
    style.setFontSize(10,
                      Style.Unit.PX);

    // --- Workaround for BS2 ---
    style.setPosition(Style.Position.RELATIVE);
    style.setPaddingTop(0,
                        Style.Unit.PX);
    style.setPaddingBottom(0,
                           Style.Unit.PX);
    style.setProperty("WebkitBoxSizing",
                      "border-box");
    style.setProperty("MozBoxSizing",
                      "border-box");
    style.setProperty("boxSizing",
                      "border-box");
    style.setProperty("lineHeight",
                      "normal");
    // --- End workaround ---

    getContainer().getElement().getStyle().setPaddingLeft(5,
                                                          Style.Unit.PX);
    getContainer().getElement().getStyle().setPaddingRight(5,
                                                           Style.Unit.PX);
    getContainer().setWidget(widget);
}
 
Example 16
Project: empiria.player   File: TutorViewImpl.java   View Source Code Vote up 4 votes
@Override
public void setAnimationLeft(int left) {
    Style style = content.getElement().getStyle();
    style.setProperty("backgroundPosition", left + DIMENSIONS_UNIT);
}
 
Example 17
Project: empiria.player   File: ElementScaler.java   View Source Code Vote up 4 votes
public void setMaxWidth(int width) {
    Style style = element.getParentElement().getStyle();
    style.setProperty(MAX_WIDTH_PROPERTY, width, Style.Unit.PX);
}
 
Example 18
Project: empiria.player   File: AbstractAnimation.java   View Source Code Vote up 4 votes
protected void setProperty(FlowPanel widget, String propertyName, String propertyValue) {
    if (widget != null) {
        Style style = widget.getElement().getStyle();
        style.setProperty(propertyName, propertyValue);
    }
}
 
Example 19
Project: appinventor-extensions   File: MockForm.java   View Source Code Vote up 4 votes
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 20
Project: gwt-material-table   File: BaseRenderer.java   View Source Code Vote up 4 votes
@Override
public TableRow drawRow(DataView<T> dataView, RowComponent<T> rowComponent, Object valueKey,
                        List<Column<T, ?>> columns, boolean redraw) {
    T data = rowComponent.getData();
    TableRow row = rowComponent.getWidget();
    boolean draw = true;
    if(row == null) {
        // Create a new row element
        row = new TableRow();
        Style style = row.getElement().getStyle();
        style.setDisplay(Display.NONE);
        style.setProperty("height", getExpectedRowHeight() + "px");
        style.setProperty("maxHeight", getExpectedRowHeight() + "px");
        style.setProperty("minHeight", getExpectedRowHeight() + "px");
        row.setStyleName(TableCssName.DATA_ROW);
        rowComponent.setWidget(row);

        if(!dataView.getSelectionType().equals(SelectionType.NONE)) {
            TableData selection = drawSelectionCell();
            row.add(selection);
        }
    } else if(!redraw && !rowComponent.isRedraw()) {
        draw = false;
    }

    if(draw) {
        // Build the columns
        int colOffset = dataView.getColumnOffset();
        int colSize = columns.size();

        for(int c = 0; c < colSize; c++) {
            int colIndex = c + colOffset;
            Context context = new Context(rowComponent.getIndex(), colIndex, valueKey);
            drawColumn(row, context, data, columns.get(c), colIndex, dataView.isHeaderVisible(colIndex));
        }
        rowComponent.setRedraw(false);
    }

    if(dataView.isUseRowExpansion()) {
        if(!row.hasExpansionColumn()) {
            TableData expand = new TableData();
            expand.setId("colex");
            MaterialIcon expandIcon = new MaterialIcon();
            expandIcon.setId("expand");
            expandIcon.setWidth("100%");
            expandIcon.setIconType(IconType.KEYBOARD_ARROW_DOWN);
            expandIcon.setWaves(WavesType.LIGHT);
            expandIcon.getElement().getStyle().setCursor(Cursor.POINTER);
            expand.add(expandIcon);
            row.add(expand);
        }
    } else if(row.hasExpansionColumn()) {
        row.removeExpansionColumn();
    }

    Scheduler.get().scheduleDeferred(() -> {
        calculateRowHeight(rowComponent);
    });
    return row;
}
 
Example 21
Project: che   File: PartButtonWidget.java   View Source Code Vote up 4 votes
/**
 * Creates a badge widget with a message
 *
 * @param messages messages count
 * @return new badge widget
 */
private Widget getBadge(int messages) {
  FlowPanel w = new FlowPanel();
  Style s = w.getElement().getStyle();

  s.setProperty("position", "absolute");
  s.setProperty("width", "12px");
  s.setProperty("height", "12px");

  s.setProperty("boxSizing", "border-box");
  s.setProperty("borderRadius", "8px");
  s.setProperty("textAlign", "center");

  s.setProperty("color", org.eclipse.che.ide.api.theme.Style.getBadgeFontColor());

  s.setProperty("left", "9px");
  s.setProperty("top", "2px");

  s.setProperty("borderWidth", "1.5px");
  s.setProperty("borderStyle", "solid");

  s.setProperty(
      "fontFamily", "'Helvetica Neue', 'Myriad Pro', arial, Verdana, Verdana, sans-serif");
  s.setProperty("fontSize", "9.5px");
  s.setProperty("fontWeight", "bold");
  s.setProperty("textShadow", "none");

  s.setProperty("backgroundColor", org.eclipse.che.ide.api.theme.Style.getBadgeBackgroundColor());

  w.setStyleName("bounceOutUp");

  if (messages > 9) {
    s.setProperty("lineHeight", "5px");
    w.getElement().setInnerHTML("...");
  } else {
    s.setProperty("lineHeight", "10px");
    w.getElement().setInnerHTML("" + messages);
  }

  return w;
}