use of org.eclipse.che.ide.api.editor.EditorAgent in project che by eclipse.
the class AppContextImpl method getRootProject.
@Override
public Project getRootProject() {
if (projects == null) {
return null;
}
if (currentResource == null || currentResources == null) {
EditorAgent editorAgent = editorAgentProvider.get();
if (editorAgent == null) {
return null;
}
final EditorPartPresenter editor = editorAgent.getActiveEditor();
if (editor == null) {
return null;
}
final VirtualFile file = editor.getEditorInput().getFile();
if (file instanceof SyntheticNode) {
final Path projectPath = ((SyntheticNode) file).getProject();
for (Project project : projects) {
if (project.getLocation().equals(projectPath)) {
return project;
}
}
}
}
if (currentResource == null) {
return null;
}
Project root = null;
for (Project project : projects) {
if (project.getLocation().isPrefixOf(currentResource.getLocation())) {
root = project;
}
}
if (root == null) {
return null;
}
for (int i = 1; i < currentResources.length; i++) {
if (!root.getLocation().isPrefixOf(currentResources[i].getLocation())) {
return null;
}
}
return root;
}
use of org.eclipse.che.ide.api.editor.EditorAgent in project che by eclipse.
the class AppContextImpl method onWorkspaceStopped.
@Override
public void onWorkspaceStopped(WorkspaceStoppedEvent event) {
appStateManager.get().persistWorkspaceState(getWorkspaceId()).then(ignored -> {
for (Project project : projects) {
eventBus.fireEvent(new ResourceChangedEvent(new ResourceDeltaImpl(project, REMOVED)));
}
projects = NO_PROJECTS;
resourceManager = null;
});
//goto close all editors
final EditorAgent editorAgent = editorAgentProvider.get();
final List<EditorPartPresenter> openedEditors = editorAgent.getOpenedEditors();
for (EditorPartPresenter editor : openedEditors) {
editorAgent.closeEditor(editor);
}
runtime = null;
}
Aggregations