本文整理匯總了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;
}
示例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;
}
示例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;
}
示例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();
}
}
示例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;
}
示例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;
}
示例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);
}
}
}
示例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;
}
示例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;
}
示例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());
}
}
});
}
示例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;
}
示例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;
}
示例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);
}
示例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;
}
示例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;
}