public void selectionChanged(IAction action, ISelection selection) { boolean enabled = false; if (selection instanceof IStructuredSelection) { IStructuredSelection sel = (IStructuredSelection) selection; Object obj = sel.getFirstElement(); if (obj instanceof ICElement) { if (obj instanceof ICContainer || obj instanceof ICProject) { fContainer = (IContainer) ((ICElement) obj).getUnderlyingResource(); } else { obj = ((ICElement) obj).getResource(); if (obj != null) { fContainer = ((IResource) obj).getParent(); } } } else if (obj instanceof IResource) { if (obj instanceof IContainer) { fContainer = (IContainer) obj; } else { fContainer = ((IResource) obj).getParent(); } } else { fContainer = null; } if (fContainer != null && AutotoolsPlugin.hasTargetBuilder(fContainer.getProject())) { enabled = true; } } action.setEnabled(enabled); }
protected Shell getShell() { if (fPart != null) { return fPart.getSite().getShell(); } else if (fWindow != null) { return fWindow.getShell(); } return AutotoolsPlugin.getActiveWorkbenchShell(); }
@Override protected void initializeEditor() { super.initializeEditor(); setDocumentProvider(getAutoconfDocumentProvider()); IPreferenceStore[] stores = new IPreferenceStore[2]; stores[0] = AutotoolsPlugin.getDefault().getPreferenceStore(); stores[1] = EditorsUI.getPreferenceStore(); ChainedPreferenceStore chainedStore = new ChainedPreferenceStore(stores); setPreferenceStore(chainedStore); setSourceViewerConfiguration(new AutoconfSourceViewerConfiguration(chainedStore, this)); AutotoolsEditorPreferenceConstants.initializeDefaultValues(stores[0]); AutoconfEditorPreferencePage.initDefaults(stores[0]); }
@Override protected void initializeEditor() { setRangeIndicator(new DefaultRangeIndicator()); setEditorContextMenuId("#MakefileEditorContext"); // $NON-NLS-1$ setRulerContextMenuId("#MakefileRulerContext"); // $NON-NLS-1$ setDocumentProvider(AutomakeEditorFactory.getDefault().getAutomakefileDocumentProvider()); IPreferenceStore[] stores = new IPreferenceStore[2]; stores[0] = AutotoolsPlugin.getDefault().getPreferenceStore(); stores[1] = EditorsUI.getPreferenceStore(); ChainedPreferenceStore chainedStore = new ChainedPreferenceStore(stores); setPreferenceStore(chainedStore); sourceViewerConfiguration = new AutomakefileSourceConfiguration(chainedStore, this); setSourceViewerConfiguration(sourceViewerConfiguration); AutotoolsEditorPreferenceConstants.initializeDefaultValues(stores[0]); AutomakeEditorPreferencePage.initDefaults(stores[0]); configureInsertMode(SMART_INSERT, false); setInsertMode(INSERT); }
/** * Determines is folding enabled. * * @return <code>true</code> if folding is enabled, <code>false</code> otherwise. */ boolean isFoldingEnabled() { return AutotoolsPlugin.getDefault() .getPreferenceStore() .getBoolean(MakefileEditorPreferenceConstants.EDITOR_FOLDING_ENABLED); }
/** Returns the preference color, identified by the given preference. */ public static Color getPreferenceColor(String key) { return ColorManager.getDefault() .getColor( PreferenceConverter.getColor(AutotoolsPlugin.getDefault().getPreferenceStore(), key)); }
// Perform apply of configuration changes. This rewrites out the current known list of // configurations // with any changes currently that have been made to them. If a configuration has been renamed, // but this // has not yet been confirmed by the end-user, then only the changes to the configuration are // made. The // name currently remains the same in the output file. public synchronized void applyConfigs(String projectName, ICConfigurationDescription[] cfgds) { try { IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot(); IResource res = root.findMember(projectName, false); if (res == null || res.getType() != IResource.PROJECT) { AutotoolsPlugin.logErrorMessage( ConfigureMessages.getFormattedString(CFG_CANT_SAVE, new String[] {projectName})); return; } IProject project = (IProject) res; IPath output = project.getLocation().append(CFG_FILE_NAME); File f = output.toFile(); if (!f.exists()) f.createNewFile(); if (f.exists()) { try (PrintWriter p = new PrintWriter(new BufferedWriter(new FileWriter(f)))) { Map<String, IAConfiguration> cfgs = getSavedConfigs(project); if (cfgs == null) return; p.println("<?xml version=\"1.0\" encoding=\"UTF-8\"?>"); // $NON-NLS-1$ p.println("<configurations>"); // $NON-NLS-1$ Option[] optionList = AutotoolsConfiguration.getOptionList(); HashSet<String> savedIds = new HashSet<>(); setSyncing(true); for (int x = 0; x < cfgds.length; ++x) { ICConfigurationDescription cfgd = cfgds[x]; @SuppressWarnings("unused") CConfigurationData data = cfgd.getConfigurationData(); String id = cfgd.getId(); savedIds.add(id); IAConfiguration cfg = getTmpConfiguration(project, cfgd); cfgs.put( id, cfg); // add to list in case we have a new configuration not yet added to Project // Description p.println("<configuration id=\"" + id + "\">"); // $NON-NLS-1$ //$NON-NLS-2$ for (int j = 0; j < optionList.length; ++j) { Option option = optionList[j]; IConfigureOption opt = cfg.getOption(option.getName()); if (!opt.isCategory()) p.println( "<option id=\"" + option.getName() + "\" value=\"" + opt.getValue() + "\"/>"); //$NON-NLS-1$ //$NON-NLS-2$ // $NON-NLS-3$ } p.println("</configuration>"); // $NON-NLS-1$ syncNameField(cfgd); } setSyncing(false); // Put all the remaining configurations already saved back into the file. // These represent deleted configurations, but confirmation has not occurred. for (Entry<String, IAConfiguration> i : cfgs.entrySet()) { String id = i.getKey(); // A remaining id won't appear in our savedIds list. if (!savedIds.contains(id)) { IAConfiguration cfg = i.getValue(); p.println("<configuration id=\"" + id + "\">"); // $NON-NLS-1$ //$NON-NLS-2$ for (int j = 0; j < optionList.length; ++j) { Option option = optionList[j]; IConfigureOption opt = cfg.getOption(option.getName()); if (!opt.isCategory()) p.println( "<option id=\"" + option.getName() + "\" value=\"" + opt.getValue() + "\"/>"); //$NON-NLS-1$ //$NON-NLS-2$ // $NON-NLS-3$ } p.println("</configuration>"); // $NON-NLS-1$ } } p.println("</configurations>"); } } } catch (IOException e) { AutotoolsPlugin.log(e); } }
private void saveConfigs(IProject project, ICConfigurationDescription[] cfgds) { try { String projectName = project.getName(); IPath output = project.getLocation().append(CFG_FILE_NAME); File f = output.toFile(); if (!f.exists()) f.createNewFile(); if (f.exists()) { try (PrintWriter p = new PrintWriter(new BufferedWriter(new FileWriter(f)))) { Map<String, IAConfiguration> cfgs = configs.get(projectName); p.println("<?xml version=\"1.0\" encoding=\"UTF-8\"?>"); // $NON-NLS-1$ p.println("<configurations>"); // $NON-NLS-1$ Option[] optionList = AutotoolsConfiguration.getOptionList(); // Before saving, force any cloning to occur via the option // value handler. setSyncing(true); for (int i = 0; i < cfgds.length; ++i) { @SuppressWarnings("unused") CConfigurationData data = cfgds[i].getConfigurationData(); } setSyncing(false); for (int i = 0; i < cfgds.length; ++i) { ICConfigurationDescription cfgd = cfgds[i]; String id = cfgd.getId(); IAConfiguration cfg = cfgs.get(id); if (cfg == null) { cfg = createDefaultConfiguration(id); } p.println("<configuration id=\"" + cfg.getId() + "\">"); // $NON-NLS-1$ //$NON-NLS-2$ for (int j = 0; j < optionList.length; ++j) { Option option = optionList[j]; IConfigureOption opt = cfg.getOption(option.getName()); if (opt.isFlag()) { p.println( "<flag id=\"" + option.getName() + "\" value=\"" //$NON-NLS-1$ //$NON-NLS-2$ + xmlEscape(option.getDefaultValue()) + "\">"); //$NON-NLS-1$ FlagConfigureOption fco = (FlagConfigureOption) opt; List<String> children = fco.getChildren(); for (int k = 0; k < children.size(); ++k) { String childName = children.get(k); IConfigureOption childopt = cfg.getOption(childName); p.println( "<flagvalue id=\"" + childopt.getName() + "\" value=\"" //$NON-NLS-1$ //$NON-NLS-2$ + xmlEscape(childopt.getValue()) + "\"/>"); // $NON-NLS-3$ } p.println("</flag>"); // $NON-NLS-1$ } else if (!opt.isCategory() && !opt.isFlagValue()) p.println( "<option id=\"" + option.getName() + "\" value=\"" + xmlEscape(opt.getValue()) // $NON-NLS-1$ //$NON-NLS-2$ + "\"/>"); // $NON-NLS-3$ } p.println("</configuration>"); // $NON-NLS-1$ // Sync name field as this configuration is now // officially saved syncNameField(cfgd); } p.println("</configurations>"); } } } catch (IOException e) { AutotoolsPlugin.log(e); } }
/** * Test getting and updating configuration options for an Autotools Project. The top-level * contains autogen.sh which will build configure, but not run it. * * @throws Exception */ public void testGetAndUpdateConfigureOptions() throws Exception { Path p = new Path("zip/project2.zip"); ProjectTools.addSourceContainerWithImport(testProject, "src", p, null); assertTrue(testProject.hasNature(ManagedCProjectNature.MNG_NATURE_ID)); ProjectTools.setConfigDir(testProject, "src"); ProjectTools.markExecutable(testProject, "src/autogen.sh"); assertTrue(ProjectTools.build()); ICConfigurationDescription cfgDes = CoreModel.getDefault().getProjectDescription(testProject).getActiveConfiguration(); IConfiguration cfg = ManagedBuildManager.getConfigurationForDescription(cfgDes); assertTrue(cfg.getName().equals("Build (GNU)")); Map<String, IAutotoolsOption> opts = AutotoolsPlugin.getDefault().getAutotoolCfgOptions(testProject, cfg.getId()); IAutotoolsOption configdir = opts.get(AutotoolsOptionConstants.OPT_CONFIGDIR); assertEquals(configdir.getType(), IAutotoolsOption.INTERNAL); assertTrue(configdir.getValue().equals("src")); assertTrue(configdir.canUpdate()); // Verify we cannot update any of the categories or flags IAutotoolsOption k = opts.get(AutotoolsOptionConstants.CATEGORY_DIRECTORIES); assertFalse(k.canUpdate()); assertEquals(k.getType(), IAutotoolsOption.CATEGORY); k = opts.get(AutotoolsOptionConstants.CATEGORY_FEATURES); assertFalse(k.canUpdate()); assertEquals(k.getType(), IAutotoolsOption.CATEGORY); k = opts.get(AutotoolsOptionConstants.CATEGORY_FILENAMES); assertFalse(k.canUpdate()); k = opts.get(AutotoolsOptionConstants.CATEGORY_GENERAL); assertEquals(k.getType(), IAutotoolsOption.CATEGORY); assertFalse(k.canUpdate()); k = opts.get(AutotoolsOptionConstants.CATEGORY_OPTIONS); assertEquals(k.getType(), IAutotoolsOption.CATEGORY); assertFalse(k.canUpdate()); k = opts.get(AutotoolsOptionConstants.CATEGORY_PLATFORM); assertFalse(k.canUpdate()); assertEquals(k.getType(), IAutotoolsOption.CATEGORY); k = opts.get(AutotoolsOptionConstants.FLAG_CFLAGS); assertFalse(k.canUpdate()); assertEquals(k.getType(), IAutotoolsOption.FLAG); // Tools are ok to update k = opts.get(AutotoolsOptionConstants.TOOL_AUTOGEN); assertTrue(k.canUpdate()); assertEquals(k.getType(), IAutotoolsOption.TOOL); assertEquals(k.getValue(), "autogen.sh"); // $NON-NLS-1$ k.setValue("autogen2.sh"); // $NON-NLS-1$ k = opts.get(AutotoolsOptionConstants.TOOL_CONFIGURE); assertTrue(k.canUpdate()); assertEquals(k.getType(), IAutotoolsOption.TOOL); assertEquals(k.getValue(), "configure"); // $NON-NLS-1$ k.setValue("config"); // $NON-NLS-1$ // Flag values are ok to update k = opts.get(AutotoolsOptionConstants.OPT_CFLAGS_DEBUG); assertTrue(k.canUpdate()); assertEquals(k.getType(), IAutotoolsOption.FLAGVALUE); assertEquals(k.getValue(), "false"); // $NON-NLS-1$ k.setValue("true"); k = opts.get(AutotoolsOptionConstants.OPT_CFLAGS_GCOV); assertTrue(k.canUpdate()); assertEquals(k.getType(), IAutotoolsOption.FLAGVALUE); assertEquals(k.getValue(), "false"); // $NON-NLS-1$ k.setValue("true"); k = opts.get(AutotoolsOptionConstants.OPT_CFLAGS_GPROF); assertTrue(k.canUpdate()); assertEquals(k.getType(), IAutotoolsOption.FLAGVALUE); assertEquals(k.getValue(), "false"); // $NON-NLS-1$ k.setValue("true"); // Check other options k = opts.get(AutotoolsOptionConstants.OPT_AUTOGENOPTS); assertTrue(k.canUpdate()); assertEquals(k.getType(), IAutotoolsOption.MULTIARG); assertEquals(k.getValue(), ""); // $NON-NLS-1$ k.setValue("some opts"); k = opts.get(AutotoolsOptionConstants.OPT_BINDIR); assertTrue(k.canUpdate()); assertEquals(k.getType(), IAutotoolsOption.STRING); assertEquals(k.getValue(), ""); // $NON-NLS-1$ k.setValue("/usr/bin"); k = opts.get(AutotoolsOptionConstants.OPT_BUILD); assertTrue(k.canUpdate()); assertEquals(k.getType(), IAutotoolsOption.STRING); assertEquals(k.getValue(), ""); // $NON-NLS-1$ k.setValue("linux"); k = opts.get(AutotoolsOptionConstants.OPT_CACHE_FILE); assertTrue(k.canUpdate()); assertEquals(k.getType(), IAutotoolsOption.STRING); assertEquals(k.getValue(), ""); // $NON-NLS-1$ k.setValue("config.status"); k = opts.get(AutotoolsOptionConstants.OPT_DATADIR); assertTrue(k.canUpdate()); assertEquals(k.getType(), IAutotoolsOption.STRING); assertEquals(k.getValue(), ""); // $NON-NLS-1$ k.setValue("/usr/data"); k = opts.get(AutotoolsOptionConstants.OPT_ENABLE_MAINTAINER_MODE); assertTrue(k.canUpdate()); assertEquals(k.getType(), IAutotoolsOption.BIN); assertEquals(k.getValue(), "false"); // $NON-NLS-1$ k.setValue("true"); k = opts.get(AutotoolsOptionConstants.OPT_EXEC_PREFIX); assertTrue(k.canUpdate()); assertEquals(k.getType(), IAutotoolsOption.STRING); assertEquals(k.getValue(), ""); // $NON-NLS-1$ k.setValue("/usr/exec"); k = opts.get(AutotoolsOptionConstants.OPT_HELP); assertTrue(k.canUpdate()); assertEquals(k.getType(), IAutotoolsOption.BIN); assertEquals(k.getValue(), "false"); // $NON-NLS-1$ k.setValue("true"); k = opts.get(AutotoolsOptionConstants.OPT_HOST); assertTrue(k.canUpdate()); assertEquals(k.getType(), IAutotoolsOption.STRING); assertEquals(k.getValue(), ""); // $NON-NLS-1$ k.setValue("linux"); k = opts.get(AutotoolsOptionConstants.OPT_INCLUDEDIR); assertTrue(k.canUpdate()); assertEquals(k.getType(), IAutotoolsOption.STRING); assertEquals(k.getValue(), ""); // $NON-NLS-1$ k.setValue("/usr/include"); k = opts.get(AutotoolsOptionConstants.OPT_INFODIR); assertTrue(k.canUpdate()); assertEquals(k.getType(), IAutotoolsOption.STRING); assertEquals(k.getValue(), ""); // $NON-NLS-1$ k.setValue("/usr/info"); k = opts.get(AutotoolsOptionConstants.OPT_LIBDIR); assertTrue(k.canUpdate()); assertEquals(k.getType(), IAutotoolsOption.STRING); assertEquals(k.getValue(), ""); // $NON-NLS-1$ k.setValue("/usr/lib"); k = opts.get(AutotoolsOptionConstants.OPT_LIBEXECDIR); assertTrue(k.canUpdate()); assertEquals(k.getType(), IAutotoolsOption.STRING); assertEquals(k.getValue(), ""); // $NON-NLS-1$ k.setValue("/usr/libexec"); k = opts.get(AutotoolsOptionConstants.OPT_LOCALSTATEDIR); assertTrue(k.canUpdate()); assertEquals(k.getType(), IAutotoolsOption.STRING); assertEquals(k.getValue(), ""); // $NON-NLS-1$ k.setValue("/usr/localstate"); k = opts.get(AutotoolsOptionConstants.OPT_MANDIR); assertTrue(k.canUpdate()); assertEquals(k.getType(), IAutotoolsOption.STRING); assertEquals(k.getValue(), ""); // $NON-NLS-1$ k.setValue("/usr/man"); k = opts.get(AutotoolsOptionConstants.OPT_NO_CREATE); assertTrue(k.canUpdate()); assertEquals(k.getType(), IAutotoolsOption.BIN); assertEquals(k.getValue(), "false"); // $NON-NLS-1$ k.setValue("true"); k = opts.get(AutotoolsOptionConstants.OPT_OLDINCLUDEDIR); assertTrue(k.canUpdate()); assertEquals(k.getType(), IAutotoolsOption.STRING); assertEquals(k.getValue(), ""); // $NON-NLS-1$ k.setValue("/usr/oldinclude"); k = opts.get(AutotoolsOptionConstants.OPT_PREFIX); assertTrue(k.canUpdate()); assertEquals(k.getType(), IAutotoolsOption.STRING); assertEquals(k.getValue(), ""); // $NON-NLS-1$ k.setValue("prefix"); k = opts.get(AutotoolsOptionConstants.OPT_PROGRAM_PREFIX); assertTrue(k.canUpdate()); assertEquals(k.getType(), IAutotoolsOption.STRING); assertEquals(k.getValue(), ""); // $NON-NLS-1$ k.setValue("program_prefix"); k = opts.get(AutotoolsOptionConstants.OPT_PROGRAM_SUFFIX); assertTrue(k.canUpdate()); assertEquals(k.getType(), IAutotoolsOption.STRING); assertEquals(k.getValue(), ""); // $NON-NLS-1$ k.setValue("program_suffix"); k = opts.get(AutotoolsOptionConstants.OPT_PROGRAM_TRANSFORM_NAME); assertTrue(k.canUpdate()); assertEquals(k.getType(), IAutotoolsOption.STRING); assertEquals(k.getValue(), ""); // $NON-NLS-1$ k.setValue("program_transform_name"); k = opts.get(AutotoolsOptionConstants.OPT_QUIET); assertTrue(k.canUpdate()); assertEquals(k.getType(), IAutotoolsOption.BIN); assertEquals(k.getValue(), "false"); // $NON-NLS-1$ k.setValue("true"); k = opts.get(AutotoolsOptionConstants.OPT_SBINDIR); assertTrue(k.canUpdate()); assertEquals(k.getType(), IAutotoolsOption.STRING); assertEquals(k.getValue(), ""); // $NON-NLS-1$ k.setValue("/usr/sbin"); k = opts.get(AutotoolsOptionConstants.OPT_SHAREDSTATEDIR); assertTrue(k.canUpdate()); assertEquals(k.getType(), IAutotoolsOption.STRING); assertEquals(k.getValue(), ""); // $NON-NLS-1$ k.setValue("/usr/sharedstate"); k = opts.get(AutotoolsOptionConstants.OPT_SRCDIR); assertTrue(k.canUpdate()); assertEquals(k.getType(), IAutotoolsOption.STRING); assertEquals(k.getValue(), ""); // $NON-NLS-1$ k.setValue("src"); k = opts.get(AutotoolsOptionConstants.OPT_SYSCONFDIR); assertTrue(k.canUpdate()); assertEquals(k.getType(), IAutotoolsOption.STRING); assertEquals(k.getValue(), ""); // $NON-NLS-1$ k.setValue("/usr/sysconf"); k = opts.get(AutotoolsOptionConstants.OPT_TARGET); assertTrue(k.canUpdate()); assertEquals(k.getType(), IAutotoolsOption.STRING); assertEquals(k.getValue(), ""); // $NON-NLS-1$ k.setValue("target"); k = opts.get(AutotoolsOptionConstants.OPT_USER); assertTrue(k.canUpdate()); assertEquals(k.getType(), IAutotoolsOption.MULTIARG); assertEquals(k.getValue(), ""); // $NON-NLS-1$ k.setValue("user opts"); k = opts.get(AutotoolsOptionConstants.OPT_VERSION); assertTrue(k.canUpdate()); assertEquals(k.getType(), IAutotoolsOption.BIN); assertEquals(k.getValue(), "false"); // $NON-NLS-1$ k.setValue("true"); // Verify last option changed has changed in our copy, but not // in the actual options assertEquals(k.getValue(), "true"); Map<String, IAutotoolsOption> opts2 = AutotoolsPlugin.getDefault().getAutotoolCfgOptions(testProject, cfg.getId()); IAutotoolsOption k2 = opts2.get(AutotoolsOptionConstants.OPT_VERSION); assertEquals(k2.getValue(), "false"); // Now update the options we changed AutotoolsPlugin.getDefault().updateAutotoolCfgOptions(testProject, cfg.getId(), opts); opts2 = AutotoolsPlugin.getDefault().getAutotoolCfgOptions(testProject, cfg.getId()); // Verify new option values k = opts2.get(AutotoolsOptionConstants.TOOL_AUTOGEN); assertEquals(k.getValue(), "autogen2.sh"); // $NON-NLS-1$ k = opts2.get(AutotoolsOptionConstants.TOOL_CONFIGURE); assertEquals(k.getValue(), "config"); // $NON-NLS-1$ k = opts2.get(AutotoolsOptionConstants.OPT_CFLAGS_DEBUG); assertEquals(k.getValue(), "true"); // $NON-NLS-1$ k = opts2.get(AutotoolsOptionConstants.OPT_CFLAGS_GCOV); assertEquals(k.getValue(), "true"); // $NON-NLS-1$ k = opts2.get(AutotoolsOptionConstants.OPT_CFLAGS_GPROF); assertEquals(k.getValue(), "true"); // $NON-NLS-1$ k = opts2.get(AutotoolsOptionConstants.OPT_AUTOGENOPTS); assertEquals(k.getValue(), "some opts"); // $NON-NLS-1$ k = opts2.get(AutotoolsOptionConstants.OPT_BINDIR); assertEquals(k.getValue(), "/usr/bin"); // $NON-NLS-1$ k = opts2.get(AutotoolsOptionConstants.OPT_BUILD); assertEquals(k.getValue(), "linux"); // $NON-NLS-1$ k = opts2.get(AutotoolsOptionConstants.OPT_CACHE_FILE); assertEquals(k.getValue(), "config.status"); // $NON-NLS-1$ k = opts2.get(AutotoolsOptionConstants.OPT_DATADIR); assertEquals(k.getValue(), "/usr/data"); // $NON-NLS-1$ k = opts2.get(AutotoolsOptionConstants.OPT_ENABLE_MAINTAINER_MODE); assertEquals(k.getValue(), "true"); // $NON-NLS-1$ k = opts2.get(AutotoolsOptionConstants.OPT_EXEC_PREFIX); assertEquals(k.getValue(), "/usr/exec"); // $NON-NLS-1$ k = opts2.get(AutotoolsOptionConstants.OPT_HELP); assertEquals(k.getValue(), "true"); // $NON-NLS-1$ k = opts2.get(AutotoolsOptionConstants.OPT_HOST); assertEquals(k.getValue(), "linux"); // $NON-NLS-1$ k = opts2.get(AutotoolsOptionConstants.OPT_INCLUDEDIR); assertEquals(k.getValue(), "/usr/include"); // $NON-NLS-1$ k = opts2.get(AutotoolsOptionConstants.OPT_INFODIR); assertEquals(k.getValue(), "/usr/info"); // $NON-NLS-1$ k = opts2.get(AutotoolsOptionConstants.OPT_LIBDIR); assertEquals(k.getValue(), "/usr/lib"); // $NON-NLS-1$ k = opts2.get(AutotoolsOptionConstants.OPT_LIBEXECDIR); assertEquals(k.getValue(), "/usr/libexec"); // $NON-NLS-1$ k = opts2.get(AutotoolsOptionConstants.OPT_LOCALSTATEDIR); assertEquals(k.getValue(), "/usr/localstate"); // $NON-NLS-1$ k = opts2.get(AutotoolsOptionConstants.OPT_MANDIR); assertEquals(k.getValue(), "/usr/man"); // $NON-NLS-1$ k = opts2.get(AutotoolsOptionConstants.OPT_NO_CREATE); assertEquals(k.getValue(), "true"); // $NON-NLS-1$ k = opts2.get(AutotoolsOptionConstants.OPT_OLDINCLUDEDIR); assertEquals(k.getValue(), "/usr/oldinclude"); // $NON-NLS-1$ k = opts2.get(AutotoolsOptionConstants.OPT_PREFIX); assertEquals(k.getValue(), "prefix"); // $NON-NLS-1$ k = opts2.get(AutotoolsOptionConstants.OPT_PROGRAM_PREFIX); assertEquals(k.getValue(), "program_prefix"); // $NON-NLS-1$ k = opts2.get(AutotoolsOptionConstants.OPT_PROGRAM_SUFFIX); assertEquals(k.getValue(), "program_suffix"); // $NON-NLS-1$ k = opts2.get(AutotoolsOptionConstants.OPT_PROGRAM_TRANSFORM_NAME); assertEquals(k.getValue(), "program_transform_name"); // $NON-NLS-1$ k = opts2.get(AutotoolsOptionConstants.OPT_QUIET); assertEquals(k.getValue(), "true"); // $NON-NLS-1$ k = opts2.get(AutotoolsOptionConstants.OPT_SBINDIR); assertEquals(k.getValue(), "/usr/sbin"); // $NON-NLS-1$ k = opts2.get(AutotoolsOptionConstants.OPT_SHAREDSTATEDIR); assertEquals(k.getValue(), "/usr/sharedstate"); // $NON-NLS-1$ k = opts2.get(AutotoolsOptionConstants.OPT_SRCDIR); assertEquals(k.getValue(), "src"); // $NON-NLS-1$ k = opts2.get(AutotoolsOptionConstants.OPT_SYSCONFDIR); assertEquals(k.getValue(), "/usr/sysconf"); // $NON-NLS-1$ k = opts2.get(AutotoolsOptionConstants.OPT_TARGET); assertEquals(k.getValue(), "target"); // $NON-NLS-1$ k = opts2.get(AutotoolsOptionConstants.OPT_USER); assertEquals(k.getValue(), "user opts"); // $NON-NLS-1$ k = opts2.get(AutotoolsOptionConstants.OPT_VERSION); assertEquals(k.getValue(), "true"); // $NON-NLS-1$ // Verify one updated option in the .autotools file for the project try { IPath fileLocation = testProject.getLocation().append(".autotools"); // $NON-NLS-1$ File dirFile = fileLocation.toFile(); DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); DocumentBuilder db = dbf.newDocumentBuilder(); assertTrue(dirFile.exists()); Document d = db.parse(dirFile); Element e = d.getDocumentElement(); // Get the stored configuration data NodeList cfgs = e.getElementsByTagName("configuration"); // $NON-NLS-1$ for (int x = 0; x < cfgs.getLength(); ++x) { Node n = cfgs.item(x); NodeList l = n.getChildNodes(); for (int y = 0; y < l.getLength(); ++y) { Node child = l.item(y); if (child.getNodeName().equals("option")) { // $NON-NLS-1$ NamedNodeMap optionAttrs = child.getAttributes(); Node id = optionAttrs.getNamedItem("id"); // $NON-NLS-1$ Node value = optionAttrs.getNamedItem("value"); // $NON-NLS-1$ // Verify the bindir option is updated if (id.equals(AutotoolsOptionConstants.OPT_BINDIR)) assertEquals(value, "/usr/bin"); // $NON-NLS-1$ } } } } catch (ParserConfigurationException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (SAXException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } }