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


Java ISourceViewer类代码示例

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


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

示例1: getPresentationReconciler

import org.eclipse.jface.text.source.ISourceViewer; //导入依赖的package包/类
@Override
public IPresentationReconciler getPresentationReconciler(ISourceViewer sourceViewer) {
	PresentationReconciler reconciler = new PresentationReconciler();

	addDefaultPresentation(reconciler);

	addPresentation(reconciler, JAVA_KEYWORD.getId(), getPreferences().getColor(COLOR_JAVA_KEYWORD), SWT.BOLD);
	addPresentation(reconciler, GROOVY_KEYWORD.getId(), getPreferences().getColor(COLOR_GROOVY_KEYWORD), SWT.BOLD);
	// Groovy provides different strings: simple and GStrings, so we use
	// separate colors:
	addPresentation(reconciler, STRING.getId(), getPreferences().getColor(COLOR_NORMAL_STRING), SWT.NONE);
	addPresentation(reconciler, GSTRING.getId(), getPreferences().getColor(COLOR_GSTRING), SWT.NONE);

	addPresentation(reconciler, COMMENT.getId(), getPreferences().getColor(COLOR_COMMENT), SWT.NONE);
	addPresentation(reconciler, ANNOTATION.getId(), getPreferences().getColor(COLOR_ANNOTATION), SWT.NONE);
	addPresentation(reconciler, GROOVY_DOC.getId(), getPreferences().getColor(COLOR_GROOVY_DOC), SWT.NONE);
	addPresentation(reconciler, JENKINS_KEYWORD.getId(), getPreferences().getColor(COLOR_JENKINS_KEYWORDS),
			SWT.BOLD);

	addPresentation(reconciler, JENKINS_VARIABLE.getId(), getPreferences().getColor(COLOR_JENKINS_VARIABLES),
			SWT.ITALIC);
	addPresentation(reconciler, JAVA_LITERAL.getId(), getPreferences().getColor(COLOR_JAVA_LITERAL), SWT.BOLD);
	return reconciler;
}
 
开发者ID:de-jcup,项目名称:eclipse-jenkins-editor,代码行数:25,代码来源:JenkinsSourceViewerConfiguration.java

示例2: getPresentationReconciler

import org.eclipse.jface.text.source.ISourceViewer; //导入依赖的package包/类
@Override
public IPresentationReconciler getPresentationReconciler(ISourceViewer sourceViewer) {

	/* Créé un Reconsilier chargé de gérer les changements du document. */
	PresentationReconciler reconciler = new PresentationReconciler();

	/* Définition du nom du partitionnement effectué par KspDocumentSetupParticipant. */
	reconciler.setDocumentPartitioning(KspRegionType.PARTITIONING);

	/* Définition des scanners pour chacune des trois partitions. */
	setRepairer(reconciler, commentScanner, KspRegionType.COMMENT.getContentType());
	setRepairer(reconciler, stringScanner, KspRegionType.STRING.getContentType());
	setRepairer(reconciler, defaultScanner, KspRegionType.DEFAULT.getContentType());

	return reconciler;
}
 
开发者ID:sebez,项目名称:vertigo-chroma-kspplugin,代码行数:17,代码来源:KspSourceViewerConfiguration.java

示例3: hasProblem

import org.eclipse.jface.text.source.ISourceViewer; //导入依赖的package包/类
/***
 * Returns true if it exists a marker annotation in the given offset and false
 * otherwise.
 *
 * @param textViewer
 * @param offset
 * @return true if it exists a marker annotation in the given offset and false
 *         otherwise.
 */
private static boolean hasProblem(ITextViewer textViewer, int offset) {
	if (!(textViewer instanceof ISourceViewer)) {
		return false;
	}

	IAnnotationModel annotationModel = ((ISourceViewer) textViewer).getAnnotationModel();
	Iterator<Annotation> iter = (annotationModel instanceof IAnnotationModelExtension2)
			? ((IAnnotationModelExtension2) annotationModel).getAnnotationIterator(offset, 1, true, true)
			: annotationModel.getAnnotationIterator();
	while (iter.hasNext()) {
		Annotation ann = iter.next();
		if (ann instanceof MarkerAnnotation) {
			return true;
		}
	}
	return false;
}
 
开发者ID:angelozerr,项目名称:ec4e,代码行数:27,代码来源:EditorConfigTextHover.java

示例4: setFocusToElement

import org.eclipse.jface.text.source.ISourceViewer; //导入依赖的package包/类
/**
 * @param nclElement
 */
