當前位置: 首頁>>代碼示例>>Java>>正文


Java ISourceViewer.getDocument方法代碼示例

本文整理匯總了Java中org.eclipse.jface.text.source.ISourceViewer.getDocument方法的典型用法代碼示例。如果您正苦於以下問題:Java ISourceViewer.getDocument方法的具體用法?Java ISourceViewer.getDocument怎麽用?Java ISourceViewer.getDocument使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.eclipse.jface.text.source.ISourceViewer的用法示例。


在下文中一共展示了ISourceViewer.getDocument方法的11個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getHoverInfo

import org.eclipse.jface.text.source.ISourceViewer; //導入方法依賴的package包/類
public String getHoverInfo( ISourceViewer sourceViewer, int lineNumber){
    IDocument document = sourceViewer.getDocument();        
    try {
        IRegion info = document.getLineInformation(lineNumber);
        return document.get(info.getOffset(), info.getLength());
    } catch (BadLocationException x) {
    }
    return null;
}
 
開發者ID:nextinterfaces,項目名稱:http4e,代碼行數:10,代碼來源:MyAnnotationHover.java

示例2: getHoverInfo

import org.eclipse.jface.text.source.ISourceViewer; //導入方法依賴的package包/類
/**
 * Find a problem marker from the given line and return its error message.
 * 
 * @param sourceViewer the source viewer
 * @param lineNumber line number in the file, starting from zero
 * @return the message of the marker of null, if no marker at the specified line
 */
public String getHoverInfo(ISourceViewer sourceViewer, int lineNumber) {
    IDocument document= sourceViewer.getDocument();
    IAnnotationModel model= sourceViewer.getAnnotationModel();
    
    if (model == null)
        return null;
    
    List<String> lineMarkers = null;

    Iterator<Annotation> e= model.getAnnotationIterator();
    while (e.hasNext()) {
        Annotation o= e.next();
        if (o instanceof MarkerAnnotation) {
            MarkerAnnotation a= (MarkerAnnotation) o;
            if (isRulerLine(model.getPosition(a), document, lineNumber)) {
                if (lineMarkers == null)
                    lineMarkers = new LinkedList<String>();
                lineMarkers.add(a.getMarker().getAttribute(IMarker.MESSAGE, null));
            }
        }
    }
    if (lineMarkers != null)
        return getMessage(lineMarkers);
    
    return null;
}
 
開發者ID:eclipse,項目名稱:texlipse,代碼行數:34,代碼來源:TexAnnotationHover.java

示例3: getHoverInfo

import org.eclipse.jface.text.source.ISourceViewer; //導入方法依賴的package包/類
public String getHoverInfo(ISourceViewer sourceViewer, int lineNumber)
    {
        IDocument document = sourceViewer.getDocument();

        /*
        try
        {
            IRegion info = document.getLineInformation(lineNumber);
            return "This is an annotation for: " + document.get(info.getOffset(), info.getLength());
        } catch (BadLocationException x)
        {
        }
*/
        return null;
    }
 
開發者ID:tlaplus,項目名稱:tlaplus,代碼行數:16,代碼來源:TLAAnnotationHover.java

示例4: getReconciler

import org.eclipse.jface.text.source.ISourceViewer; //導入方法依賴的package包/類
public IReconciler getReconciler(final ISourceViewer sourceViewer) {
	if (fPreferenceStore == null || !fPreferenceStore.getBoolean(SpellingService.PREFERENCE_SPELLING_ENABLED)) {
		return null;
	}
	
	SpellingService spellingService = EditorsUI.getSpellingService();
	if (spellingService.getActiveSpellingEngineDescriptor(fPreferenceStore) == null) {
		return null;
	}
	
	IReconcilingStrategy strategy = new SpellingReconcileStrategy(sourceViewer, spellingService) {
		
		@Override
		protected ISpellingProblemCollector createSpellingProblemCollector() {
			final ISpellingProblemCollector collector = super.createSpellingProblemCollector();
			
			return new ISpellingProblemCollector() {
				
				public void accept(SpellingProblem problem) {
					int offset = problem.getOffset();
					int length = problem.getLength();
					if (sourceViewer == null) {
						return;
					}
					IDocument document = sourceViewer.getDocument();
					if (document == null) {
						return;
					}
					String text;
					try {
						text = document.get(offset, length);
					} catch (BadLocationException e) {
						return;
					}
					if (new de.darwinspl.preferences.resource.dwprofile.ui.DwprofileIgnoredWordsFilter().ignoreWord(text)) {
						return;
					}
					collector.accept(problem);
				}
				
				public void beginCollecting() {
					collector.beginCollecting();
				}
				
				public void endCollecting() {
					collector.endCollecting();
				}
			};
		}
	};
	
	MonoReconciler reconciler = new MonoReconciler(strategy, false);
	reconciler.setDelay(500);
	return reconciler;
}
 
