/** Set the program name attributes on the working copy based on the ICElement */ protected void initializeProgramName(ICElement cElement, ILaunchConfigurationWorkingCopy config) { boolean renamed = false; if (!(cElement instanceof IBinary)) { cElement = cElement.getCProject(); } if (cElement instanceof ICProject) { IProject project = cElement.getCProject().getProject(); String name = project.getName(); ICProjectDescription projDes = CCorePlugin.getDefault().getProjectDescription(project); if (projDes != null) { String buildConfigName = projDes.getActiveConfiguration().getName(); name = name + " " + buildConfigName; // $NON-NLS-1$ } name = getLaunchConfigurationDialog().generateName(name); config.rename(name); renamed = true; } IBinary binary = null; if (cElement instanceof ICProject) { IBinary[] bins = getBinaryFiles((ICProject) cElement); if (bins != null && bins.length == 1) { binary = bins[0]; } } else if (cElement instanceof IBinary) { binary = (IBinary) cElement; } if (binary != null) { String path; path = binary.getResource().getProjectRelativePath().toOSString(); config.setAttribute(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_NAME, path); if (!renamed) { String name = binary.getElementName(); int index = name.lastIndexOf('.'); if (index > 0) { name = name.substring(0, index); } name = getLaunchConfigurationDialog().generateName(name); config.rename(name); renamed = true; } } if (!renamed) { String name = getLaunchConfigurationDialog().generateName(cElement.getCProject().getElementName()); config.rename(name); } }
@Override public void init(ICElement cElement, List<CPElement> cPaths) { fCurrCElement = cElement; fCurrCProject = cElement.getCProject(); List<CPElementGroup> elements = createGroups(cElement, cPaths); fIncludeSymPathsList.setElements(elements); updateStatus(); }
/** * Determine if the project is a C++ project * * @param ce the ICElement representing a file * @return */ protected boolean isCPPproject(ICElement ce) { IProject p = ce.getCProject().getProject(); try { IProjectNature nature = p.getNature("org.eclipse.cdt.core.ccnature"); // $NON-NLS-1$ if (nature != null) { return true; } } catch (CoreException e) { // TODO Auto-generated catch block // e.printStackTrace(); } return false; }