Java Code Examples for com.google.gwt.user.client.DOM#getParent()

The following examples show how to use com.google.gwt.user.client.DOM#getParent() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: NodeShape.java    From EasyML with Apache License 2.0 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 2
Source File: NodeShape.java    From EasyML with Apache License 2.0 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 3
Source File: SimpleEditPage.java    From unitime with Apache License 2.0 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 4
Source File: ExtendedFlexTable.java    From document-management-system with GNU General Public License v2.0 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 5
Source File: ExtendedFlexTable.java    From document-management-system with GNU General Public License v2.0 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 6
Source File: ExtendedFlexTable.java    From document-management-system with GNU General Public License v2.0 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 7
Source File: ExtendedFlexTable.java    From document-management-system with GNU General Public License v2.0 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 8
Source File: UniTimeTable.java    From unitime with Apache License 2.0 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 9
Source File: FlowForm.java    From unitime with Apache License 2.0 5 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
Source File: FreeTimePicker.java    From unitime with Apache License 2.0 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 11
Source File: ExtendedFlexTable.java    From document-management-system with GNU General Public License v2.0 5 votes vote down vote up
public void onBrowserEvent(Event event) {
	int selectedRow = 0;

	if (DOM.eventGetType(event) == Event.ONDBLCLICK || DOM.eventGetType(event) == Event.ONMOUSEDOWN) {
		Element td = getMouseEventTargetCell(event);
		if (td == null) return;
		Element tr = DOM.getParent(td);
		Element body = DOM.getParent(tr);
		selectedRow = DOM.getChildIndex(body, tr);
	}

	// Only if selectedRow >= 0, indicates a document row value and must apear menu or double click action
	if (selectedRow >= 0) {

		// When de button mouse is released
		mouseX = DOM.eventGetClientX(event);
		mouseY = DOM.eventGetClientY(event);

		// On double click not sends event to onCellClicked across super.onBrowserEvent();
		if (DOM.eventGetType(event) == Event.ONDBLCLICK) {
			// Disables the event propagation the sequence is:
			// Two time entry onCellClicked before entry on onBrowserEvent and disbles the
			// Tree onCellClicked that produces inconsistence error refreshing
			DOM.eventCancelBubble(event, true);
			Main.get().mainPanel.search.historySearch.searchSaved.getSearch();

		} else if (DOM.eventGetType(event) == Event.ONMOUSEDOWN) {
			switch (DOM.eventGetButton(event)) {
				case Event.BUTTON_RIGHT:
					markSelectedRow(selectedRow);
					Main.get().mainPanel.search.historySearch.searchSaved.showMenu();
					DOM.eventPreventDefault(event); // Prevent to fire event to browser
					break;
				default:
					break;
			}
		}
	}
	super.onBrowserEvent(event);
}
 
Example 12
Source File: SimpleForm.java    From unitime with Apache License 2.0 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 13
Source File: CourseCurriculaTable.java    From unitime with Apache License 2.0 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 14
Source File: CurriculumProjectionRulesPage.java    From unitime with Apache License 2.0 4 votes vote down vote up
private void moveRow(Element tr, Element before) {
	Element body = DOM.getParent(tr);
	body.removeChild(tr);
	DOM.insertBefore(body, tr, before);
}
 
Example 15
Source File: CellPanel.java    From consulo with Apache License 2.0 4 votes vote down vote up
public Element getWidgetTd(Widget w) {
  if (w.getParent() != this) {
    return null;
  }
  return DOM.getParent(w.getElement());
}
 
