home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
BUG 15
/
BUGCD1998_06.ISO
/
aplic
/
jbuilder
/
jsamples.z
/
LocaleChooserCollationLocaleEditor.java
< prev
next >
Wrap
Text File
|
1997-07-30
|
3KB
|
88 lines
package borland.samples.intl.beans;
import java.beans.*;
import java.util.*;
import java.awt.*;
import java.awt.event.*;
import borland.jbcl.model.*;
public class LocaleChooserCollationLocaleEditor extends java.beans.PropertyEditorSupport {
protected Locale collationLocale = null;
public String[] getTags() {
String [] tags;
if (collationLocale.equals(LocaleChooser.NULL_LOCALE) ||
collationLocale.equals(LocaleChooser.DEFAULT_RUNTIME_LOCALE)) {
tags = new String [] {
"NULL_LOCALE",
"DEFAULT_RUNTIME_LOCALE",
};
} else {
tags = new String [] {
"NULL_LOCALE",
"DEFAULT_RUNTIME_LOCALE",
getJavaInitializationString(),
};
}
return tags;
}
public String getJavaInitializationString() {
String localeInitString;
if (collationLocale.equals(LocaleChooser.NULL_LOCALE)) {
localeInitString = "LocaleChooser.NULL_LOCALE";
} else if (collationLocale.equals(LocaleChooser.DEFAULT_RUNTIME_LOCALE)) {
localeInitString = "LocaleChooser.DEFAULT_RUNTIME_LOCALE";
} else {
localeInitString = "new java.util.Locale(\"" + collationLocale.getLanguage() + "\", \"";
if (collationLocale.getCountry().length() == 0) {
localeInitString += "\")";
} else {
localeInitString += collationLocale.getCountry() + "\"";
if (collationLocale.getVariant().length() == 0) {
localeInitString += ")";
} else {
localeInitString += ",\"" + collationLocale.getVariant() + "\")";
}
}
}
return localeInitString;
}
public void setAsText(String text) {
throw new IllegalArgumentException(text);
}
public String getAsText() {
String localeInitString;
if (collationLocale.equals(LocaleChooser.NULL_LOCALE)) {
localeInitString = "NULL_LOCALE";
} else if (collationLocale.equals(LocaleChooser.DEFAULT_RUNTIME_LOCALE)) {
localeInitString = "DEFAULT_RUNTIME_LOCALE";
} else {
localeInitString = "new java.util.Locale(\"" + collationLocale.getLanguage() + "\", \"";
if (collationLocale.getCountry().length() == 0) {
localeInitString += "\")";
} else {
localeInitString += collationLocale.getCountry() + "\"";
if (collationLocale.getVariant().length() == 0) {
localeInitString += ")";
} else {
localeInitString += ",\"" + collationLocale.getVariant() + "\")";
}
}
}
return localeInitString;
}
public void setValue(Object o) {
collationLocale = (Locale) o;
}
public Object getValue() {
return collationLocale;
}
}