本文整理匯總了Java中org.eclipse.jface.text.source.SourceViewer類的典型用法代碼示例。如果您正苦於以下問題:Java SourceViewer類的具體用法?Java SourceViewer怎麽用?Java SourceViewer使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
SourceViewer類屬於org.eclipse.jface.text.source包,在下文中一共展示了SourceViewer類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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: getTMPresentationReconciler
import org.eclipse.jface.text.source.SourceViewer; //導入依賴的package包/類
/**
* Returns the {@link TMPresentationReconciler} of the given text viewer and
* null otherwise.
*
* @param textViewer
* @return the {@link TMPresentationReconciler} of the given text viewer and
* null otherwise.
*/
public static TMPresentationReconciler getTMPresentationReconciler(ITextViewer textViewer) {
try {
Field field = SourceViewer.class.getDeclaredField("fPresentationReconciler");
if (field != null) {
field.setAccessible(true);
IPresentationReconciler presentationReconciler = (IPresentationReconciler) field.get(textViewer);
return presentationReconciler instanceof TMPresentationReconciler
? (TMPresentationReconciler) presentationReconciler
: null;
}
} catch (Exception e) {
}
return null;
}
示例4: 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();
}
示例5: removeItem
import org.eclipse.jface.text.source.SourceViewer; //導入依賴的package包/類
/**
* Removes the item from the view, performing necessary
* cleanup.
*
* @param item
*/
private void removeItem(ExpandItem item)
{
// remove the source viewer's control from the
// font listener since it no longer needs to be
// notified of font changes.
fontListener.removeControl(((SourceViewer) viewers.get(item)).getControl());
// retrieve the id for the item
// the id is stored in the item's data, which should be a marker,
// as set in the updateItem method
final Object data = item.getData(KEY);
items.remove(Integer.parseInt(data.toString()));
item.getControl().dispose();
item.dispose();
}
示例6: 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;
}
示例7: configureTextViewer
import org.eclipse.jface.text.source.SourceViewer; //導入依賴的package包/類
@Override
protected void configureTextViewer(TextViewer viewer) {
if (viewer instanceof SourceViewer) {
SourceViewer sourceViewer = (SourceViewer) viewer;
if (fSourceViewer == null)
fSourceViewer = new ArrayList<>();
if (!fSourceViewer.contains(sourceViewer))
fSourceViewer.add(sourceViewer);
TypeScriptTextTools tools = JSDTTypeScriptUIPlugin.getDefault().getJavaTextTools();
if (tools != null) {
IEditorInput editorInput = getEditorInput(sourceViewer);
sourceViewer.unconfigure();
if (editorInput == null) {
sourceViewer.configure(getSourceViewerConfiguration(sourceViewer, null));
return;
}
getSourceViewerConfiguration(sourceViewer, editorInput);
}
}
}
示例8: setActionsActivated
import org.eclipse.jface.text.source.SourceViewer; //導入依賴的package包/類
@Override
protected void setActionsActivated(SourceViewer sourceViewer, boolean state) {
if (fEditor != null) {
Object editor = fEditor.get(sourceViewer);
if (editor instanceof TypeScriptEditorAdapter) {
TypeScriptEditorAdapter cuea = (TypeScriptEditorAdapter) editor;
cuea.setActionsActivated(state);
IAction saveAction = cuea.getAction(ITextEditorActionConstants.SAVE);
if (saveAction instanceof IPageListener) {
PartEventAction partEventAction = (PartEventAction) saveAction;
IWorkbenchPart compareEditorPart = getCompareConfiguration().getContainer().getWorkbenchPart();
if (state)
partEventAction.partActivated(compareEditorPart);
else
partEventAction.partDeactivated(compareEditorPart);
}
}
}
}
示例9: createViewer
import org.eclipse.jface.text.source.SourceViewer; //導入依賴的package包/類
/**
* Creates the viewer to be used to display the pattern. Subclasses may override.
*
* @param parent the parent composite of the viewer
* @return a configured <code>SourceViewer</code>
*/
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() {
@Override
public IContentAssistant getContentAssistant(ISourceViewer sourceViewer) {
ContentAssistant assistant= new ContentAssistant();
assistant.enableAutoActivation(true);
assistant.enableAutoInsert(true);
assistant.setContentAssistProcessor(fTemplateProcessor, IDocument.DEFAULT_CONTENT_TYPE);
return assistant;
}
};
viewer.configure(configuration);
return viewer;
}
示例10: doCreateViewer
import org.eclipse.jface.text.source.SourceViewer; //導入依賴的package包/類
private SourceViewer doCreateViewer(Composite parent) {
Label label= new Label(parent, SWT.NONE);
label.setText(TemplatesMessages.TemplatePreferencePage_preview);
GridData data= new GridData();
data.horizontalSpan= 2;
label.setLayoutData(data);
SourceViewer viewer= createViewer(parent);
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);
Control control= viewer.getControl();
data= new GridData(GridData.FILL_BOTH);
data.horizontalSpan= 2;
data.heightHint= convertHeightInCharsToPixels(5);
control.setLayoutData(data);
return viewer;
}
示例11: 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));
}
}
}
示例12: createSourceViewerConfiguration
import org.eclipse.jface.text.source.SourceViewer; //導入依賴的package包/類
protected SourceViewerConfiguration createSourceViewerConfiguration(SourceViewer sourceViewer,
IEditorInput editorInput) {
SourceViewerConfiguration sourceViewerConfiguration = null;
if (editorInput != null && getEditor(sourceViewer) != null) {
DefaultMergeEditor mergeEditor = getEditor(sourceViewer);
sourceViewerConfiguration = mergeEditor.getXtextSourceViewerConfiguration();
try {
mergeEditor.init((IEditorSite) mergeEditor.getSite(), editorInput);
mergeEditor.createActions();
} catch (PartInitException partInitException) {
throw new WrappedException(partInitException);
}
} else {
sourceViewerConfiguration = sourceViewerConfigurationProvider.get();
}
return sourceViewerConfiguration;
}
示例13: setActionsActivated
import org.eclipse.jface.text.source.SourceViewer; //導入依賴的package包/類
@Override
protected void setActionsActivated(SourceViewer sourceViewer, boolean state) {
DefaultMergeEditor mergeEditor = getEditor(sourceViewer);
if (mergeEditor != null) {
mergeEditor.setActionsActivated(state);
IAction saveAction = mergeEditor.getAction(ITextEditorActionConstants.SAVE);
if (saveAction instanceof IPageListener) {
PartEventAction partEventAction = (PartEventAction) saveAction;
IWorkbenchPart compareEditorPart = getCompareConfiguration().getContainer().getWorkbenchPart();
if (state) {
partEventAction.partActivated(compareEditorPart);
} else {
partEventAction.partDeactivated(compareEditorPart);
}
}
}
}
示例14: createSourceViewer
import org.eclipse.jface.text.source.SourceViewer; //導入依賴的package包/類
@Override
protected SourceViewer createSourceViewer(Composite parent, int textOrientation) {
if (getSite() != null) {
if (sourceViewerEditorMap == null) {
sourceViewerEditorMap = Maps.newHashMapWithExpectedSize(3);
}
DefaultMergeEditor mergeEditor = createMergeEditor();
mergeEditor.setXtextEditorCallback(new CompoundXtextEditorCallback(null));
mergeEditor.setTextOrientation(textOrientation);
mergeEditor.setInternalSite(getSite());
mergeEditor.createPartControl(parent);
SourceViewer internalSourceViewer = (SourceViewer) mergeEditor.getInternalSourceViewer();
sourceViewerEditorMap.put(internalSourceViewer, mergeEditor);
return internalSourceViewer;
}
return super.createSourceViewer(parent, textOrientation);
}
示例15: installUndoRedoSupport
import org.eclipse.jface.text.source.SourceViewer; //導入依賴的package包/類
protected OperationHistoryListener installUndoRedoSupport(SourceViewer viewer, IDocument document, final EmbeddedEditorActions actions) {
IDocumentUndoManager undoManager = DocumentUndoManagerRegistry.getDocumentUndoManager(document);
final IUndoContext context = undoManager.getUndoContext();
// XXX cp uncommented
// IOperationHistory operationHistory = PlatformUI.getWorkbench().getOperationSupport().getOperationHistory();
OperationHistoryListener operationHistoryListener = new OperationHistoryListener(context, new IUpdate() {
public void update() {
actions.updateAction(ITextEditorActionConstants.REDO);
actions.updateAction(ITextEditorActionConstants.UNDO);
}
});
viewer.addTextListener(new ITextListener() {
public void textChanged(TextEvent event) {
actions.updateAction(ITextEditorActionConstants.REDO);
actions.updateAction(ITextEditorActionConstants.UNDO);
}
});
//
// operationHistory.addOperationHistoryListener(operationHistoryListener);
return operationHistoryListener;
}