本文整理汇总了Java中org.eclipse.che.ide.api.editor.texteditor.TextEditor类的典型用法代码示例。如果您正苦于以下问题:Java TextEditor类的具体用法?Java TextEditor怎么用?Java TextEditor使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TextEditor类属于org.eclipse.che.ide.api.editor.texteditor包,在下文中一共展示了TextEditor类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: selectRange
import org.eclipse.che.ide.api.editor.texteditor.TextEditor; //导入依赖的package包/类
private void selectRange(EditorPartPresenter editor) {
if (editor instanceof TextEditor) {
((TextEditor) editor)
.getDocument()
.setSelectedRange(
LinearRange.createWithStart(searchOccurrence.getStartOffset())
.andEnd(searchOccurrence.getEndOffset()),
true);
}
}
示例2: scrollToLine
import org.eclipse.che.ide.api.editor.texteditor.TextEditor; //导入依赖的package包/类
private void scrollToLine(EditorPartPresenter editor, String lineParam) {
if (!(editor instanceof TextEditor)) {
return;
}
new Timer() {
@Override
public void run() {
try {
int lineNumber = parseInt(lineParam);
TextEditor textEditor = (TextEditor) editor;
textEditor.getDocument().setCursorPosition(new TextPosition(lineNumber - 1, 0));
} catch (NumberFormatException e) {
Log.error(getClass(), localization.fileToOpenLineIsNotANumber());
}
}
}.schedule(300);
}
示例3: selectRange
import org.eclipse.che.ide.api.editor.texteditor.TextEditor; //导入依赖的package包/类
/**
* Selects and shows the specified line and column of text in editor
*
* @param editor
* @param line
* @param column
*/
protected void selectRange(EditorPartPresenter editor, int line, int column) {
line--;
column--;
if (line < 0) line = 0;
if (editor instanceof TextEditor) {
Document document = ((TextEditor) editor).getDocument();
LinearRange selectionRange = document.getLinearRangeForLine(line);
if (column >= 0) {
selectionRange =
LinearRange.createWithStart(selectionRange.getStartOffset() + column).andLength(0);
}
document.setSelectedRange(selectionRange, true);
document.setCursorPosition(new TextPosition(line, column >= 0 ? column : 0));
}
}
示例4: doCloseEditor
import org.eclipse.che.ide.api.editor.texteditor.TextEditor; //导入依赖的package包/类
private void doCloseEditor(EditorTab tab) {
checkArgument(tab != null, "Null editor tab occurred");
EditorPartPresenter editor = tab.getRelativeEditorPart();
if (editor == null) {
return;
}
openedEditors.remove(editor);
openedEditorsToProviders.remove(editor);
editor.close(false);
if (editor instanceof TextEditor) {
editorContentSynchronizer.unTrackEditor(editor);
}
if (activeEditor != null && activeEditor == editor) {
activeEditor = null;
}
eventBus.fireEvent(FileEvent.createFileClosedEvent(tab));
}
示例5: finalizeInit
import org.eclipse.che.ide.api.editor.texteditor.TextEditor; //导入依赖的package包/类
private void finalizeInit(
VirtualFile file, EditorPartPresenter editor, EditorProvider editorProvider) {
openedEditorsToProviders.put(editor, editorProvider.getId());
editor.addCloseHandler(this);
editor.addPropertyListener(
(source, propId) -> {
if (propId == EditorPartPresenter.PROP_INPUT) {
if (editor instanceof HasReadOnlyProperty) {
((HasReadOnlyProperty) editor).setReadOnly(file.isReadOnly());
}
if (editor instanceof TextEditor) {
editorContentSynchronizer.trackEditor(editor);
}
eventBus.fireEvent(FileEvent.createFileOpenedEvent(file));
}
});
}
示例6: storeEditors
import org.eclipse.che.ide.api.editor.texteditor.TextEditor; //导入依赖的package包/类
private JsonArray storeEditors(EditorPartStack partStack) {
JsonArray result = Json.createArray();
int i = 0;
List<EditorPartPresenter> parts = partStack.getParts();
for (EditorPartPresenter part : parts) {
JsonObject file = Json.createObject();
file.put("PATH", part.getEditorInput().getFile().getLocation().toString());
file.put("EDITOR_PROVIDER", openedEditorsToProviders.get(part));
if (part instanceof TextEditor) {
file.put("CURSOR_OFFSET", ((TextEditor) part).getCursorOffset());
file.put("TOP_VISIBLE_LINE", ((TextEditor) part).getTopVisibleLine());
}
if (partStack.getActivePart().equals(part)) {
file.put("ACTIVE", true);
}
result.set(i++, file);
}
return result;
}
示例7: setCursorAndActivateEditor
import org.eclipse.che.ide.api.editor.texteditor.TextEditor; //导入依赖的package包/类
private void setCursorAndActivateEditor(final EditorPartPresenter editor, final int offset) {
/*
For some undefined reason we need to wrap cursor and focus setting into timer with 1ms.
When editors are switching, they don't have enough time to redraw and set focus. Need
to investigate this problem more deeply. But at this moment this trick works as well.
*/
new DelayedTask() {
@Override
public void onExecute() {
if (editor instanceof TextEditor) {
((TextEditor) editor)
.getDocument()
.setSelectedRange(LinearRange.createWithStart(offset).andLength(0), true);
editor.activate(); // force set focus to the editor
}
}
}.delay(1);
}
示例8: actionPerformed
import org.eclipse.che.ide.api.editor.texteditor.TextEditor; //导入依赖的package包/类
@Override
public void actionPerformed(ActionEvent e) {
DocumentSymbolParams paramsDTO = dtoFactory.createDto(DocumentSymbolParams.class);
TextDocumentIdentifier identifierDTO = dtoFactory.createDto(TextDocumentIdentifier.class);
identifierDTO.setUri(
editorAgent.getActiveEditor().getEditorInput().getFile().getLocation().toString());
paramsDTO.setTextDocument(identifierDTO);
activeEditor = (TextEditor) editorAgent.getActiveEditor();
cursorPosition = activeEditor.getDocument().getCursorPosition();
client
.documentSymbol(paramsDTO)
.then(
arg -> {
cachedItems = arg;
presenter.run(GoToSymbolAction.this);
})
.catchError(
arg -> {
notificationManager.notify(
"Can't fetch document symbols.",
arg.getMessage(),
StatusNotification.Status.FAIL,
StatusNotification.DisplayMode.FLOAT_MODE);
});
}
示例9: updateInPerspective
import org.eclipse.che.ide.api.editor.texteditor.TextEditor; //导入依赖的package包/类
@Override
public void updateInPerspective(@NotNull ActionEvent event) {
EditorPartPresenter activeEditor = editorAgent.getActiveEditor();
if (Objects.nonNull(activeEditor) && activeEditor instanceof TextEditor) {
TextEditorConfiguration configuration = ((TextEditor) activeEditor).getConfiguration();
if (configuration instanceof LanguageServerEditorConfiguration) {
ServerCapabilities capabilities =
((LanguageServerEditorConfiguration) configuration).getServerCapabilities();
event
.getPresentation()
.setEnabledAndVisible(
capabilities.getDocumentSymbolProvider() != null
&& capabilities.getDocumentSymbolProvider());
return;
}
}
event.getPresentation().setEnabledAndVisible(false);
}
示例10: SymbolEntry
import org.eclipse.che.ide.api.editor.texteditor.TextEditor; //导入依赖的package包/类
public SymbolEntry(
String name,
String type,
String description,
TextRange range,
TextEditor editor,
List<Match> highlights,
SVGResource icon) {
this.name = name;
this.type = type;
this.description = description;
this.range = range;
this.editor = editor;
this.icon = icon;
setHighlights(highlights);
}
示例11: updateInPerspective
import org.eclipse.che.ide.api.editor.texteditor.TextEditor; //导入依赖的package包/类
@Override
public void updateInPerspective(@NotNull ActionEvent event) {
EditorPartPresenter activeEditor = editorAgent.getActiveEditor();
if (activeEditor instanceof TextEditor) {
TextEditorConfiguration configuration = ((TextEditor) activeEditor).getConfiguration();
if (configuration instanceof LanguageServerEditorConfiguration) {
ServerCapabilities capabilities =
((LanguageServerEditorConfiguration) configuration).getServerCapabilities();
event
.getPresentation()
.setEnabledAndVisible(
capabilities.getReferencesProvider() != null
&& capabilities.getReferencesProvider());
return;
}
}
event.getPresentation().setEnabledAndVisible(false);
}
示例12: updateInPerspective
import org.eclipse.che.ide.api.editor.texteditor.TextEditor; //导入依赖的package包/类
@Override
public void updateInPerspective(@NotNull ActionEvent event) {
EditorPartPresenter activeEditor = editorAgent.getActiveEditor();
if (Objects.nonNull(activeEditor) && activeEditor instanceof TextEditor) {
TextEditorConfiguration configuration = ((TextEditor) activeEditor).getConfiguration();
if (configuration instanceof LanguageServerEditorConfiguration) {
ServerCapabilities capabilities =
((LanguageServerEditorConfiguration) configuration).getServerCapabilities();
event
.getPresentation()
.setEnabledAndVisible(
capabilities.getWorkspaceSymbolProvider() != null
&& capabilities.getWorkspaceSymbolProvider());
return;
}
}
event.getPresentation().setEnabledAndVisible(false);
}
示例13: updateInPerspective
import org.eclipse.che.ide.api.editor.texteditor.TextEditor; //导入依赖的package包/类
@Override
public void updateInPerspective(@NotNull ActionEvent event) {
EditorPartPresenter activeEditor = editorAgent.getActiveEditor();
if (activeEditor instanceof TextEditor) {
TextEditorConfiguration configuration = ((TextEditor) activeEditor).getConfiguration();
if (configuration instanceof LanguageServerEditorConfiguration) {
ServerCapabilities capabilities =
((LanguageServerEditorConfiguration) configuration).getServerCapabilities();
event
.getPresentation()
.setEnabledAndVisible(
capabilities.getDefinitionProvider() != null
&& capabilities.getDefinitionProvider());
return;
}
}
event.getPresentation().setEnabledAndVisible(false);
}
示例14: actionPerformed
import org.eclipse.che.ide.api.editor.texteditor.TextEditor; //导入依赖的package包/类
@Override
public void actionPerformed(ActionEvent e) {
EditorPartPresenter activeEditor = editorAgent.getActiveEditor();
TextEditor textEditor = ((TextEditor) activeEditor);
TextDocumentPositionParams paramsDTO =
dtoBuildHelper.createTDPP(textEditor.getDocument(), textEditor.getCursorPosition());
final Promise<List<Location>> promise = client.definition(paramsDTO);
promise
.then(
arg -> {
if (arg.size() == 1) {
presenter.onLocationSelected(arg.get(0));
} else {
presenter.openLocation(promise);
}
})
.catchError(
arg -> {
presenter.showError(arg);
});
}
示例15: showWindow
import org.eclipse.che.ide.api.editor.texteditor.TextEditor; //导入依赖的package包/类
private void showWindow(TextPosition cursorPosition, TextEditor editor, String oldName) {
String value = inputBox.getInputValue();
inputBox.hide(false);
inputBox = null;
showPreview = false;
RenameDialog renameDialog = this.renameWindow.get();
renameDialog.show(
value,
oldName,
newName -> {
renameDialog.closeDialog();
callRename(newName, cursorPosition, editor);
},
newName -> {
showPreview = true;
renameDialog.closeDialog();
callRename(newName, cursorPosition, editor);
},
() -> {
renameDialog.closeDialog();
editor.setFocus();
});
}