translation-tool: code for removing locale from tool
git-svn-id: https://micropolis.googlecode.com/svn/trunk/micropolis-java@668 d9718cc8-9f43-0410-858b-315f434eb58c
This commit is contained in:
parent
4f728f229f
commit
74bc9593b3
2 changed files with 76 additions and 1 deletions
|
@ -171,6 +171,30 @@ class StringsModel extends AbstractTableModel
|
||||||
fireTableStructureChanged();
|
fireTableStructureChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String [] getAllLocaleCodes()
|
||||||
|
{
|
||||||
|
String [] rv = new String[locales.size()];
|
||||||
|
for (int i = 0; i < rv.length; i++) {
|
||||||
|
rv[i] = locales.get(i).code;
|
||||||
|
}
|
||||||
|
return rv;
|
||||||
|
}
|
||||||
|
|
||||||
|
void removeLocale(String localeCode)
|
||||||
|
{
|
||||||
|
boolean found = false;
|
||||||
|
for (int i = locales.size()-1; i >= 0; i--) {
|
||||||
|
String loc = locales.get(i).code;
|
||||||
|
if (loc == localeCode || (loc != null && loc.equals(localeCode))) {
|
||||||
|
locales.remove(i);
|
||||||
|
found = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (found) {
|
||||||
|
fireTableStructureChanged();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void makeDirectories(File f)
|
void makeDirectories(File f)
|
||||||
throws IOException
|
throws IOException
|
||||||
{
|
{
|
||||||
|
|
|
@ -96,6 +96,19 @@ public class TranslationTool extends JFrame
|
||||||
|
|
||||||
private void onTestClicked()
|
private void onTestClicked()
|
||||||
{
|
{
|
||||||
|
String code = pickLocale(
|
||||||
|
"Which locale do you want to test?",
|
||||||
|
"Test Locale"
|
||||||
|
);
|
||||||
|
if (code == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
String [] localeParts = code.split("_");
|
||||||
|
lastLanguage = localeParts.length >= 1 ? localeParts[0] : "";
|
||||||
|
lastCountry = localeParts.length >= 2 ? localeParts[1] : "";
|
||||||
|
lastVariant = localeParts.length >= 3 ? localeParts[2] : "";
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
String javaPath = "java";
|
String javaPath = "java";
|
||||||
|
@ -195,9 +208,47 @@ public class TranslationTool extends JFrame
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String pickLocale(String message, String dlgTitle)
|
||||||
|
{
|
||||||
|
String[] locales = stringsModel.getAllLocaleCodes();
|
||||||
|
if (locales.length == 1) {
|
||||||
|
return locales[0];
|
||||||
|
}
|
||||||
|
else if (locales.length == 0) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
JComboBox<String> localeCb = new JComboBox<String>();
|
||||||
|
for (int i = 0; i < locales.length; i++) {
|
||||||
|
localeCb.addItem(locales[i] != null ? locales[i] : "C");
|
||||||
|
}
|
||||||
|
localeCb.setSelectedIndex(locales.length-1);
|
||||||
|
|
||||||
|
JComponent [] inputs = new JComponent[] {
|
||||||
|
new JLabel(message),
|
||||||
|
localeCb
|
||||||
|
};
|
||||||
|
int rv = JOptionPane.showOptionDialog(this,
|
||||||
|
inputs,
|
||||||
|
dlgTitle,
|
||||||
|
JOptionPane.OK_CANCEL_OPTION,
|
||||||
|
JOptionPane.PLAIN_MESSAGE,
|
||||||
|
null, null, null);
|
||||||
|
if (rv != JOptionPane.OK_OPTION)
|
||||||
|
return null;
|
||||||
|
|
||||||
|
return (String) localeCb.getSelectedItem();
|
||||||
|
}
|
||||||
|
|
||||||
private void onRemoveLocaleClicked()
|
private void onRemoveLocaleClicked()
|
||||||
{
|
{
|
||||||
//TODO
|
String code = pickLocale(
|
||||||
|
"Which locale do you want to remove?",
|
||||||
|
"Remove Locale"
|
||||||
|
);
|
||||||
|
if (code != null) {
|
||||||
|
stringsModel.removeLocale(code.equals("C") ? null : code);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void onSubmitClicked()
|
private void onSubmitClicked()
|
||||||
|
|
Reference in a new issue