開發者ID:DarwinSPL,項目名稱:DarwinSPL,代碼行數:56,代碼來源:DwprofileSourceViewerConfiguration.java

示例5: getReconciler

import org.eclipse.jface.text.source.ISourceViewer; //導入方法依賴的package包/類
public IReconciler getReconciler(final ISourceViewer sourceViewer) {
	if (fPreferenceStore == null || !fPreferenceStore.getBoolean(SpellingService.PREFERENCE_SPELLING_ENABLED)) {
		return null;
	}
	
	SpellingService spellingService = EditorsUI.getSpellingService();
	if (spellingService.getActiveSpellingEngineDescriptor(fPreferenceStore) == null) {
		return null;
	}
	
	IReconcilingStrategy strategy = new SpellingReconcileStrategy(sourceViewer, spellingService) {
		
		@Override
		protected ISpellingProblemCollector createSpellingProblemCollector() {
			final ISpellingProblemCollector collector = super.createSpellingProblemCollector();
			
			return new ISpellingProblemCollector() {
				
				public void accept(SpellingProblem problem) {
					int offset = problem.getOffset();
					int length = problem.getLength();
					if (sourceViewer == null) {
						return;
					}
					IDocument document = sourceViewer.getDocument();
					if (document == null) {
						return;
					}
					String text;
					try {
						text = document.get(offset, length);
					} catch (BadLocationException e) {
						return;
					}
					if (new eu.hyvar.feature.expression.resource.hyexpression.ui.HyexpressionIgnoredWordsFilter().ignoreWord(text)) {
						return;
					}
					collector.accept(problem);
				}
				
				public void beginCollecting() {
					collector.beginCollecting();
				}
				
				public void endCollecting() {
					collector.endCollecting();
				}
			};
		}
	};
	
	MonoReconciler reconciler = new MonoReconciler(strategy, false);
	reconciler.setDelay(500);
	return reconciler;
}
 
開發者ID:DarwinSPL,項目名稱:DarwinSPL,代碼行數:56,代碼來源:HyexpressionSourceViewerConfiguration.java

示例6: getReconciler

import org.eclipse.jface.text.source.ISourceViewer; //導入方法依賴的package包/類
public IReconciler getReconciler(final ISourceViewer sourceViewer) {
	if (fPreferenceStore == null || !fPreferenceStore.getBoolean(SpellingService.PREFERENCE_SPELLING_ENABLED)) {
		return null;
	}
	
	SpellingService spellingService = EditorsUI.getSpellingService();
	if (spellingService.getActiveSpellingEngineDescriptor(fPreferenceStore) == null) {
		return null;
	}
	
	IReconcilingStrategy strategy = new SpellingReconcileStrategy(sourceViewer, spellingService) {
		
		@Override
		protected ISpellingProblemCollector createSpellingProblemCollector() {
			final ISpellingProblemCollector collector = super.createSpellingProblemCollector();
			
			return new ISpellingProblemCollector() {
				
				public void accept(SpellingProblem problem) {
					int offset = problem.getOffset();
					int length = problem.getLength();
					if (sourceViewer == null) {
						return;
					}
					IDocument document = sourceViewer.getDocument();
					if (document == null) {
						return;
					}
					String text;
					try {
						text = document.get(offset, length);
					} catch (BadLocationException e) {
						return;
					}
					if (new eu.hyvar.context.contextValidity.resource.hyvalidityformula.ui.HyvalidityformulaIgnoredWordsFilter().ignoreWord(text)) {
						return;
					}
					collector.accept(problem);
				}
				
				public void beginCollecting() {
					collector.beginCollecting();
				}
				
				public void endCollecting() {
					collector.endCollecting();
				}
			};
		}
	};
	
	MonoReconciler reconciler = new MonoReconciler(strategy, false);
	reconciler.setDelay(500);
	return reconciler;
}
 
開發者ID:DarwinSPL,項目名稱:DarwinSPL,代碼行數:56,代碼來源:HyvalidityformulaSourceViewerConfiguration.java

示例7: getReconciler

