com.google.gwt.dom.client.AnchorElement Java Examples

The following examples show how to use com.google.gwt.dom.client.AnchorElement. 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: BaseNavWidgetView.java    From dashbuilder with Apache License 2.0 6 votes vote down vote up
@Override
public void addItem(String id, String name, String description, Command onItemSelected) {
    AnchorElement anchor = Document.get().createAnchorElement();
    anchor.setInnerText(name);
    if (description != null && !description.equals(name)) {
        anchor.setTitle(description);
    }

    LIElement li = Document.get().createLIElement();
    li.getStyle().setCursor(Style.Cursor.POINTER);
    li.appendChild(anchor);
    navWidget.appendChild((Node) li);
    itemMap.put(id, li);

    Event.sinkEvents(anchor, Event.ONCLICK);
    Event.setEventListener(anchor, event -> {
        if (Event.ONCLICK == event.getTypeInt()) {
            onItemSelected.execute();
        }
    });
}
 
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: OutputEmail.java    From putnami-web-toolkit with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public void edit(String value) {
	this.getElement().removeAllChildren();
	if (value != null) {
		AnchorElement anchor = Document.get().createAnchorElement();
		Icon icon = new Icon();
		icon.setType(IconFont.ICON_MAIL);
		StringBuffer sb = new StringBuffer();
		sb.append("mailto:").append(value);
		anchor.setHref(sb.toString());
		anchor.appendChild(icon.getElement());
		anchor.appendChild(Document.get().createTextNode(value));

		this.getElement().appendChild(anchor);
	}
}
 
Example #4
Source File: TodoListMapper.java    From mapper with Apache License 2.0 6 votes vote down vote up
private void setActive(final AnchorElement element, final UListElement active, final List<UListElement> allElements) {
  $(element).click(new Function() {
    @Override
    public boolean f(Event e) {
      $("a.inline").removeClass("selected");
      $(element).addClass("selected");
      for (UListElement otherElement : allElements) {
        if (otherElement != active) {
          $(otherElement).hide();
        }
      }
      $(active).show();
      return false;
    }
  });
}
 
Example #5
Source File: Button.java    From putnami-web-toolkit with GNU Lesser General Public License v3.0 6 votes vote down vote up
public Button(Button<T> source) {
	super(source);

	this.element = AnchorElement.as(this.getElement());
	this.endConstruct();

	this.setName(source.name);
	this.setText(source.text);
	this.setType(source.type);
	this.setIconType(source.iconType);
	this.setSize(source.size);
	this.setBlock(source.block);
	this.setDisabled(source.disabled);

	if (source.tabIndex != null) {
		this.setTabIndex(source.tabIndex);
	}
}
 
Example #6
Source File: PerspectiveDragConfigModalView.java    From dashbuilder with Apache License 2.0 6 votes vote down vote up
@Override
public void addItem(String name, Command onSelect) {
    AnchorElement anchor = Document.get().createAnchorElement();
    anchor.setInnerText(name);

    LIElement li = Document.get().createLIElement();
    li.getStyle().setCursor(Style.Cursor.POINTER);
    li.appendChild(anchor);
    selectorItems.appendChild((Node) li);

    Event.sinkEvents(anchor, Event.ONCLICK);
    Event.setEventListener(anchor, event -> {
        if(Event.ONCLICK == event.getTypeInt()) {
            onSelect.execute();
        }
    });
}
 
Example #7
Source File: PerspectivesExplorerView.java    From dashbuilder with Apache License 2.0 6 votes vote down vote up
@Override
public void addPerspective(String name, Command onClicked) {
    AnchorElement anchor = Document.get().createAnchorElement();
    anchor.getStyle().setCursor(Style.Cursor.POINTER);
    anchor.getStyle().setColor("black");
    anchor.getStyle().setProperty("fontSize", "larger");
    anchor.setInnerText(name);

    Event.sinkEvents(anchor, Event.ONCLICK);
    Event.setEventListener(anchor, event -> {
        if(Event.ONCLICK == event.getTypeInt()) {
            onClicked.execute();
        }
    });

    SpanElement icon = Document.get().createSpanElement();
    icon.getStyle().setMarginRight(10, Style.Unit.PX);
    icon.setClassName("pficon-virtual-machine");
    icon.getStyle().setProperty("fontSize", "larger");

    DivElement gi = createItemDiv(new Element[] {icon, anchor});
    perspectivesDiv.appendChild((Node) gi);
}
 
