diff --git a/.travis.yml b/.travis.yml index 6657b5bbe..c8305393f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,17 +1,22 @@ +dist: xenial language: java jdk: - - oraclejdk8 + - openjdk8 - openjdk11 + - openjdk-ea + +matrix: + allow_failures: + - jdk: openjdk-ea env: global: - - DEPLOY_JDK=oraclejdk8 + - DEPLOY_JDK=openjdk8 - DEPLOY_REPO=jdemetra/jdemetra-app - - DEPLOY_BIN=nbdemetra-app/target/jdemetra-*-bin.zip + - DEPLOY_BIN=nbdemetra-app/target/binaries/* -before_install: - - "export DISPLAY=:99.0" - - "sh -e /etc/init.d/xvfb start" +services: + - xvfb deploy: # Maven snapshots from develop branch diff --git a/README.md b/README.md index 13b673e66..b7db7368b 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,8 @@ # Econometric software for seasonal adjustment and other time series methods (JDemetra+) [![Download](https://img.shields.io/github/release/jdemetra/jdemetra-app.svg)](https://github.com/jdemetra/jdemetra-app/releases/latest) +![GitHub All Releases](https://img.shields.io/github/downloads/jdemetra/jdemetra-app/total) +![GitHub Releases](https://img.shields.io/github/downloads/jdemetra/jdemetra-app/latest/total) **JDemetra+ is a new tool for seasonal adjustment (SA)** developed by the National Bank of Belgium (NBB) in cooperation with the Deutsche Bundesbank and Eurostat in accordance with the Guidelines of the European Statistical System (ESS). diff --git a/nbdemetra-anomalydetection/pom.xml b/nbdemetra-anomalydetection/pom.xml index 17f96374d..7b0dac1a3 100644 --- a/nbdemetra-anomalydetection/pom.xml +++ b/nbdemetra-anomalydetection/pom.xml @@ -4,7 +4,7 @@ nbdemetra-parent eu.europa.ec.joinup.sat - 2.2.2 + 2.2.3 nbdemetra-anomalydetection @@ -13,6 +13,13 @@ NbDemetra - Anomaly Detection + + + org.checkerframework + checker-qual + provided + + org.netbeans.api @@ -94,6 +101,10 @@ org.netbeans.api org-openide-filesystems-nb + + org.netbeans.api + org-openide-util-ui + @@ -113,7 +124,7 @@ - org.codehaus.mojo + org.apache.netbeans.utilities nbm-maven-plugin true diff --git a/nbdemetra-anomalydetection/src/main/java/ec/nbdemetra/anomalydetection/ui/AnomalyDetectionChart.java b/nbdemetra-anomalydetection/src/main/java/ec/nbdemetra/anomalydetection/ui/AnomalyDetectionChart.java index eb37d7ca8..8eab070b5 100644 --- a/nbdemetra-anomalydetection/src/main/java/ec/nbdemetra/anomalydetection/ui/AnomalyDetectionChart.java +++ b/nbdemetra-anomalydetection/src/main/java/ec/nbdemetra/anomalydetection/ui/AnomalyDetectionChart.java @@ -45,8 +45,8 @@ import java.beans.PropertyChangeListener; import java.text.NumberFormat; import java.util.Arrays; -import javax.annotation.Nonnull; -import javax.annotation.Nullable; +import org.checkerframework.checker.nullness.qual.NonNull; +import org.checkerframework.checker.nullness.qual.Nullable; import javax.swing.JComponent; import javax.swing.JMenu; @@ -171,7 +171,7 @@ public static final class Model { private final Ts ts; private final OutlierEstimation[] outliers; - Model(@Nonnull Ts ts, @Nonnull PreprocessingModel model) { + Model(@NonNull Ts ts, @NonNull PreprocessingModel model) { this.ts = ts; TsData data = ts.getTsData(); this.outliers = new OutlierEstimation[data.getLength()]; @@ -181,12 +181,12 @@ public static final class Model { } } - @Nonnull + @NonNull public Ts getTs() { return ts; } - @Nonnull + @NonNull public OutlierEstimation[] getOutliers() { return outliers; } diff --git a/nbdemetra-anomalydetection/src/main/java/ec/nbdemetra/anomalydetection/ui/JTsAnomalyGrid.java b/nbdemetra-anomalydetection/src/main/java/ec/nbdemetra/anomalydetection/ui/JTsAnomalyGrid.java index a72122abe..5c3783774 100644 --- a/nbdemetra-anomalydetection/src/main/java/ec/nbdemetra/anomalydetection/ui/JTsAnomalyGrid.java +++ b/nbdemetra-anomalydetection/src/main/java/ec/nbdemetra/anomalydetection/ui/JTsAnomalyGrid.java @@ -38,8 +38,8 @@ import java.text.DecimalFormat; import java.util.ArrayList; import java.util.List; -import javax.annotation.Nonnull; -import javax.annotation.Nullable; +import org.checkerframework.checker.nullness.qual.NonNull; +import org.checkerframework.checker.nullness.qual.Nullable; import javax.swing.JComponent; import javax.swing.JLabel; import javax.swing.JTable; @@ -253,7 +253,7 @@ public TsCollection getTsCollection() { return grid.getTsCollection(); } - @Nonnull + @NonNull public ObsIndex getHoveredObs() { return grid.getHoveredObs(); } diff --git a/nbdemetra-app/pom.xml b/nbdemetra-app/pom.xml index ffb644615..c4be3ed23 100644 --- a/nbdemetra-app/pom.xml +++ b/nbdemetra-app/pom.xml @@ -5,7 +5,7 @@ eu.europa.ec.joinup.sat nbdemetra-parent - 2.2.2 + 2.2.3 nbdemetra-app @@ -17,6 +17,8 @@ UTF-8 ${netbeans.run.params.ide} + ${project.build.directory}/binaries + jdemetra-${project.version}-bin @@ -34,6 +36,10 @@ org.netbeans.modules org-netbeans-modules-junitlib + + org.netbeans.api + org-netbeans-modules-javahelp + @@ -42,13 +48,19 @@ org.netbeans.modules org-netbeans-modules-dbapi ${netbeans.version} + + + org.netbeans.api + org-netbeans-modules-javahelp + + org.netbeans.modules org-netbeans-modules-projectapi-nb ${netbeans.version} - + ${project.groupId} @@ -94,39 +106,66 @@ + - org.codehaus.mojo + org.apache.netbeans.utilities nbm-maven-plugin - jdemetra-${project.version}-bin + ${project.x.zipname} jdemetra-${project.version}-setup src/main/resources/nbdemetra.conf + + + + org.apache.maven.plugins + maven-antrun-plugin + 3.0.0 + + + verify + + + + + + + run + + + + + + + + net.nicoulaj.maven.plugins + checksum-maven-plugin + 1.8 + + + + files + + + + + + SHA-256 + + + + ${project.x.binaries} + + *.sha256 + + + + false + + - - - - deployment - - - - org.codehaus.mojo - nbm-maven-plugin - - - extra - - autoupdate - - - - - - - - - diff --git a/nbdemetra-app/src/main/resources/nbdemetra.conf b/nbdemetra-app/src/main/resources/nbdemetra.conf index 1679c4588..9862677c4 100644 --- a/nbdemetra-app/src/main/resources/nbdemetra.conf +++ b/nbdemetra-app/src/main/resources/nbdemetra.conf @@ -1,10 +1,10 @@ # ${HOME} will be replaced by user home directory according to platform -default_userdir="${HOME}/.${APPNAME}/dev" -default_mac_userdir="${HOME}/Library/Application Support/${APPNAME}/dev" +default_userdir="${DEFAULT_USERDIR_ROOT}/../.${APPNAME}/dev" +default_mac_userdir="${DEFAULT_USERDIR_ROOT}/dev" # options used by the launcher by default, can be overridden by explicit # command line switches -default_options="--branding nbdemetra -J-Xms128m -J-Xmx512m -J-Dapple.laf.useScreenMenuBar=true -J-Dapple.awt.graphics.UseQuartz=true -J-Dsun.java2d.noddraw=true -J-Dsun.java2d.dpiaware=true" +default_options="--branding nbdemetra -J-Djdk.gtk.version=2.2 -J-Dapple.laf.useScreenMenuBar=true -J-Dapple.awt.graphics.UseQuartz=true -J-Dsun.java2d.noddraw=true -J-Dsun.java2d.dpiaware=true -J-XX:+IgnoreUnrecognizedVMOptions -J-Djna.nosys=false -J-Djna.nounpack=true" # for development purposes you may wish to append: -J-Dnetbeans.logger.console=true -J-ea # default location of JDK/JRE, can be overridden by using --jdkhome switch diff --git a/nbdemetra-branding/pom.xml b/nbdemetra-branding/pom.xml index c331794b8..16f53c7de 100644 --- a/nbdemetra-branding/pom.xml +++ b/nbdemetra-branding/pom.xml @@ -5,7 +5,7 @@ eu.europa.ec.joinup.sat nbdemetra-parent - 2.2.2 + 2.2.3 nbdemetra-branding @@ -23,7 +23,7 @@ - org.codehaus.mojo + org.apache.netbeans.utilities nbm-maven-plugin diff --git a/nbdemetra-common/pom.xml b/nbdemetra-common/pom.xml index b2e05bd12..925697058 100644 --- a/nbdemetra-common/pom.xml +++ b/nbdemetra-common/pom.xml @@ -4,7 +4,7 @@ eu.europa.ec.joinup.sat nbdemetra-parent - 2.2.2 + 2.2.3 nbdemetra-common @@ -83,7 +83,7 @@ - org.codehaus.mojo + org.apache.netbeans.utilities nbm-maven-plugin true diff --git a/nbdemetra-core/pom.xml b/nbdemetra-core/pom.xml index c0a9602b3..68298e83b 100644 --- a/nbdemetra-core/pom.xml +++ b/nbdemetra-core/pom.xml @@ -4,7 +4,7 @@ eu.europa.ec.joinup.sat nbdemetra-parent - 2.2.2 + 2.2.3 nbdemetra-core @@ -32,6 +32,12 @@ lombok provided + + org.checkerframework + checker-qual + provided + + org.netbeans.api @@ -68,10 +74,10 @@ guava - com.google.code.findbugs - jsr305 + com.github.stephenc.jcip + jcip-annotations compile - + org.slf4j slf4j-api @@ -86,16 +92,21 @@ jcl-over-slf4j - org.xerial.snappy - snappy-java - 1.1.2 + javax.xml.bind + jaxb-api + 2.4.0-b180830.0359 + + + org.glassfish.jaxb + jaxb-runtime + 2.4.0-b180830.0438 - org.codehaus.mojo + org.apache.netbeans.utilities nbm-maven-plugin true @@ -111,12 +122,14 @@ org.slf4j.* com.google.common.* org.apache.commons.logging.* - javax.annotation.* ec.demetra.workspace ec.demetra.workspace.file ec.demetra.workspace.file.spi ec.demetra.workspace.file.util - ioutil + javax.annotation.* + javax.xml.bind.* + net.jcip.annotations + nbbrd.io.* diff --git a/nbdemetra-core/src/main/java/ec/nbdemetra/core/GlobalServiceProcessor.java b/nbdemetra-core/src/main/java/ec/nbdemetra/core/GlobalServiceProcessor.java index bb363098a..fe4e48807 100644 --- a/nbdemetra-core/src/main/java/ec/nbdemetra/core/GlobalServiceProcessor.java +++ b/nbdemetra-core/src/main/java/ec/nbdemetra/core/GlobalServiceProcessor.java @@ -64,7 +64,7 @@ public boolean process(Set annotations, RoundEnvironment m.printMessage(kind, "Default method requires no parameters", e); continue; } - if (!t.getReturnType().toString().equals(e.asType().toString())) { + if (!t.getReturnType().toString().contains(e.asType().toString())) { m.printMessage(kind, "Default method must return the annotated type", e); continue; } diff --git a/nbdemetra-core/src/main/java/ec/nbdemetra/core/Installer.java b/nbdemetra-core/src/main/java/ec/nbdemetra/core/Installer.java index 84811e8fa..2312164e3 100644 --- a/nbdemetra-core/src/main/java/ec/nbdemetra/core/Installer.java +++ b/nbdemetra-core/src/main/java/ec/nbdemetra/core/Installer.java @@ -28,7 +28,6 @@ import ec.tss.sa.SaManager; import ec.tss.tsproviders.IFileLoader; import ec.tss.tsproviders.TsProviders; -import ec.tss.tsproviders.utils.ByteArrayConverter; import ec.tss.tsproviders.utils.Formatters; import ec.tss.tsproviders.utils.IFormatter; import ec.tss.tsproviders.utils.IParser; @@ -57,7 +56,6 @@ public final class Installer extends ModuleInstall { final InstallerStep step = InstallerStep.all( new PackageInfoFixStep(), new AppVersionStep(), - new ByteArrayConverterStep(), new ProvidersStep(), new SaFactoriesStep(), new SaDiagnosticsStep(), @@ -100,19 +98,6 @@ public void restore() { } } - private static final class ByteArrayConverterStep extends InstallerStep { - - @Override - public void restore() { - try { - ByteArrayConverter.setInstance(new SnappyConverter()); - LOGGER.info("Using Snappy byte array converter"); - } catch (Exception ex) { - LOGGER.warn("While loading Snappy byte array converter", ex); - } - } - } - private static final class ProvidersStep extends InstallerStep.LookupStep { final Preferences prefs = prefs(); diff --git a/nbdemetra-core/src/main/java/ec/nbdemetra/core/PackageInfoFix.java b/nbdemetra-core/src/main/java/ec/nbdemetra/core/PackageInfoFix.java index c31327885..0fdd1de07 100644 --- a/nbdemetra-core/src/main/java/ec/nbdemetra/core/PackageInfoFix.java +++ b/nbdemetra-core/src/main/java/ec/nbdemetra/core/PackageInfoFix.java @@ -16,21 +16,15 @@ */ package ec.nbdemetra.core; -import ioutil.IO; import java.io.IOException; import java.io.UncheckedIOException; -import java.net.URI; import java.net.URISyntaxException; import java.net.URL; -import java.nio.file.FileSystem; -import java.nio.file.FileSystemNotFoundException; -import java.nio.file.FileSystems; import java.nio.file.Files; import java.nio.file.Path; -import java.nio.file.Paths; -import java.util.Collections; import java.util.Enumeration; import java.util.logging.Level; +import nbbrd.io.Resource; /** * A bug prevents NetBeans module to auto-load package-info classes under @@ -47,7 +41,7 @@ public void doLoadPackageInfos(ClassLoader classLoader) { Enumeration urls = classLoader.getResources("META-INF/MANIFEST.MF"); while (urls.hasMoreElements()) { URL url = urls.nextElement(); - processRessource(url.toURI(), o -> loadPackageInfos(classLoader, getRootOfManifest(o))); + Resource.process(url.toURI(), o -> loadPackageInfos(classLoader, getRootOfManifest(o))); } } catch (IOException | URISyntaxException | UncheckedIOException ex) { log.log(Level.WARNING, "While loading package infos", ex); @@ -85,15 +79,4 @@ private void loadClass(ClassLoader classLoader, String className) { log.log(Level.WARNING, "Cannot load class '" + className + "'", ex); } } - - // see https://stackoverflow.com/a/36021165 - private void processRessource(URI uri, IO.Consumer action) throws IOException { - try { - action.acceptWithIO(Paths.get(uri)); - } catch (FileSystemNotFoundException ex) { - try (FileSystem fs = FileSystems.newFileSystem(uri, Collections.emptyMap())) { - action.acceptWithIO(fs.provider().getPath(uri)); - } - } - } } diff --git a/nbdemetra-core/src/main/java/ec/nbdemetra/core/SnappyConverter.java b/nbdemetra-core/src/main/java/ec/nbdemetra/core/SnappyConverter.java deleted file mode 100644 index f1632d656..000000000 --- a/nbdemetra-core/src/main/java/ec/nbdemetra/core/SnappyConverter.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright 2013 National Bank of Belgium - * - * Licensed under the EUPL, Version 1.1 or - as soon they will be approved - * by the European Commission - subsequent versions of the EUPL (the "Licence"); - * You may not use this work except in compliance with the Licence. - * You may obtain a copy of the Licence at: - * - * http://ec.europa.eu/idabc/eupl - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the Licence is distributed on an "AS IS" basis, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the Licence for the specific language governing permissions and - * limitations under the Licence. - */ -package ec.nbdemetra.core; - -import ec.tss.tsproviders.utils.ByteArrayConverter; -import java.io.IOException; -import org.xerial.snappy.Snappy; - -/** - * - * @author Philippe Charles - */ -final class SnappyConverter extends ByteArrayConverter { - - @Override - public byte[] fromDoubleArray(double[] input) { - try { - return Snappy.compress(input); - } catch (IOException ex) { - throw new RuntimeException(ex); - } - } - - @Override - public double[] toDoubleArray(byte[] input) { - try { - return Snappy.uncompressDoubleArray(input); - } catch (IOException ex) { - throw new RuntimeException(ex); - } - } -} diff --git a/nbdemetra-core/src/test/java/ec/nbdemetra/core/SnappyConverterTest.java b/nbdemetra-core/src/test/java/ec/nbdemetra/core/SnappyConverterTest.java deleted file mode 100644 index 8fca5b7da..000000000 --- a/nbdemetra-core/src/test/java/ec/nbdemetra/core/SnappyConverterTest.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright 2013 National Bank of Belgium - * - * Licensed under the EUPL, Version 1.1 or - as soon they will be approved - * by the European Commission - subsequent versions of the EUPL (the "Licence"); - * You may not use this work except in compliance with the Licence. - * You may obtain a copy of the Licence at: - * - * http://ec.europa.eu/idabc/eupl - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the Licence is distributed on an "AS IS" basis, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the Licence for the specific language governing permissions and - * limitations under the Licence. - */ -package ec.nbdemetra.core; - -import ec.tss.tsproviders.utils.ByteArrayConverter; -import org.junit.Assert; -import org.junit.Test; - -/** - * - * @author Philippe Charles - */ -public class SnappyConverterTest { - - @Test - public void testSnappy() { - ByteArrayConverter converter = new SnappyConverter(); - - double[] input0 = {}; - Assert.assertArrayEquals(input0, converter.toDoubleArray(converter.fromDoubleArray(input0)), 0); - Assert.assertNotSame(input0, converter.toDoubleArray(converter.fromDoubleArray(input0))); - - double[] input1 = {0.0, 1.1, 2.2, 3.3}; - Assert.assertArrayEquals(input1, converter.toDoubleArray(converter.fromDoubleArray(input1)), 0); - Assert.assertNotSame(input1, converter.toDoubleArray(converter.fromDoubleArray(input1))); - - double[] input2 = {Double.NaN, Double.MAX_VALUE, Double.MIN_VALUE, Double.MIN_NORMAL, - Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY}; - Assert.assertArrayEquals(input2, converter.toDoubleArray(converter.fromDoubleArray(input2)), 0); - Assert.assertNotSame(input2, converter.toDoubleArray(converter.fromDoubleArray(input2))); - } -} diff --git a/nbdemetra-jdbc/pom.xml b/nbdemetra-jdbc/pom.xml index d46c5f9fa..a12453c7b 100644 --- a/nbdemetra-jdbc/pom.xml +++ b/nbdemetra-jdbc/pom.xml @@ -4,7 +4,7 @@ eu.europa.ec.joinup.sat nbdemetra-parent - 2.2.2 + 2.2.3 nbdemetra-jdbc @@ -14,6 +14,18 @@ This module provides JDBC IO to Demetra. + + + org.projectlombok + lombok + provided + + + org.checkerframework + checker-qual + provided + + org.netbeans.api @@ -87,7 +99,7 @@ - org.codehaus.mojo + org.apache.netbeans.utilities nbm-maven-plugin true @@ -96,6 +108,7 @@ ec.util.* ec.nbdemetra.db.* ec.nbdemetra.jdbc.* + nbbrd.sql.jdbc diff --git a/nbdemetra-jdbc/src/main/java/ec/nbdemetra/db/DbProviderBuddy.java b/nbdemetra-jdbc/src/main/java/ec/nbdemetra/db/DbProviderBuddy.java index 5142e1a4c..2372923b4 100644 --- a/nbdemetra-jdbc/src/main/java/ec/nbdemetra/db/DbProviderBuddy.java +++ b/nbdemetra-jdbc/src/main/java/ec/nbdemetra/db/DbProviderBuddy.java @@ -36,7 +36,7 @@ import java.util.ArrayList; import java.util.List; import java.util.stream.Collectors; -import javax.annotation.Nonnull; +import org.checkerframework.checker.nullness.qual.NonNull; import javax.swing.DefaultListCellRenderer; import javax.swing.JList; import javax.swing.ListCellRenderer; @@ -96,8 +96,8 @@ private List createSheetSets(DbBean bean) { @NbBundle.Messages({ "bean.dbName.display=Data source name", "bean.dbName.description=Data structure describing the connection to the database."}) - @Nonnull - protected NodePropertySetBuilder withDbName(@Nonnull NodePropertySetBuilder b, @Nonnull BEAN bean) { + @NonNull + protected NodePropertySetBuilder withDbName(@NonNull NodePropertySetBuilder b, @NonNull BEAN bean) { return b.withAutoCompletion() .select(bean, "dbName") .source(getDbSource(bean)) @@ -110,8 +110,8 @@ protected NodePropertySetBuilder withDbName(@Nonnull NodePropertySetBuilder b, @ @NbBundle.Messages({ "bean.file.display=Database file", "bean.file.description=The path to the database file."}) - @Nonnull - protected NodePropertySetBuilder withFileName(@Nonnull NodePropertySetBuilder b, @Nonnull BEAN bean) { + @NonNull + protected NodePropertySetBuilder withFileName(@NonNull NodePropertySetBuilder b, @NonNull BEAN bean) { Optional loader = TsProviders.lookup(IFileLoader.class, getProviderName()); if (loader.isPresent()) { return b.withFile() @@ -137,8 +137,8 @@ protected NodePropertySetBuilder withFileName(@Nonnull NodePropertySetBuilder b, "bean.valueColumn.description=A column name that defines the value of an observation.", "bean.versionColumn.display=Version column", "bean.versionColumn.description=An optional column name that defines the version of an observation.",}) - @Nonnull - protected NodePropertySetBuilder withSource(@Nonnull NodePropertySetBuilder b, @Nonnull BEAN bean) { + @NonNull + protected NodePropertySetBuilder withSource(@NonNull NodePropertySetBuilder b, @NonNull BEAN bean) { AutoCompletionSource columns = getColumnSource(bean); ListCellRenderer columnCellRenderer = getColumnRenderer(bean); @@ -194,8 +194,8 @@ protected NodePropertySetBuilder withSource(@Nonnull NodePropertySetBuilder b, @ "bean.frequency.description=The frequency of the observations in the table. An undefined frequency allows the provider to guess it.", "bean.aggregationType.display=Aggregation type", "bean.aggregationType.description=The aggregation method to use when a frequency is defined."}) - @Nonnull - protected NodePropertySetBuilder withOptions(@Nonnull NodePropertySetBuilder b, @Nonnull BEAN bean) { + @NonNull + protected NodePropertySetBuilder withOptions(@NonNull NodePropertySetBuilder b, @NonNull BEAN bean) { b.with(DataFormat.class) .select(bean, "dataFormat") .display(Bundle.bean_dataFormat_display()) @@ -219,8 +219,8 @@ protected NodePropertySetBuilder withOptions(@Nonnull NodePropertySetBuilder b, "bean.cacheDepth.description=The data retrieval depth. It is always more performant to get one big chunk of data instead of several smaller parts. The downside of it is the increase of memory usage. Setting this value to zero disables the cache.", "bean.cacheTtl.display=Time to live", "bean.cacheTtl.description=The lifetime of the data stored in the cache. Setting this value to zero disables the cache."}) - @Nonnull - protected NodePropertySetBuilder withCache(@Nonnull NodePropertySetBuilder b, @Nonnull BEAN bean) { + @NonNull + protected NodePropertySetBuilder withCache(@NonNull NodePropertySetBuilder b, @NonNull BEAN bean) { b.withInt() .select(bean, "cacheDepth") .display(Bundle.bean_cacheDepth_display()) @@ -248,8 +248,8 @@ protected NodePropertySetBuilder withCache(@Nonnull NodePropertySetBuilder b, @N * @see DbBean * @see JAutoCompletion#setSource(ec.util.completion.AutoCompletionSource) */ - @Nonnull - protected AutoCompletionSource getDbSource(@Nonnull BEAN bean) { + @NonNull + protected AutoCompletionSource getDbSource(@NonNull BEAN bean) { return AutoCompletionSources.empty(); } @@ -265,8 +265,8 @@ protected AutoCompletionSource getDbSource(@Nonnull BEAN bean) { * @see DbBean * @see JAutoCompletion#setSource(ec.util.completion.AutoCompletionSource) */ - @Nonnull - protected AutoCompletionSource getTableSource(@Nonnull BEAN bean) { + @NonNull + protected AutoCompletionSource getTableSource(@NonNull BEAN bean) { return AutoCompletionSources.empty(); } @@ -282,8 +282,8 @@ protected AutoCompletionSource getTableSource(@Nonnull BEAN bean) { * @see DbBean * @see JAutoCompletion#setSource(ec.util.completion.AutoCompletionSource) */ - @Nonnull - protected AutoCompletionSource getColumnSource(@Nonnull BEAN bean) { + @NonNull + protected AutoCompletionSource getColumnSource(@NonNull BEAN bean) { return AutoCompletionSources.empty(); } @@ -299,8 +299,8 @@ protected AutoCompletionSource getColumnSource(@Nonnull BEAN bean) { * @see DbBean * @see JList#setCellRenderer(javax.swing.ListCellRenderer) */ - @Nonnull - protected ListCellRenderer getDbRenderer(@Nonnull BEAN bean) { + @NonNull + protected ListCellRenderer getDbRenderer(@NonNull BEAN bean) { return new DefaultListCellRenderer(); } @@ -316,8 +316,8 @@ protected ListCellRenderer getDbRenderer(@Nonnull BEAN bean) { * @see DbBean * @see JList#setCellRenderer(javax.swing.ListCellRenderer) */ - @Nonnull - protected ListCellRenderer getTableRenderer(@Nonnull BEAN bean) { + @NonNull + protected ListCellRenderer getTableRenderer(@NonNull BEAN bean) { return new DefaultListCellRenderer(); } @@ -333,8 +333,8 @@ protected ListCellRenderer getTableRenderer(@Nonnull BEAN bean) { * @see DbBean * @see JList#setCellRenderer(javax.swing.ListCellRenderer) */ - @Nonnull - protected ListCellRenderer getColumnRenderer(@Nonnull BEAN bean) { + @NonNull + protected ListCellRenderer getColumnRenderer(@NonNull BEAN bean) { return new DefaultListCellRenderer(); } } diff --git a/nbdemetra-jdbc/src/main/java/ec/nbdemetra/jdbc/DbExplorerUtil.java b/nbdemetra-jdbc/src/main/java/ec/nbdemetra/jdbc/DbExplorerUtil.java index 7dff428e2..e0be776dc 100644 --- a/nbdemetra-jdbc/src/main/java/ec/nbdemetra/jdbc/DbExplorerUtil.java +++ b/nbdemetra-jdbc/src/main/java/ec/nbdemetra/jdbc/DbExplorerUtil.java @@ -18,7 +18,7 @@ import com.google.common.base.Optional; import java.util.Properties; -import javax.annotation.Nonnull; +import org.checkerframework.checker.nullness.qual.NonNull; import org.netbeans.api.db.explorer.ConnectionManager; import org.netbeans.api.db.explorer.DatabaseConnection; import org.netbeans.api.db.explorer.DatabaseException; @@ -41,14 +41,18 @@ private DbExplorerUtil() { // static class } - static boolean isConnected(@Nonnull DatabaseConnection conn) { + static boolean isConnected(@NonNull DatabaseConnection conn) { return conn.getJDBCConnection() != null; } - static boolean isTableOrView(@Nonnull Node node) { + static boolean isTableOrView(@NonNull Node node) { return lookupContains(node.getLookup(), - "org.netbeans.modules.db.explorer.node.TableNode", - "org.netbeans.modules.db.explorer.node.ViewNode"); + getClassName("TableNode"), + getClassName("ViewNode")); + } + + private static String getClassName(String name) { + return "org.netbeans.modules.db.explorer.node." + name; } // some part of the db api is private; we need to cheat a bit @@ -63,8 +67,8 @@ private static boolean lookupContains(Lookup lookup, String... classNames) { return false; } - @Nonnull - static Optional findConnection(@Nonnull Node node) { + @NonNull + static Optional findConnection(@NonNull Node node) { DatabaseConnection result = null; Node current = node; while (current != null && (result = current.getLookup().lookup(DatabaseConnection.class)) == null) { @@ -73,16 +77,16 @@ static Optional findConnection(@Nonnull Node node) { return Optional.fromNullable(result); } - @Nonnull - static Optional getDriverByClass(@Nonnull String driverClass) { + @NonNull + static Optional getDriverByClass(@NonNull String driverClass) { for (JDBCDriver o : JDBCDriverManager.getDefault().getDrivers(driverClass)) { return Optional.of(o); } return Optional.absent(); } - @Nonnull - static Optional getConnectionByDisplayName(@Nonnull String displayName) { + @NonNull + static Optional getConnectionByDisplayName(@NonNull String displayName) { for (DatabaseConnection o : ConnectionManager.getDefault().getConnections()) { if (o.getDisplayName().equals(displayName)) { return Optional.of(o); @@ -91,7 +95,7 @@ static Optional getConnectionByDisplayName(@Nonnull String d return Optional.absent(); } - public static void importConnection(@Nonnull DriverBasedConfig config) { + public static void importConnection(@NonNull DriverBasedConfig config) { Optional driver = getDriverByClass(config.getDriverClass()); if (!driver.isPresent()) { String msg = "Cannot find driver '" + config.getDriverClass() + "'"; @@ -114,8 +118,8 @@ public static void importConnection(@Nonnull DriverBasedConfig config) { } } - @Nonnull - public static DriverBasedConfig exportConnection(@Nonnull DatabaseConnection conn) { + @NonNull + public static DriverBasedConfig exportConnection(@NonNull DatabaseConnection conn) { DriverBasedConfig.Builder b = DriverBasedConfig.builder(conn.getDriverClass(), conn.getDatabaseURL(), conn.getSchema(), conn.getDisplayName()); Properties properties = conn.getConnectionProperties(); for (String o : properties.stringPropertyNames()) { diff --git a/nbdemetra-jdbc/src/main/java/ec/nbdemetra/jdbc/DriverBasedConfig.java b/nbdemetra-jdbc/src/main/java/ec/nbdemetra/jdbc/DriverBasedConfig.java index ace434c02..1ccfbfedc 100644 --- a/nbdemetra-jdbc/src/main/java/ec/nbdemetra/jdbc/DriverBasedConfig.java +++ b/nbdemetra-jdbc/src/main/java/ec/nbdemetra/jdbc/DriverBasedConfig.java @@ -30,7 +30,7 @@ import java.util.Map; import java.util.Objects; import java.util.SortedMap; -import javax.annotation.Nonnull; +import org.checkerframework.checker.nullness.qual.NonNull; import javax.xml.bind.JAXBContext; import javax.xml.bind.JAXBException; import javax.xml.bind.annotation.XmlAttribute; @@ -51,7 +51,7 @@ public final class DriverBasedConfig implements IConfig { private final ImmutableSortedMap params; @VisibleForTesting - DriverBasedConfig(@Nonnull String driverClass, @Nonnull String databaseUrl, @Nonnull String schema, @Nonnull String displayName, @Nonnull ImmutableSortedMap params) { + DriverBasedConfig(@NonNull String driverClass, @NonNull String databaseUrl, @NonNull String schema, @NonNull String displayName, @NonNull ImmutableSortedMap params) { this.driverClass = driverClass; this.databaseUrl = databaseUrl; this.schema = schema; @@ -59,22 +59,22 @@ public final class DriverBasedConfig implements IConfig { this.params = params; } - @Nonnull + @NonNull public String getDriverClass() { return driverClass; } - @Nonnull + @NonNull public String getDatabaseUrl() { return databaseUrl; } - @Nonnull + @NonNull public String getSchema() { return schema; } - @Nonnull + @NonNull public String getDisplayName() { return displayName; } @@ -120,8 +120,8 @@ ConnectionBean toBean() { return bean; } - @Nonnull - public static DriverBasedConfig deepCopyOf(@Nonnull String driverClass, @Nonnull String databaseUrl, @Nonnull String schema, @Nonnull String displayName, @Nonnull Map params) { + @NonNull + public static DriverBasedConfig deepCopyOf(@NonNull String driverClass, @NonNull String databaseUrl, @NonNull String schema, @NonNull String displayName, @NonNull Map params) { return new DriverBasedConfig( Objects.requireNonNull(driverClass, "driverClass"), Objects.requireNonNull(databaseUrl, "databaseUrl"), @@ -130,8 +130,8 @@ public static DriverBasedConfig deepCopyOf(@Nonnull String driverClass, @Nonnull ImmutableSortedMap.copyOf(Objects.requireNonNull(params, "params"))); } - @Nonnull - public static Builder builder(@Nonnull String driverClass, @Nonnull String databaseUrl, @Nonnull String schema, @Nonnull String displayName) { + @NonNull + public static Builder builder(@NonNull String driverClass, @NonNull String databaseUrl, @NonNull String schema, @NonNull String displayName) { return new Builder( Objects.requireNonNull(driverClass, "driverClass"), Objects.requireNonNull(databaseUrl, "databaseUrl"), @@ -139,13 +139,11 @@ public static Builder builder(@Nonnull String driverClass, @Nonnull String datab Objects.requireNonNull(displayName, "displayName")); } - @Nonnull - public static Formatters.Formatter xmlFormatter(boolean formattedOutput) { + public static Formatters.@NonNull Formatter xmlFormatter(boolean formattedOutput) { return formattedOutput ? XML.get().formattedOutputFormatter : XML.get().defaultFormatter; } - @Nonnull - public static Parsers.Parser xmlParser() { + public static Parsers.@NonNull Parser xmlParser() { return XML.get().defaultParser; } @@ -157,7 +155,7 @@ public static final class Builder extends AbstractConfigBuilder { @Override diff --git a/nbdemetra-jdbc/src/main/java/ec/nbdemetra/jdbc/JdbcProviderBuddy.java b/nbdemetra-jdbc/src/main/java/ec/nbdemetra/jdbc/JdbcProviderBuddy.java index 404e2fbe1..d718e0c36 100644 --- a/nbdemetra-jdbc/src/main/java/ec/nbdemetra/jdbc/JdbcProviderBuddy.java +++ b/nbdemetra-jdbc/src/main/java/ec/nbdemetra/jdbc/JdbcProviderBuddy.java @@ -17,7 +17,10 @@ package ec.nbdemetra.jdbc; import com.google.common.base.Strings; +import ec.nbdemetra.db.DbColumnListCellRenderer; +import ec.nbdemetra.db.DbIcon; import ec.nbdemetra.db.DbProviderBuddy; +import ec.nbdemetra.ui.awt.SimpleHtmlListCellRenderer; import ec.tss.tsproviders.jdbc.ConnectionSupplier; import ec.tss.tsproviders.jdbc.JdbcBean; import ec.tstoolkit.utilities.GuavaCaches; @@ -26,20 +29,22 @@ import static ec.util.completion.AutoCompletionSource.Behavior.NONE; import static ec.util.completion.AutoCompletionSource.Behavior.SYNC; import ec.util.completion.ExtAutoCompletionSource; -import ec.util.jdbc.JdbcColumn; -import ec.util.jdbc.JdbcTable; -import ec.util.jdbc.SqlIdentifierQuoter; import java.sql.Connection; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Statement; +import java.sql.Types; import java.time.Duration; import java.util.Comparator; import java.util.List; import java.util.function.Predicate; import java.util.stream.Collectors; -import javax.annotation.Nonnull; +import javax.swing.Icon; +import org.checkerframework.checker.nullness.qual.NonNull; import javax.swing.ListCellRenderer; +import nbbrd.sql.jdbc.SqlColumn; +import nbbrd.sql.jdbc.SqlIdentifierQuoter; +import nbbrd.sql.jdbc.SqlTable; /** * An abstract provider buddy that targets Jdbc providers. @@ -51,73 +56,148 @@ public abstract class JdbcProviderBuddy extends DbProvide protected final ConnectionSupplier supplier; - public JdbcProviderBuddy(@Nonnull ConnectionSupplier supplier) { + public JdbcProviderBuddy(@NonNull ConnectionSupplier supplier) { this.supplier = supplier; } @Override protected AutoCompletionSource getTableSource(BEAN bean) { return ExtAutoCompletionSource - .builder(o -> getJdbcTables(supplier, bean)) + .builder(o -> getSqlTables(supplier, bean)) .behavior(o -> !Strings.isNullOrEmpty(bean.getDbName()) ? ASYNC : NONE) - .postProcessor(JdbcProviderBuddy::getJdbcTables) - .valueToString(JdbcTable::getName) + .postProcessor(JdbcProviderBuddy::getSqlTables) + .valueToString(SqlTable::getName) .cache(GuavaCaches.ttlCacheAsMap(Duration.ofMinutes(1)), o -> bean.getDbName(), SYNC) .build(); } @Override protected ListCellRenderer getTableRenderer(BEAN bean) { - return new JdbcTableListCellRenderer(); + return new SqlTableRenderer(); } @Override protected AutoCompletionSource getColumnSource(BEAN bean) { return ExtAutoCompletionSource - .builder(o -> getJdbcColumns(supplier, bean)) + .builder(o -> getSqlColumns(supplier, bean)) .behavior(o -> !Strings.isNullOrEmpty(bean.getDbName()) && !Strings.isNullOrEmpty(bean.getTableName()) ? ASYNC : NONE) - .postProcessor(JdbcProviderBuddy::getJdbcColumns) - .valueToString(JdbcColumn::getName) + .postProcessor(JdbcProviderBuddy::getSqlColumns) + .valueToString(SqlColumn::getName) .cache(GuavaCaches.ttlCacheAsMap(Duration.ofMinutes(1)), o -> bean.getDbName() + "/" + bean.getTableName(), SYNC) .build(); } @Override protected ListCellRenderer getColumnRenderer(BEAN bean) { - return new JdbcColumnListCellRenderer(); + return new SqlColumnRenderer(); } // - private static List getJdbcTables(ConnectionSupplier supplier, T bean) throws SQLException { + private static final class SqlTableRenderer extends SimpleHtmlListCellRenderer { + + public SqlTableRenderer() { + super(o -> "" + o.getName() + " - " + o.getType() + ""); + } + } + + private static final class SqlColumnRenderer extends DbColumnListCellRenderer { + + @Override + protected String getName(SqlColumn value) { + return value.getName(); + } + + @Override + protected String getTypeName(SqlColumn value) { + return value.getTypeName(); + } + + @Override + protected Icon getTypeIcon(SqlColumn value) { + switch (value.getType()) { + case Types.BIGINT: + case Types.DECIMAL: + case Types.INTEGER: + case Types.NUMERIC: + case Types.SMALLINT: + case Types.TINYINT: + return DbIcon.DATA_TYPE_INTEGER; + case Types.DOUBLE: + case Types.FLOAT: + case Types.REAL: + return DbIcon.DATA_TYPE_DOUBLE; + case Types.BINARY: + case Types.BLOB: + case Types.CLOB: + case Types.JAVA_OBJECT: + case Types.LONGVARBINARY: + case Types.NCLOB: + case Types.VARBINARY: + return DbIcon.DATA_TYPE_BINARY; + case Types.CHAR: + case Types.LONGNVARCHAR: + case Types.LONGVARCHAR: + case Types.NCHAR: + case Types.NVARCHAR: + case Types.VARCHAR: + return DbIcon.DATA_TYPE_STRING; + case Types.DATE: + case Types.TIME: + case Types.TIMESTAMP: + return DbIcon.DATA_TYPE_DATETIME; + case Types.BIT: + case Types.BOOLEAN: + return DbIcon.DATA_TYPE_BOOLEAN; + case Types.ARRAY: + case Types.DATALINK: + case Types.DISTINCT: + case Types.NULL: + case Types.OTHER: + case Types.REF: + case Types.ROWID: + case Types.SQLXML: + case Types.STRUCT: + return DbIcon.DATA_TYPE_NULL; + } + return null; + } + } + + private static List getSqlTables(ConnectionSupplier supplier, T bean) throws SQLException { try (Connection c = supplier.getConnection(bean)) { - return JdbcTable.allOf(c.getMetaData(), c.getCatalog(), c.getSchema(), "%", new String[]{"TABLE", "VIEW"}); + return SqlTable.allOf(c.getMetaData(), c.getCatalog(), c.getSchema(), "%", new String[]{"TABLE", "VIEW"}); } } - private static List getJdbcColumns(ConnectionSupplier supplier, T bean) throws SQLException { + private static List getSqlColumns(ConnectionSupplier supplier, T bean) throws SQLException { try (Connection c = supplier.getConnection(bean)) { - SqlIdentifierQuoter quoter = SqlIdentifierQuoter.create(c.getMetaData()); + SqlIdentifierQuoter quoter = SqlIdentifierQuoter.of(c.getMetaData()); try (Statement st = c.createStatement()) { try (ResultSet rs = st.executeQuery("select * from " + quoter.quote(bean.getTableName(), false) + " where 1 = 0")) { - return JdbcColumn.ofAll(rs.getMetaData()); + return SqlColumn.allOf(rs.getMetaData()); } } } } - private static List getJdbcTables(List values, String term) { + private static List getSqlTables(List values, String term) { Predicate filter = ExtAutoCompletionSource.basicFilter(term); return values.stream() .filter(o -> filter.test(o.getName()) || filter.test(o.getSchema()) || filter.test(o.getCatalog()) || filter.test(o.getRemarks())) - .sorted() + .sorted(Comparator + .comparing(SqlTable::getType) + .thenComparing(SqlTable::getCatalog) + .thenComparing(SqlTable::getSchema) + .thenComparing(SqlTable::getName) + ) .collect(Collectors.toList()); } - private static List getJdbcColumns(List values, String term) { + private static List getSqlColumns(List values, String term) { Predicate filter = ExtAutoCompletionSource.basicFilter(term); return values.stream() .filter(o -> filter.test(o.getName()) || filter.test(o.getLabel()) || filter.test(o.getTypeName())) - .sorted(Comparator.comparing(JdbcColumn::getName)) + .sorted(Comparator.comparing(SqlColumn::getName)) .collect(Collectors.toList()); } // diff --git a/nbdemetra-jdbc/src/main/java/ec/nbdemetra/jdbc/JdbcTableListCellRenderer.java b/nbdemetra-jdbc/src/main/java/ec/nbdemetra/jdbc/JdbcTableListCellRenderer.java index 7d7dea9aa..272a252af 100644 --- a/nbdemetra-jdbc/src/main/java/ec/nbdemetra/jdbc/JdbcTableListCellRenderer.java +++ b/nbdemetra-jdbc/src/main/java/ec/nbdemetra/jdbc/JdbcTableListCellRenderer.java @@ -11,6 +11,7 @@ * * @author Philippe Charles */ +@Deprecated public class JdbcTableListCellRenderer extends SimpleHtmlListCellRenderer { public JdbcTableListCellRenderer() { diff --git a/nbdemetra-jdbc/src/main/java/ec/nbdemetra/jdbc/JndiJdbcProviderBuddy.java b/nbdemetra-jdbc/src/main/java/ec/nbdemetra/jdbc/JndiJdbcProviderBuddy.java index 38d37b2bf..5807061ee 100644 --- a/nbdemetra-jdbc/src/main/java/ec/nbdemetra/jdbc/JndiJdbcProviderBuddy.java +++ b/nbdemetra-jdbc/src/main/java/ec/nbdemetra/jdbc/JndiJdbcProviderBuddy.java @@ -53,7 +53,7 @@ import java.util.concurrent.RunnableFuture; import java.util.function.Predicate; import java.util.stream.Collectors; -import javax.annotation.Nonnull; +import org.checkerframework.checker.nullness.qual.NonNull; import javax.swing.Action; import javax.swing.JCheckBox; import javax.swing.ListCellRenderer; @@ -305,7 +305,7 @@ private static final class FailSafeConnection extends ForwardingConnection { private final Connection delegate; private final String defaultSchema; - public FailSafeConnection(@Nonnull Connection delegate, String defaultSchema) { + public FailSafeConnection(@NonNull Connection delegate, String defaultSchema) { this.delegate = delegate; this.defaultSchema = defaultSchema; } diff --git a/nbdemetra-odbc/pom.xml b/nbdemetra-odbc/pom.xml index 0f9fa75d6..fdebeaa46 100644 --- a/nbdemetra-odbc/pom.xml +++ b/nbdemetra-odbc/pom.xml @@ -4,7 +4,7 @@ eu.europa.ec.joinup.sat nbdemetra-parent - 2.2.2 + 2.2.3 nbdemetra-odbc @@ -35,6 +35,10 @@ org.netbeans.api org-openide-explorer + + org.netbeans.api + org-openide-util-ui + @@ -75,19 +79,25 @@ com.google.guava guava + + + + be.nbb.rd + java-sql-lhod + 1.0.1 + - net.java.dev.jna - jna-platform + be.nbb.rd + java-sql-jdbc - - org.codehaus.mojo + org.apache.netbeans.utilities nbm-maven-plugin true diff --git a/nbdemetra-odbc/src/main/java/ec/nbdemetra/odbc/OdbcProviderBuddy.java b/nbdemetra-odbc/src/main/java/ec/nbdemetra/odbc/OdbcProviderBuddy.java index d7483e6fd..b0a62001e 100644 --- a/nbdemetra-odbc/src/main/java/ec/nbdemetra/odbc/OdbcProviderBuddy.java +++ b/nbdemetra-odbc/src/main/java/ec/nbdemetra/odbc/OdbcProviderBuddy.java @@ -28,8 +28,6 @@ import ec.tss.tsproviders.jdbc.JdbcBean; import ec.tss.tsproviders.odbc.OdbcBean; import ec.tss.tsproviders.odbc.OdbcProvider; -import ec.tss.tsproviders.odbc.registry.IOdbcRegistry; -import ec.tss.tsproviders.odbc.registry.OdbcDataSource; import ec.tstoolkit.utilities.GuavaCaches; import ec.util.completion.AutoCompletionSource; import ec.util.completion.ExtAutoCompletionSource; @@ -44,9 +42,10 @@ import java.util.function.Predicate; import java.util.stream.Collectors; import javax.swing.ListCellRenderer; +import nbbrd.sql.odbc.OdbcDataSource; +import nbbrd.sql.odbc.OdbcRegistry; import org.openide.util.Exceptions; import org.openide.util.ImageUtilities; -import org.openide.util.Lookup; import org.openide.util.lookup.ServiceProvider; /** @@ -62,7 +61,7 @@ public class OdbcProviderBuddy extends JdbcProviderBuddy implements IC public OdbcProviderBuddy() { super(getOdbcConnectionSupplier()); - this.dbSource = odbcDsnSource(); + this.dbSource = odbcDsnSource(OdbcRegistry.ofServiceLoader()); this.dbRenderer = new SimpleHtmlListCellRenderer<>((OdbcDataSource o) -> "" + o.getName() + " - " + o.getServerName() + ""); } @@ -138,9 +137,9 @@ public Connection getConnection(JdbcBean bean) throws SQLException { } } - private static AutoCompletionSource odbcDsnSource() { + private static AutoCompletionSource odbcDsnSource(java.util.Optional odbcRegistry) { return ExtAutoCompletionSource - .builder(OdbcProviderBuddy::getDataSources) + .builder(() -> getDataSources(odbcRegistry)) .behavior(AutoCompletionSource.Behavior.ASYNC) .postProcessor(OdbcProviderBuddy::getDataSources) .valueToString(OdbcDataSource::getName) @@ -148,10 +147,9 @@ private static AutoCompletionSource odbcDsnSource() { .build(); } - private static List getDataSources() throws Exception { - IOdbcRegistry odbcRegistry = Lookup.getDefault().lookup(IOdbcRegistry.class); - return odbcRegistry != null - ? odbcRegistry.getDataSources(OdbcDataSource.Type.SYSTEM, OdbcDataSource.Type.USER) + private static List getDataSources(java.util.Optional odbcRegistry) throws Exception { + return odbcRegistry.isPresent() + ? odbcRegistry.get().getDataSources(OdbcDataSource.Type.SYSTEM, OdbcDataSource.Type.USER) : Collections.emptyList(); } diff --git a/nbdemetra-odbc/src/main/java/ec/nbdemetra/odbc/OdbcRegistry.java b/nbdemetra-odbc/src/main/java/ec/nbdemetra/odbc/OdbcRegistry.java deleted file mode 100644 index ebb18c4b2..000000000 --- a/nbdemetra-odbc/src/main/java/ec/nbdemetra/odbc/OdbcRegistry.java +++ /dev/null @@ -1,154 +0,0 @@ -/* - * Copyright 2013 National Bank of Belgium - * - * Licensed under the EUPL, Version 1.1 or - as soon they will be approved - * by the European Commission - subsequent versions of the EUPL (the "Licence"); - * You may not use this work except in compliance with the Licence. - * You may obtain a copy of the Licence at: - * - * http://ec.europa.eu/idabc/eupl - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the Licence is distributed on an "AS IS" basis, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the Licence for the specific language governing permissions and - * limitations under the Licence. - */ -package ec.nbdemetra.odbc; - -import com.google.common.base.Splitter; -import com.google.common.collect.ImmutableList; -import com.google.common.io.Files; -import ec.tss.tsproviders.odbc.registry.IOdbcRegistry; -import ec.tss.tsproviders.odbc.registry.OdbcDataSource; -import ec.tss.tsproviders.odbc.registry.OdbcDriver; -import ec.tstoolkit.design.IntValue; -import ec.tstoolkit.design.VisibleForTesting; -import ec.util.desktop.impl.WinRegistry; -import static ec.util.desktop.impl.WinRegistry.Root.HKEY_CURRENT_USER; -import static ec.util.desktop.impl.WinRegistry.Root.HKEY_LOCAL_MACHINE; -import java.io.IOException; -import java.util.ArrayList; -import java.util.List; -import java.util.Map.Entry; -import java.util.SortedMap; -import org.openide.util.lookup.ServiceProvider; - -/** - * - * @author Philippe Charles - */ -@ServiceProvider(service = IOdbcRegistry.class) -public final class OdbcRegistry implements IOdbcRegistry { - - private static final String DATA_SOURCES_KEY = "SOFTWARE\\ODBC\\ODBC.INI\\ODBC Data Sources"; - private static final String DATA_SOURCE_KEY = "SOFTWARE\\ODBC\\ODBC.INI"; - private static final String DRIVERS_KEY = "SOFTWARE\\ODBC\\Odbcinst.INI\\ODBC Drivers"; - private static final String DRIVER_KEY = "SOFTWARE\\ODBC\\Odbcinst.INI"; - - private final WinRegistry registry; - - public OdbcRegistry() { - this(WinRegistry.getDefault()); - } - - @VisibleForTesting - OdbcRegistry(WinRegistry registry) { - this.registry = registry; - } - - @Override - public List getDataSources(OdbcDataSource.Type... types) throws IOException { - List result = new ArrayList<>(); - for (OdbcDataSource.Type type : types) { - WinRegistry.Root root = getRoot(type); - if (registry.keyExists(root, DATA_SOURCES_KEY)) { - for (Entry ds : registry.getValues(root, DATA_SOURCES_KEY).entrySet()) { - String dataSourceKey = DATA_SOURCE_KEY + "\\" + ds.getKey(); - if (registry.keyExists(root, dataSourceKey)) { - result.add(newDataSource(type, ds, registry.getValues(root, dataSourceKey))); - } - } - } - } - return result; - } - - private static OdbcDataSource newDataSource(OdbcDataSource.Type type, Entry master, SortedMap details) { - return new OdbcDataSource(type, master.getKey(), - asString(details.get("Description")), - asString(master.getValue()), - asString(details.get("Driver")), - asString(details.get("Server"))); - } - - private static WinRegistry.Root getRoot(OdbcDataSource.Type type) { - switch (type) { - case SYSTEM: - return HKEY_LOCAL_MACHINE; - case USER: - return HKEY_CURRENT_USER; - } - throw new UnsupportedOperationException("Not supported yet."); - } - - @Override - public List getDrivers() throws IOException { - List result = new ArrayList<>(); - if (registry.keyExists(HKEY_LOCAL_MACHINE, DRIVERS_KEY)) { - for (String name : registry.getValues(HKEY_LOCAL_MACHINE, DRIVERS_KEY).keySet()) { - String driverKey = DRIVER_KEY + "\\" + name; - if (registry.keyExists(HKEY_LOCAL_MACHINE, driverKey)) { - result.add(newDriver(name, registry.getValues(HKEY_LOCAL_MACHINE, driverKey))); - } - } - } - return result; - } - - private static OdbcDriver newDriver(String name, SortedMap details) { - return new OdbcDriver(name, - parseEnum(details.get("APILevel"), OdbcDriver.ApiLevel.class, OdbcDriver.ApiLevel.NONE), - OdbcDriver.ConnectFunctions.valueOf((String) asString(details.get("ConnectFunctions"))), - asString(details.get("Driver")), - asString(details.get("DriverOdbcVer")), - readFileExtns(details.get("FileExtns")), - parseEnum(details.get("FileUsage"), OdbcDriver.FileUsage.class, OdbcDriver.FileUsage.NONE), - asString(details.get("Setup")), - parseEnum(details.get("SQLLevel"), OdbcDriver.SqlLevel.class, OdbcDriver.SqlLevel.SQL_92_ENTRY), - asInt(details.get("UsageCount"), -1)); - } - - private static String asString(Object o) { - return o instanceof String ? (String) o : null; - } - - private static int asInt(Object obj, int defaultValue) { - return obj instanceof Integer ? (Integer) obj : defaultValue; - } - - private static & IntValue> Z parseEnum(Object obj, Class clazz, Z defaultValue) { - if (obj == null) { - return defaultValue; - } - int value = Integer.parseInt(obj.toString()); - for (Z o : clazz.getEnumConstants()) { - if (o.intValue() == value) { - return o; - } - } - return defaultValue; - } - - private static ImmutableList readFileExtns(Object obj) { - if (obj == null) { - return ImmutableList.of(); - } - ImmutableList.Builder builder = ImmutableList.builder(); - for (String o : EXTNS_SPLITTER.split(obj.toString())) { - builder.add(Files.getFileExtension(o)); - } - return builder.build(); - } - private static final Splitter EXTNS_SPLITTER = Splitter.on(',').omitEmptyStrings(); -} diff --git a/nbdemetra-sa/pom.xml b/nbdemetra-sa/pom.xml index 9bc705d7d..5aca72258 100644 --- a/nbdemetra-sa/pom.xml +++ b/nbdemetra-sa/pom.xml @@ -4,7 +4,7 @@ eu.europa.ec.joinup.sat nbdemetra-parent - 2.2.2 + 2.2.3 nbdemetra-sa @@ -16,6 +16,13 @@ + + + org.checkerframework + checker-qual + provided + + org.netbeans.api @@ -112,7 +119,7 @@ - org.codehaus.mojo + org.apache.netbeans.utilities nbm-maven-plugin true diff --git a/nbdemetra-sa/src/main/java/ec/nbdemetra/sa/SaBatchUI.java b/nbdemetra-sa/src/main/java/ec/nbdemetra/sa/SaBatchUI.java index 73b292b62..35f19e50f 100644 --- a/nbdemetra-sa/src/main/java/ec/nbdemetra/sa/SaBatchUI.java +++ b/nbdemetra-sa/src/main/java/ec/nbdemetra/sa/SaBatchUI.java @@ -890,6 +890,8 @@ static class EstimationRenderer extends SimpleRenderer { @Override protected String getText(SaItem item) { switch (item.getEstimationPolicy()) { + case Current: + return "Current (AO)"; case Fixed: return "Fixed model"; case FixedParameters: diff --git a/nbdemetra-sa/src/main/java/ec/nbdemetra/sa/actions/LocalRefreshConcurrent.java b/nbdemetra-sa/src/main/java/ec/nbdemetra/sa/actions/LocalRefreshConcurrent.java index 882013f18..458c5ff0a 100644 --- a/nbdemetra-sa/src/main/java/ec/nbdemetra/sa/actions/LocalRefreshConcurrent.java +++ b/nbdemetra-sa/src/main/java/ec/nbdemetra/sa/actions/LocalRefreshConcurrent.java @@ -20,7 +20,7 @@ id = "ec.nbdemetra.sa.actions.LocalRefreshConcurrent") @ActionRegistration(displayName = "#CTL_LocalRefreshConcurrent") @ActionReferences({ - @ActionReference(path = MultiProcessingManager.LOCALPATH+LocalRefresh.PATH, position = 1290) + @ActionReference(path = MultiProcessingManager.LOCALPATH+LocalRefresh.PATH, position = 1230) }) @Messages("CTL_LocalRefreshConcurrent=Concurrent") public final class LocalRefreshConcurrent implements ActionListener { diff --git a/nbdemetra-sa/src/main/java/ec/nbdemetra/sa/actions/LocalRefreshCurrent.java b/nbdemetra-sa/src/main/java/ec/nbdemetra/sa/actions/LocalRefreshCurrent.java new file mode 100644 index 000000000..5e7efcddc --- /dev/null +++ b/nbdemetra-sa/src/main/java/ec/nbdemetra/sa/actions/LocalRefreshCurrent.java @@ -0,0 +1,40 @@ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ +package ec.nbdemetra.sa.actions; + +import ec.nbdemetra.sa.MultiProcessingManager; +import ec.nbdemetra.sa.SaBatchUI; +import ec.nbdemetra.ui.ActiveViewManager; +import ec.tss.sa.EstimationPolicyType; +import java.awt.event.ActionListener; +import java.awt.event.ActionEvent; + +import org.openide.awt.ActionRegistration; +import org.openide.awt.ActionReference; +import org.openide.awt.ActionReferences; +import org.openide.awt.ActionID; +import org.openide.util.NbBundle.Messages; + +@ActionID(category = "SaProcessing", +id = "ec.nbdemetra.sa.actions.LocalRefreshCurrent") +@ActionRegistration(displayName = "#CTL_LocalRefreshCurrent") +@ActionReferences({ + @ActionReference(path = MultiProcessingManager.LOCALPATH+LocalRefresh.PATH, position = 1201) +}) +@Messages("CTL_LocalRefreshCurrent=Current adjustment (AO approach)") +public final class LocalRefreshCurrent implements ActionListener { + + public LocalRefreshCurrent() { + } + + @Override + public void actionPerformed(ActionEvent ev) { + SaBatchUI ui = ActiveViewManager.getInstance().getLookup().lookup(SaBatchUI.class); + if (ui == null) { + return; + } + ui.refreshSelection(EstimationPolicyType.Current, false, true); + } +} \ No newline at end of file diff --git a/nbdemetra-sa/src/main/java/ec/nbdemetra/sa/actions/LocalRefreshFixedModel.java b/nbdemetra-sa/src/main/java/ec/nbdemetra/sa/actions/LocalRefreshFixedModel.java index 721168d06..1eeb016e9 100644 --- a/nbdemetra-sa/src/main/java/ec/nbdemetra/sa/actions/LocalRefreshFixedModel.java +++ b/nbdemetra-sa/src/main/java/ec/nbdemetra/sa/actions/LocalRefreshFixedModel.java @@ -22,7 +22,7 @@ @ActionReferences({ @ActionReference(path = MultiProcessingManager.LOCALPATH + LocalRefreshPartial.PATH, position = 1205) }) -@Messages("CTL_LocalRefreshFixedModel=Current adjustment") +@Messages("CTL_LocalRefreshFixedModel=Fixed model") public final class LocalRefreshFixedModel implements ActionListener { public LocalRefreshFixedModel() { diff --git a/nbdemetra-sa/src/main/java/ec/nbdemetra/sa/actions/Output.java b/nbdemetra-sa/src/main/java/ec/nbdemetra/sa/actions/Output.java index 5d5b8f2e8..047c955b3 100644 --- a/nbdemetra-sa/src/main/java/ec/nbdemetra/sa/actions/Output.java +++ b/nbdemetra-sa/src/main/java/ec/nbdemetra/sa/actions/Output.java @@ -39,7 +39,7 @@ import java.io.File; import java.util.List; import java.util.concurrent.ExecutionException; -import javax.annotation.Nullable; +import org.checkerframework.checker.nullness.qual.Nullable; import javax.swing.SwingWorker; import org.netbeans.api.progress.ProgressHandle; import org.openide.DialogDescriptor; diff --git a/nbdemetra-sa/src/main/java/ec/nbdemetra/sa/actions/RefreshConcurrent.java b/nbdemetra-sa/src/main/java/ec/nbdemetra/sa/actions/RefreshConcurrent.java index bcab62132..4c364e0bd 100644 --- a/nbdemetra-sa/src/main/java/ec/nbdemetra/sa/actions/RefreshConcurrent.java +++ b/nbdemetra-sa/src/main/java/ec/nbdemetra/sa/actions/RefreshConcurrent.java @@ -20,7 +20,7 @@ id = "ec.nbdemetra.sa.actions.RefreshConcurrent") @ActionRegistration(displayName = "#CTL_RefreshConcurrent") @ActionReferences({ - @ActionReference(path = MultiProcessingManager.CONTEXTPATH+Refresh.PATH, position = 1290) + @ActionReference(path = MultiProcessingManager.CONTEXTPATH+Refresh.PATH, position = 1230) }) @Messages("CTL_RefreshConcurrent=Concurrent") public final class RefreshConcurrent implements ActionListener { diff --git a/nbdemetra-sa/src/main/java/ec/nbdemetra/sa/actions/RefreshCurrent.java b/nbdemetra-sa/src/main/java/ec/nbdemetra/sa/actions/RefreshCurrent.java new file mode 100644 index 000000000..ea3a924c4 --- /dev/null +++ b/nbdemetra-sa/src/main/java/ec/nbdemetra/sa/actions/RefreshCurrent.java @@ -0,0 +1,40 @@ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ +package ec.nbdemetra.sa.actions; + +import ec.nbdemetra.sa.MultiProcessingManager; +import ec.nbdemetra.sa.SaBatchUI; +import ec.nbdemetra.ui.ActiveViewManager; +import ec.tss.sa.EstimationPolicyType; +import java.awt.event.ActionListener; +import java.awt.event.ActionEvent; + +import org.openide.awt.ActionRegistration; +import org.openide.awt.ActionReference; +import org.openide.awt.ActionReferences; +import org.openide.awt.ActionID; +import org.openide.util.NbBundle.Messages; + +@ActionID(category = "SaProcessing", +id = "ec.nbdemetra.sa.actions.RefreshCurrent") +@ActionRegistration(displayName = "#CTL_RefreshCurrent") +@ActionReferences({ + @ActionReference(path = MultiProcessingManager.CONTEXTPATH+Refresh.PATH, position = 1201) +}) +@Messages("CTL_RefreshCurrent=Current adjustment (AO approach)") +public final class RefreshCurrent implements ActionListener { + + public RefreshCurrent() { + } + + @Override + public void actionPerformed(ActionEvent ev) { + SaBatchUI ui = ActiveViewManager.getInstance().getLookup().lookup(SaBatchUI.class); + if (ui == null) { + return; + } + ui.refresh(EstimationPolicyType.Current, false, true); + } +} \ No newline at end of file diff --git a/nbdemetra-sa/src/main/java/ec/nbdemetra/tramoseats/actions/ImportTramoSeatsSpec.java b/nbdemetra-sa/src/main/java/ec/nbdemetra/tramoseats/actions/ImportTramoSeatsSpec.java index 48c91397a..986dfe954 100644 --- a/nbdemetra-sa/src/main/java/ec/nbdemetra/tramoseats/actions/ImportTramoSeatsSpec.java +++ b/nbdemetra-sa/src/main/java/ec/nbdemetra/tramoseats/actions/ImportTramoSeatsSpec.java @@ -30,7 +30,7 @@ import ec.tstoolkit.algorithm.IProcSpecification; import java.util.Collections; import java.util.List; -import javax.annotation.Nonnull; +import org.checkerframework.checker.nullness.qual.NonNull; import javax.swing.JMenuItem; import org.openide.awt.ActionID; import org.openide.awt.ActionReference; @@ -98,7 +98,7 @@ public void importConfig(Config config) throws IllegalArgumentException { }); } - private static TramoSeatsSpecification fromConfig(@Nonnull Config config) throws IllegalArgumentException { + private static TramoSeatsSpecification fromConfig(@NonNull Config config) throws IllegalArgumentException { if (!TramoSeatsSpecification.class.getName().equals(config.getDomain())) { throw new IllegalArgumentException("Invalid config"); } diff --git a/nbdemetra-sa/src/main/java/ec/nbdemetra/tramoseats/actions/ImportTramoSpec.java b/nbdemetra-sa/src/main/java/ec/nbdemetra/tramoseats/actions/ImportTramoSpec.java index 921ba0066..c271fa0d5 100644 --- a/nbdemetra-sa/src/main/java/ec/nbdemetra/tramoseats/actions/ImportTramoSpec.java +++ b/nbdemetra-sa/src/main/java/ec/nbdemetra/tramoseats/actions/ImportTramoSpec.java @@ -29,7 +29,7 @@ import ec.tstoolkit.modelling.arima.tramo.TramoSpecification; import java.util.Collections; import java.util.List; -import javax.annotation.Nonnull; +import org.checkerframework.checker.nullness.qual.NonNull; import javax.swing.JMenuItem; import org.openide.awt.ActionID; import org.openide.awt.ActionReference; @@ -97,7 +97,7 @@ public void importConfig(Config config) throws IllegalArgumentException { }); } - private static TramoSpecification fromConfig(@Nonnull Config config) throws IllegalArgumentException { + private static TramoSpecification fromConfig(@NonNull Config config) throws IllegalArgumentException { if (!TramoSpecification.class.getName().equals(config.getDomain())) { throw new IllegalArgumentException("Invalid config"); } diff --git a/nbdemetra-sa/src/main/java/ec/nbdemetra/x13/actions/ImportRegArimaSpec.java b/nbdemetra-sa/src/main/java/ec/nbdemetra/x13/actions/ImportRegArimaSpec.java index 9e0244521..9745616d6 100644 --- a/nbdemetra-sa/src/main/java/ec/nbdemetra/x13/actions/ImportRegArimaSpec.java +++ b/nbdemetra-sa/src/main/java/ec/nbdemetra/x13/actions/ImportRegArimaSpec.java @@ -29,7 +29,7 @@ import ec.tstoolkit.modelling.arima.x13.RegArimaSpecification; import java.util.Collections; import java.util.List; -import javax.annotation.Nonnull; +import org.checkerframework.checker.nullness.qual.NonNull; import javax.swing.JMenuItem; import org.openide.awt.ActionID; import org.openide.awt.ActionReference; @@ -97,7 +97,7 @@ public void importConfig(Config config) throws IllegalArgumentException { }); } - private static RegArimaSpecification fromConfig(@Nonnull Config config) throws IllegalArgumentException { + private static RegArimaSpecification fromConfig(@NonNull Config config) throws IllegalArgumentException { if (!RegArimaSpecification.class.getName().equals(config.getDomain())) { throw new IllegalArgumentException("Invalid config"); } diff --git a/nbdemetra-sa/src/main/java/ec/nbdemetra/x13/actions/ImportX13Spec.java b/nbdemetra-sa/src/main/java/ec/nbdemetra/x13/actions/ImportX13Spec.java index 83ff3eeda..477dd6b26 100644 --- a/nbdemetra-sa/src/main/java/ec/nbdemetra/x13/actions/ImportX13Spec.java +++ b/nbdemetra-sa/src/main/java/ec/nbdemetra/x13/actions/ImportX13Spec.java @@ -30,7 +30,7 @@ import ec.tstoolkit.algorithm.IProcSpecification; import java.util.Collections; import java.util.List; -import javax.annotation.Nonnull; +import org.checkerframework.checker.nullness.qual.NonNull; import javax.swing.JMenuItem; import org.openide.awt.ActionID; import org.openide.awt.ActionReference; @@ -98,7 +98,7 @@ public void importConfig(Config config) throws IllegalArgumentException { }); } - private static X13Specification fromConfig(@Nonnull Config config) throws IllegalArgumentException { + private static X13Specification fromConfig(@NonNull Config config) throws IllegalArgumentException { if (!X13Specification.class.getName().equals(config.getDomain())) { throw new IllegalArgumentException("Invalid config"); } diff --git a/nbdemetra-sdmx/pom.xml b/nbdemetra-sdmx/pom.xml index 7b516b0de..601ab6810 100644 --- a/nbdemetra-sdmx/pom.xml +++ b/nbdemetra-sdmx/pom.xml @@ -4,7 +4,7 @@ eu.europa.ec.joinup.sat nbdemetra-parent - 2.2.2 + 2.2.3 nbdemetra-sdmx @@ -70,7 +70,7 @@ - org.codehaus.mojo + org.apache.netbeans.utilities nbm-maven-plugin true diff --git a/nbdemetra-spreadsheet/pom.xml b/nbdemetra-spreadsheet/pom.xml index 5999b30dd..3f016e93d 100644 --- a/nbdemetra-spreadsheet/pom.xml +++ b/nbdemetra-spreadsheet/pom.xml @@ -4,7 +4,7 @@ eu.europa.ec.joinup.sat nbdemetra-parent - 2.2.2 + 2.2.3 nbdemetra-spreadsheet @@ -14,6 +14,13 @@ This module provides spreadsheet IO (such as Excel files) to Demetra. + + + org.checkerframework + checker-qual + provided + + org.netbeans.api @@ -102,7 +109,7 @@ - org.codehaus.mojo + org.apache.netbeans.utilities nbm-maven-plugin true diff --git a/nbdemetra-spreadsheet/src/main/java/ec/util/grid/swing/ext/SheetCellRenderer.java b/nbdemetra-spreadsheet/src/main/java/ec/util/grid/swing/ext/SheetCellRenderer.java index d80809647..0db4d0dd1 100644 --- a/nbdemetra-spreadsheet/src/main/java/ec/util/grid/swing/ext/SheetCellRenderer.java +++ b/nbdemetra-spreadsheet/src/main/java/ec/util/grid/swing/ext/SheetCellRenderer.java @@ -25,8 +25,8 @@ import java.awt.Color; import java.awt.Component; import java.util.Date; -import javax.annotation.Nonnull; -import javax.annotation.Nullable; +import org.checkerframework.checker.nullness.qual.NonNull; +import org.checkerframework.checker.nullness.qual.Nullable; import javax.swing.JLabel; import javax.swing.JTable; import javax.swing.JToolTip; @@ -45,7 +45,7 @@ public final class SheetCellRenderer implements TableCellRenderer { private final boolean invertColors; private final DefaultTableCellRenderer2 delegate; - public SheetCellRenderer(@Nonnull DataFormat dataFormat, @Nullable SwingColorSchemeSupport colorSchemeSupport, boolean invertColors) { + public SheetCellRenderer(@NonNull DataFormat dataFormat, @Nullable SwingColorSchemeSupport colorSchemeSupport, boolean invertColors) { this.numberFormat = dataFormat.numberFormatter(); this.dateFormat = dataFormat.dateFormatter(); this.colorSchemeSupport = colorSchemeSupport; diff --git a/nbdemetra-spreadsheet/src/main/java/ec/util/grid/swing/ext/SheetGridCommand.java b/nbdemetra-spreadsheet/src/main/java/ec/util/grid/swing/ext/SheetGridCommand.java index 985a6f652..e8eb95145 100644 --- a/nbdemetra-spreadsheet/src/main/java/ec/util/grid/swing/ext/SheetGridCommand.java +++ b/nbdemetra-spreadsheet/src/main/java/ec/util/grid/swing/ext/SheetGridCommand.java @@ -26,7 +26,7 @@ import ec.util.various.swing.JCommand; import java.awt.Toolkit; import java.awt.datatransfer.Transferable; -import javax.annotation.Nonnull; +import org.checkerframework.checker.nullness.qual.NonNull; import javax.swing.ListSelectionModel; /** @@ -43,15 +43,15 @@ public void execute(JGrid grid) { } // TODO: merge some code with TableGridCommand - @Nonnull - abstract public Table toTable(@Nonnull JGrid grid); + @NonNull + abstract public Table toTable(@NonNull JGrid grid); - @Nonnull + @NonNull public static SheetGridCommand copyAll(boolean rowHeader, boolean columnHeader) { return new CopyAllCommand(rowHeader, columnHeader); } - @Nonnull + @NonNull public static SheetGridCommand copySelection(boolean rowHeader, boolean columnHeader) { return new CopySelectionCommand(rowHeader, columnHeader); } diff --git a/nbdemetra-spreadsheet/src/main/java/ec/util/grid/swing/ext/SheetGridModel.java b/nbdemetra-spreadsheet/src/main/java/ec/util/grid/swing/ext/SheetGridModel.java index 9e355137b..b2e27c3f0 100644 --- a/nbdemetra-spreadsheet/src/main/java/ec/util/grid/swing/ext/SheetGridModel.java +++ b/nbdemetra-spreadsheet/src/main/java/ec/util/grid/swing/ext/SheetGridModel.java @@ -18,7 +18,7 @@ import ec.util.grid.swing.AbstractGridModel; import ec.util.spreadsheet.Sheet; -import javax.annotation.Nonnull; +import org.checkerframework.checker.nullness.qual.NonNull; /** * @@ -28,7 +28,7 @@ public final class SheetGridModel extends AbstractGridModel { private final Sheet sheet; - public SheetGridModel(@Nonnull Sheet sheet) { + public SheetGridModel(@NonNull Sheet sheet) { this.sheet = sheet; } diff --git a/nbdemetra-ui/pom.xml b/nbdemetra-ui/pom.xml index 3ae464103..17167a2ed 100644 --- a/nbdemetra-ui/pom.xml +++ b/nbdemetra-ui/pom.xml @@ -4,7 +4,7 @@ eu.europa.ec.joinup.sat nbdemetra-parent - 2.2.2 + 2.2.3 nbdemetra-ui @@ -14,17 +14,24 @@ 3.7.4 - 1.0.5 + 1.3.0 1.4 1.0.3 - 2.2.2 + 2.2.4 - eu.europa.ec.joinup.sat - nbdemetra-utils + be.nbb.rd + java-desktop-util-chart + ${java-desktop-util.version} + pom + import + + + be.nbb.rd + java-desktop-util-os ${java-desktop-util.version} pom import @@ -59,6 +66,12 @@ lombok provided + + org.checkerframework + checker-qual + provided + + junit @@ -162,11 +175,6 @@ ${project.groupId} nbdemetra-core - - ${project.groupId} - nbdemetra-utils - ${java-desktop-util.version} - @@ -194,19 +202,31 @@ swing-layout - net.java.dev.jna - jna + be.nbb.rd + java-desktop-util-swing + ${java-desktop-util.version} + + + be.nbb.rd + java-desktop-util-chart + ${java-desktop-util.version} - net.java.dev.jna - jna-platform + be.nbb.rd + java-desktop-util-fa + ${java-desktop-util.version} + + + be.nbb.rd + java-desktop-util-os + ${java-desktop-util.version} - org.codehaus.mojo + org.apache.netbeans.utilities nbm-maven-plugin true @@ -221,7 +241,6 @@ ec.util.* net.miginfocom.* org.jfree.* - com.sun.jna.* com.l2fprod.common.* com.toedter.* diff --git a/nbdemetra-ui/src/main/java/ec/nbdemetra/ui/AbstractConfigurable.java b/nbdemetra-ui/src/main/java/ec/nbdemetra/ui/AbstractConfigurable.java index e0183dec9..3dc8a8de9 100644 --- a/nbdemetra-ui/src/main/java/ec/nbdemetra/ui/AbstractConfigurable.java +++ b/nbdemetra-ui/src/main/java/ec/nbdemetra/ui/AbstractConfigurable.java @@ -16,7 +16,7 @@ */ package ec.nbdemetra.ui; -import javax.annotation.Nonnull; +import org.checkerframework.checker.nullness.qual.NonNull; /** * @@ -25,18 +25,18 @@ */ public abstract class AbstractConfigurable implements IConfigurable { - @Nonnull + @NonNull protected abstract B loadBean(); - protected abstract void storeBean(@Nonnull B bean); + protected abstract void storeBean(@NonNull B bean); - protected abstract boolean editBean(@Nonnull B bean); + protected abstract boolean editBean(@NonNull B bean); - @Nonnull - protected abstract Config toConfig(@Nonnull B bean); + @NonNull + protected abstract Config toConfig(@NonNull B bean); - @Nonnull - protected abstract B fromConfig(@Nonnull Config config) throws IllegalArgumentException; + @NonNull + protected abstract B fromConfig(@NonNull Config config) throws IllegalArgumentException; @Override final public Config getConfig() { diff --git a/nbdemetra-ui/src/main/java/ec/nbdemetra/ui/ActiveViewManager.java b/nbdemetra-ui/src/main/java/ec/nbdemetra/ui/ActiveViewManager.java index 6640d9fdd..363ddc54a 100644 --- a/nbdemetra-ui/src/main/java/ec/nbdemetra/ui/ActiveViewManager.java +++ b/nbdemetra-ui/src/main/java/ec/nbdemetra/ui/ActiveViewManager.java @@ -51,7 +51,7 @@ private ActiveViewManager() { public void set(IActiveView view) { if (view == null) { - content.set(Collections.EMPTY_SET, null); + content.set(Collections.emptySet(), null); //mgr.setRootContext(Node.EMPTY); } else { content.set(Collections.singleton(view), null); diff --git a/nbdemetra-ui/src/main/java/ec/nbdemetra/ui/BeanHandler.java b/nbdemetra-ui/src/main/java/ec/nbdemetra/ui/BeanHandler.java index e27a0a245..35667d6f3 100644 --- a/nbdemetra-ui/src/main/java/ec/nbdemetra/ui/BeanHandler.java +++ b/nbdemetra-ui/src/main/java/ec/nbdemetra/ui/BeanHandler.java @@ -20,7 +20,7 @@ import com.google.common.base.Converter; import ec.nbdemetra.ui.properties.IBeanEditor; import java.beans.IntrospectionException; -import javax.annotation.Nonnull; +import org.checkerframework.checker.nullness.qual.NonNull; import org.openide.util.Exceptions; /** @@ -31,18 +31,18 @@ */ public abstract class BeanHandler { - @Nonnull - public abstract B loadBean(@Nonnull R resource); + @NonNull + public abstract B loadBean(@NonNull R resource); - public abstract void storeBean(@Nonnull R resource, @Nonnull B bean); + public abstract void storeBean(@NonNull R resource, @NonNull B bean); - @Nonnull - public Configurator toConfigurator(@Nonnull Converter converter) { + @NonNull + public Configurator toConfigurator(@NonNull Converter converter) { return new ConfiguratorImpl(this, converter, DEFAULT_EDITOR); } - @Nonnull - public Configurator toConfigurator(@Nonnull Converter converter, @Nonnull IBeanEditor editor) { + @NonNull + public Configurator toConfigurator(@NonNull Converter converter, @NonNull IBeanEditor editor) { return new ConfiguratorImpl(this, converter, editor); } diff --git a/nbdemetra-ui/src/main/java/ec/nbdemetra/ui/ComponentFactory.java b/nbdemetra-ui/src/main/java/ec/nbdemetra/ui/ComponentFactory.java index c96750705..af79c8942 100644 --- a/nbdemetra-ui/src/main/java/ec/nbdemetra/ui/ComponentFactory.java +++ b/nbdemetra-ui/src/main/java/ec/nbdemetra/ui/ComponentFactory.java @@ -27,7 +27,7 @@ import ec.ui.grid.JTsGrid; import ec.ui.html.JHtmlView; import ec.ui.list.JTsList; -import javax.annotation.Nonnull; +import org.checkerframework.checker.nullness.qual.NonNull; import org.openide.util.Lookup; import org.openide.util.lookup.ServiceProvider; @@ -39,32 +39,32 @@ @ServiceProvider(service = ComponentFactory.class) public class ComponentFactory { - @Nonnull + @NonNull public static ComponentFactory getDefault() { return Lookup.getDefault().lookup(ComponentFactory.class); } - @Nonnull + @NonNull public ATsChart newTsChart() { return new JTsChart(); } - @Nonnull + @NonNull public ATsGrid newTsGrid() { return new JTsGrid(); } - @Nonnull + @NonNull public ATsGrowthChart newTsGrowthChart() { return new JTsGrowthChart(); } - @Nonnull + @NonNull public ATsList newTsList() { return new JTsList(); } - @Nonnull + @NonNull public AHtmlView newHtmlView() { return new JHtmlView(); } diff --git a/nbdemetra-ui/src/main/java/ec/nbdemetra/ui/Config.java b/nbdemetra-ui/src/main/java/ec/nbdemetra/ui/Config.java index ada816f6a..aed50578c 100644 --- a/nbdemetra-ui/src/main/java/ec/nbdemetra/ui/Config.java +++ b/nbdemetra-ui/src/main/java/ec/nbdemetra/ui/Config.java @@ -31,7 +31,7 @@ import java.util.Map; import java.util.Objects; import java.util.SortedMap; -import javax.annotation.Nonnull; +import org.checkerframework.checker.nullness.qual.NonNull; import javax.xml.bind.JAXBContext; import javax.xml.bind.JAXBException; import javax.xml.bind.annotation.XmlAttribute; @@ -107,8 +107,7 @@ public String toString() { * @return a non-null builder * @since 2.2.0 */ - @Nonnull - public Config.Builder toBuilder() { + public Config.@NonNull Builder toBuilder() { return new Builder(domain, name, version).putAll(params); } diff --git a/nbdemetra-ui/src/main/java/ec/nbdemetra/ui/Configurator.java b/nbdemetra-ui/src/main/java/ec/nbdemetra/ui/Configurator.java index 97e9726dc..37916b2b3 100644 --- a/nbdemetra-ui/src/main/java/ec/nbdemetra/ui/Configurator.java +++ b/nbdemetra-ui/src/main/java/ec/nbdemetra/ui/Configurator.java @@ -16,7 +16,7 @@ */ package ec.nbdemetra.ui; -import javax.annotation.Nonnull; +import org.checkerframework.checker.nullness.qual.NonNull; /** * @@ -25,16 +25,16 @@ */ public abstract class Configurator { - @Nonnull - abstract public Config getConfig(@Nonnull R resource); + @NonNull + abstract public Config getConfig(@NonNull R resource); - abstract public void setConfig(@Nonnull R resource, @Nonnull Config config) throws IllegalArgumentException; + abstract public void setConfig(@NonNull R resource, @NonNull Config config) throws IllegalArgumentException; - @Nonnull - abstract public Config editConfig(@Nonnull Config config) throws IllegalArgumentException; + @NonNull + abstract public Config editConfig(@NonNull Config config) throws IllegalArgumentException; - @Nonnull - public IConfigurable toConfigurable(@Nonnull R resource) { + @NonNull + public IConfigurable toConfigurable(@NonNull R resource) { return new ConfigurableImpl(this, resource); } diff --git a/nbdemetra-ui/src/main/java/ec/nbdemetra/ui/DemetraUI.java b/nbdemetra-ui/src/main/java/ec/nbdemetra/ui/DemetraUI.java index 47a53319c..f600ea634 100644 --- a/nbdemetra-ui/src/main/java/ec/nbdemetra/ui/DemetraUI.java +++ b/nbdemetra-ui/src/main/java/ec/nbdemetra/ui/DemetraUI.java @@ -47,7 +47,7 @@ import java.util.Collection; import java.util.List; import java.util.function.Function; -import javax.annotation.Nonnull; +import org.checkerframework.checker.nullness.qual.NonNull; import javax.swing.Icon; import org.netbeans.api.options.OptionsDisplayer; import org.openide.util.Lookup; @@ -62,13 +62,13 @@ @ServiceProvider(service = DemetraUI.class) public class DemetraUI extends ListenableBean implements IConfigurable { - @Nonnull + @NonNull public static DemetraUI getDefault() { return Lookup.getDefault().lookup(DemetraUI.class); } @Deprecated - @Nonnull + @NonNull public static DemetraUI getInstance() { return getDefault(); } diff --git a/nbdemetra-ui/src/main/java/ec/nbdemetra/ui/DocumentUIServices.java b/nbdemetra-ui/src/main/java/ec/nbdemetra/ui/DocumentUIServices.java index 3802542dd..bb7795ec7 100644 --- a/nbdemetra-ui/src/main/java/ec/nbdemetra/ui/DocumentUIServices.java +++ b/nbdemetra-ui/src/main/java/ec/nbdemetra/ui/DocumentUIServices.java @@ -13,7 +13,7 @@ import ec.ui.view.tsprocessing.IProcDocumentView; import java.util.HashMap; import java.util.Map; -import javax.annotation.Nonnull; +import org.checkerframework.checker.nullness.qual.NonNull; import javax.swing.JComponent; import org.openide.util.Lookup; import org.openide.util.lookup.ServiceProvider; @@ -26,7 +26,7 @@ @ServiceProvider(service = DocumentUIServices.class) public class DocumentUIServices { - @Nonnull + @NonNull public static DocumentUIServices getDefault() { return Lookup.getDefault().lookup(DocumentUIServices.class); } diff --git a/nbdemetra-ui/src/main/java/ec/nbdemetra/ui/IConfigurable.java b/nbdemetra-ui/src/main/java/ec/nbdemetra/ui/IConfigurable.java index e2dd6398a..7a31a934c 100644 --- a/nbdemetra-ui/src/main/java/ec/nbdemetra/ui/IConfigurable.java +++ b/nbdemetra-ui/src/main/java/ec/nbdemetra/ui/IConfigurable.java @@ -16,7 +16,7 @@ */ package ec.nbdemetra.ui; -import javax.annotation.Nonnull; +import org.checkerframework.checker.nullness.qual.NonNull; /** * @@ -24,11 +24,11 @@ */ public interface IConfigurable { - @Nonnull + @NonNull Config getConfig(); - void setConfig(@Nonnull Config config) throws IllegalArgumentException; + void setConfig(@NonNull Config config) throws IllegalArgumentException; - @Nonnull - Config editConfig(@Nonnull Config config) throws IllegalArgumentException; + @NonNull + Config editConfig(@NonNull Config config) throws IllegalArgumentException; } diff --git a/nbdemetra-ui/src/main/java/ec/nbdemetra/ui/MonikerUI.java b/nbdemetra-ui/src/main/java/ec/nbdemetra/ui/MonikerUI.java index 8fe218480..ff0947126 100644 --- a/nbdemetra-ui/src/main/java/ec/nbdemetra/ui/MonikerUI.java +++ b/nbdemetra-ui/src/main/java/ec/nbdemetra/ui/MonikerUI.java @@ -24,8 +24,8 @@ import ec.tss.tsproviders.DataSource; import java.awt.Image; import java.beans.BeanInfo; -import javax.annotation.Nonnull; -import javax.annotation.Nullable; +import org.checkerframework.checker.nullness.qual.NonNull; +import org.checkerframework.checker.nullness.qual.Nullable; import javax.swing.Icon; import org.openide.util.ImageUtilities; import org.openide.util.Lookup; @@ -40,13 +40,13 @@ @ServiceProvider(service = MonikerUI.class) public class MonikerUI { - @Nonnull + @NonNull public static MonikerUI getDefault() { return Lookup.getDefault().lookup(MonikerUI.class); } @Nullable - public Icon getIcon(@Nonnull TsMoniker moniker) { + public Icon getIcon(@NonNull TsMoniker moniker) { return DataSourceProviderBuddySupport.getDefault() .getIcon(moniker, BeanInfo.ICON_COLOR_16x16, false) .map(ImageUtilities::image2Icon) diff --git a/nbdemetra-ui/src/main/java/ec/nbdemetra/ui/NbComponents.java b/nbdemetra-ui/src/main/java/ec/nbdemetra/ui/NbComponents.java index d8e554fdd..bf7d926b3 100644 --- a/nbdemetra-ui/src/main/java/ec/nbdemetra/ui/NbComponents.java +++ b/nbdemetra-ui/src/main/java/ec/nbdemetra/ui/NbComponents.java @@ -19,8 +19,8 @@ import ec.util.various.swing.ModernUI; import java.awt.Component; import java.awt.Toolkit; -import javax.annotation.Nonnull; -import javax.annotation.Nullable; +import org.checkerframework.checker.nullness.qual.NonNull; +import org.checkerframework.checker.nullness.qual.Nullable; import javax.swing.*; import javax.swing.border.Border; import org.openide.awt.Toolbar; @@ -43,7 +43,7 @@ public static boolean isXPTheme() { return isXP == null ? false : isXP; } - @Nonnull + @NonNull public static JToolBar newInnerToolbar() { JToolBar result = new Toolbar(); Border b = (Border) UIManager.get("Nb.Editor.Toolbar.border"); //NOI18N @@ -58,33 +58,33 @@ public static JToolBar newInnerToolbar() { return result; } - @Nonnull + @NonNull public static JScrollPane newJScrollPane() { return ModernUI.withEmptyBorders(new JScrollPane()); } - @Nonnull - public static JScrollPane newJScrollPane(@Nonnull Component view) { + @NonNull + public static JScrollPane newJScrollPane(@NonNull Component view) { return ModernUI.withEmptyBorders(new JScrollPane(view)); } - @Nonnull + @NonNull public static JSplitPane newJSplitPane(int orientation) { return ModernUI.withEmptyBorders(new JSplitPane(orientation)); } - @Nonnull - public static JSplitPane newJSplitPane(int orientation, @Nonnull Component left, @Nonnull Component right) { + @NonNull + public static JSplitPane newJSplitPane(int orientation, @NonNull Component left, @NonNull Component right) { return ModernUI.withEmptyBorders(new JSplitPane(orientation, left, right)); } - @Nonnull - public static JSplitPane newJSplitPane(int orientation, boolean continuousLayout, @Nonnull Component left, @Nonnull Component right) { + @NonNull + public static JSplitPane newJSplitPane(int orientation, boolean continuousLayout, @NonNull Component left, @NonNull Component right) { return ModernUI.withEmptyBorders(new JSplitPane(orientation, continuousLayout, left, right)); } @Nullable - public static T findTopComponentByNameAndClass(@Nonnull String name, @Nonnull Class clazz) { + public static T findTopComponentByNameAndClass(@NonNull String name, @NonNull Class clazz) { for (TopComponent o : TopComponent.getRegistry().getOpened()) { if (o.getName().equals(name) && clazz.isInstance(o)) { return (T) o; @@ -94,7 +94,7 @@ public static T findTopComponentByNameAndClass(@Nonnull } @Nullable - public static TopComponent findTopComponentByName(@Nonnull String name) { + public static TopComponent findTopComponentByName(@NonNull String name) { return findTopComponentByNameAndClass(name, TopComponent.class); } } diff --git a/nbdemetra-ui/src/main/java/ec/nbdemetra/ui/SingleFileExporter.java b/nbdemetra-ui/src/main/java/ec/nbdemetra/ui/SingleFileExporter.java index 8c129c492..aca4fb4ef 100644 --- a/nbdemetra-ui/src/main/java/ec/nbdemetra/ui/SingleFileExporter.java +++ b/nbdemetra-ui/src/main/java/ec/nbdemetra/ui/SingleFileExporter.java @@ -27,7 +27,7 @@ import java.util.function.BiConsumer; import java.util.function.Consumer; import java.util.function.Supplier; -import javax.annotation.Nonnull; +import org.checkerframework.checker.nullness.qual.NonNull; import javax.swing.SwingUtilities; import org.netbeans.api.progress.ProgressHandle; import org.openide.DialogDisplayer; @@ -53,55 +53,55 @@ public SingleFileExporter() { this.success = f -> notifySuccess(f, "Export succeeded"); } - @Nonnull - public SingleFileExporter fileChooser(@Nonnull Supplier fileChooser) { + @NonNull + public SingleFileExporter fileChooser(@NonNull Supplier fileChooser) { this.fileChooser = Objects.requireNonNull(fileChooser); return this; } - @Nonnull - public SingleFileExporter file(@Nonnull File file) { + @NonNull + public SingleFileExporter file(@NonNull File file) { Objects.requireNonNull(file); return fileChooser(() -> file); } - @Nonnull - public SingleFileExporter progressHandle(@Nonnull Supplier progressHandle) { + @NonNull + public SingleFileExporter progressHandle(@NonNull Supplier progressHandle) { this.progressHandle = Objects.requireNonNull(progressHandle); return this; } - @Nonnull - public SingleFileExporter progressLabel(@Nonnull String displayName) { + @NonNull + public SingleFileExporter progressLabel(@NonNull String displayName) { Objects.requireNonNull(displayName); return progressHandle(() -> ProgressHandle.createHandle(displayName)); } - @Nonnull - public SingleFileExporter onError(@Nonnull BiConsumer error) { + @NonNull + public SingleFileExporter onError(@NonNull BiConsumer error) { this.error = Objects.requireNonNull(error); return this; } - @Nonnull - public SingleFileExporter onErrorNotify(@Nonnull String message) { + @NonNull + public SingleFileExporter onErrorNotify(@NonNull String message) { Objects.requireNonNull(message); return onError((f, t) -> notifyError(f, t, message)); } - @Nonnull - public SingleFileExporter onSussess(@Nonnull Consumer success) { + @NonNull + public SingleFileExporter onSussess(@NonNull Consumer success) { this.success = Objects.requireNonNull(success); return this; } - @Nonnull - public SingleFileExporter onSussessNotify(@Nonnull String message) { + @NonNull + public SingleFileExporter onSussessNotify(@NonNull String message) { Objects.requireNonNull(message); return onSussess(f -> notifySuccess(f, message)); } - public void execAsync(@Nonnull SingleFileTask task) { + public void execAsync(@NonNull SingleFileTask task) { Objects.requireNonNull(task); File file = fileChooser.get(); if (file != null) { @@ -141,8 +141,8 @@ private static void notifyError(File file, Throwable t, String message) { NotifyUtil.error(message, getMessageOrElseType(t), t); } - @Nonnull - private static String getMessageOrElseType(@Nonnull Throwable t) { + @NonNull + private static String getMessageOrElseType(@NonNull Throwable t) { String msg = t.getMessage(); return msg != null ? t.getMessage() : t.getClass().getSimpleName(); } @@ -155,8 +155,7 @@ private static Throwable unwrapException(Throwable ex, Class o.isInstance(ex)) ? unwrapException(ex.getCause(), types) : ex; } - @Nonnull - public static FileChooserBuilder.SelectionApprover overwriteApprover() { + public static FileChooserBuilder.@NonNull SelectionApprover overwriteApprover() { return new SaveSelectionApprover(); } diff --git a/nbdemetra-ui/src/main/java/ec/nbdemetra/ui/ThemeSupport.java b/nbdemetra-ui/src/main/java/ec/nbdemetra/ui/ThemeSupport.java index b6bf60e16..48b0358aa 100644 --- a/nbdemetra-ui/src/main/java/ec/nbdemetra/ui/ThemeSupport.java +++ b/nbdemetra-ui/src/main/java/ec/nbdemetra/ui/ThemeSupport.java @@ -15,7 +15,7 @@ import java.util.HashMap; import java.util.Map; import java.util.Objects; -import javax.annotation.Nullable; +import org.checkerframework.checker.nullness.qual.Nullable; import org.openide.util.WeakListeners; /** diff --git a/nbdemetra-ui/src/main/java/ec/nbdemetra/ui/awt/ActionMaps.java b/nbdemetra-ui/src/main/java/ec/nbdemetra/ui/awt/ActionMaps.java index ad164dcb2..21d376b60 100644 --- a/nbdemetra-ui/src/main/java/ec/nbdemetra/ui/awt/ActionMaps.java +++ b/nbdemetra-ui/src/main/java/ec/nbdemetra/ui/awt/ActionMaps.java @@ -25,7 +25,7 @@ import java.util.Map; import java.util.Set; import java.util.stream.Collectors; -import javax.annotation.Nonnull; +import org.checkerframework.checker.nullness.qual.NonNull; import javax.swing.Action; import javax.swing.ActionMap; @@ -39,8 +39,8 @@ private ActionMaps() { // static class } - @Nonnull - public static ActionMap getRoot(@Nonnull ActionMap actionMap) { + @NonNull + public static ActionMap getRoot(@NonNull ActionMap actionMap) { ActionMap result = actionMap; while (result.getParent() != null) { result = result.getParent(); @@ -48,16 +48,16 @@ public static ActionMap getRoot(@Nonnull ActionMap actionMap) { return result; } - @Nonnull - public static Map asMap(@Nonnull ActionMap actionMap, boolean includeParentKeys) { + @NonNull + public static Map asMap(@NonNull ActionMap actionMap, boolean includeParentKeys) { return asKeySet(actionMap, includeParentKeys).stream().collect(Collectors.toMap(o -> o, o -> actionMap.get(o))); } - public static void copyEntries(@Nonnull ActionMap source, boolean includeParentKeys, @Nonnull ActionMap destination) { + public static void copyEntries(@NonNull ActionMap source, boolean includeParentKeys, @NonNull ActionMap destination) { asMap(source, includeParentKeys).forEach((k, v) -> destination.put(k, v)); } - public static void performAction(@Nonnull ActionMap actionMap, @Nonnull String actionName, @Nonnull MouseEvent e) { + public static void performAction(@NonNull ActionMap actionMap, @NonNull String actionName, @NonNull MouseEvent e) { Action action = actionMap.get(actionName); if (action != null && action.isEnabled()) { action.actionPerformed(new ActionEvent(e.getSource(), ActionEvent.ACTION_PERFORMED, actionName)); @@ -65,8 +65,8 @@ public static void performAction(@Nonnull ActionMap actionMap, @Nonnull String a } // - @Nonnull - private static Set asKeySet(final @Nonnull ActionMap actionMap, final boolean includeParentKeys) { + @NonNull + private static Set asKeySet(final @NonNull ActionMap actionMap, final boolean includeParentKeys) { return new AbstractSet() { @Override public Iterator iterator() { diff --git a/nbdemetra-ui/src/main/java/ec/nbdemetra/ui/awt/IPropertyChangeSource.java b/nbdemetra-ui/src/main/java/ec/nbdemetra/ui/awt/IPropertyChangeSource.java index bf072b6fc..450a6d1b1 100644 --- a/nbdemetra-ui/src/main/java/ec/nbdemetra/ui/awt/IPropertyChangeSource.java +++ b/nbdemetra-ui/src/main/java/ec/nbdemetra/ui/awt/IPropertyChangeSource.java @@ -17,7 +17,7 @@ package ec.nbdemetra.ui.awt; import java.beans.PropertyChangeListener; -import javax.annotation.Nonnull; +import org.checkerframework.checker.nullness.qual.NonNull; /** * @@ -25,11 +25,11 @@ */ public interface IPropertyChangeSource { - void addPropertyChangeListener(@Nonnull String propertyName, @Nonnull PropertyChangeListener listener); + void addPropertyChangeListener(@NonNull String propertyName, @NonNull PropertyChangeListener listener); - void addPropertyChangeListener(@Nonnull PropertyChangeListener listener); + void addPropertyChangeListener(@NonNull PropertyChangeListener listener); - void removePropertyChangeListener(@Nonnull String propertyName, @Nonnull PropertyChangeListener listener); + void removePropertyChangeListener(@NonNull String propertyName, @NonNull PropertyChangeListener listener); - void removePropertyChangeListener(@Nonnull PropertyChangeListener listener); + void removePropertyChangeListener(@NonNull PropertyChangeListener listener); } diff --git a/nbdemetra-ui/src/main/java/ec/nbdemetra/ui/awt/InputMaps.java b/nbdemetra-ui/src/main/java/ec/nbdemetra/ui/awt/InputMaps.java index aa13654e3..a276b9bef 100644 --- a/nbdemetra-ui/src/main/java/ec/nbdemetra/ui/awt/InputMaps.java +++ b/nbdemetra-ui/src/main/java/ec/nbdemetra/ui/awt/InputMaps.java @@ -23,7 +23,7 @@ import java.util.Map; import java.util.Set; import java.util.stream.Collectors; -import javax.annotation.Nonnull; +import org.checkerframework.checker.nullness.qual.NonNull; import javax.swing.InputMap; import javax.swing.KeyStroke; @@ -37,8 +37,8 @@ private InputMaps() { // static class } - @Nonnull - public static InputMap getRoot(@Nonnull InputMap inputMap) { + @NonNull + public static InputMap getRoot(@NonNull InputMap inputMap) { InputMap result = inputMap; while (result.getParent() != null) { result = result.getParent(); @@ -46,18 +46,18 @@ public static InputMap getRoot(@Nonnull InputMap inputMap) { return result; } - @Nonnull - public static Map asMap(@Nonnull InputMap inputMap, boolean includeParentKeys) { + @NonNull + public static Map asMap(@NonNull InputMap inputMap, boolean includeParentKeys) { return asKeySet(inputMap, includeParentKeys).stream().collect(Collectors.toMap(o -> o, o -> inputMap.get(o))); } - public static void copyEntries(@Nonnull InputMap source, boolean includeParentKeys, @Nonnull InputMap destination) { + public static void copyEntries(@NonNull InputMap source, boolean includeParentKeys, @NonNull InputMap destination) { asMap(source, includeParentKeys).forEach((k, v) -> destination.put(k, v)); } // - @Nonnull - private static Set asKeySet(final @Nonnull InputMap inputMap, final boolean includeParentKeys) { + @NonNull + private static Set asKeySet(final @NonNull InputMap inputMap, final boolean includeParentKeys) { return new AbstractSet() { @Override public Iterator iterator() { diff --git a/nbdemetra-ui/src/main/java/ec/nbdemetra/ui/awt/ShowInFolderActionListener.java b/nbdemetra-ui/src/main/java/ec/nbdemetra/ui/awt/ShowInFolderActionListener.java index 3e89ba402..ab575acc2 100644 --- a/nbdemetra-ui/src/main/java/ec/nbdemetra/ui/awt/ShowInFolderActionListener.java +++ b/nbdemetra-ui/src/main/java/ec/nbdemetra/ui/awt/ShowInFolderActionListener.java @@ -22,7 +22,7 @@ import java.awt.event.ActionListener; import java.io.File; import java.io.IOException; -import javax.annotation.Nonnull; +import org.checkerframework.checker.nullness.qual.NonNull; import org.openide.util.Exceptions; /** @@ -32,8 +32,8 @@ */ public final class ShowInFolderActionListener implements ActionListener { - @Nonnull - public static ShowInFolderActionListener of(@Nonnull File file) { + @NonNull + public static ShowInFolderActionListener of(@NonNull File file) { return new ShowInFolderActionListener(DesktopManager.get(), file); } diff --git a/nbdemetra-ui/src/main/java/ec/nbdemetra/ui/awt/SimpleHtmlListCellRenderer.java b/nbdemetra-ui/src/main/java/ec/nbdemetra/ui/awt/SimpleHtmlListCellRenderer.java index d1014f02c..11fb80cd9 100644 --- a/nbdemetra-ui/src/main/java/ec/nbdemetra/ui/awt/SimpleHtmlListCellRenderer.java +++ b/nbdemetra-ui/src/main/java/ec/nbdemetra/ui/awt/SimpleHtmlListCellRenderer.java @@ -5,7 +5,7 @@ package ec.nbdemetra.ui.awt; import java.awt.Component; -import javax.annotation.Nonnull; +import org.checkerframework.checker.nullness.qual.NonNull; import javax.swing.JList; import javax.swing.ListCellRenderer; import org.openide.awt.HtmlRenderer; @@ -19,7 +19,7 @@ public class SimpleHtmlListCellRenderer implements ListCellRenderer { protected final HtmlProvider htmlProvider; protected final HtmlRenderer.Renderer htmlRenderer; - public SimpleHtmlListCellRenderer(@Nonnull HtmlProvider htmlProvider) { + public SimpleHtmlListCellRenderer(@NonNull HtmlProvider htmlProvider) { this.htmlProvider = htmlProvider; this.htmlRenderer = HtmlRenderer.createRenderer(); } diff --git a/nbdemetra-ui/src/main/java/ec/nbdemetra/ui/completion/JAutoCompletionService.java b/nbdemetra-ui/src/main/java/ec/nbdemetra/ui/completion/JAutoCompletionService.java index 481760f01..9ef100ee9 100644 --- a/nbdemetra-ui/src/main/java/ec/nbdemetra/ui/completion/JAutoCompletionService.java +++ b/nbdemetra-ui/src/main/java/ec/nbdemetra/ui/completion/JAutoCompletionService.java @@ -18,7 +18,7 @@ import ec.tstoolkit.design.ServiceDefinition; import ec.util.completion.swing.JAutoCompletion; -import javax.annotation.Nonnull; +import org.checkerframework.checker.nullness.qual.NonNull; import javax.swing.text.JTextComponent; import org.openide.util.lookup.Lookups; @@ -30,16 +30,16 @@ @ServiceDefinition public abstract class JAutoCompletionService { - @Nonnull - abstract public JAutoCompletion bind(@Nonnull JTextComponent textComponent); + @NonNull + abstract public JAutoCompletion bind(@NonNull JTextComponent textComponent); // public static final String LOCALE_PATH = "JAutoCompletionService/Locale"; public static final String DATE_PATTERN_PATH = "JAutoCompletionService/DatePattern"; public static final String COLOR_SCHEME_PATH = "JAutoCompletionService/ColorScheme"; public static final String CHARSET_PATH = "JAutoCompletionService/Charset"; - @Nonnull - public static JAutoCompletion forPathBind(@Nonnull String path, @Nonnull JTextComponent textComponent) { + @NonNull + public static JAutoCompletion forPathBind(@NonNull String path, @NonNull JTextComponent textComponent) { JAutoCompletionService o = Lookups.forPath(path).lookup(JAutoCompletionService.class); return o != null ? o.bind(textComponent) : new JAutoCompletion(textComponent); } diff --git a/nbdemetra-ui/src/main/java/ec/nbdemetra/ui/interchange/ExportAction.java b/nbdemetra-ui/src/main/java/ec/nbdemetra/ui/interchange/ExportAction.java index 7b6258096..49c6fe42d 100644 --- a/nbdemetra-ui/src/main/java/ec/nbdemetra/ui/interchange/ExportAction.java +++ b/nbdemetra-ui/src/main/java/ec/nbdemetra/ui/interchange/ExportAction.java @@ -21,7 +21,7 @@ import java.awt.event.ActionEvent; import java.io.IOException; import java.util.List; -import javax.annotation.Nonnull; +import org.checkerframework.checker.nullness.qual.NonNull; import javax.swing.AbstractAction; import javax.swing.JMenu; import javax.swing.JMenuItem; @@ -67,8 +67,8 @@ private static List getExportables(Node[] activatedNodes) { .toList(); } - @Nonnull - public static JMenuItem getPopupPresenter(@Nonnull List exportables) { + @NonNull + public static JMenuItem getPopupPresenter(@NonNull List exportables) { JMenu result = new JMenu(); result.setText(Bundle.CTL_ExportAction()); for (InterchangeBroker o : Lookup.getDefault().lookupAll(InterchangeBroker.class)) { diff --git a/nbdemetra-ui/src/main/java/ec/nbdemetra/ui/interchange/Exportable.java b/nbdemetra-ui/src/main/java/ec/nbdemetra/ui/interchange/Exportable.java index 076bfc24e..6ce8c0f68 100644 --- a/nbdemetra-ui/src/main/java/ec/nbdemetra/ui/interchange/Exportable.java +++ b/nbdemetra-ui/src/main/java/ec/nbdemetra/ui/interchange/Exportable.java @@ -18,7 +18,7 @@ import ec.nbdemetra.ui.Config; import ec.util.various.swing.OnEDT; -import javax.annotation.Nonnull; +import org.checkerframework.checker.nullness.qual.NonNull; /** * Defines the ability of a component to export its state/configuration. @@ -33,7 +33,7 @@ public interface Exportable { * @return a non-null config */ @OnEDT - @Nonnull + @NonNull Config exportConfig(); } diff --git a/nbdemetra-ui/src/main/java/ec/nbdemetra/ui/interchange/ImportAction.java b/nbdemetra-ui/src/main/java/ec/nbdemetra/ui/interchange/ImportAction.java index 97603d8a4..ea6de62c7 100644 --- a/nbdemetra-ui/src/main/java/ec/nbdemetra/ui/interchange/ImportAction.java +++ b/nbdemetra-ui/src/main/java/ec/nbdemetra/ui/interchange/ImportAction.java @@ -22,7 +22,7 @@ import java.awt.event.ActionEvent; import java.io.IOException; import java.util.List; -import javax.annotation.Nonnull; +import org.checkerframework.checker.nullness.qual.NonNull; import javax.swing.AbstractAction; import javax.swing.JMenu; import javax.swing.JMenuItem; @@ -74,8 +74,8 @@ private static List getImportables(Node[] activatedNodes) { .toList(); } - @Nonnull - public static JMenuItem getPopupPresenter(@Nonnull List importables) { + @NonNull + public static JMenuItem getPopupPresenter(@NonNull List importables) { JMenu result = new JMenu(); result.setText(Bundle.CTL_ImportAction()); for (InterchangeBroker o : Lookup.getDefault().lookupAll(InterchangeBroker.class)) { diff --git a/nbdemetra-ui/src/main/java/ec/nbdemetra/ui/interchange/Importable.java b/nbdemetra-ui/src/main/java/ec/nbdemetra/ui/interchange/Importable.java index ac5bd18dc..9c331aa27 100644 --- a/nbdemetra-ui/src/main/java/ec/nbdemetra/ui/interchange/Importable.java +++ b/nbdemetra-ui/src/main/java/ec/nbdemetra/ui/interchange/Importable.java @@ -18,7 +18,7 @@ import ec.nbdemetra.ui.Config; import ec.util.various.swing.OnEDT; -import javax.annotation.Nonnull; +import org.checkerframework.checker.nullness.qual.NonNull; /** * Defines the ability of a component to import a previous state/configuration. @@ -33,7 +33,7 @@ public interface Importable { * @return a non-null domain */ @OnEDT - @Nonnull + @NonNull String getDomain(); /** @@ -43,6 +43,6 @@ public interface Importable { * @throws IllegalArgumentException if the config cannot be parsed */ @OnEDT - void importConfig(@Nonnull Config config) throws IllegalArgumentException; + void importConfig(@NonNull Config config) throws IllegalArgumentException; } diff --git a/nbdemetra-ui/src/main/java/ec/nbdemetra/ui/interchange/InterchangeBroker.java b/nbdemetra-ui/src/main/java/ec/nbdemetra/ui/interchange/InterchangeBroker.java index 009590b4a..20510ebe2 100644 --- a/nbdemetra-ui/src/main/java/ec/nbdemetra/ui/interchange/InterchangeBroker.java +++ b/nbdemetra-ui/src/main/java/ec/nbdemetra/ui/interchange/InterchangeBroker.java @@ -23,7 +23,7 @@ import java.awt.Image; import java.io.IOException; import java.util.List; -import javax.annotation.Nonnull; +import org.checkerframework.checker.nullness.qual.NonNull; import org.openide.util.ImageUtilities; /** @@ -41,22 +41,22 @@ public Image getIcon(int type, boolean opened) { } @OnEDT - public boolean canImport(@Nonnull List importables) { + public boolean canImport(@NonNull List importables) { return false; } @OnEDT - public void performImport(@Nonnull List importables) throws IOException, IllegalArgumentException { + public void performImport(@NonNull List importables) throws IOException, IllegalArgumentException { throw new UnsupportedOperationException(); } @OnEDT - public boolean canExport(@Nonnull List exportables) { + public boolean canExport(@NonNull List exportables) { return false; } @OnEDT - public void performExport(@Nonnull List exportables) throws IOException { + public void performExport(@NonNull List exportables) throws IOException { throw new UnsupportedOperationException(); } } diff --git a/nbdemetra-ui/src/main/java/ec/nbdemetra/ui/interchange/impl/ClipboardBroker.java b/nbdemetra-ui/src/main/java/ec/nbdemetra/ui/interchange/impl/ClipboardBroker.java index 7c091ff2d..61472f60d 100644 --- a/nbdemetra-ui/src/main/java/ec/nbdemetra/ui/interchange/impl/ClipboardBroker.java +++ b/nbdemetra-ui/src/main/java/ec/nbdemetra/ui/interchange/impl/ClipboardBroker.java @@ -27,7 +27,7 @@ import java.awt.datatransfer.UnsupportedFlavorException; import java.io.IOException; import java.util.List; -import javax.annotation.Nonnull; +import org.checkerframework.checker.nullness.qual.NonNull; import org.openide.util.lookup.ServiceProvider; /** @@ -77,8 +77,8 @@ public void performExport(List exportables) throws IOExcep store(getClipboard(), configs); } - @Nonnull - private static Configs load(@Nonnull Clipboard clipboard) throws IOException { + @NonNull + private static Configs load(@NonNull Clipboard clipboard) throws IOException { String xml = readString(clipboard); if (xml == null) { throw new IOException("Not string input"); @@ -90,7 +90,7 @@ private static Configs load(@Nonnull Clipboard clipboard) throws IOException { return result; } - private static void store(@Nonnull Clipboard clipboard, @Nonnull Configs configs) throws IOException { + private static void store(@NonNull Clipboard clipboard, @NonNull Configs configs) throws IOException { String xml = Configs.xmlFormatter(true).formatAsString(configs); if (xml == null) { throw new IOException("Cannot format configs"); @@ -98,7 +98,7 @@ private static void store(@Nonnull Clipboard clipboard, @Nonnull Configs configs clipboard.setContents(new StringSelection(xml), null); } - private static String readString(@Nonnull Clipboard clipboard) throws IOException { + private static String readString(@NonNull Clipboard clipboard) throws IOException { if (clipboard.isDataFlavorAvailable(DataFlavor.stringFlavor)) { try { return (String) clipboard.getData(DataFlavor.stringFlavor); diff --git a/nbdemetra-ui/src/main/java/ec/nbdemetra/ui/interchange/impl/Configs.java b/nbdemetra-ui/src/main/java/ec/nbdemetra/ui/interchange/impl/Configs.java index 15f831d97..a5e91b3c6 100644 --- a/nbdemetra-ui/src/main/java/ec/nbdemetra/ui/interchange/impl/Configs.java +++ b/nbdemetra-ui/src/main/java/ec/nbdemetra/ui/interchange/impl/Configs.java @@ -30,7 +30,7 @@ import ec.tstoolkit.design.VisibleForTesting; import java.io.IOException; import java.util.List; -import javax.annotation.Nonnull; +import org.checkerframework.checker.nullness.qual.NonNull; import javax.xml.bind.JAXBContext; import javax.xml.bind.JAXBException; import javax.xml.bind.annotation.XmlAttribute; @@ -57,7 +57,7 @@ public final class Configs { this.items = items; } - @Nonnull + @NonNull public String getAuthor() { return author; } @@ -66,7 +66,7 @@ public long getCreationTime() { return creationTime; } - @Nonnull + @NonNull public List getItems() { return items; } @@ -80,13 +80,11 @@ ConfigsBean toBean() { return result; } - @Nonnull - public static Formatters.Formatter xmlFormatter(boolean formattedOutput) { + public static Formatters.@NonNull Formatter xmlFormatter(boolean formattedOutput) { return formattedOutput ? XML.get().formattedOutputFormatter : XML.get().defaultFormatter; } - @Nonnull - public static Parsers.Parser xmlParser() { + public static Parsers.@NonNull Parser xmlParser() { return XML.get().defaultParser; } diff --git a/nbdemetra-ui/src/main/java/ec/nbdemetra/ui/interchange/impl/FileBroker.java b/nbdemetra-ui/src/main/java/ec/nbdemetra/ui/interchange/impl/FileBroker.java index 4aab72737..9c25b4063 100644 --- a/nbdemetra-ui/src/main/java/ec/nbdemetra/ui/interchange/impl/FileBroker.java +++ b/nbdemetra-ui/src/main/java/ec/nbdemetra/ui/interchange/impl/FileBroker.java @@ -34,7 +34,7 @@ import java.util.Locale; import java.util.zip.GZIPInputStream; import java.util.zip.GZIPOutputStream; -import javax.annotation.Nonnull; +import org.checkerframework.checker.nullness.qual.NonNull; import javax.swing.JFileChooser; import javax.swing.filechooser.FileNameExtensionFilter; import org.openide.filesystems.FileChooserBuilder; @@ -98,8 +98,8 @@ private File enforceExtension(File input) { return index != -1 ? input : new File(input.getPath() + ".cfgx"); } - @Nonnull - public static Configs load(@Nonnull Path file) throws IOException { + @NonNull + public static Configs load(@NonNull Path file) throws IOException { CharSequence xml = readGZIP(file); Configs result = Configs.xmlParser().parse(xml); if (result == null) { @@ -108,7 +108,7 @@ public static Configs load(@Nonnull Path file) throws IOException { return result; } - public static void store(@Nonnull Path file, @Nonnull Configs configs) throws IOException { + public static void store(@NonNull Path file, @NonNull Configs configs) throws IOException { CharSequence xml = Configs.xmlFormatter(true).format(configs); if (xml == null) { throw new IOException("Cannot format configs"); diff --git a/nbdemetra-ui/src/main/java/ec/nbdemetra/ui/interchange/impl/MailBroker.java b/nbdemetra-ui/src/main/java/ec/nbdemetra/ui/interchange/impl/MailBroker.java index 0553ac2c2..296fb1b7b 100644 --- a/nbdemetra-ui/src/main/java/ec/nbdemetra/ui/interchange/impl/MailBroker.java +++ b/nbdemetra-ui/src/main/java/ec/nbdemetra/ui/interchange/impl/MailBroker.java @@ -23,7 +23,7 @@ import ec.util.desktop.MailtoBuilder; import java.io.IOException; import java.util.List; -import javax.annotation.Nonnull; +import org.checkerframework.checker.nullness.qual.NonNull; import org.openide.util.lookup.ServiceProvider; /** @@ -53,7 +53,7 @@ public void performExport(List exportables) throws IOExcep store(getDesktop(), configs); } - private static void store(@Nonnull Desktop desktop, @Nonnull Configs configs) throws IOException { + private static void store(@NonNull Desktop desktop, @NonNull Configs configs) throws IOException { String subject = configs.getItems().size() == 1 ? configs.getItems().get(0).getName() : "Configs"; String body = Configs.xmlFormatter(true).formatValueAsString(configs).orElseThrow(RuntimeException::new); desktop.mail(new MailtoBuilder().subject(subject).body(body).build()); diff --git a/nbdemetra-ui/src/main/java/ec/nbdemetra/ui/nodes/ControlNode.java b/nbdemetra-ui/src/main/java/ec/nbdemetra/ui/nodes/ControlNode.java index a249a0070..c945c2231 100644 --- a/nbdemetra-ui/src/main/java/ec/nbdemetra/ui/nodes/ControlNode.java +++ b/nbdemetra-ui/src/main/java/ec/nbdemetra/ui/nodes/ControlNode.java @@ -31,7 +31,7 @@ import java.util.HashSet; import java.util.Map; import java.util.Optional; -import javax.annotation.Nonnull; +import org.checkerframework.checker.nullness.qual.NonNull; import org.openide.explorer.ExplorerManager; import org.openide.nodes.AbstractNode; import org.openide.nodes.Children; @@ -230,8 +230,7 @@ private static Sheet.Set getMetaSheetSet(TsCollection col, NodePropertySetBuilde return b.build(); } - @Nonnull - public static Sheet.Set getDefinitionSheetSet(@Nonnull Ts ts, @Nonnull NodePropertySetBuilder b) { + public static Sheet.@NonNull Set getDefinitionSheetSet(@NonNull Ts ts, @NonNull NodePropertySetBuilder b) { b.reset("Time series"); b.with(String.class) diff --git a/nbdemetra-ui/src/main/java/ec/nbdemetra/ui/nodes/ExceptionNode.java b/nbdemetra-ui/src/main/java/ec/nbdemetra/ui/nodes/ExceptionNode.java index 7da1cbe4a..1e5a9f452 100644 --- a/nbdemetra-ui/src/main/java/ec/nbdemetra/ui/nodes/ExceptionNode.java +++ b/nbdemetra-ui/src/main/java/ec/nbdemetra/ui/nodes/ExceptionNode.java @@ -23,7 +23,7 @@ import java.awt.Image; import java.awt.KeyboardFocusManager; import java.awt.event.ActionEvent; -import javax.annotation.Nonnull; +import org.checkerframework.checker.nullness.qual.NonNull; import javax.swing.AbstractAction; import javax.swing.Action; import org.openide.DialogDisplayer; @@ -44,7 +44,7 @@ public class ExceptionNode extends AbstractNode { private static int internalCounter = 0; - public ExceptionNode(@Nonnull Exception ex) { + public ExceptionNode(@NonNull Exception ex) { super(Children.LEAF, Lookups.fixed(ex, internalCounter++)); } diff --git a/nbdemetra-ui/src/main/java/ec/nbdemetra/ui/nodes/FailSafeChildFactory.java b/nbdemetra-ui/src/main/java/ec/nbdemetra/ui/nodes/FailSafeChildFactory.java index c9b309f5d..80994ece8 100644 --- a/nbdemetra-ui/src/main/java/ec/nbdemetra/ui/nodes/FailSafeChildFactory.java +++ b/nbdemetra-ui/src/main/java/ec/nbdemetra/ui/nodes/FailSafeChildFactory.java @@ -19,8 +19,8 @@ import ec.util.various.swing.OnAnyThread; import ec.util.various.swing.OnEDT; import java.util.List; -import javax.annotation.Nonnull; -import javax.annotation.Nullable; +import org.checkerframework.checker.nullness.qual.NonNull; +import org.checkerframework.checker.nullness.qual.Nullable; import org.openide.nodes.ChildFactory; import org.openide.nodes.Node; @@ -31,30 +31,30 @@ public abstract class FailSafeChildFactory extends ChildFactory.Detachable { @OnAnyThread - abstract protected boolean tryCreateKeys(@Nonnull List list) throws Exception; + abstract protected boolean tryCreateKeys(@NonNull List list) throws Exception; @OnEDT @Nullable - protected Node tryCreateNodeForKey(@Nonnull Object key) throws Exception { + protected Node tryCreateNodeForKey(@NonNull Object key) throws Exception { throw new AssertionError("Neither tryCreateNodeForKey() nor tryCreateNodesForKey() overridden in " + getClass().getName()); } @OnEDT @Nullable - protected Node[] tryCreateNodesForKey(@Nonnull Object key) throws Exception { + protected Node[] tryCreateNodesForKey(@NonNull Object key) throws Exception { Node n = tryCreateNodeForKey(key); return n == null ? null : new Node[]{n}; } @OnEDT @Nullable - protected Node createExceptionNode(@Nonnull Exception ex) { + protected Node createExceptionNode(@NonNull Exception ex) { return new ExceptionNode(ex); } @OnEDT @Nullable - protected Node[] createExceptionNodes(@Nonnull Exception ex) { + protected Node[] createExceptionNodes(@NonNull Exception ex) { Node n = createExceptionNode(ex); return n == null ? null : new Node[]{n}; } diff --git a/nbdemetra-ui/src/main/java/ec/nbdemetra/ui/nodes/NodeAnnotator.java b/nbdemetra-ui/src/main/java/ec/nbdemetra/ui/nodes/NodeAnnotator.java index 119217d5a..90c993391 100644 --- a/nbdemetra-ui/src/main/java/ec/nbdemetra/ui/nodes/NodeAnnotator.java +++ b/nbdemetra-ui/src/main/java/ec/nbdemetra/ui/nodes/NodeAnnotator.java @@ -7,7 +7,7 @@ import ec.nbdemetra.core.GlobalService; import ec.tstoolkit.design.ServiceDefinition; import java.awt.Image; -import javax.annotation.Nonnull; +import org.checkerframework.checker.nullness.qual.NonNull; import org.openide.nodes.Node; import org.openide.util.Lookup; import org.openide.util.lookup.ServiceProvider; @@ -27,7 +27,7 @@ public interface NodeAnnotator { @ServiceProvider(service = Support.class) public static class Support { - @Nonnull + @NonNull public static Support getDefault() { return Lookup.getDefault().lookup(Support.class); } diff --git a/nbdemetra-ui/src/main/java/ec/nbdemetra/ui/nodes/Nodes.java b/nbdemetra-ui/src/main/java/ec/nbdemetra/ui/nodes/Nodes.java index fba85e3b9..6e4a34b9b 100644 --- a/nbdemetra-ui/src/main/java/ec/nbdemetra/ui/nodes/Nodes.java +++ b/nbdemetra-ui/src/main/java/ec/nbdemetra/ui/nodes/Nodes.java @@ -23,7 +23,7 @@ import java.util.Arrays; import java.util.Collections; import java.util.stream.Stream; -import javax.annotation.Nonnull; +import org.checkerframework.checker.nullness.qual.NonNull; import javax.swing.Action; import org.openide.nodes.Node; import org.openide.util.Utilities; @@ -40,35 +40,35 @@ private Nodes() { // static class } - @Nonnull - public static Action[] actionsForPath(@Nonnull String path) { + @NonNull + public static Action[] actionsForPath(@NonNull String path) { return Iterables.toArray(Utilities.actionsForPath(path), Action.class); } - @Nonnull - public static Stream childrenStream(@Nonnull Node root) { + @NonNull + public static Stream childrenStream(@NonNull Node root) { return !root.isLeaf() ? Arrays.stream(root.getChildren().getNodes()) : Stream.empty(); } - @Nonnull - public static FluentIterable childrenIterable(@Nonnull Node root) { + @NonNull + public static FluentIterable childrenIterable(@NonNull Node root) { return FluentIterable.from(root.isLeaf() ? Collections.emptyList() : Arrays.asList(root.getChildren().getNodes())); } - @Nonnull - public static FluentIterable breadthFirstIterable(@Nonnull Node root) { + @NonNull + public static FluentIterable breadthFirstIterable(@NonNull Node root) { return FluentIterable.from(root.isLeaf() ? Collections.singleton(root) : Trees.breadthFirstIterable(root, Nodes::childrenStream)); } - @Nonnull - public static FluentIterable depthFirstIterable(@Nonnull Node root) { + @NonNull + public static FluentIterable depthFirstIterable(@NonNull Node root) { return FluentIterable.from(root.isLeaf() ? Collections.singleton(root) : Trees.depthFirstIterable(root, Nodes::childrenStream)); } - @Nonnull - public static FluentIterable asIterable(@Nonnull Node[] nodes) { + @NonNull + public static FluentIterable asIterable(@NonNull Node[] nodes) { return FluentIterable.from(Arrays.asList(nodes)); } } diff --git a/nbdemetra-ui/src/main/java/ec/nbdemetra/ui/nodes/SingleNodeAction.java b/nbdemetra-ui/src/main/java/ec/nbdemetra/ui/nodes/SingleNodeAction.java index 255642486..d936cd005 100644 --- a/nbdemetra-ui/src/main/java/ec/nbdemetra/ui/nodes/SingleNodeAction.java +++ b/nbdemetra-ui/src/main/java/ec/nbdemetra/ui/nodes/SingleNodeAction.java @@ -16,7 +16,7 @@ */ package ec.nbdemetra.ui.nodes; -import javax.annotation.Nonnull; +import org.checkerframework.checker.nullness.qual.NonNull; import org.openide.nodes.Node; import org.openide.util.HelpCtx; import org.openide.util.actions.NodeAction; @@ -32,7 +32,7 @@ public abstract class SingleNodeAction extends NodeAction { private final Class nodeType; - public SingleNodeAction(@Nonnull Class nodeType) { + public SingleNodeAction(@NonNull Class nodeType) { this.nodeType = nodeType; } @@ -53,7 +53,7 @@ protected final boolean enable(Node[] activatedNodes) { * * @param activatedNode a non-null node to be used as context */ - protected abstract void performAction(@Nonnull T activatedNode); + protected abstract void performAction(@NonNull T activatedNode); /** * Checks if the action is enabled or not. It is called before running the @@ -62,7 +62,7 @@ protected final boolean enable(Node[] activatedNodes) { * @param activatedNode a non-null node to be used as context * @return */ - protected abstract boolean enable(@Nonnull T activatedNode); + protected abstract boolean enable(@NonNull T activatedNode); @Deprecated protected T getSingleNode(Node[] activatedNodes) { diff --git a/nbdemetra-ui/src/main/java/ec/nbdemetra/ui/notification/NotifyUtil.java b/nbdemetra-ui/src/main/java/ec/nbdemetra/ui/notification/NotifyUtil.java index 541c094c4..2acb74b51 100644 --- a/nbdemetra-ui/src/main/java/ec/nbdemetra/ui/notification/NotifyUtil.java +++ b/nbdemetra-ui/src/main/java/ec/nbdemetra/ui/notification/NotifyUtil.java @@ -17,7 +17,7 @@ package ec.nbdemetra.ui.notification; import java.awt.event.ActionListener; -import javax.annotation.Nullable; +import org.checkerframework.checker.nullness.qual.Nullable; import javax.swing.JComponent; import javax.swing.JLabel; import org.openide.ErrorManager; diff --git a/nbdemetra-ui/src/main/java/ec/nbdemetra/ui/ns/INamedService.java b/nbdemetra-ui/src/main/java/ec/nbdemetra/ui/ns/INamedService.java index b01be32f4..5a539d1b1 100644 --- a/nbdemetra-ui/src/main/java/ec/nbdemetra/ui/ns/INamedService.java +++ b/nbdemetra-ui/src/main/java/ec/nbdemetra/ui/ns/INamedService.java @@ -18,8 +18,8 @@ import ec.util.various.swing.OnEDT; import java.awt.Image; -import javax.annotation.Nonnull; -import javax.annotation.Nullable; +import org.checkerframework.checker.nullness.qual.NonNull; +import org.checkerframework.checker.nullness.qual.Nullable; import org.openide.nodes.Sheet; /** @@ -30,11 +30,11 @@ public interface INamedService { @OnEDT - @Nonnull + @NonNull String getName(); @OnEDT - @Nonnull + @NonNull default String getDisplayName() { return getName(); } @@ -46,7 +46,7 @@ default Image getIcon(int type, boolean opened) { } @OnEDT - @Nonnull + @NonNull default Sheet createSheet() { return new Sheet(); } diff --git a/nbdemetra-ui/src/main/java/ec/nbdemetra/ui/ns/NamedServiceNode.java b/nbdemetra-ui/src/main/java/ec/nbdemetra/ui/ns/NamedServiceNode.java index 5649d3aa2..cd7224b2e 100644 --- a/nbdemetra-ui/src/main/java/ec/nbdemetra/ui/ns/NamedServiceNode.java +++ b/nbdemetra-ui/src/main/java/ec/nbdemetra/ui/ns/NamedServiceNode.java @@ -23,7 +23,7 @@ import ec.nbdemetra.ui.nodes.AbstractNodeBuilder; import java.awt.Image; import java.awt.event.ActionEvent; -import javax.annotation.Nonnull; +import org.checkerframework.checker.nullness.qual.NonNull; import javax.swing.AbstractAction; import javax.swing.Action; import org.openide.explorer.ExplorerManager; @@ -40,7 +40,7 @@ */ public class NamedServiceNode extends AbstractNode { - public NamedServiceNode(@Nonnull INamedService namedService) { + public NamedServiceNode(@NonNull INamedService namedService) { this(namedService, new InstanceContent()); } diff --git a/nbdemetra-ui/src/main/java/ec/nbdemetra/ui/properties/AbstractExPropertyEditor.java b/nbdemetra-ui/src/main/java/ec/nbdemetra/ui/properties/AbstractExPropertyEditor.java index 0f34d647d..991ea4ed5 100644 --- a/nbdemetra-ui/src/main/java/ec/nbdemetra/ui/properties/AbstractExPropertyEditor.java +++ b/nbdemetra-ui/src/main/java/ec/nbdemetra/ui/properties/AbstractExPropertyEditor.java @@ -19,7 +19,7 @@ import com.google.common.base.Suppliers; import java.beans.PropertyEditorSupport; import java.util.function.Supplier; -import javax.annotation.Nonnull; +import org.checkerframework.checker.nullness.qual.NonNull; import org.openide.explorer.propertysheet.ExPropertyEditor; import org.openide.explorer.propertysheet.InplaceEditor; import org.openide.explorer.propertysheet.PropertyEnv; @@ -42,6 +42,6 @@ public InplaceEditor getInplaceEditor() { return supplier.get(); } - @Nonnull + @NonNull abstract protected InplaceEditor createInplaceEditor(); } diff --git a/nbdemetra-ui/src/main/java/ec/nbdemetra/ui/properties/AutoCompletedComponent.java b/nbdemetra-ui/src/main/java/ec/nbdemetra/ui/properties/AutoCompletedComponent.java index a7df2e5d8..1987a5082 100644 --- a/nbdemetra-ui/src/main/java/ec/nbdemetra/ui/properties/AutoCompletedComponent.java +++ b/nbdemetra-ui/src/main/java/ec/nbdemetra/ui/properties/AutoCompletedComponent.java @@ -32,8 +32,8 @@ import java.util.concurrent.Callable; import java.util.concurrent.ExecutionException; import java.util.function.Consumer; -import javax.annotation.Nonnull; -import javax.annotation.Nullable; +import org.checkerframework.checker.nullness.qual.NonNull; +import org.checkerframework.checker.nullness.qual.Nullable; import javax.swing.BorderFactory; import javax.swing.CellRendererPane; import javax.swing.DefaultListModel; @@ -143,7 +143,7 @@ private void onRunningChange() { // // - @Nonnull + @NonNull public String getValue() { return value; } @@ -176,7 +176,7 @@ public void setDefaultValueSupplier(@Nullable Callable defaultValueSuppl firePropertyChange(DEFAULT_VALUE_SUPPLIER_PROPERTY, old, this.defaultValueSupplier); } - @Nonnull + @NonNull public String getSeparator() { return separator; } diff --git a/nbdemetra-ui/src/main/java/ec/nbdemetra/ui/properties/CharsetComponent2.java b/nbdemetra-ui/src/main/java/ec/nbdemetra/ui/properties/CharsetComponent2.java index d5633dc71..ede0c02bd 100644 --- a/nbdemetra-ui/src/main/java/ec/nbdemetra/ui/properties/CharsetComponent2.java +++ b/nbdemetra-ui/src/main/java/ec/nbdemetra/ui/properties/CharsetComponent2.java @@ -21,7 +21,7 @@ import ec.util.various.swing.TextPrompt; import java.awt.BorderLayout; import java.nio.charset.Charset; -import javax.annotation.Nullable; +import org.checkerframework.checker.nullness.qual.Nullable; import javax.swing.JComponent; import javax.swing.JTextField; import javax.swing.border.Border; diff --git a/nbdemetra-ui/src/main/java/ec/nbdemetra/ui/properties/DataFormatComponent2.java b/nbdemetra-ui/src/main/java/ec/nbdemetra/ui/properties/DataFormatComponent2.java index b3f8596d0..db74f7d4f 100644 --- a/nbdemetra-ui/src/main/java/ec/nbdemetra/ui/properties/DataFormatComponent2.java +++ b/nbdemetra-ui/src/main/java/ec/nbdemetra/ui/properties/DataFormatComponent2.java @@ -23,8 +23,8 @@ import java.awt.Dimension; import java.awt.GridLayout; import java.util.Date; -import javax.annotation.Nonnull; -import javax.annotation.Nullable; +import org.checkerframework.checker.nullness.qual.NonNull; +import org.checkerframework.checker.nullness.qual.Nullable; import javax.swing.JComponent; import javax.swing.JLabel; import javax.swing.JTextField; @@ -153,7 +153,7 @@ private void onPreviewVisibleChange() { // // - @Nonnull + @NonNull public DataFormat getDataFormat() { return dataFormat; } diff --git a/nbdemetra-ui/src/main/java/ec/nbdemetra/ui/properties/FieldNodeProperty.java b/nbdemetra-ui/src/main/java/ec/nbdemetra/ui/properties/FieldNodeProperty.java index 8ac85fcf3..cd6439c6f 100644 --- a/nbdemetra-ui/src/main/java/ec/nbdemetra/ui/properties/FieldNodeProperty.java +++ b/nbdemetra-ui/src/main/java/ec/nbdemetra/ui/properties/FieldNodeProperty.java @@ -21,7 +21,7 @@ import java.lang.reflect.Field; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Modifier; -import javax.annotation.Nonnull; +import org.checkerframework.checker.nullness.qual.NonNull; import org.openide.nodes.Node; /** @@ -31,8 +31,8 @@ */ public class FieldNodeProperty extends Node.Property { - @Nonnull - public static FieldNodeProperty create(@Nonnull Object instance, @Nonnull Class valueType, @Nonnull String fieldName) { + @NonNull + public static FieldNodeProperty create(@NonNull Object instance, @NonNull Class valueType, @NonNull String fieldName) { try { return new FieldNodeProperty(instance, valueType, instance.getClass().getField(fieldName)); } catch (NoSuchFieldException | SecurityException ex) { diff --git a/nbdemetra-ui/src/main/java/ec/nbdemetra/ui/properties/FileLoaderFileFilter.java b/nbdemetra-ui/src/main/java/ec/nbdemetra/ui/properties/FileLoaderFileFilter.java index d2f11b092..72b916af7 100644 --- a/nbdemetra-ui/src/main/java/ec/nbdemetra/ui/properties/FileLoaderFileFilter.java +++ b/nbdemetra-ui/src/main/java/ec/nbdemetra/ui/properties/FileLoaderFileFilter.java @@ -18,7 +18,7 @@ import ec.tss.tsproviders.IFileLoader; import java.io.File; -import javax.annotation.Nonnull; +import org.checkerframework.checker.nullness.qual.NonNull; /** * @@ -28,7 +28,7 @@ public class FileLoaderFileFilter extends javax.swing.filechooser.FileFilter imp private final IFileLoader loader; - public FileLoaderFileFilter(@Nonnull IFileLoader loader) { + public FileLoaderFileFilter(@NonNull IFileLoader loader) { this.loader = loader; } diff --git a/nbdemetra-ui/src/main/java/ec/nbdemetra/ui/properties/ForwardingNodeProperty.java b/nbdemetra-ui/src/main/java/ec/nbdemetra/ui/properties/ForwardingNodeProperty.java index b43c48187..1d0b2ea9a 100644 --- a/nbdemetra-ui/src/main/java/ec/nbdemetra/ui/properties/ForwardingNodeProperty.java +++ b/nbdemetra-ui/src/main/java/ec/nbdemetra/ui/properties/ForwardingNodeProperty.java @@ -18,7 +18,7 @@ import java.beans.PropertyEditor; import java.lang.reflect.InvocationTargetException; -import javax.annotation.Nonnull; +import org.checkerframework.checker.nullness.qual.NonNull; import org.openide.nodes.Node; import org.openide.nodes.PropertySupport; @@ -31,7 +31,7 @@ public abstract class ForwardingNodeProperty extends Node.Property { private final Node.Property delegate; - public ForwardingNodeProperty(@Nonnull Node.Property delegate) { + public ForwardingNodeProperty(Node.@NonNull Property delegate) { super(delegate.getValueType()); this.delegate = delegate; } @@ -121,8 +121,7 @@ public void restoreDefaultValue() throws IllegalAccessException, InvocationTarge delegate.restoreDefaultValue(); } - @Nonnull - public static Node.Property readOnly(@Nonnull Node.Property p) { + public static Node.@NonNull Property readOnly(Node.@NonNull Property p) { return p instanceof PropertySupport.ReadOnly || p instanceof ReadOnly ? p : new ReadOnly(p); } diff --git a/nbdemetra-ui/src/main/java/ec/nbdemetra/ui/properties/ForwardingPropertyEditor.java b/nbdemetra-ui/src/main/java/ec/nbdemetra/ui/properties/ForwardingPropertyEditor.java index f3afe95a4..1f1059da6 100644 --- a/nbdemetra-ui/src/main/java/ec/nbdemetra/ui/properties/ForwardingPropertyEditor.java +++ b/nbdemetra-ui/src/main/java/ec/nbdemetra/ui/properties/ForwardingPropertyEditor.java @@ -21,7 +21,7 @@ import java.awt.Rectangle; import java.beans.PropertyChangeListener; import java.beans.PropertyEditor; -import javax.annotation.Nonnull; +import org.checkerframework.checker.nullness.qual.NonNull; /** * @@ -31,7 +31,7 @@ public abstract class ForwardingPropertyEditor implements PropertyEditor { private final PropertyEditor delegate; - public ForwardingPropertyEditor(@Nonnull PropertyEditor delegate) { + public ForwardingPropertyEditor(@NonNull PropertyEditor delegate) { this.delegate = delegate; } diff --git a/nbdemetra-ui/src/main/java/ec/nbdemetra/ui/properties/IBeanEditor.java b/nbdemetra-ui/src/main/java/ec/nbdemetra/ui/properties/IBeanEditor.java index 46bd22e67..035490bdf 100644 --- a/nbdemetra-ui/src/main/java/ec/nbdemetra/ui/properties/IBeanEditor.java +++ b/nbdemetra-ui/src/main/java/ec/nbdemetra/ui/properties/IBeanEditor.java @@ -17,7 +17,7 @@ package ec.nbdemetra.ui.properties; import java.beans.IntrospectionException; -import javax.annotation.Nonnull; +import org.checkerframework.checker.nullness.qual.NonNull; /** * @@ -25,6 +25,6 @@ */ public interface IBeanEditor { - boolean editBean(@Nonnull Object bean) throws IntrospectionException; + boolean editBean(@NonNull Object bean) throws IntrospectionException; } diff --git a/nbdemetra-ui/src/main/java/ec/nbdemetra/ui/properties/NodePropertySetBuilder.java b/nbdemetra-ui/src/main/java/ec/nbdemetra/ui/properties/NodePropertySetBuilder.java index f9dc90aea..2b643eebb 100644 --- a/nbdemetra-ui/src/main/java/ec/nbdemetra/ui/properties/NodePropertySetBuilder.java +++ b/nbdemetra-ui/src/main/java/ec/nbdemetra/ui/properties/NodePropertySetBuilder.java @@ -35,8 +35,8 @@ import java.util.Objects; import java.util.concurrent.Callable; import java.util.function.Function; -import javax.annotation.Nonnull; -import javax.annotation.Nullable; +import org.checkerframework.checker.nullness.qual.NonNull; +import org.checkerframework.checker.nullness.qual.Nullable; import javax.swing.ListCellRenderer; import javax.swing.text.NumberFormatter; import org.openide.nodes.Node; @@ -72,7 +72,7 @@ public NodePropertySetBuilder() { * @param name a programmatic name * @return this builder */ - @Nonnull + @NonNull public NodePropertySetBuilder reset(@Nullable String name) { this.nodeProperties.clear(); this.name = name; @@ -88,7 +88,7 @@ public NodePropertySetBuilder reset(@Nullable String name) { * @param name a programmatic name * @return this builder */ - @Nonnull + @NonNull public NodePropertySetBuilder name(@Nullable String name) { this.name = name; return this; @@ -102,7 +102,7 @@ public NodePropertySetBuilder name(@Nullable String name) { * @see * http://platform.netbeans.org/tutorials/nbm-nodesapi2.html#separate-property-groups */ - @Nonnull + @NonNull public NodePropertySetBuilder group(@Nullable String tabName) { this.tabName = tabName; return this; @@ -114,7 +114,7 @@ public NodePropertySetBuilder group(@Nullable String tabName) { * @param displayName a display name * @return this builder */ - @Nonnull + @NonNull public NodePropertySetBuilder display(@Nullable String displayName) { this.displayName = displayName; return this; @@ -126,7 +126,7 @@ public NodePropertySetBuilder display(@Nullable String displayName) { * @param shortDescription a short description * @return this builder */ - @Nonnull + @NonNull public NodePropertySetBuilder description(@Nullable String shortDescription) { this.shortDescription = shortDescription; return this; @@ -138,8 +138,8 @@ public NodePropertySetBuilder description(@Nullable String shortDescription) { * @param nodeProperty a non-null property * @return this builder */ - @Nonnull - public NodePropertySetBuilder add(@Nonnull Node.Property nodeProperty) { + @NonNull + public NodePropertySetBuilder add(Node.@NonNull Property nodeProperty) { nodeProperties.add(nodeProperty); return this; } @@ -151,8 +151,8 @@ public NodePropertySetBuilder add(@Nonnull Node.Property nodeProperty) { * @param valueType * @return a non-null selection step */ - @Nonnull - public SelectStep with(@Nonnull Class valueType) { + @NonNull + public SelectStep with(@NonNull Class valueType) { return new SelectStep<>(valueType, DefaultStep::new); } @@ -161,7 +161,7 @@ public SelectStep with(@Nonnull Class valueType) { * * @return a non-null selection step */ - @Nonnull + @NonNull public SelectStep withFile() { return new SelectStep<>(File.class, FileStep::new); } @@ -171,7 +171,7 @@ public SelectStep withFile() { * * @return a non-null selection step */ - @Nonnull + @NonNull public SelectStep withAutoCompletion() { return new SelectStep<>(String.class, AutoCompletedStep::new); } @@ -181,7 +181,7 @@ public SelectStep withAutoCompletion() { * * @return a non-null selection step */ - @Nonnull + @NonNull public SelectStep withBoolean() { return new SelectStep<>(boolean.class, BooleanStep::new); } @@ -191,7 +191,7 @@ public SelectStep withBoolean() { * * @return a non-null selection step */ - @Nonnull + @NonNull public SelectStep withInt() { return new SelectStep<>(int.class, IntStep::new); } @@ -201,7 +201,7 @@ public SelectStep withInt() { * * @return a non-null selection step */ - @Nonnull + @NonNull public SelectStep withDouble() { return new SelectStep<>(double.class, DoubleStep::new); } @@ -213,8 +213,8 @@ public SelectStep withDouble() { * @param valueType * @return a non-null selection step */ - @Nonnull - public > SelectStep> withEnum(@Nonnull Class valueType) { + @NonNull + public > SelectStep> withEnum(@NonNull Class valueType) { return new SelectStep<>(valueType, EnumStep::new); } @@ -247,13 +247,13 @@ private SelectStep(Class valueType, Function, NEXT_STEP> nex this.next = next; } - @Nonnull - public NEXT_STEP select(@Nonnull Node.Property property) { + @NonNull + public NEXT_STEP select(Node.@NonNull Property property) { return next.apply(property); } - @Nonnull - public NEXT_STEP select(@Nonnull Object bean, @Nonnull String property) { + @NonNull + public NEXT_STEP select(@NonNull Object bean, @NonNull String property) { try { return next.apply(new PropertySupport.Reflection<>(bean, valueType, property)); } catch (NoSuchMethodException ex) { @@ -261,8 +261,8 @@ public NEXT_STEP select(@Nonnull Object bean, @Nonnull String property) { } } - @Nonnull - public NEXT_STEP select(@Nonnull Object bean, @Nonnull String getter, @Nullable String setter) { + @NonNull + public NEXT_STEP select(@NonNull Object bean, @NonNull String getter, @Nullable String setter) { try { return next.apply(new PropertySupport.Reflection<>(bean, valueType, getter, setter)); } catch (NoSuchMethodException ex) { @@ -270,8 +270,8 @@ public NEXT_STEP select(@Nonnull Object bean, @Nonnull String getter, @Nullable } } - @Nonnull - public NEXT_STEP select(@Nonnull Object bean, @Nonnull String property, @Nonnull Class source, @Nonnull Function forward, @Nonnull Function backward) { + @NonNull + public NEXT_STEP select(@NonNull Object bean, @NonNull String property, @NonNull Class source, @NonNull Function forward, @NonNull Function backward) { try { return next.apply(new PropertyAdapter<>(new PropertySupport.Reflection<>(bean, source, property), valueType, forward, backward)); } catch (NoSuchMethodException ex) { @@ -288,8 +288,8 @@ public NEXT_STEP select(@Nonnull Object bean, @Nonnull String property, @Non * {@link #selectConst(java.lang.String, java.lang.Object)} instead */ @Deprecated - @Nonnull - public NEXT_STEP select(@Nonnull String name, @Nonnull T value) { + @NonNull + public NEXT_STEP select(@NonNull String name, @NonNull T value) { return selectConst(name, value); } @@ -300,13 +300,13 @@ public NEXT_STEP select(@Nonnull String name, @Nonnull T value) { * @return * @since 2.2.0 */ - @Nonnull - public NEXT_STEP selectConst(@Nonnull String name, @Nullable T value) { + @NonNull + public NEXT_STEP selectConst(@NonNull String name, @Nullable T value) { return next.apply(new ConstProperty<>(value, name, valueType, null, null)); } - @Nonnull - public NEXT_STEP selectField(@Nonnull Object bean, @Nonnull String fieldName) { + @NonNull + public NEXT_STEP selectField(@NonNull Object bean, @NonNull String fieldName) { return next.apply(FieldNodeProperty.create(bean, valueType, fieldName)); } } @@ -333,8 +333,8 @@ private PropertyStep(Node.Property nodeProperty) { * @param name The programmatic name of the property/method/event * @return a reference to this object. */ - @Nonnull - public THIS name(@Nonnull String name) { + @NonNull + public THIS name(@NonNull String name) { nodeProperty.setName(Objects.requireNonNull(name)); return (THIS) this; } @@ -347,7 +347,7 @@ public THIS name(@Nonnull String name) { * property/method/event. * @return a reference to this object. */ - @Nonnull + @NonNull public THIS display(@Nullable String displayName) { nodeProperty.setDisplayName(displayName); return (THIS) this; @@ -372,7 +372,7 @@ public THIS display(@Nullable String displayName) { * implementation is null. * @return a reference to this object. */ - @Nonnull + @NonNull public THIS htmlDisplay(@Nullable String htmlDisplayName) { nodeProperty.setHtmlDisplayName(htmlDisplayName); return (THIS) this; @@ -386,7 +386,7 @@ public THIS htmlDisplay(@Nullable String htmlDisplayName) { * property/method/event. This defaults to be the display name. * @return a reference to this object. */ - @Nonnull + @NonNull public THIS description(@Nullable String description) { nodeProperty.setShortDescription(description); return (THIS) this; @@ -400,8 +400,8 @@ public THIS description(@Nullable String description) { * @param value The value. * @return a reference to this object. */ - @Nonnull - public THIS attribute(@Nonnull String attributeName, @Nonnull Object value) { + @NonNull + public THIS attribute(@NonNull String attributeName, @NonNull Object value) { nodeProperty.setValue(attributeName, value); return (THIS) this; } @@ -412,7 +412,7 @@ public THIS attribute(@Nonnull String attributeName, @Nonnull Object value) { * @param editorType class type of the property editor * @return a reference to this object. */ - @Nonnull + @NonNull protected THIS editor(@Nullable Class editorType) { nodeProperty.setPropertyEditorClass(editorType); return (THIS) this; @@ -423,7 +423,7 @@ protected THIS editor(@Nullable Class editorType) { * * @return a reference to the builder */ - @Nonnull + @NonNull public NodePropertySetBuilder add() { return NodePropertySetBuilder.this.add(nodeProperty); } @@ -463,8 +463,8 @@ private AutoCompletedStep(Node.Property nodeProperty) { * @return this step * @see AutoCompletedPropertyEditor3.SERVICE_PATH_ATTRIBUTE */ - @Nonnull - public AutoCompletedStep servicePath(@Nonnull String path) { + @NonNull + public AutoCompletedStep servicePath(@NonNull String path) { return attribute(AutoCompletedPropertyEditor3.SERVICE_PATH_ATTRIBUTE, path); } @@ -475,8 +475,8 @@ public AutoCompletedStep servicePath(@Nonnull String path) { * @return this step * @see AutoCompletedPropertyEditor3.PROMPT_TEXT_ATTRIBUTE */ - @Nonnull - public AutoCompletedStep promptText(@Nonnull String text) { + @NonNull + public AutoCompletedStep promptText(@NonNull String text) { return attribute(AutoCompletedPropertyEditor3.PROMPT_TEXT_ATTRIBUTE, text); } @@ -487,7 +487,7 @@ public AutoCompletedStep promptText(@Nonnull String text) { * @return this step * @see AutoCompletedPropertyEditor3.AUTO_FOCUS_ATTRIBUTE */ - @Nonnull + @NonNull public AutoCompletedStep autoFocus(boolean autoFocus) { return attribute(AutoCompletedPropertyEditor3.AUTO_FOCUS_ATTRIBUTE, autoFocus); } @@ -499,7 +499,7 @@ public AutoCompletedStep autoFocus(boolean autoFocus) { * @return this step * @see AutoCompletedPropertyEditor3.DELAY_ATTRIBUTE */ - @Nonnull + @NonNull public AutoCompletedStep delay(int delay) { return attribute(AutoCompletedPropertyEditor3.DELAY_ATTRIBUTE, delay); } @@ -511,7 +511,7 @@ public AutoCompletedStep delay(int delay) { * @return this step * @see AutoCompletedPropertyEditor3.MIN_LENGTH_ATTRIBUTE */ - @Nonnull + @NonNull public AutoCompletedStep minLength(int minLength) { return attribute(AutoCompletedPropertyEditor3.MIN_LENGTH_ATTRIBUTE, minLength); } @@ -523,8 +523,8 @@ public AutoCompletedStep minLength(int minLength) { * @return this step * @see AutoCompletedPropertyEditor3.SEPARATOR_ATTRIBUTE */ - @Nonnull - public AutoCompletedStep separator(@Nonnull String separator) { + @NonNull + public AutoCompletedStep separator(@NonNull String separator) { return attribute(AutoCompletedPropertyEditor3.SEPARATOR_ATTRIBUTE, separator); } @@ -535,8 +535,8 @@ public AutoCompletedStep separator(@Nonnull String separator) { * @return this step * @see AutoCompletedPropertyEditor3.SOURCE_ATTRIBUTE */ - @Nonnull - public AutoCompletedStep source(@Nonnull AutoCompletionSource source) { + @NonNull + public AutoCompletedStep source(@NonNull AutoCompletionSource source) { return attribute(AutoCompletedPropertyEditor3.SOURCE_ATTRIBUTE, source); } @@ -547,8 +547,8 @@ public AutoCompletedStep source(@Nonnull AutoCompletionSource source) { * @return this step * @see AutoCompletedPropertyEditor3.SOURCE_ATTRIBUTE */ - @Nonnull - public AutoCompletedStep source(@Nonnull Object... list) { + @NonNull + public AutoCompletedStep source(@NonNull Object... list) { return source(Arrays.asList(list)); } @@ -559,8 +559,8 @@ public AutoCompletedStep source(@Nonnull Object... list) { * @return this step * @see AutoCompletedPropertyEditor3.SOURCE_ATTRIBUTE */ - @Nonnull - public AutoCompletedStep source(@Nonnull Iterable list) { + @NonNull + public AutoCompletedStep source(@NonNull Iterable list) { return source(AutoCompletionSources.of(false, list)); } @@ -571,8 +571,8 @@ public AutoCompletedStep source(@Nonnull Iterable list) { * @return this step * @see AutoCompletedPropertyEditor3#CELL_RENDERER_ATTRIBUTE */ - @Nonnull - public AutoCompletedStep cellRenderer(@Nonnull ListCellRenderer cellRenderer) { + @NonNull + public AutoCompletedStep cellRenderer(@NonNull ListCellRenderer cellRenderer) { return attribute(AutoCompletedPropertyEditor3.CELL_RENDERER_ATTRIBUTE, cellRenderer); } @@ -584,8 +584,8 @@ public AutoCompletedStep cellRenderer(@Nonnull ListCellRenderer cellRenderer) { * @since 2.2.0 * @see AutoCompletedPropertyEditor3.DEFAULT_VALUE_SUPPLIER_ATTRIBUTE */ - @Nonnull - public AutoCompletedStep defaultValueSupplier(@Nonnull Callable defaultValueSupplier) { + @NonNull + public AutoCompletedStep defaultValueSupplier(@NonNull Callable defaultValueSupplier) { return attribute(AutoCompletedPropertyEditor3.DEFAULT_VALUE_SUPPLIER_ATTRIBUTE, defaultValueSupplier); } @@ -597,8 +597,8 @@ public AutoCompletedStep defaultValueSupplier(@Nonnull Callable defaultV * @since 2.2.0 * @see AutoCompletedPropertyEditor3.DEFAULT_VALUE_SUPPLIER_ATTRIBUTE */ - @Nonnull - public AutoCompletedStep defaultValueSupplier(@Nonnull String defaultValue) { + @NonNull + public AutoCompletedStep defaultValueSupplier(@NonNull String defaultValue) { return AutoCompletedStep.this.defaultValueSupplier(() -> defaultValue); } } @@ -616,8 +616,8 @@ private FileStep(Node.Property nodeProperty) { //editor(FileEditor.class); } - @Nonnull - public FileStep paths(@Nonnull File[] paths) { + @NonNull + public FileStep paths(@NonNull File[] paths) { return attribute(DesktopFilePropertyEditor.PATHS_ATTRIBUTE, paths); } @@ -627,8 +627,8 @@ public FileStep paths(@Nonnull File[] paths) { * @param fileFilter * @return */ - @Nonnull - public FileStep filterForSwing(@Nonnull javax.swing.filechooser.FileFilter fileFilter) { + @NonNull + public FileStep filterForSwing(javax.swing.filechooser.@NonNull FileFilter fileFilter) { return attribute("filter", fileFilter); } @@ -638,8 +638,8 @@ public FileStep filterForSwing(@Nonnull javax.swing.filechooser.FileFilter fileF * @param fileFilter * @return */ - @Nonnull - public FileStep filter(@Nonnull java.io.FileFilter fileFilter) { + @NonNull + public FileStep filter(java.io.@NonNull FileFilter fileFilter) { return attribute("filter", fileFilter); } @@ -649,8 +649,8 @@ public FileStep filter(@Nonnull java.io.FileFilter fileFilter) { * @param fileNameFilter * @return */ - @Nonnull - public FileStep filterByName(@Nonnull java.io.FilenameFilter fileNameFilter) { + @NonNull + public FileStep filterByName(java.io.@NonNull FilenameFilter fileNameFilter) { return attribute("filter", fileNameFilter); } @@ -660,7 +660,7 @@ public FileStep filterByName(@Nonnull java.io.FilenameFilter fileNameFilter) { * @param selectables * @return */ - @Nonnull + @NonNull public FileStep directories(boolean selectables) { return attribute("directories", selectables); } @@ -671,7 +671,7 @@ public FileStep directories(boolean selectables) { * @param selectables * @return */ - @Nonnull + @NonNull public FileStep files(boolean selectables) { return attribute("files", selectables); } @@ -682,8 +682,8 @@ public FileStep files(boolean selectables) { * @param file * @return */ - @Nonnull - public FileStep currentDir(@Nonnull File file) { + @NonNull + public FileStep currentDir(@NonNull File file) { return attribute("currentDir", file); } @@ -702,8 +702,8 @@ public FileStep currentDir(@Nonnull File file) { * @param file * @return */ - @Nonnull - public FileStep baseDir(@Nonnull File file) { + @NonNull + public FileStep baseDir(@NonNull File file) { return attribute("baseDir", file); } } @@ -734,7 +734,7 @@ private IntStep(Node.Property nodeProperty) { * @param max maximum legal value that can be input * @return this step */ - @Nonnull + @NonNull public IntStep max(int max) { return attribute(JSpinFieldPropertyEditor.MAX_ATTRIBUTE, max); } @@ -745,7 +745,7 @@ public IntStep max(int max) { * @param min minimum legal value that can be input * @return this step */ - @Nonnull + @NonNull public IntStep min(int min) { return attribute(JSpinFieldPropertyEditor.MIN_ATTRIBUTE, min); } @@ -773,7 +773,7 @@ private DoubleStep(Node.Property nodeProperty) { * @param max maximum legal value that can be input * @return this step */ - @Nonnull + @NonNull public DoubleStep max(double max) { formatter.setMaximum(max); return this; @@ -785,7 +785,7 @@ public DoubleStep max(double max) { * @param min minimum legal value that can be input * @return this step */ - @Nonnull + @NonNull public DoubleStep min(double min) { formatter.setMinimum(min); return this; @@ -805,36 +805,35 @@ private EnumStep(Property nodeProperty) { of(EnumSet.allOf(nodeProperty.getValueType())); } - @Nonnull - public EnumStep of(@Nonnull T... values) { + @NonNull + public EnumStep of(@NonNull T... values) { return attribute(ComboBoxPropertyEditor.VALUES_ATTRIBUTE, values); } - @Nonnull - public EnumStep of(@Nonnull Iterable values) { + @NonNull + public EnumStep of(@NonNull Iterable values) { return of(Iterables.toArray(values, nodeProperty.getValueType())); } - @Nonnull - public EnumStep noneOf(@Nonnull T... values) { + @NonNull + public EnumStep noneOf(@NonNull T... values) { EnumSet tmp = EnumSet.allOf(nodeProperty.getValueType()); tmp.removeAll(Arrays.asList(values)); return of(tmp); } - @Nonnull - public EnumStep noneOf(@Nonnull Iterable values) { + @NonNull + public EnumStep noneOf(@NonNull Iterable values) { EnumSet tmp = EnumSet.allOf(nodeProperty.getValueType()); tmp.removeAll(Lists.newArrayList(values)); return of(tmp); } } - @Nonnull - public static Node.Property adapt( - @Nonnull Object bean, @Nonnull String property, - @Nonnull Class source, @Nonnull Class target, - @Nonnull Function forward, @Nonnull Function backward) { + public static Node.@NonNull Property adapt( + @NonNull Object bean, @NonNull String property, + @NonNull Class source, @NonNull Class target, + @NonNull Function forward, @NonNull Function backward) { try { return new PropertyAdapter<>(new PropertySupport.Reflection<>(bean, source, property), target, forward, backward); } catch (NoSuchMethodException ex) { diff --git a/nbdemetra-ui/src/main/java/ec/nbdemetra/ui/properties/OpenIdePropertySheetBeanEditor.java b/nbdemetra-ui/src/main/java/ec/nbdemetra/ui/properties/OpenIdePropertySheetBeanEditor.java index 26564a635..15500c9e6 100644 --- a/nbdemetra-ui/src/main/java/ec/nbdemetra/ui/properties/OpenIdePropertySheetBeanEditor.java +++ b/nbdemetra-ui/src/main/java/ec/nbdemetra/ui/properties/OpenIdePropertySheetBeanEditor.java @@ -18,8 +18,8 @@ import java.awt.Image; import java.beans.IntrospectionException; -import javax.annotation.Nonnull; -import javax.annotation.Nullable; +import org.checkerframework.checker.nullness.qual.NonNull; +import org.checkerframework.checker.nullness.qual.Nullable; import org.openide.nodes.Node; import org.openide.nodes.Sheet; @@ -44,12 +44,12 @@ public boolean editBean(Object bean) throws IntrospectionException { } @Deprecated - public static boolean editNode(@Nonnull Node node, @Nullable String title, @Nullable Image image) { + public static boolean editNode(@NonNull Node node, @Nullable String title, @Nullable Image image) { return new PropertySheetDialogBuilder().title(title).icon(image).editNode(node); } @Deprecated - public static boolean editSheet(@Nonnull Sheet sheet, @Nullable String title, @Nullable Image image) { + public static boolean editSheet(@NonNull Sheet sheet, @Nullable String title, @Nullable Image image) { return new PropertySheetDialogBuilder().title(title).icon(image).editSheet(sheet); } } diff --git a/nbdemetra-ui/src/main/java/ec/nbdemetra/ui/properties/PropertySheetDialogBuilder.java b/nbdemetra-ui/src/main/java/ec/nbdemetra/ui/properties/PropertySheetDialogBuilder.java index 9b859d762..fdce88244 100644 --- a/nbdemetra-ui/src/main/java/ec/nbdemetra/ui/properties/PropertySheetDialogBuilder.java +++ b/nbdemetra-ui/src/main/java/ec/nbdemetra/ui/properties/PropertySheetDialogBuilder.java @@ -26,8 +26,8 @@ import java.beans.IntrospectionException; import java.util.Arrays; import java.util.stream.Stream; -import javax.annotation.Nonnull; -import javax.annotation.Nullable; +import org.checkerframework.checker.nullness.qual.NonNull; +import org.checkerframework.checker.nullness.qual.Nullable; import javax.swing.Icon; import javax.swing.JTable; import org.openide.DialogDescriptor; @@ -53,24 +53,24 @@ public PropertySheetDialogBuilder() { this.image = null; } - @Nonnull + @NonNull public PropertySheetDialogBuilder title(@Nullable String title) { this.title = title; return this; } - @Nonnull + @NonNull public PropertySheetDialogBuilder icon(@Nullable Image image) { this.image = image; return this; } - @Nonnull + @NonNull public PropertySheetDialogBuilder icon(@Nullable Icon icon) { return icon != null ? icon(ImageUtilities.icon2Image(icon)) : this; } - public boolean editNode(@Nonnull Node node) { + public boolean editNode(@NonNull Node node) { PropertySheet v = new PropertySheet(); v.setNodes(new Node[]{node}); @@ -89,11 +89,11 @@ public boolean editNode(@Nonnull Node node) { return d.getValue() == DialogDescriptor.OK_OPTION; } - public boolean editBean(@Nonnull Object bean) throws IntrospectionException { + public boolean editBean(@NonNull Object bean) throws IntrospectionException { return editNode(new BeanNode(bean)); } - public boolean editSheet(@Nonnull Sheet sheet) { + public boolean editSheet(@NonNull Sheet sheet) { return editNode(new AbstractNodeBuilder().sheet(sheet).build()); } diff --git a/nbdemetra-ui/src/main/java/ec/nbdemetra/ui/properties/Util.java b/nbdemetra-ui/src/main/java/ec/nbdemetra/ui/properties/Util.java index 0a845ccfe..f5b63b11e 100644 --- a/nbdemetra-ui/src/main/java/ec/nbdemetra/ui/properties/Util.java +++ b/nbdemetra-ui/src/main/java/ec/nbdemetra/ui/properties/Util.java @@ -17,8 +17,8 @@ package ec.nbdemetra.ui.properties; import java.util.Optional; -import javax.annotation.Nonnull; -import javax.annotation.Nullable; +import org.checkerframework.checker.nullness.qual.NonNull; +import org.checkerframework.checker.nullness.qual.Nullable; import org.openide.explorer.propertysheet.PropertyEnv; /** @@ -32,8 +32,8 @@ private Util() { // static class } - @Nonnull - public static Optional attr(@Nullable PropertyEnv env, @Nonnull String attrName, @Nonnull Class attrType) { + @NonNull + public static Optional attr(@Nullable PropertyEnv env, @NonNull String attrName, @NonNull Class attrType) { if (env == null) { return Optional.empty(); } diff --git a/nbdemetra-ui/src/main/java/ec/nbdemetra/ui/tsaction/ITsAction.java b/nbdemetra-ui/src/main/java/ec/nbdemetra/ui/tsaction/ITsAction.java index 09d33fd2f..ec00e2ecf 100644 --- a/nbdemetra-ui/src/main/java/ec/nbdemetra/ui/tsaction/ITsAction.java +++ b/nbdemetra-ui/src/main/java/ec/nbdemetra/ui/tsaction/ITsAction.java @@ -20,7 +20,7 @@ import ec.tss.Ts; import ec.tstoolkit.design.ServiceDefinition; import ec.util.various.swing.OnEDT; -import javax.annotation.Nonnull; +import org.checkerframework.checker.nullness.qual.NonNull; /** * @@ -31,5 +31,5 @@ public interface ITsAction extends INamedService { @OnEDT - void open(@Nonnull Ts ts); + void open(@NonNull Ts ts); } diff --git a/nbdemetra-ui/src/main/java/ec/nbdemetra/ui/tsproviders/AbstractDataSourceProviderBuddy.java b/nbdemetra-ui/src/main/java/ec/nbdemetra/ui/tsproviders/AbstractDataSourceProviderBuddy.java index 0f9f56117..f13d6e154 100644 --- a/nbdemetra-ui/src/main/java/ec/nbdemetra/ui/tsproviders/AbstractDataSourceProviderBuddy.java +++ b/nbdemetra-ui/src/main/java/ec/nbdemetra/ui/tsproviders/AbstractDataSourceProviderBuddy.java @@ -25,7 +25,7 @@ import java.io.IOException; import java.util.Collections; import java.util.List; -import javax.annotation.Nonnull; +import org.checkerframework.checker.nullness.qual.NonNull; import org.openide.nodes.Sheet; import org.openide.nodes.Sheet.Set; import org.openide.util.ImageUtilities; @@ -86,28 +86,27 @@ public boolean editBean(String title, Object bean) throws IntrospectionException return new PropertySheetDialogBuilder().title(title).icon(image).editSheet(sheet); } - @Nonnull + @NonNull protected List createSheetSets() { return ProvidersUtil.sheetSetsOfProvider(getProviderName()); } - @Nonnull - protected List createSheetSets(@Nonnull DataSource dataSource) { + @NonNull + protected List createSheetSets(@NonNull DataSource dataSource) { return ProvidersUtil.sheetSetsOfDataSource(dataSource, ProvidersUtil.usingErrorManager(this::createSheetSets, Collections::emptyList)); } - @Nonnull - protected List createSheetSets(@Nonnull DataSet dataSet) { + @NonNull + protected List createSheetSets(@NonNull DataSet dataSet) { return ProvidersUtil.sheetSetsOfDataSet(dataSet, this::createSheetSets, this::fillParamProperties); } - @Nonnull - protected void fillParamProperties(@Nonnull NodePropertySetBuilder b, @Nonnull DataSet dataSet) { + protected void fillParamProperties(@NonNull NodePropertySetBuilder b, @NonNull DataSet dataSet) { ProvidersUtil.fillParamProperties(b, dataSet); } - @Nonnull - protected List createSheetSets(@Nonnull Object bean) throws IntrospectionException { + @NonNull + protected List createSheetSets(@NonNull Object bean) throws IntrospectionException { return ProvidersUtil.sheetSetsOfBean(bean); } diff --git a/nbdemetra-ui/src/main/java/ec/nbdemetra/ui/tsproviders/CollectionNode.java b/nbdemetra-ui/src/main/java/ec/nbdemetra/ui/tsproviders/CollectionNode.java index 5563fe74f..9e12a3850 100644 --- a/nbdemetra-ui/src/main/java/ec/nbdemetra/ui/tsproviders/CollectionNode.java +++ b/nbdemetra-ui/src/main/java/ec/nbdemetra/ui/tsproviders/CollectionNode.java @@ -26,7 +26,7 @@ import static internal.TsEventHelper.SHOULD_BE_NONE; import java.awt.datatransfer.Transferable; import java.io.IOException; -import javax.annotation.Nonnull; +import org.checkerframework.checker.nullness.qual.NonNull; import org.openide.awt.ActionID; import org.openide.awt.ActionReference; import org.openide.awt.ActionReferences; @@ -44,7 +44,7 @@ public final class CollectionNode extends DataSetNode { public static final String ACTION_PATH = "CollectionNode"; - public CollectionNode(@Nonnull DataSet dataSet) { + public CollectionNode(@NonNull DataSet dataSet) { super(dataSet, ACTION_PATH); } diff --git a/nbdemetra-ui/src/main/java/ec/nbdemetra/ui/tsproviders/DataSetNode.java b/nbdemetra-ui/src/main/java/ec/nbdemetra/ui/tsproviders/DataSetNode.java index 0485e69de..a2497ce85 100644 --- a/nbdemetra-ui/src/main/java/ec/nbdemetra/ui/tsproviders/DataSetNode.java +++ b/nbdemetra-ui/src/main/java/ec/nbdemetra/ui/tsproviders/DataSetNode.java @@ -34,7 +34,7 @@ import java.awt.Image; import java.io.IOException; import java.util.List; -import javax.annotation.Nonnull; +import org.checkerframework.checker.nullness.qual.NonNull; import javax.swing.Action; import org.netbeans.api.actions.Openable; import org.openide.nodes.AbstractNode; @@ -59,8 +59,8 @@ abstract public class DataSetNode extends AbstractNode { * @param dataSet * @return */ - @Nonnull - public static DataSetNode create(@Nonnull DataSet dataSet) { + @NonNull + public static DataSetNode create(@NonNull DataSet dataSet) { switch (dataSet.getKind()) { case COLLECTION: return new CollectionNode(dataSet); @@ -72,7 +72,7 @@ public static DataSetNode create(@Nonnull DataSet dataSet) { // private final String actionPath; - public DataSetNode(@Nonnull DataSet dataSet, @Nonnull String actionPath) { + public DataSetNode(@NonNull DataSet dataSet, @NonNull String actionPath) { this(dataSet, new InstanceContent(), actionPath); } diff --git a/nbdemetra-ui/src/main/java/ec/nbdemetra/ui/tsproviders/DataSourceNode.java b/nbdemetra-ui/src/main/java/ec/nbdemetra/ui/tsproviders/DataSourceNode.java index 752ac9004..710f074b7 100644 --- a/nbdemetra-ui/src/main/java/ec/nbdemetra/ui/tsproviders/DataSourceNode.java +++ b/nbdemetra-ui/src/main/java/ec/nbdemetra/ui/tsproviders/DataSourceNode.java @@ -48,7 +48,7 @@ import java.io.File; import java.io.IOException; import java.util.List; -import javax.annotation.Nonnull; +import org.checkerframework.checker.nullness.qual.NonNull; import javax.swing.AbstractAction; import javax.swing.Action; import javax.swing.JButton; @@ -91,7 +91,7 @@ public final class DataSourceNode extends AbstractNode { public static final String ACTION_PATH = "SourceNode"; - public DataSourceNode(@Nonnull DataSource dataSource) { + public DataSourceNode(@NonNull DataSource dataSource) { this(dataSource, new InstanceContent()); } @@ -309,7 +309,7 @@ private static final class LocalFileTransferable extends ExTransferable.Single { private static final DataFlavor LOCAL_FILE_DATA_FLAVOR = DataTransfers.newLocalObjectDataFlavor(File.class); private final File file; - public LocalFileTransferable(@Nonnull File file) { + public LocalFileTransferable(@NonNull File file) { super(LOCAL_FILE_DATA_FLAVOR); this.file = file; } diff --git a/nbdemetra-ui/src/main/java/ec/nbdemetra/ui/tsproviders/DataSourceProviderBuddySupport.java b/nbdemetra-ui/src/main/java/ec/nbdemetra/ui/tsproviders/DataSourceProviderBuddySupport.java index 3b857bde2..7451f552c 100644 --- a/nbdemetra-ui/src/main/java/ec/nbdemetra/ui/tsproviders/DataSourceProviderBuddySupport.java +++ b/nbdemetra-ui/src/main/java/ec/nbdemetra/ui/tsproviders/DataSourceProviderBuddySupport.java @@ -30,8 +30,8 @@ import java.awt.Image; import java.io.IOException; import java.util.Optional; -import javax.annotation.Nonnull; -import javax.annotation.Nullable; +import org.checkerframework.checker.nullness.qual.NonNull; +import org.checkerframework.checker.nullness.qual.Nullable; import org.openide.util.Lookup; import org.openide.util.lookup.ServiceProvider; @@ -43,13 +43,13 @@ @ServiceProvider(service = DataSourceProviderBuddySupport.class) public class DataSourceProviderBuddySupport { - @Nonnull + @NonNull public static DataSourceProviderBuddySupport getDefault() { return Lookup.getDefault().lookup(DataSourceProviderBuddySupport.class); } @Deprecated - @Nonnull + @NonNull public static DataSourceProviderBuddySupport getInstance() { return getDefault(); } @@ -60,12 +60,12 @@ public DataSourceProviderBuddySupport() { fallback = CacheBuilder.newBuilder().build(new CacheLoaderImpl()); } - @Nonnull - protected IDataSourceProviderBuddy getFallback(@Nonnull String providerName) { + @NonNull + protected IDataSourceProviderBuddy getFallback(@NonNull String providerName) { return fallback.getUnchecked(providerName); } - @Nonnull + @NonNull public IDataSourceProviderBuddy get(@Nullable String providerName) { String tmp = Strings.nullToEmpty(providerName); return Lookup.getDefault().lookupAll(IDataSourceProviderBuddy.class).stream() @@ -75,23 +75,23 @@ public IDataSourceProviderBuddy get(@Nullable String providerName) { .orElseGet(() -> getFallback(tmp)); } - @Nonnull - public IDataSourceProviderBuddy get(@Nonnull IDataSourceProvider provider) { + @NonNull + public IDataSourceProviderBuddy get(@NonNull IDataSourceProvider provider) { return get(provider.getSource()); } - @Nonnull - public IDataSourceProviderBuddy get(@Nonnull DataSource dataSource) { + @NonNull + public IDataSourceProviderBuddy get(@NonNull DataSource dataSource) { return get(dataSource.getProviderName()); } - @Nonnull - public IDataSourceProviderBuddy get(@Nonnull DataSet dataSet) { + @NonNull + public IDataSourceProviderBuddy get(@NonNull DataSet dataSet) { return get(dataSet.getDataSource()); } - @Nonnull - public IDataSourceProviderBuddy get(@Nonnull TsMoniker moniker) { + @NonNull + public IDataSourceProviderBuddy get(@NonNull TsMoniker moniker) { return get(moniker.getSource()); } @@ -104,8 +104,8 @@ public IDataSourceProviderBuddy get(@Nonnull TsMoniker moniker) { * @return an optional icon * @since 2.2.0 */ - @Nonnull - public Optional getIcon(@Nonnull String providerName, int type, boolean opened) { + @NonNull + public Optional getIcon(@NonNull String providerName, int type, boolean opened) { return Optional.ofNullable(get(providerName).getIcon(type, opened)); } @@ -118,8 +118,8 @@ public Optional getIcon(@Nonnull String providerName, int type, boolean o * @return an optional icon * @since 2.2.0 */ - @Nonnull - public Optional getIcon(@Nonnull DataSource dataSource, int type, boolean opened) { + @NonNull + public Optional getIcon(@NonNull DataSource dataSource, int type, boolean opened) { return Optional.ofNullable(get(dataSource).getIcon(dataSource, type, opened)); } @@ -132,8 +132,8 @@ public Optional getIcon(@Nonnull DataSource dataSource, int type, boolean * @return an optional icon * @since 2.2.0 */ - @Nonnull - public Optional getIcon(@Nonnull DataSet dataSet, int type, boolean opened) { + @NonNull + public Optional getIcon(@NonNull DataSet dataSet, int type, boolean opened) { return Optional.ofNullable(get(dataSet).getIcon(dataSet, type, opened)); } @@ -147,8 +147,8 @@ public Optional getIcon(@Nonnull DataSet dataSet, int type, boolean opene * @return an optional icon * @since 2.2.0 */ - @Nonnull - public Optional getIcon(@Nonnull String providerName, @Nonnull IOException ex, int type, boolean opened) { + @NonNull + public Optional getIcon(@NonNull String providerName, @NonNull IOException ex, int type, boolean opened) { return Optional.ofNullable(get(providerName).getIcon(ex, type, opened)); } @@ -161,8 +161,8 @@ public Optional getIcon(@Nonnull String providerName, @Nonnull IOExceptio * @return an optional icon * @since 2.2.0 */ - @Nonnull - public Optional getIcon(@Nonnull TsMoniker moniker, int type, boolean opened) { + @NonNull + public Optional getIcon(@NonNull TsMoniker moniker, int type, boolean opened) { TsMoniker original = FrozenTsHelper.getOriginalMoniker(moniker); return original != null ? Optional.ofNullable(get(original).getIcon(moniker, type, opened)) : Optional.empty(); } @@ -174,8 +174,8 @@ public Optional getIcon(@Nonnull TsMoniker moniker, int type, boolean ope * @return an optional configurable * @since 2.2.0 */ - @Nonnull - public Optional getConfigurable(@Nonnull String providerName) { + @NonNull + public Optional getConfigurable(@NonNull String providerName) { IDataSourceProviderBuddy buddy = get(providerName); return buddy instanceof IConfigurable ? Optional.of((IConfigurable) buddy) : Optional.empty(); } diff --git a/nbdemetra-ui/src/main/java/ec/nbdemetra/ui/tsproviders/IDataSourceProviderBuddy.java b/nbdemetra-ui/src/main/java/ec/nbdemetra/ui/tsproviders/IDataSourceProviderBuddy.java index 1b3e714f4..3f8a8f72f 100644 --- a/nbdemetra-ui/src/main/java/ec/nbdemetra/ui/tsproviders/IDataSourceProviderBuddy.java +++ b/nbdemetra-ui/src/main/java/ec/nbdemetra/ui/tsproviders/IDataSourceProviderBuddy.java @@ -26,8 +26,8 @@ import java.beans.IntrospectionException; import java.io.IOException; import java.util.List; -import javax.annotation.Nonnull; -import javax.annotation.Nullable; +import org.checkerframework.checker.nullness.qual.NonNull; +import org.checkerframework.checker.nullness.qual.Nullable; import org.openide.nodes.Sheet; /** @@ -38,7 +38,7 @@ @ServiceDefinition public interface IDataSourceProviderBuddy { - @Nonnull + @NonNull String getProviderName(); @Nullable @@ -47,50 +47,50 @@ default Image getIcon(int type, boolean opened) { } @Nullable - default Image getIcon(@Nonnull DataSource dataSource, int type, boolean opened) { + default Image getIcon(@NonNull DataSource dataSource, int type, boolean opened) { return getIcon(type, opened); } @Nullable - default Image getIcon(@Nonnull DataSet dataSet, int type, boolean opened) { + default Image getIcon(@NonNull DataSet dataSet, int type, boolean opened) { return getIcon(dataSet.getDataSource(), type, opened); } @Nullable - default Image getIcon(@Nonnull IOException ex, int type, boolean opened) { + default Image getIcon(@NonNull IOException ex, int type, boolean opened) { return null; } @Nullable - default Image getIcon(@Nonnull TsMoniker moniker, int type, boolean opened) { + default Image getIcon(@NonNull TsMoniker moniker, int type, boolean opened) { return getIcon(type, opened); } - @Nonnull + @NonNull default Sheet createSheet() { List result = ProvidersUtil.sheetSetsOfProvider(getProviderName()); return ProvidersUtil.sheetOf(result); } - @Nonnull - default Sheet createSheet(@Nonnull DataSource dataSource) { + @NonNull + default Sheet createSheet(@NonNull DataSource dataSource) { List result = ProvidersUtil.sheetSetsOfDataSource(dataSource); return ProvidersUtil.sheetOf(result); } - @Nonnull - default Sheet createSheet(@Nonnull DataSet dataSet) { + @NonNull + default Sheet createSheet(@NonNull DataSet dataSet) { List result = ProvidersUtil.sheetSetsOfDataSet(dataSet); return ProvidersUtil.sheetOf(result); } - @Nonnull - default Sheet createSheet(@Nonnull IOException ex) { + @NonNull + default Sheet createSheet(@NonNull IOException ex) { List result = ProvidersUtil.sheetSetsOfException(ex); return ProvidersUtil.sheetOf(result); } - default boolean editBean(@Nonnull String title, @Nonnull Object bean) throws IntrospectionException { + default boolean editBean(@NonNull String title, @NonNull Object bean) throws IntrospectionException { return new PropertySheetDialogBuilder() .title(title) .icon(getIcon(BeanInfo.ICON_COLOR_16x16, false)) diff --git a/nbdemetra-ui/src/main/java/ec/nbdemetra/ui/tsproviders/ProviderNode.java b/nbdemetra-ui/src/main/java/ec/nbdemetra/ui/tsproviders/ProviderNode.java index cd17fa0f9..9f035228f 100644 --- a/nbdemetra-ui/src/main/java/ec/nbdemetra/ui/tsproviders/ProviderNode.java +++ b/nbdemetra-ui/src/main/java/ec/nbdemetra/ui/tsproviders/ProviderNode.java @@ -31,7 +31,7 @@ import java.io.IOException; import java.util.Comparator; import java.util.List; -import javax.annotation.Nonnull; +import org.checkerframework.checker.nullness.qual.NonNull; import javax.swing.Action; import org.netbeans.api.actions.Openable; import org.openide.awt.ActionID; @@ -63,7 +63,7 @@ public final class ProviderNode extends AbstractNode { public static final String ACTION_PATH = "ProviderNode"; - public ProviderNode(@Nonnull IDataSourceProvider provider) { + public ProviderNode(@NonNull IDataSourceProvider provider) { this(provider, new InstanceContent()); } diff --git a/nbdemetra-ui/src/main/java/ec/nbdemetra/ui/tsproviders/ProvidersUtil.java b/nbdemetra-ui/src/main/java/ec/nbdemetra/ui/tsproviders/ProvidersUtil.java index a545772dc..8ac413c08 100644 --- a/nbdemetra-ui/src/main/java/ec/nbdemetra/ui/tsproviders/ProvidersUtil.java +++ b/nbdemetra-ui/src/main/java/ec/nbdemetra/ui/tsproviders/ProvidersUtil.java @@ -37,7 +37,7 @@ import java.util.function.Function; import java.util.function.Supplier; import java.util.stream.Stream; -import javax.annotation.Nonnull; +import org.checkerframework.checker.nullness.qual.NonNull; import org.openide.ErrorManager; import org.openide.nodes.BeanNode; import org.openide.nodes.Node; @@ -53,13 +53,13 @@ private ProvidersUtil() { // static class } - @Nonnull + @NonNull public static String getDataSourceDomain() { return DataSource.class.getName(); } - @Nonnull - public static DataSource getDataSource(@Nonnull Config config) throws IllegalArgumentException { + @NonNull + public static DataSource getDataSource(@NonNull Config config) throws IllegalArgumentException { return config.getParam("uri") .map(DataSource.uriParser()::parse) .orElseThrow(() -> new IllegalArgumentException("Invalid config")); @@ -99,15 +99,15 @@ private static Optional find(DataSource dataSource, ProviderNode node) { return Optional.absent(); } - @Nonnull + @NonNull static Sheet sheetOf(List sets) { Sheet result = new Sheet(); sets.forEach(result::put); return result; } - @Nonnull - static List sheetSetsOfProvider(@Nonnull String providerName) { + @NonNull + static List sheetSetsOfProvider(@NonNull String providerName) { Optional op = TsProviders.lookup(IDataSourceProvider.class, providerName); if (op.isPresent()) { IDataSourceProvider provider = op.get(); @@ -124,8 +124,8 @@ static List sheetSetsOfProvider(@Nonnull String providerName) { return Collections.emptyList(); } - @Nonnull - static List sheetSetsOfBean(@Nonnull Object bean) throws IntrospectionException { + @NonNull + static List sheetSetsOfBean(@NonNull Object bean) throws IntrospectionException { List result = new ArrayList<>(); for (Node.PropertySet o : new BeanNode<>(bean).getPropertySets()) { Sheet.Set set = Sheet.createPropertiesSet(); @@ -135,8 +135,8 @@ static List sheetSetsOfBean(@Nonnull Object bean) throws Introspectio return result; } - @Nonnull - static List sheetSetsOfException(@Nonnull IOException ex) { + @NonNull + static List sheetSetsOfException(@NonNull IOException ex) { List result = new ArrayList<>(); NodePropertySetBuilder b = new NodePropertySetBuilder().name("IOException"); @@ -153,13 +153,13 @@ static List sheetSetsOfException(@Nonnull IOException ex) { return result; } - @Nonnull - static List sheetSetsOfDataSource(@Nonnull DataSource dataSource) { + @NonNull + static List sheetSetsOfDataSource(@NonNull DataSource dataSource) { return sheetSetsOfDataSource(dataSource, usingErrorManager(ProvidersUtil::sheetSetsOfBean, Collections::emptyList)); } - @Nonnull - static List sheetSetsOfDataSource(@Nonnull DataSource dataSource, @Nonnull Function> beanFunc) { + @NonNull + static List sheetSetsOfDataSource(@NonNull DataSource dataSource, @NonNull Function> beanFunc) { List result = new ArrayList<>(); NodePropertySetBuilder b = new NodePropertySetBuilder().name("DataSource"); b.with(String.class).select(dataSource, "getProviderName", null).display("Source").add(); @@ -176,20 +176,19 @@ static List sheetSetsOfDataSource(@Nonnull DataSource dataSource, @No return result; } - @Nonnull + @NonNull static List sheetSetsOfDataSet(DataSet dataSet) { return sheetSetsOfDataSet(dataSet, ProvidersUtil::sheetSetsOfDataSource, ProvidersUtil::fillParamProperties); } - @Nonnull - static void fillParamProperties(@Nonnull NodePropertySetBuilder b, @Nonnull DataSet dataSet) { + static void fillParamProperties(@NonNull NodePropertySetBuilder b, @NonNull DataSet dataSet) { dataSet.forEach((k, v) -> b.with(String.class).selectConst(k, v).add()); } - @Nonnull - static List sheetSetsOfDataSet(@Nonnull DataSet dataSet, - @Nonnull Function> sourceFunc, - @Nonnull BiConsumer paramFiller) { + @NonNull + static List sheetSetsOfDataSet(@NonNull DataSet dataSet, + @NonNull Function> sourceFunc, + @NonNull BiConsumer paramFiller) { List result = Lists.newArrayList(sourceFunc.apply(dataSet.getDataSource())); NodePropertySetBuilder b = new NodePropertySetBuilder().name("DataSet"); b.withEnum(DataSet.Kind.class).select(dataSet, "getKind", null).display("Kind").add(); @@ -204,7 +203,7 @@ interface IntrospectionFunc { Y apply(X x) throws IntrospectionException; } - @Nonnull + @NonNull static Function usingErrorManager(IntrospectionFunc func, Supplier defaultValue) { return (X x) -> { try { diff --git a/nbdemetra-ui/src/main/java/ec/nbdemetra/ui/tsproviders/SeriesNode.java b/nbdemetra-ui/src/main/java/ec/nbdemetra/ui/tsproviders/SeriesNode.java index d255cee08..29b5e1daa 100644 --- a/nbdemetra-ui/src/main/java/ec/nbdemetra/ui/tsproviders/SeriesNode.java +++ b/nbdemetra-ui/src/main/java/ec/nbdemetra/ui/tsproviders/SeriesNode.java @@ -26,7 +26,7 @@ import java.awt.datatransfer.Transferable; import java.awt.event.ActionEvent; import java.io.IOException; -import javax.annotation.Nonnull; +import org.checkerframework.checker.nullness.qual.NonNull; import javax.swing.AbstractAction; import javax.swing.Action; import org.netbeans.api.actions.Openable; @@ -49,7 +49,7 @@ public final class SeriesNode extends DataSetNode { public static final String ACTION_PATH = "SeriesNode"; - public SeriesNode(@Nonnull DataSet dataSet) { + public SeriesNode(@NonNull DataSet dataSet) { super(dataSet, ACTION_PATH); } diff --git a/nbdemetra-ui/src/main/java/ec/nbdemetra/ui/tssave/ITsSavable.java b/nbdemetra-ui/src/main/java/ec/nbdemetra/ui/tssave/ITsSavable.java index dd405dd30..30910fef0 100644 --- a/nbdemetra-ui/src/main/java/ec/nbdemetra/ui/tssave/ITsSavable.java +++ b/nbdemetra-ui/src/main/java/ec/nbdemetra/ui/tssave/ITsSavable.java @@ -20,7 +20,7 @@ import ec.tss.TsCollection; import ec.tss.TsFactory; import java.util.Arrays; -import javax.annotation.Nonnull; +import org.checkerframework.checker.nullness.qual.NonNull; /** * @@ -29,7 +29,7 @@ public interface ITsSavable { @Deprecated - @Nonnull + @NonNull Ts[] getAllTs(); /** @@ -37,7 +37,7 @@ public interface ITsSavable { * @return a non-null collection * @since 2.2.0 */ - @Nonnull + @NonNull default TsCollection getTsCollection() { TsCollection result = TsFactory.instance.createTsCollection(); result.quietAppend(Arrays.asList(getAllTs())); diff --git a/nbdemetra-ui/src/main/java/ec/nbdemetra/ui/tssave/ITsSave.java b/nbdemetra-ui/src/main/java/ec/nbdemetra/ui/tssave/ITsSave.java index 6c04e364e..0108a6372 100644 --- a/nbdemetra-ui/src/main/java/ec/nbdemetra/ui/tssave/ITsSave.java +++ b/nbdemetra-ui/src/main/java/ec/nbdemetra/ui/tssave/ITsSave.java @@ -13,7 +13,7 @@ import ec.util.various.swing.OnEDT; import java.util.function.Function; import java.util.stream.Stream; -import javax.annotation.Nonnull; +import org.checkerframework.checker.nullness.qual.NonNull; /** * @@ -24,7 +24,7 @@ public interface ITsSave extends INamedService { @OnEDT - void save(@Nonnull Ts[] input); + void save(@NonNull Ts[] input); /** * @@ -32,7 +32,7 @@ public interface ITsSave extends INamedService { * @since 2.2.0 */ @OnEDT - default void save(@Nonnull TsCollection[] input) { + default void save(@NonNull TsCollection[] input) { Function> toStream = o -> { o.load(TsInformationType.Definition); return o.stream(); diff --git a/nbdemetra-ui/src/main/java/ec/nbdemetra/ui/tssave/TsSaveAction.java b/nbdemetra-ui/src/main/java/ec/nbdemetra/ui/tssave/TsSaveAction.java index 373628fa9..7b8962672 100644 --- a/nbdemetra-ui/src/main/java/ec/nbdemetra/ui/tssave/TsSaveAction.java +++ b/nbdemetra-ui/src/main/java/ec/nbdemetra/ui/tssave/TsSaveAction.java @@ -21,7 +21,7 @@ import ec.tss.TsCollection; import java.awt.event.ActionEvent; import java.util.List; -import javax.annotation.Nonnull; +import org.checkerframework.checker.nullness.qual.NonNull; import javax.swing.AbstractAction; import javax.swing.JMenu; import javax.swing.JMenuItem; @@ -66,8 +66,8 @@ private static List getAll(Node[] activatedNodes) { .toList(); } - @Nonnull - public static JMenuItem getPopupPresenter(@Nonnull List data) { + @NonNull + public static JMenuItem getPopupPresenter(@NonNull List data) { JMenu result = new JMenu(); result.setText(Bundle.CTL_TsSaveAction()); for (ITsSave o : Lookup.getDefault().lookupAll(ITsSave.class)) { diff --git a/nbdemetra-ui/src/main/java/ec/nbdemetra/ui/tssave/TsSaveUtil.java b/nbdemetra-ui/src/main/java/ec/nbdemetra/ui/tssave/TsSaveUtil.java index a38b593a2..4178557f4 100644 --- a/nbdemetra-ui/src/main/java/ec/nbdemetra/ui/tssave/TsSaveUtil.java +++ b/nbdemetra-ui/src/main/java/ec/nbdemetra/ui/tssave/TsSaveUtil.java @@ -26,7 +26,7 @@ import java.util.Arrays; import java.util.function.Consumer; import java.util.function.Predicate; -import javax.annotation.Nonnull; +import org.checkerframework.checker.nullness.qual.NonNull; import org.openide.filesystems.FileChooserBuilder; /** @@ -36,15 +36,15 @@ @lombok.experimental.UtilityClass public class TsSaveUtil { - @Nonnull - public TsCollection[] toCollections(@Nonnull Ts[] input) { + @NonNull + public TsCollection[] toCollections(@NonNull Ts[] input) { TsCollection col = TsFactory.instance.createTsCollection(); col.quietAppend(Arrays.asList(input)); return new TsCollection[]{col}; } - @Nonnull - public TsCollectionInformation loadContent(@Nonnull TsCollection[] data) { + @NonNull + public TsCollectionInformation loadContent(@NonNull TsCollection[] data) { TsCollectionInformation result = new TsCollectionInformation(); for (TsCollection col : data) { col.load(TsInformationType.All); @@ -53,15 +53,15 @@ public TsCollectionInformation loadContent(@Nonnull TsCollection[] data) { return result; } - public void saveToFile(@Nonnull FileChooserBuilder fileChooser, @Nonnull Predicate predicate, @Nonnull Consumer action) { + public void saveToFile(@NonNull FileChooserBuilder fileChooser, @NonNull Predicate predicate, @NonNull Consumer action) { File target = fileChooser.showSaveDialog(); if (target != null && predicate.test(target)) { action.accept(target); } } - @Nonnull - public FileChooserBuilder fileChooser(@Nonnull Class type) { + @NonNull + public FileChooserBuilder fileChooser(@NonNull Class type) { return new FileChooserBuilder(type).setSelectionApprover(SingleFileExporter.overwriteApprover()); } } diff --git a/nbdemetra-ui/src/main/java/ec/nbdemetra/ui/variables/VariablesDocumentManager.java b/nbdemetra-ui/src/main/java/ec/nbdemetra/ui/variables/VariablesDocumentManager.java index 343cb5fd3..82240b8d1 100644 --- a/nbdemetra-ui/src/main/java/ec/nbdemetra/ui/variables/VariablesDocumentManager.java +++ b/nbdemetra-ui/src/main/java/ec/nbdemetra/ui/variables/VariablesDocumentManager.java @@ -103,7 +103,7 @@ public List> getDefaultItems() { // result.add(systemItem(o, manager.get(o))); // } // return result; - return Collections.EMPTY_LIST; + return Collections.emptyList(); } @Override diff --git a/nbdemetra-ui/src/main/java/ec/nbdemetra/ws/AbstractFileItemRepository.java b/nbdemetra-ui/src/main/java/ec/nbdemetra/ws/AbstractFileItemRepository.java index 1de99c0c1..29f2901ac 100644 --- a/nbdemetra-ui/src/main/java/ec/nbdemetra/ws/AbstractFileItemRepository.java +++ b/nbdemetra-ui/src/main/java/ec/nbdemetra/ws/AbstractFileItemRepository.java @@ -18,6 +18,7 @@ import java.io.IOException; import java.io.OutputStreamWriter; import java.nio.charset.StandardCharsets; +import java.nio.file.InvalidPathException; import java.util.function.Consumer; import javax.xml.bind.JAXBContext; import javax.xml.bind.JAXBException; @@ -63,7 +64,7 @@ protected static boolean loadFile(WorkspaceItem item, Consumer onSu try (FileWorkspace storage = FileWorkspace.open(file.toPath())) { onSuccess.accept((R) storage.load(toFileItem(item))); return true; - } catch (IOException ex) { + } catch (IOException | InvalidPathException ex) { Exceptions.printStackTrace(ex); } } @@ -77,7 +78,7 @@ protected static boolean storeFile(WorkspaceItem item, R value, Runnab storage.store(toFileItem(item), value); onSuccess.run(); return true; - } catch (IOException ex) { + } catch (IOException | InvalidPathException ex) { Exceptions.printStackTrace(ex); } } @@ -90,7 +91,7 @@ protected static boolean deleteFile(WorkspaceItem item) { try (FileWorkspace storage = FileWorkspace.open(file.toPath())) { storage.delete(toFileItem(item)); return true; - } catch (IOException ex) { + } catch (IOException | InvalidPathException ex) { Exceptions.printStackTrace(ex); } } diff --git a/nbdemetra-ui/src/main/java/ec/nbdemetra/ws/AbstractWorkspaceRepository.java b/nbdemetra-ui/src/main/java/ec/nbdemetra/ws/AbstractWorkspaceRepository.java index 63d5856a1..860b8b988 100644 --- a/nbdemetra-ui/src/main/java/ec/nbdemetra/ws/AbstractWorkspaceRepository.java +++ b/nbdemetra-ui/src/main/java/ec/nbdemetra/ws/AbstractWorkspaceRepository.java @@ -20,7 +20,7 @@ import java.util.HashMap; import java.util.List; import java.util.Map; -import javax.annotation.Nullable; +import org.checkerframework.checker.nullness.qual.Nullable; /** * diff --git a/nbdemetra-ui/src/main/java/ec/nbdemetra/ws/FileRepository.java b/nbdemetra-ui/src/main/java/ec/nbdemetra/ws/FileRepository.java index bfb10365b..905961347 100644 --- a/nbdemetra-ui/src/main/java/ec/nbdemetra/ws/FileRepository.java +++ b/nbdemetra-ui/src/main/java/ec/nbdemetra/ws/FileRepository.java @@ -36,12 +36,13 @@ import java.io.File; import java.io.IOException; import java.nio.file.Files; +import java.nio.file.InvalidPathException; import java.nio.file.Path; import java.util.Collection; import java.util.Optional; import java.util.function.UnaryOperator; -import javax.annotation.Nonnull; -import javax.annotation.Nullable; +import org.checkerframework.checker.nullness.qual.NonNull; +import org.checkerframework.checker.nullness.qual.Nullable; import org.openide.DialogDisplayer; import org.openide.NotifyDescriptor; import org.openide.filesystems.FileChooserBuilder; @@ -79,7 +80,7 @@ public FileRepository() { .setFileFilter(new javax.swing.filechooser.FileNameExtensionFilter("Xml files", "xml")); } - @Nonnull + @NonNull public static DataSource encode(@Nullable File file) { if (file != null) { String sfile = file.getAbsolutePath(); @@ -90,7 +91,7 @@ public static DataSource encode(@Nullable File file) { } @Nullable - public static File decode(@Nonnull DataSource source) { + public static File decode(@NonNull DataSource source) { if (!source.getProviderName().equals(NAME)) { return null; } @@ -137,17 +138,16 @@ protected boolean saveWorkspace(Workspace ws) { return saveAs(ws); } - Path target = file.toPath(); - boolean exist = Files.exists(target); + boolean exist = file.exists(); try (FileWorkspace storage = exist - ? FileWorkspace.open(target) - : FileWorkspace.create(target, FileFormat.GENERIC)) { + ? FileWorkspace.open(file.toPath()) + : FileWorkspace.create(file.toPath(), FileFormat.GENERIC)) { storage.setName(ws.getName()); storeCalendar(storage, ws.getContext().getGregorianCalendars()); if (exist) { removeDeletedItems(storage, ws); } - } catch (IOException ex) { + } catch (IOException | InvalidPathException ex) { Exceptions.printStackTrace(ex); return false; } @@ -195,7 +195,7 @@ public boolean load(Workspace ws) { ws.setName(storage.getName()); loadCalendars(storage, ws); loadItems(storage.getItems(), ws); - } catch (IOException ex) { + } catch (IOException | InvalidPathException ex) { Exceptions.printStackTrace(ex); return false; } diff --git a/nbdemetra-ui/src/main/java/ec/tss/datatransfer/DataSourceTransferHandler.java b/nbdemetra-ui/src/main/java/ec/tss/datatransfer/DataSourceTransferHandler.java index 36b6f02a4..8a6b4b72a 100644 --- a/nbdemetra-ui/src/main/java/ec/tss/datatransfer/DataSourceTransferHandler.java +++ b/nbdemetra-ui/src/main/java/ec/tss/datatransfer/DataSourceTransferHandler.java @@ -20,7 +20,7 @@ import ec.tss.tsproviders.DataSource; import ec.tstoolkit.design.ServiceDefinition; import java.awt.datatransfer.Transferable; -import javax.annotation.Nonnull; +import org.checkerframework.checker.nullness.qual.NonNull; /** * Class that can produce a DataSource from a Transferable. To be used through @@ -37,7 +37,7 @@ public abstract class DataSourceTransferHandler { * @param t the input data * @return */ - abstract public boolean canHandle(@Nonnull Transferable t); + abstract public boolean canHandle(@NonNull Transferable t); /** * Checks if this class can handle the specified Transferable with a @@ -47,7 +47,7 @@ public abstract class DataSourceTransferHandler { * @param providerName a specific provider name * @return */ - abstract public boolean canHandle(@Nonnull Transferable t, @Nonnull String providerName); + abstract public boolean canHandle(@NonNull Transferable t, @NonNull String providerName); /** * Retrieve a DataSource from a Transferable. @@ -56,8 +56,8 @@ public abstract class DataSourceTransferHandler { * @return an optional DataSource * @see #canHandle(java.awt.datatransfer.Transferable) */ - @Nonnull - abstract public Optional getDataSource(@Nonnull Transferable t); + @NonNull + abstract public Optional getDataSource(@NonNull Transferable t); /** * Retrieve a DataSource from a Transferable with a specific provider. @@ -67,6 +67,6 @@ public abstract class DataSourceTransferHandler { * @return an optional DataSource * @see #canHandle(java.awt.datatransfer.Transferable, java.lang.String) */ - @Nonnull - abstract public Optional getDataSource(@Nonnull Transferable t, @Nonnull String providerName); + @NonNull + abstract public Optional getDataSource(@NonNull Transferable t, @NonNull String providerName); } diff --git a/nbdemetra-ui/src/main/java/ec/tss/datatransfer/DataSourceTransferSupport.java b/nbdemetra-ui/src/main/java/ec/tss/datatransfer/DataSourceTransferSupport.java index 9c285c443..b4cd1c127 100644 --- a/nbdemetra-ui/src/main/java/ec/tss/datatransfer/DataSourceTransferSupport.java +++ b/nbdemetra-ui/src/main/java/ec/tss/datatransfer/DataSourceTransferSupport.java @@ -21,7 +21,7 @@ import ec.nbdemetra.core.GlobalService; import ec.tss.tsproviders.DataSource; import java.awt.datatransfer.Transferable; -import javax.annotation.Nonnull; +import org.checkerframework.checker.nullness.qual.NonNull; import org.openide.util.Lookup; import org.openide.util.lookup.ServiceProvider; @@ -34,32 +34,32 @@ @ServiceProvider(service = DataSourceTransferSupport.class) public class DataSourceTransferSupport { - @Nonnull + @NonNull public static DataSourceTransferSupport getDefault() { return Lookup.getDefault().lookup(DataSourceTransferSupport.class); } @Deprecated - @Nonnull + @NonNull public static DataSourceTransferSupport getInstance() { return getDefault(); } - @Nonnull + @NonNull public FluentIterable all() { return FluentIterable.from(Lookup.getDefault().lookupAll(DataSourceTransferHandler.class)); } - public boolean canHandle(@Nonnull Transferable t) { + public boolean canHandle(@NonNull Transferable t) { return all().anyMatch(o -> o != null ? o.canHandle(t) : false); } - public boolean canHandle(@Nonnull Transferable t, @Nonnull String providerName) { + public boolean canHandle(@NonNull Transferable t, @NonNull String providerName) { return all().anyMatch(o -> o != null ? o.canHandle(t, providerName) : false); } - @Nonnull - public Optional getDataSource(@Nonnull Transferable t) { + @NonNull + public Optional getDataSource(@NonNull Transferable t) { for (DataSourceTransferHandler o : all().filter(o -> o != null ? o.canHandle(t) : false)) { Optional dataSource = o.getDataSource(t); if (dataSource.isPresent()) { @@ -69,8 +69,8 @@ public Optional getDataSource(@Nonnull Transferable t) { return Optional.absent(); } - @Nonnull - public Optional getDataSource(@Nonnull Transferable t, @Nonnull String providerName) { + @NonNull + public Optional getDataSource(@NonNull Transferable t, @NonNull String providerName) { for (DataSourceTransferHandler o : all().filter(o -> o != null ? o.canHandle(t, providerName) : false)) { Optional dataSource = o.getDataSource(t, providerName); if (dataSource.isPresent()) { diff --git a/nbdemetra-ui/src/main/java/ec/tss/datatransfer/DataTransfers.java b/nbdemetra-ui/src/main/java/ec/tss/datatransfer/DataTransfers.java index 812eb67ec..8b81f9e12 100644 --- a/nbdemetra-ui/src/main/java/ec/tss/datatransfer/DataTransfers.java +++ b/nbdemetra-ui/src/main/java/ec/tss/datatransfer/DataTransfers.java @@ -27,7 +27,7 @@ import java.util.concurrent.ConcurrentMap; import java.util.stream.IntStream; import java.util.stream.Stream; -import javax.annotation.Nonnull; +import org.checkerframework.checker.nullness.qual.NonNull; import org.openide.util.datatransfer.ExTransferable; import org.openide.util.datatransfer.MultiTransferObject; @@ -84,25 +84,24 @@ public static Optional tryFormat(T value, IFormatter format : Optional.absent(); } - public static boolean isMultiFlavor(@Nonnull DataFlavor[] dataFlavors) { + public static boolean isMultiFlavor(@NonNull DataFlavor[] dataFlavors) { return dataFlavors.length == 1 && dataFlavors[0] == ExTransferable.multiFlavor; } - @Nonnull - public static Stream getMultiTransferables(@Nonnull Transferable t) { + @NonNull + public static Stream getMultiTransferables(@NonNull Transferable t) { return getMultiTransferObject(t) .map(DataTransfers::asTransferableStream) .orElse(Stream.of(t)); } - @Nonnull - public static Stream getMultiDataFlavors(@Nonnull Transferable t) { + @NonNull + public static Stream getMultiDataFlavors(@NonNull Transferable t) { return getMultiTransferables(t).flatMap(o -> Stream.of(o.getTransferDataFlavors())); } - @Nonnull - public static java.util.Optional getMultiTransferObject(@Nonnull Transferable t) { + public static java.util.@NonNull Optional getMultiTransferObject(@NonNull Transferable t) { if (isMultiFlavor(t.getTransferDataFlavors())) { try { return java.util.Optional.of((MultiTransferObject) t.getTransferData(ExTransferable.multiFlavor)); @@ -113,12 +112,12 @@ public static java.util.Optional getMultiTransferObject(@No return java.util.Optional.empty(); } - @Nonnull - public static Stream asTransferableStream(@Nonnull MultiTransferObject multi) { + @NonNull + public static Stream asTransferableStream(@NonNull MultiTransferObject multi) { return IntStream.range(0, multi.getCount()).mapToObj(multi::getTransferableAt); } - @Nonnull + @NonNull public static Transferable systemClipboardAsTransferable() { return new ClipboardAsTransferable(Toolkit.getDefaultToolkit().getSystemClipboard()); } diff --git a/nbdemetra-ui/src/main/java/ec/tss/datatransfer/TssTransferHandler.java b/nbdemetra-ui/src/main/java/ec/tss/datatransfer/TssTransferHandler.java index 16b705108..006307205 100644 --- a/nbdemetra-ui/src/main/java/ec/tss/datatransfer/TssTransferHandler.java +++ b/nbdemetra-ui/src/main/java/ec/tss/datatransfer/TssTransferHandler.java @@ -28,7 +28,7 @@ import java.awt.Image; import java.awt.datatransfer.DataFlavor; import java.io.IOException; -import javax.annotation.Nonnull; +import org.checkerframework.checker.nullness.qual.NonNull; import org.openide.nodes.Sheet; import org.openide.util.ImageUtilities; @@ -42,7 +42,7 @@ @ServiceDefinition(hasPosition = true) public abstract class TssTransferHandler implements INamedService { - @Nonnull + @NonNull abstract public DataFlavor getDataFlavor(); // @@ -63,72 +63,72 @@ public Sheet createSheet() { // @OnEDT - public boolean canExportTsCollection(@Nonnull TsCollection col) { + public boolean canExportTsCollection(@NonNull TsCollection col) { return false; } @OnAnyThread - @Nonnull - public Object exportTsCollection(@Nonnull TsCollection col) throws IOException { + @NonNull + public Object exportTsCollection(@NonNull TsCollection col) throws IOException { throw new UnsupportedOperationException(); } @OnEDT - public boolean canImportTsCollection(@Nonnull Object obj) { + public boolean canImportTsCollection(@NonNull Object obj) { return false; } @OnEDT - @Nonnull - public TsCollection importTsCollection(@Nonnull Object obj) throws IOException, ClassCastException { + @NonNull + public TsCollection importTsCollection(@NonNull Object obj) throws IOException, ClassCastException { throw new UnsupportedOperationException(); } // // @OnEDT - public boolean canExportMatrix(@Nonnull Matrix matrix) { + public boolean canExportMatrix(@NonNull Matrix matrix) { return false; } @OnAnyThread - @Nonnull - public Object exportMatrix(@Nonnull Matrix matrix) throws IOException { + @NonNull + public Object exportMatrix(@NonNull Matrix matrix) throws IOException { throw new UnsupportedOperationException(); } @OnEDT - public boolean canImportMatrix(@Nonnull Object obj) { + public boolean canImportMatrix(@NonNull Object obj) { return false; } @OnEDT - @Nonnull - public Matrix importMatrix(@Nonnull Object obj) throws IOException, ClassCastException { + @NonNull + public Matrix importMatrix(@NonNull Object obj) throws IOException, ClassCastException { throw new UnsupportedOperationException(); } // // @OnEDT - public boolean canExportTable(@Nonnull Table table) { + public boolean canExportTable(@NonNull Table table) { return false; } @OnAnyThread - @Nonnull - public Object exportTable(@Nonnull Table table) throws IOException { + @NonNull + public Object exportTable(@NonNull Table table) throws IOException { throw new UnsupportedOperationException(); } @OnEDT - public boolean canImportTable(@Nonnull Object obj) { + public boolean canImportTable(@NonNull Object obj) { return false; } @OnEDT - @Nonnull - public Table importTable(@Nonnull Object obj) throws IOException, ClassCastException { + @NonNull + public Table importTable(@NonNull Object obj) throws IOException, ClassCastException { throw new UnsupportedOperationException(); } // diff --git a/nbdemetra-ui/src/main/java/ec/tss/datatransfer/TssTransferSupport.java b/nbdemetra-ui/src/main/java/ec/tss/datatransfer/TssTransferSupport.java index c6ae3b6d4..39b458c90 100644 --- a/nbdemetra-ui/src/main/java/ec/tss/datatransfer/TssTransferSupport.java +++ b/nbdemetra-ui/src/main/java/ec/tss/datatransfer/TssTransferSupport.java @@ -16,7 +16,6 @@ */ package ec.tss.datatransfer; -import com.google.common.base.Preconditions; import com.google.common.collect.FluentIterable; import com.google.common.collect.Iterables; import com.google.common.collect.Sets; @@ -43,8 +42,8 @@ import java.util.function.Predicate; import java.util.stream.Collectors; import java.util.stream.Stream; -import javax.annotation.Nonnull; -import javax.annotation.Nullable; +import org.checkerframework.checker.nullness.qual.NonNull; +import org.checkerframework.checker.nullness.qual.Nullable; import org.openide.util.Lookup; import org.openide.util.lookup.ServiceProvider; import org.slf4j.Logger; @@ -72,13 +71,13 @@ public class TssTransferSupport extends ListenableBean { * * @return a non-null TssTransferSupport */ - @Nonnull + @NonNull public static TssTransferSupport getDefault() { return Lookup.getDefault().lookup(TssTransferSupport.class); } @Deprecated - @Nonnull + @NonNull public static TssTransferSupport getInstance() { return getDefault(); } @@ -124,7 +123,7 @@ private void setValidClipboard(boolean validClipboard) { * @deprecated use {@link #streamAll()} instead */ @Deprecated - @Nonnull + @NonNull public FluentIterable all() { return FluentIterable.from(Iterables.concat(lookup.lookupAll(TssTransferHandler.class), ATsCollectionFormatter.getLegacyHandlers())); } @@ -134,7 +133,7 @@ public FluentIterable all() { * * @return a non-null stream of TssTransferHandler */ - @Nonnull + @NonNull public Stream stream() { return Stream.concat(lookup.lookupAll(TssTransferHandler.class).stream(), ATsCollectionFormatter.getLegacyHandlers().stream()); } @@ -147,19 +146,19 @@ public Stream stream() { * @deprecated use {@link #all()} instead */ @Deprecated - @Nonnull + @NonNull public List getFormatters() { return new ArrayList<>(); } @OnEDT - public boolean canImport(@Nonnull DataFlavor... dataFlavors) { + public boolean canImport(@NonNull DataFlavor... dataFlavors) { // multiFlavor means "maybe", not "yes" return DataTransfers.isMultiFlavor(dataFlavors) || stream().anyMatch(onDataFlavors(dataFlavors)); } @OnEDT - public boolean canImport(@Nonnull Transferable transferable) { + public boolean canImport(@NonNull Transferable transferable) { Set dataFlavors = DataTransfers.getMultiDataFlavors(transferable).collect(Collectors.toSet()); return stream().anyMatch(onDataFlavors(dataFlavors)); } @@ -171,9 +170,9 @@ public boolean canImport(@Nonnull Transferable transferable) { * @return a never-null {@link Transferable} */ @OnEDT - @Nonnull - public Transferable fromTsData(@Nonnull TsData data) { - Preconditions.checkNotNull(data); + @NonNull + public Transferable fromTsData(@NonNull TsData data) { + Objects.requireNonNull(data); return fromTs(TsFactory.instance.createTs("", null, data)); } @@ -184,9 +183,9 @@ public Transferable fromTsData(@Nonnull TsData data) { * @return a never-null {@link Transferable} */ @OnEDT - @Nonnull - public Transferable fromTs(@Nonnull Ts ts) { - Preconditions.checkNotNull(ts); + @NonNull + public Transferable fromTs(@NonNull Ts ts) { + Objects.requireNonNull(ts); TsCollection col = TsFactory.instance.createTsCollection(); col.quietAdd(ts); return fromTsCollection(col); @@ -199,9 +198,9 @@ public Transferable fromTs(@Nonnull Ts ts) { * @return a never-null {@link Transferable} */ @OnEDT - @Nonnull - public Transferable fromTsCollection(@Nonnull TsCollection col) { - Preconditions.checkNotNull(col); + @NonNull + public Transferable fromTsCollection(@NonNull TsCollection col) { + Objects.requireNonNull(col); return asTransferable(col, stream(), TsCollectionHelper.INSTANCE); } @@ -212,9 +211,9 @@ public Transferable fromTsCollection(@Nonnull TsCollection col) { * @return a never-null {@link Transferable} */ @OnEDT - @Nonnull - public Transferable fromMatrix(@Nonnull Matrix matrix) { - Preconditions.checkNotNull(matrix); + @NonNull + public Transferable fromMatrix(@NonNull Matrix matrix) { + Objects.requireNonNull(matrix); return asTransferable(matrix, stream(), MatrixHelper.INSTANCE); } @@ -225,9 +224,9 @@ public Transferable fromMatrix(@Nonnull Matrix matrix) { * @return a never-null {@link Transferable} */ @OnEDT - @Nonnull - public Transferable fromTable(@Nonnull Table table) { - Preconditions.checkNotNull(table); + @NonNull + public Transferable fromTable(@NonNull Table table) { + Objects.requireNonNull(table); return asTransferable(table, stream(), TableHelper.INSTANCE); } @@ -239,7 +238,7 @@ public Transferable fromTable(@Nonnull Table table) { */ @OnEDT @Nullable - public TsData toTsData(@Nonnull Transferable transferable) { + public TsData toTsData(@NonNull Transferable transferable) { Ts ts = toTs(transferable); if (ts != null) { ts.load(TsInformationType.Data); @@ -262,7 +261,7 @@ public TsData toTsData(@Nonnull Transferable transferable) { */ @OnEDT @Nullable - public Ts toTs(@Nonnull Transferable transferable) { + public Ts toTs(@NonNull Transferable transferable) { TsCollection col = toTsCollection(transferable); return col != null && !col.isEmpty() ? col.get(0) : null; } @@ -280,8 +279,8 @@ public Ts toTs(@Nonnull Transferable transferable) { */ @OnEDT @Nullable - public TsCollection toTsCollection(@Nonnull Transferable transferable) { - Preconditions.checkNotNull(transferable); + public TsCollection toTsCollection(@NonNull Transferable transferable) { + Objects.requireNonNull(transferable); return stream() .filter(onDataFlavors(transferable.getTransferDataFlavors())) .map(o -> toTsCollection(o, transferable, logger)) @@ -291,8 +290,8 @@ public TsCollection toTsCollection(@Nonnull Transferable transferable) { } @OnEDT - @Nonnull - public Stream toTsCollectionStream(@Nonnull Transferable transferable) { + @NonNull + public Stream toTsCollectionStream(@NonNull Transferable transferable) { return DataTransfers.getMultiTransferables(transferable) .map(this::toTsCollection) .filter(Objects::nonNull); @@ -306,8 +305,8 @@ public Stream toTsCollectionStream(@Nonnull Transferable transfera */ @OnEDT @Nullable - public Matrix toMatrix(@Nonnull Transferable transferable) { - Preconditions.checkNotNull(transferable); + public Matrix toMatrix(@NonNull Transferable transferable) { + Objects.requireNonNull(transferable); return stream() .filter(onDataFlavors(transferable.getTransferDataFlavors())) .map(o -> toMatrix(o, transferable, logger)) @@ -324,8 +323,8 @@ public Matrix toMatrix(@Nonnull Transferable transferable) { */ @OnEDT @Nullable - public Table toTable(@Nonnull Transferable transferable) { - Preconditions.checkNotNull(transferable); + public Table toTable(@NonNull Transferable transferable) { + Objects.requireNonNull(transferable); return stream() .filter(onDataFlavors(transferable.getTransferDataFlavors())) .map(o -> toTable(o, transferable, logger)) @@ -341,12 +340,12 @@ public Table toTable(@Nonnull Transferable transferable) { * @param transferable * @return */ - public boolean isTssTransferable(@Nonnull Transferable transferable) { + public boolean isTssTransferable(@NonNull Transferable transferable) { return transferable.isDataFlavorSupported(LocalObjectTssTransferHandler.DATA_FLAVOR); } @Deprecated - public static boolean isMultiFlavor(@Nonnull DataFlavor[] dataFlavors) { + public static boolean isMultiFlavor(@NonNull DataFlavor[] dataFlavors) { return DataTransfers.isMultiFlavor(dataFlavors); } diff --git a/nbdemetra-ui/src/main/java/ec/tss/datatransfer/impl/LocalObjectTssTransferHandler.java b/nbdemetra-ui/src/main/java/ec/tss/datatransfer/impl/LocalObjectTssTransferHandler.java index e8875de3c..78916ccc3 100644 --- a/nbdemetra-ui/src/main/java/ec/tss/datatransfer/impl/LocalObjectTssTransferHandler.java +++ b/nbdemetra-ui/src/main/java/ec/tss/datatransfer/impl/LocalObjectTssTransferHandler.java @@ -13,8 +13,8 @@ import java.awt.datatransfer.Transferable; import java.awt.datatransfer.UnsupportedFlavorException; import java.io.IOException; -import javax.annotation.Nonnull; -import javax.annotation.Nullable; +import org.checkerframework.checker.nullness.qual.NonNull; +import org.checkerframework.checker.nullness.qual.Nullable; import org.openide.util.Exceptions; import org.openide.util.lookup.ServiceProvider; @@ -106,7 +106,7 @@ public Table importTable(Object obj) throws IOException, ClassCastException { } @Nullable - public TsCollection peekTsCollection(@Nonnull Transferable t) { + public TsCollection peekTsCollection(@NonNull Transferable t) { if (t.isDataFlavorSupported(DATA_FLAVOR)) { try { Object data = t.getTransferData(DATA_FLAVOR); diff --git a/nbdemetra-ui/src/main/java/ec/ui/ATsCollectionView.java b/nbdemetra-ui/src/main/java/ec/ui/ATsCollectionView.java index ff3d70b52..da6172755 100644 --- a/nbdemetra-ui/src/main/java/ec/ui/ATsCollectionView.java +++ b/nbdemetra-ui/src/main/java/ec/ui/ATsCollectionView.java @@ -61,8 +61,8 @@ import java.util.Observer; import java.util.function.Supplier; import java.util.stream.Stream; -import javax.annotation.Nonnull; -import javax.annotation.Nullable; +import org.checkerframework.checker.nullness.qual.NonNull; +import org.checkerframework.checker.nullness.qual.Nullable; import javax.swing.ActionMap; import javax.swing.InputMap; import javax.swing.JCheckBoxMenuItem; @@ -599,7 +599,7 @@ public boolean importData(TransferSupport support) { } } - public static boolean canImport(@Nonnull ITsCollectionView view, @Nonnull Supplier toData) { + public static boolean canImport(@NonNull ITsCollectionView view, @NonNull Supplier toData) { if (!view.getTsUpdateMode().isReadOnly()) { Transferable t = toData.get(); return TssTransferSupport.getDefault().canImport(t) @@ -608,7 +608,7 @@ public static boolean canImport(@Nonnull ITsCollectionView view, @Nonnull Suppli return false; } - public static boolean importData(@Nonnull ITsCollectionView view, @Nonnull Supplier toData) { + public static boolean importData(@NonNull ITsCollectionView view, @NonNull Supplier toData) { if (!view.getTsUpdateMode().isReadOnly()) { return TssTransferSupport.getDefault() .toTsCollectionStream(toData.get()) @@ -659,7 +659,7 @@ private static TransferChange of(LocalObjectTssTransferHandler handler, Transfer .orElse(NO); } - private static TransferChange of(@Nullable TsCollection source, @Nonnull TsCollection target) { + private static TransferChange of(@Nullable TsCollection source, @NonNull TsCollection target) { if (source == null) { return MAYBE; } diff --git a/nbdemetra-ui/src/main/java/ec/ui/ATsView.java b/nbdemetra-ui/src/main/java/ec/ui/ATsView.java index c25ec80d1..fef9e6581 100644 --- a/nbdemetra-ui/src/main/java/ec/ui/ATsView.java +++ b/nbdemetra-ui/src/main/java/ec/ui/ATsView.java @@ -28,7 +28,7 @@ import internal.TsEventHelper; import java.util.Observable; import java.util.Observer; -import javax.annotation.Nullable; +import org.checkerframework.checker.nullness.qual.Nullable; import javax.swing.TransferHandler; /** diff --git a/nbdemetra-ui/src/main/java/ec/ui/DemoUtils.java b/nbdemetra-ui/src/main/java/ec/ui/DemoUtils.java index de9efff9b..6ccf1969a 100644 --- a/nbdemetra-ui/src/main/java/ec/ui/DemoUtils.java +++ b/nbdemetra-ui/src/main/java/ec/ui/DemoUtils.java @@ -29,8 +29,8 @@ import java.util.Date; import java.util.concurrent.atomic.AtomicLong; import java.util.stream.IntStream; -import javax.annotation.Nonnegative; -import javax.annotation.Nonnull; +import org.checkerframework.checker.index.qual.NonNegative; +import org.checkerframework.checker.nullness.qual.NonNull; /** * @@ -42,13 +42,13 @@ private DemoUtils() { // static class } - @Nonnull + @NonNull public static TsCollection randomTsCollection(int nSeries) { return randomTsCollection(nSeries, 24, new XorshiftRNG(0)); } - @Nonnull - public static TsCollection randomTsCollection(@Nonnegative int nSeries, @Nonnegative int nObs, @Nonnull IRandomNumberGenerator rng) { + @NonNull + public static TsCollection randomTsCollection(@NonNegative int nSeries, @NonNegative int nObs, @NonNull IRandomNumberGenerator rng) { RandomTsBuilder builder = new RandomTsBuilder(); return IntStream.range(0, nSeries) .mapToObj(o -> builder.withObsCount(nObs).withRng(rng).withName("S" + o).build().toTs()) @@ -80,63 +80,63 @@ public RandomTsCollectionBuilder() { } // - @Nonnull - public RandomTsCollectionBuilder withSeries(@Nonnegative int count) { + @NonNull + public RandomTsCollectionBuilder withSeries(@NonNegative int count) { this.nSeries = count; return this; } - @Nonnull - public RandomTsCollectionBuilder withObs(@Nonnegative int count) { + @NonNull + public RandomTsCollectionBuilder withObs(@NonNegative int count) { delegate.withObsCount(count); return this; } - @Nonnull - public RandomTsCollectionBuilder withRNG(@Nonnull IRandomNumberGenerator rng) { + @NonNull + public RandomTsCollectionBuilder withRNG(@NonNull IRandomNumberGenerator rng) { delegate.withRng(rng); return this; } - @Nonnull - public RandomTsCollectionBuilder withForecast(@Nonnegative int count) { + @NonNull + public RandomTsCollectionBuilder withForecast(@NonNegative int count) { delegate.withForecastCount(count); return this; } - @Nonnull + @NonNull public RandomTsCollectionBuilder withStartTimeMillis(long time) { this.startTimeMillis = time; return this; } - @Nonnull - public RandomTsCollectionBuilder withFrequency(@Nonnull TsFrequency frequency) { + @NonNull + public RandomTsCollectionBuilder withFrequency(@NonNull TsFrequency frequency) { this.frequency = frequency; return this; } - @Nonnull - public RandomTsCollectionBuilder withStartPeriod(@Nonnull TsPeriod period) { + @NonNull + public RandomTsCollectionBuilder withStartPeriod(@NonNull TsPeriod period) { this.frequency = period.getFrequency(); this.startTimeMillis = period.firstday().getTimeInMillis(); return this; } - @Nonnull - public RandomTsCollectionBuilder withStatus(@Nonnull TsStatus status) { + @NonNull + public RandomTsCollectionBuilder withStatus(@NonNull TsStatus status) { delegate.withStatus(status); return this; } - @Nonnull - public RandomTsCollectionBuilder withNaming(@Nonnull TsNamingScheme naming) { + @NonNull + public RandomTsCollectionBuilder withNaming(@NonNull TsNamingScheme naming) { this.naming = naming; return this; } - @Nonnull - public RandomTsCollectionBuilder withMissingValues(@Nonnegative int missingValues) { + @NonNull + public RandomTsCollectionBuilder withMissingValues(@NonNegative int missingValues) { delegate.withMissingCount(missingValues); return this; } diff --git a/nbdemetra-ui/src/main/java/ec/ui/ExtAction.java b/nbdemetra-ui/src/main/java/ec/ui/ExtAction.java index 4d6c5cc98..67b69cec3 100644 --- a/nbdemetra-ui/src/main/java/ec/ui/ExtAction.java +++ b/nbdemetra-ui/src/main/java/ec/ui/ExtAction.java @@ -18,7 +18,7 @@ import java.awt.Component; import java.beans.PropertyChangeListener; -import javax.annotation.Nonnull; +import org.checkerframework.checker.nullness.qual.NonNull; import javax.swing.AbstractAction; import javax.swing.AbstractButton; import javax.swing.Action; @@ -109,8 +109,8 @@ public void set(Action action) { abstract protected boolean canSelect(); } - @Nonnull - public static C hideWhenDisabled(@Nonnull C c) { + @NonNull + public static C hideWhenDisabled(@NonNull C c) { c.setVisible(c.isEnabled()); c.addPropertyChangeListener(HIDE); return c; diff --git a/nbdemetra-ui/src/main/java/ec/ui/chart/JTimeSeriesChartUtil.java b/nbdemetra-ui/src/main/java/ec/ui/chart/JTimeSeriesChartUtil.java index ff13aa5f3..edf10a9cd 100644 --- a/nbdemetra-ui/src/main/java/ec/ui/chart/JTimeSeriesChartUtil.java +++ b/nbdemetra-ui/src/main/java/ec/ui/chart/JTimeSeriesChartUtil.java @@ -27,7 +27,7 @@ import static ec.util.chart.swing.JTimeSeriesChartCommand.saveImage; import ec.util.chart.swing.SwingColorSchemeSupport; import java.awt.Color; -import javax.annotation.Nonnull; +import org.checkerframework.checker.nullness.qual.NonNull; import javax.swing.JMenu; /** @@ -40,16 +40,16 @@ private JTimeSeriesChartUtil() { // static class } - @Nonnull - public static ThemeSupport newThemeSupport(@Nonnull JTimeSeriesChart chart) { + @NonNull + public static ThemeSupport newThemeSupport(@NonNull JTimeSeriesChart chart) { return new ThemeSupportImpl(chart); } - public static void setColorScheme(@Nonnull JTimeSeriesChart chart, @Nonnull ColorScheme colorScheme) { + public static void setColorScheme(@NonNull JTimeSeriesChart chart, @NonNull ColorScheme colorScheme) { chart.setColorSchemeSupport(SwingColorSchemeSupport.from(colorScheme)); } - public static void setDataFormat(@Nonnull JTimeSeriesChart chart, @Nonnull DataFormat dataFormat) { + public static void setDataFormat(@NonNull JTimeSeriesChart chart, @NonNull DataFormat dataFormat) { try { chart.setPeriodFormat(dataFormat.newDateFormat()); } catch (IllegalArgumentException ex) { @@ -62,7 +62,7 @@ public static void setDataFormat(@Nonnull JTimeSeriesChart chart, @Nonnull DataF } } - public static void setSeriesColorist(final @Nonnull JTimeSeriesChart chart, final @Nonnull SeriesFunction colorist) { + public static void setSeriesColorist(final @NonNull JTimeSeriesChart chart, final @NonNull SeriesFunction colorist) { chart.setSeriesColorist(new SeriesFunction() { @Override public Color apply(int series) { @@ -72,8 +72,8 @@ public Color apply(int series) { }); } - @Nonnull - public static JMenu newExportImageMenu(@Nonnull JTimeSeriesChart chart) { + @NonNull + public static JMenu newExportImageMenu(@NonNull JTimeSeriesChart chart) { JMenu result = new JMenu("Export image to"); result.add(printImage().toAction(chart)).setText("Printer..."); result.add(copyImage().toAction(chart)).setText("Clipboard"); @@ -81,8 +81,8 @@ public static JMenu newExportImageMenu(@Nonnull JTimeSeriesChart chart) { return result; } - @Nonnull - public static ITsPrinter newTsPrinter(@Nonnull JTimeSeriesChart chart) { + @NonNull + public static ITsPrinter newTsPrinter(@NonNull JTimeSeriesChart chart) { return new TsPrinterImpl(chart); } diff --git a/nbdemetra-ui/src/main/java/ec/ui/chart/JTsChart.java b/nbdemetra-ui/src/main/java/ec/ui/chart/JTsChart.java index 21edb9320..a2ccbe0e9 100644 --- a/nbdemetra-ui/src/main/java/ec/ui/chart/JTsChart.java +++ b/nbdemetra-ui/src/main/java/ec/ui/chart/JTsChart.java @@ -64,8 +64,8 @@ import java.beans.PropertyChangeListener; import java.util.Date; import java.util.TooManyListenersException; -import javax.annotation.Nonnull; -import javax.annotation.Nullable; +import org.checkerframework.checker.nullness.qual.NonNull; +import org.checkerframework.checker.nullness.qual.Nullable; import javax.swing.JMenu; import javax.swing.JMenuItem; import javax.swing.JPopupMenu; @@ -355,7 +355,7 @@ private void onHoveredObsChange() { // // - @Nonnull + @NonNull public ObsIndex getHoveredObs() { return hoveredObs; } diff --git a/nbdemetra-ui/src/main/java/ec/ui/chart/TsXYDatasets.java b/nbdemetra-ui/src/main/java/ec/ui/chart/TsXYDatasets.java index 9db817f5d..7d6b93b3c 100644 --- a/nbdemetra-ui/src/main/java/ec/ui/chart/TsXYDatasets.java +++ b/nbdemetra-ui/src/main/java/ec/ui/chart/TsXYDatasets.java @@ -17,7 +17,6 @@ package ec.ui.chart; import com.google.common.base.Preconditions; -import static com.google.common.base.Preconditions.checkNotNull; import com.google.common.collect.ImmutableList; import ec.tss.*; import ec.tstoolkit.design.IBuilder; @@ -30,8 +29,9 @@ import java.util.Calendar; import java.util.HashSet; import java.util.List; +import java.util.Objects; import java.util.Set; -import javax.annotation.Nonnull; +import org.checkerframework.checker.nullness.qual.NonNull; import org.jfree.data.DomainOrder; import org.jfree.data.general.AbstractSeriesDataset; import org.jfree.data.xy.IntervalXYDataset; @@ -52,23 +52,23 @@ private TsXYDatasets() { // a shared builder used in the event dispatch thread private static final Builder EDT_BUILDER = new Builder(); - @Nonnull - public static IntervalXYDataset from(@Nonnull Comparable key, @Nonnull TsPeriod start, @Nonnull double[] data) { + @NonNull + public static IntervalXYDataset from(@NonNull Comparable key, @NonNull TsPeriod start, @NonNull double[] data) { return EDT_BUILDER.clear().add(key, start, data).build(); } - @Nonnull - public static IntervalXYDataset from(@Nonnull Comparable key, @Nonnull TsData data) { + @NonNull + public static IntervalXYDataset from(@NonNull Comparable key, @NonNull TsData data) { return EDT_BUILDER.clear().add(key, data).build(); } - @Nonnull - public static IntervalXYDataset from(@Nonnull Iterable tss) { + @NonNull + public static IntervalXYDataset from(@NonNull Iterable tss) { return EDT_BUILDER.clear().add(tss).build(); } - @Nonnull - public static IntervalXYDataset from(@Nonnull Ts... tss) { + @NonNull + public static IntervalXYDataset from(@NonNull Ts... tss) { return EDT_BUILDER.clear().add(tss).build(); } @@ -78,12 +78,12 @@ public static IntervalXYDataset from(@Nonnull Ts... tss) { * @deprecated use {@link Charts#emptyXYDataset()} instead */ @Deprecated - @Nonnull + @NonNull public static IntervalXYDataset empty() { return Charts.emptyXYDataset(); } - @Nonnull + @NonNull @NewObject public static Builder builder() { return new Builder(); @@ -96,7 +96,7 @@ public static final class Builder implements IBuilder { private final List list = new ArrayList<>(); private void checkKey(Comparable key) { - Preconditions.checkNotNull(key, "Cannot add null key"); + Objects.requireNonNull(key, "Cannot add null key"); Preconditions.checkArgument(!keys.contains(key), "Duplicated key"); } @@ -106,51 +106,51 @@ private void add(TsFacade item) { } private void addTs(Ts ts) { - checkNotNull(ts, "Ts cannot be null"); + Objects.requireNonNull(ts, "Ts cannot be null"); checkKey(ts.getMoniker()); if (ts.hasData().equals(TsStatus.Valid)) { add(FastTs.create(ts)); } } - @Nonnull - public Builder add(@Nonnull Comparable key, @Nonnull TsPeriod start, @Nonnull double[] data) { + @NonNull + public Builder add(@NonNull Comparable key, @NonNull TsPeriod start, @NonNull double[] data) { checkKey(key); - checkNotNull(start, "Start cannot be null"); - checkNotNull(data, "Data cannot be null"); + Objects.requireNonNull(start, "Start cannot be null"); + Objects.requireNonNull(data, "Data cannot be null"); if (data.length > 0) { add(FastTs.create(key, start, data)); } return this; } - @Nonnull - public Builder add(@Nonnull Comparable key, @Nonnull TsData data) { + @NonNull + public Builder add(@NonNull Comparable key, @NonNull TsData data) { checkKey(key); - checkNotNull(data, "Data cannot be null"); + Objects.requireNonNull(data, "Data cannot be null"); if (!data.isEmpty()) { add(FastTs.create(key, data)); } return this; } - @Nonnull - public Builder add(@Nonnull Iterable tss) { + @NonNull + public Builder add(@NonNull Iterable tss) { for (Ts o : tss) { addTs(o); } return this; } - @Nonnull - public Builder add(@Nonnull Ts... tss) { + @NonNull + public Builder add(@NonNull Ts... tss) { for (Ts o : tss) { addTs(o); } return this; } - @Nonnull + @NonNull public Builder clear() { keys.clear(); list.clear(); @@ -223,7 +223,7 @@ private static final class MultiTsXYDataset extends AbstractTsXYDataset { private final List list; - private MultiTsXYDataset(@Nonnull List list) { + private MultiTsXYDataset(@NonNull List list) { this.list = list; } @@ -267,7 +267,7 @@ private static final class SingleTsXYDataset extends AbstractTsXYDataset { private final TsFacade singleton; - private SingleTsXYDataset(@Nonnull TsFacade singleton) { + private SingleTsXYDataset(@NonNull TsFacade singleton) { this.singleton = singleton; } @@ -333,18 +333,18 @@ private static final class FastTs implements TsFacade { private static final Calendar EDT_CALENDAR = Calendar.getInstance(); // FACTORY METHODS - @Nonnull - static FastTs create(@Nonnull Ts ts) { + @NonNull + static FastTs create(@NonNull Ts ts) { return create(ts.getMoniker(), ts.getTsData()); } - @Nonnull - static FastTs create(@Nonnull Comparable key, @Nonnull TsData data) { + @NonNull + static FastTs create(@NonNull Comparable key, @NonNull TsData data) { return create(key, data.getStart(), data.internalStorage()); } - @Nonnull - static FastTs create(@Nonnull Comparable key, @Nonnull TsPeriod start, @Nonnull double[] data) { + @NonNull + static FastTs create(@NonNull Comparable key, @NonNull TsPeriod start, @NonNull double[] data) { int freq = start.getFrequency().intValue(); int id = start.hashCode(); // quick&dirty hack return (id >= 0) @@ -359,7 +359,7 @@ static FastTs create(@Nonnull Comparable key, @Nonnull TsPeriod start, @Nonnu private final int startPos; private final double[] data; - private FastTs(@Nonnull Calendar cal, @Nonnull Comparable key, int freq, int startYear, int startPos, @Nonnull double[] data) { + private FastTs(@NonNull Calendar cal, @NonNull Comparable key, int freq, int startYear, int startPos, @NonNull double[] data) { this.cal = cal; this.key = key; this.freq = freq; diff --git a/nbdemetra-ui/src/main/java/ec/ui/commands/ColorSchemeCommand.java b/nbdemetra-ui/src/main/java/ec/ui/commands/ColorSchemeCommand.java index 73d30c4e7..7dba187ff 100644 --- a/nbdemetra-ui/src/main/java/ec/ui/commands/ColorSchemeCommand.java +++ b/nbdemetra-ui/src/main/java/ec/ui/commands/ColorSchemeCommand.java @@ -22,8 +22,8 @@ import ec.util.chart.ColorScheme; import ec.util.various.swing.JCommand; import java.util.Objects; -import javax.annotation.Nonnull; -import javax.annotation.Nullable; +import org.checkerframework.checker.nullness.qual.NonNull; +import org.checkerframework.checker.nullness.qual.Nullable; /** * @@ -36,7 +36,7 @@ private ColorSchemeCommand() { // static class } - @Nonnull + @NonNull public static JCommand applyColorScheme(@Nullable ColorScheme colorScheme) { return new ApplyColorSchemeCommand(colorScheme); } diff --git a/nbdemetra-ui/src/main/java/ec/ui/commands/GridCommand.java b/nbdemetra-ui/src/main/java/ec/ui/commands/GridCommand.java index deb7225f2..7cb2d74af 100644 --- a/nbdemetra-ui/src/main/java/ec/ui/commands/GridCommand.java +++ b/nbdemetra-ui/src/main/java/ec/ui/commands/GridCommand.java @@ -20,7 +20,7 @@ import ec.ui.interfaces.IZoomableGrid; import static ec.ui.interfaces.IZoomableGrid.ZOOM_PROPERTY; import ec.util.various.swing.JCommand; -import javax.annotation.Nonnull; +import org.checkerframework.checker.nullness.qual.NonNull; /** * @@ -29,12 +29,12 @@ @UtilityClass(IZoomableGrid.class) public class GridCommand { - @Nonnull + @NonNull public static JCommand applyZoomRatio(int zoomRatio) { return new ZoomRatioCommand(zoomRatio); } - @Nonnull + @NonNull public static JCommand applyColorScale(double scale) { return new ColorScaleCommand(scale); } diff --git a/nbdemetra-ui/src/main/java/ec/ui/commands/TsChartCommand.java b/nbdemetra-ui/src/main/java/ec/ui/commands/TsChartCommand.java index 75df43d82..477654553 100644 --- a/nbdemetra-ui/src/main/java/ec/ui/commands/TsChartCommand.java +++ b/nbdemetra-ui/src/main/java/ec/ui/commands/TsChartCommand.java @@ -39,7 +39,7 @@ import static ec.ui.interfaces.ITsCollectionView.SELECTION_PROPERTY; import ec.util.various.swing.JCommand; import java.util.Calendar; -import javax.annotation.Nonnull; +import org.checkerframework.checker.nullness.qual.NonNull; import javax.swing.Icon; import org.openide.util.ImageUtilities; import org.openide.util.NbCollections; @@ -55,27 +55,27 @@ private TsChartCommand() { // static class } - @Nonnull + @NonNull public static JCommand toggleTitleVisibility() { return ToggleTitleVisibilityCommand.INSTANCE; } - @Nonnull + @NonNull public static JCommand toggleLegendVisibility() { return ToggleLegendVisibilityCommand.INSTANCE; } - @Nonnull - public static JCommand applyLineThickNess(@Nonnull ITsChart.LinesThickness thickness) { + @NonNull + public static JCommand applyLineThickNess(ITsChart.@NonNull LinesThickness thickness) { return ITsChart.LinesThickness.Thick.equals(thickness) ? ApplyLineThickNessCommand.THICK : ApplyLineThickNessCommand.THIN; } - @Nonnull + @NonNull public static JCommand showAll() { return ShowAllCommand.INSTANCE; } - @Nonnull + @NonNull public static JCommand splitIntoYearlyComponents() { return SplitIntoYearlyComponentsCommand.INSTANCE; } diff --git a/nbdemetra-ui/src/main/java/ec/ui/commands/TsCollectionViewCommand.java b/nbdemetra-ui/src/main/java/ec/ui/commands/TsCollectionViewCommand.java index 9c1d2625d..89ae3d8e3 100644 --- a/nbdemetra-ui/src/main/java/ec/ui/commands/TsCollectionViewCommand.java +++ b/nbdemetra-ui/src/main/java/ec/ui/commands/TsCollectionViewCommand.java @@ -44,7 +44,7 @@ import java.beans.PropertyChangeListener; import java.util.Arrays; import java.util.EnumMap; -import javax.annotation.Nonnull; +import org.checkerframework.checker.nullness.qual.NonNull; import javax.swing.AbstractAction; import javax.swing.JButton; import org.openide.DialogDisplayer; @@ -62,62 +62,62 @@ private TsCollectionViewCommand() { // static class } - @Nonnull + @NonNull public static JCommand rename() { return RenameCommand.INSTANCE; } - @Nonnull + @NonNull public static JCommand open() { return OpenCommand.INSTANCE; } - @Nonnull - public static JCommand openWith(@Nonnull ITsAction tsAction) { + @NonNull + public static JCommand openWith(@NonNull ITsAction tsAction) { return new OpenWithCommand(tsAction); } - @Nonnull - public static JCommand save(@Nonnull ITsSave tsSave) { + @NonNull + public static JCommand save(@NonNull ITsSave tsSave) { return new SaveCommand(tsSave); } - @Nonnull + @NonNull public static JCommand copy() { return CopyCommand.INSTANCE; } - @Nonnull + @NonNull public static JCommand copyAll() { return CopyAllCommand.INSTANCE; } - @Nonnull + @NonNull public static JCommand paste() { return PasteCommand.INSTANCE; } - @Nonnull + @NonNull public static JCommand delete() { return DeleteCommand.INSTANCE; } - @Nonnull + @NonNull public static JCommand clear() { return ClearCommand.INSTANCE; } - @Nonnull + @NonNull public static JCommand selectAll() { return SelectAllCommand.INSTANCE; } - @Nonnull - public static JCommand selectByFreq(@Nonnull TsFrequency freq) { + @NonNull + public static JCommand selectByFreq(@NonNull TsFrequency freq) { return SelectByFreqCommand.VALUES.get(freq); } - @Nonnull + @NonNull public static JCommand freeze() { return FreezeCommand.INSTANCE; } @@ -225,7 +225,7 @@ private static final class OpenWithCommand extends SingleSelectionCommand { private final ITsAction tsAction; - public OpenWithCommand(@Nonnull ITsAction tsAction) { + public OpenWithCommand(@NonNull ITsAction tsAction) { this.tsAction = tsAction; } @@ -243,7 +243,7 @@ private static final class SaveCommand extends AnySelectionCommand { private final ITsSave tsSave; - SaveCommand(@Nonnull ITsSave tsSave) { + SaveCommand(@NonNull ITsSave tsSave) { this.tsSave = tsSave; } diff --git a/nbdemetra-ui/src/main/java/ec/ui/commands/TsControlCommand.java b/nbdemetra-ui/src/main/java/ec/ui/commands/TsControlCommand.java index 083281e2a..3930f91c2 100644 --- a/nbdemetra-ui/src/main/java/ec/ui/commands/TsControlCommand.java +++ b/nbdemetra-ui/src/main/java/ec/ui/commands/TsControlCommand.java @@ -25,8 +25,8 @@ import java.awt.Dimension; import java.awt.FlowLayout; import java.util.Objects; -import javax.annotation.Nonnull; -import javax.annotation.Nullable; +import org.checkerframework.checker.nullness.qual.NonNull; +import org.checkerframework.checker.nullness.qual.Nullable; import javax.swing.BorderFactory; import javax.swing.JButton; import javax.swing.JPanel; @@ -44,17 +44,17 @@ private TsControlCommand() { // static class } - @Nonnull + @NonNull public static JCommand printPreview() { return PrintPreviewCommand.INSTANCE; } - @Nonnull + @NonNull public static JCommand applyDataFormat(@Nullable DataFormat dataFormat) { return new ApplyDataFormatCommand(dataFormat); } - @Nonnull + @NonNull public static JCommand editDataFormat() { return EditDataFormatCommand.INSTANCE; } diff --git a/nbdemetra-ui/src/main/java/ec/ui/commands/TsGridCommand.java b/nbdemetra-ui/src/main/java/ec/ui/commands/TsGridCommand.java index 9534cd711..c5c3ca594 100644 --- a/nbdemetra-ui/src/main/java/ec/ui/commands/TsGridCommand.java +++ b/nbdemetra-ui/src/main/java/ec/ui/commands/TsGridCommand.java @@ -24,7 +24,7 @@ import static ec.ui.interfaces.ITsGrid.ZOOM_PROPERTY; import ec.util.various.swing.JCommand; import java.util.EnumMap; -import javax.annotation.Nonnull; +import org.checkerframework.checker.nullness.qual.NonNull; /** * @@ -37,27 +37,27 @@ private TsGridCommand() { // static class } - @Nonnull + @NonNull public static JCommand transpose() { return TransposeCommand.INSTANCE; } - @Nonnull + @NonNull public static JCommand reverseChronology() { return ReverseChronologyCommand.INSTANCE; } - @Nonnull + @NonNull public static JCommand toggleMode() { return ToggleModeCommand.INSTANCE; } - @Nonnull + @NonNull public static JCommand applyMode(ITsGrid.Mode mode) { return ApplyModeCommand.VALUES.get(mode); } - @Nonnull + @NonNull public static JCommand applyZoomRatio(int zoomRatio) { return new ZoomRatioCommand(zoomRatio); } diff --git a/nbdemetra-ui/src/main/java/ec/ui/commands/TsGrowthChartCommand.java b/nbdemetra-ui/src/main/java/ec/ui/commands/TsGrowthChartCommand.java index 87f3129af..f44a9fc86 100644 --- a/nbdemetra-ui/src/main/java/ec/ui/commands/TsGrowthChartCommand.java +++ b/nbdemetra-ui/src/main/java/ec/ui/commands/TsGrowthChartCommand.java @@ -31,7 +31,7 @@ import java.awt.datatransfer.Transferable; import java.util.Arrays; import java.util.EnumMap; -import javax.annotation.Nonnull; +import org.checkerframework.checker.nullness.qual.NonNull; import javax.swing.BorderFactory; import javax.swing.JPanel; import org.openide.DialogDisplayer; @@ -48,17 +48,17 @@ private TsGrowthChartCommand() { // static class } - @Nonnull + @NonNull public static JCommand copyGrowthData() { return CopyGrowthData.INSTANCE; } - @Nonnull - public static JCommand applyGrowthKind(@Nonnull ITsGrowthChart.GrowthKind growthKind) { + @NonNull + public static JCommand applyGrowthKind(ITsGrowthChart.@NonNull GrowthKind growthKind) { return ApplyGrowthKind.VALUES.get(growthKind); } - @Nonnull + @NonNull public static JCommand editLastYears() { return EditLastYearsCommand.INSTANCE; } diff --git a/nbdemetra-ui/src/main/java/ec/ui/grid/JTsGrid.java b/nbdemetra-ui/src/main/java/ec/ui/grid/JTsGrid.java index d03107bf7..fa4cf4a3f 100644 --- a/nbdemetra-ui/src/main/java/ec/ui/grid/JTsGrid.java +++ b/nbdemetra-ui/src/main/java/ec/ui/grid/JTsGrid.java @@ -45,8 +45,8 @@ import java.beans.Beans; import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; -import javax.annotation.Nonnull; -import javax.annotation.Nullable; +import org.checkerframework.checker.nullness.qual.NonNull; +import org.checkerframework.checker.nullness.qual.Nullable; import javax.swing.DefaultComboBoxModel; import javax.swing.DefaultListCellRenderer; import javax.swing.JCheckBoxMenuItem; @@ -353,7 +353,7 @@ public void setShowBars(boolean showBars) { firePropertyChange(SHOW_BARS_PROPERTY, old, this.showBars); } - @Nonnull + @NonNull public TableCellRenderer getCellRenderer() { return cellRenderer; } @@ -374,7 +374,7 @@ public void setCrosshairVisible(boolean crosshairVisible) { firePropertyChange(CROSSHAIR_VISIBLE_PROPERTY, old, this.crosshairVisible); } - @Nonnull + @NonNull public ObsIndex getHoveredObs() { return hoveredObs; } @@ -604,7 +604,7 @@ private static final class CustomCellRenderer extends BarTableCellRenderer { private SwingColorSchemeSupport colorSchemeSupport; private boolean showBars; - public CustomCellRenderer(@Nonnull TableCellRenderer delegate) { + public CustomCellRenderer(@NonNull TableCellRenderer delegate) { super(false); setHorizontalAlignment(JLabel.TRAILING); setOpaque(true); @@ -616,7 +616,7 @@ public CustomCellRenderer(@Nonnull TableCellRenderer delegate) { this.showBars = false; } - void update(@Nonnull DataFormat dataFormat, @Nullable SwingColorSchemeSupport colorSchemeSupport, boolean showBars) { + void update(@NonNull DataFormat dataFormat, @Nullable SwingColorSchemeSupport colorSchemeSupport, boolean showBars) { this.valueFormatter = dataFormat.numberFormatter(); this.colorSchemeSupport = colorSchemeSupport; this.showBars = showBars; diff --git a/nbdemetra-ui/src/main/java/ec/ui/grid/JTsGridCommand.java b/nbdemetra-ui/src/main/java/ec/ui/grid/JTsGridCommand.java index 9062c9987..cc07e7e1a 100644 --- a/nbdemetra-ui/src/main/java/ec/ui/grid/JTsGridCommand.java +++ b/nbdemetra-ui/src/main/java/ec/ui/grid/JTsGridCommand.java @@ -22,7 +22,7 @@ import static ec.ui.grid.JTsGrid.USE_COLOR_SCHEME_PROPERTY; import ec.util.various.swing.JCommand; import java.awt.Component; -import javax.annotation.Nonnull; +import org.checkerframework.checker.nullness.qual.NonNull; /** * @@ -35,17 +35,17 @@ private JTsGridCommand() { // static } - @Nonnull + @NonNull public static JCommand toggleUseColorScheme() { return ToggleUseColorSchemeCommand.INSTANCE; } - @Nonnull + @NonNull public static JCommand toggleShowBars() { return ToggleShowBarsCommand.INSTANCE; } - @Nonnull + @NonNull public static JCommand toggleCrosshairVisibility() { return ToggleCrosshairVisibilityCommand.INSTANCE; } diff --git a/nbdemetra-ui/src/main/java/ec/ui/grid/MultiTsGridData.java b/nbdemetra-ui/src/main/java/ec/ui/grid/MultiTsGridData.java index ba92da2c7..ffad4cbd9 100644 --- a/nbdemetra-ui/src/main/java/ec/ui/grid/MultiTsGridData.java +++ b/nbdemetra-ui/src/main/java/ec/ui/grid/MultiTsGridData.java @@ -16,7 +16,6 @@ */ package ec.ui.grid; -import com.google.common.base.Supplier; import com.google.common.primitives.Doubles; import ec.tss.Ts; import ec.tss.TsCollection; @@ -31,8 +30,9 @@ import ec.util.grid.CellIndex; import java.util.ArrayList; import java.util.List; -import javax.annotation.Nonnegative; -import javax.annotation.Nonnull; +import java.util.function.Supplier; +import org.checkerframework.checker.index.qual.NonNegative; +import org.checkerframework.checker.nullness.qual.NonNull; /** * @@ -140,12 +140,12 @@ public void moveTo(int periodId, int seriesId) { obsIndex = currentSeries.convertRowIndexToModel(periodId); } - @Nonnegative + @NonNegative public int getObsIndex() { return obsIndex; } - @Nonnull + @NonNull public TsPeriod getPeriod() { return currentSeries.getPeriod(obsIndex); } diff --git a/nbdemetra-ui/src/main/java/ec/ui/grid/SingleTsGridData.java b/nbdemetra-ui/src/main/java/ec/ui/grid/SingleTsGridData.java index 8939354fd..bda89b6ba 100644 --- a/nbdemetra-ui/src/main/java/ec/ui/grid/SingleTsGridData.java +++ b/nbdemetra-ui/src/main/java/ec/ui/grid/SingleTsGridData.java @@ -16,16 +16,15 @@ */ package ec.ui.grid; -import com.google.common.base.Supplier; import ec.tss.TsCollection; import ec.tstoolkit.data.DescriptiveStatistics; import ec.tstoolkit.data.IReadDataBlock; -import ec.tstoolkit.data.Values; import ec.tstoolkit.timeseries.simplets.TsDomain; import ec.tstoolkit.timeseries.simplets.TsPeriod; import ec.ui.chart.DataFeatureModel; import ec.util.chart.ObsIndex; import ec.util.grid.CellIndex; +import java.util.function.Supplier; /** * diff --git a/nbdemetra-ui/src/main/java/ec/ui/grid/TsGridData.java b/nbdemetra-ui/src/main/java/ec/ui/grid/TsGridData.java index 782f7c986..80c423680 100644 --- a/nbdemetra-ui/src/main/java/ec/ui/grid/TsGridData.java +++ b/nbdemetra-ui/src/main/java/ec/ui/grid/TsGridData.java @@ -24,8 +24,8 @@ import ec.ui.interfaces.ITsGrid.Orientation; import ec.util.chart.ObsIndex; import ec.util.grid.CellIndex; -import javax.annotation.Nonnegative; -import javax.annotation.Nonnull; +import org.checkerframework.checker.index.qual.NonNegative; +import org.checkerframework.checker.nullness.qual.NonNull; /** * @@ -33,38 +33,38 @@ */ abstract class TsGridData { - @Nonnegative + @NonNegative abstract public int getColumnCount(); - @Nonnull + @NonNull abstract public String getColumnName(int j); - @Nonnegative + @NonNegative abstract public int getRowCount(); - @Nonnull + @NonNull abstract public String getRowName(int i); - @Nonnull + @NonNull abstract public TsGridObs getObs(int i, int j); - @Nonnull + @NonNull public TsGridData transpose() { return new Transposed(this); } - @Nonnull + @NonNull public TsGridData flipHorizontaly() { return new FlippedHorizontaly(this); } - @Nonnull + @NonNull public TsGridData flipVerticaly() { return new FlippedVerticaly(this); } - @Nonnull - public ObsIndex toObsIndex(@Nonnull CellIndex index) { + @NonNull + public ObsIndex toObsIndex(@NonNull CellIndex index) { if (CellIndex.NULL.equals(index)) { return ObsIndex.NULL; } @@ -75,15 +75,15 @@ public ObsIndex toObsIndex(@Nonnull CellIndex index) { return ObsIndex.valueOf(obs.getSeriesIndex(), obs.getIndex()); } - @Nonnull - abstract public CellIndex toCellIndex(@Nonnull ObsIndex index); + @NonNull + abstract public CellIndex toCellIndex(@NonNull ObsIndex index); - @Nonnull + @NonNull public static TsGridData empty() { return Empty.INSTANCE; } - @Nonnull + @NonNull public static TsGridData create(TsCollection col, int singleSeriesIndex, Orientation orientation, Chronology chronology, DataFeatureModel dataFeatureModel) { if (col.isEmpty() || (singleSeriesIndex != -1 && col.get(singleSeriesIndex).hasData() != TsStatus.Valid)) { return empty(); diff --git a/nbdemetra-ui/src/main/java/ec/ui/grid/TsGridObs.java b/nbdemetra-ui/src/main/java/ec/ui/grid/TsGridObs.java index 306cd9209..77650dca0 100644 --- a/nbdemetra-ui/src/main/java/ec/ui/grid/TsGridObs.java +++ b/nbdemetra-ui/src/main/java/ec/ui/grid/TsGridObs.java @@ -23,8 +23,8 @@ import ec.tstoolkit.timeseries.simplets.TsPeriod; import ec.ui.chart.DataFeatureModel; import java.util.function.Supplier; -import javax.annotation.Nonnegative; -import javax.annotation.Nonnull; +import org.checkerframework.checker.index.qual.NonNegative; +import org.checkerframework.checker.nullness.qual.NonNull; /** * @@ -33,24 +33,24 @@ @FlyweightPattern public abstract class TsGridObs { - @Nonnull + @NonNull abstract public TsDataTableInfo getInfo(); - @Nonnegative + @NonNegative abstract public int getSeriesIndex(); - @Nonnegative + @NonNegative abstract public int getIndex() throws IllegalStateException; - @Nonnull + @NonNull abstract public TsPeriod getPeriod() throws IllegalStateException; abstract public double getValue() throws IllegalStateException; - @Nonnull + @NonNull abstract public DescriptiveStatistics getStats() throws IllegalStateException; - abstract public boolean hasFeature(@Nonnull Ts.DataFeature feature) throws IllegalStateException; + abstract public boolean hasFeature(Ts.@NonNull DataFeature feature) throws IllegalStateException; // static final TsGridObs empty(int seriesIndex) { diff --git a/nbdemetra-ui/src/main/java/ec/ui/interfaces/ITsActionAble.java b/nbdemetra-ui/src/main/java/ec/ui/interfaces/ITsActionAble.java index b3985e6b0..051d5bc7a 100644 --- a/nbdemetra-ui/src/main/java/ec/ui/interfaces/ITsActionAble.java +++ b/nbdemetra-ui/src/main/java/ec/ui/interfaces/ITsActionAble.java @@ -17,7 +17,7 @@ package ec.ui.interfaces; import ec.nbdemetra.ui.tsaction.ITsAction; -import javax.annotation.Nullable; +import org.checkerframework.checker.nullness.qual.Nullable; /** * diff --git a/nbdemetra-ui/src/main/java/ec/ui/interfaces/ITsControl.java b/nbdemetra-ui/src/main/java/ec/ui/interfaces/ITsControl.java index 664e348ec..eb17247cc 100644 --- a/nbdemetra-ui/src/main/java/ec/ui/interfaces/ITsControl.java +++ b/nbdemetra-ui/src/main/java/ec/ui/interfaces/ITsControl.java @@ -2,7 +2,7 @@ import ec.nbdemetra.ui.awt.IPropertyChangeSource; import ec.tss.tsproviders.utils.DataFormat; -import javax.annotation.Nullable; +import org.checkerframework.checker.nullness.qual.Nullable; /** * Interface that should be implemented by every control that has to display diff --git a/nbdemetra-ui/src/main/java/ec/ui/list/JTsVariableList.java b/nbdemetra-ui/src/main/java/ec/ui/list/JTsVariableList.java index 4a0591586..70c8f2ef2 100644 --- a/nbdemetra-ui/src/main/java/ec/ui/list/JTsVariableList.java +++ b/nbdemetra-ui/src/main/java/ec/ui/list/JTsVariableList.java @@ -52,7 +52,7 @@ import java.awt.event.MouseEvent; import java.util.Collections; import java.util.List; -import javax.annotation.Nonnull; +import org.checkerframework.checker.nullness.qual.NonNull; import javax.swing.ActionMap; import javax.swing.InputMap; import javax.swing.InputVerifier; @@ -500,7 +500,7 @@ private static final class OpenWithItemCommand extends JCommand private final ITsAction tsAction; - public OpenWithItemCommand(@Nonnull ITsAction tsAction) { + public OpenWithItemCommand(@NonNull ITsAction tsAction) { this.tsAction = tsAction; } diff --git a/nbdemetra-ui/src/main/java/ec/ui/view/ARPView.java b/nbdemetra-ui/src/main/java/ec/ui/view/ARPView.java index 76c8dcb53..314941897 100644 --- a/nbdemetra-ui/src/main/java/ec/ui/view/ARPView.java +++ b/nbdemetra-ui/src/main/java/ec/ui/view/ARPView.java @@ -33,8 +33,8 @@ import java.util.ArrayList; import java.util.Collection; import java.util.List; -import javax.annotation.Nonnegative; -import javax.annotation.Nonnull; +import org.checkerframework.checker.index.qual.NonNegative; +import org.checkerframework.checker.nullness.qual.NonNull; import javax.swing.JMenu; import org.jfree.chart.ChartFactory; import org.jfree.chart.ChartPanel; @@ -90,7 +90,7 @@ public void reset() { } } - public void setData(@Nonnull String name, @Nonnegative int freq, @Nonnull IReadDataBlock values) { + public void setData(@NonNull String name, @NonNegative int freq, @NonNull IReadDataBlock values) { data = ARPData.copyOf(name, freq, values); onARPDataChange(); onColorSchemeChange(); diff --git a/nbdemetra-ui/src/main/java/ec/ui/view/tsprocessing/ComposedProcDocumentItemFactory.java b/nbdemetra-ui/src/main/java/ec/ui/view/tsprocessing/ComposedProcDocumentItemFactory.java index 338a49b7a..1f856f0ec 100644 --- a/nbdemetra-ui/src/main/java/ec/ui/view/tsprocessing/ComposedProcDocumentItemFactory.java +++ b/nbdemetra-ui/src/main/java/ec/ui/view/tsprocessing/ComposedProcDocumentItemFactory.java @@ -23,8 +23,9 @@ import ec.tstoolkit.utilities.InformationExtractor; import java.awt.BorderLayout; import java.awt.Component; +import java.util.Objects; import java.util.concurrent.ExecutionException; -import javax.annotation.Nonnull; +import org.checkerframework.checker.nullness.qual.NonNull; import javax.swing.JComponent; import javax.swing.JLabel; import javax.swing.SwingConstants; @@ -54,11 +55,11 @@ public class ComposedProcDocumentItemFactory extends * @param informationExtractor * @param itemUI */ - public ComposedProcDocumentItemFactory(@Nonnull Class documentType, @Nonnull Id itemId, @Nonnull InformationExtractor informationExtractor, @Nonnull ItemUI, I> itemUI) { - this.documentType = Preconditions.checkNotNull(documentType, "documentType"); - this.itemId = Preconditions.checkNotNull(itemId, "itemId"); - this.informationExtractor = Preconditions.checkNotNull(informationExtractor, "informationExtractor"); - this.itemUI = Preconditions.checkNotNull(itemUI, "itemUI"); + public ComposedProcDocumentItemFactory(@NonNull Class documentType, @NonNull Id itemId, @NonNull InformationExtractor informationExtractor, @NonNull ItemUI, I> itemUI) { + this.documentType = Objects.requireNonNull(documentType, "documentType"); + this.itemId = Objects.requireNonNull(itemId, "itemId"); + this.informationExtractor = Objects.requireNonNull(informationExtractor, "informationExtractor"); + this.itemUI = Objects.requireNonNull(itemUI, "itemUI"); this.async = false; } @@ -90,12 +91,12 @@ public JComponent getView(IProcDocumentView host, IProc return async ? new AsyncView(host, source) : itemUI.getView(host, info); } - @Nonnull + @NonNull public InformationExtractor getInformationExtractor() { return informationExtractor; } - @Nonnull + @NonNull public ItemUI getItemUI() { return itemUI; } diff --git a/nbdemetra-ui/src/main/java/ec/ui/view/tsprocessing/IProcDocumentView.java b/nbdemetra-ui/src/main/java/ec/ui/view/tsprocessing/IProcDocumentView.java index e48a457d6..1ca7fed8e 100644 --- a/nbdemetra-ui/src/main/java/ec/ui/view/tsprocessing/IProcDocumentView.java +++ b/nbdemetra-ui/src/main/java/ec/ui/view/tsprocessing/IProcDocumentView.java @@ -8,8 +8,8 @@ import ec.tstoolkit.utilities.Id; import ec.ui.interfaces.IDisposable; import java.util.List; -import javax.annotation.Nonnull; -import javax.annotation.Nullable; +import org.checkerframework.checker.nullness.qual.NonNull; +import org.checkerframework.checker.nullness.qual.Nullable; import javax.swing.Action; import javax.swing.Icon; import javax.swing.JComponent; @@ -20,13 +20,13 @@ */ public interface IProcDocumentView extends IDisposable { - @Nonnull + @NonNull D getDocument(); - @Nonnull + @NonNull ITsViewToolkit getToolkit(); - @Nonnull + @NonNull List getItems(); @Nullable diff --git a/nbdemetra-ui/src/main/java/ec/ui/view/tsprocessing/IProcDocumentViewFactory.java b/nbdemetra-ui/src/main/java/ec/ui/view/tsprocessing/IProcDocumentViewFactory.java index f9124c314..54b672a5f 100644 --- a/nbdemetra-ui/src/main/java/ec/ui/view/tsprocessing/IProcDocumentViewFactory.java +++ b/nbdemetra-ui/src/main/java/ec/ui/view/tsprocessing/IProcDocumentViewFactory.java @@ -7,8 +7,8 @@ import ec.tstoolkit.algorithm.IProcDocument; import ec.tstoolkit.utilities.Id; import ec.tstoolkit.utilities.InformationExtractor; -import javax.annotation.Nonnull; -import javax.annotation.Nullable; +import org.checkerframework.checker.nullness.qual.NonNull; +import org.checkerframework.checker.nullness.qual.Nullable; /** * @@ -16,15 +16,15 @@ */ public interface IProcDocumentViewFactory { - @Nonnull - IProcDocumentView create(@Nonnull D document); + @NonNull + IProcDocumentView create(@NonNull D document); @Deprecated void register( - @Nonnull Id id, + @NonNull Id id, @Nullable InformationExtractor info, - @Nonnull ItemUI, I> ui); + @NonNull ItemUI, I> ui); @Deprecated - void unregister(@Nonnull Id id); + void unregister(@NonNull Id id); } diff --git a/nbdemetra-ui/src/main/java/ec/ui/view/tsprocessing/ProcDocumentItemFactory.java b/nbdemetra-ui/src/main/java/ec/ui/view/tsprocessing/ProcDocumentItemFactory.java index 932894680..9cb96cfcd 100644 --- a/nbdemetra-ui/src/main/java/ec/ui/view/tsprocessing/ProcDocumentItemFactory.java +++ b/nbdemetra-ui/src/main/java/ec/ui/view/tsprocessing/ProcDocumentItemFactory.java @@ -7,8 +7,8 @@ import ec.tstoolkit.algorithm.IProcDocument; import ec.tstoolkit.design.ServiceDefinition; import ec.tstoolkit.utilities.Id; -import javax.annotation.Nonnull; -import javax.annotation.Nullable; +import org.checkerframework.checker.nullness.qual.NonNull; +import org.checkerframework.checker.nullness.qual.Nullable; import javax.swing.Action; import javax.swing.Icon; import javax.swing.JComponent; @@ -20,14 +20,14 @@ @ServiceDefinition(hasPosition = true) public abstract class ProcDocumentItemFactory { - @Nonnull + @NonNull abstract public Class getDocumentType(); - @Nonnull + @NonNull abstract public Id getItemId(); - @Nonnull - abstract public JComponent getView(@Nonnull IProcDocumentView host, @Nonnull IProcDocument doc) throws IllegalArgumentException; + @NonNull + abstract public JComponent getView(@NonNull IProcDocumentView host, @NonNull IProcDocument doc) throws IllegalArgumentException; @Nullable public Icon getIcon() { diff --git a/nbdemetra-ui/src/main/java/ec/ui/view/tsprocessing/ProcDocumentViewFactory.java b/nbdemetra-ui/src/main/java/ec/ui/view/tsprocessing/ProcDocumentViewFactory.java index 384089251..9449907b2 100644 --- a/nbdemetra-ui/src/main/java/ec/ui/view/tsprocessing/ProcDocumentViewFactory.java +++ b/nbdemetra-ui/src/main/java/ec/ui/view/tsprocessing/ProcDocumentViewFactory.java @@ -11,8 +11,8 @@ import ec.tstoolkit.utilities.InformationExtractor; import java.util.LinkedHashMap; import java.util.List; -import javax.annotation.Nonnull; -import javax.annotation.Nullable; +import org.checkerframework.checker.nullness.qual.NonNull; +import org.checkerframework.checker.nullness.qual.Nullable; import javax.swing.Action; import javax.swing.Icon; import javax.swing.JComponent; @@ -160,12 +160,12 @@ public void registerToolkit(@Nullable ITsViewToolkit toolkit) { toolkit_ = toolkit != null ? toolkit : TsViewToolkit.getInstance(); } - @Nonnull + @NonNull public ITsViewToolkit getToolkit() { return toolkit_; } - @Nonnull + @NonNull public List getItems() { return Lists.newArrayList(itemFactories.keySet()); } diff --git a/nbdemetra-ui/src/main/java/ec/util/chart/swing/ext/MatrixChartCommand.java b/nbdemetra-ui/src/main/java/ec/util/chart/swing/ext/MatrixChartCommand.java index a9e20a4dd..89c2abeab 100644 --- a/nbdemetra-ui/src/main/java/ec/util/chart/swing/ext/MatrixChartCommand.java +++ b/nbdemetra-ui/src/main/java/ec/util/chart/swing/ext/MatrixChartCommand.java @@ -10,7 +10,7 @@ import ec.util.chart.swing.ChartCommand; import java.awt.Toolkit; import java.awt.datatransfer.Transferable; -import javax.annotation.Nonnull; +import org.checkerframework.checker.nullness.qual.NonNull; import org.jfree.chart.ChartPanel; import org.jfree.chart.plot.XYPlot; import org.jfree.data.xy.XYDataset; @@ -36,8 +36,8 @@ public void execute(ChartPanel chartPanel) { * @param chartPanel the source of data * @return a non-null matrix */ - @Nonnull - abstract protected Matrix toMatrix(@Nonnull ChartPanel chartPanel); + @NonNull + abstract protected Matrix toMatrix(@NonNull ChartPanel chartPanel); /** * Creates a command that extracts a single series from a chart and put in @@ -47,7 +47,7 @@ public void execute(ChartPanel chartPanel) { * @param series * @return a non-null command */ - @Nonnull + @NonNull public static ChartCommand copySeries(int index, int series) { Preconditions.checkArgument(index >= 0, "index must be positive"); Preconditions.checkArgument(series >= 0, "series must be positive"); diff --git a/nbdemetra-ui/src/main/java/ec/util/completion/ext/QuickAutoCompletionSource.java b/nbdemetra-ui/src/main/java/ec/util/completion/ext/QuickAutoCompletionSource.java index fbdd5dee9..1b819c7f5 100644 --- a/nbdemetra-ui/src/main/java/ec/util/completion/ext/QuickAutoCompletionSource.java +++ b/nbdemetra-ui/src/main/java/ec/util/completion/ext/QuickAutoCompletionSource.java @@ -23,7 +23,7 @@ import ec.util.completion.AutoCompletionSources; import java.util.List; import java.util.stream.Collectors; -import javax.annotation.Nonnull; +import org.checkerframework.checker.nullness.qual.NonNull; /** * An implementation of AutoCompletionSource that allows to quickly construct a @@ -36,8 +36,8 @@ @Deprecated public abstract class QuickAutoCompletionSource extends AbstractAutoCompletionSource { - @Nonnull - public static QuickAutoCompletionSource from(@Nonnull Iterable list) { + @NonNull + public static QuickAutoCompletionSource from(@NonNull Iterable list) { return new QuickAutoCompletionSource() { @Override protected Iterable getAllValues() throws Exception { @@ -66,8 +66,8 @@ protected List getValues(String term, Iterable allValues) { * #matches(ec.util.completion.AbstractAutoCompletionSource.TermMatcher, * java.lang.Object) */ - @Nonnull - protected Predicate getFilter(@Nonnull String term) { + @NonNull + protected Predicate getFilter(@NonNull String term) { final TermMatcher termMatcher = createTermMatcher(term); return o -> matches(termMatcher, o); } @@ -78,7 +78,7 @@ protected Predicate getFilter(@Nonnull String term) { * * @return a new ordering */ - @Nonnull + @NonNull protected Ordering getSorter() { return Ordering.from(this); } diff --git a/nbdemetra-ui/src/main/java/ec/util/grid/swing/ext/TableGridCommand.java b/nbdemetra-ui/src/main/java/ec/util/grid/swing/ext/TableGridCommand.java index ad339ebd7..d96eafcd6 100644 --- a/nbdemetra-ui/src/main/java/ec/util/grid/swing/ext/TableGridCommand.java +++ b/nbdemetra-ui/src/main/java/ec/util/grid/swing/ext/TableGridCommand.java @@ -25,7 +25,7 @@ import ec.util.various.swing.JCommand; import java.awt.Toolkit; import java.awt.datatransfer.Transferable; -import javax.annotation.Nonnull; +import org.checkerframework.checker.nullness.qual.NonNull; import javax.swing.ListSelectionModel; /** @@ -41,23 +41,23 @@ public void execute(JGrid grid) { Toolkit.getDefaultToolkit().getSystemClipboard().setContents(t, null); } - @Nonnull + @NonNull public static TableGridCommand copyAll(boolean rowHeader, boolean columnHeader) { return new CopyAllCommand(rowHeader, columnHeader); } - @Nonnull + @NonNull public static TableGridCommand copySelection(boolean rowHeader, boolean columnHeader) { return new CopySelectionCommand(rowHeader, columnHeader); } - @Nonnull + @NonNull private static TableGridCommand copyRange(Range rowRange, Range columnRange, boolean rowHeader, boolean columnHeader) { return new CopyRangeCommand(rowRange, columnRange, rowHeader, columnHeader); } - @Nonnull - abstract public Table toTable(@Nonnull JGrid grid); + @NonNull + abstract public Table toTable(@NonNull JGrid grid); // private static Table copy(GridModel model, int firstRow, int firstColumn, int lastRow, int lastColumn, boolean rowHeader, boolean columnHeader) { diff --git a/nbdemetra-ui/src/main/java/ec/util/various/swing/ext/FontAwesomeUtils.java b/nbdemetra-ui/src/main/java/ec/util/various/swing/ext/FontAwesomeUtils.java index a4c096d80..d18cb6648 100644 --- a/nbdemetra-ui/src/main/java/ec/util/various/swing/ext/FontAwesomeUtils.java +++ b/nbdemetra-ui/src/main/java/ec/util/various/swing/ext/FontAwesomeUtils.java @@ -23,7 +23,7 @@ import java.beans.BeanInfo; import java.util.HashMap; import java.util.Map; -import javax.annotation.Nonnull; +import org.checkerframework.checker.nullness.qual.NonNull; import javax.swing.Icon; /** @@ -50,7 +50,7 @@ public static float toSize(int type) throws IllegalArgumentException { } @OnEDT - @Nonnull + @NonNull public static Color toColor(int type) throws IllegalArgumentException { switch (type) { case BeanInfo.ICON_COLOR_16x16: @@ -63,14 +63,14 @@ public static Color toColor(int type) throws IllegalArgumentException { } @OnEDT - @Nonnull - public static Icon getIcon(@Nonnull FontAwesome fa, int type) throws IllegalArgumentException { + @NonNull + public static Icon getIcon(@NonNull FontAwesome fa, int type) throws IllegalArgumentException { return getIcon(fa, toColor(type), toSize(type)); } @OnEDT - @Nonnull - public static Image getImage(@Nonnull FontAwesome fa, int type) throws IllegalArgumentException { + @NonNull + public static Image getImage(@NonNull FontAwesome fa, int type) throws IllegalArgumentException { return getImage(fa, toColor(type), toSize(type)); } diff --git a/nbdemetra-ui/src/main/java/internal/FrozenTsHelper.java b/nbdemetra-ui/src/main/java/internal/FrozenTsHelper.java index 732df8b30..2a093f4d2 100644 --- a/nbdemetra-ui/src/main/java/internal/FrozenTsHelper.java +++ b/nbdemetra-ui/src/main/java/internal/FrozenTsHelper.java @@ -23,8 +23,8 @@ import java.time.LocalDateTime; import java.time.format.DateTimeFormatter; import java.util.Locale; -import javax.annotation.Nonnull; -import javax.annotation.Nullable; +import org.checkerframework.checker.nullness.qual.NonNull; +import org.checkerframework.checker.nullness.qual.Nullable; /** * @@ -37,7 +37,7 @@ private FrozenTsHelper() { } @Nullable - public static String getSource(@Nonnull Ts ts) { + public static String getSource(@NonNull Ts ts) { String source = ts.getMoniker().getSource(); if (source != null) { return source; @@ -50,13 +50,13 @@ public static String getSource(@Nonnull Ts ts) { } @Nullable - private static String getSource(@Nonnull MetaData md) { + private static String getSource(@NonNull MetaData md) { String result = md.get(MetaData.SOURCE); return result != null ? result : md.get(Ts.SOURCE_OLD); } @Nullable - private static String getId(@Nonnull MetaData md) { + private static String getId(@NonNull MetaData md) { String result = md.get(MetaData.ID); return result != null ? result : md.get(Ts.ID_OLD); } @@ -64,19 +64,19 @@ private static String getId(@Nonnull MetaData md) { private static final DateTimeFormatter TIMESTAMP_FORMATTER = DateTimeFormatter.ofPattern("EEE MMM dd HH:mm:ss zzz yyyy", Locale.ROOT); @Nullable - public static LocalDateTime getTimestamp(@Nonnull Ts ts) { + public static LocalDateTime getTimestamp(@NonNull Ts ts) { MetaData md = ts.getMetaData(); return md != null ? getTimestamp(md) : null; } @Nullable - private static LocalDateTime getTimestamp(@Nonnull MetaData md) { + private static LocalDateTime getTimestamp(@NonNull MetaData md) { String dateAsString = md.get(MetaData.DATE); return dateAsString != null ? LocalDateTime.parse(dateAsString, TIMESTAMP_FORMATTER) : null; } @Nullable - public static TsMoniker getOriginalMoniker(@Nonnull TsMoniker moniker) { + public static TsMoniker getOriginalMoniker(@NonNull TsMoniker moniker) { if (!moniker.isAnonymous()) { return moniker; } diff --git a/nbdemetra-ui/src/main/java/internal/RandomTsBuilder.java b/nbdemetra-ui/src/main/java/internal/RandomTsBuilder.java index 46a86d176..d1b9767d3 100644 --- a/nbdemetra-ui/src/main/java/internal/RandomTsBuilder.java +++ b/nbdemetra-ui/src/main/java/internal/RandomTsBuilder.java @@ -32,7 +32,7 @@ import ec.tstoolkit.timeseries.simplets.TsPeriod; import java.util.Objects; import java.util.function.BiFunction; -import javax.annotation.Nonnull; +import org.checkerframework.checker.nullness.qual.NonNull; /** * @@ -65,7 +65,7 @@ public int getObsCount() { return obsCount; } - @Nonnull + @NonNull public IRandomNumberGenerator getRng() { return rng; } @@ -74,55 +74,55 @@ public int getForecastCount() { return forecastCount; } - @Nonnull + @NonNull public TsStatus getStatus() { return status; } - @Nonnull - public RandomTsBuilder withName(@Nonnull String name) { + @NonNull + public RandomTsBuilder withName(@NonNull String name) { this.name = Objects.requireNonNull(name); return this; } - @Nonnull - public RandomTsBuilder withStatus(@Nonnull TsStatus status) { + @NonNull + public RandomTsBuilder withStatus(@NonNull TsStatus status) { this.status = Objects.requireNonNull(status); return this; } - @Nonnull - public RandomTsBuilder withStart(@Nonnull TsPeriod start) { + @NonNull + public RandomTsBuilder withStart(@NonNull TsPeriod start) { this.start = Objects.requireNonNull(start); return this; } - @Nonnull - public RandomTsBuilder withGenerator(@Nonnull BiFunction generator) { + @NonNull + public RandomTsBuilder withGenerator(@NonNull BiFunction generator) { this.generator = Objects.requireNonNull(generator); return this; } - @Nonnull + @NonNull public RandomTsBuilder withForecastCount(int forecastCount) { this.forecastCount = forecastCount; return this; } - @Nonnull + @NonNull public RandomTsBuilder withMissingCount(int missingCount) { this.missingCount = missingCount; return this; } - @Nonnull + @NonNull public RandomTsBuilder withObsCount(int obsCount) { this.obsCount = obsCount; return this; } - @Nonnull - public RandomTsBuilder withRng(@Nonnull IRandomNumberGenerator rng) { + @NonNull + public RandomTsBuilder withRng(@NonNull IRandomNumberGenerator rng) { this.rng = Objects.requireNonNull(rng); return this; } diff --git a/nbdemetra-ui/src/main/resources/ec/nbdemetra/ui/layer.xml b/nbdemetra-ui/src/main/resources/ec/nbdemetra/ui/layer.xml index 070781f69..0b87f1351 100644 --- a/nbdemetra-ui/src/main/resources/ec/nbdemetra/ui/layer.xml +++ b/nbdemetra-ui/src/main/resources/ec/nbdemetra/ui/layer.xml @@ -53,6 +53,10 @@ + + + + diff --git a/pom.xml b/pom.xml index 5196a3aff..f171f189e 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ eu.europa.ec.joinup.sat nbdemetra-parent - 2.2.2 + 2.2.3 pom NbDemetra - Parent @@ -18,22 +18,8 @@ - - UTF-8 - 1.8 - 1.8 - 3.8.0 - 3.1.0 - 3.0.1 - 3.0.0-M2 - 3.0.0-M1 - 1.16 - 3.0.0 - 3.14 nbdemetra - - - RELEASE82 + RELEASE112 ${project.version} @@ -137,7 +123,57 @@ org.netbeans.api org-netbeans-modules-javahelp - ${netbeans.version} + RELEASE80 + + + org.netbeans.api + org-netbeans-api-progress + + + org.netbeans.api + org-netbeans-api-progress-nb + + + org.netbeans.api + org-netbeans-spi-quicksearch + + + org.netbeans.api + org-openide-awt + + + org.netbeans.api + org-openide-filesystems + + + org.netbeans.api + org-openide-loaders + + + org.netbeans.api + org-openide-modules + + + org.netbeans.api + org-openide-nodes + + + org.netbeans.api + org-openide-util-ui + + + org.netbeans.api + org-openide-util + + + org.netbeans.api + org-openide-util-lookup + + + org.netbeans.api + org-openide-windows + + org.netbeans.api @@ -249,6 +285,11 @@ nbdemetra-anomalydetection ${project.version} + + ${project.groupId} + nbdemetra-utils + ${project.version} + @@ -261,166 +302,153 @@ - - - - - org.apache.maven.plugins - maven-jar-plugin - ${maven-jar-plugin.version} - - - - ${project.build.outputDirectory}/META-INF/MANIFEST.MF - - - - - org.apache.maven.plugins - maven-deploy-plugin - ${maven-deploy-plugin.version} - - - org.apache.maven.plugins - maven-compiler-plugin - ${maven-compiler-plugin.version} - - - org.apache.maven.plugins - maven-source-plugin - ${maven-source-plugin.version} - - - verify - - jar-no-fork - - - - - - org.apache.maven.plugins - maven-enforcer-plugin - ${maven-enforcer-plugin.version} - - - enforce - - - - - - - enforce - - - - - - org.codehaus.mojo - findbugs-maven-plugin - ${findbugs-maven-plugin.version} - - true - true - true - Max - Low - - - - org.codehaus.mojo - nbm-maven-plugin - ${nbm-maven-plugin.version} - true - - ${brandingToken} - ${brandingToken} - - - - org.codehaus.mojo - animal-sniffer-maven-plugin - ${animal-sniffer-maven-plugin.version} - - - org.codehaus.mojo.signature - java18 - 1.0 - - - - - check-java18 - test - - check - - - - - - - - - org.apache.maven.plugins - maven-jar-plugin - - - org.apache.maven.plugins - maven-compiler-plugin - - - org.apache.maven.plugins - maven-enforcer-plugin - - - org.codehaus.mojo - findbugs-maven-plugin - - - org.codehaus.mojo - animal-sniffer-maven-plugin - - - org.codehaus.mojo - nbm-maven-plugin - - - - - + + base-java8 - 11 + + !skipBaseJava8 + - - - javax.activation - javax.activation-api - 1.2.0 - provided - - - javax.xml.bind - jaxb-api - 2.4.0-b180830.0359 - provided - - - org.glassfish.jaxb - jaxb-runtime - 2.4.0-b180830.0438 - provided - - - javax.annotation - javax.annotation-api - 1.3.2 - provided - - + + UTF-8 + 1.8 + 1.8 + + + + + org.apache.maven.plugins + maven-compiler-plugin + 3.8.1 + + + org.apache.maven.plugins + maven-jar-plugin + 3.2.0 + + + org.apache.maven.plugins + maven-deploy-plugin + 3.0.0-M1 + + + + + + + + enforce-java8-api + + [11,) + + + 8 + + + + + + enforce-dependency-rules + + + !skipEnforceDependencyRules + + + + + + org.apache.maven.plugins + maven-enforcer-plugin + 3.0.0-M3 + + + enforce + + + + 3.3.9 + + + + true + + + + + enforce + + + + + + + + + + + enforce-modern-api + + + !skipEnforceModernAPI + + + + + + org.gaul + modernizer-maven-plugin + 2.1.0 + + 1.8 + + com/google/common/base/Optional.* + + + com/google/common/base/Function + + + + + modernizer + verify + + modernizer + + + + + + + + + + + optional-checks + + + + org.jacoco + jacoco-maven-plugin + 0.8.5 + + + + prepare-agent + + + + report + prepare-package + + report + + + + + + @@ -434,9 +462,23 @@ + + org.apache.maven.plugins + maven-deploy-plugin + 3.0.0-M1 + org.apache.maven.plugins maven-source-plugin + 3.2.1 + + + verify + + jar-no-fork + + + @@ -453,19 +495,59 @@ + + org.apache.maven.plugins + maven-deploy-plugin + 3.0.0-M1 + org.apache.maven.plugins maven-source-plugin + 3.2.1 + + + verify + + jar-no-fork + + + - + + + + + org.apache.maven.plugins + maven-jar-plugin + + + + ${project.build.outputDirectory}/META-INF/MANIFEST.MF + + + + + org.apache.netbeans.utilities + nbm-maven-plugin + 4.5 + true + + false + ${brandingToken} + ${brandingToken} + + + + + - netbeans-releases - http://bits.netbeans.org/nexus/content/groups/netbeans/ + netbeans-releases-mirror + https://repo.spring.io/plugins-release false @@ -484,12 +566,5 @@ true - - projectlombok.org - https://projectlombok.org/edge-releases - - true - -