use of org.eclipse.che.ide.ext.java.shared.dto.ClassContent in project che by eclipse.
the class OpenImplementationPresenter method actionPerformed.
public void actionPerformed(final Member member) {
if (member.isBinary()) {
final Resource resource = context.getResource();
if (resource == null) {
return;
}
final Optional<Project> project = resource.getRelatedProject();
service.getEntry(project.get().getLocation(), member.getLibId(), member.getRootPath()).then(new Operation<JarEntry>() {
@Override
public void apply(final JarEntry entry) throws OperationException {
service.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(member.getFileRegion());
}
});
}
});
}
});
} 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(member.getFileRegion());
}
});
}
}
});
}
Scheduler.get().scheduleDeferred(new Scheduler.ScheduledCommand() {
@Override
public void execute() {
activeEditor.setFocus();
}
});
}
use of org.eclipse.che.ide.ext.java.shared.dto.ClassContent in project che by eclipse.
the class JarNavigationTest method testNonJavaFileContent.
@Test
public void testNonJavaFileContent() throws Exception {
String javaHome = System.getProperty("java.home") + "/lib/ext/zipfs.jar";
IPackageFragmentRoot root = project.getPackageFragmentRoot(new File(javaHome).getPath());
ClassContent content = navigation.getContent(project, root.hashCode(), "/META-INF/services/java.nio.file.spi.FileSystemProvider");
assertThat(content.getContent()).isNotNull().isNotEmpty().contains("");
}
use of org.eclipse.che.ide.ext.java.shared.dto.ClassContent in project che by eclipse.
the class JarNavigationTest method testJavaSource.
@Test
@Ignore
public void testJavaSource() throws Exception {
String javaHome = System.getProperty("java.home") + "/lib/rt.jar";
IPackageFragmentRoot root = project.getPackageFragmentRoot(new File(javaHome).getPath());
ClassContent content = navigation.getContent(project, root.hashCode(), "java.lang.Object");
assertThat(content.getContent()).isNotNull().isNotEmpty().contains("public class Object");
}
use of org.eclipse.che.ide.ext.java.shared.dto.ClassContent in project che by eclipse.
the class OpenDeclarationFinder method handleDescriptor.
private void handleDescriptor(final Path projectPath, final OpenDeclarationDescriptor descriptor) {
final EditorPartPresenter openedEditor = editorAgent.getOpenedEditor(Path.valueOf(descriptor.getPath()));
if (openedEditor != null) {
editorAgent.openEditor(openedEditor.getEditorInput().getFile(), new OpenEditorCallbackImpl() {
@Override
public void onEditorOpened(EditorPartPresenter editor) {
setCursorAndActivateEditor(editor, descriptor.getOffset());
}
@Override
public void onEditorActivated(EditorPartPresenter editor) {
setCursorAndActivateEditor(editor, descriptor.getOffset());
}
});
return;
}
if (descriptor.isBinary()) {
navigationService.getEntry(projectPath, descriptor.getLibId(), descriptor.getPath()).then(new Operation<JarEntry>() {
@Override
public void apply(final JarEntry entry) throws OperationException {
navigationService.getContent(projectPath, descriptor.getLibId(), Path.valueOf(entry.getPath())).then(new Operation<ClassContent>() {
@Override
public void apply(ClassContent content) throws OperationException {
final VirtualFile file = javaNodeFactory.newJarFileNode(entry, descriptor.getLibId(), projectPath, null);
editorAgent.openEditor(file, new OpenEditorCallbackImpl() {
@Override
public void onEditorOpened(final EditorPartPresenter editor) {
Scheduler.get().scheduleDeferred(new Scheduler.ScheduledCommand() {
@Override
public void execute() {
if (editor instanceof TextEditor) {
((TextEditor) editor).getDocument().setSelectedRange(LinearRange.createWithStart(descriptor.getOffset()).andLength(0), true);
editor.activate();
}
}
});
}
});
}
});
}
});
} else {
appContext.getWorkspaceRoot().getFile(descriptor.getPath()).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(final EditorPartPresenter editor) {
Scheduler.get().scheduleDeferred(new Scheduler.ScheduledCommand() {
@Override
public void execute() {
if (editor instanceof TextEditor) {
((TextEditor) editor).getDocument().setSelectedRange(LinearRange.createWithStart(descriptor.getOffset()).andLength(0), true);
editor.activate();
}
}
});
}
});
}
}
});
}
}
use of org.eclipse.che.ide.ext.java.shared.dto.ClassContent in project che by eclipse.
the class JavaNavigation method createContent.
private ClassContent createContent(String content, boolean generated) {
ClassContent classContent = DtoFactory.newDto(ClassContent.class);
classContent.setContent(content);
classContent.setGenerated(generated);
return classContent;
}
Aggregations