This is an automated email from the ASF dual-hosted git repository. desruisseaux pushed a commit to branch visual-test in repository https://gitbox.apache.org/repos/asf/sis.git
commit e230c88533659a15e86b073686fb90d9cdf6a4a4 Author: Martin Desruisseaux <[email protected]> AuthorDate: Wed May 10 22:49:43 2023 +0200 Update for an API change in `org.apache.sis.resources.IndexResourceBundle`. --- .../org/apache/sis/swing/internal/Resources.java | 35 +++++++++++++++------- .../apache/sis/swing/internal/Resources_en.java | 30 +++++++++++++++++++ .../apache/sis/swing/internal/Resources_fr.java | 30 +++++++++++++++++++ 3 files changed, 84 insertions(+), 11 deletions(-) diff --git a/src/main/java/org/apache/sis/swing/internal/Resources.java b/src/main/java/org/apache/sis/swing/internal/Resources.java index ef1678b91b..a85dc0cfa1 100644 --- a/src/main/java/org/apache/sis/swing/internal/Resources.java +++ b/src/main/java/org/apache/sis/swing/internal/Resources.java @@ -16,7 +16,7 @@ */ package org.apache.sis.swing.internal; -import java.net.URL; +import java.io.InputStream; import java.util.Locale; import java.util.MissingResourceException; import org.apache.sis.util.resources.KeyConstants; @@ -27,10 +27,10 @@ import org.apache.sis.util.resources.IndexedResourceBundle; * Resources for the Swing widgets. * * @author Martin Desruisseaux (IRD, Geomatys) - * @version 1.1 + * @version 1.4 * @since 1.1 */ -public final class Resources extends IndexedResourceBundle { +public class Resources extends IndexedResourceBundle { /** * Resource keys. This class is used when compiling sources, but no dependencies to * {@code Keys} should appear in any resulting class files. Since the Java compiler @@ -151,13 +151,21 @@ public final class Resources extends IndexedResourceBundle { } /** - * Constructs a new resource bundle loading data from the given UTF file. - * - * @param resources the path of the binary file containing resources, or {@code null} if - * there are no resources. The resources may be a file or an entry in a JAR file. + * Constructs a new resource bundle loading data from + * the resource file of the same name than this class. */ - public Resources(final URL resources) { - super(resources); + public Resources() { + } + + /** + * Opens the binary file containing the localized resources to load. + * This method delegates to {@link Class#getResourceAsStream(String)}, + * but this delegation must be done from the same module than the one + * that provides the binary file. + */ + @Override + protected InputStream getResourceAsStream(final String name) { + return getClass().getResourceAsStream(name); } /** @@ -177,7 +185,12 @@ public final class Resources extends IndexedResourceBundle { * @return resources in the given locale. * @throws MissingResourceException if resources cannot be found. */ - public static Resources forLocale(final Locale locale) throws MissingResourceException { - return getBundle(Resources.class, locale); + public static Resources forLocale(final Locale locale) { + /* + * We cannot factorize this method into the parent class, because we need to call + * `ResourceBundle.getBundle(String)` from the module that provides the resources. + * We do not cache the result because `ResourceBundle` already provides a cache. + */ + return (Resources) getBundle(Resources.class.getName(), nonNull(locale)); } } diff --git a/src/main/java/org/apache/sis/swing/internal/Resources_en.java b/src/main/java/org/apache/sis/swing/internal/Resources_en.java new file mode 100644 index 0000000000..334dd60fc6 --- /dev/null +++ b/src/main/java/org/apache/sis/swing/internal/Resources_en.java @@ -0,0 +1,30 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.sis.swing.internal; + + +/** + * Resource in English language. + */ +public class Resources_en extends Resources { + /** + * Constructs a new resource bundle loading data from + * the resource file of the same name than this class. + */ + public Resources_en() { + } +} diff --git a/src/main/java/org/apache/sis/swing/internal/Resources_fr.java b/src/main/java/org/apache/sis/swing/internal/Resources_fr.java new file mode 100644 index 0000000000..7466f197b6 --- /dev/null +++ b/src/main/java/org/apache/sis/swing/internal/Resources_fr.java @@ -0,0 +1,30 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.sis.swing.internal; + + +/** + * Messages in French language. + */ +public class Resources_fr extends Resources { + /** + * Constructs a new resource bundle loading data from + * the resource file of the same name than this class. + */ + public Resources_fr() { + } +}
