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

The following are top voted examples for showing how to use com.google.gwt.user.client.DOM. 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   View source code 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: bootstrap-formgroup   File: ClientSideFormGroup.java   View source code 6 votes vote down vote up
public void setWidget(Widget w, boolean delegateCaptionHandling) {
    if (w != null) {
        this.widgetType = VaadinWidgetUtils.getWidgetTypeByWidget(w);
        this.widgetElement = VaadinWidgetUtils.getElementByVaadinWidget(w, this.widgetType);
        if (this.widgetType.isAddStyle()) {
            this.widgetElement.addClassName(this.widgetType.getCssStyle());
        } else {
            this.widgetElement.setClassName(this.widgetType.getCssStyle());
        }
        if (delegateCaptionHandling) {
            getElement().appendChild(label = DOM.createLabel());
        } else {
            getElement().appendChild(label = DOM.createDiv());
        }
        getElement().appendChild(div);
    }
    super.setWidget(w);

    if (w != null) {
        getContainerElement().appendChild(small);
        getContainerElement().appendChild(feedback);
    }
}
 
Example 3
Project: EasyML   File: DatasetWidget.java   View source code 6 votes vote down vote up
@Override
protected void init() {
	clientWidth = DOM.getElementPropertyInt(label.getElement(), "clientHeight");
	clientWidth = DOM.getElementPropertyInt(label.getElement(), "clientHeight");
	clientHeight = DOM.getElementPropertyInt(label.getElement(), "clientHeight");
	offsetWidth = label.getOffsetWidth();
	offsetHeight = label.getOffsetHeight();
	offsetTop = DOM.getElementPropertyInt(label.getElement(), "offsetTop");
	offsetLeft = DOM.getElementPropertyInt(label.getElement(), "offsetLeft");

	boder = (offsetHeight - clientHeight) / 2;

	custom();

	this.setPixelSize((int) offsetWidth + offsetLeft * 2, (int) offsetHeight
			+ offsetTop * 2);
}
 
Example 4
Project: EasyML   File: NodeShape.java   View source code 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 5
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 6
Project: appinventor-extensions   File: MockComponentsUtil.java   View source code 6 votes vote down vote up
/**
 * Sets the font typeface for the given widget.
 *
 * @param widget  widget to change font typeface for
 * @param typeface  "0" for normal, "1" for sans serif, "2" for serif and
 *                  "3" for monospace
 */
static void setWidgetFontTypeface(Widget widget, String typeface) {
  switch (Integer.parseInt(typeface)) {
    default:
      // This should never happen
      throw new IllegalArgumentException("Typeface:" + typeface);

    case 0:
    case 1:
      typeface = "sans-serif";
      break;

    case 2:
      typeface = "serif";
      break;

    case 3:
      typeface = "monospace";
      break;
  }
  DOM.setStyleAttribute(widget.getElement(), "fontFamily", typeface);
}
 
Example 7
Project: unitimes   File: ImageButton.java   View source code 6 votes vote down vote up
@Override
public void onBrowserEvent(Event event) {
	if (!isEnabled()) return;

	super.onBrowserEvent(event);

    if ((event.getTypeInt() & Event.KEYEVENTS) != 0) {
    	int type = DOM.eventGetType(event);
    	char keyCode = (char) event.getKeyCode();
    	switch (type) {
    	case Event.ONKEYDOWN:
    		if (keyCode == ' ' || keyCode == '\n' || keyCode == '\r') {
    			if (iDown != null) setResource(iDown);
    		}
    		break;
        case Event.ONKEYUP:
        	if (keyCode == ' ' || keyCode == '\n' || keyCode == '\r') {
        		setResource(iUp);
        		onClick();
        	}
        	break;
    	}
    }
}
 
Example 8
Project: appinventor-extensions   File: MockComponentsUtil.java   View source code 6 votes vote down vote up
/**
 * Sets the text alignment for the given widget.
 *
 * @param widget  widget to change text alignment for
 * @param align  one of "0" for left, "1" for center or "2" for right
 */
static void setWidgetTextAlign(Widget widget, String align) {
  switch (Integer.parseInt(align)) {
    default:
      // This should never happen
      throw new IllegalArgumentException("align:" + align);

    case 0:
      align = "left";
      break;

    case 1:
      align = "center";
      break;

    case 2:
      align = "right";
      break;
  }
  DOM.setStyleAttribute(widget.getElement(), "textAlign", align);
}
 
Example 9
Project: unitimes   File: FlowForm.java   View source code 6 votes vote down vote up
public int getCellForWidget(Widget w) {
	for (Element e = w.getElement(); e != null; e = DOM.getParent(e)) {
		if (e.getPropertyString("tagName").equalsIgnoreCase("span")) {
			if (DOM.getParent(e) == getElement())
				return DOM.getChildIndex(getElement(), e);
		}
		if (e == getElement()) { return -1; }
	}
	return -1;
}
 
Example 10
Project: unitimes   File: SimpleForm.java   View source code 6 votes vote down vote up
public int addRow(Widget header, Widget widget, int colSpan) {
	header.addStyleName("label-cell");
	int row = getRowCount();
	setWidget(row, 0, header);
	getCellFormatter().setStyleName(row, 0, "label-td");
	if (widget instanceof HasMobileScroll) {
		ScrollPanel scroll = new ScrollPanel(widget);
		scroll.addStyleName("table-cell");
		setWidget(row, 1, scroll);
		getCellFormatter().setStyleName(row, 1, "table-td");
	} else {
		widget.addStyleName("widget-cell");
		setWidget(row, 1, widget);
		getCellFormatter().setStyleName(row, 1, "widget-td");
	}
	if (colSpan != 1)
		getFlexCellFormatter().setColSpan(row, 1, colSpan);
	if (header.getElement().getId() == null || header.getElement().getId().isEmpty())
		header.getElement().setId(DOM.createUniqueId());
	if (widget instanceof UniTimeWidget)
		Roles.getTextboxRole().setAriaLabelledbyProperty(((UniTimeWidget)widget).getWidget().getElement(), Id.of(header.getElement()));
	else
		Roles.getTextboxRole().setAriaLabelledbyProperty(widget.getElement(), Id.of(header.getElement()));
	return row;
}
 
Example 11
Project: unitimes   File: HorizontalPanelWithHint.java   View source code 6 votes vote down vote up
public void onBrowserEvent(Event event) {
	int x = 10 + event.getClientX() + getElement().getOwnerDocument().getScrollLeft();
	int y = 10 + event.getClientY() + getElement().getOwnerDocument().getScrollTop();
	
	switch (DOM.eventGetType(event)) {
	case Event.ONMOUSEMOVE:
		if (iHint.isShowing()) {
			iHint.setPopupPosition(x, y);
		} else {
			iShowHint.cancel();
			iHint.setPopupPosition(x, y);
			iShowHint.schedule(1000);
		}
		break;
	case Event.ONMOUSEOUT:
		iShowHint.cancel();
		if (iHint.isShowing())
			iHideHint.schedule(1000);
		break;
	}
}
 
Example 12
Project: unitimes   File: SessionDatesSelector.java   View source code 6 votes vote down vote up
@Override
public void onBrowserEvent(Event event) {
	switch (DOM.eventGetType(event)) {
    case Event.ONMOUSEDOWN:
    	SelectionMode mode = null; 
    	for (SelectionMode m: SelectionMode.values())
    		if (hasUnselectedDays(m)) {
    			mode = m; break;
    		}
    	if (mode != null)
    		setAllSelected(true, mode);
    	else
    		setAllSelected(false, SelectionMode.All);
    	if (iCursor != null) iPanel.getWidget().setCursor(iCursor);
    	event.preventDefault();
    	break;
	}
	super.onBrowserEvent(event);
}
 
Example 13
Project: appinventor-extensions   File: MockButtonBase.java   View source code 6 votes vote down vote up
private void setImageProperty(String text) {
  imagePropValue = text;
  String url = convertImagePropertyValueToUrl(text);
  if (url == null) {
    hasImage = false;
    url = "";
    setBackgroundColorProperty(backgroundColor);
    setShapeProperty(Integer.toString(shape));
  } else {
    hasImage = true;
    // Android Buttons do not show a background color if they have an image.
    // The container's background color shows through any transparent
    // portions of the Image, an effect we can get in the browser by
    // setting the widget's background color to COLOR_NONE.
    MockComponentsUtil.setWidgetBackgroundColor(buttonWidget,
        "&H" + COLOR_NONE);
    DOM.setStyleAttribute(buttonWidget.getElement(), "borderRadius", "0px");
  }
  MockComponentsUtil.setWidgetBackgroundImage(buttonWidget, url);
  image.setUrl(url);
}
 
