コード例 #1
0
ファイル: MakeContentProvider.java プロジェクト: alblue/cdt
 /* (non-Javadoc)
  * @see org.eclipse.jface.viewers.IContentProvider#inputChanged(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object)
  */
 public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
   if (this.viewer == null) {
     MakeCorePlugin.getDefault().getTargetManager().addListener(this);
   }
   this.viewer = (StructuredViewer) viewer;
   IWorkspace oldWorkspace = null;
   IWorkspace newWorkspace = null;
   if (oldInput instanceof IWorkspace) {
     oldWorkspace = (IWorkspace) oldInput;
   } else if (oldInput instanceof IContainer) {
     oldWorkspace = ((IContainer) oldInput).getWorkspace();
   } else if (oldInput instanceof TargetSourceContainer) {
     oldWorkspace = ((TargetSourceContainer) oldInput).getContainer().getWorkspace();
   }
   if (newInput instanceof IWorkspace) {
     newWorkspace = (IWorkspace) newInput;
   } else if (newInput instanceof IContainer) {
     newWorkspace = ((IContainer) newInput).getWorkspace();
   } else if (newInput instanceof TargetSourceContainer) {
     newWorkspace = ((TargetSourceContainer) newInput).getContainer().getWorkspace();
   }
   if (oldWorkspace != newWorkspace) {
     ICProjectDescriptionManager mngr = CoreModel.getDefault().getProjectDescriptionManager();
     if (oldWorkspace != null) {
       InstanceScope.INSTANCE.getNode(CCorePlugin.PLUGIN_ID).removePreferenceChangeListener(this);
       mngr.removeCProjectDescriptionListener(this);
       oldWorkspace.removeResourceChangeListener(this);
     }
     if (newWorkspace != null) {
       newWorkspace.addResourceChangeListener(this, IResourceChangeEvent.POST_CHANGE);
       mngr.addCProjectDescriptionListener(this, CProjectDescriptionEvent.APPLIED);
       InstanceScope.INSTANCE.getNode(CCorePlugin.PLUGIN_ID).addPreferenceChangeListener(this);
     }
   }
 }
コード例 #2
0
ファイル: MakeContentProvider.java プロジェクト: alblue/cdt
  /** Get source entries for default setting configuration (i.e. configuration shown in UI). */
  private static ICSourceEntry[] getSourceEntries(IProject project) {
    ICProjectDescriptionManager mgr = CCorePlugin.getDefault().getProjectDescriptionManager();
    ICProjectDescription prjDescription = mgr.getProjectDescription(project, false);
    if (prjDescription != null) {
      ICConfigurationDescription cfgDescription = prjDescription.getDefaultSettingConfiguration();
      if (cfgDescription != null) {
        ICSourceEntry[] srcEntries = cfgDescription.getResolvedSourceEntries();
        return srcEntries;
      }
    }

    return new ICSourceEntry[0];
  }
コード例 #3
0
ファイル: ResourceHelper.java プロジェクト: NVIDIA/cdt-nsight
  /**
   * Creates CDT project in a specific path in workspace adding specified configurations and opens
   * it.
   *
   * @param projectName - project name.
   * @param pathInWorkspace - path relative to workspace root.
   * @param configurationIds - array of configuration IDs.
   * @return - new {@link IProject}.
   * @throws CoreException - if the project can't be created.
   * @throws OperationCanceledException...
   */
  public static IProject createCDTProject(
      String projectName, String pathInWorkspace, String[] configurationIds)
      throws OperationCanceledException, CoreException {
    CCorePlugin cdtCorePlugin = CCorePlugin.getDefault();
    IWorkspace workspace = ResourcesPlugin.getWorkspace();
    IWorkspaceRoot root = workspace.getRoot();

    IProject project = root.getProject(projectName);
    IndexerPreferences.set(project, IndexerPreferences.KEY_INDEXER_ID, IPDOMManager.ID_NO_INDEXER);
    resourcesCreated.add(project);

    IProjectDescription prjDescription = workspace.newProjectDescription(projectName);
    if (pathInWorkspace != null) {
      IPath absoluteLocation = root.getLocation().append(pathInWorkspace);
      prjDescription.setLocation(absoluteLocation);
    }

    if (configurationIds != null && configurationIds.length > 0) {
      ICProjectDescriptionManager prjDescManager = cdtCorePlugin.getProjectDescriptionManager();

      project.create(NULL_MONITOR);
      project.open(NULL_MONITOR);

      ICProjectDescription icPrjDescription =
          prjDescManager.createProjectDescription(project, false);
      ICConfigurationDescription baseConfiguration =
          cdtCorePlugin.getPreferenceConfiguration(TestCfgDataProvider.PROVIDER_ID);

      for (String cfgId : configurationIds) {
        icPrjDescription.createConfiguration(cfgId, cfgId + " Name", baseConfiguration);
      }
      prjDescManager.setProjectDescription(project, icPrjDescription);
    }
    project = cdtCorePlugin.createCDTProject(prjDescription, project, NULL_MONITOR);
    waitForProjectRefreshToFinish();
    Assert.assertNotNull(project);

    project.open(null);
    Assert.assertTrue(project.isOpen());

    return project;
  }