Java Code Examples for com.google.gwt.dom.client.Element#insertFirst()

The following examples show how to use com.google.gwt.dom.client.Element#insertFirst() . 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: ImplPanel.java    From swellrt with Apache License 2.0 6 votes vote down vote up
/**
 * Inserts a widget into this panel, attaching its HTML to a specified
 * location within this panel's HTML.
 * <p>
 * Note that in order for this panel to have arbitrary HTML decorations,
 * rather than none at all, this panel must not care about the logical order
 * of its child widgets (an inherited restriction from ComplexPanel, which
 * assumes logical child index == physical DOM index).
 * <p>
 * Assumes (but does not check) that {@code container} is a descendant of this
 * widget's element, and that {@code reference} is a direct child of {@code
 * container}.
 *
 * @param child
 * @param container
 * @param reference
 */
public void insertAfter(Widget child, Element container, Element reference) {
  // The implementation below is identical to add(), except the physical DOM
  // insertion is positional.

  // Detach new child.
  child.removeFromParent();

  // Logical attach.
  getChildren().add(child);

  // Physical attach.
  if (reference == null) {
    container.insertFirst(child.getElement());
  } else {
    container.insertAfter(child.getElement(), reference);
  }

  // Adopt.
  adopt(child);
}
 
Example 2
Source File: BreadcrumbLink.java    From putnami-web-toolkit with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public void redraw() {
	StyleUtils.toggleStyle(this, LinkStyle.ACTIVE, this.active);
	Element elem = getElement();
	elem.removeAllChildren();
	if (!active) {
		elem = Document.get().createAnchorElement();
		getElement().appendChild(elem);
		if (this.link != null) {
			AnchorElement.as(elem).setHref(this.link);
		}
	}

	if (this.label != null) {
		elem.setInnerHTML(this.label);
	}
	if (this.iconType != null) {
		Icon icon = new Icon();
		icon.setType(this.iconType);
		elem.insertFirst(icon.getElement());
	}
}
 
Example 3
Source File: ImplPanel.java    From incubator-retired-wave with Apache License 2.0 6 votes vote down vote up
/**
 * Inserts a widget into this panel, attaching its HTML to a specified
 * location within this panel's HTML.
 * <p>
 * Note that in order for this panel to have arbitrary HTML decorations,
 * rather than none at all, this panel must not care about the logical order
 * of its child widgets (an inherited restriction from ComplexPanel, which
 * assumes logical child index == physical DOM index).
 * <p>
 * Assumes (but does not check) that {@code container} is a descendant of this
 * widget's element, and that {@code reference} is a direct child of {@code
 * container}.
 *
 * @param child
 * @param container
 * @param reference
 */
public void insertAfter(Widget child, Element container, Element reference) {
  // The implementation below is identical to add(), except the physical DOM
  // insertion is positional.

  // Detach new child.
  child.removeFromParent();

  // Logical attach.
  getChildren().add(child);

  // Physical attach.
  if (reference == null) {
    container.insertFirst(child.getElement());
  } else {
    container.insertAfter(child.getElement(), reference);
  }

  // Adopt.
  adopt(child);
}
 
Example 4
Source File: VComboBoxMultiselect.java    From vaadin-combobox-multiselect with Apache License 2.0 5 votes vote down vote up
/**
 * Default constructor
 */
SuggestionPopup() {
	super(true, false);
	debug("VComboBoxMultiselect.SP: constructor()");
	setOwner(VComboBoxMultiselect.this);
	this.menu = new SuggestionMenu();
	setWidget(this.menu);

	getElement().getStyle()
		.setZIndex(Z_INDEX);

	final Element root = getContainerElement();

	this.up.setInnerHTML("<span>Prev</span>");
	DOM.sinkEvents(this.up, Event.ONCLICK);

	this.down.setInnerHTML("<span>Next</span>");
	DOM.sinkEvents(this.down, Event.ONCLICK);

	root.insertFirst(this.up);
	root.appendChild(this.down);
	root.appendChild(this.status);

	DOM.sinkEvents(root, Event.ONMOUSEDOWN | Event.ONMOUSEWHEEL);
	addCloseHandler(this);

	Roles.getListRole()
		.set(getElement());

	setPreviewingAllNativeEvents(true);
}
 
