Bug 215232

Summary: [refactoring] create a utility method to fetch locales
Product: [Eclipse Project] PDE Reporter: Chris Aniszczyk <caniszczyk>
Component: UIAssignee: Benjamin Cabé <contact>
Status: RESOLVED FIXED QA Contact:
Severity: enhancement    
Priority: P3 CC: contact
Version: 3.4Keywords: contributed
Target Milestone: 3.4 M6   
Hardware: PC   
OS: Windows XP   
Whiteboard:
Attachments:
Description Flags
Patch none

Description Chris Aniszczyk CLA 2008-01-14 11:16:32 EST
In a few places within PDE (like EnvironmentSection and the target platform preference page), we have to fetch the available locales. We have boilerplate code like this:

private static String[] getLocales() {
		Locale[] locales = Locale.getAvailableLocales();
		String[] result = new String[locales.length];
		for (int i = 0; i < locales.length; i++) {
			Locale locale = locales[i];
			StringBuffer buffer = new StringBuffer();
			buffer.append(locale.toString());
			buffer.append(" - "); //$NON-NLS-1$
			buffer.append(locale.getDisplayName());
			result[i] = buffer.toString();
		}
		return result;
	}

We should create a utility method somewhere for this.
Comment 1 Benjamin Cabé CLA 2008-03-10 17:45:54 EDT
Created attachment 92093 [details]
Patch

I need my daily patch, Chris :p
Comment 2 Chris Aniszczyk CLA 2008-03-10 20:21:05 EDT
Thanks!!
Comment 3 Chris Aniszczyk CLA 2008-03-10 20:35:59 EDT
Thanks for the patch Ben, nice and elegant ;)

It's good to have the code in PDE be cleaned up here and there.