Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add informative messages to the loaders it will helpful for error det… #8613

Merged
merged 2 commits into from
Feb 7, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
import com.google.inject.Singleton;
import org.eclipse.che.api.promises.client.Operation;
import org.eclipse.che.api.promises.client.OperationException;
import org.eclipse.che.api.promises.client.PromiseError;
import org.eclipse.che.ide.api.app.AppContext;
import org.eclipse.che.ide.api.editor.EditorAgent;
import org.eclipse.che.ide.api.editor.EditorPartPresenter;
Expand All @@ -35,11 +34,9 @@
import org.eclipse.che.ide.ext.java.shared.JarEntry;
import org.eclipse.che.ide.ext.java.shared.dto.ClassContent;
import org.eclipse.che.ide.ext.java.shared.dto.Region;
import org.eclipse.che.ide.ext.java.shared.dto.model.CompilationUnit;
import org.eclipse.che.ide.ext.java.shared.dto.model.Member;
import org.eclipse.che.ide.resource.Path;
import org.eclipse.che.ide.ui.loaders.request.LoaderFactory;
import org.eclipse.che.ide.ui.loaders.request.MessageLoader;
import org.eclipse.che.ide.util.loging.Log;

/**
Expand All @@ -54,7 +51,6 @@ public class FileStructurePresenter implements FileStructure.ActionDelegate {
private final JavaNavigationService javaNavigationService;
private final AppContext context;
private final EditorAgent editorAgent;
private final MessageLoader loader;

private TextEditor activeEditor;
private boolean showInheritedMembers;
Expand All @@ -71,7 +67,6 @@ public FileStructurePresenter(
this.javaNavigationService = javaNavigationService;
this.context = context;
this.editorAgent = editorAgent;
this.loader = loaderFactory.newLoader();
this.view.setDelegate(this);
}

Expand All @@ -81,8 +76,8 @@ public FileStructurePresenter(
* @param editorPartPresenter the active editor
*/
public void show(EditorPartPresenter editorPartPresenter) {
loader.show();
view.setTitle(editorPartPresenter.getEditorInput().getFile().getName());
view.show();

if (!(editorPartPresenter instanceof TextEditor)) {
Log.error(getClass(), "Open Declaration support only TextEditor as editor");
Expand All @@ -103,26 +98,16 @@ public void show(EditorPartPresenter editorPartPresenter) {
}

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();
}
unit -> {
view.setStructure(unit, showInheritedMembers);
showInheritedMembers = !showInheritedMembers;
})
.catchError(
new Operation<PromiseError>() {
@Override
public void apply(PromiseError arg) throws OperationException {
Log.error(FileStructurePresenter.class, arg.getMessage());
loader.hide();
}
arg -> {
Log.error(FileStructurePresenter.class, arg.getMessage());
});
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,7 @@ public Promise<CompilationUnit> getCompilationUnit(
return requestFactory
.createGetRequest(url)
.header(ACCEPT, APPLICATION_JSON)
.loader(loaderFactory.newLoader("Getting information about ..."))
.send(unmarshallerFactory.newUnmarshaller(CompilationUnit.class));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@
import org.eclipse.che.ide.rest.DtoUnmarshallerFactory;
import org.eclipse.che.ide.rest.StringUnmarshaller;
import org.eclipse.che.ide.ui.loaders.request.LoaderFactory;
import org.eclipse.che.ide.ui.loaders.request.MessageLoader;

/**
* @author Dmitry Shnurenko
Expand All @@ -54,8 +53,8 @@ final class RefactoringServiceClientImpl implements RefactoringServiceClient {
private final AsyncRequestFactory asyncRequestFactory;
private final DtoUnmarshallerFactory unmarshallerFactory;
private final AppContext appContext;
private final LoaderFactory loaderFactory;
private final String pathToService;
private final MessageLoader loader;

@Inject
public RefactoringServiceClientImpl(
Expand All @@ -66,7 +65,7 @@ public RefactoringServiceClientImpl(
this.asyncRequestFactory = asyncRequestFactory;
this.unmarshallerFactory = unmarshallerFactory;
this.appContext = appContext;
this.loader = loaderFactory.newLoader();
this.loaderFactory = loaderFactory;
this.pathToService = "/java/refactoring/";
}

Expand All @@ -79,7 +78,7 @@ public Promise<String> createMoveRefactoring(final CreateMoveRefactoring moveRef
moveRefactoring)
.header(ACCEPT, TEXT_PLAIN)
.header(CONTENT_TYPE, APPLICATION_JSON)
.loader(loader)
.loader(loaderFactory.newLoader("Prepare for move refactoring ..."))
.send(new StringUnmarshaller());
}

Expand All @@ -92,7 +91,7 @@ public Promise<RenameRefactoringSession> createRenameRefactoring(
.createPostRequest(url, settings)
.header(ACCEPT, APPLICATION_JSON)
.header(CONTENT_TYPE, APPLICATION_JSON)
.loader(loader)
.loader(loaderFactory.newLoader("Prepare for rename refactoring ..."))
.send(unmarshallerFactory.newUnmarshaller(RenameRefactoringSession.class));
}

Expand All @@ -106,7 +105,7 @@ public Promise<RefactoringResult> applyLinkedModeRename(
.createPostRequest(url, refactoringApply)
.header(ACCEPT, APPLICATION_JSON)
.header(CONTENT_TYPE, APPLICATION_JSON)
.loader(loader)
.loader(loaderFactory.newLoader("Apply linked mode rename refactoring ..."))
.send(unmarshallerFactory.newUnmarshaller(RefactoringResult.class));
}

Expand All @@ -119,7 +118,7 @@ public Promise<RefactoringStatus> setDestination(final ReorgDestination destinat
.createPostRequest(url, destination)
.header(ACCEPT, APPLICATION_JSON)
.header(CONTENT_TYPE, APPLICATION_JSON)
.loader(loader)
.loader(loaderFactory.newLoader("Set move refactoring destination..."))
.send(unmarshallerFactory.newUnmarshaller(RefactoringStatus.class));
}

Expand All @@ -133,7 +132,7 @@ public Promise<Void> setMoveSettings(final MoveSettings settings) {
.createPostRequest(url, settings)
.header(ACCEPT, APPLICATION_JSON)
.header(CONTENT_TYPE, APPLICATION_JSON)
.loader(loader)
.loader(loaderFactory.newLoader("Set move refactoring settings ..."))
.send();
}

Expand All @@ -146,7 +145,7 @@ public Promise<ChangeCreationResult> createChange(final RefactoringSession sessi
.createPostRequest(url, session)
.header(ACCEPT, APPLICATION_JSON)
.header(CONTENT_TYPE, APPLICATION_JSON)
.loader(loader)
.loader(loaderFactory.newLoader("Creating refactoring changes"))
.send(unmarshallerFactory.newUnmarshaller(ChangeCreationResult.class));
}

Expand All @@ -159,7 +158,7 @@ public Promise<RefactoringPreview> getRefactoringPreview(final RefactoringSessio
.createPostRequest(url, session)
.header(ACCEPT, APPLICATION_JSON)
.header(CONTENT_TYPE, APPLICATION_JSON)
.loader(loader)
.loader(loaderFactory.newLoader("Getting preview ..."))
.send(unmarshallerFactory.newUnmarshaller(RefactoringPreview.class));
}

Expand All @@ -172,7 +171,7 @@ public Promise<RefactoringResult> applyRefactoring(final RefactoringSession sess
.createPostRequest(url, session)
.header(ACCEPT, APPLICATION_JSON)
.header(CONTENT_TYPE, APPLICATION_JSON)
.loader(loader)
.loader(loaderFactory.newLoader("Apply refactoring ... "))
.send(unmarshallerFactory.newUnmarshaller(RefactoringResult.class));
}

Expand All @@ -185,7 +184,7 @@ public Promise<Void> changeChangeEnabledState(final ChangeEnabledState state) {
.createPostRequest(url, state)
.header(ACCEPT, APPLICATION_JSON)
.header(CONTENT_TYPE, APPLICATION_JSON)
.loader(loader)
.loader(loaderFactory.newLoader("Choosing some change ..."))
.send();
}

Expand All @@ -198,7 +197,7 @@ public Promise<ChangePreview> getChangePreview(final RefactoringChange change) {
.createPostRequest(url, change)
.header(ACCEPT, APPLICATION_JSON)
.header(CONTENT_TYPE, APPLICATION_JSON)
.loader(loader)
.loader(loaderFactory.newLoader("Get refactoring change preview"))
.send(unmarshallerFactory.newUnmarshaller(ChangePreview.class));
}

Expand All @@ -212,7 +211,7 @@ public Promise<RefactoringStatus> validateNewName(final ValidateNewName newName)
.createPostRequest(url, newName)
.header(ACCEPT, APPLICATION_JSON)
.header(CONTENT_TYPE, APPLICATION_JSON)
.loader(loader)
.loader(loaderFactory.newLoader("Validates new name ..."))
.send(unmarshallerFactory.newUnmarshaller(RefactoringStatus.class));
}

Expand All @@ -226,7 +225,7 @@ public Promise<Void> setRenameSettings(final RenameSettings settings) {
.createPostRequest(url, settings)
.header(ACCEPT, APPLICATION_JSON)
.header(CONTENT_TYPE, APPLICATION_JSON)
.loader(loader)
.loader(loaderFactory.newLoader("Set rename refactoring settings"))
.send();
}

Expand All @@ -238,6 +237,9 @@ public Promise<Void> reindexProject(String projectPath) {
+ "reindex?projectpath="
+ encodePath(valueOf(projectPath));

return asyncRequestFactory.createGetRequest(url).loader(loader).send();
return asyncRequestFactory
.createGetRequest(url)
.loader(loaderFactory.newLoader("Reindexing project ..."))
.send();
}
}