本文整理汇总了Java中org.eclipse.xtext.ui.editor.XtextEditor类的典型用法代码示例。如果您正苦于以下问题:Java XtextEditor类的具体用法?Java XtextEditor怎么用?Java XtextEditor使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
XtextEditor类属于org.eclipse.xtext.ui.editor包,在下文中一共展示了XtextEditor类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: openXtextEditor
import org.eclipse.xtext.ui.editor.XtextEditor; //导入依赖的package包/类
/**
* Obtains or opens {@link XtextEditor} for provided {@link Resource} and editor id. Upon activation or opening of
* the editor waits a moment for editor to become active.
*
* @param uri
* URI to be opened
* @param editorExtensionID
* {String} defining the id of the editor extension to use
* @return {@link Optional} instance of {@link XtextEditor} for given {@link Resource}.
*/
public static final Optional<XtextEditor> openXtextEditor(URI uri, String editorExtensionID) {
String platformStr = uri.toString().replace("platform:/resource/", "");
IFile file = ResourcesPlugin.getWorkspace().getRoot().getFile(new Path(platformStr));
Optional<IWorkbenchPage> page = getActivePage();
Optional<IEditorPart> internalFileEditor = getFileEditor(file, page.get(), editorExtensionID);
if ((page.isPresent() && internalFileEditor.isPresent()) == false) {
logger.warn("Cannot obtain editor components for " + file.getRawLocationURI());
return Optional.empty();
}
IEditorPart ieditorPart = internalFileEditor.get();
if (ieditorPart instanceof XtextEditor == false) {
logger.warn("cannot obtain Xtext editor for file " + file.getRawLocation());
return Optional.empty();
}
waitForEditorToBeActive(ieditorPart, page.get());
return Optional.ofNullable((XtextEditor) ieditorPart);
}
开发者ID:eclipse,项目名称:n4js,代码行数:34,代码来源:EditorsUtil.java
示例2: tryValidateManifestInEditor
import org.eclipse.xtext.ui.editor.XtextEditor; //导入依赖的package包/类
private void tryValidateManifestInEditor(final IResourceDelta delta) {
if (isWorkbenchRunning()) {
Display.getDefault().asyncExec(() -> {
final IWorkbenchWindow window = getWorkbench().getActiveWorkbenchWindow();
if (null != window) {
final IWorkbenchPage page = window.getActivePage();
for (final IEditorReference editorRef : page.getEditorReferences()) {
if (isEditorForResource(editorRef, delta.getResource())) {
final IWorkbenchPart part = editorRef.getPart(true);
if (part instanceof XtextEditor) {
editorCallback.afterSave((XtextEditor) part);
return;
}
}
}
}
});
}
}
开发者ID:eclipse,项目名称:n4js,代码行数:20,代码来源:N4JSAllContainersState.java
示例3: newValidationJob
import org.eclipse.xtext.ui.editor.XtextEditor; //导入依赖的package包/类
private ValidationJob newValidationJob(final XtextEditor editor) {
final IXtextDocument document = editor.getDocument();
final IAnnotationModel annotationModel = editor.getInternalSourceViewer().getAnnotationModel();
final IssueResolutionProvider issueResolutionProvider = getService(editor, IssueResolutionProvider.class);
final MarkerTypeProvider markerTypeProvider = getService(editor, MarkerTypeProvider.class);
final MarkerCreator markerCreator = getService(editor, MarkerCreator.class);
final IValidationIssueProcessor issueProcessor = new CompositeValidationIssueProcessor(
new AnnotationIssueProcessor(document, annotationModel, issueResolutionProvider),
new MarkerIssueProcessor(editor.getResource(), markerCreator, markerTypeProvider));
return editor.getDocument().modify(resource -> {
final IResourceServiceProvider serviceProvider = resource.getResourceServiceProvider();
final IResourceValidator resourceValidator = serviceProvider.getResourceValidator();
return new ValidationJob(resourceValidator, editor.getDocument(), issueProcessor, ALL);
});
}
开发者ID:eclipse,项目名称:n4js,代码行数:20,代码来源:OwnResourceValidatorAwareValidatingEditorCallback.java
示例4: getLaunchConfigFromEditor
import org.eclipse.xtext.ui.editor.XtextEditor; //导入依赖的package包/类
protected LaunchConfig getLaunchConfigFromEditor(ExecutionEvent event) {
XtextEditor activeXtextEditor = EditorUtils.getActiveXtextEditor(event);
if (activeXtextEditor == null) {
return null;
}
final ITextSelection selection = (ITextSelection) activeXtextEditor.getSelectionProvider().getSelection();
return activeXtextEditor.getDocument().priorityReadOnly(new IUnitOfWork<LaunchConfig, XtextResource>() {
@Override
public LaunchConfig exec(XtextResource xTextResource) throws Exception {
EObject lc = eObjectAtOffsetHelper.resolveContainedElementAt(xTextResource, selection.getOffset());
return findParentLaunchConfig(lc);
}
});
}
开发者ID:mduft,项目名称:lcdsl,代码行数:17,代码来源:AbstractLaunchConfigGeneratorHandler.java
示例5: valuesForAttributes
import org.eclipse.xtext.ui.editor.XtextEditor; //导入依赖的package包/类
/**
* Retrieve the object's values for the given EAttributes.
*
* @param attributes
* the EAttributes
* @return List<Pair<EAttribute, Object>> the attribute+values - possibly containing null entries
*/
private List<AttributeValuePair> valuesForAttributes(final EList<EAttribute> attributes) {
final URI elementUri = xtextElementSelectionListener.getSelectedElementUri();
XtextEditor editor = xtextElementSelectionListener.getEditor();
if (editor != null && elementUri != null) {
return editor.getDocument().readOnly(new IUnitOfWork<List<AttributeValuePair>, XtextResource>() {
@SuppressWarnings("PMD.SignatureDeclareThrowsException")
public List<AttributeValuePair> exec(final XtextResource state) throws Exception {
final EObject eObject = state.getEObject(elementUri.fragment());
List<AttributeValuePair> pairs = Lists.transform(attributes, new Function<EAttribute, AttributeValuePair>() {
public AttributeValuePair apply(final EAttribute from) {
return new AttributeValuePair(from, eObject.eGet(from));
}
});
return pairs;
}
});
}
return newArrayList();
}
开发者ID:dsldevkit,项目名称:dsl-devkit,代码行数:27,代码来源:EObjectContentProvider.java
示例6: getActiveXtextEditor
import org.eclipse.xtext.ui.editor.XtextEditor; //导入依赖的package包/类
/** {@inheritDoc} */
public XtextEditor getActiveXtextEditor() {
IWorkbench workbench = PlatformUI.getWorkbench();
IWorkbenchWindow workbenchWindow = workbench.getActiveWorkbenchWindow();
if (workbenchWindow == null) {
return null;
}
IWorkbenchPage activePage = workbenchWindow.getActivePage();
if (activePage == null) {
return null;
}
IEditorPart activeEditor = activePage.getActiveEditor();
if (activeEditor instanceof XtextEditor) {
return (XtextEditor) activeEditor;
// return null;
}
// XtextEditor xtextEditor = (XtextEditor) activeEditor.getAdapter(XtextEditor.class);
// return xtextEditor;
return null;
}
开发者ID:dsldevkit,项目名称:dsl-devkit,代码行数:21,代码来源:ASMDEditorUtils.java
示例7: mockSelectedElement
import org.eclipse.xtext.ui.editor.XtextEditor; //导入依赖的package包/类
/**
* Mocks XtextEditor and XtextElementSelectionListener to return an element selection that has:
* - given EAttribute with a specific value (AttributeValuePair)
* - given EStructuralFeature
* - given EOperation.
*
* @param attributeValuePair
* EAttribute with a specific value
* @param feature
* the EStructuralFeature
* @param operation
* the EOperation
* @return the EClass of the "selected" element
*/
@SuppressWarnings("unchecked")
private EClass mockSelectedElement(final AttributeValuePair attributeValuePair, final EStructuralFeature feature, final EOperation operation) {
EClass mockSelectionEClass = mock(EClass.class);
when(mockSelectionListener.getSelectedElementType()).thenReturn(mockSelectionEClass);
// Mockups for returning AttributeValuePair
URI elementUri = URI.createURI("");
when(mockSelectionListener.getSelectedElementUri()).thenReturn(elementUri);
XtextEditor mockEditor = mock(XtextEditor.class);
when(mockSelectionListener.getEditor()).thenReturn(mockEditor);
IXtextDocument mockDocument = mock(IXtextDocument.class);
when(mockEditor.getDocument()).thenReturn(mockDocument);
when(mockDocument.<ArrayList<AttributeValuePair>> readOnly(any(IUnitOfWork.class))).thenReturn(newArrayList(attributeValuePair));
// Mockups for returning EOperation
BasicEList<EOperation> mockEOperationsList = new BasicEList<EOperation>();
mockEOperationsList.add(operation);
when(mockSelectionEClass.getEAllOperations()).thenReturn(mockEOperationsList);
// Mockups for returning EStructuralFeature
BasicEList<EStructuralFeature> mockEStructuralFeatureList = new BasicEList<EStructuralFeature>();
mockEStructuralFeatureList.add(feature);
mockEStructuralFeatureList.add(attributeValuePair.getAttribute());
when(mockSelectionEClass.getEAllStructuralFeatures()).thenReturn(mockEStructuralFeatureList);
return mockSelectionEClass;
}
开发者ID:dsldevkit,项目名称:dsl-devkit,代码行数:38,代码来源:EObjectContentProviderTest.java
示例8: getDisplay
import org.eclipse.xtext.ui.editor.XtextEditor; //导入依赖的package包/类
private Display getDisplay() {
XtextEditor editor = this.editor;
if (editor == null) {
return null;
}
IWorkbenchPartSite site = editor.getSite();
if (site == null) {
return null;
}
Shell shell = site.getShell();
if (shell == null || shell.isDisposed()) {
return null;
}
Display display = shell.getDisplay();
if (display == null || display.isDisposed()) {
return null;
}
return display;
}
开发者ID:dsldevkit,项目名称:dsl-devkit,代码行数:23,代码来源:FixedHighlightingReconciler.java
示例9: install
import org.eclipse.xtext.ui.editor.XtextEditor; //导入依赖的package包/类
/**
* Install this reconciler on the given editor and presenter.
*
* @param editor
* the editor
* @param sourceViewer
* the source viewer
* @param presenter
* the highlighting presenter
*/
@Override
public void install(final XtextEditor editor, final XtextSourceViewer sourceViewer, final HighlightingPresenter presenter) {
synchronized (fReconcileLock) {
cleanUpAfterReconciliation = false; // prevents a potentially already running reconciliation process to clean up after itself
}
this.presenter = presenter;
this.editor = editor;
this.sourceViewer = sourceViewer;
if (calculator != null) {
if (editor == null) {
((IXtextDocument) sourceViewer.getDocument()).addModelListener(this);
} else if (editor.getDocument() != null) {
editor.getDocument().addModelListener(this);
}
sourceViewer.addTextInputListener(this);
}
refresh();
}
开发者ID:dsldevkit,项目名称:dsl-devkit,代码行数:30,代码来源:FixedHighlightingReconciler.java
示例10: loadCycleInfo
import org.eclipse.xtext.ui.editor.XtextEditor; //导入依赖的package包/类
private void loadCycleInfo(final int offset, final int length, XtextEditor editor, final IDocument doc) {
final ILocationInFileProvider locationInFileProvider = Z80Activator.getInstance().getInjector(Z80Activator.ORG_EFRY_Z80EDITOR_Z80).getInstance(ILocationInFileProvider.class);
editor.getDocument().readOnly(new IUnitOfWork<Boolean, XtextResource>() {
@Override
public Boolean exec(XtextResource state) throws Exception {
Z80OperationTypeWalker operationInstructions = new Z80OperationTypeWalker(state, locationInFileProvider, offset, offset + length);
Z80CycleCalculator calc = new Z80CycleCalculator();
for (Operation o : operationInstructions) {
ITextRegion region = locationInFileProvider.getFullTextRegion(o);
calc.addOperation(o, doc.get(region.getOffset(), region.getLength()));
}
label.setText(calc.getHtmlFormattedText());
return Boolean.TRUE;
}
});
}
开发者ID:yuv422,项目名称:z80editor,代码行数:21,代码来源:Z80InstructionHelpView.java
示例11: initializeImageMaps
import org.eclipse.xtext.ui.editor.XtextEditor; //导入依赖的package包/类
private static final void initializeImageMaps() {
if(imagesInitialized)
return;
annotationImagesFixable.put(XtextEditor.ERROR_ANNOTATION_TYPE, get(OBJ_FIXABLE_ERROR));
annotationImagesFixable.put(XtextEditor.WARNING_ANNOTATION_TYPE, get(OBJ_FIXABLE_WARNING));
annotationImagesFixable.put(XtextEditor.INFO_ANNOTATION_TYPE, get(OBJ_FIXABLE_INFO));
//XXX cp uncommented
// ISharedImages sharedImages= PlatformUI.getWorkbench().getSharedImages();
// Image error = sharedImages.getImage(ISharedImages.IMG_OBJS_ERROR_TSK);
// Image warning = sharedImages.getImage(ISharedImages.IMG_OBJS_WARN_TSK);
// Image info = sharedImages.getImage(ISharedImages.IMG_OBJS_INFO_TSK);
annotationImagesNonFixable.put(XtextEditor.ERROR_ANNOTATION_TYPE, get(OBJ_DESC_ERROR));
annotationImagesNonFixable.put(XtextEditor.WARNING_ANNOTATION_TYPE, get(OBJ_DESC_EXCLAMATION));
annotationImagesNonFixable.put(XtextEditor.INFO_ANNOTATION_TYPE, get(OBJ_DESC_INFORMATION));
Display display = Display.getCurrent();
annotationImagesDeleted.put(XtextEditor.ERROR_ANNOTATION_TYPE, new Image(display, get(OBJ_DESC_ERROR), SWT.IMAGE_GRAY));
annotationImagesDeleted.put(XtextEditor.WARNING_ANNOTATION_TYPE, new Image(display, get(OBJ_DESC_EXCLAMATION), SWT.IMAGE_GRAY));
annotationImagesDeleted.put(XtextEditor.INFO_ANNOTATION_TYPE, new Image(display, get(OBJ_DESC_INFORMATION), SWT.IMAGE_GRAY));
imagesInitialized = true;
}
开发者ID:cplutte,项目名称:bts,代码行数:25,代码来源:XtextPluginImages.java
示例12: execute
import org.eclipse.xtext.ui.editor.XtextEditor; //导入依赖的package包/类
public Object execute(final ExecutionEvent event) throws ExecutionException {
final XtextEditor xtextEditor = EditorUtils.getActiveXtextEditor(event);
if (xtextEditor != null) {
final IXtextDocument document = xtextEditor.getDocument();
document.readOnly(new IUnitOfWork.Void<XtextResource>() {
@Override
public void process(XtextResource state) throws Exception {
final QuickOutlinePopup quickOutlinePopup = createPopup(xtextEditor.getEditorSite().getShell());
quickOutlinePopup.setEditor(xtextEditor);
quickOutlinePopup.setInput(document);
quickOutlinePopup.setEvent((Event) event.getTrigger());
quickOutlinePopup.open();
}
});
}
return null;
}
开发者ID:cplutte,项目名称:bts,代码行数:18,代码来源:ShowQuickOutlineActionHandler.java
示例13: execute
import org.eclipse.xtext.ui.editor.XtextEditor; //导入依赖的package包/类
public Object execute(ExecutionEvent event) throws ExecutionException {
try {
XtextEditor editor = EditorUtils.getActiveXtextEditor(event);
if (editor != null) {
final ITextSelection selection = (ITextSelection) editor.getSelectionProvider().getSelection();
editor.getDocument().readOnly(new IUnitOfWork.Void<XtextResource>() {
@Override
public void process(XtextResource state) throws Exception {
EObject target = eObjectAtOffsetHelper.resolveElementAt(state, selection.getOffset());
findReferences(target);
}
});
}
} catch (Exception e) {
LOG.error(Messages.FindReferencesHandler_3, e);
}
return null;
}
开发者ID:cplutte,项目名称:bts,代码行数:19,代码来源:FindReferencesHandler.java
示例14: getDisplay
import org.eclipse.xtext.ui.editor.XtextEditor; //导入依赖的package包/类
private Display getDisplay() {
XtextEditor editor = this.editor;
if (editor == null){
if(sourceViewer != null)
return sourceViewer.getControl().getDisplay();
return null;
}
IWorkbenchPartSite site = editor.getSite();
if (site == null)
return null;
Shell shell = site.getShell();
if (shell == null || shell.isDisposed())
return null;
Display display = shell.getDisplay();
if (display == null || display.isDisposed())
return null;
return display;
}
开发者ID:cplutte,项目名称:bts,代码行数:21,代码来源:HighlightingReconciler.java
示例15: execute
import org.eclipse.xtext.ui.editor.XtextEditor; //导入依赖的package包/类
public Object execute(ExecutionEvent event) throws ExecutionException {
XtextEditor xtextEditor = EditorUtils.getActiveXtextEditor(event);
if (xtextEditor != null) {
ITextSelection selection = (ITextSelection) xtextEditor.getSelectionProvider().getSelection();
IRegion region = new Region(selection.getOffset(), selection.getLength());
ISourceViewer internalSourceViewer = xtextEditor.getInternalSourceViewer();
IHyperlink[] hyperlinks = getDetector().detectHyperlinks(internalSourceViewer, region, false);
if (hyperlinks != null && hyperlinks.length > 0) {
IHyperlink hyperlink = hyperlinks[0];
hyperlink.open();
}
}
return null;
}
开发者ID:cplutte,项目名称:bts,代码行数:18,代码来源:OpenDeclarationHandler.java
示例16: getResolutions
import org.eclipse.xtext.ui.editor.XtextEditor; //导入依赖的package包/类
public IMarkerResolution[] getResolutions(IMarker marker) {
final IMarkerResolution[] emptyResult = new IMarkerResolution[0];
try {
if(!marker.isSubtypeOf(MarkerTypes.ANY_VALIDATION))
return emptyResult;
} catch (CoreException e) {
return emptyResult;
}
if(!languageResourceHelper.isLanguageResource(marker.getResource())) {
return emptyResult;
}
XtextEditor editor = getEditor(marker.getResource());
if(editor == null)
return emptyResult;
IAnnotationModel annotationModel = editor.getDocumentProvider().getAnnotationModel(editor.getEditorInput());
if(annotationModel != null && !isMarkerStillValid(marker, annotationModel))
return emptyResult;
final Iterable<IssueResolution> resolutions = getResolutions(getIssueUtil().createIssue(marker), editor.getDocument());
return getAdaptedResolutions(Lists.newArrayList(resolutions));
}
开发者ID:cplutte,项目名称:bts,代码行数:23,代码来源:MarkerResolutionGenerator.java
示例17: getQualifiedName
import org.eclipse.xtext.ui.editor.XtextEditor; //导入依赖的package包/类
@Override
protected String getQualifiedName(ExecutionEvent event) {
XtextEditor activeXtextEditor = EditorUtils.getActiveXtextEditor(event);
if (activeXtextEditor == null) {
return null;
}
final ITextSelection selection = getTextSelection(activeXtextEditor);
return activeXtextEditor.getDocument().readOnly(new IUnitOfWork<String, XtextResource>() {
public String exec(XtextResource xTextResource) throws Exception {
EObject context = getContext(selection, xTextResource);
EObject selectedElement = getSelectedName(selection, xTextResource);
return getQualifiedName(selectedElement, context);
}
});
}
开发者ID:cplutte,项目名称:bts,代码行数:18,代码来源:EditorCopyQualifiedNameHandler.java
示例18: reconcileAllEditors
import org.eclipse.xtext.ui.editor.XtextEditor; //导入依赖的package包/类
public void reconcileAllEditors(IWorkbench workbench, final boolean saveAll, IProgressMonitor monitor) {
SubMonitor pm0 = SubMonitor.convert(monitor, workbench.getWorkbenchWindowCount());
for (IWorkbenchWindow window : workbench.getWorkbenchWindows()) {
SubMonitor pm1 = pm0.newChild(1).setWorkRemaining(window.getPages().length);
for (IWorkbenchPage page : window.getPages()) {
SubMonitor pm2 = pm1.newChild(1).setWorkRemaining(2 * page.getEditorReferences().length);
for (IEditorReference editorReference : page.getEditorReferences()) {
if (pm2.isCanceled())
return;
IEditorPart editor = editorReference.getEditor(false);
if (editor != null) {
if (editor instanceof XtextEditor)
waitForReconciler((XtextEditor) editor);
if (editor.isDirty() && saveAll)
editor.doSave(pm2.newChild(1));
}
pm2.worked(1);
}
}
}
}
开发者ID:cplutte,项目名称:bts,代码行数:22,代码来源:SyncUtil.java
示例19: getOriginalName
import org.eclipse.xtext.ui.editor.XtextEditor; //导入依赖的package包/类
protected String getOriginalName(final XtextEditor xtextEditor) {
return xtextEditor.getDocument().readOnly(new IUnitOfWork<String, XtextResource>() {
public String exec(XtextResource state) throws Exception {
try {
EObject targetElement = state.getResourceSet().getEObject(renameElementContext.getTargetElementURI(),
false);
IRenameStrategy.Provider strategyProvider = globalServiceProvider.findService(targetElement,
IRenameStrategy.Provider.class);
if (strategyProvider != null) {
IRenameStrategy strategy = strategyProvider.get(targetElement, renameElementContext);
if (strategy != null)
return strategy.getOriginalName();
}
} catch(NoSuchStrategyException e) {
// null
}
return null;
}
});
}
开发者ID:cplutte,项目名称:bts,代码行数:21,代码来源:RenameRefactoringController.java
示例20: updateEditorImage
import org.eclipse.xtext.ui.editor.XtextEditor; //导入依赖的package包/类
@Override
protected void updateEditorImage(final XtextEditor editor) {
Severity severity = null;
//
// try {
severity = getSeverity(editor);
//
// } catch (ResourceException e) {
// // do nothing, emitted when a marker cannot be found
// }
ImageDescriptor descriptor = null;
if (severity == null || severity == Severity.INFO) {
descriptor = GamaIcons.create(IGamaIcons.OVERLAY_OK).descriptor();
} else if (severity == Severity.ERROR) {
descriptor = GamaIcons.create("overlay.error2").descriptor();
} else if (severity == Severity.WARNING) {
descriptor = GamaIcons.create("overlay.warning2").descriptor();
} else {
super.updateEditorImage(editor);
return;
}
final DecorationOverlayIcon decorationOverlayIcon = new DecorationOverlayIcon(editor.getDefaultImage(),
descriptor, IDecoration.BOTTOM_LEFT);
scheduleUpdateEditor(decorationOverlayIcon);
}
开发者ID:gama-platform,项目名称:gama,代码行数:27,代码来源:GamlEditorTickUpdater.java
注:本文中的org.eclipse.xtext.ui.editor.XtextEditor类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论