Java Code Examples for com.google.gwt.user.client.Element

The following are top voted examples for showing how to use com.google.gwt.user.client.Element. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: empiria.player   File: AccessibleCheckBox.java   Source Code and License 7 votes vote down vote up
protected AccessibleCheckBox(Element elem) {
    super(DOM.createSpan());
    inputElem = InputElement.as(elem);
    labelElem = Document.get().createLabelElement();

    getElement().appendChild(inputElem);
    getElement().appendChild(labelElem);

    String uid = DOM.createUniqueId();
    inputElem.setPropertyString("id", uid);
    labelElem.setHtmlFor(uid);

    // Accessibility: setting tab index to be 0 by default, ensuring element
    // appears in tab sequence. FocusWidget's setElement method already
    // calls setTabIndex, which is overridden below. However, at the time
    // that this call is made, inputElem has not been created. So, we have
    // to call setTabIndex again, once inputElem has been created.
    setTabIndex(0);
}
 
Example 2
Project: empiria.player   File: AccessibleCheckBox.java   Source Code and License 6 votes vote down vote up
/**
 * Replace the current input element with a new one. Preserves all state except for the name property, for nasty reasons related to radio button grouping.
 * (See implementation of {@link RadioButton#setName}.)
 *
 * @param elem the new input element
 */
protected void replaceInputElement(Element elem) {
    InputElement newInputElem = InputElement.as(elem);
    // Collect information we need to set
    int tabIndex = getTabIndex();
    boolean checked = getValue();
    boolean enabled = isEnabled();
    String formValue = getFormValue();
    String uid = inputElem.getId();
    String accessKey = inputElem.getAccessKey();
    int sunkEvents = Event.getEventsSunk(inputElem);

    // Clear out the old input element
    setEventListener(asOld(inputElem), null);

    getElement().replaceChild(newInputElem, inputElem);

    // Sink events on the new element
    Event.sinkEvents(elem, Event.getEventsSunk(inputElem));
    Event.sinkEvents(inputElem, 0);
    inputElem = newInputElem;

    // Setup the new element
    Event.sinkEvents(inputElem, sunkEvents);
    inputElem.setId(uid);
    if (!"".equals(accessKey)) {
        inputElem.setAccessKey(accessKey);
    }
    setTabIndex(tabIndex);
    setValue(checked);
    setEnabled(enabled);
    setFormValue(formValue);

    // Set the event listener
    if (isAttached()) {
        setEventListener(asOld(inputElem), this);
    }
}
 
Example 3
Project: empiria.player   File: ColorfillCanvasImplJUnitTest.java   Source Code and License 6 votes vote down vote up
@Test
public void onAreaClickWrongCoordinates() throws Exception {
    ColorfillAreaClickListener colorfillAreaClickListener = mock(ColorfillAreaClickListener.class);
    instance.setAreaClickListener(colorfillAreaClickListener);
    when(canvasImageDataProvider.getCanvasImageData(canvasStubView)).thenReturn(imageData);

    doReturn(-10).when(positionHelper)
                 .getXPositionRelativeToTarget(any(NativeEvent.class), Matchers.any(Element.class));
    doReturn(-15).when(positionHelper)
                 .getYPositionRelativeToTarget(any(NativeEvent.class), Matchers.any(Element.class));

    ArgumentCaptor<LoadHandler> loadHandlerCaptor = ArgumentCaptor.forClass(LoadHandler.class);
    verify(canvasStubView).setImageLoadHandler(loadHandlerCaptor.capture());
    loadHandlerCaptor.getValue()
                     .onLoad(null);

    ArgumentCaptor<Command> commandCaptor = ArgumentCaptor.forClass(Command.class);
    verify(userInteractionHandlerFactory).applyUserClickHandler(commandCaptor.capture(), eq(canvas));

    NativeEvent nativeEvent = mock(NativeEvent.class);
    commandCaptor.getValue()
                 .execute(nativeEvent);

    verify(colorfillAreaClickListener, times(0)).onAreaClick(any(Area.class));
}
 
