@Override @SuppressWarnings("deprecation") public void onBrowserEvent(Context context, Element parent, InlineHyperlink value, NativeEvent nativeEvent, ValueUpdater<InlineHyperlink> valueUpdater) { super.onBrowserEvent(context, parent, value, nativeEvent, valueUpdater); Event event = Event.as(nativeEvent); if(DOM.eventGetType(event) == Event.ONCLICK && impl.handleAsClick(event)) { Element target = Element.as(event.getEventTarget()); Element child = parent.getFirstChildElement(); if(child.isOrHasChild(target)) { History.newItem(value.getTargetHistoryToken()); DOM.eventPreventDefault(event); } } }
/** * Generate breadcrumbs into the specified container using the format link > link > text where the * last breadcrumb is always plain text. */ private void generateBreadcrumbs(Panel container, List<Title> titles) { container.clear(); // For all of the titles previous to the last, add a link and a separator. for (Title notLast : titles.subList(0, titles.size() - 1)) { container.add(new InlineHyperlink(notLast.getTitle(), notLast.getFragment())); container.add(new InlineLabel(" > ")); } // Append only the text for the last title. Title lastTitle = Iterables.getLast(titles); container.add(new InlineLabel(lastTitle.getTitle())); if (lastTitle.getSubtitle() != null) { Label subtitle = new InlineLabel(" - " + lastTitle.getSubtitle()); subtitle.addStyleName(style.methodSubtitle()); container.add(subtitle); } }
@Override public InlineHyperlink getValue(CuratorAction action) { Term term = getTerm(action.getEntity()); return term != null ? new InlineHyperlink(term.getName(), term.getReferenceId()) : null; }
@Override public void initBreadcrumbs(int breadcrumbSize, String _heading) { breadCrumbPanel.setVisible(true); breadcrumbs.clear(); heading.setHTML("<h1>" + _heading + "</h1>"); for (int i = 0; i < breadcrumbSize; ++i) { if (i > 0) { breadcrumbs.add(new InlineLabel(" > ")); } breadcrumbs.add(new InlineHyperlink("Loading title...", placeManager.buildRelativeHistoryToken(i + 1))); } }
@Override public void setBreadcrumbs(int index, String title) { InlineHyperlink hyperlink = (InlineHyperlink) breadcrumbs.getWidget(index * 2); if (title == null) { hyperlink.setHTML("Unknown title"); } else { hyperlink.setHTML(title); } }
@Override public void render(Context context, InlineHyperlink h, SafeHtmlBuilder sb) { if(h != null) { sb.append(SafeHtmlUtils.fromTrustedString(h.toString())); } }
@Override public InlineHyperlink getValue(Term term) { return new InlineHyperlink(term.getName(), term.getReferenceId()); }
@Override public InlineHyperlink getValue(Relationship relationship) { Term term = relationship.getTerm(); return new InlineHyperlink(term.getName(), term.getReferenceId()); }
@Override public InlineHyperlink getValue(Relationship relationship) { Term term = relationship.getRelatedTerm(); return new InlineHyperlink(term.getName(), term.getReferenceId()); }
@Override public void onSearch(SearchEvent event) { final String pattern = event.getPattern(); final Object source = event.getSource(); lastPattern = pattern; if(source != null && busyIndicator == null && source instanceof Widget) { busyIndicator = new WidgetBusyIndicatorHandler((Widget)source, "busy-icon-left", "error-icon-left"); } if(pattern != null && pattern.length() > 1) { if(busyIndicator != null) { busyIndicator.busy(); } service.search(pattern, searchOptions.includeSynonyms(), new AsyncCallback<List<HTMLSearchResult>>() { public void onFailure(Throwable caught) { ul.clear(); if(busyIndicator != null) { busyIndicator.idle(); } if(caught instanceof InvalidQuerySyntaxException) { if(busyIndicator != null) { busyIndicator.error(); } } else { GWT.log("Failed to load search results", caught); ErrorView.instance().onUncaughtException(caught); } } public void onSuccess(List<HTMLSearchResult> results) { if (pattern == lastPattern) { String filterByOntology = searchOptions.filterByOntology(); ul.clear(); for (HTMLSearchResult result : results) { if(filterByOntology == null || filterByOntology.equals(result.getOntology())) { ListItem li = new ListItem(); InlineHyperlink hyperlink = new InlineHyperlink( SafeHtmlUtils.fromTrustedString(result.getHtml()), result.getReferenceId()); li.add(hyperlink); if(filterByOntology == null) { InlineLabel ontology = new InlineLabel(result.getOntology()); ontology.addStyleName("search-result-tag"); li.add(ontology); } if(result.isSynonym()) { InlineLabel synonym = new InlineLabel("synonym"); synonym.addStyleName("search-result-tag"); li.add(synonym); } ul.add(li); } } } else { GWT.log("Ignoring results from previous search: " + pattern); } if(busyIndicator != null) { busyIndicator.idle(); } } }); } else { ul.clear(); } }
@Override public InlineHyperlink getValue(Synonym synonym) { Term term = synonym.getTerm(); return new InlineHyperlink(term.getName(), term.getReferenceId()); }
@Override public Widget generateAnchor(String embeddingText, String fragment) { return new InlineHyperlink(embeddingText, fragment); }