am cdece3f1: Merge change 5678 into donut

Merge commit 'cdece3f14d9ea083e7cec3c696542206232c87cc'

* commit 'cdece3f14d9ea083e7cec3c696542206232c87cc':
  ADT #1843641: fix 'Extract string from layout creates blank string'
This commit is contained in:
Android (Google) Code Review
2009-07-01 00:07:12 -07:00
committed by The Android Open Source Project

View File

@@ -58,8 +58,10 @@ class ExtractStringInputPage extends UserInputWizardPage implements IWizardPage
/** The project where the user selection happened. */
private final IProject mProject;
/** Test field where the user enters the new ID to be generated or replaced with. */
/** Text field where the user enters the new ID to be generated or replaced with. */
private Text mStringIdField;
/** Text field where the user enters the new string value. */
private Text mStringValueField;
/** The configuration selector, to select the resource path of the XML file. */
private ConfigurationSelector mConfigSelector;
/** The combo to display the existing XML files or enter a new one. */
@@ -80,6 +82,7 @@ class ExtractStringInputPage extends UserInputWizardPage implements IWizardPage
private XmlStringFileHelper mXmlHelper = new XmlStringFileHelper();
public ExtractStringInputPage(IProject project) {
super("ExtractStringInputPage"); //$NON-NLS-1$
mProject = project;
@@ -133,17 +136,15 @@ class ExtractStringInputPage extends UserInputWizardPage implements IWizardPage
String selectedString = ref.getTokenString();
final Text stringValueField = new Text(group, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
stringValueField.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
stringValueField.setText(selectedString != null ? selectedString : ""); //$NON-NLS-1$
mStringValueField = new Text(group, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
mStringValueField.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
mStringValueField.setText(selectedString != null ? selectedString : ""); //$NON-NLS-1$
ref.setNewStringValue(stringValueField.getText());
ref.setNewStringValue(mStringValueField.getText());
stringValueField.addModifyListener(new ModifyListener() {
mStringValueField.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent e) {
if (validatePage()) {
ref.setNewStringValue(stringValueField.getText());
}
validatePage();
}
});
@@ -170,9 +171,7 @@ class ExtractStringInputPage extends UserInputWizardPage implements IWizardPage
mStringIdField.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent e) {
if (validatePage()) {
ref.setNewStringId(mStringIdField.getText().trim());
}
validatePage();
}
});
}
@@ -259,11 +258,15 @@ class ExtractStringInputPage extends UserInputWizardPage implements IWizardPage
* Validates fields of the wizard input page. Displays errors as appropriate and
* enable the "Next" button (or not) by calling {@link #setPageComplete(boolean)}.
*
* If validation succeeds, this udpates the text id & value in the refactoring object.
*
* @return True if the page has been positively validated. It may still have warnings.
*/
private boolean validatePage() {
boolean success = true;
ExtractStringRefactoring ref = getOurRefactoring();
// Analyze fatal errors.
String text = mStringIdField.getText().trim();
@@ -284,6 +287,11 @@ class ExtractStringInputPage extends UserInputWizardPage implements IWizardPage
break;
}
}
// update the field in the refactoring object in case of success
if (success) {
ref.setNewStringId(text);
}
}
String resFile = mResFileCombo.getText();
@@ -302,8 +310,6 @@ class ExtractStringInputPage extends UserInputWizardPage implements IWizardPage
if (success) {
setErrorMessage(null);
ExtractStringRefactoring ref = getOurRefactoring();
ref.setTargetFile(resFile);
sLastResFilePath.put(mProject.getFullPath().toPortableString(), resFile);
@@ -326,6 +332,11 @@ class ExtractStringInputPage extends UserInputWizardPage implements IWizardPage
}
}
if (success) {
// Also update the text value in case of success.
ref.setNewStringValue(mStringValueField.getText());
}
setPageComplete(success);
return success;
}