/** Creates copy of the given {@code context}. */ public ApplicableContext(ApplicableContext context) { this(context.isWorkspaceApplicable(), new HashSet<>(context.getApplicableProjects())); }
/** 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; }); }
if (!context.isWorkspaceApplicable() && context.getApplicableProjects().isEmpty()) { return promiseProvider.reject( new Exception("Command has to be applicable to the workspace or at least one project")); if (context.isWorkspaceApplicable()) { Promise<CommandImpl> p = workspaceCommandManager