当前位置: 首页>>代码示例>>Java>>正文


Java IHyperlink类代码示例

本文整理汇总了Java中org.eclipse.jface.text.hyperlink.IHyperlink的典型用法代码示例。如果您正苦于以下问题:Java IHyperlink类的具体用法?Java IHyperlink怎么用?Java IHyperlink使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


IHyperlink类属于org.eclipse.jface.text.hyperlink包,在下文中一共展示了IHyperlink类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: detectHyperlinks

import org.eclipse.jface.text.hyperlink.IHyperlink; //导入依赖的package包/类
@Override
public IHyperlink[] detectHyperlinks(ITextViewer textViewer, IRegion region,
        boolean canShowMultipleHyperlinks) {
    SQLEditor editor = getAdapter(SQLEditor.class);
    PgDbParser parser = editor.getParser();

    int offset = region.getOffset();
    List<PgObjLocation> refs = parser.getObjsForEditor(editor.getEditorInput());
    for (PgObjLocation obj : refs) {
        if (offset > obj.getOffset()
                && offset < (obj.getOffset() + obj.getObjLength())) {
            IHyperlink[] links =  parser.getDefinitionsForObj(obj)
                    .map(def -> new SQLEditorHyperLink(
                            new Region(def.getOffset(), def.getObjLength()),
                            new Region(obj.getOffset(), obj.getObjLength()),
                            obj.getObjName(), def.getFilePath(), def.getLineNumber()))
                    .toArray(IHyperlink[]::new);
            if (links.length != 0) {
                return links;
            }
        }
    }
    return null;
}
 
开发者ID:pgcodekeeper,项目名称:pgcodekeeper,代码行数:25,代码来源:SQLEditorHyperLinkDetector.java

示例2: detectKspName

import org.eclipse.jface.text.hyperlink.IHyperlink; //导入依赖的package包/类
private IHyperlink[] detectKspName(String currentWord, IRegion targetRegion, FileRegion fileRegion) {

		/* Cherche la déclaration. */
		KspDeclaration kspDeclaration = KspManager.getInstance().findKspDeclarationByConstantCaseName(currentWord);
		if (kspDeclaration == null) {
			return null; // NOSONAR
		}

		/* Vérifie que le focus n'est pas déjà sur la déclaration. */
		if (fileRegion.equals(kspDeclaration.getFileRegion())) {
			return null; // NOSONAR
		}

		/* Renvoie un lien vers la déclaration. */
		return new IHyperlink[] { new KspDeclarationHyperLink(targetRegion, kspDeclaration) };
	}
 
开发者ID:sebez,项目名称:vertigo-chroma-kspplugin,代码行数:17,代码来源:KspNameHyperLinkDetector.java

示例3: handleFileLink

import org.eclipse.jface.text.hyperlink.IHyperlink; //导入依赖的package包/类
private IHyperlink[] handleFileLink(IRegion lineInfo, GradleHyperLinkResult result) {
	try {
		File folder = editorFile.getParentFile();
		String fileName = result.linkContent;
		
		File target = new File(folder, fileName); 
		if (!target.exists()) {
			target = new File(fileName);
		}
		if (!target.exists()) {
			return null;
		}

		IFileStore fileStore = EFS.getLocalFileSystem().getStore(target.toURI());
		if (fileStore==null){
			return null;
		}
		IRegion urlRegion = new Region(lineInfo.getOffset() + result.linkOffsetInLine, result.linkLength);
		GradleFileHyperlink	gradleFileHyperlink = new GradleFileHyperlink(urlRegion, fileStore);
		return new IHyperlink[] { gradleFileHyperlink };
	} catch (RuntimeException e) {
		return null;
	}
}
 
开发者ID:de-jcup,项目名称:egradle,代码行数:25,代码来源:GradleHyperlinkDetector.java

示例4: getHyperlinkDetectors

