private void appendStaticField(StringBuffer buf, NLSSubstitution substitution) { buf.append("public static String "); //$NON-NLS-1$ buf.append(substitution.getKey()); buf.append(';'); }
private void appendStaticField(StringBuffer buf, NLSSubstitution substitution) { buf.append("public static String "); //$NON-NLS-1$ buf.append(substitution.getKey()); buf.append(';'); }
@Override protected void okPressed() { String prefix= fNameField.getText(); for (int i= 0; i < fSelectedSubstitutions.size(); i++) { NLSSubstitution sub= fSelectedSubstitutions.get(i); String newKey= prefix + sub.getKey().substring(fCommonPrefixLength); sub.setKey(newKey); } super.okPressed(); }
@Override protected void okPressed() { String prefix= fNameField.getText(); for (int i= 0; i < fSelectedSubstitutions.size(); i++) { NLSSubstitution sub= fSelectedSubstitutions.get(i); String newKey= prefix + sub.getKey().substring(fCommonPrefixLength); sub.setKey(newKey); } super.okPressed(); }
protected void okPressed() { String prefix= fNameField.getText(); for (int i= 0; i < fSelectedSubstitutions.size(); i++) { NLSSubstitution sub= (NLSSubstitution) fSelectedSubstitutions.get(i); String newKey= prefix + sub.getKey().substring(fCommonPrefixLength); sub.setKey(newKey); } super.okPressed(); }
private void checkMissingKeys(RefactoringStatus status) { for (int i= 0; i < fSubstitutions.length; i++) { NLSSubstitution substitution= fSubstitutions[i]; if ((substitution.getValue() == null) && (substitution.getKey() != null)) { status.addWarning(NLSUIMessages.ExternalizeWizardPage_warning_keymissing); return; } } }
private void checkMissingKeys(RefactoringStatus status) { for (int i= 0; i < fSubstitutions.length; i++) { NLSSubstitution substitution= fSubstitutions[i]; if ((substitution.getValue() == null) && (substitution.getKey() != null)) { status.addWarning(NLSUIMessages.ExternalizeWizardPage_warning_keymissing); return; } } }
public static void updateSubtitutions(NLSSubstitution[] substitutions, Properties props, String accessorClassName) { for (int i= 0; i < substitutions.length; i++) { NLSSubstitution substitution= substitutions[i]; if ((substitution.getState() == NLSSubstitution.EXTERNALIZED) && !substitution.hasStateChanged()) { substitution.setInitialValue(props.getProperty(substitution.getKey())); substitution.setUpdatedAccessor(accessorClassName); } } }
public static void updateSubtitutions(NLSSubstitution[] substitutions, Properties props, String accessorClassName) { for (int i= 0; i < substitutions.length; i++) { NLSSubstitution substitution= substitutions[i]; if ((substitution.getState() == NLSSubstitution.EXTERNALIZED) && !substitution.hasStateChanged()) { substitution.setInitialValue(props.getProperty(substitution.getKey())); substitution.setUpdatedAccessor(accessorClassName); } } }
static boolean doReplace(NLSSubstitution substitution, Map newKeyToSubstMap, Map oldKeyToSubstMap) { if (substitution.getState() != NLSSubstitution.EXTERNALIZED || substitution.hasStateChanged() || substitution.getInitialValue() == null) { return false; // was not in property file before } if (oldKeyToSubstMap.get(substitution.getInitialKey()) != substitution) { return false; // not the owner of this key } if (substitution.isKeyRename() || substitution.isValueRename()) { if (newKeyToSubstMap.get(substitution.getKey()) == substitution) { // only rename if we're not a duplicate. duplicates will be removed return true; } } return false; }
private void replaceKey(NLSSubstitution substitution, TextChange change) { Region region= substitution.getNLSElement().getPosition(); String[] args= {substitution.getInitialKey(), BasicElementLabels.getJavaElementName(substitution.getKey())}; ReplaceEdit replaceEdit; if (fIsEclipseNLS) replaceEdit= new ReplaceEdit(region.getOffset(), region.getLength(), substitution.getKey()); else replaceEdit= new ReplaceEdit(region.getOffset(), region.getLength(), '\"' + unwindEscapeChars(substitution.getKey()) + '\"'); // TextChangeCompatibility.addTextEdit(change, Messages.format(NLSMessages.NLSSourceModifier_replace_key, args), replaceEdit); }
private void replaceKey(NLSSubstitution substitution, TextChange change) { Region region= substitution.getNLSElement().getPosition(); String[] args= {substitution.getInitialKey(), BasicElementLabels.getJavaElementName(substitution.getKey())}; ReplaceEdit replaceEdit; if (fIsEclipseNLS) replaceEdit= new ReplaceEdit(region.getOffset(), region.getLength(), substitution.getKey()); else replaceEdit= new ReplaceEdit(region.getOffset(), region.getLength(), '\"' + unwindEscapeChars(substitution.getKey()) + '\"'); // TextChangeCompatibility.addTextEdit(change, Messages.format(NLSMessages.NLSSourceModifier_replace_key, args), replaceEdit); }
private void replaceKey(NLSSubstitution substitution, TextChange change) { Region region= substitution.getNLSElement().getPosition(); String[] args= {substitution.getInitialKey(), substitution.getKey()}; ReplaceEdit replaceEdit; if (fIsEclipseNLS) replaceEdit= new ReplaceEdit(region.getOffset(), region.getLength(), substitution.getKey()); else replaceEdit= new ReplaceEdit(region.getOffset(), region.getLength(), '\"' + unwindEscapeChars(substitution.getKey()) + '\"'); // TextChangeCompatibility.addTextEdit(change, Messages.format(NLSMessages.NLSSourceModifier_replace_key, args), replaceEdit); }
private static void addReplaceEdits(TextChange textChange, NLSSubstitution[] substitutions, Map newKeyToSubstMap, Map oldKeyToSubstMap, PropertyFileDocumentModel model) { for (int i= 0; i < substitutions.length; i++) { NLSSubstitution substitution= substitutions[i]; if (doReplace(substitution, newKeyToSubstMap, oldKeyToSubstMap)) { KeyValuePair initialPair= new KeyValuePair(substitution.getInitialKey(), substitution.getInitialValue()); KeyValuePair newPair= new KeyValuePair(substitution.getKey(), substitution.getValueNonEmpty()); TextEdit edit= model.replace(initialPair, newPair); if (edit != null) { TextChangeCompatibility.addTextEdit(textChange, Messages.format(NLSMessages.NLSPropertyFileModifier_replace_entry, substitution.getKey()), edit); } } } }
private RefactoringStatus checkKeys() { RefactoringStatus result= new RefactoringStatus(); NLSSubstitution[] subs= fSubstitutions; for (int i= 0; i < subs.length; i++) { NLSSubstitution substitution= subs[i]; if ((substitution.getState() == NLSSubstitution.EXTERNALIZED) && substitution.hasStateChanged()) { result.merge(checkKey(substitution.getKey())); } } return result; }
private void addKey(NLSSubstitution sub, TextChange change) { String name= Messages.format(NLSMessages.AccessorClassModifier_add_entry, BasicElementLabels.getJavaElementName(sub.getKey())); TextEditGroup editGroup= new TextEditGroup(name); change.addTextEditGroup(editGroup); addKey(sub, editGroup); }
private static void addInsertEdits(TextChange textChange, NLSSubstitution[] substitutions, Map newKeyToSubstMap, Map oldKeyToSubstMap, PropertyFileDocumentModel model) { for (int i= 0; i < substitutions.length; i++) { NLSSubstitution substitution= substitutions[i]; if (doInsert(substitution, newKeyToSubstMap, oldKeyToSubstMap)) { String value= substitution.getValueNonEmpty(); KeyValuePair curr= new KeyValuePair(substitution.getKey(), value); InsertEdit insert= model.insert(curr); String message= Messages.format(NLSMessages.NLSPropertyFileModifier_add_entry, curr.getKey()); TextChangeCompatibility.addTextEdit(textChange, message, insert); } } }
private void addNLS(NLSSubstitution sub, TextChange change, String accessorName) { if (sub.getState() == NLSSubstitution.INTERNALIZED) return; NLSElement element= sub.getNLSElement(); addAccessor(sub, change, accessorName); if (!fIsEclipseNLS || sub.getState() == NLSSubstitution.IGNORED) { // Add $NON-NLS-n tag String arg= sub.getState() == NLSSubstitution.EXTERNALIZED ? sub.getKey() : sub.getValueNonEmpty(); String name= Messages.format(NLSMessages.NLSSourceModifier_add_tag, arg); TextChangeCompatibility.addTextEdit(change, name, createAddTagChange(element)); } }