public void setFocusToElement(NCLElement nclElement) {
	int line = nclElement.getLineNumber();
	int lineOffset, lineLength;
	ISourceViewer viewer = getSourceViewer();
	try {
		lineOffset = viewer.getDocument().getLineOffset(line);
		lineLength = viewer.getDocument().getLineLength(line);

		// Move cursor to new position
		resetHighlightRange();
		setHighlightRange(lineOffset, lineLength, true);
		setFocus();
	} catch (BadLocationException e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
	}
}
 
开发者ID:ncleclipse,项目名称:ncl30-eclipse,代码行数:21,代码来源:NCLEditor.java

示例5: getContentAssistant

import org.eclipse.jface.text.source.ISourceViewer; //导入依赖的package包/类
@Override
public IContentAssistant getContentAssistant(ISourceViewer sourceViewer) {
	ContentAssistant assistant = new ContentAssistant();
	IContentAssistProcessor processor = new EiffelContentAssistantProcessor();
	assistant.setContentAssistProcessor(processor, IDocument.DEFAULT_CONTENT_TYPE);
	assistant.setInformationControlCreator(getInformationControlCreator(sourceViewer));
	
	assistant.setDocumentPartitioning(getConfiguredDocumentPartitioning(sourceViewer));
	assistant.setContentAssistProcessor(new EiffelContentAssistantProcessor(),
			IDocument.DEFAULT_CONTENT_TYPE);
	
	assistant.setAutoActivationDelay(100);
	assistant.enableAutoActivation(true);
	assistant.enableAutoInsert(true);
	
	assistant.setProposalSelectorBackground(Display.getDefault().getSystemColor(SWT.COLOR_WHITE));
	
	return assistant;
}
 
开发者ID:Imhotup,项目名称:LibertyEiffel-Eclipse-Plugin,代码行数:20,代码来源:EiffelSourceViewerConfiguration.java

示例6: computeHighlightRange

import org.eclipse.jface.text.source.ISourceViewer; //导入依赖的package包/类
/**
 * Computes and returns the source reference that includes the caret and serves as provider for the
 * outline pageModel selection and the editor range indication.
 *
 * @return the computed source reference
 */
public ISourceReference computeHighlightRange() {
	ISourceViewer sourceViewer = getSourceViewer();
	if (sourceViewer == null) return null;

	StyledText styledText = sourceViewer.getTextWidget();
	if (styledText == null) return null;

	int caret = 0;
	if (sourceViewer instanceof ITextViewerExtension5) {
		ITextViewerExtension5 extension = (ITextViewerExtension5) sourceViewer;
		caret = extension.widgetOffset2ModelOffset(styledText.getSelection().x);
	} else {
		int offset = sourceViewer.getVisibleRegion().getOffset();
		caret = offset + styledText.getSelection().x;
	}

	PagePart part = getPagePartAt(caret, false);
	return (ISourceReference) part;
}
 
开发者ID:grosenberg,项目名称:fluentmark,代码行数:26,代码来源:FluentMkEditor.java

示例7: setType

import org.eclipse.jface.text.source.ISourceViewer; //导入依赖的package包/类
/**
 * Checks the type of the word wrap and activates the correct type.
 */
private void setType() {
    String wrapStyle = TexlipsePlugin.getPreference(TexlipseProperties.WORDWRAP_TYPE);
    ISourceViewer viewer = getTextEditor() != null ? getTextEditor().getViewer() : null;
    if (wrapStyle.equals(TexlipseProperties.WORDWRAP_TYPE_SOFT)) {
        TexAutoIndentStrategy.setHardWrap(false);
        if (viewer != null) {
            viewer.getTextWidget().setWordWrap(true);
        }
    } else if (wrapStyle.equals(TexlipseProperties.WORDWRAP_TYPE_HARD)) {
        TexAutoIndentStrategy.setHardWrap(true);
        if (viewer != null) {
            viewer.getTextWidget().setWordWrap(false);
        }
    }
}
 
开发者ID:eclipse,项目名称:texlipse,代码行数:19,代码来源:TexWordWrapAction.java

示例8: getContentFormatter

import org.eclipse.jface.text.source.ISourceViewer; //导入依赖的package包/类
public IContentFormatter getContentFormatter( ISourceViewer sourceViewer){
    ContentFormatter formatter = new ContentFormatter();
    XMLFormattingStrategy formattingStrategy = new XMLFormattingStrategy();
    DefaultFormattingStrategy defaultStrategy = new DefaultFormattingStrategy();
    TextFormattingStrategy textStrategy = new TextFormattingStrategy();
    DocTypeFormattingStrategy doctypeStrategy = new DocTypeFormattingStrategy();
    PIFormattingStrategy piStrategy = new PIFormattingStrategy();
    formatter.setFormattingStrategy(defaultStrategy,
            IDocument.DEFAULT_CONTENT_TYPE);
    formatter.setFormattingStrategy(textStrategy,
            XMLPartitionScanner.XML_TEXT);
    formatter.setFormattingStrategy(doctypeStrategy,
            XMLPartitionScanner.XML_DOCTYPE);
    formatter.setFormattingStrategy(piStrategy, XMLPartitionScanner.XML_PI);
    formatter.setFormattingStrategy(textStrategy,
            XMLPartitionScanner.XML_CDATA);
    formatter.setFormattingStrategy(formattingStrategy,
            XMLPartitionScanner.XML_START_TAG);
    formatter.setFormattingStrategy(formattingStrategy,
            XMLPartitionScanner.XML_END_TAG);
    
    return formatter;
}
 
