use of org.eclipse.che.api.promises.client.OperationException 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.api.promises.client.OperationException 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.api.promises.client.OperationException 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.api.promises.client.OperationException in project che by eclipse.
the class OpenImplementationPresenter method show.
/**
* Shows the implementations of the selected element.
*
* @param editorPartPresenter
* the active editor
*/
public void show(final EditorPartPresenter editorPartPresenter) {
if (!(editorPartPresenter instanceof TextEditor)) {
Log.error(getClass(), "Open Declaration support only TextEditor as editor");
return;
}
activeEditor = ((TextEditor) editorPartPresenter);
final 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);
service.getImplementations(project.get().getLocation(), fqn, activeEditor.getCursorOffset()).then(new Operation<ImplementationsDescriptorDTO>() {
@Override
public void apply(ImplementationsDescriptorDTO impls) throws OperationException {
int overridingSize = impls.getImplementations().size();
String title = locale.openImplementationWindowTitle(impls.getMemberName(), overridingSize);
NoImplementationWidget noImplementationWidget = new NoImplementationWidget(popupResources, javaResources, locale, OpenImplementationPresenter.this, title);
if (overridingSize == 1) {
actionPerformed(impls.getImplementations().get(0));
} else if (overridingSize > 1) {
openOneImplementation(impls, noImplementationWidget, (TextEditor) editorPartPresenter);
} else if (!isNullOrEmpty(impls.getMemberName()) && overridingSize == 0) {
showNoImplementations(noImplementationWidget, (TextEditor) editorPartPresenter);
}
}
});
}
}
use of org.eclipse.che.api.promises.client.OperationException in project che by eclipse.
the class MovePresenter method onAcceptButtonClicked.
/** {@inheritDoc} */
@Override
public void onAcceptButtonClicked() {
final RefactoringSession session = dtoFactory.createDto(RefactoringSession.class);
session.setSessionId(refactoringSessionId);
prepareMovingChanges(session).then(new Operation<ChangeCreationResult>() {
@Override
public void apply(ChangeCreationResult arg) throws OperationException {
if (arg.isCanShowPreviewPage()) {
eventBus.fireEvent(newFileTrackingSuspendEvent());
refactorService.applyRefactoring(session).then(new Operation<RefactoringResult>() {
@Override
public void apply(RefactoringResult arg) throws OperationException {
if (arg.getSeverity() == OK) {
view.hide();
refactoringUpdater.updateAfterRefactoring(arg.getChanges());
final Resource[] resources = refactorInfo.getResources();
if (resources != null && resources.length == 1) {
refactorService.reindexProject(resources[0].getRelatedProject().get().getLocation().toString());
}
} else {
view.showErrorMessage(arg);
}
for (ChangeInfo change : arg.getChanges()) {
final String path = change.getPath();
final String oldPath = change.getOldPath();
eventBus.fireEvent(newFileTrackingMoveEvent(path, oldPath));
}
eventBus.fireEvent(newFileTrackingResumeEvent());
}
});
} else {
view.showErrorMessage(arg.getStatus());
}
}
}).catchError(new Operation<PromiseError>() {
@Override
public void apply(PromiseError error) throws OperationException {
notificationManager.notify(locale.applyMoveError(), error.getMessage(), Status.FAIL, FLOAT_MODE);
}
});
}
Aggregations