Example 14
Project: unitimes   File: InfoPanelImpl.java   View source code 6 votes vote down vote up
public void onBrowserEvent(Event event) {
	if (iHint.getText().isEmpty()) return;
	iX = 10 + event.getClientX() + getElement().getOwnerDocument().getScrollLeft();
	iY = 10 + event.getClientY() + getElement().getOwnerDocument().getScrollTop();
	
	switch (DOM.eventGetType(event)) {
	case Event.ONMOUSEMOVE:
		if (iInfoPanel.isShowing()) {
			int maxX = Window.getScrollLeft() + Window.getClientWidth() - iInfoPanel.getOffsetWidth() - 10;
			iInfoPanel.setPopupPosition(Math.min(iX, maxX), iY);
		} else if (iInfo.getRowCount() > 0) {
			iShowInfo.cancel();
			iShowInfo.schedule(1000);
		}
		break;
	case Event.ONMOUSEOUT:
		iShowInfo.cancel();
		if (iInfoPanel.isShowing())
			iHideInfo.schedule(1000);
		break;
	}
}
 
Example 15
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 16
Project: calendar-component   File: CalendarWeekDropHandler.java   View source code 6 votes vote down vote up
/**
 * Checks if the location is a valid drop location
 *
 * @param elementOver
 *            The element to check
 * @return
 */
private boolean isLocationValid(Element elementOver) {
    Element weekGridElement = calendarConnector.getWidget().getWeekGrid()
            .getElement();
    Element timeBarElement = calendarConnector.getWidget().getWeekGrid()
            .getTimeBar().getElement();

    Element todayBarElement = null;
    if (calendarConnector.getWidget().getWeekGrid().hasToday()) {
        todayBarElement = calendarConnector.getWidget().getWeekGrid()
                .getDateCellOfToday().getTodaybarElement();
    }

    // drops are not allowed in:
    // - weekday header
    // - allday event list
    // - todaybar
    // - timebar
    // - items
    return DOM.isOrHasChild(weekGridElement, elementOver)
            && !DOM.isOrHasChild(timeBarElement, elementOver)
            && todayBarElement != elementOver
            && (WidgetUtil.findWidget(elementOver,
                    DateCellDayItem.class) == null);
}
 
Example 17
Project: calendar-component   File: DateCell.java   View source code 6 votes vote down vote up
public void setToday(Date today, int width) {
    this.today = today;
    addStyleDependentName("today");
    Element lastChild = (Element) getElement().getLastChild();
    if (lastChild.getClassName().equals("v-calendar-current-time")) {
        todaybar = lastChild;
    } else {
        todaybar = DOM.createDiv();
        todaybar.setClassName("v-calendar-current-time");
        getElement().appendChild(todaybar);
    }

    if (width != -1) {
        todaybar.getStyle().setWidth(width, Unit.PX);
    }

    // position is calculated later, when we know the cell heights
}
 
Example 18
Project: appinventor-extensions   File: MockCanvas.java   View source code 6 votes vote down vote up
/**
 * Sets the canvas's BackgroundImage property to a new value.
 */
private void setBackgroundImageProperty(String text) {
  String url = convertImagePropertyValueToUrl(text);

  // We tell the layout (which is a MockCanvasLayout) that there is (or is not) a background
  // image so it can adjust the "layout width/height". The "layout width/height" is used when the
  // preferred width/height of a MockContainer is requested. See MockContainer.getPreferredWidth
  // and getPreferredHeight, as well as MockLayout.getPreferredWidth and getPreferredHeight.
  if (url == null) {
    // text was not recognized as an asset.
    ((MockCanvasLayout) layout).setBackgroundImageUrl("");
    url = "images/canvas.png";
    // We set the background image of the canvasWidget so it displays the image. We do it inside
    // the if because we need to override the background-size property only for this case
    MockComponentsUtil.setWidgetBackgroundImage(this, canvasWidget, url);
    DOM.setStyleAttribute(canvasWidget.getElement(), "backgroundSize", "");
  } else {
    ((MockCanvasLayout) layout).setBackgroundImageUrl(url);
    // We set the background image of the canvasWidget so it displays the image.
    MockComponentsUtil.setWidgetBackgroundImage(this, canvasWidget, url);
  }
}
 
