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

The following are top voted examples for showing how to use com.google.gwt.dom.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: unitimes   File: Lookup.java   View source code 6 votes vote down vote up
private void scrollToSelectedRow() {
	int row = iTable.getSelectedRow();
	if (row < 0) return;
	
	Element scroll = iScroll.getElement();
	
	Element item = iTable.getRowFormatter().getElement(iTable.getSelectedRow());
	if (item==null) return;
	
	int realOffset = 0;
	while (item !=null && !item.equals(scroll)) {
		realOffset += item.getOffsetTop();
		item = item.getOffsetParent();
	}
	
	scroll.setScrollTop(realOffset - scroll.getOffsetHeight() / 2);
}
 
Example 2
Project: sig-seguimiento-vehiculos   File: JoinDataTool.java   View source code 6 votes vote down vote up
private SubmitCompleteHandler getSubmitCompleteHandler() {
	return new SubmitCompleteHandler() {
		public void onSubmitComplete(final SubmitCompleteEvent event) {

			final Element label = DOM.createLabel();
			label.setInnerHTML(event.getResults());

			final String csvData = label.getInnerText();
			if (hasError(csvData)) {
				showAlert("Error: " + csvData);
			} else {
				parseCsvData(csvData);
				autoMessageBox.hide();
			}
		}

		private boolean hasError(final String contentFile) {
			return contentFile.startsWith("413")
					|| contentFile.startsWith("500");
		}
	};
}
 
Example 3
Project: unitimes   File: CourseFinderCourses.java   View source code 6 votes vote down vote up
protected void scrollToSelectedRow() {
	if (iCourses.getSelectedRow() < 0) return;
	
	Element scroll = iCoursesPanel.getElement();
	
	com.google.gwt.dom.client.Element item = iCourses.getRowFormatter().getElement(iCourses.getSelectedRow());
	if (item==null) return;
	
	int realOffset = 0;
	while (item !=null && !item.equals(scroll)) {
		realOffset += item.getOffsetTop();
		item = item.getOffsetParent();
	}
	
	scroll.setScrollTop(realOffset - scroll.getOffsetHeight() / 2);
}
 
Example 4
Project: unitimes   File: DegreePlanDialog.java   View source code 6 votes vote down vote up
protected void scrollToSelectedRow() {
	if (iDegreePlanTable.getSelectedRow() < 0) return;
	
	Element scroll = iDegreePlanPanel.getElement();
	
	com.google.gwt.dom.client.Element item = iDegreePlanTable.getRowFormatter().getElement(iDegreePlanTable.getSelectedRow());
	if (item == null) return;
	
	int realOffset = 0;
	while (item !=null && !item.equals(scroll)) {
		realOffset += item.getOffsetTop();
		item = item.getOffsetParent();
	}
	
	scroll.setScrollTop(realOffset - scroll.getOffsetHeight() / 2);
}
 
Example 5
Project: empiria.player   File: JsAssessmentHeaderViewExtension.java   View source code 6 votes vote down vote up
@Override
public ViewSocket getAssessmentHeaderViewSocket() {
    Element element = getViewJs(extensionJsObject);
    Widget widget = null;
    if (element != null) {
        widget = new ElementWrapperWidget(element);
    }

    final Widget widget2 = widget;

    return new ViewSocket() {
        @Override
        public Widget getView() {
            return widget2;
        }
    };
}
 
Example 6
Project: bootstrap-formgroup   File: VaadinWidgetUtils.java   View source code 6 votes vote down vote up
public static Element getElementByVaadinWidget(Widget widget, VaadinWidgetType widgetType) {
    if (widgetType == null) {
        return widget.getElement();
    }

    switch (widgetType) {
        case TEXTFIELD:
            return widget.getElement();
        case DATEFIELD:
            return ((VAbstractTextualDate) widget).text.getElement();
        case COMBOBOX:
            return ((VComboBox) widget).tb.getElement();
        case CHECKBOXGROUP:
            // returning the outer div for styling purpose
            return widget.getElement();
        case CHECKBOX:
            // returning the outer div for styling purpose
            return widget.getElement();
        case NATIVESELECT:
            return ((VNativeSelect) widget).getListBox().getElement();
        default:
            return widget.getElement();
    }
}
 
