public static Change create(NLSSubstitution[] nlsSubstitutions, IPath propertyFilePath) throws CoreException { String name= Messages.format(NLSMessages.NLSPropertyFileModifier_change_name, propertyFilePath.toString()); TextChange textChange= null; if (!Checks.resourceExists(propertyFilePath)) { IProject project= getFileHandle(propertyFilePath).getProject(); String lineDelimiter= StubUtility.getLineDelimiterPreference(project); Document document= new Document(); document.setInitialLineDelimiter(lineDelimiter); textChange= new DocumentChange(name, document); addChanges(textChange, nlsSubstitutions); textChange.perform(new NullProgressMonitor()); String encoding= null; IContentType javaPropertiesContentType= Platform.getContentTypeManager().getContentType("org.eclipse.jdt.core.javaProperties"); //$NON-NLS-1$ IContentType[] contentTypes= Platform.getContentTypeManager().findContentTypesFor(propertyFilePath.lastSegment()); if (contentTypes.length == 0 || contentTypes.length > 1 || !contentTypes[0].equals(javaPropertiesContentType)) { if (javaPropertiesContentType != null) encoding= javaPropertiesContentType.getDefaultCharset(); if (encoding == null) encoding= "ISO-8859-1"; //$NON-NLS-1$ } return new CreateTextFileChange(propertyFilePath, textChange.getCurrentContent(new NullProgressMonitor()), encoding, "properties"); //$NON-NLS-1$ } textChange= new TextFileChange(name, getPropertyFile(propertyFilePath)); textChange.setTextType("properties"); //$NON-NLS-1$ addChanges(textChange, nlsSubstitutions); return textChange; }
public static Change create(NLSSubstitution[] nlsSubstitutions, IPath propertyFilePath) throws CoreException { String name= Messages.format(NLSMessages.NLSPropertyFileModifier_change_name, BasicElementLabels.getPathLabel(propertyFilePath, false)); TextChange textChange= null; if (!Checks.resourceExists(propertyFilePath)) { IProject project= getFileHandle(propertyFilePath).getProject(); String lineDelimiter= StubUtility.getLineDelimiterPreference(project); Document document= new Document(); document.setInitialLineDelimiter(lineDelimiter); textChange= new DocumentChange(name, document); addChanges(textChange, nlsSubstitutions); textChange.perform(new NullProgressMonitor()); String encoding= null; IContentType javaPropertiesContentType= Platform.getContentTypeManager().getContentType("org.eclipse.jdt.core.javaProperties"); //$NON-NLS-1$ IContentType[] contentTypes= Platform.getContentTypeManager().findContentTypesFor(propertyFilePath.lastSegment()); if (contentTypes.length == 0 || contentTypes.length > 1 || !contentTypes[0].equals(javaPropertiesContentType)) { if (javaPropertiesContentType != null) encoding= javaPropertiesContentType.getDefaultCharset(); if (encoding == null) encoding= "ISO-8859-1"; //$NON-NLS-1$ } return new CreateTextFileChange(propertyFilePath, textChange.getCurrentContent(new NullProgressMonitor()), encoding, "properties"); //$NON-NLS-1$ } textChange= new TextFileChange(name, getPropertyFile(propertyFilePath)); textChange.setTextType("properties"); //$NON-NLS-1$ addChanges(textChange, nlsSubstitutions); return textChange; }
public static Change create(NLSSubstitution[] nlsSubstitutions, IPath propertyFilePath) throws CoreException { String name= Messages.format(NLSMessages.NLSPropertyFileModifier_change_name, BasicElementLabels.getPathLabel(propertyFilePath, false)); TextChange textChange= null; if (!Checks.resourceExists(propertyFilePath)) { IProject project= getFileHandle(propertyFilePath).getProject(); String lineDelimiter= StubUtility.getLineDelimiterPreference(project); Document document= new Document(); document.setInitialLineDelimiter(lineDelimiter); textChange= new DocumentChange(name, document); addChanges(textChange, nlsSubstitutions); textChange.perform(new NullProgressMonitor()); String encoding= null; IContentType javaPropertiesContentType= Platform.getContentTypeManager().getContentType("org.eclipse.jdt.core.javaProperties"); //$NON-NLS-1$ IContentType[] contentTypes= Platform.getContentTypeManager().findContentTypesFor(propertyFilePath.lastSegment()); if (contentTypes.length == 0 || contentTypes.length > 1 || !contentTypes[0].equals(javaPropertiesContentType)) { if (javaPropertiesContentType != null) encoding= javaPropertiesContentType.getDefaultCharset(); if (encoding == null) encoding= "ISO-8859-1"; //$NON-NLS-1$ } return new CreateTextFileChange(propertyFilePath, textChange.getCurrentContent(new NullProgressMonitor()), encoding, "properties"); //$NON-NLS-1$ } textChange= new TextFileChange(name, getPropertyFile(propertyFilePath)); textChange.setTextType("properties"); //$NON-NLS-1$ addChanges(textChange, nlsSubstitutions); return textChange; }