use of org.eclipse.che.ide.api.editor.texteditor.TextEditor in project che by eclipse.
the class QuickDocPresenter method showDocumentation.
@Override
public void showDocumentation() {
EditorPartPresenter activeEditor = editorAgent.getActiveEditor();
if (activeEditor == null) {
return;
}
if (!(activeEditor instanceof TextEditor)) {
Log.error(getClass(), "Quick Document support only TextEditor as editor");
return;
}
TextEditor editor = ((TextEditor) activeEditor);
int offset = editor.getCursorOffset();
final PositionConverter.PixelCoordinates coordinates = editor.getPositionConverter().offsetToPixel(offset);
final Resource resource = appContext.getResource();
if (resource != null) {
final Optional<Project> project = resource.getRelatedProject();
final Optional<Resource> srcFolder = resource.getParentWithMarker(SourceFolderMarker.ID);
if (!srcFolder.isPresent()) {
return;
}
final String fqn = JavaUtil.resolveFQN((Container) srcFolder.get(), resource);
final String docUrl = appContext.getDevMachine().getWsAgentBaseUrl() + "/java/javadoc/find?fqn=" + fqn + "&projectpath=" + project.get().getLocation() + "&offset=" + offset;
view.show(agentURLDecorator.modify(docUrl), coordinates.getX(), coordinates.getY());
}
}
use of org.eclipse.che.ide.api.editor.texteditor.TextEditor in project che by eclipse.
the class FileWatcher method handleFileOperations.
@Inject
private void handleFileOperations(EventBus eventBus) {
eventBus.addHandler(ResourceChangedEvent.getType(), new ResourceChangedEvent.ResourceChangedHandler() {
@Override
public void onResourceChanged(ResourceChangedEvent event) {
if (event.getDelta().getKind() != REMOVED) {
return;
}
if ((event.getDelta().getFlags() & DERIVED) == 0) {
return;
}
final Resource resource = event.getDelta().getResource();
final Optional<Resource> srcFolder = resource.getParentWithMarker(SourceFolderMarker.ID);
if (srcFolder.isPresent()) {
reparseAllOpenedFiles();
}
}
});
eventBus.addHandler(ActivePartChangedEvent.TYPE, new ActivePartChangedHandler() {
@Override
public void onActivePartChanged(ActivePartChangedEvent event) {
if (event.getActivePart() instanceof TextEditor) {
if (editor2reconcile.contains(event.getActivePart())) {
reParseEditor((TextEditor) event.getActivePart());
}
}
}
});
}
use of org.eclipse.che.ide.api.editor.texteditor.TextEditor in project che by eclipse.
the class OpenImplementationPresenter method show.
/**
* Shows the implementations of the selected element.
*
* @param editorPartPresenter
* the active editor
*/
public void show(final EditorPartPresenter editorPartPresenter) {
if (!(editorPartPresenter instanceof TextEditor)) {
Log.error(getClass(), "Open Declaration support only TextEditor as editor");
return;
}
activeEditor = ((TextEditor) editorPartPresenter);
final VirtualFile file = activeEditor.getEditorInput().getFile();
if (file instanceof Resource) {
final Optional<Project> project = ((Resource) file).getRelatedProject();
final Optional<Resource> srcFolder = ((Resource) file).getParentWithMarker(SourceFolderMarker.ID);
if (!srcFolder.isPresent()) {
return;
}
final String fqn = JavaUtil.resolveFQN((Container) srcFolder.get(), (Resource) file);
service.getImplementations(project.get().getLocation(), fqn, activeEditor.getCursorOffset()).then(new Operation<ImplementationsDescriptorDTO>() {
@Override
public void apply(ImplementationsDescriptorDTO impls) throws OperationException {
int overridingSize = impls.getImplementations().size();
String title = locale.openImplementationWindowTitle(impls.getMemberName(), overridingSize);
NoImplementationWidget noImplementationWidget = new NoImplementationWidget(popupResources, javaResources, locale, OpenImplementationPresenter.this, title);
if (overridingSize == 1) {
actionPerformed(impls.getImplementations().get(0));
} else if (overridingSize > 1) {
openOneImplementation(impls, noImplementationWidget, (TextEditor) editorPartPresenter);
} else if (!isNullOrEmpty(impls.getMemberName()) && overridingSize == 0) {
showNoImplementations(noImplementationWidget, (TextEditor) editorPartPresenter);
}
}
});
}
}
use of org.eclipse.che.ide.api.editor.texteditor.TextEditor in project che by eclipse.
the class JavaQuickAssistProcessor method computeQuickAssistProposals.
@Override
public void computeQuickAssistProposals(final QuickAssistInvocationContext quickAssistContext, final CodeAssistCallback callback) {
final TextEditor textEditor = quickAssistContext.getTextEditor();
final Document document = textEditor.getDocument();
LinearRange tempRange;
tempRange = textEditor.getSelectedLinearRange();
final LinearRange range = tempRange;
final boolean goToClosest = (range.getLength() == 0);
final QueryAnnotationsEvent.AnnotationFilter filter = new QueryAnnotationsEvent.AnnotationFilter() {
@Override
public boolean accept(final Annotation annotation) {
if (!(annotation instanceof JavaAnnotation)) {
return false;
} else {
JavaAnnotation javaAnnotation = (JavaAnnotation) annotation;
return (!javaAnnotation.isMarkedDeleted());
}
}
};
final QueryAnnotationsEvent.QueryCallback queryCallback = new QueryAnnotationsEvent.QueryCallback() {
@Override
public void respond(final Map<Annotation, Position> annotations) {
List<Problem> problems = new ArrayList<>();
/*final Map<Annotation, Position> problems =*/
int offset = collectQuickFixableAnnotations(range, document, annotations, goToClosest, problems);
if (offset != range.getStartOffset()) {
TextEditor presenter = ((TextEditor) textEditor);
presenter.getCursorModel().setCursorPosition(offset);
}
setupProposals(callback, textEditor, offset, problems);
}
};
final QueryAnnotationsEvent event = new QueryAnnotationsEvent.Builder().withFilter(filter).withCallback(queryCallback).build();
document.getDocumentHandle().getDocEventBus().fireEvent(event);
}
use of org.eclipse.che.ide.api.editor.texteditor.TextEditor in project che by eclipse.
the class ParametersHintsAction method actionPerformed.
@Override
public void actionPerformed(ActionEvent event) {
EditorPartPresenter activeEditor = editorAgent.getActiveEditor();
if (!(activeEditor instanceof TextEditor)) {
return;
}
parametersHintsPresenter.show((TextEditor) activeEditor);
}
Aggregations