Example 4
Project: empiria.player   File: AbstractHTML5MediaExecutorJUnitBase.java   Source Code and License 6 votes vote down vote up
@Test
public void shouldTestInitNoConfiguration() {
    // given
    Element element = mock(Element.class);
    MediaWrapper<MediaBase> mediaDescriptor = mock(MediaWrapper.class);
    when(mediaDescriptor.getMediaObject()).thenReturn(mediaBase);
    when(mediaBase.getElement()).thenReturn(element);

    instance.setMediaWrapper(mediaDescriptor);
    mediaConfiguration = new BaseMediaConfiguration(new HashMap<String, String>(), false);
    instance.setBaseMediaConfiguration(mediaConfiguration);

    // when
    instance.init();

    // then
    verify(mediaBase).setPreload(Matchers.eq(getAssumedMediaPreloadType()));
    verify(mediaBase).setControls(Matchers.eq(true));
    for (Map.Entry<HTML5MediaEventsType, MediaEventTypes> typePair : createEventsPairMap().entrySet()) {
        verify(html5MediaNativeListeners).addListener(element, typePair.getKey().toString());
    }
}
 
Example 5
Project: empiria.player   File: AbstractHTML5MediaExecutorJUnitBase.java   Source Code and License 6 votes vote down vote up
@Test
public void shouldInitiateValues_whenMediaBaseIsSet() {
    // given
    Element element = mock(Element.class);
    MediaWrapper<MediaBase> mediaDescriptor = mock(MediaWrapper.class);
    when(mediaDescriptor.getMediaObject()).thenReturn(mediaBase);
    when(mediaBase.getElement()).thenReturn(element);

    instance.setMediaWrapper(mediaDescriptor);
    instance.setBaseMediaConfiguration(mediaConfiguration);

    // when
    instance.init();

    // then
    verify(mediaBase).setPreload(Matchers.eq(getAssumedMediaPreloadType()));
    verify(mediaBase).setControls(Matchers.eq(false));
    for (Map.Entry<HTML5MediaEventsType, MediaEventTypes> typePair : createEventsPairMap().entrySet()) {
        verify(html5MediaNativeListeners).addListener(element, typePair.getKey().toString());
    }
}
 
Example 6
Project: EasyML   File: NodeShape.java   Source Code and License 6 votes vote down vote up
protected int getContainerOffsetLeft() {
	if (containerOffsetLeft < 0 || !sync) {
		int scrollLeft = 0;
		Element parent = DOM.getParent(getWidget().getElement());
		while (parent != null) {
			if (getScrollLeft(parent) > 0) {
				scrollLeft += getScrollLeft(parent);
				GWT.log("Scroll left detected : " + scrollLeft);
			}
			if (containerFinder.isContainer(parent)) {
				containerOffsetLeft = DOM.getAbsoluteLeft(parent) - scrollLeft;
			}
			parent = DOM.getParent(parent);
		}
	}
	return containerOffsetLeft;
}
 
Example 7
Project: EasyML   File: NodeShape.java   Source Code and License 6 votes vote down vote up
protected int getContainerOffsetTop() {
	if (containerOffsetTop < 0 || !sync) {
		int scrollTop = 0;
		Element parent = DOM.getParent(getWidget().getElement());
		while (parent != null) {
			if (getScrollTop(parent) > 0) {
				scrollTop += getScrollTop(parent);
				GWT.log("Scroll Top detected : " + scrollTop);
			}
			if (containerFinder.isContainer(parent)) {
				containerOffsetTop = DOM.getAbsoluteTop(parent) - scrollTop;
			}
			parent = DOM.getParent(parent);
		}
	}
	return containerOffsetTop;
}
 
Example 8
Project: WebConsole   File: SliderComponent.java   Source Code and License 6 votes vote down vote up
public Thumb() {
	visibleThumb = new SimplePanel();
	Element visibleElem = visibleThumb.getElement();
	Element touchElem = getElement();
	
	visibleThumb.setStylePrimaryName(THUMB_CLASS_NAME);
	
	BrowserUtils.setStyleAttributeAllBrowsers(visibleElem, "boxSizing", "border-box");
	BrowserUtils.setStyleAttributeAllBrowsers(touchElem, "boxSizing", "border-box");

	this.setWidget(visibleThumb);
	
	if (!isPassive)
	{
		visibleThumb.addStyleName(INTERACTIVE_CLASS_NAME);
	}
}
 
Example 9
Project: document-management-system   File: ColoredFlexTable.java   Source Code and License 6 votes vote down vote up
@Override
public void onBrowserEvent(Event event) {
	super.onBrowserEvent(event);
	Element td = getEventTargetCell(event);
	if (td == null)
		return;
	Element tr = DOM.getParent(td);

	switch (DOM.eventGetType(event)) {
		case Event.ONMOUSEOVER:
			tr.addClassName(ROW_STYLE_NAME + "-mouseover");
			break;

		case Event.ONMOUSEOUT: {
			tr.removeClassName(ROW_STYLE_NAME + "-mouseover");
			break;
		}
	}
}
 