Example 7
Project: empiria.player   File: JsAssessmentFooterViewExtension.java   View source code 6 votes vote down vote up
@Override
public ViewSocket getAssessmentFooterViewSocket() {
    Element e = getViewJs(extensionJsObject);
    Widget w = null;
    if (e != null)
        w = new ElementWrapperWidget(e);

    final Widget w2 = w;

    return new ViewSocket() {
        @Override
        public Widget getView() {
            return w2;
        }
    };
}
 
Example 8
Project: empiria.player   File: TouchablePanel.java   View source code 6 votes vote down vote up
private native void registerTouchEvents(Element element)/*-{
    var instance = this;
    element.ontouchstart = function (e) {
        e.preventDefault();
        if (e.touches.length == 1) {
            var touch = e.touches[0];
            [email protected]::processOnTouchStartEvent(II)(touch.pageX, touch.pageY);
        }
    }

    element.ontouchmove = function (e) {
        e.preventDefault();
        if (e.touches.length == 1) {
            var touch = e.touches[0];
            [email protected]::processOnTouchMoveEvent(II)(touch.pageX, touch.pageY);
        }
    }

    element.ontouchend = function (e) {
        e.preventDefault();
        [email protected]::processOnTouchEndEvent()();
    }

}-*/;
 
Example 9
Project: unitimes   File: PeriodPreferencesHint.java   View source code 6 votes vote down vote up
public static void showHintForExam(final Element relativeObject, final Long examId, final Long periodId) {
	sLastLocationId = examId;
	sShowHint = true;
	RPC.execute(RoomInterface.PeriodPreferenceRequest.loadForExam(examId, null), new AsyncCallback<RoomInterface.PeriodPreferenceModel>() {
		@Override
		public void onFailure(Throwable caught) {
		}
		
		@Override
		public void onSuccess(RoomInterface.PeriodPreferenceModel result) {
			if (examId.equals(sLastLocationId) && sShowHint && result != null) {
				if (periodId != null) result.setAssignedPeriodId(periodId);
				GwtHint.showHint(relativeObject, content(result));
			}
		}
	});
}
 
Example 10
Project: empiria.player   File: StyleToPropertyMappingHelperTest.java   View source code 6 votes vote down vote up
@Test
public void setPropertyTest() {
    // prepare
    Map<String, String> propertyStyle = new HashMap<String, String>();
    propertyStyle.put("lineWidth", "0");
    propertyStyle.put("lineCap", "miter");
    propertyStyle.put("lineJoin", "square");
    propertyStyle.put("miterLimit", "3");

    // test
    testObject.applyStyles(mock(Element.class), propertyStyle);
    verify(nativeStyleHelper, times(4)).applyProperty(any(Element.class), any(String.class), any(String.class));
    for (Map.Entry<String, String> entry : propertyStyle.entrySet()) {
        verify(nativeStyleHelper).applyProperty(any(Element.class), Matchers.eq(entry.getKey()), Matchers.eq(entry.getValue()));
    }
}
 
Example 11
Project: empiria.player   File: StyleToPropertyMappingHelperTest.java   View source code 6 votes vote down vote up
@Test
public void callFunctionTest() {
    // prepare
    Map<String, String> propertyStyle = new HashMap<String, String>();
    propertyStyle.put("lineWidth", "0");
    propertyStyle.put("lineCap", "miter");
    propertyStyle.put("lineJoin", "square");
    propertyStyle.put("miterLimit", "3");
    propertyStyle.put("fn-lineCap", "miter");
    propertyStyle.put("fn-lineJoin", "square");
    propertyStyle.put("fn-miterLimit", "3");
    // test
    testObject.applyStyles(mock(Element.class), propertyStyle);
    verify(nativeStyleHelper, times(0)).callFunction(any(Element.class), any(String.class), any(String.class));
    testObject.addFunctionToWhiteList("lineCap");
    testObject.addFunctionToWhiteList("miterLimit");
    testObject.applyStyles(mock(Element.class), propertyStyle);
    verify(nativeStyleHelper, times(2)).callFunction(any(Element.class), any(String.class), any(String.class));
}
 
