use of org.eclipse.che.ide.api.resources.Project in project che by eclipse.
the class GetEffectivePomAction method actionPerformed.
@Override
public void actionPerformed(ActionEvent e) {
final Resource[] resources = appContext.getResources();
checkState(resources != null && resources.length == 1);
final Project project = resources[0].getRelatedProject().get();
checkState(MAVEN_ID.equals(project.getType()));
mavenServerServiceClient.getEffectivePom(project.getLocation().toString()).then(new Operation<String>() {
@Override
public void apply(String content) throws OperationException {
editorAgent.openEditor(new SyntheticFile("pom.xml", project.getAttributes().get(MavenAttributes.ARTIFACT_ID).get(0) + " [effective pom]", content));
}
}).catchError(new Operation<PromiseError>() {
@Override
public void apply(PromiseError arg) throws OperationException {
notificationManager.notify("Problem with generating effective pom file", arg.getMessage(), FAIL, EMERGE_MODE);
}
});
}
use of org.eclipse.che.ide.api.resources.Project in project che by eclipse.
the class ReimportMavenDependenciesAction method getPathsToSelectedMavenProject.
private List<String> getPathsToSelectedMavenProject() {
final Resource[] resources = appContext.getResources();
if (resources == null) {
return Collections.emptyList();
}
Set<String> paths = new HashSet<>();
for (Resource resource : resources) {
final Optional<Project> project = resource.getRelatedProject();
if (project.isPresent() && project.get().isTypeOf(MAVEN_ID)) {
paths.add(project.get().getLocation().toString());
}
}
return new ArrayList<>(paths);
}
use of org.eclipse.che.ide.api.resources.Project in project che by eclipse.
the class ProjectClasspathPresenter method show.
/** Show dialog. */
public void show() {
final Resource[] resources = appContext.getResources();
Preconditions.checkState(resources != null && resources.length == 1);
final Optional<Project> project = resources[0].getRelatedProject();
Preconditions.checkState(isJavaProject(project.get()));
classpathContainer.getClasspathEntries(project.get().getLocation().toString()).then(new Operation<List<ClasspathEntryDto>>() {
@Override
public void apply(List<ClasspathEntryDto> arg) throws OperationException {
classpathResolver.resolveClasspathEntries(arg);
if (propertiesMap == null) {
propertiesMap = new HashMap<>();
for (ClasspathPagePresenter page : classpathPages) {
Set<ClasspathPagePresenter> pages = propertiesMap.get(page.getCategory());
if (pages == null) {
pages = new HashSet<>();
propertiesMap.put(page.getCategory(), pages);
}
pages.add(page);
}
view.setPages(propertiesMap);
}
view.show();
view.selectPage(propertiesMap.entrySet().iterator().next().getValue().iterator().next());
}
}).catchError(new Operation<PromiseError>() {
@Override
public void apply(PromiseError arg) throws OperationException {
notificationManager.notify("Problems with getting classpath", arg.getMessage(), FAIL, EMERGE_MODE);
}
});
}
use of org.eclipse.che.ide.api.resources.Project 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();
}
});
}
}
use of org.eclipse.che.ide.api.resources.Project in project che by eclipse.
the class FileStructurePresenter method actionPerformed.
/** {@inheritDoc} */
@Override
public void actionPerformed(final Member member) {
if (member.isBinary()) {
final Resource resource = context.getResource();
if (resource == null) {
return;
}
final Optional<Project> project = resource.getRelatedProject();
javaNavigationService.getEntry(project.get().getLocation(), member.getLibId(), member.getRootPath()).then(new Operation<JarEntry>() {
@Override
public void apply(final JarEntry entry) throws OperationException {
javaNavigationService.getContent(project.get().getLocation(), member.getLibId(), Path.valueOf(entry.getPath())).then(new Operation<ClassContent>() {
@Override
public void apply(ClassContent content) throws OperationException {
final String clazz = entry.getName().substring(0, entry.getName().indexOf('.'));
final VirtualFile file = new SyntheticFile(entry.getName(), clazz, content.getContent());
editorAgent.openEditor(file, new OpenEditorCallbackImpl() {
@Override
public void onEditorOpened(EditorPartPresenter editor) {
setCursor(editor, member.getFileRegion().getOffset());
}
});
}
});
}
});
} else {
context.getWorkspaceRoot().getFile(member.getRootPath()).then(new Operation<Optional<File>>() {
@Override
public void apply(Optional<File> file) throws OperationException {
if (file.isPresent()) {
editorAgent.openEditor(file.get(), new OpenEditorCallbackImpl() {
@Override
public void onEditorOpened(EditorPartPresenter editor) {
setCursor(editor, member.getFileRegion().getOffset());
}
});
}
}
});
}
Scheduler.get().scheduleDeferred(new Scheduler.ScheduledCommand() {
@Override
public void execute() {
setCursorPosition(member.getFileRegion());
}
});
showInheritedMembers = false;
}
Aggregations