use of org.eclipse.che.ide.project.node.SyntheticNode 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;
}
Aggregations