home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World 1998 October
/
PCWorld_1998-10_cd.bin
/
software
/
prehled
/
inprise
/
JSAMPLES.Z
/
LocaleChooserCollationLocaleEditor.java
< prev
next >
Wrap
Text File
|
1998-05-08
|
4KB
|
107 lines
/*
* Copyright (c) 1997-1998 Borland International, Inc. All Rights Reserved.
*
* This SOURCE CODE FILE, which has been provided by Borland as part
* of a Borland product for use ONLY by licensed users of the product,
* includes CONFIDENTIAL and PROPRIETARY information of Borland.
*
* USE OF THIS SOFTWARE IS GOVERNED BY THE TERMS AND CONDITIONS
* OF THE LICENSE STATEMENT AND LIMITED WARRANTY FURNISHED WITH
* THE PRODUCT.
*
* IN PARTICULAR, YOU WILL INDEMNIFY AND HOLD BORLAND, ITS RELATED
* COMPANIES AND ITS SUPPLIERS, HARMLESS FROM AND AGAINST ANY CLAIMS
* OR LIABILITIES ARISING OUT OF THE USE, REPRODUCTION, OR DISTRIBUTION
* OF YOUR PROGRAMS, INCLUDING ANY CLAIMS OR LIABILITIES ARISING OUT OF
* OR RESULTING FROM THE USE, MODIFICATION, OR DISTRIBUTION OF PROGRAMS
* OR FILES CREATED FROM, BASED ON, AND/OR DERIVED FROM THIS SOURCE
* CODE FILE.
*/
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;
}
}