示例#1
0
 /**
  * Searches in the prj for the config description with the same ID as for given cfg. If there's no
  * such cfgd, it will be created.
  *
  * @param prj - project description where we'll search (or create) config description
  * @param cfg - config description belonging to another project description, it is a sample for
  *     search and base for possile creation of resulting configuration description.
  * @return the configuration description (found or created) or null in case of error
  */
 private ICConfigurationDescription findCfg(
     ICProjectDescription prj, ICConfigurationDescription cfg) {
   String id = cfg.getId();
   // find config with the same ID as original one
   ICConfigurationDescription c = prj.getConfigurationById(id);
   // if there's no cfg found, try to create it
   if (c == null) {
     try {
       c = prj.createConfiguration(id, cfg.getName(), cfg);
       c.setDescription(cfg.getDescription());
     } catch (CoreException e) {
       /* do nothing: c is already null */
     }
   }
   // if creation failed, report an error and return null
   if (c == null) {
     MessageBox mb = new MessageBox(getShell());
     mb.setMessage(Messages.AbstractPage_3);
     mb.open();
   }
   return c;
 }