public static PropertyScanner createScanner(ProjectVersion version) { Project project = version.getParent(); String propertyType = project.getPropertyType(); return createScanner(propertyType); }
public static URI computeTemplateResourceLocation(Locale locale, URI translationLocation, Locale masterLocale, ProjectVersion version) { PropertyScanner scanner = createScanner(version); URI parentPath = version.absoluteFilePath(); File path = scanner.findTemplate(new File(parentPath.path()+translationLocation.toString()), null); URI location = URI.createFileURI(path.getAbsolutePath()); URI trimmedLocation = URI.createURI(location.segment(parentPath.segmentCount())); for (int i = parentPath.segmentCount()+1; i < location.segmentCount(); i++) { //append the other segments trimmedLocation = trimmedLocation.appendSegment(location.segment(i)); } return trimmedLocation; }
protected PropertyFileDescriptor findDescriptor(URI path) { PropertyScanner scanner = PropertyResourceUtil.createScanner(this); Locale variant = scanner.getLocale(new File(path.path())); ProjectLocale locale = variant == null ? getTemplate() : getProjectLocale(variant); if (locale == null) return null; EList<PropertyFileDescriptor> descriptors = locale.getDescriptors(); for (PropertyFileDescriptor descriptor : descriptors) { if (path.equals(descriptor.getLocation())) { return descriptor; } } return null; }
@Override protected void doSave(OutputStream outputStream, Map<?, ?> options) throws IOException { savedProperties = 0; String type = getPropertyType(options); PropertyScanner scanner = PropertyResourceUtil.createScanner(type); String encoding = scanner.getEncoding(); PropertyConverter converter = scanner.createConverter(getURI()); try{ PropertyFile file = (PropertyFile) getContents().get(0); savedProperties = converter.write(outputStream, file,encoding); } finally{ outputStream.close(); } }
@Override protected void doLoad(InputStream inputStream, Map<?, ?> options) throws IOException { String type = getPropertyType(options); PropertyScanner scanner = PropertyResourceUtil.createScanner(type); PropertyConverter converter = scanner.createConverter(getURI()); PropertyFile file = converter.load(inputStream, scanner.getEncoding()); getContents().add(file); }
public static URI computeLocaleResourceLocation(Locale locale, ProjectVersion version, URI templateLocation) { PropertyScanner scanner = createScanner(version); URI parentPath = version.absoluteFilePath(); String childPath = templateLocation.path(); if (childPath != null && !childPath.startsWith("/")) childPath = "/" + childPath; File path = scanner.computeTranslationPath(new File(URI.decode(parentPath.path()) + URI.decode(childPath)), version.getTemplate().getLocale(), locale); /* * workaround for https://github.com/jutzig/jabylon/issues/238 certain * issues seem to trigger a bug in EMFs createFileURI */ URI location = URI.createURI(path.getAbsolutePath().replace('\\','/')); URI trimmedLocation = URI.createURI(location.segment(parentPath.segmentCount())); for (int i = parentPath.segmentCount() + 1; i < location.segmentCount(); i++) { // append the other segments trimmedLocation = trimmedLocation.appendSegment(location.segment(i)); } return trimmedLocation; }
File baseDir = new File(absolutPath().path()).getAbsoluteFile(); SubMonitor subMonitor = SubMonitor.convert(monitor, "Scanning", 100); PropertyScanner propertyScanner = PropertyResourceUtil.createScanner(this); scanner.fullScan(new FullScanFileAcceptor(this, propertyScanner, configuration), baseDir, propertyScanner, configuration, subMonitor.newChild(50));
PropertyScanner propertyScanner = PropertyResourceUtil.createScanner(this); WorkspaceScanner scanner = new WorkspaceScanner(); File baseDir = new File(absolutPath().path()).getAbsoluteFile();