Example 19
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 20
Project: appinventor-extensions   File: MockComponentsUtil.java   View source code 5 votes vote down vote up
/**
 * Sets the font size for the given widget.
 *
 * @param widget  widget to change font size for
 * @param size  new font size (in scaled px)
 */
static void setWidgetFontSize(Widget widget, String size) {
  // Fonts on Android are in scaled pixels...
  try {
    DOM.setStyleAttribute(widget.getElement(), "fontSize",
        (int)(Float.parseFloat(size) * 0.9) + "px");
  } catch (NumberFormatException e) {
    // Ignore this. If we throw an exception here, the project is unrecoverable.
  }
}
 
Example 21
Project: unitimes   File: CourseCurriculaTable.java   View source code 5 votes vote down vote up
public void onBrowserEvent(Event event) {
	Element td = getEventTargetCell(event);
	if (td==null) return;
    Element tr = DOM.getParent(td);
    Element body = DOM.getParent(tr);
    final int row = DOM.getChildIndex(body, tr);

    final ChainedCommand command = iRowClicks.get(row);
    
    switch (DOM.eventGetType(event)) {
	case Event.ONMOUSEOVER:
		getRowFormatter().setStyleName(row, "unitime-TableRowHover");
		if (command == null) getRowFormatter().getElement(row).getStyle().setCursor(Cursor.AUTO);
		break;
	case Event.ONMOUSEOUT:
		getRowFormatter().setStyleName(row, null);	
		break;
	case Event.ONCLICK:
		if (command == null) break;
		if (command.getLoadingMessage() != null)
			LoadingWidget.getInstance().show(command.getLoadingMessage());
		getRowFormatter().setStyleName(row, "unitime-TableRowSelected");
		iSelectedRow = row;
		command.execute(new ConditionalCommand() {
			@Override
			public void executeOnSuccess() {
				//getRowFormatter().setStyleName(row, null);	
				if (command.getLoadingMessage() != null)
					LoadingWidget.getInstance().hide();
			}
			@Override
			public void executeOnFailure() {
				getRowFormatter().setStyleName(row, "unitime-TableRowHover");	
				if (command.getLoadingMessage() != null)
					LoadingWidget.getInstance().hide();
			}
		});
		break;
	}
}
 
Example 22
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 23
Project: unitimes   File: ClickableHint.java   View source code 5 votes vote down vote up
@Override
public void onBrowserEvent(Event event) {
	super.onBrowserEvent(event);

    if ((event.getTypeInt() & Event.KEYEVENTS) != 0) {
    	int type = DOM.eventGetType(event);
    	char keyCode = (char) event.getKeyCode();
    	switch (type) {
        case Event.ONKEYUP:
        	if (keyCode == ' ' || keyCode == '\n' || keyCode == '\r')
        		onClick();
        	break;
    	}
    }
}
 
Example 24
Project: appinventor-extensions   File: MockHVLayoutBase.java   View source code 5 votes vote down vote up
private void ensureDividerInited() {
  if (dividerElement == null) {
    dividerElement = DOM.createDiv();
    DOM.setStyleAttribute(dividerElement, "backgroundColor", DIVIDER_COLOR);
    setDividerVisible(false);
    DOM.appendChild(container.getRootPanel().getElement(), dividerElement);
  }
}
 
Example 25
Project: unitimes   File: AriaTabBar.java   View source code 5 votes vote down vote up
@Override
protected void insertTabWidget(Widget widget, int beforeIndex) {
	super.insertTabWidget(widget, beforeIndex);
	Roles.getTabRole().setAriaSelectedState(getTabElement(beforeIndex), SelectedValue.FALSE);
	getTabElement(beforeIndex).setId(DOM.createUniqueId());
	Id ids[] = new Id[getTabCount()];
	for (int i = 0; i < getTabCount(); i++) {
		Roles.getTabRole().setAriaLabelProperty(getTabElement(i), ARIA.tabNotSelected(1 + i, getTabCount(), getTabLabel(i)));
		ids[i] = Id.of(getTabElement(i));
	}
	Roles.getTablistRole().setAriaOwnsProperty(getElement(), ids);
}
 
