本文整理匯總了Java中org.eclipse.jface.text.source.SourceViewer.getDocument方法的典型用法代碼示例。如果您正苦於以下問題:Java SourceViewer.getDocument方法的具體用法?Java SourceViewer.getDocument怎麽用?Java SourceViewer.getDocument使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.eclipse.jface.text.source.SourceViewer
的用法示例。
在下文中一共展示了SourceViewer.getDocument方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: createViewer
import org.eclipse.jface.text.source.SourceViewer; //導入方法依賴的package包/類
protected SourceViewer createViewer (Composite composite) {
SourceViewer viewer = ViewerHelper.createEditor(composite);
viewer.getControl().setData(WIDGET_ID, WIDGET_ACTION_SCRIPT);
FocusListener listener = new FocusListener() {
@Override
public void focusGained(FocusEvent e) {
}
@Override
public void focusLost(FocusEvent event) {
if (!notification) return;
if (viewer.getDocument() == null) return;
String content = viewer.getDocument().get();
getProperties().setPropertyValue(ModelProperties.PROPERTY_EDGE_ACTION, content);
}
};
viewer.getControl().addFocusListener(listener);
return viewer;
}
示例2: createViewer
import org.eclipse.jface.text.source.SourceViewer; //導入方法依賴的package包/類
protected SourceViewer createViewer (Composite composite) {
SourceViewer viewer = ViewerHelper.createEditor(composite);
viewer.getControl().setData(WIDGET_ID, WIDGET_GUARD_SCRIPT);
FocusListener listener = new FocusListener() {
@Override
public void focusGained(FocusEvent e) {
}
@Override
public void focusLost(FocusEvent event) {
if (!notification) return;
if (viewer.getDocument() == null) return;
String content = viewer.getDocument().get();
getProperties().setPropertyValue(ModelProperties.PROPERTY_EDGE_GUARD, content);
}
};
viewer.getControl().addFocusListener(listener);
return viewer;
}
示例3: configureSourceViewer
import org.eclipse.jface.text.source.SourceViewer; //導入方法依賴的package包/類
protected void configureSourceViewer(SourceViewer sourceViewer) {
IEditorInput editorInput = getEditorInput(sourceViewer);
SourceViewerConfiguration sourceViewerConfiguration = createSourceViewerConfiguration(sourceViewer, editorInput);
sourceViewer.unconfigure();
sourceViewer.configure(sourceViewerConfiguration);
if (sourceViewer.getDocument() instanceof IXtextDocument) {
IXtextDocument xtextDocument = (IXtextDocument) sourceViewer.getDocument();
if (!xtextDocument.readOnly(TEST_EXISTING_XTEXT_RESOURCE)) {
String[] configuredContentTypes = sourceViewerConfiguration.getConfiguredContentTypes(sourceViewer);
for (String contentType : configuredContentTypes) {
sourceViewer.removeTextHovers(contentType);
}
sourceViewer.setHyperlinkDetectors(null, sourceViewerConfiguration.getHyperlinkStateMask(sourceViewer));
}
}
}
示例4: 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$
}
}
示例5: 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$
}
}
示例6: createPartControl
import org.eclipse.jface.text.source.SourceViewer; //導入方法依賴的package包/類
public void createPartControl( Composite parent )
{
Composite child = this.initEditorLayout( parent );
// Script combo
cmbExprListViewer = new ComboViewer( cmbExpList );
JSExpListProvider provider = new JSExpListProvider( );
cmbExprListViewer.setContentProvider( provider );
cmbExprListViewer.setLabelProvider( provider );
cmbExprListViewer.setData( VIEWER_CATEGORY_KEY, VIEWER_CATEGORY_CONTEXT );
// SubFunctions combo
JSSubFunctionListProvider subProvider = new JSSubFunctionListProvider( this );
// also add subProvider as listener of expr viewer.
cmbExprListViewer.addSelectionChangedListener( subProvider );
cmbSubFunctions.addListener( CustomChooserComposite.DROPDOWN_EVENT,
new Listener( ) {
public void handleEvent( Event event )
{
cmbSubFunctions.deselectAll( );
ScriptParser parser = new ScriptParser( getEditorText( ) );
Collection<IScriptMethodInfo> coll = parser.getAllMethodInfo( );
for ( Iterator<IScriptMethodInfo> itr = coll.iterator( ); itr.hasNext( ); )
{
IScriptMethodInfo mtd = itr.next( );
cmbSubFunctions.markSelection( METHOD_DISPLAY_INDENT
+ mtd.getName( ) );
}
}
} );
cmbSubFunctionsViewer = new TextComboViewer( cmbSubFunctions );
cmbSubFunctionsViewer.setContentProvider( subProvider );
cmbSubFunctionsViewer.setLabelProvider( subProvider );
cmbSubFunctionsViewer.addSelectionChangedListener( subProvider );
cmbSubFunctionsViewer.addSelectionChangedListener( propertyDefnChangeListener );
// Initialize the model for the document.
Object model = getModel( );
if ( model != null )
{
cmbExpList.setVisible( true );
cmbSubFunctions.setVisible( true );
setComboViewerInput( model );
}
else
{
setComboViewerInput( Messages.getString( "JSEditor.Input.trial" ) ); //$NON-NLS-1$
}
cmbExprListViewer.addSelectionChangedListener( palettePage.getSupport( ) );
cmbExprListViewer.addSelectionChangedListener( propertyDefnChangeListener );
scriptEditor.createPartControl( child );
scriptValidator = new ScriptValidator( getViewer( ) );
disableEditor( );
SourceViewer viewer = getViewer( );
IDocument document = viewer == null ? null : viewer.getDocument( );
if ( document != null )
{
IDocumentUndoManager undoManager = DocumentUndoManagerRegistry.getDocumentUndoManager( document );
if ( undoManager != null )
{
undoManager.addDocumentUndoListener( undoListener );
}
document.addDocumentListener( documentListener );
}
}