开发者ID:nextinterfaces,项目名称:http4e,代码行数:24,代码来源:XMLConfiguration.java

示例9: getQuickFixes

import org.eclipse.jface.text.source.ISourceViewer; //导入依赖的package包/类
private List<de.darwinspl.preferences.resource.dwprofile.IDwprofileQuickFix> getQuickFixes(ISourceViewer sourceViewer, int offset, int length) {
	List<de.darwinspl.preferences.resource.dwprofile.IDwprofileQuickFix> foundFixes = new ArrayList<de.darwinspl.preferences.resource.dwprofile.IDwprofileQuickFix>();
	IAnnotationModel model = annotationModelProvider.getAnnotationModel();
	
	if (model == null) {
		return foundFixes;
	}
	
	Iterator<?> iter = model.getAnnotationIterator();
	while (iter.hasNext()) {
		Annotation annotation = (Annotation) iter.next();
		Position position = model.getPosition(annotation);
		if (offset >= 0) {
			if (!position.overlapsWith(offset, length)) {
				continue;
			}
		}
		Collection<de.darwinspl.preferences.resource.dwprofile.IDwprofileQuickFix> quickFixes = getQuickFixes(annotation);
		if (quickFixes != null) {
			foundFixes.addAll(quickFixes);
		}
	}
	return foundFixes;
}
 
开发者ID:DarwinSPL,项目名称:DarwinSPL,代码行数:25,代码来源:DwprofileQuickAssistProcessor.java

示例10: MkReconcilingStrategy

import org.eclipse.jface.text.source.ISourceViewer; //导入依赖的package包/类
/**
 * Creates a new Dsl reconciling strategy.
 * 
 * @param viewer the source viewer
 * @param editor the editor of the strategy's reconciler
 * @param documentPartitioning the document partitioning this strategy uses for configuration
 */
public MkReconcilingStrategy(ISourceViewer viewer, ITextEditor editor, String documentPartitioning) {
	this.viewer = viewer;
	this.editor = editor;
	this.store = FluentMkUI.getDefault().getPreferenceStore();
	setReconcilingStrategies(getReconcilingStrategies());

	// TODO: figure out how to dispose
	this.store.addPropertyChangeListener(new IPropertyChangeListener() {

		@Override
		public void propertyChange(PropertyChangeEvent event) {
			if (event.getProperty().equals(Prefs.SPELLING_ENABLED)) {
				setReconcilingStrategies(getReconcilingStrategies());
			}
		}
	});
}
 
开发者ID:grosenberg,项目名称:fluentmark,代码行数:25,代码来源:MkReconcilingStrategy.java

示例11: computeQuickAssistProposals

import org.eclipse.jface.text.source.ISourceViewer; //导入依赖的package包/类
public ICompletionProposal[] computeQuickAssistProposals(IQuickAssistInvocationContext invocationContext) {
	ISourceViewer sourceViewer = invocationContext.getSourceViewer();
	int offset = -1;
	int length = 0;
	if (invocationContext instanceof TextInvocationContext) {
		TextInvocationContext textContext = (TextInvocationContext) invocationContext;
		offset = textContext.getOffset();
		length = textContext.getLength();
	}
	List<eu.hyvar.feature.expression.resource.hyexpression.IHyexpressionQuickFix> quickFixes = getQuickFixes(sourceViewer, offset, length);
	ICompletionProposal[] proposals = new ICompletionProposal[quickFixes.size()];
	for (int i = 0; i < proposals.length; i++) {
		proposals[i] = createCompletionProposal(sourceViewer, quickFixes.get(i));
	}
	return proposals;
}
 
开发者ID:DarwinSPL,项目名称:DarwinSPL,代码行数:17,代码来源:HyexpressionQuickAssistProcessor.java

示例12: getQuickFixes

