public boolean performFinish() { FeatureModel featureModel = new FeatureModel(); featureModel.createDefaultValues(""); Path fullFilePath = new Path(page.fileName.getText()); IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot(); IPath rootPath = root.getLocation(); if (rootPath.isPrefixOf(fullFilePath)) { // case: is file in workspace int matchingFirstSegments = rootPath.matchingFirstSegments(fullFilePath); IPath localFilePath = fullFilePath.removeFirstSegments(matchingFirstSegments); String[] segments = localFilePath.segments(); localFilePath = new Path(""); for (String segment : segments) { localFilePath = localFilePath.append(segment); } IFile file = root.getFile(localFilePath); featureModel.initFMComposerExtension(file.getProject()); try { new FeatureModelWriterIFileWrapper(new XmlFeatureModelWriter(featureModel)) .writeToFile(file); file.refreshLocal(IResource.DEPTH_INFINITE, null); } catch (CoreException e) { FMUIPlugin.getDefault().logError(e); } open(file); } else { // case: is no file in workspace File file = fullFilePath.toFile(); new XmlFeatureModelWriter(featureModel).writeToFile(file); } return true; }
private ArrayList getTemplates() { ArrayList templates = new ArrayList(); CFMLPropertyManager propertyManager = new CFMLPropertyManager(); Path snipBase = new Path(propertyManager.defaultSnippetsPath()); File file = snipBase.toFile(); logger.debug("Getting snippets from " + file.getAbsolutePath()); // Now we iterate over the items I guess return null; }
/** Save attributes to an XML file. */ static void saveAttributes(IPath filenameHint, AttributeValueSets attributes) { final IPath pathHint = filenameHint.isAbsolute() ? filenameHint : FileDialogs.recallPath(REMEMBER_DIRECTORY).append(filenameHint); final Path saveLocation = FileDialogs.openSaveXML(pathHint); if (saveLocation != null) { try { final Persister persister = new Persister(new Format(2)); persister.write(attributes, saveLocation.toFile()); } catch (Exception e) { Utils.showError( new Status( IStatus.ERROR, WorkbenchCorePlugin.PLUGIN_ID, "An error occurred while saving attributes.", e)); } FileDialogs.rememberDirectory(REMEMBER_DIRECTORY, saveLocation); } }