@Override public void registerSolution(String path, boolean openProjects) throws IOException { Solution sln = readSolutionFile(path); SolutionEntry entry = new SolutionEntry(sln); session.getSolutions().put(entry.getId(), entry); reloadSolution(entry.getId(), openProjects); }
public List<WorkbenchCommand> createSolutionCommands(String id, boolean openProjects) throws IOException { SolutionEntry solutionEntry = session.getSolutions().get(id); SolutionEntry sln = new SolutionEntry(readSolutionFile(solutionEntry.getFile())); // load projects if necessary List<WorkbenchCommand> commands = new LinkedList<WorkbenchCommand>(); // update tracking information commands.add(new WorkbenchCommandImpl.UpdateTrackingInformation(id)); /* * - find out which projects are not yet imported and create ImportCommands * - compare old set of project ids for the case that some projects have been removed from */ Project[] projectSpecs = sln.getProjects(); Map<String, IProject> projectMap = getProjectMap(); Map<String, IWorkingSet> workingSetMap = getWorkingSetMap(); // import/open new projects for (Project project : projectSpecs) { commands.add( new WorkbenchCommandImpl.ImportProject( project.getName(), project.getProjectFile(), openProjects)); } // create working sets Set<String> createdWorkingSets = new HashSet<String>(); Map<String, Set<String>> workingSetTable = getWorkingSetTable(); List<WorkbenchCommand> addProjectsToWS = new LinkedList<WorkbenchCommand>(); for (Project p : projectSpecs) { String wsId = p.getWorkingSet(); if (!createdWorkingSets.contains(wsId)) { commands.add(new WorkbenchCommandImpl.CreateWorkingSet(wsId)); // track which working set has been created already createdWorkingSets.add(wsId); } addProjectsToWS.add(new WorkbenchCommandImpl.AddProjectToWorkingSet(p.getName(), wsId)); } // add projects to working sets commands.addAll(addProjectsToWS); // create/update solution working set if (workingSetMap.containsKey(sln.getId())) { commands.add(new WorkbenchCommandImpl.UpdateSolutionWorkingSet(sln)); } else { commands.add(new WorkbenchCommandImpl.CreateSolutionWorkingSet(sln)); } return commands; }