protected String getHref(IHelpResource res) { return (res instanceof ITopic) ? res.getHref() : null; }
public String getText(Object obj) { if (obj instanceof BookmarkManager) return Messages.BookmarksPart_savedTopics; if (obj instanceof IHelpResource) return ((IHelpResource) obj).getLabel(); return super.getText(obj); }
public String getText(Object obj) { if (obj instanceof IHelpResource) return ((IHelpResource) obj).getLabel(); return super.getText(obj); }
protected String getHref(IHelpResource res) { return res.getHref(); }
sbuf.append("\" indent=\"21\">"); //$NON-NLS-1$ sbuf.append("<a href=\""); //$NON-NLS-1$ sbuf.append(link.getHref()); String tcat = getTopicCategory(link.getHref(), locale); if (tcat != null && !Platform.getWS().equals(Platform.WS_GTK)) { sbuf.append("\" alt=\""); //$NON-NLS-1$ sbuf.append(parent.escapeSpecialChars(link.getLabel())); sbuf.append("</a>"); //$NON-NLS-1$ sbuf.append("</li>"); //$NON-NLS-1$
public int category(Object element) { if (element instanceof ISearchEngineResult) { ISearchEngineResult r = (ISearchEngineResult)element; IHelpResource c = r.getCategory(); if (c!=null) { String label = c.getLabel(); if (label.length()==0) return 10; return 5; } } return super.category(element); }
/** @deprecated */ @Deprecated @Override public void displayHelpResource(IHelpResource helpResource) { // convenience method - funnel through the real method displayHelpResource(helpResource.getHref()); }
IHelpResource cat = hit.getCategory(); if (part.getShowCategories() && cat != null && (oldCat == null || !oldCat.getLabel().equals(cat.getLabel()))) { buff.append("<p>"); //$NON-NLS-1$ if (cat.getHref() != null) { buff.append("<a bold=\"true\" href=\""); //$NON-NLS-1$ String absoluteHref = ""; //$NON-NLS-1$ if (cat.getHref().endsWith(".xml")) { //$NON-NLS-1$ absoluteHref = absoluteHref + CAT_HEADING_PREFIX; absoluteHref = absoluteHref + hit.toAbsoluteHref(cat.getHref(), true); buff.append(part.parent.escapeSpecialChars(absoluteHref)); buff.append("\">"); //$NON-NLS-1$ buff.append(cat.getLabel()); buff.append("</a>"); //$NON-NLS-1$ } else { buff.append("<b>"); //$NON-NLS-1$ buff.append(cat.getLabel()); buff.append("</b>"); //$NON-NLS-1$ if (hit.getCategory() != null && Platform.getWS() != Platform.WS_GTK) { buff.append(" alt=\""); //$NON-NLS-1$ buff.append(hit.getCategory().getLabel()); buff.append("\""); //$NON-NLS-1$
public String getText(Object obj) { if (obj instanceof IIndexEntry) return ((IIndexEntry) obj).getKeyword(); if (obj instanceof IHelpResource) return ((IHelpResource) obj).getLabel(); return super.getText(obj); }
public void mergeContext(IContext src) { String text = src.getText(); if (getText() == null || getText().length() == 0) { setText(text); } if (src instanceof IContext2 && getTitle() == null) { String title = ((IContext2)src).getTitle(); if (title != null) { setAttribute(ATTRIBUTE_TITLE, title); } } if (src instanceof IContext3) { ICommandLink[] commands = ((IContext3)src).getRelatedCommands(); for (int i=0;i<commands.length;++i) { appendChild(new CommandLink(commands[i])); } } IHelpResource[] topics = src.getRelatedTopics(); for (int i=0;i<topics.length;++i) { if (topics[i] instanceof ITopic) { appendChild(new Topic((ITopic)topics[i])); } else { Topic topic = new Topic(); topic.setHref(topics[i].getHref()); topic.setLabel(topics[i].getLabel()); appendChild(topic); } } }
/** * Measures the longest label of related links * * @param text * @return */ private int getLinksWidth(Description text) { int linkWidth = 0; IHelpResource relatedTopics[] = context.getRelatedTopics(); if (relatedTopics != null) { GC gc = new GC(text); for (int i = 0; i < relatedTopics.length; i++) { linkWidth = Math.max(linkWidth, gc.textExtent(relatedTopics[i] .getLabel()).x); } gc.dispose(); } return linkWidth; }
protected void doOpen(Object obj) { if (!(obj instanceof IHelpResource)) return; IHelpResource res = (IHelpResource) obj; if (res instanceof IToc || (res instanceof ITopic && ((ITopic) obj).getSubtopics().length > 0 && res .getHref() == null)) treeViewer.setExpandedState(obj, !treeViewer.getExpandedState(res)); if (res instanceof IToc) postUpdate(res); else if (res.getHref() != null) parent.showURL(res.getHref()); }
private Control createLink(Composite parent, IHelpResource topic) { Label image = new Label(parent, SWT.NONE); image.setImage(getImage()); image.setBackground(backgroundColour); GridData data = new GridData(); data.horizontalAlignment = GridData.HORIZONTAL_ALIGN_BEGINNING; data.verticalAlignment = GridData.VERTICAL_ALIGN_BEGINNING; //data.horizontalIndent = 4; image.setLayoutData(data); HyperlinkLabel link = new HyperlinkLabel(parent, SWT.NONE); link.setText(topic.getLabel()); link.setBackground(backgroundColour); link.setForeground(linkColour); link.setFont(parent.getFont()); linkManager.registerHyperlink(link, new LinkListener(topic)); return link; }
public boolean select(Viewer viewer, Object parentElement, Object element) { IHelpResource res = (IHelpResource) element; String href = res.getHref(); if (href == null) return true; return HelpBasePlugin.getActivitySupport().isEnabled(href); } }
public int compare(Viewer viewer, Object e1, Object e2) { int cat1 = category(e1); int cat2 = category(e2); if (cat1 != cat2) return cat1 - cat2; try { ISearchEngineResult r1 = (ISearchEngineResult) e1; ISearchEngineResult r2 = (ISearchEngineResult) e2; IHelpResource c1 = r1.getCategory(); IHelpResource c2 = r2.getCategory(); if (c1!=null && c2!=null) { int cat = super.compare(viewer, c1.getLabel(), c2.getLabel()); if (cat!=0) return cat; } float rank1 = ((ISearchEngineResult) e1).getScore(); float rank2 = ((ISearchEngineResult) e2).getScore(); if (rank1 - rank2 > 0) { return -1; } else if (rank1 == rank2) { return 0; } else { return 1; } } catch (Exception e) { } return super.compare(viewer, e1, e2); } }
private boolean isExcluded(String href, IHelpResource [] excludedTopics) { if (excludedTopics==null) return false; for (int i=0; i<excludedTopics.length; i++) { if (href.startsWith(excludedTopics[i].getHref())) return true; if (parent.isFilteredByRoles()) { if (!HelpBasePlugin.getActivitySupport().isEnabled(href)) return true; } } return false; }
private void updateStatus(IHelpResource res, boolean defaultToSelection) { if (defaultToSelection && res == null) { IStructuredSelection ssel = (IStructuredSelection) treeViewer .getSelection(); Object obj = ssel.getFirstElement(); if (obj instanceof IHelpResource) res = (IHelpResource) obj; } if (res != null) { String label = res.getLabel(); String href = getHref(res); HyperlinkTreePart.this.parent.handleLinkEntered(new HyperlinkEvent( treeViewer.getTree(), href, label, SWT.NULL)); } else { HyperlinkTreePart.this.parent.handleLinkExited(null); } }
protected void doOpen(Object obj) { if (obj instanceof IHelpResource) { parent.showURL(((IHelpResource) obj).getHref()); } else if (obj instanceof IIndexEntry) { IIndexEntry entry = (IIndexEntry) obj; if (getChildren(entry).length > 0) { treeViewer.setExpandedState(obj, !treeViewer.getExpandedState(obj)); } IHelpResource[] topics = entry.getTopics(); if (topics.length == 1) { parent.showURL(topics[0].getHref()); } } }