use of org.eclipse.che.ide.ext.java.client.tree.library.JarFileNode 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.client.tree.library.JarFileNode in project che by eclipse.
the class OpenDeclarationFinder method openDeclaration.
public void openDeclaration() {
EditorPartPresenter activeEditor = editorAgent.getActiveEditor();
if (activeEditor == null) {
return;
}
if (!(activeEditor instanceof TextEditor)) {
Log.error(getClass(), "Open Declaration support only TextEditor as editor");
return;
}
TextEditor editor = ((TextEditor) activeEditor);
int offset = editor.getCursorOffset();
final VirtualFile file = editor.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);
navigationService.findDeclaration(project.get().getLocation(), fqn, offset).then(new Operation<OpenDeclarationDescriptor>() {
@Override
public void apply(OpenDeclarationDescriptor result) throws OperationException {
if (result != null) {
handleDescriptor(project.get().getLocation(), result);
}
}
});
} else if (file instanceof JarFileNode) {
navigationService.findDeclaration(((JarFileNode) file).getProjectLocation(), file.getLocation().toString().replace('/', '.'), offset).then(new Operation<OpenDeclarationDescriptor>() {
@Override
public void apply(OpenDeclarationDescriptor result) throws OperationException {
if (result != null) {
handleDescriptor(((JarFileNode) file).getProject(), result);
}
}
});
}
}
use of org.eclipse.che.ide.ext.java.client.tree.library.JarFileNode in project che by eclipse.
the class ClassFileSourcesDownloader method onEditorOpened.
@Override
public void onEditorOpened(EditorOpenedEvent event) {
EditorPartPresenter editor = event.getEditor();
VirtualFile file = editor.getEditorInput().getFile();
if (file instanceof JarFileNode) {
final JarFileNode jarFileNode = (JarFileNode) file;
if (jarFileNode.isContentGenerated()) {
if (editor instanceof TextEditor) {
final TextEditor presenter = (TextEditor) editor;
TextEditorPartView view = presenter.getView();
final DivElement divElement = Elements.createDivElement();
divElement.setClassName(resources.css().editorInfoPanel());
Text textNode = Elements.createTextNode(constant.mavenClassDecompiled());
DivElement decompiledElement = Elements.createDivElement();
decompiledElement.appendChild(textNode);
decompiledElement.setClassName(resources.css().editorMessage());
divElement.appendChild(decompiledElement);
AnchorElement anchorElement = Elements.createAnchorElement();
anchorElement.appendChild(Elements.createTextNode(constant.mavenDownloadSources()));
anchorElement.setHref("#");
anchorElement.setClassName(resources.css().downloadLink());
divElement.appendChild(anchorElement);
final HasNotificationPanel.NotificationRemover remover = view.addNotification((Element) divElement);
anchorElement.setOnclick(new EventListener() {
@Override
public void handleEvent(Event evt) {
downloadSources(jarFileNode, remover);
}
});
}
}
}
}
Aggregations