Example 12
Project: unitimes   File: InstructorAvailabilityHint.java   View source code 6 votes vote down vote up
public static void showHint(final Element relativeObject, final String instructorId, boolean includeNotAvailable, final String pattern) {
	sLastInstructorId = instructorId;
	RPC.execute(InstructorAvailabilityRequest.load(instructorId, includeNotAvailable), new AsyncCallback<InstructorAvailabilityModel>() {
		@Override
		public void onFailure(Throwable caught) {
		}

		@Override
		public void onSuccess(InstructorAvailabilityModel result) {
			if (pattern != null)
				result.setPattern(pattern);
			if (instructorId.equals(sLastInstructorId) && result != null)
				GwtHint.showHint(relativeObject, content(result));
		}
	});
}
 
Example 13
Project: unitimes   File: SimpleEditPage.java   View source code 6 votes vote down vote up
public void onBrowserEvent(final Event event) {
	Element td = getEventTargetCell(event);
	if (td==null) return;
    final Element tr = DOM.getParent(td);
	int col = DOM.getChildIndex(tr, td);
    Element body = DOM.getParent(tr);
    int row = DOM.getChildIndex(body, tr);
    
    Widget widget = getWidget(row, col);
    if (widget != null && widget instanceof UniTimeHeaderPanel) {
    	super.onBrowserEvent(event);
    	return;
    }
    
	switch (DOM.eventGetType(event)) {
	case Event.ONMOUSEOVER:
		getRowFormatter().addStyleName(row, "hover");
		break;
	case Event.ONMOUSEOUT:
		getRowFormatter().removeStyleName(row, "hover");
		break;
	}
	
	super.onBrowserEvent(event);
}
 
Example 14
Project: bootstrap-formgroup   File: ClientSideFormGroup.java   View source code 5 votes vote down vote up
private Element getInput() {
    if (VaadinWidgetType.CHECKBOX.equals(widgetType)) {
        // we want to apply aria attributes to the input / not the styling div
        return widgetElement.getFirstChildElement();
    } else if (VaadinWidgetType.CHECKBOXGROUP.equals(widgetType)) {
        // just a reminder - CheckBoxGroup can have the describedby here because
        // the outer div has tabindex and is kinda like a fieldset for all inputs.
        return widgetElement;
    }

    // anything else
    return widgetElement;
}
 
Example 15
Project: unitimes   File: UniTimeTable.java   View source code 5 votes vote down vote up
public int getRowForWidget(Widget w) {
	for (Element td = w.getElement(); td != null; td = DOM.getParent(td)) {
		if (td.getPropertyString("tagName").equalsIgnoreCase("td")) {
			Element tr = DOM.getParent(td);
			Element body = DOM.getParent(tr);
			if (body == getBodyElement())
				return DOM.getChildIndex(body, tr);
		}
		if (td == getBodyElement()) { return -1; }
	}
	return -1;
}
 
Example 16
Project: empiria.player   File: MagnificPopup.java   View source code 5 votes vote down vote up
private native void openImageNative(String imageSrc, Element title) /*-{
    $wnd.$.magnificPopup.open({
        items: {
            src: imageSrc
        },
        type: 'image',

        image: {
            titleSrc: function () {
                return title
            }
        },
        closeOnContentClick: true
    });
}-*/;
 
Example 17
Project: unitimes   File: UniTimeTable.java   View source code 5 votes vote down vote up
private void swapRows(int r0, int r1) {
	if (r0 == r1) return;
	if (r0 > r1) {
		swapRows(r1, r0);
	} else { // r0 < r1
		Element body = getBodyElement();
		Element a = DOM.getChild(body, r0);
		Element b = DOM.getChild(body, r1);
		body.removeChild(a);
		body.removeChild(b);
		DOM.insertChild(body, b, r0);
		DOM.insertChild(body, a, r1);
	}
}
 
Example 18
Project: unitimes   File: SimpleForm.java   View source code 5 votes vote down vote up
public int getRowForWidget(Widget w) {
	for (Element td = w.getElement(); td != null; td = DOM.getParent(td)) {
		if (td.getPropertyString("tagName").equalsIgnoreCase("td")) {
			Element tr = DOM.getParent(td);
			Element body = DOM.getParent(tr);
			if (body == getBodyElement())
				return DOM.getChildIndex(body, tr);
		}
		if (td == getBodyElement()) { return -1; }
	}
	return -1;
}
 