Example 10
Project: document-management-system   File: ExtendedFlexTable.java   Source Code and License 6 votes vote down vote up
/**
 * Method originally copied from HTMLTable superclass where it was defined private
 * Now implemented differently to only return target cell if it'spart of 'this' table
 */
private Element getMouseEventTargetCell(Event event) {
	Element td = DOM.eventGetTarget(event);
	//locate enclosing td element
	while (!DOM.getElementProperty(td, "tagName").equalsIgnoreCase("td")) {
		// If we run out of elements, or run into the table itself, then give up.
		if ((td == null) || td == getElement())
			return null;
		td = DOM.getParent(td);
	}
	//test if the td is actually from this table
	Element tr = DOM.getParent(td);
	Element body = DOM.getParent(tr);
	if (body == this.getBodyElement()) {
		return td;
	}
	//Didn't find appropriate cell
	return null;
}
 
Example 11
Project: document-management-system   File: ExtendedFlexTable.java   Source Code and License 6 votes vote down vote up
/**
 * Method originally copied from HTMLTable superclass where it was defined private
 * Now implemented differently to only return target cell if it'spart of 'this' table
 */
private Element getMouseEventTargetCell(Event event) {
	Element td = DOM.eventGetTarget(event);
	//locate enclosing td element
	while (!DOM.getElementProperty(td, "tagName").equalsIgnoreCase("td")) {
		// If we run out of elements, or run into the table itself, then give up.
		if ((td == null) || td == getElement())
			return null;
		td = DOM.getParent(td);
	}
	//test if the td is actually from this table
	Element tr = DOM.getParent(td);
	Element body = DOM.getParent(tr);
	if (body == this.getBodyElement()) {
		return td;
	}
	//Didn't find appropriate cell
	return null;
}
 
Example 12
Project: document-management-system   File: ExtendedFlexTable.java   Source Code and License 6 votes vote down vote up
/**
 * Method originally copied from HTMLTable superclass where it was defined private
 * Now implemented differently to only return target cell if it'spart of 'this' table
 */
private Element getMouseEventTargetCell(Event event) {
	Element td = DOM.eventGetTarget(event);
	//locate enclosing td element
	while (!DOM.getElementProperty(td, "tagName").equalsIgnoreCase("td")) {
		// If we run out of elements, or run into the table itself, then give up.
		if ((td == null) || td == getElement())
			return null;
		td = DOM.getParent(td);
	}
	//test if the td is actually from this table
	Element tr = DOM.getParent(td);
	Element body = DOM.getParent(tr);
	if (body == this.getBodyElement()) {
		return td;
	}
	//Didn't find appropriate cell
	return null;
}
 
Example 13
Project: document-management-system   File: ExtendedFlexTable.java   Source Code and License 6 votes vote down vote up
/**
 * Method originally copied from HTMLTable superclass where it was defined private
 * Now implemented differently to only return target cell if it'spart of 'this' table
 */
private Element getMouseEventTargetCell(Event event) {
	Element td = DOM.eventGetTarget(event);
	//locate enclosing td element
	while (!DOM.getElementProperty(td, "tagName").equalsIgnoreCase("td")) {
		// If we run out of elements, or run into the table itself, then give up.
		if ((td == null) || td == getElement())
			return null;
		td = DOM.getParent(td);
	}
	//test if the td is actually from this table
	Element tr = DOM.getParent(td);
	Element body = DOM.getParent(tr);
	if (body == this.getBodyElement()) {
		return td;
	}
	//Didn't find appropriate cell
	return null;
}
 
Example 14
Project: document-management-system   File: Util.java   Source Code and License 6 votes vote down vote up
/**
 * Download files exported as zip
 *
 * @author danilo
 */
@Deprecated
public static void downloadFiles(List<String> path, String params) {
	if (!params.equals("")) {
		params = "&" + params;
	}

	final Element downloadIframe = RootPanel.get("__download").getElement();
	String url = RPCService.DownloadServlet + "?export" + params;

	for (String p : path) {
		url += "&pathList=" + URL.encodeQueryString(p);
	}

	DOM.setElementAttribute(downloadIframe, "src", url);
}
 