import org.eclipse.jface.text.source.ISourceViewer; //導入方法依賴的package包/類
public IReconciler getReconciler(final ISourceViewer sourceViewer) {
	if (fPreferenceStore == null || !fPreferenceStore.getBoolean(SpellingService.PREFERENCE_SPELLING_ENABLED)) {
		return null;
	}
	
	SpellingService spellingService = EditorsUI.getSpellingService();
	if (spellingService.getActiveSpellingEngineDescriptor(fPreferenceStore) == null) {
		return null;
	}
	
	IReconcilingStrategy strategy = new SpellingReconcileStrategy(sourceViewer, spellingService) {
		
		@Override
		protected ISpellingProblemCollector createSpellingProblemCollector() {
			final ISpellingProblemCollector collector = super.createSpellingProblemCollector();
			
			return new ISpellingProblemCollector() {
				
				public void accept(SpellingProblem problem) {
					int offset = problem.getOffset();
					int length = problem.getLength();
					if (sourceViewer == null) {
						return;
					}
					IDocument document = sourceViewer.getDocument();
					if (document == null) {
						return;
					}
					String text;
					try {
						text = document.get(offset, length);
					} catch (BadLocationException e) {
						return;
					}
					if (new eu.hyvar.dataValues.resource.hydatavalue.ui.HydatavalueIgnoredWordsFilter().ignoreWord(text)) {
						return;
					}
					collector.accept(problem);
				}
				
				public void beginCollecting() {
					collector.beginCollecting();
				}
				
				public void endCollecting() {
					collector.endCollecting();
				}
			};
		}
	};
	
	MonoReconciler reconciler = new MonoReconciler(strategy, false);
	reconciler.setDelay(500);
	return reconciler;
}
 
開發者ID:DarwinSPL,項目名稱:DarwinSPL,代碼行數:56,代碼來源:HydatavalueSourceViewerConfiguration.java

示例8: getReconciler

import org.eclipse.jface.text.source.ISourceViewer; //導入方法依賴的package包/類
public IReconciler getReconciler(final ISourceViewer sourceViewer) {
	if (fPreferenceStore == null || !fPreferenceStore.getBoolean(SpellingService.PREFERENCE_SPELLING_ENABLED)) {
		return null;
	}
	
	SpellingService spellingService = EditorsUI.getSpellingService();
	if (spellingService.getActiveSpellingEngineDescriptor(fPreferenceStore) == null) {
		return null;
	}
	
	IReconcilingStrategy strategy = new SpellingReconcileStrategy(sourceViewer, spellingService) {
		
		@Override
		protected ISpellingProblemCollector createSpellingProblemCollector() {
			final ISpellingProblemCollector collector = super.createSpellingProblemCollector();
			
			return new ISpellingProblemCollector() {
				
				public void accept(SpellingProblem problem) {
					int offset = problem.getOffset();
					int length = problem.getLength();
					if (sourceViewer == null) {
						return;
					}
					IDocument document = sourceViewer.getDocument();
					if (document == null) {
						return;
					}
					String text;
					try {
						text = document.get(offset, length);
					} catch (BadLocationException e) {
						return;
					}
					if (new eu.hyvar.feature.mapping.resource.hymapping.ui.HymappingIgnoredWordsFilter().ignoreWord(text)) {
						return;
					}
					collector.accept(problem);
				}
				
				public void beginCollecting() {
					collector.beginCollecting();
				}
				
				public void endCollecting() {
					collector.endCollecting();
				}
			};
		}
	};
	
	MonoReconciler reconciler = new MonoReconciler(strategy, false);
	reconciler.setDelay(500);
	return reconciler;
}
 
開發者ID:DarwinSPL,項目名稱:DarwinSPL,代碼行數:56,代碼來源:HymappingSourceViewerConfiguration.java

示例9: getReconciler

import org.eclipse.jface.text.source.ISourceViewer; //導入方法依賴的package包/類
public IReconciler getReconciler(final ISourceViewer sourceViewer) {
	if (fPreferenceStore == null || !fPreferenceStore.getBoolean(SpellingService.PREFERENCE_SPELLING_ENABLED)) {
		return null;
	}
	
	SpellingService spellingService = EditorsUI.getSpellingService();
	if (spellingService.getActiveSpellingEngineDescriptor(fPreferenceStore) == null) {
		return null;
	}
	
	IReconcilingStrategy strategy = new SpellingReconcileStrategy(sourceViewer, spellingService) {
		
		@Override
		protected ISpellingProblemCollector createSpellingProblemCollector() {
			final ISpellingProblemCollector collector = super.createSpellingProblemCollector();
			
			return new ISpellingProblemCollector() {
				
				public void accept(SpellingProblem problem) {
					int offset = problem.getOffset();
					int length = problem.getLength();
					if (sourceViewer == null) {
						return;
					}
					IDocument document = sourceViewer.getDocument();
					if (document == null) {
						return;
					}
					String text;
					try {
						text = document.get(offset, length);
					} catch (BadLocationException e) {
						return;
					}
					if (new eu.hyvar.feature.constraint.resource.hyconstraints.ui.HyconstraintsIgnoredWordsFilter().ignoreWord(text)) {
						return;
					}
					collector.accept(problem);
				}
				
				public void beginCollecting() {
					collector.beginCollecting();
				}
				
				public void endCollecting() {
					collector.endCollecting();
				}
			};
		}
	};
	
	MonoReconciler reconciler = new MonoReconciler(strategy, false);
	reconciler.setDelay(500);
	return reconciler;
}
 
