本文整理匯總了Java中org.eclipse.jface.text.source.SourceViewer.setDocument方法的典型用法代碼示例。如果您正苦於以下問題:Java SourceViewer.setDocument方法的具體用法?Java SourceViewer.setDocument怎麽用?Java SourceViewer.setDocument使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.eclipse.jface.text.source.SourceViewer
的用法示例。
在下文中一共展示了SourceViewer.setDocument方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: buildEditorText
import org.eclipse.jface.text.source.SourceViewer; //導入方法依賴的package包/類
private StyledText buildEditorText( Composite parent){
final SourceViewer sourceViewer = new SourceViewer(parent, null, SWT.BORDER | SWT.MULTI | SWT.V_SCROLL | SWT.H_SCROLL);
final HConfiguration sourceConf = new HConfiguration(HContentAssistProcessor.PARAM_PROCESSOR);
sourceViewer.configure(sourceConf);
sourceViewer.setDocument(DocumentUtils.createDocument1());
sourceViewer.getControl().addKeyListener(new KeyAdapter() {
public void keyPressed( KeyEvent e){
// if ((e.character == ' ') && ((e.stateMask & SWT.CTRL) != 0)) {
if (Utils.isAutoAssistInvoked(e)) {
IContentAssistant ca = sourceConf.getContentAssistant(sourceViewer);
ca.showPossibleCompletions();
}
}
});
return sourceViewer.getTextWidget();
}
示例2: createViewer
import org.eclipse.jface.text.source.SourceViewer; //導入方法依賴的package包/類
protected SourceViewer createViewer(Composite parent) {
IDocument document= new Document();
JavaScriptTextTools tools= JSDTTypeScriptUIPlugin.getDefault().getJavaTextTools();
tools.setupJavaDocumentPartitioner(document, IJavaScriptPartitions.JAVA_PARTITIONING);
IPreferenceStore store= JSDTTypeScriptUIPlugin.getDefault().getCombinedPreferenceStore();
SourceViewer viewer= new JavaSourceViewer(parent, null, null, false, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL, store);
SimpleJavaSourceViewerConfiguration configuration= new SimpleJavaSourceViewerConfiguration(tools.getColorManager(), store, null, IJavaScriptPartitions.JAVA_PARTITIONING, false);
viewer.configure(configuration);
viewer.setEditable(false);
viewer.setDocument(document);
Font font= JFaceResources.getFont(PreferenceConstants.EDITOR_TEXT_FONT);
viewer.getTextWidget().setFont(font);
new TypeScriptSourcePreviewerUpdater(viewer, configuration, store);
Control control= viewer.getControl();
GridData data= new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.FILL_VERTICAL);
control.setLayoutData(data);
return viewer;
}
示例3: createViewer
import org.eclipse.jface.text.source.SourceViewer; //導入方法依賴的package包/類
@Override
protected SourceViewer createViewer(Composite parent) {
IDocument document= new Document();
JavaTextTools tools= JavaPlugin.getDefault().getJavaTextTools();
tools.setupJavaDocumentPartitioner(document, IJavaPartitions.JAVA_PARTITIONING);
IPreferenceStore store= JavaPlugin.getDefault().getCombinedPreferenceStore();
SourceViewer viewer= new JavaSourceViewer(parent, null, null, false, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL, store);
SimpleJavaSourceViewerConfiguration configuration= new SimpleJavaSourceViewerConfiguration(tools.getColorManager(), store, null, IJavaPartitions.JAVA_PARTITIONING, false);
viewer.configure(configuration);
viewer.setEditable(false);
viewer.setDocument(document);
Font font= JFaceResources.getFont(PreferenceConstants.EDITOR_TEXT_FONT);
viewer.getTextWidget().setFont(font);
new JavaSourcePreviewerUpdater(viewer, configuration, store);
Control control= viewer.getControl();
GridData data= new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.FILL_VERTICAL);
control.setLayoutData(data);
return viewer;
}
示例4: createPreviewer
import org.eclipse.jface.text.source.SourceViewer; //導入方法依賴的package包/類
private Control createPreviewer(Composite parent) {
IPreferenceStore store = new ChainedPreferenceStore(new IPreferenceStore[] { fOverlayStore,
EditorConfigUIPlugin.getDefault().getCombinedPreferenceStore() });
fPreviewViewer = new SourceViewer(parent, null, null, false, SWT.V_SCROLL | SWT.H_SCROLL | SWT.BORDER);
fColorManager = new EditorConfigColorManager(false);
EditorConfigSourceViewerConfiguration configuration = new EditorConfigSourceViewerConfiguration(fColorManager,
store, null, IEditorConfigPartitions.EDITOR_CONFIG_PARTITIONING);
fPreviewViewer.configure(configuration);
Font font = JFaceResources.getFont(PreferenceConstants.EDITOR_CONFIG_EDITOR_TEXT_FONT);
fPreviewViewer.getTextWidget().setFont(font);
new SourcePreviewerUpdater(fPreviewViewer, configuration, store);
fPreviewViewer.setEditable(false);
String content = loadPreviewContentFromFile("EditorConfigEditorColorSettingPreviewCode.txt"); //$NON-NLS-1$
IDocument document = new Document(content);
EditorConfigDocumentSetupParticipant.setupDocument(document);
fPreviewViewer.setDocument(document);
return fPreviewViewer.getControl();
}
示例5: createViewer
import org.eclipse.jface.text.source.SourceViewer; //導入方法依賴的package包/類
/**
* Creates, configures and returns a source viewer to present the template
* pattern on the preference page. Clients may override to provide a
* custom source viewer featuring e.g. syntax coloring.
*
* @param parent
* the parent control
* @return a configured source viewer
*/
@Override
protected final SourceViewer createViewer(Composite parent) {
final ApexSourceViewerConfiguration configuration = new ApexSourceViewerConfiguration(preferenceStore(), null);
configuration.init(this.componentModel.getProject());
final IDocument document = new Document();
new ApexDocumentSetupParticipant().setup(document);
SourceViewer viewer= new SourceViewer(parent, null, null, false, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL);
viewer.configure(configuration);
viewer.setDocument(document);
viewer.getTextWidget().setFont(JFaceResources.getFont(JFaceResources.TEXT_FONT));
viewer.setEditable(false);
return viewer;
}
示例6: createSourceViewer
import org.eclipse.jface.text.source.SourceViewer; //導入方法依賴的package包/類
/**
* Creates the source viewer to be used by this editor.
*
* @param parent
* the parent control
* @return the source viewer
*/
protected SourceViewer createSourceViewer( Composite parent )
{
IVerticalRuler ruler = createVerticalRuler( );
Composite composite = new Composite( parent, SWT.BORDER
| SWT.LEFT_TO_RIGHT );
composite.setLayoutData( new GridData( GridData.FILL_BOTH ) );
composite.setLayout( UIUtil.createGridLayoutWithoutMargin( ) );
int styles = SWT.V_SCROLL
| SWT.H_SCROLL
| SWT.MULTI
| SWT.BORDER
| SWT.FULL_SELECTION;
SourceViewer viewer = new SourceViewer( composite, ruler, styles );
viewer.configure( sourceViewerConfiguration );
updateStyledTextColors( viewer.getTextWidget( ) );
JSEditorInput editorInput = new JSEditorInput( expression,
getEncoding( ) );
JSDocumentProvider documentProvider = new JSDocumentProvider( );
try
{
documentProvider.connect( editorInput );
}
catch ( CoreException e )
{
ExceptionHandler.handle( e );
}
viewer.setDocument( documentProvider.getDocument( editorInput ),
ruler == null ? null : ruler.getModel( ) );
return viewer;
}
示例7: buildEditorText
import org.eclipse.jface.text.source.SourceViewer; //導入方法依賴的package包/類
private StyledText buildEditorText( Composite parent){
final SourceViewer sourceViewer = new SourceViewer(parent, null, SWT.MULTI | SWT.V_SCROLL | SWT.WRAP);
final XMLConfiguration sourceConf = new XMLConfiguration(new ColorManagerAdaptor(ResourceUtils.getResourceCache()));
sourceViewer.configure(sourceConf);
sourceViewer.setDocument(DocumentUtils.createDocument2());
return sourceViewer.getTextWidget();
}
示例8: buildEditorText
import org.eclipse.jface.text.source.SourceViewer; //導入方法依賴的package包/類
private static StyledText buildEditorText( Composite parent){
final SourceViewer sourceViewer = new SourceViewer(parent, null, SWT.MULTI | SWT.V_SCROLL | SWT.WRAP);
final XMLConfiguration sourceConf = new XMLConfiguration(new ColorManagerAdaptor(ResourceUtils.getResourceCache()));
sourceViewer.configure(sourceConf);
sourceViewer.setDocument(DocumentUtils.createDocument2());
return sourceViewer.getTextWidget();
}
示例9: updateViewerInput
import org.eclipse.jface.text.source.SourceViewer; //導入方法依賴的package包/類
protected void updateViewerInput() {
IStructuredSelection selection= (IStructuredSelection) getTableViewer().getSelection();
SourceViewer viewer= getViewer();
if (selection.size() == 1 && selection.getFirstElement() instanceof TemplatePersistenceData) {
TemplatePersistenceData data= (TemplatePersistenceData) selection.getFirstElement();
Template template= data.getTemplate();
String contextId= template.getContextTypeId();
TemplateContextType type= JSDTTypeScriptUIPlugin.getDefault().getTemplateContextRegistry().getContextType(contextId);
fTemplateProcessor.setContextType(type);
IDocument doc= viewer.getDocument();
String start= null;
if ("javadoc".equals(contextId)) { //$NON-NLS-1$
start= "/**" + doc.getLegalLineDelimiters()[0]; //$NON-NLS-1$
} else
start= ""; //$NON-NLS-1$
doc.set(start + template.getPattern());
int startLen= start.length();
viewer.setDocument(doc, startLen, doc.getLength() - startLen);
} else {
viewer.getDocument().set(""); //$NON-NLS-1$
}
}
示例10: createViewer
import org.eclipse.jface.text.source.SourceViewer; //導入方法依賴的package包/類
private SourceViewer createViewer(Composite parent, int nColumns) {
Label label = new Label(parent, SWT.NONE);
label.setText(JSDTTypeScriptUIMessages.CodeTemplateBlock_preview);
GridData data = new GridData();
data.horizontalSpan = nColumns;
label.setLayoutData(data);
IDocument document = new Document();
JavaScriptTextTools tools = JavaScriptPlugin.getDefault().getJavaTextTools();
tools.setupJavaDocumentPartitioner(document, IJavaScriptPartitions.JAVA_PARTITIONING);
IPreferenceStore store = JavaScriptPlugin.getDefault().getCombinedPreferenceStore();
SourceViewer viewer = new JavaSourceViewer(parent, null, null, false, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL,
store);
CodeTemplateSourceViewerConfiguration configuration = new CodeTemplateSourceViewerConfiguration(
tools.getColorManager(), store, null, fTemplateProcessor);
viewer.configure(configuration);
viewer.setEditable(false);
viewer.setDocument(document);
Font font = JFaceResources.getFont(PreferenceConstants.EDITOR_TEXT_FONT);
viewer.getTextWidget().setFont(font);
new TypeScriptSourcePreviewerUpdater(viewer, configuration, store);
Control control = viewer.getControl();
data = new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.FILL_VERTICAL);
data.horizontalSpan = nColumns;
data.heightHint = fPixelConverter.convertHeightInCharsToPixels(5);
control.setLayoutData(data);
return viewer;
}
示例11: createViewer
import org.eclipse.jface.text.source.SourceViewer; //導入方法依賴的package包/類
/**
* Creates, configures and returns a source viewer to present the template
* pattern on the preference page. Clients may override to provide a custom
* source viewer featuring e.g. syntax coloring.
*
* @param parent the parent control
* @return a configured source viewer
*/
protected SourceViewer createViewer(Composite parent) {
SourceViewer viewer= new SourceViewer(parent, null, null, false, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL);
SourceViewerConfiguration configuration= new SourceViewerConfiguration();
viewer.configure(configuration);
IDocument document= new Document();
viewer.setDocument(document);
return viewer;
}
示例12: createControl
import org.eclipse.jface.text.source.SourceViewer; //導入方法依賴的package包/類
@Override
public void createControl(Composite parent) {
composite = new Composite(parent, SWT.NONE);
composite.setLayout(new GridLayout(1, false));
generateJUnitTimeoutEditor = new Button(composite, SWT.CHECK | SWT.LEFT);
generateJUnitTimeoutEditor.setText("Use timeouts in generated test cases");
generateJUnitTimeoutEditor.setSelection(EclipseForcesPlugin.getDefault()
.isGenerateJUnitTimeout());
codeTemplateLabel = new Label(composite, SWT.NONE);
codeTemplateLabel.setText("Code template:");
codeTemplateEditor = new SourceViewer(composite, null, SWT.MULTI | SWT.H_SCROLL
| SWT.V_SCROLL | SWT.BORDER);
JavaSourceViewerConfiguration config = new JavaSourceViewerConfiguration(JavaUI.getColorManager(), JavaPlugin.getDefault().getCombinedPreferenceStore(), null, IJavaPartitions.JAVA_PARTITIONING);
codeTemplateEditor.configure(config);
Document doc = new Document(EclipseForcesPlugin.getDefault().getCodeTemplate());
JavaPartitionScanner scanner = new JavaPartitionScanner();
FastPartitioner fp = new FastPartitioner(scanner, new String[] {IJavaPartitions.JAVA_STRING, IJavaPartitions.JAVA_MULTI_LINE_COMMENT, IJavaPartitions.JAVA_CHARACTER,
IJavaPartitions.JAVA_DOC, IJavaPartitions.JAVA_SINGLE_LINE_COMMENT});
fp.connect(doc);
doc.setDocumentPartitioner(IJavaPartitions.JAVA_PARTITIONING, fp);
codeTemplateEditor.setDocument(doc);
codeTemplateEditor.getControl().setLayoutData(new GridData(GridData.FILL_BOTH));
codeTemplateEditor.getControl().pack();
}
示例13: createSourcePreview
import org.eclipse.jface.text.source.SourceViewer; //導入方法依賴的package包/類
/**
* @param composite
*/
public SourceViewer createSourcePreview(Composite composite, IScriptFormatterFactory factory)
{
IPreferenceStore generalTextStore = EditorsUI.getPreferenceStore();
// TODO - Note that we pass the factory's preferences store and not calling to this.getPrefereceStore.
// In case we decide to unify the preferences into the this plugin, we might need to change this.
IPreferenceStore store = new ChainedPreferenceStore(new IPreferenceStore[] { factory.getPreferenceStore(),
generalTextStore });
SourceViewer fPreviewViewer = createPreviewViewer(composite, null, null, false, SWT.V_SCROLL | SWT.H_SCROLL
| SWT.BORDER, store);
if (fPreviewViewer == null)
{
return null;
}
SourceViewerConfiguration configuration = (SourceViewerConfiguration) factory
.createSimpleSourceViewerConfiguration(fColorManager, store, null, false);
fPreviewViewer.configure(configuration);
if (fPreviewViewer.getTextWidget().getTabs() == 0)
{
fPreviewViewer.getTextWidget().setTabs(4);
}
new ScriptSourcePreviewerUpdater(fPreviewViewer, configuration, store);
fPreviewViewer.setEditable(false);
IDocument document = new Document();
fPreviewViewer.setDocument(document);
IPartitioningConfiguration partitioningConfiguration = (IPartitioningConfiguration) factory
.getPartitioningConfiguration();
CompositePartitionScanner partitionScanner = new CompositePartitionScanner(
partitioningConfiguration.createSubPartitionScanner(), new NullSubPartitionScanner(),
new NullPartitionerSwitchStrategy());
IDocumentPartitioner partitioner = new ExtendedFastPartitioner(partitionScanner,
partitioningConfiguration.getContentTypes());
partitionScanner.setPartitioner((IExtendedPartitioner) partitioner);
partitioner.connect(document);
document.setDocumentPartitioner(partitioner);
return fPreviewViewer;
}
示例14: updateViewerInput
import org.eclipse.jface.text.source.SourceViewer; //導入方法依賴的package包/類
@Override
protected void updateViewerInput() {
IStructuredSelection selection= (IStructuredSelection) getTableViewer().getSelection();
SourceViewer viewer= getViewer();
if (selection.size() == 1 && selection.getFirstElement() instanceof TemplatePersistenceData) {
TemplatePersistenceData data= (TemplatePersistenceData) selection.getFirstElement();
Template template= data.getTemplate();
String contextId= template.getContextTypeId();
TemplateContextType type= JavaPlugin.getDefault().getTemplateContextRegistry().getContextType(contextId);
fTemplateProcessor.setContextType(type);
IDocument doc= viewer.getDocument();
String start= null;
if ("javadoc".equals(contextId)) { //$NON-NLS-1$
start= "/**" + doc.getLegalLineDelimiters()[0]; //$NON-NLS-1$
} else
start= ""; //$NON-NLS-1$
doc.set(start + template.getPattern());
int startLen= start.length();
viewer.setDocument(doc, startLen, doc.getLength() - startLen);
} else {
viewer.getDocument().set(""); //$NON-NLS-1$
}
}
示例15: createViewer
import org.eclipse.jface.text.source.SourceViewer; //導入方法依賴的package包/類
private SourceViewer createViewer(Composite parent, int nColumns) {
Label label= new Label(parent, SWT.NONE);
label.setText(PreferencesMessages.CodeTemplateBlock_preview);
GridData data= new GridData();
data.horizontalSpan= nColumns;
label.setLayoutData(data);
IDocument document= new Document();
JavaTextTools tools= JavaPlugin.getDefault().getJavaTextTools();
tools.setupJavaDocumentPartitioner(document, IJavaPartitions.JAVA_PARTITIONING);
IPreferenceStore store= JavaPlugin.getDefault().getCombinedPreferenceStore();
SourceViewer viewer= new JavaSourceViewer(parent, null, null, false, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL, store);
CodeTemplateSourceViewerConfiguration configuration= new CodeTemplateSourceViewerConfiguration(tools.getColorManager(), store, null, fTemplateProcessor);
viewer.configure(configuration);
viewer.setEditable(false);
Cursor arrowCursor= viewer.getTextWidget().getDisplay().getSystemCursor(SWT.CURSOR_ARROW);
viewer.getTextWidget().setCursor(arrowCursor);
// Don't set caret to 'null' as this causes https://bugs.eclipse.org/293263
// viewer.getTextWidget().setCaret(null);
viewer.setDocument(document);
Font font= JFaceResources.getFont(PreferenceConstants.EDITOR_TEXT_FONT);
viewer.getTextWidget().setFont(font);
new JavaSourcePreviewerUpdater(viewer, configuration, store);
Control control= viewer.getControl();
data= new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.FILL_VERTICAL);
data.horizontalSpan= nColumns;
data.heightHint= fPixelConverter.convertHeightInCharsToPixels(5);
control.setLayoutData(data);
return viewer;
}