Example 19
Project: bootstrap-formgroup   File: ClientSideFormGroup.java   View source code 5 votes vote down vote up
void setDescription(String description, ContentMode contentMode) {
    Element element = getInput();

    if (description == null || description.isEmpty() || description.trim().isEmpty()) {
        if (hasFeedback) {
            Roles.getTextboxRole().setAriaDescribedbyProperty(element, Id.of(this.feedback));
        } else {
            Roles.getTextboxRole().removeAriaDescribedbyProperty(element);
        }
        small.setInnerHTML(isDescriptionHeightReservedIfEmpty ? "&nbsp;" : "");
        hasDescription = false;
        return;
    }

    if (!hasDescription) {
        if (hasFeedback) {
            Roles.getTextboxRole().setAriaDescribedbyProperty(element, Id.of(small), Id.of(this.feedback));
        } else {
            Roles.getTextboxRole().setAriaDescribedbyProperty(element, Id.of(small));
        }
        hasDescription = true;
    }

    if (ContentMode.HTML == contentMode) {
        small.setInnerHTML(description);
    } else {
        small.setInnerText(description);
    }
}
 
Example 20
Project: empiria.player   File: MultiPageController.java   View source code 5 votes vote down vote up
/**
 * Na androidzie podczas swipe gapy zle sie rysowaly nachodzac na siebie.
 * Pozbycie sie z nich focusa na czas swipe rozwiazalo problem
 */
private void dropFocus() {
    focusDropped = true;
    NodeList<Element> elementsByTagName = rootPanelDelegate.getBodyElement().getElementsByTagName("input");
    for (int x = 0; x < elementsByTagName.getLength(); ++x) {
        elementsByTagName.getItem(x).blur();
    }
}
 
Example 21
Project: unitimes   File: UniTimeTable.java   View source code 5 votes vote down vote up
public TableEvent(Event sourceEvent, int row, int col, Element tr, Element td, T data) {
	iRow = row;
	iCol = col;
	iTR = tr;
	iTD = td;
	iData = data;
	iSourceEvent = sourceEvent;
}
 
Example 22
Project: calendar-component   File: DateCellDayItem.java   View source code 5 votes vote down vote up
@Override
public void onMouseDown(MouseDownEvent event) {

    startX = event.getClientX();
    startY = event.getClientY();

    if (isDisabled() || event.getNativeButton() != NativeEvent.BUTTON_LEFT) {
        return;
    }

    clickTarget = Element.as(event.getNativeEvent().getEventTarget());
    mouseMoveCanceled = false;

    if ((weekGrid.getCalendar().isItemMoveAllowed() && getCalendarItem().isMoveable())
            || (clickTargetsResize() && getCalendarItem().isResizeable())) {

        moveRegistration = addMouseMoveHandler(this);
        setFocus(true);
        try {
            startYrelative = (int) ((double) event.getRelativeY(caption) % slotHeight);
            startXrelative = (event.getRelativeX(weekGrid.getElement())
                    - weekGrid.timebar.getOffsetWidth())
                    % getDateCellWidth();
        } catch (Exception e) {
            GWT.log("Exception calculating relative start position", e);
        }
        mouseMoveStarted = false;
        Style s = getElement().getStyle();
        s.setZIndex(1000);
        startDatetimeFrom = (Date) calendarItem.getStartTime().clone();
        startDatetimeTo = (Date) calendarItem.getEndTime().clone();
        Event.setCapture(getElement());
    }

    // make sure the right cursor is always displayed
    if (clickTargetsResize() && getCalendarItem().isResizeable()) {
        addGlobalResizeStyle();
    }

    /*
     * We need to stop the event propagation or else the WeekGrid range
     * select will kick in
     */
    event.stopPropagation();
    event.preventDefault();
}
 
Example 23
Project: empiria.player   File: AbstractHTML5MediaExecutor.java   View source code 5 votes vote down vote up
@Override
public void init() {
    if (media != null) {
        Element audioElement = mediaDescriptor.getMediaObject().getElement();
        configureMediaBase();
        initExecutor();
        setNativeListeners(audioElement);
    }
}
 
