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

The following examples show how to use com.google.gwt.dom.client.AnchorElement. These examples are extracted from open source projects. 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 Project: dashbuilder   Source File: TopMenuBar.java    License: 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 2
Source Project: dashbuilder   Source File: DisplayerHtmlEditorView.java    License: 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 3
Source Project: dashbuilder   Source File: SourceCodeEditorView.java    License: 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 4
Source Project: dashbuilder   Source File: NavTilesWidgetView.java    License: 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 5
Source Project: dashbuilder   Source File: NavComponentConfigModalView.java    License: 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 6
Source Project: dashbuilder   Source File: NavRootNodeEditorView.java    License: 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 7
Source Project: dashbuilder   Source File: TargetPerspectiveEditorView.java    License: 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 8
Source Project: dashbuilder   Source File: NavItemDefaultEditorView.java    License: 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 Project: dashbuilder   Source File: BaseNavWidgetView.java    License: 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 10
Source Project: dashbuilder   Source File: PerspectivesExplorerView.java    License: 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 11
@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 12
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 13
@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 14
@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 15
Source Project: mapper   Source File: TodoListMapper.java    License: 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 16
Source Project: gwt-material   Source File: FocusableMixin.java    License: 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 17
public Button() {
	super(AnchorElement.TAG);

	this.element = AnchorElement.as(this.getElement());
	this.endConstruct();
	this.setType(Type.DEFAULT);
}
 
Example 18
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 19
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 20
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 21
public void setLink(String link) {
	this.link = link;
	if (link == null) {
		this.getElement().removeAttribute("href");
	} else {
		AnchorElement.as(this.getElement()).setHref(link);
	}
}
 
Example 22
public void setTarget(String target) {
    this.target = target;
    if (target == null) {
        this.getElement().removeAttribute("target");
    } else {
        AnchorElement.as(this.getElement()).setTarget(target);
    }
}
 
Example 23
@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 24
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 25
Source Project: swellrt   Source File: AnchorPanel.java    License: 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 26
public Anchor() {
	super(AnchorElement.TAG);
	this.endConstruct();
}
 
Example 27
public void setLinkAsDummy() {
	AnchorElement.as(this.getElement()).setHref(AnchorUtils.DUMMY_HREF);
}
 
Example 28
Source Project: incubator-retired-wave   Source File: AnchorPanel.java    License: 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 29
Source Project: gwtbootstrap3-extras   Source File: GalleryImage.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public void setHref(String href) {
    AnchorElement.as(getElement()).setHref(href);
}
 
Example 30
Source Project: gwtbootstrap3-extras   Source File: GalleryImage.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public String getHref() {
    return AnchorElement.as(getElement()).getHref();
}