Example #8
Source File: NavItemDefaultEditorView.java    From dashbuilder with Apache License 2.0 6 votes vote down vote up
@Override
public void addCommand(String name, Command command) {
    AnchorElement anchor = Document.get().createAnchorElement();
    anchor.setInnerText(name);

    LIElement li = Document.get().createLIElement();
    li.getStyle().setCursor(Style.Cursor.POINTER);
    li.appendChild(anchor);
    commandMenu.appendChild((Node) li);

    Event.sinkEvents(anchor, Event.ONCLICK);
    Event.setEventListener(anchor, event -> {
        if(Event.ONCLICK == event.getTypeInt()) {
            command.execute();
        }
    });
}
 
Example #9
Source File: TargetPerspectiveEditorView.java    From dashbuilder with Apache License 2.0 6 votes vote down vote up
private void addItem(UnorderedList unorderedList, String name, boolean selected, Command onSelect) {
    AnchorElement anchor = Document.get().createAnchorElement();
    anchor.setInnerText(name);

    LIElement li = Document.get().createLIElement();
    li.getStyle().setCursor(Style.Cursor.POINTER);
    li.appendChild(anchor);
    li.setClassName(selected ? "selected" : "");
    unorderedList.appendChild((Node) li);

    Event.sinkEvents(anchor, Event.ONCLICK);
    Event.setEventListener(anchor, event -> {
        if(Event.ONCLICK == event.getTypeInt()) {
            onSelect.execute();
        }
    });
}
 
Example #10
Source File: NavRootNodeEditorView.java    From dashbuilder with Apache License 2.0 6 votes vote down vote up
@Override
public void addCommand(String name, Command command) {
    AnchorElement anchor = Document.get().createAnchorElement();
    anchor.setInnerText(name);

    LIElement li = Document.get().createLIElement();
    li.getStyle().setCursor(Style.Cursor.POINTER);
    li.appendChild(anchor);
    commandMenu.appendChild((Node) li);

    Event.sinkEvents(anchor, Event.ONCLICK);
    Event.setEventListener(anchor, event -> {
        if(Event.ONCLICK == event.getTypeInt()) {
            command.execute();
        }
    });
}
 
Example #11
Source File: NavComponentConfigModalView.java    From dashbuilder with Apache License 2.0 6 votes vote down vote up
private void addItem(UnorderedList unorderedList, String name, boolean selected, Command onSelect) {
    AnchorElement anchor = Document.get().createAnchorElement();
    anchor.setInnerText(name);

    LIElement li = Document.get().createLIElement();
    li.getStyle().setCursor(Style.Cursor.POINTER);
    li.appendChild(anchor);
    li.setClassName(selected ? "selected" : "");
    unorderedList.appendChild((Node) li);

    Event.sinkEvents(anchor, Event.ONCLICK);
    Event.setEventListener(anchor, event -> {
        if(Event.ONCLICK == event.getTypeInt()) {
            onSelect.execute();
        }
    });
}
 
Example #12
Source File: NavTilesWidgetView.java    From dashbuilder with Apache License 2.0 6 votes vote down vote up
@Override
public void addBreadcrumbItem(String navItemName, Command onClicked) {
    LIElement li = Document.get().createLIElement();
    breadcrumb.appendChild((Node) li);

    if (onClicked != null) {
        AnchorElement anchor = Document.get().createAnchorElement();
        anchor.setInnerText(navItemName);
        li.appendChild(anchor);
        li.getStyle().setCursor(Style.Cursor.POINTER);

        Event.sinkEvents(anchor, Event.ONCLICK);
        Event.setEventListener(anchor, event -> {
            if (Event.ONCLICK == event.getTypeInt()) {
                onClicked.execute();
            }
        });
    } else {
        ((Node) li).setTextContent(navItemName);
        li.setClassName("active");
    }
}
 