Example 16
Source File: CurriculaCourses.java    From unitime with Apache License 2.0 4 votes vote down vote up
public CurriculaCourses() {
	iTable = new UniTimeTable<String>();
	iTable.addStyleName("unitime-CurriculaCourseProjections");
	initWidget(iTable);
	iCourseChangedHandler = new CourseSelectionHandler() {
		
		@Override
		public void onCourseSelection(CourseSelectionEvent event) {
			CurriculumStudentsInterface[] c = (iLastCourses == null ? null : iLastCourses.get(event.getCourse()));
			for (int col = 0; col < iClassifications.getClassifications().size(); col ++) {
				setEnrollmentAndLastLike(event.getCourse(), col,
						c == null || c[col] == null ? null : c[col].getEnrollment(), 
						c == null || c[col] == null ? null : c[col].getLastLike(),
						c == null || c[col] == null ? null : c[col].getProjection(),
						c == null || c[col] == null ? null : c[col].getRequested(),
						c == null || c[col] == null ? null : (!c[col].isSessionHasSnapshotData() ? null : c[col].getSnapshotProjection()));
			}
			Element td = ((Widget)event.getSource()).getElement();
			while (td != null && !td.getPropertyString("tagName").equalsIgnoreCase("td")) {
				td = DOM.getParent(td);
			}
			Element tr = DOM.getParent(td);
		    Element body = DOM.getParent(tr);
		    int row = DOM.getChildIndex(body, tr);
		    if (event.getCourse().isEmpty()) {
				iTable.getRowFormatter().addStyleName(row, "unitime-NoPrint");
		    } else {
				iTable.getRowFormatter().removeStyleName(row, "unitime-NoPrint");
		    }
		    if (row + 1 == iTable.getRowCount() && !event.getCourse().isEmpty())
				addBlankLine();
		}
	};
	
	iNewGroupDialog = new GroupDialogBox();
	
	iTable.setHintProvider(new HintProvider<String>() {
		@Override
		public Widget getHint(TableEvent<String> event) {
			if (!canShowStudentsTable(event.getRow())) return null;
			StudentsTable studentsTable = new StudentsTable(event.getRow());
			if (studentsTable.canShow()) return studentsTable;
			return null;
		}
	});
}
 
Example 17
Source File: ExtendedFlexTable.java    From document-management-system with GNU General Public License v2.0 4 votes vote down vote up
public void onBrowserEvent(Event event) {
	int selectedRow = 0;

	if (DOM.eventGetType(event) == Event.ONDBLCLICK || DOM.eventGetType(event) == Event.ONMOUSEDOWN) {
		Element td = getMouseEventTargetCell(event);
		if (td == null) return;
		Element tr = DOM.getParent(td);
		Element body = DOM.getParent(tr);
		selectedRow = DOM.getChildIndex(body, tr);
	}

	// Only if selectedRow >= 0, indicates a document row value and must apear menu or double click action
	if (selectedRow >= 0) {

		// When de button mouse is released
		mouseX = DOM.eventGetClientX(event);
		mouseY = DOM.eventGetClientY(event);

		// On double click not sends event to onCellClicked across super.onBrowserEvent();
		if (DOM.eventGetType(event) == Event.ONDBLCLICK) {
			// Disables the event propagation the sequence is:
			// Two time entry onCellClicked before entry on onBrowserEvent and disables the
			// Tree onCellClicked that produces inconsistence error refreshing
			DOM.eventCancelBubble(event, true);
			MessagingToolBarBox.get().messageDashboard.messageStack.proposedSubscriptionReceived.refreshProposedSubscriptions();

		} else if (DOM.eventGetType(event) == Event.ONMOUSEDOWN) {
			switch (DOM.eventGetButton(event)) {
				case Event.BUTTON_RIGHT:
					markSelectedRow(selectedRow);
					MessagingToolBarBox.get().messageDashboard.messageStack.proposedSubscriptionReceived.menuPopup.setPopupPosition(mouseX, mouseY);
					MessagingToolBarBox.get().messageDashboard.messageStack.proposedSubscriptionReceived.menuPopup.show();
					DOM.eventPreventDefault(event); // Prevent to fire event to browser
					break;
				default:
					break;
			}
		}
	}
	super.onBrowserEvent(event);
}
 
Example 18
Source File: ExtendedFlexTable.java    From document-management-system with GNU General Public License v2.0 4 votes vote down vote up
public void onBrowserEvent(Event event) {
	int selectedRow = 0;

	if (DOM.eventGetType(event) == Event.ONDBLCLICK || DOM.eventGetType(event) == Event.ONMOUSEDOWN) {
		Element td = getMouseEventTargetCell(event);
		if (td == null) return;
		Element tr = DOM.getParent(td);
		Element body = DOM.getParent(tr);
		selectedRow = DOM.getChildIndex(body, tr);
	}

	// Only if selectedRow >= 0, indicates a document row value and must apear menu or double click action
	if (selectedRow >= 0) {

		// When de button mouse is released
		mouseX = DOM.eventGetClientX(event);
		mouseY = DOM.eventGetClientY(event);

		// On double click not sends event to onCellClicked across super.onBrowserEvent();
		if (DOM.eventGetType(event) == Event.ONDBLCLICK) {
			// Disables the event propagation the sequence is:
			// Two time entry onCellClicked before entry on onBrowserEvent and disables the
			// Tree onCellClicked that produces inconsistence error refreshing
			DOM.eventCancelBubble(event, true);
			MessagingToolBarBox.get().messageDashboard.messageStack.proposedQueryReceived.refreshProposedQueries();

		} else if (DOM.eventGetType(event) == Event.ONMOUSEDOWN) {
			switch (DOM.eventGetButton(event)) {
				case Event.BUTTON_RIGHT:
					markSelectedRow(selectedRow);
					MessagingToolBarBox.get().messageDashboard.messageStack.proposedQueryReceived.menuPopup.setPopupPosition(mouseX, mouseY);
					MessagingToolBarBox.get().messageDashboard.messageStack.proposedQueryReceived.menuPopup.show();
					DOM.eventPreventDefault(event); // Prevent to fire event to browser
					break;
				default:
					break;
			}
		}
	}
	super.onBrowserEvent(event);
}
 