Example 26
Project: unitimes   File: Client.java   View source code 5 votes vote down vote up
public void onModuleLoadDeferred() {
	// register triggers
	GWT.runAsync(new RunAsyncCallback() {
		@Override
		public void onSuccess() {
			for (Triggers t: Triggers.values())
				t.register();
			callGwtOnLoadIfExists();
		}
		@Override
		public void onFailure(Throwable reason) {
		}
	});
	
	// load page
	if (RootPanel.get("UniTimeGWT:Body") != null) {
		LoadingWidget.getInstance().show(MESSAGES.waitLoadingPage());
		Scheduler.get().scheduleDeferred(new ScheduledCommand() {
			@Override
			public void execute() {
				initPageAsync(Window.Location.getParameter("page"));
			}
		});
	}
	
	// load components
	for (final Components c: Components.values()) {
		final RootPanel p = RootPanel.get(c.id());
		if (p != null) {
			Scheduler.get().scheduleDeferred(new ScheduledCommand() {
				@Override
				public void execute() {
					initComponentAsync(p, c);
				}
			});
		}
		if (p == null && c.isMultiple()) {
			NodeList<Element> x = getElementsByName(c.id());
			if (x != null && x.getLength() > 0)
				for (int i = 0; i < x.getLength(); i++) {
					Element e = x.getItem(i);
					e.setId(DOM.createUniqueId());
					final RootPanel q = RootPanel.get(e.getId());
					Scheduler.get().scheduleDeferred(new ScheduledCommand() {
						@Override
						public void execute() {
							initComponentAsync(q, c);
						}
					});
				}
		}
	}
	
	Window.addWindowClosingHandler(new Window.ClosingHandler() {
		@Override
		public void onWindowClosing(Window.ClosingEvent event) {
			if (isLoadingDisplayed() || LoadingWidget.getInstance().isShowing()) return;
			LoadingWidget.showLoading(MESSAGES.waitPlease());
			iPageLoadingTimer = new Timer() {
				@Override
				public void run() {
					RPC.execute(new IsSessionBusyRpcRequest(), new AsyncCallback<GwtRpcResponseBoolean>() {
						@Override
						public void onFailure(Throwable caught) {
							LoadingWidget.hideLoading();
						}
						@Override
						public void onSuccess(GwtRpcResponseBoolean result) {
							if (result.getValue()) {
								iPageLoadingTimer.schedule(500);
							} else {
								LoadingWidget.hideLoading();
							}
						}
					});
				}
			};
			iPageLoadingTimer.schedule(500);
		}
	});
}
 
Example 27
Project: unitimes   File: TravelTimes.java   View source code 5 votes vote down vote up
@Override
public void onBrowserEvent(Event event) {
	switch (DOM.eventGetType(event)) {
    case Event.ONMOUSEDOWN:
    	MouseDownEvent.fireNativeEvent(event, this);
    	event.stopPropagation();
    	event.preventDefault();
    	break;
	}
}
 
Example 28
Project: appinventor-extensions   File: MockHVLayoutBase.java   View source code 5 votes vote down vote up
private void setDividerBoundsAndShow(int x, int y, int width, int height) {
  DOM.setStyleAttribute(dividerElement, "position", "absolute");
  DOM.setStyleAttribute(dividerElement, "left", x + "px");
  DOM.setStyleAttribute(dividerElement, "top", y + "px");
  DOM.setStyleAttribute(dividerElement, "width", width + "px");
  DOM.setStyleAttribute(dividerElement, "height", height + "px");
  setDividerVisible(true);
}
 