Example 15
Project: document-management-system   File: ExtendedFlexTable.java   Source Code and License 6 votes vote down vote up
public void onBrowserEvent(Event event) {
	int selectedRow = 0;

	if (DOM.eventGetType(event) == Event.ONDBLCLICK) {
		Element td = getMouseEventTargetCell(event);
		if (td == null) return;
		Element tr = DOM.getParent(td);
		Element body = DOM.getParent(tr);
		selectedRow = DOM.getChildIndex(body, tr);
		if (selectedRow >= 0) {
			markSelectedRow(selectedRow);
			Main.get().onlineUsersPopup.enableAcceptButton();
			DOM.eventCancelBubble(event, true);
			Main.get().onlineUsersPopup.executeAction();
		}
	}

	super.onBrowserEvent(event);
}
 
Example 16
Project: document-management-system   File: ExtendedFlexTable.java   Source Code and License 6 votes vote down vote up
/**
 * Method originally copied from HTMLTable superclass where it was defined private
 * Now implemented differently to only return target cell if it'spart of 'this' table
 */
private Element getMouseEventTargetCell(Event event) {
	Element td = DOM.eventGetTarget(event);
	//locate enclosing td element
	while (!DOM.getElementProperty(td, "tagName").equalsIgnoreCase("td")) {
		// If we run out of elements, or run into the table itself, then give up.
		if ((td == null) || td == getElement())
			return null;
		td = DOM.getParent(td);
	}
	//test if the td is actually from this table
	Element tr = DOM.getParent(td);
	Element body = DOM.getParent(tr);
	if (body == this.getBodyElement()) {
		return td;
	}
	//Didn't find appropriate cell
	return null;
}
 
Example 17
Project: document-management-system   File: ExtendedFlexTable.java   Source Code and License 6 votes vote down vote up
/**
 * Method originally copied from HTMLTable superclass where it was defined private
 * Now implemented differently to only return target cell if it'spart of 'this' table
 */
private Element getMouseEventTargetCell(Event event) {
	Element td = DOM.eventGetTarget(event);
	//locate enclosing td element
	while (!DOM.getElementProperty(td, "tagName").equalsIgnoreCase("td")) {
		// If we run out of elements, or run into the table itself, then give up.
		if ((td == null) || td == getElement())
			return null;
		td = DOM.getParent(td);
	}
	//test if the td is actually from this table
	Element tr = DOM.getParent(td);
	Element body = DOM.getParent(tr);
	if (body == this.getBodyElement()) {
		return td;
	}
	//Didn't find appropriate cell
	return null;
}
 
Example 18
Project: document-management-system   File: ExtendedFlexTable.java   Source Code and License 6 votes vote down vote up
/**
 * Method originally copied from HTMLTable superclass where it was defined private
 * Now implemented differently to only return target cell if it'spart of 'this' table
 */
private Element getMouseEventTargetCell(Event event) {
	Element td = DOM.eventGetTarget(event);
	//locate enclosing td element
	while (!DOM.getElementProperty(td, "tagName").equalsIgnoreCase("td")) {
		// If we run out of elements, or run into the table itself, then give up.
		if ((td == null) || td == getElement())
			return null;
		td = DOM.getParent(td);
	}
	//test if the td is actually from this table
	Element tr = DOM.getParent(td);
	Element body = DOM.getParent(tr);
	if (body == this.getBodyElement()) {
		return td;
	}
	//Didn't find appropriate cell
	return null;
}
 
Example 19
Project: cuba   File: CubaScrollBoxLayoutWidget.java   Source Code and License 6 votes vote down vote up
@Override
public void onBrowserEvent(Event event) {
    super.onBrowserEvent(event);

    if (DOM.eventGetType(event) == Event.ONSCROLL) {
        Element element = getElement();

        int scrollTop = element.getScrollTop();
        int scrollLeft = element.getScrollLeft();

        if (this.scrollTop != scrollTop || this.scrollLeft != scrollLeft) {
            if (onScrollHandler != null) {
                onScrollHandler.accept(scrollTop, scrollLeft);
            }

            this.scrollTop = scrollTop;
            this.scrollLeft = scrollLeft;
        }
    }
}
 
Example 20
Project: kie-docker-ci   File: KieCalendar.java   Source Code and License 6 votes vote down vote up
@Override
public void onMouseOver(MouseOverEvent<Appointment> event) {
    final Element element = (Element)event.getElement();
    final Appointment appt = event.getTarget();
    final StringBuilder t = new StringBuilder("<p><b>").append(appt.getTitle()).append("</b></p>");
    if (appt.getDescription() != null) {
        t.append(appt.getDescription());
    }
    t.append("<p><i>").append(Constants.INSTANCE.dblClickToExplore()).append("</i></p>");
    appointmentPopup.setWidget(new HTML(t.toString()));

    int left = element.getAbsoluteLeft() + 10;
    int top = element.getAbsoluteTop() + 10;
    appointmentPopup.setPopupPosition(left, top);
    appointmentPopup.show();
}
 