Example 24
Project: empiria.player   File: AbstractHTML5MediaExecutor.java   View source code 5 votes vote down vote up
private void setNativeListeners(Element audioElement) {
    ArrayList<HTML5MediaEventsType> eventTypes = Lists.newArrayList(HTML5MediaEventsType.canplay, HTML5MediaEventsType.suspend, HTML5MediaEventsType.ended,
            HTML5MediaEventsType.error, HTML5MediaEventsType.pause, HTML5MediaEventsType.play, HTML5MediaEventsType.volumechange,
            HTML5MediaEventsType.timeupdate, HTML5MediaEventsType.durationchange);

    for (HTML5MediaEventsType eventType : eventTypes) {
        html5MediaNativeListeners.addListener(audioElement, eventType.toString());
    }
}
 
Example 25
Project: empiria.player   File: ContentPreloader.java   View source code 5 votes vote down vote up
private void centerMainPreloader(int x, int y, Element preloaderElement) {
    preloaderElement.setId(MAIN_PRELOADER_ID);
    preloaderElement.getStyle().setPosition(Style.Position.ABSOLUTE);
    int leftOffset = x - preloaderElement.getOffsetWidth() / 2;
    preloaderElement.getStyle().setLeft(leftOffset, Style.Unit.PX);
    int topOffset = y - preloaderElement.getOffsetHeight() / 2;
    preloaderElement.getStyle().setTop(topOffset, Style.Unit.PX);
}
 
Example 26
Project: empiria.player   File: PositionHelper.java   View source code 5 votes vote down vote up
public int getYPositionRelativeToTarget(NativeEvent event, Element target) {
    Touch touch = getTouch(event);
    float positionY = 0;// hack dont change to int
    if (touch == null) {
        positionY = getRelativeY(event, target);
    } else {
        positionY = touch.getRelativeY(target);
    }
    return (int) positionY;
}
 
Example 27
Project: unitimes   File: EventResourceTimetable.java   View source code 5 votes vote down vote up
private native static void nativeCopyToClipboard(Element e)/*-{
	alert('here');
	e.focus();
	e.select();
	$doc.execCommand('Copy');
	alert('Copied');
}-*/;
 
Example 28
Project: calendar-component   File: VCalendar.java   View source code 5 votes vote down vote up
/**
 * Hack for IE to not select text when dragging.
 *
 * @param e
 *            The element to apply the hack on
 */
private native void blockSelect(Element e)
/*-{
	e.onselectstart = function() {
		return false;
	}

	e.ondragstart = function() {
		return false;
	}
}-*/;
 
Example 29
Project: empiria.player   File: AccessibleRadioButton.java   View source code 5 votes vote down vote up
/**
 * Overridden to send ValueChangeEvents only when appropriate.
 */
@Override
public void onBrowserEvent(Event event) {
    switch (DOM.eventGetType(event)) {
        case Event.ONMOUSEUP:
        case Event.ONBLUR:
        case Event.ONKEYDOWN:
            // Note the old value for onValueChange purposes (in ONCLICK case)
            oldValue = getValue();
            break;

        case Event.ONCLICK:
            EventTarget target = event.getEventTarget();
            if (Element.is(target) && labelElem.isOrHasChild(Element.as(target))) {

                // They clicked the label. Note our pre-click value, and
                // short circuit event routing so that other click handlers
                // don't hear about it
                oldValue = getValue();
                return;
            }

            // It's not the label. Let our handlers hear about the
            // click...
            super.onBrowserEvent(event);
            // ...and now maybe tell them about the change
            ValueChangeEvent.fireIfNotEqual(AccessibleRadioButton.this, oldValue, getValue());
            return;
    }

    super.onBrowserEvent(event);
}
 
Example 30
Project: empiria.player   File: SwiffyObject.java   View source code 5 votes vote down vote up
private native void createSwiffyObject(String iframeId, Element container)/*-{
    var iframe = $doc.getElementById(iframeId);
    iframe.contentWindow.swiffyObject = iframe.contentWindow
        .getSwiffyObject();
    iframe.contentWindow.swiffyStage = new iframe.contentWindow.swiffy.Stage(
        container, iframe.contentWindow.swiffyObject);
}-*/;
 