Example #13
Source File: SourceCodeEditorView.java    From dashbuilder with Apache License 2.0 6 votes vote down vote up
@Override
public void declareVariable(String var, String description) {

    SpanElement span = Document.get().createSpanElement();
    span.setInnerText(var);

    AnchorElement anchor = Document.get().createAnchorElement();
    anchor.setTitle(description);
    anchor.appendChild(span);

    LIElement li = Document.get().createLIElement();
    li.getStyle().setCursor(Style.Cursor.POINTER);
    li.appendChild(anchor);

    variablesMenu.appendChild((Node) li);

    Event.sinkEvents(anchor, Event.ONCLICK);
    Event.setEventListener(anchor, event -> {
        if(Event.ONCLICK == event.getTypeInt()) {
            presenter.onVariableSelected(var);
        }
    });
}
 
Example #14
Source File: DisplayerHtmlEditorView.java    From dashbuilder with Apache License 2.0 6 votes vote down vote up
@Override
public void addSourceCodeItem(String name) {
    AnchorElement anchor = Document.get().createAnchorElement();
    String displayName = DisplayerHtmlConstants.INSTANCE.getString("displayer_source_code_" + name);
    anchor.setInnerText(displayName);

    LIElement li = Document.get().createLIElement();
    li.getStyle().setCursor(Style.Cursor.POINTER);
    li.appendChild(anchor);
    tabList.appendChild((Node) li);

    Event.sinkEvents(anchor, Event.ONCLICK);
    Event.setEventListener(anchor, event -> {
        if(Event.ONCLICK == event.getTypeInt()) {
            presenter.onSourceCodeItemSelected(name);
            if (selectedItem != null) {
                selectedItem.setClassName("");
                selectedItem.getStyle().setCursor(Style.Cursor.POINTER);
            }
            selectedItem = li;
            selectedItem.setClassName("active");
            selectedItem.getStyle().setCursor(Style.Cursor.DEFAULT);
            previewItem.setClassName("");
        }
    });
}
 
Example #15
Source File: TopMenuBar.java    From dashbuilder with Apache License 2.0 6 votes vote down vote up
private void addEntry(String entry, boolean logout) {
    AnchorElement anchor = Document.get().createAnchorElement();
    anchor.setInnerText(entry);

    Event.sinkEvents(anchor, Event.ONCLICK);
    Event.setEventListener(anchor, event -> {
        if (Event.ONCLICK == event.getTypeInt()) {
            if (!logout) {
                onRoleClicked(entry);
            } else {
                onLogoutClicked();
            }
        }
    });

    LIElement li = Document.get().createLIElement();
    li.getStyle().setCursor(Style.Cursor.POINTER);
    li.appendChild(anchor);
    roleList.appendChild((Node) li);
}
 
Example #16
Source File: Button.java    From putnami-web-toolkit with GNU Lesser General Public License v3.0 5 votes vote down vote up
public Button() {
	super(AnchorElement.TAG);

	this.element = AnchorElement.as(this.getElement());
	this.endConstruct();
	this.setType(Type.DEFAULT);
}
 
Example #17
Source File: Anchor.java    From putnami-web-toolkit with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public void edit(T value) {
	this.value = value;
       if (this.link == null) {
           if (this.value instanceof String) {
               AnchorElement.as(this.getElement()).setHref((String) this.value);
           } else {
               setLinkAsDummy();
           }
       }
}
 
Example #18
Source File: Anchor.java    From putnami-web-toolkit with GNU Lesser General Public License v3.0 5 votes vote down vote up
public void setTarget(String target) {
    this.target = target;
    if (target == null) {
        this.getElement().removeAttribute("target");
    } else {
        AnchorElement.as(this.getElement()).setTarget(target);
    }
}
 
Example #19
Source File: Anchor.java    From putnami-web-toolkit with GNU Lesser General Public License v3.0 5 votes vote down vote up
public void setLink(String link) {
	this.link = link;
	if (link == null) {
		this.getElement().removeAttribute("href");
	} else {
		AnchorElement.as(this.getElement()).setHref(link);
	}
}
 
Example #20
Source File: ContentAssistAspect.java    From putnami-web-toolkit with GNU Lesser General Public License v3.0 5 votes vote down vote up
SuggestionItem(Oracle.Suggestion<T> suggestion, String displayedValue) {
	this.setElement(Document.get().createLIElement());
	this.suggestion = suggestion;
	AnchorElement anchor = Document.get().createAnchorElement();
	anchor.setHref(AnchorUtils.DUMMY_HREF);
	anchor.setInnerHTML(displayedValue);
	this.getElement().appendChild(anchor);
}
 