import org.eclipse.jface.text.source.ISourceViewer; //导入依赖的package包/类
private List<eu.hyvar.feature.mapping.resource.hymapping.IHymappingQuickFix> getQuickFixes(ISourceViewer sourceViewer, int offset, int length) {
	List<eu.hyvar.feature.mapping.resource.hymapping.IHymappingQuickFix> foundFixes = new ArrayList<eu.hyvar.feature.mapping.resource.hymapping.IHymappingQuickFix>();
	IAnnotationModel model = annotationModelProvider.getAnnotationModel();
	
	if (model == null) {
		return foundFixes;
	}
	
	Iterator<?> iter = model.getAnnotationIterator();
	while (iter.hasNext()) {
		Annotation annotation = (Annotation) iter.next();
		Position position = model.getPosition(annotation);
		if (offset >= 0) {
			if (!position.overlapsWith(offset, length)) {
				continue;
			}
		}
		Collection<eu.hyvar.feature.mapping.resource.hymapping.IHymappingQuickFix> quickFixes = getQuickFixes(annotation);
		if (quickFixes != null) {
			foundFixes.addAll(quickFixes);
		}
	}
	return foundFixes;
}
 
开发者ID:DarwinSPL,项目名称:DarwinSPL,代码行数:25,代码来源:HymappingQuickAssistProcessor.java

示例13: createContentAssistActionHandler

import org.eclipse.jface.text.source.ISourceViewer; //导入依赖的package包/类
private ActionHandler createContentAssistActionHandler(
		final ITextOperationTarget textOperationTarget) {
	Action proposalAction = new Action() {
		@Override
		public void run() {
			if (textOperationTarget
					.canDoOperation(ISourceViewer.CONTENTASSIST_PROPOSALS)
					&& getTextWidget().isFocusControl())
				textOperationTarget
						.doOperation(ISourceViewer.CONTENTASSIST_PROPOSALS);
		}
	};
	proposalAction
			.setActionDefinitionId(ITextEditorActionDefinitionIds.CONTENT_ASSIST_PROPOSALS);
	return new ActionHandler(proposalAction);
}
 
开发者ID:cchabanois,项目名称:mesfavoris,代码行数:17,代码来源:SpellcheckableMessageArea.java

示例14: getQuickFixes

import org.eclipse.jface.text.source.ISourceViewer; //导入依赖的package包/类
private List<eu.hyvar.context.contextValidity.resource.hyvalidityformula.IHyvalidityformulaQuickFix> getQuickFixes(ISourceViewer sourceViewer, int offset, int length) {
	List<eu.hyvar.context.contextValidity.resource.hyvalidityformula.IHyvalidityformulaQuickFix> foundFixes = new ArrayList<eu.hyvar.context.contextValidity.resource.hyvalidityformula.IHyvalidityformulaQuickFix>();
	IAnnotationModel model = annotationModelProvider.getAnnotationModel();
	
	if (model == null) {
		return foundFixes;
	}
	
	Iterator<?> iter = model.getAnnotationIterator();
	while (iter.hasNext()) {
		Annotation annotation = (Annotation) iter.next();
		Position position = model.getPosition(annotation);
		if (offset >= 0) {
			if (!position.overlapsWith(offset, length)) {
				continue;
			}
		}
		Collection<eu.hyvar.context.contextValidity.resource.hyvalidityformula.IHyvalidityformulaQuickFix> quickFixes = getQuickFixes(annotation);
		if (quickFixes != null) {
			foundFixes.addAll(quickFixes);
		}
	}
	return foundFixes;
}
 
开发者ID:DarwinSPL,项目名称:DarwinSPL,代码行数:25,代码来源:HyvalidityformulaQuickAssistProcessor.java

示例15: getQuickFixes

import org.eclipse.jface.text.source.ISourceViewer; //导入依赖的package包/类
private List<eu.hyvar.dataValues.resource.hydatavalue.IHydatavalueQuickFix> getQuickFixes(ISourceViewer sourceViewer, int offset, int length) {
	List<eu.hyvar.dataValues.resource.hydatavalue.IHydatavalueQuickFix> foundFixes = new ArrayList<eu.hyvar.dataValues.resource.hydatavalue.IHydatavalueQuickFix>();
	IAnnotationModel model = annotationModelProvider.getAnnotationModel();
	
	if (model == null) {
		return foundFixes;
	}
	
	Iterator<?> iter = model.getAnnotationIterator();
	while (iter.hasNext()) {
		Annotation annotation = (Annotation) iter.next();
		Position position = model.getPosition(annotation);
		if (offset >= 0) {
			if (!position.overlapsWith(offset, length)) {
				continue;
			}
		}
		Collection<eu.hyvar.dataValues.resource.hydatavalue.IHydatavalueQuickFix> quickFixes = getQuickFixes(annotation);
		if (quickFixes != null) {
			foundFixes.addAll(quickFixes);
		}
	}
	return foundFixes;
}
 
开发者ID:DarwinSPL,项目名称:DarwinSPL,代码行数:25,代码来源:HydatavalueQuickAssistProcessor.java


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