Example 31
Project: empiria.player   File: AccessibleListBox.java   View source code 5 votes vote down vote up
/**
 * Creates a ListBox widget that wraps an existing &lt;select&gt; element.
 * <p/>
 * This element must already be attached to the document. If the element is removed from the document, you must call {@link RootPanel#detachNow(Widget)}.
 *
 * @param element the element to be wrapped
 * @return list box
 */
public static AccessibleListBox wrap(Element element) {
    // Assert that the element is attached.
    assert Document.get().getBody().isOrHasChild(element);

    AccessibleListBox listBox = new AccessibleListBox(element);

    // Mark it attached and remember it for cleanup.
    listBox.onAttach();
    RootPanel.detachOnWindowClose(listBox);

    return listBox;
}
 
Example 32
Project: calendar-component   File: DateCellDayItem.java   View source code 5 votes vote down vote up
@Override
public void onMouseUp(MouseUpEvent event) {
    if (mouseMoveCanceled
            || event.getNativeButton() != NativeEvent.BUTTON_LEFT) {
        return;
    }

    Event.releaseCapture(getElement());
    setFocus(false);
    if (moveRegistration != null) {
        moveRegistration.removeHandler();
        moveRegistration = null;
    }

    int endX = event.getClientX();
    int endY = event.getClientY();
    int xDiff = 0, yDiff = 0;
    if (startX != -1 && startY != -1) {
        // Drag started
        xDiff = startX - endX;
        yDiff = startY - endY;
    }

    startX = -1;
    startY = -1;
    mouseMoveStarted = false;
    Style s = getElement().getStyle();
    s.setZIndex(1);

    if (!clickTargetsResize()) {

        // check if mouse has moved over threshold of 3 pixels
        boolean mouseMoved = (xDiff < -3 || xDiff > 3 || yDiff < -3 || yDiff > 3);

        if (!weekGrid.getCalendar().isDisabled() && mouseMoved) {
            // Item Move:
            // - calendar must be enabled
            // - calendar must not be in read-only mode
            weekGrid.itemMoved(this);

        } else if (!weekGrid.getCalendar().isDisabled() && getCalendarItem().isClickable()) {
            // Item Click:
            // - calendar must be enabled (read-only is allowed)
            EventTarget et = event.getNativeEvent().getEventTarget();
            Element e = Element.as(et);
            if (e == caption || e == eventContent
                    || e.getParentElement() == caption) {
                if (weekGrid.getCalendar().getItemClickListener() != null) {
                    weekGrid.getCalendar().getItemClickListener().itemClick(calendarItem);
                }
            }
        }

    } else {
        // click targeted resize bar
        removeGlobalResizeStyle();
        if (weekGrid.getCalendar().getItemResizeListener() != null) {
            weekGrid.getCalendar().getItemResizeListener().itemResized(calendarItem);
        }
        dateCell.recalculateItemWidths();
    }
}
 
Example 33
Project: empiria.player   File: TestGuiceModule.java   View source code 5 votes vote down vote up
@Provides
@Singleton
public PositionHelper getPositionHelper() {
    PositionHelper helper = mock(PositionHelper.class);
    when(helper.getXPositionRelativeToTarget(Matchers.any(NativeEvent.class), Matchers.any(Element.class))).thenReturn(20);
    when(helper.getYPositionRelativeToTarget(Matchers.any(NativeEvent.class), Matchers.any(Element.class))).thenReturn(20);
    return helper;
}
 
Example 34
Project: empiria.player   File: MathJaxPresenterTest.java   View source code 5 votes vote down vote up
@Before
public void init() {
    Widget widget = mock(Widget.class);
    com.google.gwt.user.client.Element viewElement = mock(com.google.gwt.user.client.Element.class);
    when(view.asWidget()).thenReturn(widget);
    when(widget.getElement()).thenReturn(viewElement);
    when(viewElement.getFirstChildElement()).thenReturn(scriptElement);
}
 