Example 21
Project: gwt-chronoscope   File: SwfObjectImpl.java   Source Code and License 6 votes vote down vote up
@Override
public Element create(String objectElementId, String swfUrl, String readyFn) {

  Element obj = DOM.createElement("object");
  DOM.setStyleAttribute(obj, "position", "absolute");
  DOM.setStyleAttribute(obj, "top", "0px");
  DOM.setStyleAttribute(obj, "left", "0px");
  DOM.setStyleAttribute(obj, "zIndex", "0");
  DOM.setElementAttribute(obj, "id", objectElementId);
  DOM.setElementAttribute(obj, "width", "100%");
  DOM.setElementAttribute(obj, "height","100%");
  DOM.setElementAttribute(obj, "type", "application/x-shockwave-flash");
  DOM.setElementAttribute(obj, "data", swfUrl);

  add(obj, "FlashVars", "readyFn=" + readyFn);
  add(obj, "quality", "autolow");
  add(obj, "bgcolor", "#FFFFFF");
  add(obj, "wmode", "opaque");
  add(obj, "MENU", "false");
  add(obj, "base", getModuleBaseURL());
  add(obj, "allowScriptAccess", "always");
  add(obj, "allowNetworking", "all");

  return obj;
}
 
Example 22
Project: umlet   File: Notification.java   Source Code and License 6 votes vote down vote up
private static void fade(final Element element, final float startOpacity, final float endOpacity, final int totalTimeMillis) {
	final int numberOfSteps = 30;
	int stepLengthMillis = totalTimeMillis / numberOfSteps;
	stepCount = 0;
	final float deltaOpacity = (endOpacity - startOpacity) / numberOfSteps;
	timerFader = new Timer() {
		@Override
		public void run() {
			float opacity = startOpacity + stepCount * deltaOpacity;
			DOM.setStyleAttribute(element, "opacity", Float.toString(opacity));

			stepCount++;
			if (stepCount == numberOfSteps) {
				DOM.setStyleAttribute(element, "opacity", Float.toString(endOpacity));
				cancel();
			}
		}
	};
	timerFader.scheduleRepeating(stepLengthMillis);
}
 
Example 23
Project: onecmdb   File: CMDBContentBrowserWidget.java   Source Code and License 6 votes vote down vote up
@Override
protected void onRender(Element parent, int index) {
	super.onRender(parent, index);
	String path = item.getParams().get("path");
	ContentFolder folder = new ContentFolder();
	if (path != null) {
		folder.setPath(path);
	}
	ContentViewerWidget widget = new ContentViewerWidget(folder);
	String rd = (String)item.getParams().get("readonly", "false");
	boolean readOnly = Boolean.parseBoolean(rd);
	widget.setReadonly(readOnly);
	add(widget);
	
	layout();
}
 
Example 24
Project: gwt-chronoscope   File: SwfObjectIE.java   Source Code and License 6 votes vote down vote up
@Override
public Element create(String objectElementId, String swfUrl, String readyFn, Element altContent) {

  Element obj = DOM.createElement("object");
  DOM.setStyleAttribute(obj, "position", "absolute");
  DOM.setStyleAttribute(obj, "top", "0px");
  DOM.setStyleAttribute(obj, "left", "0px");
  DOM.setStyleAttribute(obj, "zIndex", "0");
  DOM.setElementAttribute(obj, "classid", "clsid:D27CDB6E-AE6D-11CF-96B8-444553540000");
  DOM.setElementAttribute(obj, "id", objectElementId);
  DOM.setElementAttribute(obj, "width", "100%");
  DOM.setElementAttribute(obj, "height","100%");

  add(obj, "movie", swfUrl);
  add(obj, "FlashVars", "readyFn=" + readyFn);
  add(obj, "quality", "autolow");
  add(obj, "bgcolor", "#FFFFFF");
  add(obj, "wmode", "opaque");
  add(obj, "MENU", "false");
  // add(obj, "base", getModuleBaseURL());
  add(obj, "allowScriptAccess", "always");
  add(obj, "allowNetworking", "all");

  return obj;
}
 
