use of org.eclipse.che.ide.api.editor.texteditor.TextEditor in project che by eclipse.
the class FindReferencesAction method actionPerformed.
@Override
public void actionPerformed(ActionEvent e) {
EditorPartPresenter activeEditor = editorAgent.getActiveEditor();
//TODO replace this
if (!(activeEditor instanceof TextEditor)) {
return;
}
TextEditor textEditor = ((TextEditor) activeEditor);
String path = activeEditor.getEditorInput().getFile().getLocation().toString();
ReferenceParamsDTO paramsDTO = dtoFactory.createDto(ReferenceParamsDTO.class);
PositionDTO positionDTO = dtoFactory.createDto(PositionDTO.class);
positionDTO.setLine(textEditor.getCursorPosition().getLine());
positionDTO.setCharacter(textEditor.getCursorPosition().getCharacter());
TextDocumentIdentifierDTO identifierDTO = dtoFactory.createDto(TextDocumentIdentifierDTO.class);
identifierDTO.setUri(path);
ReferenceContextDTO contextDTO = dtoFactory.createDto(ReferenceContextDTO.class);
contextDTO.setIncludeDeclaration(true);
paramsDTO.setUri(path);
paramsDTO.setPosition(positionDTO);
paramsDTO.setTextDocument(identifierDTO);
paramsDTO.setContext(contextDTO);
Promise<List<LocationDTO>> promise = client.references(paramsDTO);
presenter.openLocation(promise);
}
use of org.eclipse.che.ide.api.editor.texteditor.TextEditor in project che by eclipse.
the class EditorPartStackView method selectTab.
/** {@inheritDoc} */
@Override
public void selectTab(@NotNull PartPresenter partPresenter) {
IsWidget view = partPresenter.getView();
// set/remove attribute 'active' for Selenium tests
for (int i = 0; i < contentPanel.getWidgetCount(); i++) {
contentPanel.getWidget(i).getElement().removeAttribute("active");
}
view.asWidget().getElement().setAttribute("active", "");
int viewIndex = contentPanel.getWidgetIndex(view);
if (viewIndex < 0) {
partPresenter.go(partViewContainer);
viewIndex = contentPanel.getWidgetIndex(view);
}
contentPanel.showWidget(viewIndex);
setActiveTab(partPresenter);
if (partPresenter instanceof TextEditor) {
((TextEditor) partPresenter).activate();
}
}
use of org.eclipse.che.ide.api.editor.texteditor.TextEditor in project che by eclipse.
the class OrganizeImportsPresenter method onFinishButtonClicked.
/** {@inheritDoc} */
@Override
public void onFinishButtonClicked() {
selected.put(page, view.getSelectedImport());
ConflictImportDTO result = dtoFactory.createDto(ConflictImportDTO.class).withTypeMatches(new ArrayList<>(selected.values()));
if (file instanceof Resource) {
final Optional<Project> project = ((Resource) file).getRelatedProject();
javaCodeAssistClient.applyChosenImports(project.get().getLocation().toString(), JavaUtil.resolveFQN(file), result).then(new Operation<List<Change>>() {
@Override
public void apply(List<Change> result) throws OperationException {
applyChanges(((TextEditor) editor).getDocument(), result);
view.hide();
((TextEditor) editor).setFocus();
}
}).catchError(new Operation<PromiseError>() {
@Override
public void apply(PromiseError arg) throws OperationException {
String title = locale.failedToProcessOrganizeImports();
String message = arg.getMessage();
notificationManager.notify(title, message, FAIL, FLOAT_MODE);
}
});
}
}
use of org.eclipse.che.ide.api.editor.texteditor.TextEditor in project che by eclipse.
the class JsJavaEditorProvider method getEditor.
@Override
public TextEditor getEditor() {
LOG.fine("JsJavaEditor instance creation.");
final TextEditor textEditor = super.getEditor();
if (textEditor instanceof OrionEditorPresenter) {
final OrionEditorPresenter editor = (OrionEditorPresenter) textEditor;
final TextEditorConfiguration configuration = configurationFactory.create(editor);
editor.initialize(configuration);
editor.addEditorUpdateAction(new EditorUpdateAction() {
@Override
public void doRefresh() {
final Reconciler reconciler = configuration.getReconciler();
if (reconciler != null) {
final ReconcilingStrategy strategy = reconciler.getReconcilingStrategy(DEFAULT_CONTENT_TYPE);
if (strategy instanceof JavaReconcilerStrategy) {
((JavaReconcilerStrategy) strategy).parse();
}
}
}
});
}
watcher.editorOpened(textEditor);
return textEditor;
}
use of org.eclipse.che.ide.api.editor.texteditor.TextEditor in project che by eclipse.
the class FileStructurePresenter method show.
/**
* Shows the structure of the opened class.
*
* @param editorPartPresenter
* the active editor
*/
public void show(EditorPartPresenter editorPartPresenter) {
loader.show();
view.setTitle(editorPartPresenter.getEditorInput().getFile().getName());
if (!(editorPartPresenter instanceof TextEditor)) {
Log.error(getClass(), "Open Declaration support only TextEditor as editor");
return;
}
activeEditor = ((TextEditor) editorPartPresenter);
cursorOffset = activeEditor.getCursorOffset();
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);
javaNavigationService.getCompilationUnit(project.get().getLocation(), fqn, showInheritedMembers).then(new Operation<CompilationUnit>() {
@Override
public void apply(CompilationUnit unit) throws OperationException {
view.setStructure(unit, showInheritedMembers);
showInheritedMembers = !showInheritedMembers;
loader.hide();
view.show();
}
}).catchError(new Operation<PromiseError>() {
@Override
public void apply(PromiseError arg) throws OperationException {
Log.error(FileStructurePresenter.class, arg.getMessage());
loader.hide();
}
});
}
}
Aggregations