Example 35
Project: unitimes   File: UniTimeSideBar.java   View source code 5 votes vote down vote up
public String getStackText(int index) {
    if (index >= getWidgetCount()) {
        return null;
      }
      Element tdWrapper = DOM.getChild((Element) DOM.getChild(body, index * 2), 0);
      return DOM.getFirstChild(tdWrapper).getInnerText();
}
 
Example 36
Project: unitimes   File: FilterBox.java   View source code 5 votes vote down vote up
@Override
public void onBrowserEvent(Event event) {
   	Element target = DOM.eventGetTarget(event);

    switch (DOM.eventGetType(event)) {
    case Event.ONMOUSEDOWN:
    	boolean open = iFilterOpen.getElement().equals(target);
    	boolean close = iFilterClose.getElement().equals(target);
    	boolean clear = iFilterClear.getElement().equals(target);
    	boolean filter = iFilter.getElement().equals(target);
    	if (isFilterPopupShowing() || close) {
    		hideFilterPopup();
    	} else if (open) {
    		hideSuggestions();
    		showFilterPopup();
    	}
    	if (clear) {
			iFilter.setText("");
			removeAllChips();
			setAriaLabel(toAriaString());
			ValueChangeEvent.fire(FilterBox.this, getValue());
    	}
    	if (!filter) {
			event.stopPropagation();
			event.preventDefault();
	    	Scheduler.get().scheduleDeferred(new ScheduledCommand() {
				@Override
				public void execute() {
					iFilter.setFocus(true);
				}
			});
    	}
    	break;
    }
}
 
Example 37
Project: unitimes   File: RoomSharingHint.java   View source code 5 votes vote down vote up
public static void showHint(final Element relativeObject, final long locationId, boolean eventAvailability) {
	sLastLocationId = locationId;
	sShowHint = true;
	RPC.execute(RoomInterface.RoomSharingRequest.load(locationId, eventAvailability), new AsyncCallback<RoomInterface.RoomSharingModel>() {
		@Override
		public void onFailure(Throwable caught) {
		}
		
		@Override
		public void onSuccess(RoomInterface.RoomSharingModel result) {
			if (locationId == sLastLocationId && sShowHint && result != null)
				GwtHint.showHint(relativeObject, content(result));
		}
	});
}
 
Example 38
Project: unitimes   File: AriaCheckBox.java   View source code 5 votes vote down vote up
public AriaCheckBox(Element elem) {
	super(elem);
	
	iAriaLabel = DOM.createLabel();
	iAriaLabel.setId(DOM.createUniqueId());
	iAriaLabel.setClassName("unitime-AriaLabel");
	DOM.appendChild(getElement(), iAriaLabel);
	Roles.getCheckboxRole().setAriaLabelledbyProperty(elem, Id.of(iAriaLabel));
}
 
Example 39
Project: sig-seguimiento-vehiculos   File: OpenProjectTool.java   View source code 5 votes vote down vote up
@PostConstruct
private void initialize() {
	addDialogListener();
	addCloseButtonHandler();
	openProjectDialog.getUploadPanel().addSubmitCompleteHandler(new SubmitCompleteHandler() {
		public void onSubmitComplete(final SubmitCompleteEvent event) {

			final Element label = DOM.createLabel();
			label.setInnerHTML(event.getResults());

			final String jsonProject = label.getInnerText();
			
			openProjectDialog.hide();
			if (hasError(jsonProject)) {
				autoMessageBox.hide();
				showAlert("Error: " + jsonProject);
				return;
			}
			
			projectLoader.load(jsonProject);				
			autoMessageBox.hide();
							
		}

		private boolean hasError(final String contentFile) {
			return contentFile.startsWith("413")
					|| contentFile.startsWith("500")
					||  contentFile.startsWith("204")
					||  contentFile.startsWith("406");
		}

		
	});
}
 
Example 40
Project: unitimes   File: AriaHiddenLabel.java   View source code 5 votes vote down vote up
public AriaHiddenLabel(String text, boolean asHtml) {
	setElement((Element)DOM.createSpan());
	setStyleName("unitime-AriaHiddenLabel");
	if (text != null) {
		if (asHtml)
			setHTML(text);
		else
			setText(text);
	}
}