Example 25
Project: firefly   File: BasicImageGrid.java   Source Code and License 6 votes vote down vote up
private void restoreScrollPositions() {
    Element body = getElement();
    int scrollX = body.getScrollLeft();
    int scrollY = body.getScrollTop();
    int viewWidth = DOM.getElementPropertyInt(body, "clientWidth");
    int viewHeight = DOM.getElementPropertyInt(body, "clientHeight");
    if (currentViewHeight == viewHeight && currentViewWidth == viewWidth) {
        if (currentScrollX != scrollX) {
            setHorizontalScrollPosition(currentScrollX);
        }

        if (currentScrollY != scrollY) {
            setScrollPosition(currentScrollY);
        }
    }
}
 
Example 26
Project: appformer   File: GridLienzoScrollUITest.java   Source Code and License 6 votes vote down vote up
@Test
public void testStyle() {

    final Widget widget = mock(Widget.class);
    final Element element = mock(Element.class);
    final Style expectedStyle = mock(Style.class);

    doReturn(expectedStyle).when(element).getStyle();
    doReturn(element).when(widget).getElement();
    doCallRealMethod().when(gridLienzoScrollUI).style(any());

    final Style actualStyle = gridLienzoScrollUI.style(widget);

    assertEquals(expectedStyle,
                 actualStyle);
}
 
Example 27
Project: appformer   File: SideDockItemFocusedTest.java   Source Code and License 6 votes vote down vote up
@Before
public void setUp() {
    when(uberfireDock.getDockPosition()).thenReturn(UberfireDockPosition.EAST);
    when(uberfireDock.getIconType()).thenReturn("RANDOM");
    when(uberfireDock.getPlaceRequest()).thenReturn(mock(PlaceRequest.class));

    when(sideDockItem.getDock()).thenReturn(uberfireDock);

    focusedItem = spy(new SideDockItemFocused(sideDockItem));

    when(button.addClickHandler(any(ClickHandler.class))).thenAnswer((Answer) aInvocation -> {
        clickHandler = (ClickHandler) aInvocation.getArguments()[0];
        return null;
    });

    element = mock(Element.class);
    style = mock(Style.class);
    when(sideDockItem.getElement()).thenReturn(element);
    when(element.getStyle()).thenReturn(style);
}
 
Example 28
Project: onecmdb   File: CMDBInstanceListGrid.java   Source Code and License 6 votes vote down vote up
@Override
protected void onRender(Element parent, int index) {
	super.onRender(parent, index);
	setLayout(new FitLayout());
	ContentFile mdr = new ContentFile();
	String mdrConf = item.getParams().get("mdrConfig");
	if (mdrConf == null) {
		mdrConf = CMDBSession.get().getConfig().get(Config.OneCMDBWebService);
	}
	mdr.setPath(mdrConf);
	
	String configFile = item.getParams().get("tableconfig");
	ContentFile config = new ContentFile(configFile);
	String header = item.getParams().get("header");
	
	
	EditableCIInstanceGrid grid = new EditableCIInstanceGrid(mdr, config, header);
	
	add(grid);
	layout();
}
 
Example 29
Project: firefly   File: GwtUtil.java   Source Code and License 6 votes vote down vote up
public static native String getComputedStyleStandard(final com.google.gwt.dom.client.Element oElm, final String strCssRule) /*-{
        var strValue = "";
        if($doc.defaultView && $doc.defaultView.getComputedStyle){
//        // use the W3C's method, if it exists
            strValue = $doc.defaultView.getComputedStyle(oElm, "").getPropertyValue(strCssRule);

        } else if(oElm.currentStyle){
//        // Oterwise, try to us IE's method
            strCssRule = strCssRule.replace(/-(w)/g, function (strMatch, p1){
                            return p1.toUpperCase();
                        });
            strValue = oElm.currentStyle[strCssRule];

        }
        return strValue;
    }-*/;
 
Example 30
Project: gwt-chronoscope   File: DomTextLayer.java   Source Code and License 6 votes vote down vote up
public TextLayer getTextLayer(String layerName) {                            
  TextLayer layer = (TextLayer) layers.get(layerName);
  if (layer == null) {
    Element layerElem;
    layerElem = DOM.createElement("div");
    DOM.setStyleAttribute(layerElem, "position", "absolute");
    DOM.setIntStyleAttribute(layerElem, "left", 0);
    DOM.setIntStyleAttribute(layerElem, "top", 0);
    DOM.setIntStyleAttribute(layerElem, "width", (int) getWidth());
    DOM.setIntStyleAttribute(layerElem, "height", (int) getHeight());
    DOM.setStyleAttribute(layerElem, "backgroundColor", "transparent");
    DOM.setStyleAttribute(layerElem, "zIndex", "" + (getLayerOrder() + 1));
    DOM.setStyleAttribute(layerElem, "overflow", "visible");
    DOM.appendChild(DOM.getParent(getElement()), layerElem);
    layer = new TextLayer();
    layer.layerElem = layerElem;
    layer.bounds = new Bounds(0, 0, getWidth(), getHeight());
    layers.put(layerName, layer);
    // layerElem = null;
  }
  return layer;
}
 