Example #21
Source File: Pagination.java    From putnami-web-toolkit with GNU Lesser General Public License v3.0 5 votes vote down vote up
NavigationPage(boolean previous) {
	this.previous = previous;
	this.setElement(Document.get().createLIElement());
	this.addDomHandler(this, ClickEvent.getType());
	AnchorElement anchor = Document.get().createAnchorElement();
	anchor.setHref(AnchorUtils.DUMMY_HREF);
	anchor.setInnerHTML(previous ? "&laquo;" : "&raquo;");
	this.getElement().appendChild(anchor);
	StyleUtils.addStyle(this, previous ? Pagination.PREVIOUS_STYLE : Pagination.NEXT_STYLE);
}
 
Example #22
Source File: Pagination.java    From putnami-web-toolkit with GNU Lesser General Public License v3.0 5 votes vote down vote up
Page(String label, int page) {
	this.setElement(Document.get().createLIElement());
	this.page = page;
	if (Pagination.this.currentPage == page) {
		StyleUtils.addStyle(this, Pagination.STYLE_ACTIVE);
	} else {
		this.addDomHandler(this, ClickEvent.getType());
	}
	AnchorElement anchor = Document.get().createAnchorElement();
	anchor.setHref(AnchorUtils.DUMMY_HREF);
	anchor.setInnerText(label);
	this.getElement().appendChild(anchor);
}
 
Example #23
Source File: Navbar.java    From putnami-web-toolkit with GNU Lesser General Public License v3.0 5 votes vote down vote up
NavbarButton() {
	this.setElement(Document.get().createAnchorElement());
	StyleUtils.addStyle(this, Navbar.STYLE_TOGGLE);
	StyleUtils.addStyle(this, Navbar.STYLE_TEXT_MUTED);
	AnchorElement.as(this.getElement()).setHref(AnchorUtils.DUMMY_HREF);
	this.getElement().appendChild(this.createIcon());
}
 
Example #24
Source File: FocusableMixin.java    From gwt-material with Apache License 2.0 5 votes vote down vote up
@Override
public void setAccessKey(final char key) {
    final Element element = uiObject.getElement();
    final String accessKey = Character.toString(key);

    if (AnchorElement.is(element)) {
        AnchorElement.as(element).setAccessKey(accessKey);
    } else if (ButtonElement.is(element)) {
        ButtonElement.as(element).setAccessKey(accessKey);
    } else if (InputElement.is(element)) {
        InputElement.as(element).setAccessKey(accessKey);
    }
}
 
Example #25
Source File: GalleryImage.java    From gwtbootstrap3-extras with Apache License 2.0 4 votes vote down vote up
@Override
public void setHref(String href) {
    AnchorElement.as(getElement()).setHref(href);
}
 
Example #26
Source File: GalleryImage.java    From gwtbootstrap3-extras with Apache License 2.0 4 votes vote down vote up
@Override
public String getHref() {
    return AnchorElement.as(getElement()).getHref();
}
 
Example #27
Source File: AnchorPanel.java    From incubator-retired-wave with Apache License 2.0 4 votes vote down vote up
/**
 * Create a new anchor panel
 */
public AnchorPanel() {
  super(Document.get().createAnchorElement());
  anchor = (AnchorElement)getElement().cast();
}
 
Example #28
Source File: Anchor.java    From putnami-web-toolkit with GNU Lesser General Public License v3.0 4 votes vote down vote up
public void setLinkAsDummy() {
	AnchorElement.as(this.getElement()).setHref(AnchorUtils.DUMMY_HREF);
}
 
Example #29
Source File: Anchor.java    From putnami-web-toolkit with GNU Lesser General Public License v3.0 4 votes vote down vote up
public Anchor() {
	super(AnchorElement.TAG);
	this.endConstruct();
}
 
Example #30
Source File: AnchorPanel.java    From swellrt with Apache License 2.0 4 votes vote down vote up
/**
 * Create a new anchor panel
 */
public AnchorPanel() {
  super(Document.get().createAnchorElement());
  anchor = (AnchorElement)getElement().cast();
}