Example 19
Source File: TimeGrid.java    From unitime with Apache License 2.0 4 votes vote down vote up
public void onBrowserEvent(Event event) {
	if (iDummy) return;
    Element target = DOM.eventGetTarget(event);
    boolean anchor = false;
    for (; target != null; target = DOM.getParent(target)) {
    	String tag = target.getPropertyString("tagName");
    	if ("a".equalsIgnoreCase(tag)) {
    		anchor = true;
    		break;
    	} else if ("div".equalsIgnoreCase(tag)) {
    		break;
    	}
    }
	EventTarget related = event.getRelatedEventTarget();
    switch (DOM.eventGetType(event)) {
	case Event.ONCLICK:
		select(false);
		if (!anchor) {
			MeetingClickEvent e = new MeetingClickEvent(Meeting.this);
			for (MeetingClickHandler h: iMeetingClickHandlers)
				h.onMeetingClick(e);
		}
		break;
	case Event.ONMOUSEOVER:
        if (related == null || !getElement().isOrHasChild((Element)related.cast())) {
			select(true);
        }
		break;
	case Event.ONMOUSEOUT:
        if (related == null || !getElement().isOrHasChild((Element)related.cast())) {
        	select(false);
        }
		break;
	case Event.ONMOUSEMOVE:
		int relativeX = event.getClientX() - getElement().getAbsoluteLeft() + getElement().getScrollLeft() + getElement().getOwnerDocument().getScrollLeft();
		if (iRTL) relativeX = iCellWidth - relativeX;
		if (relativeX < iLeft - 6 - getDay() * iCellWidth || relativeX > iLeft - 2 - getDay() * iCellWidth + iWidth) {
			select(false);
		}
		break;
	}
    super.onBrowserEvent(event);
}
 
Example 20
Source File: ExtendedFlexTable.java    From document-management-system with GNU General Public License v2.0 4 votes vote down vote up
public void onBrowserEvent(Event event) {
	int selectedRow = 0;

	if (DOM.eventGetType(event) == Event.ONDBLCLICK || DOM.eventGetType(event) == Event.ONMOUSEDOWN) {
		Element td = getMouseEventTargetCell(event);
		if (td == null) return;
		Element tr = DOM.getParent(td);
		Element body = DOM.getParent(tr);
		selectedRow = DOM.getChildIndex(body, tr);
	}

	// Only if selectedRow >= 0, indicates a document row value and must apear menu or double click action
	if (selectedRow >= 0) {

		// When de button mouse is released
		mouseX = DOM.eventGetClientX(event);
		mouseY = DOM.eventGetClientY(event);

		// On double click not sends event to onCellClicked across super.onBrowserEvent();
		if (DOM.eventGetType(event) == Event.ONDBLCLICK) {
			// Disables the event propagation the sequence is:
			// Two time entry onCellClicked before entry on onBrowserEvent and disables the
			// Tree onCellClicked that produces inconsistence error refreshing
			DOM.eventCancelBubble(event, true);
			MessagingToolBarBox.get().messageDashboard.messageStack.messageReceived.refreshMessagesReceived();

		} else if (DOM.eventGetType(event) == Event.ONMOUSEDOWN) {
			switch (DOM.eventGetButton(event)) {
				case Event.BUTTON_RIGHT:
					markSelectedRow(selectedRow);
					MessagingToolBarBox.get().messageDashboard.messageStack.messageReceived.menuPopup.setPopupPosition(mouseX, mouseY);
					MessagingToolBarBox.get().messageDashboard.messageStack.messageReceived.menuPopup.show();
					DOM.eventPreventDefault(event); // Prevent to fire event to browser
					break;
				default:
					break;
			}
		}
	}
	super.onBrowserEvent(event);
}