import org.eclipse.jface.text.hyperlink.IHyperlink; //导入依赖的package包/类
@Override
public IHyperlinkDetector[] getHyperlinkDetectors(ISourceViewer sourceViewer) {
	List<IHyperlinkDetector> detectors = new LinkedList<IHyperlinkDetector>();
	IHyperlinkDetector[] inheritedDetectors = super.getHyperlinkDetectors(sourceViewer);
	if (inheritedDetectors != null) {
		for (final IHyperlinkDetector detector : inheritedDetectors) {
			detectors.add(new IHyperlinkDetector() {
				public IHyperlink[] detectHyperlinks(ITextViewer textViewer, IRegion region,
						boolean canShowMultipleHyperlinks) {
					try {
						return detector.detectHyperlinks(textViewer, region, canShowMultipleHyperlinks);
					}
					catch (Throwable e) {
						// fail safe hyperlink detector - prevent others
						// from failing
					}
					return null;
				}

			});
		}
	}
	detectors.add(detector);
	return detectors.toArray(new IHyperlinkDetector[detectors.size()]);
}
 
开发者ID:cplutte,项目名称:bts,代码行数:26,代码来源:XtextSourceViewerConfiguration.java

示例5: execute

import org.eclipse.jface.text.hyperlink.IHyperlink; //导入依赖的package包/类
public Object execute(ExecutionEvent event) throws ExecutionException {
	XtextEditor xtextEditor = EditorUtils.getActiveXtextEditor(event);
	if (xtextEditor != null) {
		ITextSelection selection = (ITextSelection) xtextEditor.getSelectionProvider().getSelection();

		IRegion region = new Region(selection.getOffset(), selection.getLength());

		ISourceViewer internalSourceViewer = xtextEditor.getInternalSourceViewer();

		IHyperlink[] hyperlinks = getDetector().detectHyperlinks(internalSourceViewer, region, false);
		if (hyperlinks != null && hyperlinks.length > 0) {
			IHyperlink hyperlink = hyperlinks[0];
			hyperlink.open();
		}
	}		
	return null;
}
 
开发者ID:cplutte,项目名称:bts,代码行数:18,代码来源:OpenDeclarationHandler.java

示例6: createHyperlinksByOffset

import org.eclipse.jface.text.hyperlink.IHyperlink; //导入依赖的package包/类
@Override
public IHyperlink[] createHyperlinksByOffset(XtextResource resource,
		int offset, boolean createMultipleHyperlinks) {

	EObject eObject = helper.resolveElementAt(resource, offset);
	if (eObject instanceof StepDefinition || 
			eObject instanceof StaticParam || 
			eObject instanceof DynamicParam) {
		IParseResult parseResult = resource.getParseResult();
		INode node = NodeModelUtils.findLeafNodeAtOffset(
				parseResult.getRootNode(), offset);
		while (!(node instanceof CompositeNode && node.getSemanticElement() instanceof StepDefinition)) {
			node = node.getParent();
		}
		String description = StepUtil.getStepText(node);
		if (!openConceptDefinition(eObject, description)) {
			openStepDefinition(description);
		}
	}
	return null;
}
 
开发者ID:getgauge-contrib,项目名称:Gauge-Eclipse,代码行数:22,代码来源:SpecHyperlinkHelper.java

示例7: doDetect

import org.eclipse.jface.text.hyperlink.IHyperlink; //导入依赖的package包/类
@Override
protected IHyperlink[] doDetect(JsonDocument doc, ITextViewer viewer, HyperlinkInfo info, JsonPointer pointer) {
    Model model = doc.getModel();
    AbstractNode node = model.find(pointer);
    List<AbstractNode> nodes = model.findByType(JsonPointer.compile("/definitions/operation"));
    Iterator<AbstractNode> it = nodes.iterator();

    AbstractNode found = null;
    while (it.hasNext() && found == null) {
        AbstractNode current = it.next();
        AbstractNode value = current.get("operationId");

        if (value != null && Objects.equals(node.asValue().getValue(), value.asValue().getValue())) {
            found = value;
        }
    }

    if (found != null) {
        IRegion target = doc.getRegion(found.getPointer());
        if (target != null) {
            return new IHyperlink[] { new SwaggerHyperlink(info.text, viewer, info.region, target) };
        }
    }

    return null;
}
 