開發者ID:DarwinSPL,項目名稱:DarwinSPL,代碼行數:56,代碼來源:HyconstraintsSourceViewerConfiguration.java

示例10: getReconciler

import org.eclipse.jface.text.source.ISourceViewer; //導入方法依賴的package包/類
public IReconciler getReconciler(final ISourceViewer sourceViewer) {
	if (fPreferenceStore == null || !fPreferenceStore.getBoolean(SpellingService.PREFERENCE_SPELLING_ENABLED)) {
		return null;
	}
	
	SpellingService spellingService = EditorsUI.getSpellingService();
	if (spellingService.getActiveSpellingEngineDescriptor(fPreferenceStore) == null) {
		return null;
	}
	
	IReconcilingStrategy strategy = new SpellingReconcileStrategy(sourceViewer, spellingService) {
		
		@Override
		protected ISpellingProblemCollector createSpellingProblemCollector() {
			final ISpellingProblemCollector collector = super.createSpellingProblemCollector();
			
			return new ISpellingProblemCollector() {
				
				public void accept(SpellingProblem problem) {
					int offset = problem.getOffset();
					int length = problem.getLength();
					if (sourceViewer == null) {
						return;
					}
					IDocument document = sourceViewer.getDocument();
					if (document == null) {
						return;
					}
					String text;
					try {
						text = document.get(offset, length);
					} catch (BadLocationException e) {
						return;
					}
					if (new eu.hyvar.mspl.manifest.resource.hymanifest.ui.HymanifestIgnoredWordsFilter().ignoreWord(text)) {
						return;
					}
					collector.accept(problem);
				}
				
				public void beginCollecting() {
					collector.beginCollecting();
				}
				
				public void endCollecting() {
					collector.endCollecting();
				}
			};
		}
	};
	
	MonoReconciler reconciler = new MonoReconciler(strategy, false);
	reconciler.setDelay(500);
	return reconciler;
}
 
開發者ID:DarwinSPL,項目名稱:DarwinSPL,代碼行數:56,代碼來源:HymanifestSourceViewerConfiguration.java

示例11: run

import org.eclipse.jface.text.source.ISourceViewer; //導入方法依賴的package包/類
public void run(IAction action) {
    if (targetEditor == null) return;
    ISourceViewer sourceViewer= targetEditor.getViewer();
    IDocument document= sourceViewer.getDocument();
    if (document == null)
        return;
    ITextSelection selection = (ITextSelection) targetEditor.getSelectionProvider().getSelection();
    SubStatusLineManager slm = 
        (SubStatusLineManager) targetEditor.getEditorSite().getActionBars().getStatusLineManager();
    
    int selectionLength= Math.abs(selection.getLength());
    if (selectionLength > 1) {
        slm.setErrorMessage(TexlipsePlugin.getResourceString("gotoMatchingBracketNotSelected"));
        slm.setVisible(true);
        sourceViewer.getTextWidget().getDisplay().beep();
        return;
    }
    
    int sourceCaretOffset= selection.getOffset() + selection.getLength();

    TexPairMatcher fBracketMatcher = new TexPairMatcher("{}[]()");
    
    IRegion region= fBracketMatcher.match(document, sourceCaretOffset);
    if (region == null) {
        slm.setErrorMessage(TexlipsePlugin.getResourceString("gotoMatchingBracketNotFound"));
        slm.setVisible(true);            
        sourceViewer.getTextWidget().getDisplay().beep();
        return;
    }

    int offset= region.getOffset();
    int length= region.getLength();

    if (length < 1) return;

    int anchor = fBracketMatcher.getAnchor();
    int targetOffset= (ICharacterPairMatcher.RIGHT == anchor) ? offset + 1: offset + length;

    if (selection.getLength() < 0)
        targetOffset -= selection.getLength();

    sourceViewer.setSelectedRange(targetOffset, selection.getLength());
    sourceViewer.revealRange(targetOffset, selection.getLength());
}
 
開發者ID:eclipse,項目名稱:texlipse,代碼行數:45,代碼來源:GoToMatchingBracketAction.java


注:本文中的org.eclipse.jface.text.source.ISourceViewer.getDocument方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。