Example 29
Project: unitimes   File: AssignedClassesPage.java   View source code 5 votes vote down vote up
protected void print() {
	final DataTable table = new DataTable(iLastResponse);
	Element headerRow = table.getRowFormatter().getElement(0);
	Element tableElement = table.getElement();
	Element thead = DOM.createTHead();
	tableElement.insertFirst(thead);
	headerRow.getParentElement().removeChild(headerRow);
	thead.appendChild(headerRow);
	Page page = new Page() {
		@Override
		public String getName() {
			return MESSAGES.sectAssignedClasses();
		}
		@Override
		public String getUser() {
			return "";
		}
		@Override
		public String getSession() {
			return "";
		}
		@Override
		public Element getBody() {
			return table.getElement();
		}
	};
	ToolBox.print(page);
}
 
Example 30
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 31
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 32
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 33
Project: unitimes   File: TimeSelector.java   View source code 5 votes vote down vote up
@Override
public void onBrowserEvent(Event event) {
	switch (DOM.eventGetType(event)) {
    case Event.ONBLUR:
    	BlurEvent.fireNativeEvent(event, this);
    	break;
    case Event.ONFOCUS:
    	FocusEvent.fireNativeEvent(event, this);
    	break;
	}
	super.onBrowserEvent(event);
}
 
Example 34
Project: unitimes   File: CourseFinderClasses.java   View source code 5 votes vote down vote up
public RoomsOrInstructors(List<String> list, String delimiter) {
	super("itemize");
	if (list != null)
		for (Iterator<String> i = list.iterator(); i.hasNext(); ) {
			P p = new P(DOM.createSpan(), "item");
			p.setText(i.next() + (i.hasNext() ? delimiter : ""));
			add(p);
		}
}
 
Example 35
Project: unitimes   File: UniTimeTableHeader.java   View source code 5 votes vote down vote up
@Override
public void onBrowserEvent(Event event) {
	switch (DOM.eventGetType(event)) {
	case Event.ONKEYPRESS:
		MenuItem item = iAccessKeys.get(Character.toLowerCase((char)event.getCharCode()));
		if (item != null) {
			event.stopPropagation();
			event.preventDefault();
			item.getScheduledCommand().execute();
		}
	}
	super.onBrowserEvent(event);
	
}
 
Example 36
Project: unitimes   File: UniTimeWidget.java   View source code 5 votes vote down vote up
@Override
public void setAriaLabel(String text) {
	if (iWidget instanceof HasAriaLabel) {
		((HasAriaLabel)iWidget).setAriaLabel(text);
	} else {
		if (iAriaLabel == null) {
			iAriaLabel = DOM.createLabel();
			iAriaLabel.setId(DOM.createUniqueId());
			iAriaLabel.setClassName("hidden-label");
			DOM.appendChild(getElement(), iAriaLabel);
			Roles.getCheckboxRole().setAriaLabelledbyProperty(iWidget.getElement(), Id.of(iAriaLabel));
		}
		iAriaLabel.setInnerText(text);
	}
}
 
Example 37
Project: appinventor-extensions   File: MockComponentsUtil.java   View source code 5 votes vote down vote up
static void restoreSizeStyle(Widget w, String[] style) {
  Element element = w.getElement();
  if (style[0] != null) {
    DOM.setStyleAttribute(element, "width", style[0]);
  }
  if (style[1] != null) {
    DOM.setStyleAttribute(element, "height", style[1]);
  }
}
 
Example 38
Project: unitimes   File: FreeTimePicker.java   View source code 5 votes vote down vote up
public void onBrowserEvent(Event event) {
	Element td = getEventTargetCell(event);
	if (td==null) return;
    Element tr = DOM.getParent(td);
    Element body = DOM.getParent(tr);
    int row = DOM.getChildIndex(body, tr);
    int col = DOM.getChildIndex(tr, td);
    if (row == 0 || col ==0) return;
    processMouseEvent(DOM.eventGetType(event), row - 1, col - 1);
}
 
Example 39
Project: unitimes   File: IntervalSelector.java   View source code 5 votes vote down vote up
@Override
public void onBrowserEvent(Event event) {
	switch (DOM.eventGetType(event)) {
    case Event.ONMOUSEDOWN:
    	MouseDownEvent.fireNativeEvent(event, this);
    	event.stopPropagation();
    	event.preventDefault();
    	break;
	}
}
 
Example 40
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;
    }
}