开发者ID:RepreZen,项目名称:KaiZen-OpenAPI-Editor,代码行数:27,代码来源:LinkOperationHyperlinkDetector.java

示例8: doDetect

import org.eclipse.jface.text.hyperlink.IHyperlink; //导入依赖的package包/类
@Override
protected IHyperlink[] doDetect(JsonDocument doc, ITextViewer viewer, HyperlinkInfo info, JsonPointer pointer) {
    Matcher matcher = PATTERN.matcher(pointer.toString());
    String link = matcher.find() ? matcher.group(1) : null;

    if (link != null) {
        Model model = doc.getModel();
        AbstractNode securityScheme = model.find("/components/securitySchemes/" + link);

        if (securityScheme != null) {
            IRegion target = doc.getRegion(securityScheme.getPointer());
            if (target != null) {
                return new IHyperlink[] { new SwaggerHyperlink(info.text, viewer, info.region, target) };
            }
        }
    }
    return null;
}
 
开发者ID:RepreZen,项目名称:KaiZen-OpenAPI-Editor,代码行数:19,代码来源:SecuritySchemeHyperlinkDetector.java

示例9: doDetect

import org.eclipse.jface.text.hyperlink.IHyperlink; //导入依赖的package包/类
@Override
protected IHyperlink[] doDetect(JsonDocument doc, ITextViewer viewer, HyperlinkInfo info, JsonPointer pointer) {
    JsonPointer targetPath;
    if (pointer.toString().matches(REQUIRED_PATTERN)) {
        targetPath = getRequiredPropertyPath(doc, info, pointer);
    } else {
        targetPath = getTagDefinitionPath(doc, info, pointer);
    }

    if (targetPath == null) {
        return null;
    }


    IRegion target = doc.getRegion(targetPath);
    if (target == null) {
        return null;
    }

    return new IHyperlink[] { new SwaggerHyperlink(info.text, viewer, info.region, target) };
}
 
开发者ID:RepreZen,项目名称:KaiZen-OpenAPI-Editor,代码行数:22,代码来源:DefinitionHyperlinkDetector.java

示例10: detectHyperlinks

import org.eclipse.jface.text.hyperlink.IHyperlink; //导入依赖的package包/类
@Override
public IHyperlink[] detectHyperlinks(ITextViewer textViewer, IRegion region, boolean canShowMultipleHyperlinks) {
    JsonDocument document = (JsonDocument) textViewer.getDocument();
    JsonPointer basePath = document.getPath(region);

    if (!canDetect(basePath)) {
        return null;
    }

    HyperlinkInfo info = getHyperlinkInfo(textViewer, region);
    if (info == null) {
        return null;
    }

    return doDetect(document, textViewer, info, basePath);
}
 
开发者ID:RepreZen,项目名称:KaiZen-OpenAPI-Editor,代码行数:17,代码来源:AbstractJsonHyperlinkDetector.java

示例11: detectHyperlinks

import org.eclipse.jface.text.hyperlink.IHyperlink; //导入依赖的package包/类
/**
 * detectHyperlinks
 * 
 * @param editor
 * @param region
 * @param canShowMultipleHyperlinks
 * @return
 */
public IHyperlink[] detectHyperlinks(AbstractThemeableEditor editor, IRegion region,
		boolean canShowMultipleHyperlinks)
{
	IHyperlink[] result = null;

	if (editor != null && region != null)
	{
		// grab AST
		IParseNode ast = editor.getAST();

		if (ast instanceof JSParseRootNode)
		{
			// gather links
			result = processAST(editor, (JSParseRootNode) ast, region.getOffset());
		}
	}

	if (!canShowMultipleHyperlinks && !ArrayUtil.isEmpty(result))
	{
		result = new IHyperlink[] { result[0] };
	}

	return result;
}
 