Example 5
Source File: VComboBoxMultiselect.java    From vaadin-combobox-multiselect with Apache License 2.0 5 votes vote down vote up
/**
 * Default constructor
 */
SuggestionPopup() {
	super(true, false);
	debug("VComboBoxMultiselect.SP: constructor()");
	setOwner(VComboBoxMultiselect.this);
	this.menu = new SuggestionMenu();
	setWidget(this.menu);

	getElement().getStyle()
		.setZIndex(Z_INDEX);

	final Element root = getContainerElement();

	this.up.setInnerHTML("<span>Prev</span>");
	DOM.sinkEvents(this.up, Event.ONCLICK);

	this.down.setInnerHTML("<span>Next</span>");
	DOM.sinkEvents(this.down, Event.ONCLICK);

	root.insertFirst(this.up);
	root.appendChild(this.down);
	root.appendChild(this.status);

	DOM.sinkEvents(root, Event.ONMOUSEDOWN | Event.ONMOUSEWHEEL);
	addCloseHandler(this);

	Roles.getListRole()
		.set(getElement());

	setPreviewingAllNativeEvents(true);
}
 
Example 6
Source File: SolutionReportsPage.java    From unitime with Apache License 2.0 5 votes vote down vote up
protected void print(final TableInterface data) {
	final DataTable table = new DataTable(data);
	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 data.getName();
		}
		@Override
		public String getUser() {
			return "";
		}
		@Override
		public String getSession() {
			return "";
		}
		@Override
		public Element getBody() {
			return table.getElement();
		}
	};
	ToolBox.print(page);
}
 
Example 7
Source File: SolutionChangesPage.java    From unitime with Apache License 2.0 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.sectSolutionChanges();
		}
		@Override
		public String getUser() {
			return "";
		}
		@Override
		public String getSession() {
			return "";
		}
		@Override
		public Element getBody() {
			return table.getElement();
		}
	};
	ToolBox.print(page);
}
 
Example 8
Source File: NotAssignedClassesPage.java    From unitime with Apache License 2.0 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.sectNotAssignedClasses();
		}
		@Override
		public String getUser() {
			return "";
		}
		@Override
		public String getSession() {
			return "";
		}
		@Override
		public Element getBody() {
			return table.getElement();
		}
	};
	ToolBox.print(page);
}
 
Example 9
Source File: AssignedClassesPage.java    From unitime with Apache License 2.0 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 10
Source File: AssignmentHistoryPage.java    From unitime with Apache License 2.0 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.sectAssignmentHistory();
		}
		@Override
		public String getUser() {
			return "";
		}
		@Override
		public String getSession() {
			return "";
		}
		@Override
		public Element getBody() {
			return table.getElement();
		}
	};
	ToolBox.print(page);
}
 
Example 11
Source File: DomViewHelper.java    From swellrt with Apache License 2.0 5 votes vote down vote up
public static void attachAfter(Element container, Element ref, Element target) {
  Preconditions.checkArgument(ref == null || ref.getParentElement().equals(container));
  Preconditions.checkArgument(target.getParentElement() == null);
  if (ref == null) {
    container.insertFirst(target);
  } else {
    container.insertAfter(target, ref);
  }
}
 
Example 12
Source File: DomViewHelper.java    From incubator-retired-wave with Apache License 2.0 5 votes vote down vote up
public static void attachAfter(Element container, Element ref, Element target) {
  Preconditions.checkArgument(ref == null || ref.getParentElement().equals(container));
  Preconditions.checkArgument(target.getParentElement() == null);
  if (ref == null) {
    container.insertFirst(target);
  } else {
    container.insertAfter(target, ref);
  }
}