use of org.eclipse.che.ide.ui.loaders.request.MessageLoader in project che by eclipse.
the class ProjectExplorerStateComponent method loadState.
@Override
public void loadState(@NotNull JsonObject state) {
if (state.hasKey(SHOW_HIDDEN_FILES)) {
projectExplorer.showHiddenFiles(state.getBoolean(SHOW_HIDDEN_FILES));
}
JsonArray paths = state.hasKey(PATH_PARAM_ID) ? state.getArray(PATH_PARAM_ID) : Json.createArray();
if (paths.length() == 0) {
return;
}
Promise<Node> revealPromise = null;
final MessageLoader loader = loaderFactory.newLoader("Restoring project structure...");
loader.show();
for (int i = 0; i < paths.length(); i++) {
final String path = paths.getString(i);
if (revealPromise == null) {
revealPromise = revealer.reveal(Path.valueOf(path), false).thenPromise(new Function<Node, Promise<Node>>() {
@Override
public Promise<Node> apply(Node node) throws FunctionException {
if (node != null) {
projectExplorer.getTree().setExpanded(node, true, false);
}
return revealer.reveal(Path.valueOf(path), false);
}
});
continue;
}
revealPromise.thenPromise(new Function<Node, Promise<Node>>() {
@Override
public Promise<Node> apply(Node node) throws FunctionException {
if (node != null) {
projectExplorer.getTree().setExpanded(node, true, false);
}
return revealer.reveal(Path.valueOf(path), false);
}
}).catchError(new Function<PromiseError, Node>() {
@Override
public Node apply(PromiseError error) throws FunctionException {
Log.info(getClass(), error.getMessage());
return null;
}
});
}
if (revealPromise != null) {
revealPromise.then(new Operation<Node>() {
@Override
public void apply(Node node) throws OperationException {
loader.hide();
}
}).catchError(new Operation<PromiseError>() {
@Override
public void apply(PromiseError error) throws OperationException {
loader.hide();
}
});
}
}
use of org.eclipse.che.ide.ui.loaders.request.MessageLoader in project che by eclipse.
the class LanguageServerEditorProvider method createEditor.
@Override
public Promise<EditorPartPresenter> createEditor(VirtualFile file) {
if (file instanceof File) {
File resource = (File) file;
Promise<InitializeResult> promise = registry.getOrInitializeServer(resource.getRelatedProject().get().getPath(), resource.getExtension(), resource.getLocation().toString());
final MessageLoader loader = loaderFactory.newLoader("Initializing Language Server for " + resource.getExtension());
loader.show();
return promise.thenPromise(new Function<InitializeResult, Promise<EditorPartPresenter>>() {
@Override
public Promise<EditorPartPresenter> apply(InitializeResult arg) throws FunctionException {
loader.hide();
return Promises.<EditorPartPresenter>resolve(createEditor(editorConfigurationFactory.build(arg.getCapabilities())));
}
});
}
return null;
}
Aggregations