コード例 #1
0
 @Override
 public void init(IWorkbench workbench, IStructuredSelection selection) {
   if (model.getConnection() != null && model.getSelectedItem() != null) {
     return;
   }
   Connection connection = UIUtils.getFirstElement(selection, Connection.class);
   if (connection != null) {
     model.setConnection(connection);
   } else {
     IResource resource = UIUtils.getFirstElement(selection, IResource.class);
     if (resource != null) {
       setModelConnection(ConnectionsRegistryUtil.safeGetConnectionFor(resource));
       model.setSelectedItem(resource);
     } else {
       IProject project = UIUtils.getFirstElement(selection, IProject.class);
       if (project != null) {
         setModelConnection(ConnectionsRegistryUtil.safeGetConnectionFor(project));
         model.setSelectedItem(project);
       } else {
         ResourceGrouping grouping = UIUtils.getFirstElement(selection, ResourceGrouping.class);
         if (grouping != null) {
           setModelConnection(ConnectionsRegistryUtil.safeGetConnectionFor(grouping.getProject()));
           model.setSelectedItem(grouping.getProject());
         }
       }
     }
   }
 }
コード例 #2
0
 public ImportApplicationWizard(Map<IProject, Collection<IBuildConfig>> projectsAndBuildConfigs) {
   this();
   if (projectsAndBuildConfigs != null && projectsAndBuildConfigs.size() == 1) {
     Map.Entry<IProject, Collection<IBuildConfig>> entry =
         projectsAndBuildConfigs.entrySet().iterator().next();
     IProject project = entry.getKey();
     Connection connection = ConnectionsRegistryUtil.safeGetConnectionFor(project);
     setModelConnection(connection);
     Collection<IBuildConfig> buildConfigs = entry.getValue();
     if (buildConfigs.size() == 1) {
       model.setSelectedItem(buildConfigs.iterator().next());
     } else {
       model.setSelectedItem(project);
       // TODO Get BuildConfigWizardPage to only display the buildconfigs passed here
     }
   }
 }