use of org.eclipse.che.ide.ext.java.shared.JarEntry in project che by eclipse.
the class JarNavigationTest method testJavaPackage.
@Test
public void testJavaPackage() throws Exception {
String javaHome = System.getProperty("java.home") + "/lib/rt.jar";
IPackageFragmentRoot root = project.getPackageFragmentRoot(new File(javaHome).getPath());
List<JarEntry> rootContent = navigation.getChildren(project, root.hashCode(), "java");
assertThat(rootContent).isNotNull().isNotEmpty().onProperty("name").contains("lang", "io", "util", "net", "nio");
}
use of org.eclipse.che.ide.ext.java.shared.JarEntry 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;
}
use of org.eclipse.che.ide.ext.java.shared.JarEntry in project che by eclipse.
the class JavaNavigation method convertToJarEntry.
private List<JarEntry> convertToJarEntry(Object[] rootContent, IPackageFragmentRoot root) throws JavaModelException {
List<JarEntry> result = new ArrayList<>();
for (Object o : rootContent) {
if (o instanceof IPackageFragment) {
JarEntry entry = DtoFactory.getInstance().createDto(JarEntry.class);
IPackageFragment packageFragment = (IPackageFragment) o;
entry.setName(getSpecificText((IJavaElement) o));
entry.setPath(packageFragment.getElementName());
entry.setType(JarEntryType.PACKAGE);
result.add(entry);
}
if (o instanceof IClassFile) {
JarEntry entry = getJarClass((IClassFile) o);
result.add(entry);
}
if (o instanceof JarEntryResource) {
result.add(getJarEntryResource((JarEntryResource) o));
}
}
Collections.sort(result, comparator);
return result;
}
Aggregations