开发者ID:apicloudcom,项目名称:APICloud-Studio,代码行数:33,代码来源:JSHyperlinkDetector.java

示例12: run

import org.eclipse.jface.text.hyperlink.IHyperlink; //导入依赖的package包/类
/**
 * Open the declaration if possible.
 */
@Override
public void run()
{
	ITextEditor textEditor = getTextEditor();

	if (textEditor instanceof JSSourceEditor)
	{
		ITextSelection selection = (ITextSelection) textEditor.getSelectionProvider().getSelection();
		IRegion region = new Region(selection.getOffset(), 1);
		JSHyperlinkDetector detector = new JSHyperlinkDetector();
		IHyperlink[] hyperlinks = detector.detectHyperlinks((AbstractThemeableEditor) textEditor, region, true);

		if (!ArrayUtil.isEmpty(hyperlinks))
		{
			// give first link highest precedence
			hyperlinks[0].open();
		}
	}
}
 
开发者ID:apicloudcom,项目名称:APICloud-Studio,代码行数:23,代码来源:OpenDeclarationAction.java

示例13: createClassMethodLink

import org.eclipse.jface.text.hyperlink.IHyperlink; //导入依赖的package包/类
private IHyperlink createClassMethodLink(final IDocument document,
		final String elementValue, final IRegion elementRegion,
		final String className) {
	IHyperlink link = null;

	IType clazz = ProjectUtil.findClass(document, className);
	if (clazz != null) {
		IMethod method = ProjectUtil.findClassParameterlessMethod(clazz,
				elementValue);
		if (method != null) {
			link = new JavaElementHyperlink(elementRegion, method);
		}
	}

	return link;
}
 
开发者ID:aleksandr-m,项目名称:strutsclipse,代码行数:17,代码来源:StrutsXmlHyperlinkDetector.java

示例14: createPackageExtendsResourcesLink

import org.eclipse.jface.text.hyperlink.IHyperlink; //导入依赖的package包/类
private List<IHyperlink> createPackageExtendsResourcesLink(
		final IDocument document, final String elementValue,
		final IRegion elementRegion) {
	List<IHyperlink> links = new ArrayList<IHyperlink>();

	IPath currentPath = ProjectUtil.getCurrentDocumentPath(document);

	List<ResourceDocument> resources = ProjectUtil
			.findStrutsResources(document);
	for (ResourceDocument rd : resources) {
		if (!rd.getResource().getFullPath().equals(currentPath)) {
			IRegion nameRegion = strutsXmlParser.getPackageNameRegion(
					rd.getDocument(), elementValue);
			if (nameRegion != null) {
				if (rd.getResource().getType() == IResource.FILE
						&& rd.getResource().exists()) {
					links.add(new FileHyperlink(elementRegion, (IFile) rd
							.getResource(), nameRegion));
				}
			}
		}
	}

	return links;
}
 
开发者ID:aleksandr-m,项目名称:strutsclipse,代码行数:26,代码来源:StrutsXmlHyperlinkDetector.java

示例15: createPackageExtendsJarLinks

import org.eclipse.jface.text.hyperlink.IHyperlink; //导入依赖的package包/类
private List<IHyperlink> createPackageExtendsJarLinks(
		final IDocument document, final String elementValue,
		final IRegion elementRegion) {
	List<IHyperlink> links = new ArrayList<IHyperlink>();

	List<JarEntryStorage> jarStorages = ProjectUtil
			.findJarEntryStrutsResources(document);
	for (JarEntryStorage jarStorage : jarStorages) {
		IRegion nameRegion = strutsXmlParser.getPackageNameRegion(
				jarStorage.toDocument(), elementValue);
		if (nameRegion != null) {
			links.add(new StorageHyperlink(elementRegion, jarStorage,
					nameRegion));
		}
	}

	return links;
}
 
开发者ID:aleksandr-m,项目名称:strutsclipse,代码行数:19,代码来源:StrutsXmlHyperlinkDetector.java


注:本文中的org.eclipse.jface.text.hyperlink.IHyperlink类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。