use of org.eclipse.che.ide.ext.java.shared.JarEntry 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.JarEntry in project che by eclipse.
the class JavaNavigation method getJarEntryResource.
private JarEntry getJarEntryResource(JarEntryResource resource) {
JarEntry entry = DtoFactory.getInstance().createDto(JarEntry.class);
if (resource instanceof JarEntryDirectory) {
entry.setType(JarEntryType.FOLDER);
}
if (resource instanceof JarEntryFile) {
entry.setType(JarEntryType.FILE);
}
entry.setName(resource.getName());
entry.setPath(resource.getFullPath().toOSString());
return entry;
}
use of org.eclipse.che.ide.ext.java.shared.JarEntry in project che by eclipse.
the class JavaDebuggerFileHandler method openExternalResource.
private void openExternalResource(final Location location, final AsyncCallback<VirtualFile> callback) {
final String className = extractOuterClassFqn(location.getTarget());
final int libId = location.getExternalResourceId();
final Path projectPath = new Path(location.getResourceProjectPath());
service.getEntry(projectPath, libId, className).then(new Operation<JarEntry>() {
@Override
public void apply(final JarEntry jarEntry) throws OperationException {
final JarFileNode file = nodeFactory.newJarFileNode(jarEntry, libId, projectPath, null);
AsyncCallback<VirtualFile> downloadSourceCallback = new AsyncCallback<VirtualFile>() {
@Override
public void onSuccess(final VirtualFile result) {
if (file.isContentGenerated()) {
handleContentGeneratedResource(file, location, callback);
} else {
handleActivatedFile(file, callback, location.getLineNumber());
}
}
@Override
public void onFailure(Throwable caught) {
callback.onFailure(caught);
}
};
handleActivatedFile(file, downloadSourceCallback, location.getLineNumber());
eventBus.fireEvent(FileEvent.createOpenFileEvent(file));
}
}).catchError(new Operation<PromiseError>() {
@Override
public void apply(PromiseError arg) throws OperationException {
callback.onFailure(arg.getCause());
}
});
}
use of org.eclipse.che.ide.ext.java.shared.JarEntry in project che by eclipse.
the class JarNavigationTest method testNonJavaFile.
@Test
public void testNonJavaFile() throws Exception {
String javaHome = System.getProperty("java.home") + "/lib/ext/zipfs.jar";
IPackageFragmentRoot root = project.getPackageFragmentRoot(new File(javaHome).getPath());
List<JarEntry> rootContent = navigation.getChildren(project, root.hashCode(), "/META-INF/services");
assertThat(rootContent).isNotNull().isNotEmpty().onProperty("name").containsExactly("java.nio.file.spi.FileSystemProvider");
}
use of org.eclipse.che.ide.ext.java.shared.JarEntry in project che by eclipse.
the class JarNavigationTest method testExternalJar.
@Test
public void testExternalJar() throws Exception {
String javaHome = getClass().getResource("/temp").getPath() + "/ws/test/gwt-user.jar";
IPackageFragmentRoot root = project.getPackageFragmentRoot(new File(javaHome).getPath());
List<JarEntry> content = navigation.getPackageFragmentRootContent(project, root.hashCode());
assertThat(content).isNotNull().isNotEmpty().onProperty("name").contains("com.google", "javax", "org", "META-INF", "about.html");
}
Aggregations