/** * 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); }
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; } } } } }); } }
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); }); }
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); } }); }
/** * 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(); }
/** {@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; }
/** * 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; }
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; }
/** * 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(); }
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; } }); }
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; }
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; }
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; }
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; }
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; }
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)); }
@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); } }); }
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); } } } }
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; } }); }
@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); }
@Override public boolean test(Object receiver, String property, Object[] args, Object expectedValue) { if (!(receiver instanceof XtextEditor)) { return false; } XtextEditor editor = (XtextEditor) receiver; ISelection selection = editor.getSelectionProvider().getSelection(); if (!(selection instanceof ITextSelection)) { return false; } ITextSelection textSelection = (ITextSelection) selection; Optional<EObject> foundEObject = EditorHandlingUtils.findEObjectAtPosition(editor, textSelection); return foundEObject.filter(UMLReferencingElement.class::isInstance).map(UMLReferencingElement.class::cast) .filter(e -> !RenameUMLElementRefactoringFilterRegistry.getInstance().getFilters().stream() .anyMatch(f -> f.prohibitRefactoring(e))) .map(UMLReferencingElement::getReferencedElement).map(NamedElement.class::isInstance).orElse(false); }
@Override public void selectionChanged(IWorkbenchPart part, ISelection selection) { if (part instanceof XtextEditor && !selection.isEmpty()) { final XtextEditor editor = (XtextEditor) part; final IXtextDocument document = editor.getDocument(); document.readOnly(new IUnitOfWork.Void<XtextResource>() { @Override public void process(XtextResource resource) throws Exception { IParseResult parseResult = resource.getParseResult(); if (parseResult != null) { ICompositeNode root = parseResult.getRootNode(); EObject taxonomy = NodeModelUtils.findActualSemanticObjectFor(root); if (taxonomy instanceof Model) { ModelRegistryPlugin.getModelRegistry().setActiveTaxonomy((Model) taxonomy); } } } }); } }
@Override public void beforeDispose(XtextEditor editor) { super.beforeDispose(editor); try { deleteEditorOpenIndicatorFile(editor); if (visitor != null) { SadlModelManager smm = null; URI uri = null; IPath prjLoc = getEditorProject(editor); uri = URI.createURI(new SadlUtils().fileNameToFileUrl(prjLoc.toOSString())); URI prjUri = ResourceManager.getProjectUri(uri); smm = visitor.get(prjUri); if (smm != null) { IConfigurationManagerForIDE configMgr = smm.getConfigurationMgr(ResourceManager.getOwlModelsFolder(uri)); configMgr.saveConfiguration(); configMgr.saveOntPolicyFile(); } } } catch (Exception e) { e.printStackTrace(); } }
@Override public void partActivated(final IWorkbenchPart part) { if (part instanceof XtextEditor) { XtextEditor xtextEditor = (XtextEditor) part; IXtextDocument xtextDocument = xtextEditor.getDocument(); if (xtextDocument != lastActiveDocument) { selectionLinker.setXtextEditor(xtextEditor); final IFigure contents = xtextDocument.readOnly(new IUnitOfWork<IFigure, XtextResource>() { @Override public IFigure exec(final XtextResource resource) throws Exception { return createFigure(resource); } }); if (contents != null) { view.setContents(contents); if (lastActiveDocument != null) { lastActiveDocument.removeModelListener(this); } lastActiveDocument = xtextDocument; lastActiveDocument.addModelListener(this); } } } }
public void determineNature(XtextEditor editor, Logger log) { // let's see what project this is. IProject project = editor.getResource().getProject(); System.out.println(project); try { IProjectDescription description = project.getDescription(); String[] natures = description.getNatureIds(); boolean aadlNature = false; for (String nature: natures) { if (nature.equalsIgnoreCase("org.osate.core.aadlnature")) { aadlNature = true; } } if (!aadlNature) { log.warn("WARNING: Project does not have aadl nature; this will likely fail during compilation because of missing property sets. Please create a project with aadl nature."); } } catch (Exception e) { log.warn("WARNING: Unable to determine nature of project; if it does not have aadl nature it will likely fail during compilation. Please create a project with aadl nature."); } }
public void determineNature(XtextEditor editor, Logger log) { // let's see what project this is. IProject project = editor.getResource().getProject(); System.out.println(project); try { IProjectDescription description = project.getDescription(); String[] natures = description.getNatureIds(); boolean aadlNature = false; for (String nature: natures) { if (nature.equalsIgnoreCase("org.osate.core.aadlnature")) { aadlNature = true; } } if (!aadlNature) { log.warn("WARNING: Project does not have aadl nature; this will likely fail during compilation because of missing property sets. Please create a project with aadl nature."); } else { } } catch (Exception e) { log.warn("WARNING: Unable to determine nature of project; if it does not have aadl nature it will likely fail during compilation. Please create a project with aadl nature."); } }
private URI getSelectionURI(ISelection currentSelection) { if (currentSelection instanceof IStructuredSelection) { IStructuredSelection iss = (IStructuredSelection) currentSelection; if (iss.size() == 1) { EObjectNode node = (EObjectNode) iss.getFirstElement(); return node.getEObjectURI(); } } else if (currentSelection instanceof TextSelection) { // Selection may be stale, get latest from editor XtextEditor xtextEditor = EditorUtils.getActiveXtextEditor(); TextSelection ts = (TextSelection) xtextEditor.getSelectionProvider().getSelection(); return xtextEditor.getDocument().readOnly(resource -> { EObject e = new EObjectAtOffsetHelper().resolveContainedElementAt(resource, ts.getOffset()); return EcoreUtil2.getURI(e); }); } return null; }
/***/ protected XtextEditor openAndGetXtextEditor(final IFile file1, final IWorkbenchPage page) { IEditorPart fileEditor = getFileEditor(file1, page); assertTrue(fileEditor instanceof XtextEditor); XtextEditor fileXtextEditor = (XtextEditor) fileEditor; return fileXtextEditor; }
/** * Will only return parse errors, not validation errors! */ protected List<Resource.Diagnostic> getEditorErrors(XtextEditor fileXtextEditor) { return fileXtextEditor.getDocument().readOnly(new IUnitOfWork<List<Diagnostic>, XtextResource>() { @Override public List<Resource.Diagnostic> exec(XtextResource state) throws Exception { EcoreUtil.resolveAll(state); return state.getErrors(); } }); }
/** * Returns validation errors in given Xtext editor. */ protected List<Issue> getEditorValidationErrors(XtextEditor editor) { return editor.getDocument().readOnly(new IUnitOfWork<List<Issue>, XtextResource>() { @Override public List<Issue> exec(XtextResource state) throws Exception { final IResourceValidator validator = state.getResourceServiceProvider().getResourceValidator(); return validator.validate(state, CheckMode.ALL, CancelIndicator.NullImpl); } }); }
/***/ protected void setDocumentContent(String context, IFile file, XtextEditor fileEditor, String newContent) { IDirtyStateManager dirtyStateManager = getInjector().getInstance(IDirtyStateManager.class); TestEventListener eventListener = new TestEventListener(context, file); dirtyStateManager.addListener(eventListener); setDocumentContent(fileEditor, newContent); eventListener.waitForFiredEvent(); dirtyStateManager.removeListener(eventListener); waitForUpdateEditorJob(); }
/***/ protected void setDocumentContent(final XtextEditor xtextEditor, final String content) { Display.getCurrent().syncExec(new Runnable() { @Override public void run() { xtextEditor.getDocument().set(content); } }); }
@Override public void afterCreatePartControl(XtextEditor xtextEditor) { editor = xtextEditor; if (xtextEditor instanceof N4JSEditor) { ((N4JSEditor) xtextEditor).setErrorTickUpdater(this); } super.afterCreatePartControl(xtextEditor); }
@Override public void beforeDispose(XtextEditor xtextEditor) { editor = null; if (xtextEditor instanceof N4JSEditor) { ((N4JSEditor) xtextEditor).setErrorTickUpdater(null); } super.beforeDispose(xtextEditor); }
/** Organize provided editor. */ public static void organizeImportsInEditor(XtextEditor editor, final Interaction interaction) { try { IResource resource = editor.getResource(); DocumentImportsOrganizer imortsOrganizer = getOrganizeImports(resource); imortsOrganizer.organizeDocument(editor.getDocument(), interaction); } catch (RuntimeException re) { if (re.getCause() instanceof BreakException) { LOGGER.debug("user canceled"); } else { LOGGER.warn("Unrecognized RT-exception", re); } } }
@Override public void afterCreatePartControl(final XtextEditor editor) { super.afterCreatePartControl(editor); if (editor.isEditable()) { newValidationJob(editor).schedule(); } }
@Override public void afterSave(final XtextEditor editor) { super.afterSave(editor); if (editor.isEditable()) { newValidationJob(editor).schedule(); } }
private XtextEditor getEditor(URI uri) { // note: trimming fragment in previous line makes this more stable in case of changes to the // Xtext editor's contents (we are not interested in a particular element, just the editor) final URI uriToEditor = uri != null ? uri.trimFragment() : null; if (uriToEditor != null) { final IEditorPart editor = getEditorOpener().open(uriToEditor, false); if (editor instanceof XtextEditor) return (XtextEditor) editor; } return null; }
@Override public void afterCreatePartControl(XtextEditor editor) { IResource resource = editor.getResource(); if (resource != null && !toggleNature.hasNature(resource.getProject()) && resource.getProject().isAccessible() && !resource.getProject().isHidden()) { toggleNature.toggleNature(resource.getProject()); } }
@Override public void propertyChange(PropertyChangeEvent event) { super.propertyChange(event); XtextEditor editor = myEditor; XtextSourceViewer sourceViewer = mySourceViewer; if (editor instanceof N4JSEditor && sourceViewer != null && event.getProperty().contains(".syntaxColorer.tokenStyles")) { ((N4JSEditor) editor).initializeViewerColors(sourceViewer); sourceViewer.invalidateTextPresentation(); } }