Bug 38287 - TVT21: Use of variable makes the string difficult to translate
diff --git a/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/ui/internal/preferences/AddCustomDialog.java b/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/ui/internal/preferences/AddCustomDialog.java
index aed46d7..c9d1d19 100644
--- a/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/ui/internal/preferences/AddCustomDialog.java
+++ b/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/ui/internal/preferences/AddCustomDialog.java
@@ -44,7 +44,6 @@
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Combo;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
@@ -70,20 +69,17 @@
//A boolean to indicate if the user has typed anything
private boolean entryChanged = false;
- protected Combo sourceNameField;
-
- private String title;
+ private Combo sourceNameField;
private List libraryUrls;
private List existingNames;
+ private String noNameErrorMsg;
+ private String alreadyExistsErrorMsg;
+
private TreeAndListGroup selectionGroup;
- protected Button sourceBrowseButton;
-
private Text nameField;
- private String customLabel;
-
private String name=""; //$NON-NLS-1$
private URL library= null;
private String className=""; //$NON-NLS-1$
@@ -93,12 +89,10 @@
/**
* Creates a new dialog with the given shell and title.
*/
- public AddCustomDialog(Shell parent, List libraryUrls, List existingNames, String title, String customLabel) {
+ public AddCustomDialog(Shell parent, List libraryUrls, List existingNames) {
super(parent);
- this.title = title;
this.libraryUrls = libraryUrls;
this.existingNames= existingNames;
- this.customLabel= customLabel;
}
/* (non-Javadoc)
@@ -155,14 +149,13 @@
*/
protected void configureShell(Shell newShell) {
super.configureShell(newShell);
- newShell.setText(title);
WorkbenchHelp.setHelp(newShell, IExternalToolsHelpContextIds.ADD_CUSTOM_DIALOG);
}
/**
* Clears the cached structure provider after first finalizing
* it properly.
*/
- protected void clearProviderCache() {
+ private void clearProviderCache() {
if (providerCache != null) {
closeZipFile(providerCache.getZipFile());
providerCache = null;
@@ -171,7 +164,7 @@
/**
* Attempts to close the passed zip file, and answers a boolean indicating success.
*/
- protected boolean closeZipFile(ZipFile file) {
+ private boolean closeZipFile(ZipFile file) {
try {
file.close();
} catch (IOException e) {
@@ -259,13 +252,13 @@
StatusInfo status= new StatusInfo();
String customName= nameField.getText().trim();
if (customName.length() == 0) {
- status.setError(MessageFormat.format(AntPreferencesMessages.getString("AddCustomDialog.name"), new String[]{customLabel})); //$NON-NLS-1$
+ status.setError(noNameErrorMsg);
} else if (!editing){
Iterator names= existingNames.iterator();
while (names.hasNext()) {
String aName = (String) names.next();
if(aName.equals(customName)) {
- status.setError(MessageFormat.format(AntPreferencesMessages.getString("AddCustomDialog.exists"), new String[]{customLabel, customName})); //$NON-NLS-1$
+ status.setError(MessageFormat.format(alreadyExistsErrorMsg, new String[]{customName}));
updateStatus(status);
return;
}
@@ -285,7 +278,7 @@
*
* @param path the path to be added
*/
- protected void setSourceName(String path) {
+ private void setSourceName(String path) {
if (path.length() > 0) {
@@ -314,7 +307,7 @@
/**
* Create the import source selection widget
*/
- protected void createFileSelectionGroup(Composite parent) {
+ private void createFileSelectionGroup(Composite parent) {
//Just create with a dummy root.
FileSystemElement dummyRoot= new FileSystemElement("Dummy", null, true); //$NON-NLS-1$
this.selectionGroup = new TreeAndListGroup(parent, dummyRoot,
@@ -341,14 +334,15 @@
}
/**
- * Answer a boolean indicating whether the specified source currently exists
+ * Returns whether the specified source currently exists
* and is valid (ie.- proper format)
*/
protected boolean ensureSourceIsValid() {
ZipFile specifiedFile = getSpecifiedSourceFile();
- if (specifiedFile == null)
+ if (specifiedFile == null){
return false;
+ }
return closeZipFile(specifiedFile);
}
@@ -357,7 +351,7 @@
* currently-specified .zip file. If this FileSystemElement is not
* currently defined then create and return it.
*/
- protected MinimizedFileSystemElement getFileSystemTree() {
+ private MinimizedFileSystemElement getFileSystemTree() {
IImportStructureProvider provider= null;
MinimizedFileSystemElement element= null;
ZipFile sourceFile = getSpecifiedSourceFile();
@@ -381,7 +375,7 @@
* structure provider. If the user specifies files then this selection is
* cached for later retrieval and is returned.
*/
- protected MinimizedFileSystemElement selectFiles(final Object rootFileSystemObject, final IImportStructureProvider structureProvider) {
+ private MinimizedFileSystemElement selectFiles(final Object rootFileSystemObject, final IImportStructureProvider structureProvider) {
final MinimizedFileSystemElement[] results = new MinimizedFileSystemElement[1];
@@ -399,7 +393,7 @@
* Creates and returns a <code>MinimizedFileSystemElement</code> if the specified
* file system object merits one.
*/
- protected MinimizedFileSystemElement createRootElement(Object fileSystemObject, IImportStructureProvider provider) {
+ private MinimizedFileSystemElement createRootElement(Object fileSystemObject, IImportStructureProvider provider) {
boolean isContainer = provider.isFolder(fileSystemObject);
String elementLabel = provider.getLabel(fileSystemObject);
@@ -422,7 +416,7 @@
* Answer a handle to the zip file currently specified as being the source.
* Return null if this file does not exist or is not of valid format.
*/
- protected ZipFile getSpecifiedSourceFile() {
+ private ZipFile getSpecifiedSourceFile() {
try {
return new ZipFile(sourceNameField.getText());
} catch (ZipException e) {
@@ -441,7 +435,7 @@
/**
* Returns a structure provider for the specified zip file.
*/
- protected ZipFileStructureProvider getStructureProvider(ZipFile targetZip) {
+ private ZipFileStructureProvider getStructureProvider(ZipFile targetZip) {
if (providerCache == null) {
providerCache = new ZipFileStructureProvider(targetZip);
} else if (!providerCache.getZipFile().getName().equals(targetZip.getName())) {
@@ -458,7 +452,7 @@
/**
* Repopulate the view based on the currently entered directory.
*/
- protected void resetSelection() {
+ private void resetSelection() {
MinimizedFileSystemElement currentRoot = getFileSystemTree();
selectionGroup.setRoot(currentRoot);
@@ -509,7 +503,7 @@
* Returns a content provider for <code>MinimizedFileSystemElement</code>s that returns
* only files as children.
*/
- protected ITreeContentProvider getFileProvider() {
+ private ITreeContentProvider getFileProvider() {
return new WorkbenchContentProvider() {
public Object[] getChildren(Object o) {
if (o instanceof MinimizedFileSystemElement) {
@@ -525,7 +519,7 @@
* Returns a content provider for <code>MinimizedFileSystemElement</code>s that returns
* only folders as children.
*/
- protected ITreeContentProvider getFolderProvider() {
+ private ITreeContentProvider getFolderProvider() {
return new WorkbenchContentProvider() {
public Object[] getChildren(Object o) {
if (o instanceof MinimizedFileSystemElement) {
@@ -620,4 +614,12 @@
super.create();
getButton(IDialogConstants.OK_ID).setEnabled(!(library == null));
}
+
+ protected void setAlreadyExistsErrorMsg(String alreadyExistsErrorMsg) {
+ this.alreadyExistsErrorMsg = alreadyExistsErrorMsg;
+ }
+
+ protected void setNoNameErrorMsg(String noNameErrorMsg) {
+ this.noNameErrorMsg = noNameErrorMsg;
+ }
}
diff --git a/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/ui/internal/preferences/AntPreferencesMessages.properties b/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/ui/internal/preferences/AntPreferencesMessages.properties
index eadfe5e..9d47772 100644
--- a/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/ui/internal/preferences/AntPreferencesMessages.properties
+++ b/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/ui/internal/preferences/AntPreferencesMessages.properties
@@ -34,8 +34,6 @@
AddCustomDialog.&Name__3=&Name:
AddCustomDialog.Could_not_close_zip_file_{0}_4=Could not close zip file {0}
AddCustomDialog.&Location=&Location:
-AddCustomDialog.name=A name must be provided for the new {0}
-AddCustomDialog.exists=A {0} with the name {1} already exists
AddCustomDialog.mustSelect=A class file must be selected from the specified location
AntPreferencePage.description = Settings used when running Ant buildfiles:
@@ -56,19 +54,19 @@
AntTasksPage.addTaskDialogTitle = Add Task
AntTasksPage.title = Tas&ks
AntTasksPage.editTaskDialogTitle = Edit Task
-AntTasksPage.task_1=task
AntTasksPage._[system_task]_3=\ [system task]
+AntTasksPage.8=A task with the name {0} already exists
+AntTasksPage.9=A name must be provided for the new task
AntTypesPage.removeButtonTitle = Remo&ve
AntTypesPage.addTypeButtonTitle = Add &Type...
AntTypesPage.editTypeButtonTitle = &Edit Type...
AntTypesPage.typesPageTitle = T&ypes
-
AntTypesPage.addTypeDialogTitle = Add Type
-
AntTypesPage.editTypeDialogTitle = Edit Type
-AntTypesPage.type_1=type
AntTypesPage._[system_type]_3=\ [system type]
+AntTypesPage.8=A type with the name {0} already exists
+AntTypesPage.9=A name must be provided for the new type
AntPropertiesPage.title = P&roperties
AntPropertiesPage.&Global_properties__1=&Global properties:
diff --git a/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/ui/internal/preferences/AntTasksPage.java b/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/ui/internal/preferences/AntTasksPage.java
index 2d59ef1..1dc3357 100644
--- a/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/ui/internal/preferences/AntTasksPage.java
+++ b/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/ui/internal/preferences/AntTasksPage.java
@@ -63,15 +63,7 @@
* Allows the user to enter a custom task.
*/
private void addTask() {
- String title = AntPreferencesMessages.getString("AntTasksPage.addTaskDialogTitle"); //$NON-NLS-1$
-
- Iterator tasks= getContents(true).iterator();
- List names= new ArrayList();
- while (tasks.hasNext()) {
- Task task = (Task) tasks.next();
- names.add(task.getTaskName());
- }
- AddCustomDialog dialog = new AddCustomDialog(getShell(), getPreferencePage().getLibraryURLs(), names, title, AntPreferencesMessages.getString("AntTasksPage.task_1")); //$NON-NLS-1$
+ AddCustomDialog dialog = getCustomDialog();
if (dialog.open() == Dialog.CANCEL) {
return;
}
@@ -83,6 +75,22 @@
addContent(task);
}
+ private AddCustomDialog getCustomDialog() {
+ String title = AntPreferencesMessages.getString("AntTasksPage.addTaskDialogTitle"); //$NON-NLS-1$
+
+ Iterator tasks= getContents(true).iterator();
+ List names= new ArrayList();
+ while (tasks.hasNext()) {
+ Task task = (Task) tasks.next();
+ names.add(task.getTaskName());
+ }
+ AddCustomDialog dialog = new AddCustomDialog(getShell(), getPreferencePage().getLibraryURLs(), names);
+ dialog.setTitle(title);
+ dialog.setAlreadyExistsErrorMsg(AntPreferencesMessages.getString("AntTasksPage.8")); //$NON-NLS-1$
+ dialog.setNoNameErrorMsg(AntPreferencesMessages.getString("AntTasksPage.9")); //$NON-NLS-1$
+ return dialog;
+ }
+
/* (non-Javadoc)
* Method declared on AntPage.
*/
@@ -125,16 +133,8 @@
if (task == null) {
return;
}
- String title = AntPreferencesMessages.getString("AntTasksPage.editTaskDialogTitle"); //$NON-NLS-1$
- Iterator tasks= getContents(true).iterator();
- List names= new ArrayList();
- while (tasks.hasNext()) {
- Task aTask = (Task) tasks.next();
- names.add(aTask.getTaskName());
- }
- AddCustomDialog dialog = new AddCustomDialog(getShell(), getPreferencePage().getLibraryURLs(), names, title, AntPreferencesMessages.getString("AntTasksPage.task_1")); //$NON-NLS-1$
-
+ AddCustomDialog dialog = getCustomDialog();
dialog.setClassName(task.getClassName());
dialog.setName(task.getTaskName());
dialog.setLibrary(task.getLibrary());
diff --git a/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/ui/internal/preferences/AntTypesPage.java b/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/ui/internal/preferences/AntTypesPage.java
index 65db92c..3d381bd 100644
--- a/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/ui/internal/preferences/AntTypesPage.java
+++ b/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/ui/internal/preferences/AntTypesPage.java
@@ -63,15 +63,7 @@
* Allows the user to enter a custom type.
*/
private void addType() {
- String title = AntPreferencesMessages.getString("AntTypesPage.addTypeDialogTitle"); //$NON-NLS-1$
-
- Iterator types= getContents(true).iterator();
- List names= new ArrayList();
- while (types.hasNext()) {
- Type aTask = (Type) types.next();
- names.add(aTask.getTypeName());
- }
- AddCustomDialog dialog = new AddCustomDialog(getShell(), getPreferencePage().getLibraryURLs(), names, title, AntPreferencesMessages.getString("AntTypesPage.type_1")); //$NON-NLS-1$
+ AddCustomDialog dialog = getCustomDialog();
if (dialog.open() == Dialog.CANCEL) {
return;
}
@@ -125,17 +117,7 @@
if (type == null) {
return;
}
- String title = AntPreferencesMessages.getString("AntTypesPage.editTypeDialogTitle"); //$NON-NLS-1$
-
- Iterator types= getContents(true).iterator();
- List names= new ArrayList();
- while (types.hasNext()) {
- Type aTask = (Type) types.next();
- names.add(aTask.getTypeName());
- }
-
- AddCustomDialog dialog = new AddCustomDialog(getShell(), getPreferencePage().getLibraryURLs(), names, title, AntPreferencesMessages.getString("AntTypesPage.type_1")); //$NON-NLS-1$
-
+ AddCustomDialog dialog = getCustomDialog();
dialog.setClassName(type.getClassName());
dialog.setName(type.getTypeName());
dialog.setLibrary(type.getLibrary());
@@ -149,6 +131,23 @@
updateContent(type);
}
+ private AddCustomDialog getCustomDialog() {
+ String title = AntPreferencesMessages.getString("AntTypesPage.editTypeDialogTitle"); //$NON-NLS-1$
+
+ Iterator types= getContents(true).iterator();
+ List names= new ArrayList();
+ while (types.hasNext()) {
+ Type aTask = (Type) types.next();
+ names.add(aTask.getTypeName());
+ }
+
+ AddCustomDialog dialog = new AddCustomDialog(getShell(), getPreferencePage().getLibraryURLs(), names);
+ dialog.setTitle(title);
+ dialog.setAlreadyExistsErrorMsg(AntPreferencesMessages.getString("AntTypesPage.8")); //$NON-NLS-1$
+ dialog.setNoNameErrorMsg(AntPreferencesMessages.getString("AntTypesPage.9")); //$NON-NLS-1$
+ return dialog;
+ }
+
/* (non-Javadoc)
* Method declared on AntPage.
*/