Example 31
Project: gwt-chronoscope   File: DomTextLayer.java   Source Code and License 6 votes vote down vote up
private Element getMetricDiv() {
  if (metricDiv == null) {
    Element gssCssElement = ((CssGssViewSupport) getCanvas().getView()).getGssCssElement();
    if (gssCssElement == null) {
      System.out.println("WARN: DomTextLayer.getMetricDiv " + getCanvas().getClass().getName() + ".getView()" + " has null gssCssElement.");
    } else {
      metricDiv = DOM.createDiv();
      DOM.setStyleAttribute(metricDiv, "position", "absolute");
      DOM.setStyleAttribute(metricDiv, "padding", "0px");
      DOM.setStyleAttribute(metricDiv, "margin", "0px");
      DOM.setStyleAttribute(metricDiv, "border", "0px");
      DOM.setStyleAttribute(metricDiv, "visibility", "hidden");
      DOM.appendChild(gssCssElement, metricDiv);
    }
  }
  return metricDiv;
}
 
Example 32
Project: onecmdb   File: CMDBInstanceTreeView.java   Source Code and License 6 votes vote down vote up
@Override
protected void onRender(Element parent, int index) {
	super.onRender(parent, index);
	
	BaseModel param = item.getParams();
	
	ContentFile file = new ContentFile();
	String mdrConf = param.get("mdrConfig");
	if (mdrConf == null) {
		mdrConf = CMDBSession.get().getConfig().get(Config.OneCMDBWebService);
	}
	file.setPath(mdrConf);
	    
	
	List<String> roots = null;
	Object o = param.get("rootCI");
	if (o instanceof List) {
		roots = param.get("rootCI");
	}
	CIModelRelationBrowser browser = new CIModelRelationBrowser(file, roots);
	add(browser);
	layout();
}
 
Example 33
Project: gwt-chronoscope   File: BrowserLayer.java   Source Code and License 6 votes vote down vote up
public void createLayerDiv(BrowserCanvas canvas, Bounds bounds) {
  layerDivElement = DOM.createElement("div");
  // layerDivElement.addClassName("chrono-layer");
  DOM.setStyleAttribute(layerDivElement, "overflow", "hidden");
  DOM.setElementAttribute(layerDivElement, "id", divElementId);
  initDivElement(layerDivElement, bounds);

  layerCanvasElement = DOM.createElement("canvas");
  DOM.setElementAttribute(layerCanvasElement, "id", canvasElementId);
  initCanvasElement(layerCanvasElement);

  positionDomElements(layerDivElement, layerCanvasElement, bounds);

  Element parent = canvas.getElement();
  if ((parent != null) && (layerDivElement != null) && (layerCanvasElement != null)) {
    DOM.appendChild(layerDivElement, layerCanvasElement);
    DOM.appendChild(parent, layerDivElement);
  }

  if(SHOW_BOXES) {
    DOM.setStyleAttribute(layerDivElement, "border", "1px dashed orange");
  }
  // return layerDivElement;
}
 
Example 34
Project: appformer   File: GridLienzoPanelTest.java   Source Code and License 6 votes vote down vote up
@Test
public void testUpdatePanelSizeWhenWidthAndHeightAreGreaterThanZero() {

    final Element element = mock(Element.class);
    final Element parentElement = mock(Element.class);
    final Integer scrollWidth = 14;
    final Integer scrollHeight = 14;
    final Integer width = 800;
    final Integer height = 600;

    doReturn(element).when(gridLienzoPanel).getElement();
    doReturn(parentElement).when(element).getParentElement();
    doReturn(width).when(parentElement).getOffsetWidth();
    doReturn(height).when(parentElement).getOffsetHeight();
    doReturn(scrollWidth).when(gridLienzoScrollHandler).scrollbarWidth();
    doReturn(scrollHeight).when(gridLienzoScrollHandler).scrollbarHeight();

    gridLienzoPanel.updatePanelSize();

    verify(domElementContainer).setPixelSize(width - scrollWidth,
                                             height - scrollHeight);
    verify(lienzoPanel).setPixelSize(width - scrollWidth,
                                     height - scrollHeight);
    verify(scrollPanel).setPixelSize(width,
                                     height);
}
 
