本文整理汇总了Java中org.eclipse.che.ide.api.editor.EditorPartPresenter类的典型用法代码示例。如果您正苦于以下问题:Java EditorPartPresenter类的具体用法?Java EditorPartPresenter怎么用?Java EditorPartPresenter使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
EditorPartPresenter类属于org.eclipse.che.ide.api.editor包,在下文中一共展示了EditorPartPresenter类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: PartStackPresenter
import org.eclipse.che.ide.api.editor.EditorPartPresenter; //导入依赖的package包/类
@Inject
public PartStackPresenter(
final EventBus eventBus,
final PartMenu partMenu,
PartStackEventHandler partStackEventHandler,
TabItemFactory tabItemFactory,
PartsComparator partsComparator,
@Assisted final PartStackView view,
@Assisted @NotNull WorkBenchPartController workBenchPartController) {
this.view = view;
this.view.setDelegate(this);
this.eventBus = eventBus;
this.partMenu = partMenu;
this.partStackHandler = partStackEventHandler;
this.workBenchPartController = workBenchPartController;
this.tabItemFactory = tabItemFactory;
this.partsComparator = partsComparator;
this.parts = new HashMap<>();
this.constraints = new LinkedHashMap<>();
this.propertyListener =
new PropertyListener() {
@Override
public void propertyChanged(PartPresenter source, int propId) {
if (PartPresenter.TITLE_PROPERTY == propId) {
updatePartTab(source);
} else if (EditorPartPresenter.PROP_DIRTY == propId) {
eventBus.fireEvent(new EditorDirtyStateChangedEvent((EditorPartPresenter) source));
}
}
};
if (workBenchPartController != null) {
this.workBenchPartController.setSize(DEFAULT_PART_SIZE);
}
currentSize = DEFAULT_PART_SIZE;
}
示例2: trackEditor
import org.eclipse.che.ide.api.editor.EditorPartPresenter; //导入依赖的package包/类
/**
* Begins to track given editor to sync its content with opened files with the same {@link Path}.
*
* @param editor editor to sync content
*/
@Override
public void trackEditor(EditorPartPresenter editor) {
Path path = editor.getEditorInput().getFile().getLocation();
if (editorGroups.containsKey(path)) {
editorGroups.get(path).addEditor(editor);
} else {
EditorGroupSynchronization group = editorGroupSyncProvider.get();
editorGroups.put(path, group);
group.addEditor(editor);
}
}
示例3: isResourceOpened
import org.eclipse.che.ide.api.editor.EditorPartPresenter; //导入依赖的package包/类
private boolean isResourceOpened(final Resource resource) {
if (!resource.isFile()) {
return false;
}
File file = (File) resource;
for (EditorPartPresenter editor : editorAgent.getOpenedEditors()) {
Path editorPath = editor.getEditorInput().getFile().getLocation();
if (editorPath.equals(file.getLocation())) {
return true;
}
}
return false;
}
示例4: updateInPerspective
import org.eclipse.che.ide.api.editor.EditorPartPresenter; //导入依赖的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);
}
示例5: setCursorAndActivateEditor
import org.eclipse.che.ide.api.editor.EditorPartPresenter; //导入依赖的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);
}
示例6: changeBreakpointState
import org.eclipse.che.ide.api.editor.EditorPartPresenter; //导入依赖的package包/类
@Override
public void changeBreakpointState(final int lineNumber) {
EditorPartPresenter editor = editorAgent.getActiveEditor();
if (editor == null) {
return;
}
final VirtualFile activeFile = editor.getEditorInput().getFile();
Optional<Breakpoint> existedBreakpoint =
breakpointStorage.get(activeFile.getLocation().toString(), lineNumber + 1);
if (existedBreakpoint.isPresent()) {
delete(existedBreakpoint.get());
} else {
if (activeFile instanceof HasLocation) {
addBreakpoint(
activeFile, new BreakpointImpl(((HasLocation) activeFile).toLocation(lineNumber + 1)));
} else {
LOG.warning("Impossible to figure debug location for: " + activeFile.getLocation());
return;
}
}
}
示例7: onOpenEditor
import org.eclipse.che.ide.api.editor.EditorPartPresenter; //导入依赖的package包/类
/** The new file has been opened in the editor. Method reads breakpoints. */
private void onOpenEditor(String filePath, EditorPartPresenter editor) {
final BreakpointRenderer renderer = getBreakpointRendererForEditor(editor);
if (renderer != null) {
breakpointStorage
.getByPath(filePath)
.forEach(
breakpoint ->
renderer.setBreakpointMark(
breakpoint,
activeBreakpoints.contains(breakpoint),
BreakpointManagerImpl.this::onLineChange));
if (suspendedLocation != null && suspendedLocation.getTarget().equals(filePath)) {
renderer.setLineActive(suspendedLocation.getLineNumber() - 1, true);
}
}
}
示例8: restore
import org.eclipse.che.ide.api.editor.EditorPartPresenter; //导入依赖的package包/类
private List<Promise<Void>> restore(
JsonObject files,
EditorPartStack editorPartStack,
Map<EditorPartPresenter, EditorPartStack> activeEditors) {
if (files.hasKey("FILES")) {
// plain
JsonArray filesArray = files.getArray("FILES");
List<Promise<Void>> promises = new ArrayList<>();
for (int i = 0; i < filesArray.length(); i++) {
JsonObject file = filesArray.getObject(i);
Promise<Void> openFile = openFile(file, editorPartStack, activeEditors);
promises.add(openFile);
}
return promises;
} else {
// split
return restoreSplit(files, editorPartStack, activeEditors);
}
}
示例9: updateInPerspective
import org.eclipse.che.ide.api.editor.EditorPartPresenter; //导入依赖的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);
}
示例10: storeEditors
import org.eclipse.che.ide.api.editor.EditorPartPresenter; //导入依赖的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;
}
示例11: EditorTabContextMenu
import org.eclipse.che.ide.api.editor.EditorPartPresenter; //导入依赖的package包/类
@Inject
public EditorTabContextMenu(
@Assisted EditorTab editorTab,
@Assisted EditorPartPresenter editorPart,
@Assisted EditorPartStack editorPartStack,
ActionManager actionManager,
KeyBindingAgent keyBindingAgent,
Provider<PerspectiveManager> managerProvider) {
super(actionManager, keyBindingAgent, managerProvider);
this.editorTab = editorTab;
this.editorPart = editorPart;
this.editorPartStack = editorPartStack;
this.actionManager = actionManager;
}
示例12: updateListClosedParts
import org.eclipse.che.ide.api.editor.EditorPartPresenter; //导入依赖的package包/类
private void updateListClosedParts(VirtualFile file) {
if (closedParts.isEmpty()) {
return;
}
for (EditorPartPresenter closedEditorPart : closedParts) {
Path path = closedEditorPart.getEditorInput().getFile().getLocation();
if (path.equals(file.getLocation())) {
closedParts.remove(closedEditorPart);
return;
}
}
}
示例13: editorOpened
import org.eclipse.che.ide.api.editor.EditorPartPresenter; //导入依赖的package包/类
public void editorOpened(final EditorPartPresenter editor) {
final PropertyListener propertyListener =
new PropertyListener() {
@Override
public void propertyChanged(PartPresenter source, int propId) {
if (propId == EditorPartPresenter.PROP_DIRTY) {
if (!editor.isDirty()) {
reparseAllOpenedFiles();
// remove just saved editor
editor2reconcile.remove(editor);
}
}
}
};
editor.addPropertyListener(propertyListener);
}
示例14: actionPerformed
import org.eclipse.che.ide.api.editor.EditorPartPresenter; //导入依赖的package包/类
@Override
public void actionPerformed(ActionEvent e) {
ContributePartPresenter contributePartPresenter = contributePartPresenterProvider.get();
PartPresenter activePart = workspaceAgent.getActivePart();
if (activePart != null && activePart instanceof ContributePartPresenter) {
workspaceAgent.hidePart(contributePartPresenter);
EditorPartPresenter activeEditor = editorAgent.getActiveEditor();
if (activeEditor != null) {
workspaceAgent.setActivePart(activeEditor);
}
return;
}
workspaceAgent.openPart(contributePartPresenter, TOOLING);
workspaceAgent.setActivePart(contributePartPresenter);
}
示例15: actionPerformed
import org.eclipse.che.ide.api.editor.EditorPartPresenter; //导入依赖的package包/类
@Override
public void actionPerformed(ActionEvent e) {
Debugger debugger = debuggerManager.getActiveDebugger();
if (debugger != null) {
EditorPartPresenter activeEditor = editorAgent.getActiveEditor();
if (activeEditor instanceof TextEditor) {
int lineNumber = ((TextEditor) activeEditor).getCursorPosition().getLine() + 1;
VirtualFile file = activeEditor.getEditorInput().getFile();
if (file instanceof HasLocation) {
Location location = ((HasLocation) file).toLocation(lineNumber);
debugger.runToLocation(location);
}
}
}
}