@Override public Promise<Void> loadState(JsonObject state) { if (state.hasKey(PERSPECTIVES)) { JsonObject perspectives = state.getObject(PERSPECTIVES); Map<String, Perspective> perspectiveMap = perspectiveManagerProvider.get().getPerspectives(); ArrayOf<Promise<?>> perspectivePromises = Collections.arrayOf(); for (String key : perspectives.keys()) { if (perspectiveMap.containsKey(key)) { perspectivePromises.push(perspectiveMap.get(key).loadState(perspectives.getObject(key))); } } return promises.all2(perspectivePromises).thenPromise(ignored -> promises.resolve(null)); } return promises.resolve(null); }
List<Promise<Void>> restore = restore(files, editorPartStackConsumer, activeEditors); Promise<ArrayOf<?>> promise = promiseProvider.all2(restore.toArray(new Promise[restore.size()])); promise.then( (Operation)
.all2(imports.toArray(new Promise<?>[imports.size()])) .then( ignored -> {
/** Removes the command without notifying listeners. */ private Promise<Void> doRemoveCommand(String name) { final CommandImpl command = commands.get(name); if (command == null) { return promiseProvider.reject(new Exception("Command '" + name + "' does not exist.")); } final ApplicableContext context = command.getApplicableContext(); final ArrayOf<Promise<?>> commandPromises = Collections.arrayOf(); if (context.isWorkspaceApplicable()) { commandPromises.push(workspaceCommandManager.removeCommand(name)); } for (final String projectPath : context.getApplicableProjects()) { final Project project = getProjectByPath(projectPath); if (project == null) { continue; } commandPromises.push(projectCommandManager.removeCommand(project, name)); } return promiseProvider .all2(commandPromises) .then( (Function<ArrayOf<?>, Void>) arg -> { commands.remove(command.getName()); return null; }); }
.all2(commandPromises) .then( (Function<ArrayOf<?>, CommandImpl>)