private boolean initModules(IResource selection) {
    // If the selection was module file, use that as the default
    if (ModuleUtils.isModuleXml(selection)) {
      ModuleFile module = ModuleUtils.create((IFile) selection);
      List<String> moduleNames = Arrays.asList(new String[] {module.getQualifiedName()});
      modulesBlock.setModules(moduleNames);
    } else {
      // Otherwise, include all modules in the project
      modulesBlock.setModules(GWTProjectProperties.getEntryPointModules(hostPageProject));
    }

    modulesBlock.setDefaultModules(GWTProjectProperties.getEntryPointModules(hostPageProject));

    return true;
  }
  private void updateModulesIfProjectChanged() {
    if (hostPageProject != null) {
      if (hostPageProject != null && !getJavaProject().equals(modulesBlock.getJavaProject())) {
        // Set the project for the block (needed for adding a module)
        modulesBlock.setJavaProject(getJavaProject());

        // Set the default and initially-selected modules for the block.
        modulesBlock.setDefaultModules(GWTProjectProperties.getEntryPointModules(hostPageProject));
        modulesBlock.setModules(GWTProjectProperties.getEntryPointModules(hostPageProject));
      }
    } else {
      modulesBlock.setJavaProject(null);
      modulesBlock.setDefaultModules(Collections.<String>emptyList());
      modulesBlock.setModules(Collections.<String>emptyList());
    }
  }