Bug 215232 - [refactoring] create a utility method to fetch locales
Summary: [refactoring] create a utility method to fetch locales
Status: RESOLVED FIXED
Alias: None
Product: PDE
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 3.4   Edit
Hardware: PC Windows XP
: P3 enhancement (vote)
Target Milestone: 3.4 M6   Edit
Assignee: Benjamin Cabé CLA
QA Contact:
URL:
Whiteboard:
Keywords: contributed
Depends on:
Blocks:
 
Reported: 2008-01-14 11:16 EST by Chris Aniszczyk CLA
Modified: 2008-03-10 20:35 EDT (History)
1 user (show)

See Also:


Attachments
Patch (9.30 KB, patch)
2008-03-10 17:45 EDT, Benjamin Cabé CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
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.