Example 35
Project: gwt-chronoscope   File: BrowserCanvas.java   Source Code and License 6 votes vote down vote up
public BrowserCanvas(BrowserView view, int width, int height) {
  super(view);
  this.width = width;
  this.height = height;

  canvasDivElementId = getView().getViewId() + "bc";
  if (null == canvasDivElement) {
    canvasDivElement = DOM.createElement("div");
  }
  DOM.setElementAttribute(canvasDivElement, "id", canvasDivElementId);

  Bounds initialBounds = new Bounds(0,0,view.getWidth(), view.getHeight());
  GwtView.initDivElement(canvasDivElement, initialBounds);
  GwtView.positionDivElement(canvasDivElement, initialBounds);

  Element viewElement = view.getElement();
  if ((viewElement != null) && (canvasDivElement !=null)) {
    DOM.appendChild(viewElement, canvasDivElement);
  }

  // create layer and append <div layer><canvas layer></div> to canvasDivElement
  // rootLayer = createLayer(Layer.BACKGROUND, new Bounds(0, 0, width, height));

}
 
Example 36
Project: gwt-chronoscope   File: ChartDemoJS.java   Source Code and License 6 votes vote down vote up
public void onModuleLoad() {
//    GWT.setUncaughtExceptionHandler(new ClientExceptionHandler());

    NodeList nl = Document.get().getElementsByTagName("style");
    final ArrayList<String> toLoad = new ArrayList<String>();
    for (int i = 0; i < nl.getLength(); i++) {
      Element e = (Element) nl.getItem(i);
      if ("text/gss".equals(e.getAttribute("type"))) {
        GWT.log("Style = " + e.getInnerText(), null);
      }
    }

    Chronoscope.setMicroformatsEnabled(true);
    ChronoscopeOptions.setErrorReporting(true);
    Chronoscope.getInstance();
  }
 
Example 37
Project: empiria.player   File: SimulationCanvasProvider.java   Source Code and License 5 votes vote down vote up
public Optional<Element> getSimulationCanvasElement(CreateJsLoader createJsLoader) {
    Optional<Canvas> simulationCanvas = getSimulationCanvas(createJsLoader);
    if (!simulationCanvas.isPresent()) {
        return Optional.<Element>absent();

    }
    Canvas canvas = simulationCanvas.get();
    return Optional.fromNullable(canvas.getElement());
}
 
Example 38
Project: empiria.player   File: HTML5VideoForcePosterHack.java   Source Code and License 5 votes vote down vote up
private void createPosterImageOnParentElementOnce() {
    if (isPosterCreated) {
        return;
    }

    Widget parent = mediaBase.getParent();
    Element parentElement = parent.getElement();

    if (parentElement != null) {
        AbstractHTML5MediaExecutor executor = mediaExecutorDelegator.getExecutor();
        BaseMediaConfiguration baseMediaConfiguration = executor.getBaseMediaConfiguration();
        createPosterImageLayer(parentElement, baseMediaConfiguration);
        isPosterCreated = true;
    }
}
 
Example 39
Project: empiria.player   File: HTML5VideoForcePosterHack.java   Source Code and License 5 votes vote down vote up
private void createPosterImageLayer(Element mediaContainerElement, BaseMediaConfiguration baseMediaConfiguration) {
    posterImageElement = DOM.createImg();
    DOM.setImgSrc(posterImageElement, baseMediaConfiguration.getPoster());
    posterImageElement.getStyle().setLeft(0, Unit.PX);
    posterImageElement.getStyle().setTop(0, Unit.PX);
    posterImageElement.getStyle().setPosition(Position.ABSOLUTE);
    posterImageElement.getStyle().setWidth(baseMediaConfiguration.getWidth(), Unit.PX);
    posterImageElement.getStyle().setHeight(baseMediaConfiguration.getHeight(), Unit.PX);
    posterImageElement.getStyle().setPadding(0, Unit.PX);
    posterImageElement.getStyle().setMargin(0, Unit.PX);
    posterImageElement.getStyle().setVisibility(Visibility.VISIBLE);

    mediaContainerElement.appendChild(posterImageElement);
}
 
Example 40
Project: empiria.player   File: SimulationCanvasProviderTest.java   Source Code and License 5 votes vote down vote up
@Test
public void testGetSimulationCanvas_contentIsNull() {
    // when
    Optional<Element> simulationElemrnt = simulationCanvasProvider.getSimulationCanvasElement(createJsLoader);
    // then
    assertFalse(simulationElemrnt.isPresent());
}